[rkward-cvs] SF.net SVN: rkward:[2629] trunk/rkward/rkward/dialogs
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Wed Aug 26 08:37:24 UTC 2009
Revision: 2629
http://rkward.svn.sourceforge.net/rkward/?rev=2629&view=rev
Author: tfry
Date: 2009-08-26 08:37:23 +0000 (Wed, 26 Aug 2009)
Log Message:
-----------
Make load/unload UI a bit nicer. See also https://sourceforge.net/tracker/?func=detail&atid=459010&aid=2844688&group_id=50231
Modified Paths:
--------------
trunk/rkward/rkward/dialogs/rkloadlibsdialog.cpp
trunk/rkward/rkward/dialogs/rkloadlibsdialog.h
Modified: trunk/rkward/rkward/dialogs/rkloadlibsdialog.cpp
===================================================================
--- trunk/rkward/rkward/dialogs/rkloadlibsdialog.cpp 2009-08-25 13:57:06 UTC (rev 2628)
+++ trunk/rkward/rkward/dialogs/rkloadlibsdialog.cpp 2009-08-26 08:37:23 UTC (rev 2629)
@@ -40,6 +40,7 @@
#include "../settings/rksettings.h"
#include "../core/robjectlist.h"
#include "../misc/rkprogresscontrol.h"
+#include "../misc/rkstandardicons.h"
#include "../debug.h"
@@ -299,9 +300,9 @@
instvbox->addWidget (label);
instvbox->addWidget (installed_view);
- load_button = new QPushButton (i18n ("Load"), this);
+ load_button = new QPushButton (RKStandardIcons::getIcon (RKStandardIcons::ActionAddRight), i18n ("Load"), this);
connect (load_button, SIGNAL (clicked ()), this, SLOT (loadButtonClicked ()));
- detach_button = new QPushButton (i18n ("Unload"), this);
+ detach_button = new QPushButton (RKStandardIcons::getIcon (RKStandardIcons::ActionRemoveLeft), i18n ("Unload"), this);
connect (detach_button, SIGNAL (clicked ()), this, SLOT (detachButtonClicked ()));
buttonvbox->addStretch (1);
buttonvbox->addWidget (load_button);
@@ -315,12 +316,16 @@
loadedvbox->addWidget (label);
loadedvbox->addWidget (loaded_view);
+ connect (loaded_view, SIGNAL (itemSelectionChanged()), this, SLOT (updateButtons()));
+ connect (installed_view, SIGNAL (itemSelectionChanged()), this, SLOT (updateButtons()));
+
connect (dialog, SIGNAL (okClicked ()), this, SLOT (ok ()));
connect (dialog, SIGNAL (applyClicked ()), this, SLOT (apply ()));
connect (dialog, SIGNAL (cancelClicked ()), this, SLOT (cancel ()));
connect (this, SIGNAL (destroyed ()), dialog, SLOT (childDeleted ()));
updateInstalledPackages ();
+ updateButtons ();
}
LoadUnloadWidget::~LoadUnloadWidget () {
@@ -360,6 +365,9 @@
for (unsigned int i=0; i < command->getDataLength (); ++i) {
QTreeWidgetItem* item = new QTreeWidgetItem (loaded_view);
item->setText (0, command->getStringVector ()[i]);
+ if (RKSettingsModuleRPackages::essentialPackages ().contains (command->getStringVector ()[i])) {
+ item->setFlags (Qt::NoItemFlags);
+ }
}
loaded_view->resizeColumnToContents (0);
setEnabled (true);
@@ -383,15 +391,17 @@
void LoadUnloadWidget::loadButtonClicked () {
RK_TRACE (DIALOGS);
+ loaded_view->clearSelection ();
QList<QTreeWidgetItem*> sel = installed_view->selectedItems ();
for (int i = 0; i < sel.size (); ++i) {
- QTreeWidgetItem* installed = sel[0];
+ QString package_name = sel[i]->text (0);
// is this package already loaded?
- QList<QTreeWidgetItem*> loaded = loaded_view->findItems (installed->text (0), Qt::MatchExactly, 0);
+ QList<QTreeWidgetItem*> loaded = loaded_view->findItems (package_name, Qt::MatchExactly, 0);
if (loaded.isEmpty ()) {
QTreeWidgetItem* item = new QTreeWidgetItem (loaded_view);
- item->setText (0, installed->text (0));
+ item->setText (0, package_name);
+ item->setSelected (true);
}
}
}
@@ -399,12 +409,29 @@
void LoadUnloadWidget::detachButtonClicked () {
RK_TRACE (DIALOGS);
+ installed_view->clearSelection ();
QList<QTreeWidgetItem*> sel = loaded_view->selectedItems ();
for (int i = 0; i < sel.size (); ++i) {
- delete (sel[i]); // remove from list
+ QString package_name = sel[i]->text (0);
+
+ delete (sel[i]); // remove from list of loaded packages
+
+ // select corresponding package in list of available packages
+ QList<QTreeWidgetItem*> installed = installed_view->findItems (package_name, Qt::MatchExactly, 0);
+ if (!installed.isEmpty ()) {
+ RK_ASSERT (installed.count () == 1);
+ installed[0]->setSelected (true);
+ }
}
}
+void LoadUnloadWidget::updateButtons () {
+ RK_TRACE (DIALOGS);
+
+ detach_button->setEnabled (!loaded_view->selectedItems ().isEmpty ());
+ load_button->setEnabled (!installed_view->selectedItems ().isEmpty ());
+}
+
void LoadUnloadWidget::ok () {
RK_TRACE (DIALOGS);
doLoadUnload ();
@@ -430,7 +457,7 @@
for (int i = 0; i < loaded_view->topLevelItemCount (); ++i) {
QTreeWidgetItem* loaded = loaded_view->topLevelItem (i);
if (!prev_packages.contains (loaded->text (0))) {
- RCommand *command = new RCommand ("library (\"" + loaded->text (0) + "\")", RCommand::App);
+ RCommand *command = new RCommand ("library (\"" + loaded->text (0) + "\")", RCommand::App | RCommand::ObjectListUpdate);
control->addRCommand (command);
RKGlobals::rInterface ()->issueCommand (command, parent->chain);
}
Modified: trunk/rkward/rkward/dialogs/rkloadlibsdialog.h
===================================================================
--- trunk/rkward/rkward/dialogs/rkloadlibsdialog.h 2009-08-25 13:57:06 UTC (rev 2628)
+++ trunk/rkward/rkward/dialogs/rkloadlibsdialog.h 2009-08-26 08:37:23 UTC (rev 2629)
@@ -2,7 +2,7 @@
rkloadlibsdialog - description
-------------------
begin : Mon Sep 6 2004
- copyright : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2006, 2007, 2009 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -118,6 +118,7 @@
void apply ();
void cancel ();
void updateInstalledPackages ();
+ void updateButtons ();
protected:
void rCommandDone (RCommand *command);
private:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list