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() ) );
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();
}
}

View file

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

View file

@ -1,158 +1,178 @@
<ui version="4.0" >
<class>Groups</class>
<widget class="QDialog" name="Groups" >
<property name="windowModality" >
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>726</width>
<height>535</height>
</rect>
</property>
<property name="windowTitle" >
<string>Groups</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<layout class="QVBoxLayout" name="verticalLayout_3" >
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Dictionaries available:</string>
</property>
</widget>
</item>
<item>
<widget class="DictListWidget" name="dictionaries" />
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Groups:</string>
</property>
</widget>
</item>
<item>
<widget class="DictGroupsWidget" name="groups" >
<property name="tabPosition" >
<enum>QTabWidget::North</enum>
</property>
<property name="elideMode" >
<enum>Qt::ElideRight</enum>
</property>
<widget class="QWidget" name="tab_4" >
<attribute name="title" >
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QPushButton" name="addGroup" >
<property name="text" >
<string>&amp;Add group</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="renameGroup" >
<property name="text" >
<string>Re&amp;name group</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeGroup" >
<property name="text" >
<string>&amp;Remove group</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_4" >
<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>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttons" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>DictListWidget</class>
<extends>QListWidget</extends>
<header>groups_widgets.hh</header>
</customwidget>
<customwidget>
<class>DictGroupsWidget</class>
<extends>QTabWidget</extends>
<header>groups_widgets.hh</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttons</sender>
<signal>accepted()</signal>
<receiver>Groups</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttons</sender>
<signal>rejected()</signal>
<receiver>Groups</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Groups</class>
<widget class="QDialog" name="Groups">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>726</width>
<height>535</height>
</rect>
</property>
<property name="windowTitle">
<string>Groups</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Dictionaries available:</string>
</property>
</widget>
</item>
<item>
<widget class="DictListWidget" name="dictionaries"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Groups:</string>
</property>
</widget>
</item>
<item>
<widget class="DictGroupsWidget" name="groups">
<property name="tabPosition">
<enum>QTabWidget::North</enum>
</property>
<property name="elideMode">
<enum>Qt::ElideRight</enum>
</property>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="addGroup">
<property name="toolTip">
<string>Create new dictionary group</string>
</property>
<property name="text">
<string>&amp;Add group</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="renameGroup">
<property name="toolTip">
<string>Rename current dictionary group</string>
</property>
<property name="text">
<string>Re&amp;name group</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeGroup">
<property name="toolTip">
<string>Remove current dictionary group</string>
</property>
<property name="text">
<string>&amp;Remove group</string>
</property>
</widget>
</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>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_4">
<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>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>DictListWidget</class>
<extends>QListWidget</extends>
<header>groups_widgets.hh</header>
</customwidget>
<customwidget>
<class>DictGroupsWidget</class>
<extends>QTabWidget</extends>
<header>groups_widgets.hh</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttons</sender>
<signal>accepted()</signal>
<receiver>Groups</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttons</sender>
<signal>rejected()</signal>
<receiver>Groups</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -330,3 +330,14 @@ void DictGroupsWidget::removeCurrentGroup()
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
void removeCurrentGroup();
/// Removes all the groups
void removeAllGroups();
/// Creates groups from what is currently set up
Config::Groups makeGroups() const;