[PC-BSD Commits] r16098 - pcbsd/current/src-qt4/pc-softwaremanager
svn at pcbsd.org
svn at pcbsd.org
Fri Mar 30 06:37:46 PDT 2012
Author: kenmoore
Date: 2012-03-30 13:37:45 +0000 (Fri, 30 Mar 2012)
New Revision: 16098
Modified:
pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbibrowser.cpp
Log:
Update AppCafe with Size and Type display for a given PBI. Also make the search functionality "smarter" by displaying PBI's with a match in the name first.
Modified: pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbibrowser.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbibrowser.cpp 2012-03-30 09:15:33 UTC (rev 16097)
+++ pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbibrowser.cpp 2012-03-30 13:37:45 UTC (rev 16098)
@@ -391,10 +391,9 @@
pLic->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
layoutBrowser->addWidget(pLic, 3, 1);
-/*
// Display the Type
QLabel *pType = new QLabel("<b>" + tr("Type:") + "</b> " + pbiAvail->getType(pbiNum) );
- pType->setAlignment(Qt::AlightLeft);
+ pType->setAlignment(Qt::AlignLeft);
pType->setWordWrap(true);
pType->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
layoutBrowser->addWidget(pType, 4, 0);
@@ -405,13 +404,12 @@
pSize->setWordWrap(true);
pSize->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
layoutBrowser->addWidget(pSize, 4, 1);
-*/
// Add a <hr> spacer
QLabel *bottomLine = new QLabel();
bottomLine->setFrameStyle(QFrame::HLine);
bottomLine->setFixedHeight(12);
- layoutBrowser->addWidget(bottomLine, 4, 0, 1, 2);
+ layoutBrowser->addWidget(bottomLine, 5, 0, 1, 2);
// Create the PBI description
QTextBrowser *pDesc = new QTextBrowser();
@@ -422,7 +420,7 @@
pDesc->setFixedHeight(120);
pDesc->setBackgroundRole(QPalette::NoRole);
pDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
- layoutBrowser->addWidget(pDesc, 5, 0, 1, 2);
+ layoutBrowser->addWidget(pDesc, 6, 0, 1, 2);
// Now display the PBI on the top widget
@@ -954,7 +952,11 @@
// Build the display of PBIs for this cat
found=false;
int pTot = pbiAvail->count();
+ int nFound = 0;
+ QList<int> nMatch, kMatch, dMatch;
+ //Find and sort all the PBI's that fit the search
for( int i = 0; i < pTot; i++) {
+ //Find a PBI for a match
if ( pbiAvail->getRepo(i) != pbiRepos->getID(curRepo) )
continue;
if ( pbiAvail->getKeys(i).indexOf(needle, 0, Qt::CaseInsensitive ) == -1 && \
@@ -962,8 +964,40 @@
pbiAvail->getName(i).indexOf(needle, 0, Qt::CaseInsensitive) == -1 )
continue;
+ nFound++;
+ //Sort the PBI into the proper grouping
+ if( pbiAvail->getName(i).toLower() == needle.toLower() ){ nMatch.prepend(i); } //exact match - place at top of list
+ else if( pbiAvail->getName(i).toLower().contains(needle.toLower()) ){ nMatch.append(i); } //name contains search term
+ else if( pbiAvail->getKeys(i).toLower().contains(needle.toLower()) ){ kMatch.append(i); } //keys contain search term
+ else if( pbiAvail->getDesc(i).toLower().contains(needle.toLower()) ){ dMatch.append(i); } //description contains search term
+ else{ nFound--; } //add better "else" handling later - do nothing now
+
+ }
+ //Display all the PBI's that match the search criteria
+ for( int j=0; j<nFound; j++){
+ //Get the "i" value for the chosen PBI
+ int i;
+ int nn = nMatch.count();
+ int nk = kMatch.count();
+ if( j < nn ){ i = nMatch[j]; } //Display Name Matches First
+ else if ( j < (nn+nk) ){ i = kMatch[j-nn]; } //Display Key Matches Second
+ else{ i = dMatch[j-nn-nk]; } // Display Description Matches Last
- found = true;
+ if(j==0){
+ found = true; //PBI's have been found -- only set this once
+ if(nn > 0){ //If there are Name Matches
+ //Add a header for "Best Matches"
+ QLabel *myLine = new QLabel( "-----<b>"+tr("Best Matches")+"</b>-----" );
+ myLine->setFixedHeight(12);
+ layoutBrowser->addWidget(myLine);
+ }
+ }else if( nn!=0 && j==(nn+1) && j<(nFound-1) ){ //After the last Name match and more matches available
+ //Add a header for "Other Matches"
+ QLabel *myLine = new QLabel( "-----<b>"+tr("Other Matches")+"</b>-----" );
+ myLine->setFixedHeight(12);
+ layoutBrowser->addWidget(myLine);
+ }
+
// Create the first horizontal box with icon / name
clickedWidget *pbiWidget = new clickedWidget(0, pbiAvail->getName(i));
QGridLayout *grid1 = new QGridLayout();
More information about the Commits
mailing list