diff options
author | Ken Moore <moorekou@gmail.com> | 2016-06-27 13:03:08 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2016-06-27 13:03:08 -0400 |
commit | 190781e33b6a94b0708a76fa3a2b8d6a50bf7107 (patch) | |
tree | 38985cb065da40d4962f9a7ff9a69b5e4955d8f0 /src-qt5/core-utils/lumina-config/pages/page_main.cpp | |
parent | Switch back to the old UI for now (new one still not finished yet). (diff) | |
download | lumina-190781e33b6a94b0708a76fa3a2b8d6a50bf7107.tar.gz lumina-190781e33b6a94b0708a76fa3a2b8d6a50bf7107.tar.bz2 lumina-190781e33b6a94b0708a76fa3a2b8d6a50bf7107.zip |
Add in the search capabilities within the new lumina-config UI.
Diffstat (limited to 'src-qt5/core-utils/lumina-config/pages/page_main.cpp')
-rw-r--r-- | src-qt5/core-utils/lumina-config/pages/page_main.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src-qt5/core-utils/lumina-config/pages/page_main.cpp b/src-qt5/core-utils/lumina-config/pages/page_main.cpp index c853f06c..02065b78 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_main.cpp +++ b/src-qt5/core-utils/lumina-config/pages/page_main.cpp @@ -14,6 +14,7 @@ page_main::page_main(QWidget *parent) : PageWidget(parent), ui(new Ui::page_main()){ ui->setupUi(this); connect(ui->treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(itemTriggered(QTreeWidgetItem*)) ); + connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(searchChanged(QString)) ); } page_main::~page_main(){ @@ -36,13 +37,17 @@ void page_main::UpdateItems(QString search){ apps->setIcon(0, LXDG::findIcon("preferences-desktop-filetype-association","")); apps->setText(0, tr("Application Settings")); //Now go through and add in the known pages for each category + QStringList SL = search.split(" "); //search list for(int i=0; i<INFO.length(); i++){ if(!search.isEmpty() ){ //See if this item needs to be included or not QStringList info; info << INFO[i].name.split(" ") << INFO[i].title.split(" ") << INFO[i].comment.split(" ") << INFO[i].search_tags; info.removeDuplicates(); //remove any duplicate terms/info first - info << search.split(" "); //add the terms we want to search for - if(0<info.removeDuplicates()){ continue; } //no duplicates between search terms and available info + bool ok = true; + for(int s=0; s<SL.length() && ok; s++){ + ok = !info.filter(SL[s]).isEmpty(); + } + if(!ok){ continue; } //no duplicates between search terms and available info } qDebug() << "Item Found:" << INFO[i].id << INFO[i].title; QTreeWidgetItem *it = new QTreeWidgetItem(); @@ -58,10 +63,10 @@ void page_main::UpdateItems(QString search){ else{ ui->treeWidget->addTopLevelItem(it); } } //Now add the categories to the tree widget if they are non-empty - if(interface->childCount()>0){ ui->treeWidget->addTopLevelItem(interface); } - if(appearance->childCount()>0){ ui->treeWidget->addTopLevelItem(appearance); } - if(session->childCount()>0){ ui->treeWidget->addTopLevelItem(session); } - if(apps->childCount()>0){ ui->treeWidget->addTopLevelItem(apps); } + if(interface->childCount()>0){ ui->treeWidget->addTopLevelItem(interface); interface->setExpanded(true); } + if(appearance->childCount()>0){ ui->treeWidget->addTopLevelItem(appearance); appearance->setExpanded(true); } + if(session->childCount()>0){ ui->treeWidget->addTopLevelItem(session); session->setExpanded(true); } + if(apps->childCount()>0){ ui->treeWidget->addTopLevelItem(apps); apps->setExpanded(true); } } //================ @@ -93,3 +98,7 @@ void page_main::itemTriggered(QTreeWidgetItem *it){ emit ChangePage(it->whatsThis(0)); } } + +void page_main::searchChanged(QString txt){ + UpdateItems(txt.simplified()); +} |