added "remove all groups" button to Groups dialog

This commit is contained in:
ars_goldendict 2009-04-29 23:32:42 +00:00
parent 67b34fd3e0
commit 8a7367ebfc
5 changed files with 210 additions and 159 deletions

View file

@ -29,6 +29,8 @@ Groups::Groups( QWidget * parent,
this, SLOT( renameCurrent() ) ); this, SLOT( renameCurrent() ) );
connect( ui.removeGroup, SIGNAL( clicked() ), connect( ui.removeGroup, SIGNAL( clicked() ),
this, SLOT( removeCurrent() ) ); this, SLOT( removeCurrent() ) );
connect( ui.removeAllGroups, SIGNAL( clicked() ),
this, SLOT( removeAll() ) );
countChanged(); countChanged();
} }
@ -44,6 +46,7 @@ void Groups::countChanged()
ui.renameGroup->setEnabled( en ); ui.renameGroup->setEnabled( en );
ui.removeGroup->setEnabled( en ); ui.removeGroup->setEnabled( en );
ui.removeAllGroups->setEnabled( en );
} }
void Groups::addNew() void Groups::addNew()
@ -90,3 +93,17 @@ void Groups::removeCurrent()
countChanged(); 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();
}
}

View file

@ -30,10 +30,10 @@ private:
void countChanged(); void countChanged();
private slots: private slots:
void addNew(); void addNew();
void renameCurrent(); void renameCurrent();
void removeCurrent(); void removeCurrent();
void removeAll();
}; };
#endif #endif

View file

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>Groups</class> <class>Groups</class>
<widget class="QDialog" name="Groups"> <widget class="QDialog" name="Groups">
@ -60,6 +61,9 @@
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QPushButton" name="addGroup"> <widget class="QPushButton" name="addGroup">
<property name="toolTip">
<string>Create new dictionary group</string>
</property>
<property name="text"> <property name="text">
<string>&amp;Add group</string> <string>&amp;Add group</string>
</property> </property>
@ -67,6 +71,9 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="renameGroup"> <widget class="QPushButton" name="renameGroup">
<property name="toolTip">
<string>Rename current dictionary group</string>
</property>
<property name="text"> <property name="text">
<string>Re&amp;name group</string> <string>Re&amp;name group</string>
</property> </property>
@ -74,11 +81,24 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="removeGroup"> <widget class="QPushButton" name="removeGroup">
<property name="toolTip">
<string>Remove current dictionary group</string>
</property>
<property name="text"> <property name="text">
<string>&amp;Remove group</string> <string>&amp;Remove group</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="removeAllGroups">
<property name="toolTip">
<string>Remove all dictionary groups</string>
</property>
<property name="text">
<string>Remove all groups</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View file

@ -330,3 +330,14 @@ void DictGroupsWidget::removeCurrentGroup()
delete w; delete w;
} }
} }
void DictGroupsWidget::removeAllGroups()
{
while ( count() )
{
QWidget * w = widget( 0 );
removeTab( 0 );
delete w;
}
}

View file

@ -120,6 +120,9 @@ public:
/// Removes the currently chosen group, if any /// Removes the currently chosen group, if any
void removeCurrentGroup(); void removeCurrentGroup();
/// Removes all the groups
void removeAllGroups();
/// Creates groups from what is currently set up /// Creates groups from what is currently set up
Config::Groups makeGroups() const; Config::Groups makeGroups() const;