[PC-BSD Commits] r9585 - pcbsd/current/src-qt4/pc-softwaremanager

svn at pcbsd.org svn at pcbsd.org
Wed Mar 9 10:57:42 PST 2011


Author: kris
Date: 2011-03-09 10:57:42 -0800 (Wed, 09 Mar 2011)
New Revision: 9585

Modified:
   pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.h
   pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbibrowser.cpp
   pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbiupdate.cpp
Log:

Cleanup the pbi browser window display
Added widget of latest 6 applications
Fixed bug displaying update version



Modified: pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.h
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.h	2011-03-09 17:52:32 UTC (rev 9584)
+++ pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.h	2011-03-09 18:57:42 UTC (rev 9585)
@@ -123,17 +123,18 @@
     QStringList histType;
     QStringList histName;
 
+    QStringList getLatestPBIs(int, QString);
     void displayRepos();
     void displayCategories(bool history);
     void displayCat(QString cat, bool history);
     void displayPBI(QString pbi, bool history, QString rID = QString());
     void displaySoftwareLoading();
     void clearSoftwareBrowser();
-
     void loadAvailPBIs();
     void loadCategories();
     void loadRepos();
     void updateHistory(QString type, QString name);
+    QWidget* getLatestPBIWidget(int);
     // End PBI Browser
    
     QString getLineFromCommandOutput( QString command );

Modified: pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbibrowser.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbibrowser.cpp	2011-03-09 17:52:32 UTC (rev 9584)
+++ pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbibrowser.cpp	2011-03-09 18:57:42 UTC (rev 9585)
@@ -184,8 +184,7 @@
 	}
 		
 	if ( found ) {
-		QSpacerItem *space = new QSpacerItem(50,50, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
-		layoutBrowser->insertSpacerItem(-1, space);
+		layoutBrowser->setAlignment(Qt::AlignTop);
 		myWidget->setLayout(layoutBrowser);
 		scrollAreaPBI->setWidget(myWidget);
 	} else {
@@ -404,11 +403,10 @@
 	QVBoxLayout *topLayout = new QVBoxLayout();
 	topLayout->addWidget(myWidget);
 
-	// Create the spacer to push to the top
-	QSpacerItem *tSpace = new QSpacerItem(50,50, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
-	topLayout->insertSpacerItem(-1, tSpace);
+	// Align us to the top of the widget
+	topLayout->setAlignment(Qt::AlignTop);
+
 	topWidget->setLayout(topLayout);
-
 	scrollAreaPBI->setWidget(topWidget);
 }
 
@@ -433,22 +431,18 @@
 	clickedWidget *hWidget = new clickedWidget(0, pbiRepos->getID(curRepo));
 	QGridLayout *hGrid = new QGridLayout();
 	QLabel *hLabel = new QLabel();
-	hLabel->setText("<b>" + pbiRepos->getDesc(curRepo) + "</b>");
+	hLabel->setText("<b> - Latest Releases - </b>");
 	hLabel->setAlignment(Qt::AlignHCenter);
 	hGrid->addWidget(hLabel, 0, 0);
 
-	QLabel *hLabel2 = new QLabel();
-	hLabel2->setText("- Latest releases -");
-	hLabel2->setAlignment(Qt::AlignHCenter);
-	hGrid->addWidget(hLabel2, 1, 0);
+	// Display the widget of latest PBI icons
+	hGrid->addWidget(getLatestPBIWidget(curRepo), 1, 0);
 
-	// TODO, 6 most recent apps list here
-
 	// TODO, stylize this header a bit more
 	hGrid->setRowMinimumHeight(2, 20);
 
 	QLabel *catHeader = new QLabel();
-	catHeader->setText(tr("Categories"));
+	catHeader->setText("<b> - " + tr("Categories") + " - </b>");
 	catHeader->setAlignment(Qt::AlignHCenter);
 	hGrid->addWidget(catHeader, 3, 0);
 
@@ -511,8 +505,7 @@
 		layoutBrowser->addWidget(myLine);
 	}
 	
-	QSpacerItem *space = new QSpacerItem(0,0, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
-	layoutBrowser->insertSpacerItem(-1, space);
+	layoutBrowser->setAlignment(Qt::AlignTop);
 	myWidget->setLayout(layoutBrowser);
 	scrollAreaPBI->setWidget(myWidget);
 }
@@ -894,3 +887,77 @@
 	pbiItem->setAutoUpdateStatus(status);
 
 }
+
+// Return a qstringlist of the latest PBIs
+QStringList PBM::getLatestPBIs(int lCount, QString repoID)
+{
+	QStringList latest, tmpList;
+
+	// Get the list of dates
+	int pTot = pbiAvail->count();
+	for( int i = 0; i < pTot; i++) {
+		if ( pbiAvail->getRepo(i) != repoID )
+                        continue;
+
+		tmpList << pbiAvail->getDate(i);
+	}
+
+	// Sort the list in descending order
+	qSort(tmpList.begin(), tmpList.end(), qGreater<QString>());
+
+
+	// Get the top lCount results
+	for ( int i = tmpList.length() ; i >= lCount; i-- )
+		tmpList.removeAt(i);
+
+	// Now return the PBI names
+	for ( int z = 0; z < tmpList.length() ; z++ ) {
+
+		pTot = pbiAvail->count();
+		for( int i = 0; i < pTot; i++) {
+			if ( pbiAvail->getRepo(i) != repoID )
+               	         continue;
+			if ( pbiAvail->getDate(i) != tmpList.at(z) )
+               	         continue;
+
+			latest << pbiAvail->getName(i);
+		}
+	}
+
+	return latest;
+}
+
+QWidget* PBM::getLatestPBIWidget(int curRepo)
+{
+	QWidget *latestWidget = new QWidget();
+	QHBoxLayout *latestLayout = new QHBoxLayout();
+
+	QStringList latestApps = getLatestPBIs(6, pbiRepos->getID(curRepo));
+	for ( int i = 0; i < latestApps.length(); i++) {
+		clickedWidget *lWidget = new clickedWidget(0, latestApps.at(i));
+		QHBoxLayout *iLayout = new QHBoxLayout();
+
+		// Find the correct PBI we are working on
+		for ( int z = 0; z < pbiAvail->count(); z++ ) {
+			if ( latestApps.at(i) != pbiAvail->getName(z) || pbiAvail->getRepo(z) != pbiRepos->getID(curRepo))
+				continue;
+
+			QPixmap pIcon(pbiAvail->getIcon(z));
+			QLabel *pIconLabel = new QLabel();
+			pIconLabel->setPixmap(pIcon.scaled(32,32, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
+			pIconLabel->setAlignment(Qt::AlignCenter);
+			pIconLabel->setMinimumSize(32,32);
+			pIconLabel->setMaximumSize(32,32);
+			pIconLabel->setToolTip(pbiAvail->getName(z) + " " + pbiAvail->getVer(z));
+			iLayout->addWidget(pIconLabel);
+		}
+		lWidget->setLayout(iLayout);
+		latestLayout->addWidget(lWidget);
+		lWidget->setCursor(Qt::PointingHandCursor);
+		connect(lWidget, SIGNAL( clicked(QString) ), this, SLOT(slotPBIClicked(QString) ) );
+	}
+
+	latestWidget->setLayout(latestLayout);
+
+	return latestWidget;
+}

Modified: pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbiupdate.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbiupdate.cpp	2011-03-09 17:52:32 UTC (rev 9584)
+++ pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbiupdate.cpp	2011-03-09 18:57:42 UTC (rev 9585)
@@ -72,18 +72,14 @@
 
     qDebug() << "Update Return:" << output;
 
-    if ( output.indexOf("Available:") == -1  && ! output.isEmpty())
+    if ( output.indexOf("Available: ") != -1  && ! output.isEmpty())
     {
-	  tmp = output.remove(0, output.indexOf("Available:"));
+	  tmp = output.remove(0, output.indexOf("Available: "));
 	  tmp = tmp.replace("Available: ", "");
-          item->setDownloadVersion(tmp);
+          item->setDownloadVersion(tmp.simplified());
 	
           // Great, we have a PBI with an available update! Notify the widget now
           item->setUpdateAvail(true);
-
-          // If the user has enabled updating all software automatically, mark it as so now
-          if (autoUpdateSoftware )
-             markPBIForUpdate(item);
     } else {
       // Update is invalid for some reason, no update for you!
       item->setUpdateAvail(false);



More information about the Commits mailing list