Permalink
Browse files

Some cosmetic improvements to PKGNG manager, now when we click a package

we will be shown a details widget, which has name / size / desc / options
/ depends / URL
  • Loading branch information...
1 parent a43929d commit 287e0371b1b81c513d0ae0f0c56897fb5a3f4af6 @kmoore134 kmoore134 committed Apr 29, 2013
Showing with 228 additions and 33 deletions.
  1. +78 −1 src-qt4/pc-pkgmanager/mainWin.cpp
  2. +3 −0 src-qt4/pc-pkgmanager/mainWin.h
  3. +147 −32 src-qt4/pc-pkgmanager/mainWin.ui
@@ -441,6 +441,7 @@ Code for package stuff
void mainWin::initMetaWidget()
{
qDebug() << "Starting metaWidget...";
+ groupInfo->setVisible(false);
// Running in basic mode
if ( stackedPkgView->currentIndex() == 0 )
@@ -460,8 +461,10 @@ void mainWin::populateNGPkgs()
tmpPkgList.clear();
new QTreeWidgetItem(treeNGPkgs, QStringList() << tr("Loading... Please wait...") );
- if ( ! pkgList.isEmpty() )
+ if ( ! pkgList.isEmpty() ) {
disconnect(treeNGPkgs, SIGNAL(itemChanged(QTreeWidgetItem *, int)), 0, 0);
+ disconnect(treeNGPkgs, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), 0, 0);
+ }
pkgList.clear();
selPkgList.clear();
@@ -542,6 +545,80 @@ void mainWin::slotFinishLoadingNGPkgs()
pushPkgApply->setEnabled(false);
connect(treeNGPkgs, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotEnableApply()));
+ connect(treeNGPkgs, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(slotNGItemChanged()));
+}
+
+void mainWin::slotNGItemChanged()
+{
+ if ( ! treeNGPkgs->currentItem() ) {
+ groupInfo->setVisible(false);
+ return;
+ }
+ QString desc, size, maint, weburl;
+
+ QTreeWidgetItem *cItem = treeNGPkgs->currentItem();
+ QString pName = cItem->text(0).section("(", 1, 1).section(")", 0, 0);
+ if ( pName.isEmpty() ) {
+ groupInfo->setVisible(false);
+ return;
+ }
+ qDebug() << "Checking: " + pName;
+
+ QRegExp rx("*:::" + pName + ":::*");
+ rx.setPatternSyntax(QRegExp::Wildcard);
+ int pAt = tmpPkgList.indexOf(rx);
+ if (pAt == -1 ) {
+ qDebug() << "Unable to find package: " + pName;
+ groupInfo->setVisible(false);
+ return;
+ }
+
+ desc = tmpPkgList.at(pAt).section(":::", 2,2);
+ size = tmpPkgList.at(pAt).section(":::", 3,3);
+ maint = tmpPkgList.at(pAt).section(":::", 4,4);
+ weburl = tmpPkgList.at(pAt).section(":::", 5,5);
+ labelPkgNameVer->setText(pName);
+ labelSize->setText(size);
+ labelWeb->setText(weburl);
+ textDesc->setText(desc);
+ textOptions->clear();
+
+ QCoreApplication::processEvents();
+
+ // Display the depends
+ QString depTxt;
+ QRegExp rxd( pName + ":::*");
+ rxd.setPatternSyntax(QRegExp::Wildcard);
+ QStringList aDeps = pkgDepList.filter(rxd);
+ for ( int r=0; r < aDeps.size(); ++r) {
+ QString dName = aDeps.at(r).section(":::", 1, 1);
+ // Is this package installed?
+ if ( pkgList.indexOf(dName) != -1 )
+ depTxt+= dName + " (Installed)\n";
+ else
+ depTxt+= dName + "\n";
+ }
+
+ textDeps->setText(depTxt);
+
+ groupInfo->setVisible(true);
+
+ getNGInfo = new QProcess();
+ qDebug() << "Getting Info for " + pName;
+ connect( getNGInfo, SIGNAL(readyReadStandardOutput()), this, SLOT(slotNGReadInfo()) );
+ getNGInfo->setProcessChannelMode(QProcess::MergedChannels);
+ if ( wDir.isEmpty() )
+ getNGInfo->start(QString("pkg"), QStringList() << "rquery" << "%Ok=%Ov" << pName );
+ else
+ getNGInfo->start(QString("chroot"), QStringList() << wDir << "pkg" << "rquery" << "%Ok=%Ov" << pName);
+}
+
+void mainWin::slotNGReadInfo()
+{
+ while (getNGInfo->canReadLine())
+ textOptions->append(getNGInfo->readLine().simplified() );
+
+ textOptions->moveCursor(QTextCursor::Start);
}
void mainWin::slotEnableApply()
@@ -68,6 +68,8 @@ private slots:
void slotGetNGInstalledPkgs();
void slotEnableApply();
void slotStartNGChanges();
+ void slotNGItemChanged();
+ void slotNGReadInfo();
private:
// Generic pkg process handlers
@@ -131,6 +133,7 @@ private slots:
QStringList pkgRemoveList;
QStringList pkgAddList;
QProcess *getNGProc;
+ QProcess *getNGInfo;
dialogConfirm *askUserConfirm;
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>757</width>
- <height>502</height>
+ <width>802</width>
+ <height>586</height>
</rect>
</property>
<property name="windowTitle">
@@ -37,41 +37,14 @@
<property name="title">
<string>System Packages</string>
</property>
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="1" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <spacer name="spacer2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>223</width>
- <height>21</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="pushPkgApply">
- <property name="text">
- <string>&amp;Apply</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
+ <layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QStackedWidget" name="stackedPkgView">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageBasic">
- <layout class="QGridLayout" name="gridLayout_6">
+ <layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<widget class="QTreeWidget" name="treeMetaPkgs">
<attribute name="headerVisible">
@@ -90,15 +63,157 @@
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QTreeWidget" name="treeNGPkgs">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
+ <column>
+ <property name="text">
+ <string notr="true">1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="groupInfo">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Package Information</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_6">
+ <item row="0" column="1" rowspan="3">
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tabDesc">
+ <attribute name="title">
+ <string>Description</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="QTextBrowser" name="textDesc"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tabOpts">
+ <attribute name="title">
+ <string>Options</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_12">
+ <item row="0" column="0">
+ <widget class="QTextBrowser" name="textOptions"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Dependances</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_13">
+ <item row="0" column="0">
+ <widget class="QTextBrowser" name="textDeps"/>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelPkgNameVer">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>My Package 1.0</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelSize">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>10 MB</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>118</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="3" column="0" colspan="2">
+ <widget class="QLabel" name="labelWeb">
+ <property name="text">
+ <string>http://www.pcbsd.org</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
+ <item row="1" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="spacer2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>223</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushPkgApply">
+ <property name="text">
+ <string>&amp;Apply</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
</item>
@@ -290,7 +405,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
- <width>757</width>
+ <width>802</width>
<height>22</height>
</rect>
</property>

0 comments on commit 287e037

Please sign in to comment.