diff --git a/src/groups.cc b/src/groups.cc index ce366208..672a4cb4 100644 --- a/src/groups.cc +++ b/src/groups.cc @@ -29,6 +29,8 @@ Groups::Groups( QWidget * parent, this, SLOT( renameCurrent() ) ); connect( ui.removeGroup, SIGNAL( clicked() ), this, SLOT( removeCurrent() ) ); + connect( ui.removeAllGroups, SIGNAL( clicked() ), + this, SLOT( removeAll() ) ); countChanged(); } @@ -44,6 +46,7 @@ void Groups::countChanged() ui.renameGroup->setEnabled( en ); ui.removeGroup->setEnabled( en ); + ui.removeAllGroups->setEnabled( en ); } void Groups::addNew() @@ -90,3 +93,17 @@ void Groups::removeCurrent() countChanged(); } } + +void Groups::removeAll() +{ + int current = ui.groups->currentIndex(); + + if ( current >= 0 && QMessageBox::question( this, tr( "Remove all groups" ), + tr( "Are you sure you want to remove all the groups?" ), + QMessageBox::Yes, QMessageBox::Cancel ) == QMessageBox::Yes ) + { + ui.groups->removeAllGroups(); + countChanged(); + } +} + diff --git a/src/groups.hh b/src/groups.hh index 5d3a9262..a557a129 100644 --- a/src/groups.hh +++ b/src/groups.hh @@ -30,10 +30,10 @@ private: void countChanged(); private slots: - void addNew(); void renameCurrent(); void removeCurrent(); + void removeAll(); }; #endif diff --git a/src/groups.ui b/src/groups.ui index 12f5ee69..ad27e874 100644 --- a/src/groups.ui +++ b/src/groups.ui @@ -1,158 +1,178 @@ - - Groups - - - Qt::WindowModal - - - - 0 - 0 - 726 - 535 - - - - Groups - - - - - - - - - - Dictionaries available: - - - - - - - - - - - - - - Groups: - - - - - - - QTabWidget::North - - - Qt::ElideRight - - - - Tab 2 - - - - - - - - - - &Add group - - - - - - - Re&name group - - - - - - - &Remove group - - - - - - - - - - - - - Drag&drop dictionaries to and from the groups, move them inside the groups, reorder the groups using your mouse. - - - true - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - DictListWidget - QListWidget -
groups_widgets.hh
-
- - DictGroupsWidget - QTabWidget -
groups_widgets.hh
- 1 -
-
- - - - buttons - accepted() - Groups - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttons - rejected() - Groups - reject() - - - 316 - 260 - - - 286 - 274 - - - - -
+ + + Groups + + + Qt::WindowModal + + + + 0 + 0 + 726 + 535 + + + + Groups + + + + + + + + + + Dictionaries available: + + + + + + + + + + + + + + Groups: + + + + + + + QTabWidget::North + + + Qt::ElideRight + + + + Tab 2 + + + + + + + + + + Create new dictionary group + + + &Add group + + + + + + + Rename current dictionary group + + + Re&name group + + + + + + + Remove current dictionary group + + + &Remove group + + + + + + + Remove all dictionary groups + + + Remove all groups + + + + + + + + + + + + + Drag&drop dictionaries to and from the groups, move them inside the groups, reorder the groups using your mouse. + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + DictListWidget + QListWidget +
groups_widgets.hh
+
+ + DictGroupsWidget + QTabWidget +
groups_widgets.hh
+ 1 +
+
+ + + + buttons + accepted() + Groups + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttons + rejected() + Groups + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/src/groups_widgets.cc b/src/groups_widgets.cc index e1d71d33..1b433a72 100644 --- a/src/groups_widgets.cc +++ b/src/groups_widgets.cc @@ -330,3 +330,14 @@ void DictGroupsWidget::removeCurrentGroup() delete w; } } + + +void DictGroupsWidget::removeAllGroups() +{ + while ( count() ) + { + QWidget * w = widget( 0 ); + removeTab( 0 ); + delete w; + } +} diff --git a/src/groups_widgets.hh b/src/groups_widgets.hh index c2f04db8..dd2a89cd 100644 --- a/src/groups_widgets.hh +++ b/src/groups_widgets.hh @@ -120,6 +120,9 @@ public: /// Removes the currently chosen group, if any void removeCurrentGroup(); + /// Removes all the groups + void removeAllGroups(); + /// Creates groups from what is currently set up Config::Groups makeGroups() const;