Bug 126485

Summary: Add "add/remove all" buttons to the "select classes" dialog, enable selection of multiple classes
Product: [Applications] umbrello Reporter: greatbunzinni
Component: generalAssignee: Umbrello Development Group <umbrello-devel>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: 1.5.2   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Enable selection of multiple classes in "Select classes" dialog

Description greatbunzinni 2006-04-29 21:05:43 UTC
Version:           1.5.2 (using KDE KDE 3.5.2)

When a user runs the Umbrello's code generation wizard, the first step it is presented is the choice of what classes should be used in the code generation process. If a user wishes to generate only a hand-full of classes, the user needs to remove each and every class he doesn't want to be generated one at a time. That makes the task incredibly tedious and time consuming.

It would be nice if that dialog had "add all" and "remove all" buttons which enabled the user to add/remove all classes. It would also be nice if it was possible to select multiple classes from the class list and then add/remove the selected ones.
Comment 1 Daniel Calviño Sánchez 2006-05-12 21:00:20 UTC
Created attachment 16051 [details]
Enable selection of multiple classes in "Select classes" dialog

Available classes list and selected classes list now allow multiple classes
selected (dragging with mouse or selecting with ctrl and shift buttons).

However ,I haven't added the "add/remove all" buttons, because in my humble
opinion they aren't needed. Interface is very clean and simple right now, and I
like it. And the behaviour of those buttons can be made clicking the first
item, dragging to the last item, and clicking the add or remove button, which
is fairly easy and quick.

About the patch itself, I edited the .ui file using QT Designer, but it updated
the ui file version to 3.3 and made some changes such as the images format. So
I reverted those changes and edited it manually keeping everything and simply
adding the new selection mode. I think that the syntax used is available in
version 3.0 (at least, it compiles and works), but I'm not sure.
Comment 2 Oliver Kellogg 2006-05-13 10:03:32 UTC
Thanks for your patch.
Since we are in string freeze for KDE 3.5.3 I'm afraid we'll
have to wait with committing it till after the release.
Comment 3 Daniel Calviño Sánchez 2006-06-09 17:47:04 UTC
SVN commit 548269 by danxuliu:

Attachment 16051 [details] enables selection of multiple classes in "Select
classes" dialog.
FEATURE: 126485

 M  +26 -18    codegenerationwizard.cpp
 M  +18 -0     codegenerationwizard.h
 M  +6 -0      codegenerationwizardbase.ui


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/dialogs/codegenerationwizard.cpp
#548268:548269
@@ -76,29 +76,19 @@


 void CodeGenerationWizard::selectClass() {
-    if( !m_availableList->selectedItem() ) {
-        return;
+    moveSelectedItems(m_availableList, m_selectedList);
+
+    if (m_selectedList->childCount() > 0) {
+        setNextEnabled(currentPage(), true);
     }
-    QString name = m_availableList->selectedItem()->text(0);
-    if( !m_selectedList->findItem( name,0 ) ) {
-        new QListViewItem(m_selectedList, name);
-    }
-    m_availableList->removeItem( m_availableList->selectedItem() );
-    setNextEnabled(currentPage(),true);
 }

 void CodeGenerationWizard::deselectClass() {
-    if( !m_selectedList->selectedItem() ) {
-        return;
+    moveSelectedItems(m_selectedList, m_availableList);
+
+    if (m_selectedList->childCount() == 0) {
+        setNextEnabled(currentPage(), false);
     }
-    QString name = m_selectedList->selectedItem()->text(0);
-    if( !m_availableList->findItem(name, 0) ) {
-        new QListViewItem(m_availableList, name);
-    }
-    if(m_selectedList->childCount() == 0) {
-        setNextEnabled(currentPage(),false);
-    }
-    m_selectedList->removeItem( m_selectedList->selectedItem() );
 }

 void CodeGenerationWizard::generateCode() {
@@ -231,6 +221,24 @@
     return (CodeGenerator*) NULL;
 }

+void CodeGenerationWizard::moveSelectedItems(QListView* fromList,
QListView* toList) {
+   QListViewItemIterator it(fromList, QListViewItemIterator::Selected);
+    while (it.current()) {
+        QListViewItem* selectedItem = it.current();
+
+        QString name = selectedItem->text(0);
+        if (!toList->findItem(name, 0)) {
+            new QListViewItem(toList, name);
+        }
+
+        ++it;
+
+        //Removed here because it can't (really, shouldn't) be removed while
+        //iterator is pointing to it
+        fromList->removeItem(selectedItem);
+    }
+}
+
 // when we change language, we need to update the codegenoptions page
 // language-dependent stuff. THe way to do this is to call its "apply" method.
 void CodeGenerationWizard::changeLanguage()
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/dialogs/codegenerationwizard.h
#548268:548269
@@ -49,7 +49,17 @@
         return QWizard::exec();
     }
 protected slots:
+
+    /**
+     * Adds the classes selected in the available classes list to the
+     * list of classes used to generate the code.
+     */
     void selectClass();
+
+    /**
+     * Removes the classes selected in the selected classes list from the
+     * list of classes used to generate the code.
+     */
     void deselectClass();
     void populateStatusList();
     void generateCode();
@@ -62,6 +72,14 @@
 private:
     CodeGenerator* generator();

+    /**
+     * Moves the selected items from first list to second list.
+     * The selected items are removed from the first list and added to the
+     * second. An item is added to the second list only if it isn't already
+     * there (no duplicated items are created).
+     */
+    void moveSelectedItems(QListView* fromList, QListView* toList);
+
     UMLApp* m_app;
     UMLDoc* m_doc;
     CodeGenerationOptionsPage* m_CodeGenerationOptionsPage;
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/dialogs/codegenerationwizardbase.ui
#548268:548269
@@ -118,6 +118,9 @@
                                 <verstretch>0</verstretch>
                             </sizepolicy>
                         </property>
+                        <property name="selectionMode">
+                            <enum>Extended</enum>
+                        </property>
                     </widget>
                     <widget class="QPushButton" row="3" column="1">
                         <property name="name">
@@ -173,6 +176,9 @@
                                 <verstretch>0</verstretch>
                             </sizepolicy>
                         </property>
+                        <property name="selectionMode">
+                            <enum>Extended</enum>
+                        </property>
                     </widget>
                     <spacer row="4" column="1">
                         <property name="name" stdset="0">