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,10 +1,11 @@
<ui version="4.0" > <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Groups</class> <class>Groups</class>
<widget class="QDialog" name="Groups" > <widget class="QDialog" name="Groups">
<property name="windowModality" > <property name="windowModality">
<enum>Qt::WindowModal</enum> <enum>Qt::WindowModal</enum>
</property> </property>
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
@ -12,73 +13,92 @@
<height>535</height> <height>535</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>Groups</string> <string>Groups</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2" > <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2" > <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_3" > <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QLabel" name="label_2" > <widget class="QLabel" name="label_2">
<property name="text" > <property name="text">
<string>Dictionaries available:</string> <string>Dictionaries available:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="DictListWidget" name="dictionaries" /> <widget class="DictListWidget" name="dictionaries"/>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout" > <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QLabel" name="label_3" > <widget class="QLabel" name="label_3">
<property name="text" > <property name="text">
<string>Groups:</string> <string>Groups:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="DictGroupsWidget" name="groups" > <widget class="DictGroupsWidget" name="groups">
<property name="tabPosition" > <property name="tabPosition">
<enum>QTabWidget::North</enum> <enum>QTabWidget::North</enum>
</property> </property>
<property name="elideMode" > <property name="elideMode">
<enum>Qt::ElideRight</enum> <enum>Qt::ElideRight</enum>
</property> </property>
<widget class="QWidget" name="tab_4" > <widget class="QWidget" name="tab_4">
<attribute name="title" > <attribute name="title">
<string>Tab 2</string> <string>Tab 2</string>
</attribute> </attribute>
</widget> </widget>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout" > <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QPushButton" name="addGroup" > <widget class="QPushButton" name="addGroup">
<property name="text" > <property name="toolTip">
<string>Create new dictionary group</string>
</property>
<property name="text">
<string>&amp;Add group</string> <string>&amp;Add group</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="renameGroup" > <widget class="QPushButton" name="renameGroup">
<property name="text" > <property name="toolTip">
<string>Rename current dictionary group</string>
</property>
<property name="text">
<string>Re&amp;name group</string> <string>Re&amp;name group</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="removeGroup" > <widget class="QPushButton" name="removeGroup">
<property name="text" > <property name="toolTip">
<string>Remove current dictionary group</string>
</property>
<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>
@ -86,21 +106,21 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_4" > <widget class="QLabel" name="label_4">
<property name="text" > <property name="text">
<string>Drag&amp;drop dictionaries to and from the groups, move them inside the groups, reorder the groups using your mouse.</string> <string>Drag&amp;drop dictionaries to and from the groups, move them inside the groups, reorder the groups using your mouse.</string>
</property> </property>
<property name="wordWrap" > <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="buttons" > <widget class="QDialogButtonBox" name="buttons">
<property name="orientation" > <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons" > <property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
@ -128,11 +148,11 @@
<receiver>Groups</receiver> <receiver>Groups</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>248</x> <x>248</x>
<y>254</y> <y>254</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>157</x> <x>157</x>
<y>274</y> <y>274</y>
</hint> </hint>
@ -144,11 +164,11 @@
<receiver>Groups</receiver> <receiver>Groups</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>316</x> <x>316</x>
<y>260</y> <y>260</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>286</x> <x>286</x>
<y>274</y> <y>274</y>
</hint> </hint>

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;