[PC-BSD Commits] r784 - pcbsd/trunk/kcmPBMsource
svn at pcbsd.org
svn at pcbsd.org
Wed Oct 10 11:40:06 PDT 2007
Author: tim
Date: 2007-10-10 11:40:06 -0700 (Wed, 10 Oct 2007)
New Revision: 784
Modified:
pcbsd/trunk/kcmPBMsource/pbm.ui
pcbsd/trunk/kcmPBMsource/pbm.ui.h
Log:
Implemented feature request #55 - It is now possible to select multiple PBIs in the PBM, and have them all removed at the same time
Modified: pcbsd/trunk/kcmPBMsource/pbm.ui
===================================================================
--- pcbsd/trunk/kcmPBMsource/pbm.ui 2007-10-10 16:36:02 UTC (rev 783)
+++ pcbsd/trunk/kcmPBMsource/pbm.ui 2007-10-10 18:40:06 UTC (rev 784)
@@ -80,6 +80,14 @@
<property name="name">
<cstring>textLabel1_2</cstring>
</property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
<string>Installed PBI Software</string>
</property>
@@ -103,6 +111,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="selectionMode">
+ <enum>Extended</enum>
+ </property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
@@ -148,25 +159,6 @@
</size>
</property>
</spacer>
- <widget class="QPushButton">
- <property name="name">
- <cstring>ExitButton</cstring>
- </property>
- <property name="sizePolicy">
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>&Quit</string>
- </property>
- <property name="accel">
- <string>Alt+Q</string>
- </property>
- </widget>
</hbox>
</widget>
</vbox>
@@ -227,6 +219,14 @@
<property name="name">
<cstring>textLabel1</cstring>
</property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
<string>Available system components</string>
</property>
@@ -282,25 +282,6 @@
</size>
</property>
</spacer>
- <widget class="QPushButton">
- <property name="name">
- <cstring>ExitButton2</cstring>
- </property>
- <property name="sizePolicy">
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>&Quit</string>
- </property>
- <property name="accel">
- <string>Alt+Q</string>
- </property>
- </widget>
</hbox>
</widget>
</vbox>
@@ -334,41 +315,37 @@
</connections>
<includes>
<include location="local" impldecl="in declaration">qprocess.h</include>
- <include location="local" impldecl="in declaration">qmessagebox.h</include>
<include location="global" impldecl="in declaration">kdirwatch.h</include>
<include location="global" impldecl="in declaration">qfile.h</include>
+ <include location="global" impldecl="in declaration">kmessagebox.h</include>
<include location="local" impldecl="in implementation">pbm.ui.h</include>
</includes>
<variables>
- <variable access="private">uint ProgSize[800];</variable>
- <variable access="private">QProcess *installComponentProc;</variable>
- <variable access="private">QProcess *removeComponentProc;</variable>
- <variable access="private">int ComponentWorkingItem;</variable>
- <variable access="private">int ComponentInstalled[500];</variable>
- <variable access="private">QString ComponentDir[500];</variable>
- <variable access="private">QString ComponentDescr[500];</variable>
- <variable access="private">QString ComponentName[500];</variable>
+ <variable access="private">QProcess *RemoveFile;</variable>
+ <variable access="private">QString RealUserName;</variable>
+ <variable access="private">QProcess *CheckRoot;</variable>
+ <variable access="private">QProcess *RemoveScript;</variable>
+ <variable access="private">QString MimeFile[800][100];</variable>
+ <variable access="private">QString ProgExe[800][100];</variable>
+ <variable access="private">QString ProgWeb[800];</variable>
+ <variable access="private">QString ProgAuthor[800];</variable>
+ <variable access="private">QString ProgIcon[800];</variable>
+ <variable access="private">QString ProgVer[800];</variable>
<variable access="private">QString ProgName[800];</variable>
+ <variable access="private">QString ComponentName[500];</variable>
+ <variable access="private">QString ComponentDescr[500];</variable>
+ <variable access="private">QString ComponentDir[500];</variable>
+ <variable access="private">int ComponentInstalled[500];</variable>
+ <variable access="private">int ComponentWorkingItem;</variable>
+ <variable access="private">QProcess *removeComponentProc;</variable>
+ <variable access="private">QProcess *installComponentProc;</variable>
+ <variable access="private">uint ProgSize[800];</variable>
<variable access="private">QProcess *InfoWindow;</variable>
- <variable access="private">QString ProgVer[800];</variable>
- <variable access="private">QString ProgIcon[800];</variable>
- <variable access="private">QString ProgAuthor[800];</variable>
- <variable access="private">QString ProgWeb[800];</variable>
- <variable access="private">QString ProgExe[800][100];</variable>
- <variable access="private">QString MimeFile[800][100];</variable>
- <variable access="private">QProcess *RemoveScript;</variable>
- <variable access="private">QProcess *CheckRoot;</variable>
- <variable access="private">QString RealUserName;</variable>
- <variable access="private">QProcess *RemoveFile;</variable>
- <variable access="private">int DeleteItem;</variable>
</variables>
<slots>
<slot access="private">RemoveButtonSlot()</slot>
- <slot access="private">ExitButtonSlot()</slot>
<slot access="private">PopulateList()</slot>
<slot access="private">CheckRootSlot()</slot>
- <slot access="private">CheckScriptSlot()</slot>
- <slot access="private">startDelete()</slot>
<slot access="private">installComponentSlot()</slot>
<slot access="private">removeComponentSlot()</slot>
<slot access="private" returnType="bool">checkComponentSlot( int component )</slot>
@@ -382,6 +359,7 @@
<function>ProgramInit()</function>
<function access="private">CleanPackageList( int RemNum )</function>
<function access="private">RemoveFiles( int RemNum )</function>
+ <function access="private">CheckScriptSlot( int item )</function>
<function access="private">loadComponents()</function>
<function access="private" returnType="QString">bytesToHumanReadable( float bytes )</function>
<function access="private" returnType="int">getDirSize( QString path )</function>
Modified: pcbsd/trunk/kcmPBMsource/pbm.ui.h
===================================================================
--- pcbsd/trunk/kcmPBMsource/pbm.ui.h 2007-10-10 16:36:02 UTC (rev 783)
+++ pcbsd/trunk/kcmPBMsource/pbm.ui.h 2007-10-10 18:40:06 UTC (rev 784)
@@ -21,13 +21,7 @@
{
qDebug("Application starting...");
- ExitButton->setEnabled(FALSE);
- ExitButton->setHidden(TRUE);
- ExitButton2->setHidden(TRUE);
- ExitButton2->setEnabled(FALSE);
-
connect(RemoveButton, SIGNAL( clicked() ), this, SLOT(RemoveButtonSlot() ) );
- connect(ExitButton, SIGNAL( clicked() ), this, SLOT(ExitButtonSlot() ) );
CheckRoot = new QProcess( this );
CheckRoot->addArgument( "whoami" );
@@ -62,47 +56,45 @@
void PBM::RemoveButtonSlot()
{
- if (SoftwareListBox->currentItem() != -1)
- {
- DeleteItem = SoftwareListBox->currentItem();
-
- switch( QMessageBox::warning( this, tr("Remove Program?"), tr("Do you want to delete ") + ProgName[DeleteItem] + " " + ProgVer[DeleteItem] + "?", tr("OK"), tr("Cancel"), 0, 0, 1 ) ) {
- case 0: // The user clicked the OK again button or pressed Enter
- break;
- case 1: // The user clicked the cancel button
- return;
- break;
- }
-
- RemoveButton->setEnabled(FALSE);
- ExitButton->setEnabled(FALSE);
-
- // Remove the script
- InfoWindow = new QProcess( this );
- InfoWindow->addArgument( "kdialog");
- InfoWindow->addArgument( "--passivepopup" );
- InfoWindow->addArgument( "Please Wait.. Removing " + ProgName[DeleteItem] + ".." );
- InfoWindow->addArgument( "300" );
-
- if ( !InfoWindow->start() ) {
- //QMessageBox::information( this, tr("Error!", "Error displaying info window!") );
- }
-
- tabPBM->setEnabled(FALSE);
-
- // Check for any custom script to run before remove
- CheckScriptSlot();
-
- }
-
+ QValueList<int> selectedItems;
+ QStringList selectedNames;
+
+ for (int i=0; i<SoftwareListBox->numRows(); i++)
+ {
+ if (SoftwareListBox->isSelected(i))
+ {
+ selectedItems += i;
+ selectedNames += ProgName[i] + " " + ProgVer[i];
+ }
+ }
+
+ tabPBM->setEnabled(FALSE);
+
+ //Cancel if the user doesn't want to go ahead with removal
+ if (KMessageBox::warningYesNoList(this, "Remove these applications?", selectedNames) == KMessageBox::No)
+ {
+ tabPBM->setEnabled(TRUE);
+ return;
+ }
+
+ for (QValueList<int>::Iterator item = selectedItems.begin(); item != selectedItems.end(); ++item)
+ {
+ qDebug("Removing item: " + QString::number(*item) + " - " + ProgName[*item] + ProgVer[*item]);
+ CheckScriptSlot(*item);
+ RemoveFiles(*item);
+ }
+
+ uint iterations = 0;
+ for (QValueList<int>::Iterator item = selectedItems.begin(); item != selectedItems.end(); ++item)
+ {
+ CleanPackageList(*item - iterations);
+ iterations++;
+ }
+
+ tabPBM->setEnabled(TRUE);
}
-void PBM::ExitButtonSlot()
-{
- close();
-}
-
// Displays our items on the list
void PBM::PopulateList()
{
@@ -442,92 +434,37 @@
}
-void PBM::CheckScriptSlot()
+void PBM::CheckScriptSlot(int item)
{
- QString ProgDirName;
-
- QString tmp;
- tmp = ProgName[DeleteItem];
- tmp.replace(" ", "");
- ProgDirName = tmp;
- tmp = ProgVer[DeleteItem];
- tmp.replace(" ", "");
- ProgDirName = ProgDirName + tmp;
-
- // Check if a custom removal script exists, and run it
- QFile CheckScript("/Programs/" + ProgDirName + "/PBI.RemoveScript.sh");
- if (CheckScript.exists() )
- {
-
- // Write out the wrapper script
- QFile file( "/Programs/" + ProgDirName + "/.PBIwrapper.sh" );
- if ( file.open( IO_WriteOnly ) ) {
- QTextStream stream( &file );
- stream << "#!/bin/sh\n";
- stream << "PROGDIR=\"" + ProgDirName + "\"; export PROGDIR\n";
- stream << "USERNAME=\"" + RealUserName + "\"; export USERNAME\n";
- stream << "INSTALLMODE=\"GUI\"; export INSTALLMODE\n";
- stream << "sh /Programs/" + ProgDirName + "/PBI.RemoveScript.sh ${PROGDIR}\nexit ${?}";
-
- file.close();
- }
-
- RemoveScript = new QProcess( this );
- RemoveScript->addArgument( "sh" );
- RemoveScript->addArgument( "/Programs/" + ProgDirName + "/.PBIwrapper.sh" );
-
-
-
- // Remove the script
- //RemoveScript = new QProcess( this );
- //RemoveScript->addArgument( "/Programs/" + ProgDirName + "/PBI.RemoveScript.sh");
- //RemoveScript->addArgument( ProgDirName );
-
- connect( RemoveScript, SIGNAL(processExited()), this, SLOT(startDelete() ) );
-
- if ( !RemoveScript->start() ) {
- QMessageBox::information( this, tr("Error!"), tr("Error starting custom removal script!") );
- startDelete();
- }
-
- } else {
-
- startDelete();
- }
-
-
+ QString progDir = ProgName[item] + ProgVer[item];
+ progDir.replace(" ", "");
+
+ // Check if a custom removal script exists, and run it
+ QFile CheckScript("/Programs/" + progDir + "/PBI.RemoveScript.sh");
+ if (CheckScript.exists())
+ {
+ // Write out the wrapper script
+ QFile file( "/Programs/" + progDir + "/.PBIwrapper.sh" );
+ if ( file.open( IO_WriteOnly ) )
+ {
+ QTextStream stream( &file );
+ stream << "#!/bin/sh\n";
+ stream << "PROGDIR=\"" + progDir + "\"; export PROGDIR\n";
+ stream << "USERNAME=\"" + RealUserName + "\"; export USERNAME\n";
+ stream << "INSTALLMODE=\"GUI\"; export INSTALLMODE\n";
+ stream << "sh /Programs/" + progDir + "/PBI.RemoveScript.sh ${PROGDIR}\nexit ${?}";
+ file.close();
+ }
+
+ RemoveScript = new QProcess( this );
+ RemoveScript->addArgument( "sh" );
+ RemoveScript->addArgument( "/Programs/" + progDir + "/.PBIwrapper.sh" );
+ if ( !RemoveScript->start() ) KMessageBox::error(this, tr("Error starting custom removal script!"));
+ }
}
-void PBM::startDelete()
-{
- // Run the deletion routines
- RemoveFiles(DeleteItem);
-
- // Clean up the config file
- CleanPackageList(DeleteItem);
-
- // Remove item from list
- SoftwareListBox->removeItem(DeleteItem);
-
- if ( InfoWindow->isRunning() )
- {
- InfoWindow->kill();
- }
-
- // Repopulate the List
- PopulateList();
-
- // Re-enable the buttons
- RemoveButton->setEnabled(TRUE);
- ExitButton->setEnabled(TRUE);
- tabPBM->setEnabled(TRUE);
- QMessageBox::information( this, tr("Success!"), tr("The package was deleted!") );
-
-}
-
-
void PBM::loadComponents()
{
componentListbox->clear();
More information about the Commits
mailing list