[Uml-devel] [Bug 126485] Add "add/remove all" buttons to the "select classes" dialog, enable selection of multiple classes
Daniel Calviño Sánchez
danxuliu at gmail.com
Fri Jun 9 15:47:07 UTC 2006
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=126485
danxuliu gmail com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
------- Additional Comments From danxuliu gmail com 2006-06-09 17:47 -------
SVN commit 548269 by danxuliu:
Attachment 16051 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">
More information about the umbrello-devel
mailing list