Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
55 src-qt4/pc-pkgmanager/mainWin.cpp
@@ -39,6 +39,7 @@ void mainWin::ProgramInit(QString ch)
connect(action_Quit, SIGNAL( triggered(bool) ), this, SLOT( slotCloseClicked() ) );
connect(action_Basic, SIGNAL( triggered(bool) ), this, SLOT( slotViewChanged() ) );
connect(action_Advanced, SIGNAL( triggered(bool) ), this, SLOT( slotViewChanged() ) );
+ connect(tool_search, SIGNAL( clicked() ), this, SLOT( slotSearchPackages() ) );
// Setup the action group
viewGroup = new QActionGroup(this);
@@ -106,6 +107,58 @@ void mainWin::slotApplyClicked() {
}
+void mainWin::slotSearchPackages(){
+ QString pkgSearch = line_search->text();
+ if(pkgSearch.isEmpty()){ return; }
+ qDebug() << "Search for package:" <<pkgSearch;
+ //Get the pointer to the proper treewidget
+ QTreeWidget *TW = treeNGPkgs;
+ if( stackedPkgView->currentIndex() == 0 ){ TW = treeMetaPkgs; }
+ //Make sure the tree widget is not empty
+ if(TW->topLevelItemCount() < 2){ return; }
+ //iterate through the tree widget, starting at the current selection
+ QTreeWidgetItem *CI = TW->currentItem();
+ bool found=false; bool atTop=false;
+ if(CI == 0){ CI = TW->topLevelItem(0); atTop=true; }
+ //Get the starting index (parent and child)
+ QTreeWidgetItem *PI = CI->parent();
+ int startParent=0; int startChild=0;
+ if(PI == 0){ startParent = TW->indexOfTopLevelItem(CI); } //startchild == 0
+ else{ startParent = TW->indexOfTopLevelItem(PI); startChild = PI->indexOfChild(CI) +1; }
+ //Now iterate over the tree, only looking at the actual packages (not categories)
+ found = performSearch(pkgSearch, TW, startParent, startChild);
+ if(!found && !atTop){
+ //Ask whether to restart the search at the top
+ if(QMessageBox::Yes == QMessageBox::question(this,tr("No Search Results"),tr("Do you want to continue the search from the top?"),QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ){
+ //Restart the search from the top
+ found = performSearch(pkgSearch, TW, 0, 0);
+ }
+ }
+ if(!found){
+ QMessageBox::information(this, tr("No Search Results"), tr("No packages could be found with that search term. Please adjust it and try again.") );
+ }
+ qDebug() << " - Search Finished";
+}
+
+bool mainWin::performSearch(QString pkgSearch, QTreeWidget *TW, int startParent, int startChild){
+ //Iterate over the Tree
+ bool found=false;
+ for(int p=startParent; p<TW->topLevelItemCount(); p++){
+ for(int c=startChild; c<TW->topLevelItem(p)->childCount(); c++){
+ QTreeWidgetItem *CI = TW->topLevelItem(p)->child(c);
+ if(CI->text(0).contains(pkgSearch, Qt::CaseInsensitive)){
+ TW->setCurrentItem(CI);
+ TW->scrollToItem(CI);
+ found=true;
+ break;
+ }
+ }
+ startChild=0; //reset this for the next top level item
+ if(found){ break; }
+ }
+ return found;
+}
+
void mainWin::checkMPKGUpdates() {
QString line, tmp, name, pkgname, pkgover, pkgnver;
@@ -672,7 +725,6 @@ void mainWin::addNGItems()
catItem->addChild(pkgItem);
}
-
}
// Lets prompt user, and do it!
@@ -899,6 +951,7 @@ void mainWin::addTreeItems(QString parent)
// Now look for any possible children
addTreeItems(metaPkgList.at(z).at(0));
}
+
}
// Check if a meta-pkg is installed
View
4 src-qt4/pc-pkgmanager/mainWin.h
@@ -48,6 +48,7 @@ private slots:
void slotFinishLoadingMetaPkgs();
void slotGetPackageDataOutput();
void slotApplyClicked();
+ void slotSearchPackages();
// Package updates
void slotRescanPkgsClicked();
@@ -79,6 +80,9 @@ private slots:
bool pkgHasFailed;
QString getConflictDetailText();
+ //Search Iteration
+ bool performSearch(QString pkgSearch, QTreeWidget *TW, int startParent, int startChild);
+
// Updates
void doUpdates();
bool sanityCheck();
View
27 src-qt4/pc-pkgmanager/mainWin.ui
@@ -181,6 +181,27 @@
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
+ <widget class="QLineEdit" name="line_search">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="tool_search">
+ <property name="text">
+ <string>Search</string>
+ </property>
+ <property name="icon">
+ <iconset resource="pc-pkgmanager.qrc">
+ <normaloff>:/search.png</normaloff>:/search.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="spacer2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -385,6 +406,10 @@ p, li { white-space: pre-wrap; }
<property name="text">
<string>&amp;Close</string>
</property>
+ <property name="icon">
+ <iconset resource="pc-pkgmanager.qrc">
+ <normaloff>:/window-close.png</normaloff>:/window-close.png</iconset>
+ </property>
</widget>
</item>
</layout>
@@ -397,7 +422,7 @@ p, li { white-space: pre-wrap; }
<x>0</x>
<y>0</y>
<width>800</width>
- <height>21</height>
+ <height>20</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
View
10 src-qt4/pc-pkgmanager/pc-pkgmanager.qrc
@@ -1,6 +1,8 @@
<RCC>
- <qresource prefix="/">
- <file>view-refresh.png</file>
- <file>pkgmanager.png</file>
- </qresource>
+ <qresource prefix="/">
+ <file>window-close.png</file>
+ <file>search.png</file>
+ <file>view-refresh.png</file>
+ <file>pkgmanager.png</file>
+ </qresource>
</RCC>

No commit comments for this range

Something went wrong with that request. Please try again.