diff options
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | src/gui/selectuserform.cpp | 53 | ||||
-rw-r--r-- | src/gui/selectuserform.h | 2 | ||||
-rw-r--r-- | src/gui/selectuserform.ui | 368 |
4 files changed, 226 insertions, 198 deletions
@@ -7,7 +7,6 @@ Remaining .ui/cpp/h files: * mphoneform - * selectuserform * syssettingsform * userprofileform * gui diff --git a/src/gui/selectuserform.cpp b/src/gui/selectuserform.cpp index 0a0af5a..9f1618f 100644 --- a/src/gui/selectuserform.cpp +++ b/src/gui/selectuserform.cpp @@ -21,7 +21,7 @@ #include <QImage> #include <QPixmap> -#include <Q3ListView> +#include <QListWidget> #include "selectuserform.h" /* * Constructs a SelectUserForm as a child of 'parent', with the @@ -58,8 +58,6 @@ void SelectUserForm::languageChange() void SelectUserForm::init() { - // Disable sorting - userListView->setSorting(-1); } void SelectUserForm::show(t_select_purpose purpose) @@ -99,15 +97,19 @@ void SelectUserForm::show(t_select_purpose purpose) // Fill list view list<t_user *> user_list = phone->ref_users(); for (list<t_user *>::reverse_iterator i = user_list.rbegin(); i != user_list.rend(); i++) { - Q3CheckListItem *item = new Q3CheckListItem(userListView, - (*i)->get_profile_name().c_str(), Q3CheckListItem::CheckBox); + QListWidgetItem* item = new QListWidgetItem(QString::fromStdString((*i)->get_profile_name()), userListView); + + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(Qt::Unchecked); switch (purpose) { case SELECT_DND: - item->setOn(phone->ref_service(*i)->is_dnd_active()); + if (phone->ref_service(*i)->is_dnd_active()) + item->setCheckState(Qt::Checked); break; case SELECT_AUTO_ANSWER: - item->setOn(phone->ref_service(*i)->is_auto_answer_active()); + if (phone->ref_service(*i)->is_auto_answer_active()) + item->setCheckState(Qt::Checked); break; default: break; @@ -121,10 +123,10 @@ void SelectUserForm::validate() { list<t_user *> selected_list, not_selected_list; - Q3ListViewItemIterator i(userListView); - while (i.current()) { - Q3CheckListItem *item = (Q3CheckListItem *)(i.current()); - if (item->isOn()) { + for (int i = 0; i < userListView->count(); i++) + { + QListWidgetItem *item = userListView->item(i); + if (item->checkState() == Qt::Checked) { selected_list.push_back(phone-> ref_user_profile(item->text().ascii())); } else { @@ -141,26 +143,25 @@ void SelectUserForm::validate() void SelectUserForm::selectAll() { - Q3ListViewItemIterator i(userListView); - while (i.current()) { - Q3CheckListItem *item = (Q3CheckListItem *)(i.current()); - item->setOn(true); - i++; - } + for (int i = 0; i < userListView->count(); i++) + { + QListWidgetItem *item = userListView->item(i); + item->setCheckState(Qt::Checked); + } } void SelectUserForm::clearAll() { - Q3ListViewItemIterator i(userListView); - while (i.current()) { - Q3CheckListItem *item = (Q3CheckListItem *)(i.current()); - item->setOn(false); - i++; - } + for (int i = 0; i < userListView->count(); i++) + { + QListWidgetItem *item = userListView->item(i); + item->setCheckState(Qt::Unchecked); + } } -void SelectUserForm::toggle(Q3ListViewItem *item) +void SelectUserForm::toggle(QModelIndex index) { - Q3CheckListItem *checkItem = (Q3CheckListItem *)item; - checkItem->setOn(!checkItem->isOn()); + QListWidgetItem *item = userListView->item(index.row()); + Qt::CheckState state = item->checkState(); + item->setCheckState((state == Qt::Checked) ? Qt::Unchecked : Qt::Checked); } diff --git a/src/gui/selectuserform.h b/src/gui/selectuserform.h index 898dbbf..9a9ce97 100644 --- a/src/gui/selectuserform.h +++ b/src/gui/selectuserform.h @@ -21,7 +21,7 @@ public slots: virtual void validate(); virtual void selectAll(); virtual void clearAll(); - virtual void toggle( Q3ListViewItem * item ); + virtual void toggle( QModelIndex item ); signals: void selection(list<t_user *>); diff --git a/src/gui/selectuserform.ui b/src/gui/selectuserform.ui index 87d723e..d379340 100644 --- a/src/gui/selectuserform.ui +++ b/src/gui/selectuserform.ui @@ -1,173 +1,201 @@ <?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0" stdsetdef="1"> - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>SelectUserForm</class> - <widget class="QDialog" name="SelectUserForm"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>584</width> - <height>228</height> - </rect> - </property> - <property name="windowTitle"> - <string>Twinkle - Select user</string> - </property> - <layout class="QGridLayout"> - <item row="1" column="4"> - <widget class="QPushButton" name="cancelPushButton"> - <property name="text"> - <string>&Cancel</string> - </property> - <property name="shortcut"> - <string>Alt+C</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QPushButton" name="selectPushButton"> - <property name="text"> - <string>&Select all</string> - </property> - <property name="shortcut"> - <string>Alt+S</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <spacer name="spacer47"> - <property name="sizeHint"> - <size> - <width>41</width> - <height>20</height> - </size> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </spacer> - </item> - <item row="1" column="3"> - <widget class="QPushButton" name="okPushButton"> - <property name="text"> - <string>&OK</string> - </property> - <property name="shortcut"> - <string>Alt+O</string> - </property> - <property name="default"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QPushButton" name="clearPushButton"> - <property name="text"> - <string>C&lear all</string> - </property> - <property name="shortcut"> - <string>Alt+L</string> - </property> - </widget> - </item> - <item row="0" column="0" rowspan="1" colspan="5"> - <layout class="QVBoxLayout"> - <item> - <widget class="QLabel" name="purposeTextLabel"> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>5</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string comment="No need to translate">purpose</string> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="Q3ListView" name="userListView"> - <property name="resizePolicy"> - <enum>Q3ScrollView::Manual</enum> - </property> - <property name="selectionMode"> - <enum>Q3ListView::NoSelection</enum> - </property> - <property name="resizeMode"> - <enum>Q3ListView::LastColumn</enum> - </property> - <column> - <property name="text"> - <string>User</string> - </property> - <property name="clickable"> - <bool>true</bool> - </property> - <property name="resizable"> - <bool>true</bool> - </property> - </column> - </widget> - </item> - </layout> - </item> +<ui version="4.0"> + <class>SelectUserForm</class> + <widget class="QDialog" name="SelectUserForm"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>582</width> + <height>226</height> + </rect> + </property> + <property name="windowTitle"> + <string>Twinkle - Select user</string> + </property> + <layout class="QGridLayout"> + <item row="1" column="4"> + <widget class="QPushButton" name="cancelPushButton"> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="shortcut"> + <string>Alt+C</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QPushButton" name="selectPushButton"> + <property name="text"> + <string>&Select all</string> + </property> + <property name="shortcut"> + <string>Alt+S</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <spacer name="spacer47"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>41</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="3"> + <widget class="QPushButton" name="okPushButton"> + <property name="text"> + <string>&OK</string> + </property> + <property name="shortcut"> + <string>Alt+O</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QPushButton" name="clearPushButton"> + <property name="text"> + <string>C&lear all</string> + </property> + <property name="shortcut"> + <string>Alt+L</string> + </property> + </widget> + </item> + <item row="0" column="0" colspan="5"> + <layout class="QVBoxLayout"> + <item> + <widget class="QLabel" name="purposeTextLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string comment="No need to translate">purpose</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QListWidget" name="userListView"> + <property name="selectionMode"> + <enum>QAbstractItemView::NoSelection</enum> + </property> + </widget> + </item> </layout> - </widget> - <layoutdefault spacing="6" margin="11"/> - <pixmapfunction></pixmapfunction> - <tabstops> - <tabstop>userListView</tabstop> - <tabstop>selectPushButton</tabstop> - <tabstop>clearPushButton</tabstop> - <tabstop>okPushButton</tabstop> - <tabstop>cancelPushButton</tabstop> - </tabstops> - <includes> - <include location="local">user.h</include> - <include location="local">phone.h</include> - <include location="local">gui.h</include> - </includes> - <connections> - <connection> - <sender>okPushButton</sender> - <signal>clicked()</signal> - <receiver>SelectUserForm</receiver> - <slot>validate()</slot> - </connection> - <connection> - <sender>cancelPushButton</sender> - <signal>clicked()</signal> - <receiver>SelectUserForm</receiver> - <slot>reject()</slot> - </connection> - <connection> - <sender>selectPushButton</sender> - <signal>clicked()</signal> - <receiver>SelectUserForm</receiver> - <slot>selectAll()</slot> - </connection> - <connection> - <sender>clearPushButton</sender> - <signal>clicked()</signal> - <receiver>SelectUserForm</receiver> - <slot>clearAll()</slot> - </connection> - <connection> - <sender>userListView</sender> - <signal>doubleClicked(Q3ListViewItem*)</signal> - <receiver>SelectUserForm</receiver> - <slot>toggle(Q3ListViewItem*)</slot> - </connection> - </connections> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <tabstops> + <tabstop>userListView</tabstop> + <tabstop>selectPushButton</tabstop> + <tabstop>clearPushButton</tabstop> + <tabstop>okPushButton</tabstop> + <tabstop>cancelPushButton</tabstop> + </tabstops> + <includes> + <include location="local">user.h</include> + <include location="local">phone.h</include> + <include location="local">gui.h</include> + </includes> + <resources/> + <connections> + <connection> + <sender>okPushButton</sender> + <signal>clicked()</signal> + <receiver>SelectUserForm</receiver> + <slot>validate()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>cancelPushButton</sender> + <signal>clicked()</signal> + <receiver>SelectUserForm</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>selectPushButton</sender> + <signal>clicked()</signal> + <receiver>SelectUserForm</receiver> + <slot>selectAll()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>clearPushButton</sender> + <signal>clicked()</signal> + <receiver>SelectUserForm</receiver> + <slot>clearAll()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>userListView</sender> + <signal>doubleClicked(Q3ListViewItem*)</signal> + <receiver>SelectUserForm</receiver> + <slot>toggle(Q3ListViewItem*)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> </ui> |