[PC-BSD Commits] r9582 - pcbsd/current/src-qt4/pc-softwaremanager
svn at pcbsd.org
svn at pcbsd.org
Wed Mar 9 08:05:24 PST 2011
Author: kris
Date: 2011-03-09 08:05:24 -0800 (Wed, 09 Mar 2011)
New Revision: 9582
Modified:
pcbsd/current/src-qt4/pc-softwaremanager/pbi.cpp
pcbsd/current/src-qt4/pc-softwaremanager/pbi.h
pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.cpp
pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.h
pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbibrowser.cpp
Log:
Enabled auto-updating via the GUI / PBI status page
Modified: pcbsd/current/src-qt4/pc-softwaremanager/pbi.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/pbi.cpp 2011-03-09 10:22:44 UTC (rev 9581)
+++ pcbsd/current/src-qt4/pc-softwaremanager/pbi.cpp 2011-03-09 16:05:24 UTC (rev 9582)
@@ -45,6 +45,7 @@
dodelete = false;
newdownload = false;
downloadFailed = false;
+ autoup = false;
}
PBI::PBI(QTreeWidget *listbox, QString name, QString version, QString iconPath, QString author, QString website) : QTreeWidgetItem(listbox)
@@ -63,6 +64,7 @@
dodelete = false;
newdownload = false;
downloadFailed = false;
+ autoup = false;
}
PBI::PBI(QIcon icon, QTreeWidget *listbox) : QTreeWidgetItem(listbox)
@@ -75,6 +77,7 @@
dodelete = false;
newdownload = false;
downloadFailed = false;
+ autoup = false;
}
PBI::~PBI()
@@ -267,6 +270,11 @@
return arch;
}
+QString PBI::getNameCLI()
+{
+ return name.toLower() + "-" + version.toLower() + "-" + arch.toLower();
+}
+
void PBI::setStatusText(QString text)
{
this->setText(1, text);
@@ -316,6 +324,17 @@
working=status;
}
+
+bool PBI::getAutoUpdateStatus()
+{
+ return autoup;
+}
+
+void PBI::setAutoUpdateStatus(bool status)
+{
+ autoup=status;
+}
+
bool PBI::isWorking()
{
return working;
Modified: pcbsd/current/src-qt4/pc-softwaremanager/pbi.h
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/pbi.h 2011-03-09 10:22:44 UTC (rev 9581)
+++ pcbsd/current/src-qt4/pc-softwaremanager/pbi.h 2011-03-09 16:05:24 UTC (rev 9582)
@@ -44,6 +44,7 @@
//Getters
virtual bool doDelete();
+ virtual bool getAutoUpdateStatus();
virtual bool getDownloadFailed();
virtual bool getUpdateAvail();
virtual bool isDirty();
@@ -58,6 +59,7 @@
virtual QString getDownloadVersion();
virtual QString getIconPath();
virtual QString getName();
+ virtual QString getNameCLI();
virtual QString getProgDir();
virtual QString getProgIndexName();
virtual QString getRepoID();
@@ -68,6 +70,7 @@
//Setters
virtual void setArch(QString type);
virtual void setAuthor(QString author);
+ virtual void setAutoUpdateStatus(bool status);
virtual void setDelete(bool status);
virtual void setDirty(bool status);
virtual void setDownloadArch(QString arch);
@@ -95,6 +98,7 @@
virtual QString toString();
private:
+ bool autoup;
bool dirty;
bool dodelete;
bool downloadFailed;
Modified: pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.cpp 2011-03-09 10:22:44 UTC (rev 9581)
+++ pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.cpp 2011-03-09 16:05:24 UTC (rev 9582)
@@ -253,7 +253,7 @@
QTreeWidgetItemIterator it(SoftwareListBox);
while (*it) {
PBI *item = dynamic_cast<PBI*>(*it);
- if ( item->getName() == name )
+ if ( item->getName().toUpper() == name.toUpper() )
return item;
++it;
}
@@ -339,7 +339,7 @@
PBI *pbi = 0;
bool foundPBI = false;
QPixmap defaultIcon(":/application.png");
- QString tmp, line, name, progIndexName, version, prefix, author, website, arch, icon, sig, repoID;
+ QString tmp, line, name, progIndexName, version, prefix, author, website, arch, icon, sig, repoID, autoUpdate;
// Start by marking all PBIs as dirty
markAllPBIDirty();
@@ -380,6 +380,9 @@
if ( line.indexOf("Arch:") == 0)
arch = line.replace("Arch: ", "");
+ if ( line.indexOf("AutoUpdate:") == 0)
+ autoUpdate = line.replace("AutoUpdate: ", "");
+
if ( line.indexOf("Associated Repo:") == 0) {
repoID = line.replace("Associated Repo: ", "");
repoID.truncate(repoID.indexOf(" "));
@@ -402,6 +405,10 @@
item->setDirty(false);
item->setDelete(false);
item->setHidden(false);
+ if ( autoUpdate == "YES" )
+ item->setAutoUpdateStatus(true);
+ else
+ item->setAutoUpdateStatus(false);
qDebug() << "Updating PBI:" << name;
} else {
// New PBI! Add it to our list
@@ -417,6 +424,10 @@
pbi->setDirty(false);
pbi->setDelete(false);
pbi->setHidden(false);
+ if ( autoUpdate == "YES" )
+ pbi->setAutoUpdateStatus(true);
+ else
+ pbi->setAutoUpdateStatus(false);
SoftwareListBox->addTopLevelItem(pbi);
qDebug() << "Found PBI:" << name << version << repoID << icon;
}
@@ -429,6 +440,7 @@
website="";
arch="";
repoID="";
+ autoUpdate="";
}
}
Modified: pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.h
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.h 2011-03-09 10:22:44 UTC (rev 9581)
+++ pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.h 2011-03-09 16:05:24 UTC (rev 9582)
@@ -96,6 +96,7 @@
void slotSearchForKeyword(bool);
void slotSearchAsTyped();
void slotSearchClicked();
+ void slotAutoUpdateClicked(bool);
private:
void RemovePBI( PBI * pbi );
@@ -118,6 +119,7 @@
QString curPageName;
QString curPageRepo;
QString curPageType;
+ QString curPBIName;
QStringList histType;
QStringList histName;
Modified: pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbibrowser.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbibrowser.cpp 2011-03-09 10:22:44 UTC (rev 9581)
+++ pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbibrowser.cpp 2011-03-09 16:05:24 UTC (rev 9582)
@@ -1,4 +1,5 @@
#include <QApplication>
+#include <QCheckBox>
#include <QGraphicsDropShadowEffect>
#include <QPushButton>
#include <QTimer>
@@ -202,6 +203,7 @@
int pbiNum;
QString pRepo;
bool installed;
+ bool autoUpdate = false;
// Save this in the history
@@ -217,6 +219,7 @@
curPageType="PBI";
curPageName=pbi;
curPageRepo=pRepo;
+ curPBIName=pbi;
clearSoftwareBrowser();
@@ -250,6 +253,16 @@
// See if this PBI is installed already
installed = checkPBILoaded(pbi);
+ // If this PBI is loaded, see of we have a update status
+ if ( installed ) {
+ PBI *pbiItem = getPBIFromName(pbi);
+ if ( pbiItem )
+ autoUpdate = pbiItem->getAutoUpdateStatus();
+ else
+ autoUpdate = false;
+ }
+
+
// Create the title / Icon
QWidget *tWidget = new QWidget();
QHBoxLayout *tLayout = new QHBoxLayout();
@@ -287,7 +300,7 @@
clickedWidget *pbiWidget = new clickedWidget(0, pbiAvail->getName(pbiNum));
- QHBoxLayout *dLayout = new QHBoxLayout();
+ QGridLayout *dLayout = new QGridLayout();
QLabel *dIcon = new QLabel();
dIcon->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
@@ -298,18 +311,26 @@
dIcon->setMinimumSize(48,48);
dIcon->setMaximumSize(48,48);
dIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- dLayout->addWidget(dIcon);
+ dLayout->addWidget(dIcon, 0, 0);
QLabel *dLabel = new QLabel();
if ( installed )
dLabel->setText("<b>" + tr("Installed") + "</b>");
else
dLabel->setText(tr("Download"));
- dLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
+ dLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
dLabel->setWordWrap(true);
dLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
- dLayout->addWidget(dLabel);
+ dLayout->addWidget(dLabel, 0, 1);
+ // Show the auto-updating checkbox if installed
+ if ( installed ) {
+ QCheckBox *dCheck = new QCheckBox(tr("Automatic Updating"));
+ dCheck->setChecked(autoUpdate);
+ connect(dCheck, SIGNAL( clicked(bool) ), this, SLOT(slotAutoUpdateClicked(bool) ) );
+ dLayout->addWidget(dCheck, 1, 0, 1, 2);
+ }
+
pbiWidget->setLayout(dLayout);
// Create the spacer widget so that only the icon / text is clickable
@@ -324,7 +345,8 @@
pbiWidget->setCursor(Qt::PointingHandCursor);
connect(pbiWidget, SIGNAL( clicked(QString) ), this, SLOT(slotDownloadClicked(QString) ) );
}
-
+
+
// Add a <hr> spacer
QLabel *myLine = new QLabel();
myLine->setFrameStyle(QFrame::HLine);
@@ -847,3 +869,28 @@
scrollAreaPBI->setWidget(myWidget);
}
}
+
+void PBM::slotAutoUpdateClicked(bool status)
+{
+ QString arg;
+ if ( status )
+ arg = "--enable-auto";
+ else
+ arg = "--disable-auto";
+
+
+ PBI *pbiItem = getPBIFromName(curPBIName);
+ if ( !pbiItem )
+ return;
+
+ QProcess pbicmd;
+ pbicmd.start(QString("pbi_update"), QStringList() << arg << pbiItem->getNameCLI() );
+
+ while ( pbicmd.state() != QProcess::NotRunning ) {
+ pbicmd.waitForFinished(50);
+ QCoreApplication::processEvents();
+ }
+
+ pbiItem->setAutoUpdateStatus(status);
+
+}
More information about the Commits
mailing list