From 5356dd9c0ccb352867e809e18b230fab7b859820 Mon Sep 17 00:00:00 2001 From: Lubos Dolezel Date: Wed, 3 Jun 2015 14:31:19 +0200 Subject: selectuserform ported to Qt4 --- TODO | 1 - src/gui/selectuserform.cpp | 53 +++---- src/gui/selectuserform.h | 2 +- src/gui/selectuserform.ui | 368 ++++++++++++++++++++++++--------------------- 4 files changed, 226 insertions(+), 198 deletions(-) diff --git a/TODO b/TODO index e326a8f..afad31b 100644 --- a/TODO +++ b/TODO @@ -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 #include -#include +#include #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 user_list = phone->ref_users(); for (list::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 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); 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 @@ - - - - - SelectUserForm - - - - 0 - 0 - 584 - 228 - - - - Twinkle - Select user - - - - - - &Cancel - - - Alt+C - - - - - - - &Select all - - - Alt+S - - - - - - - - 41 - 20 - - - - QSizePolicy::Expanding - - - Qt::Horizontal - - - - - - - &OK - - - Alt+O - - - true - - - - - - - C&lear all - - - Alt+L - - - - - - - - - - 1 - 5 - 0 - 0 - - - - purpose - - - false - - - - - - - Q3ScrollView::Manual - - - Q3ListView::NoSelection - - - Q3ListView::LastColumn - - - - User - - - true - - - true - - - - - - + + SelectUserForm + + + + 0 + 0 + 582 + 226 + + + + Twinkle - Select user + + + + + + &Cancel + + + Alt+C + + + + + + + &Select all + + + Alt+S + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 41 + 20 + + + + + + + + &OK + + + Alt+O + + + true + + + + + + + C&lear all + + + Alt+L + + + + + + + + + + 0 + 0 + + + + purpose + + + false + + + + + + + QAbstractItemView::NoSelection + + + - - - - - userListView - selectPushButton - clearPushButton - okPushButton - cancelPushButton - - - user.h - phone.h - gui.h - - - - okPushButton - clicked() - SelectUserForm - validate() - - - cancelPushButton - clicked() - SelectUserForm - reject() - - - selectPushButton - clicked() - SelectUserForm - selectAll() - - - clearPushButton - clicked() - SelectUserForm - clearAll() - - - userListView - doubleClicked(Q3ListViewItem*) - SelectUserForm - toggle(Q3ListViewItem*) - - + + + + + + userListView + selectPushButton + clearPushButton + okPushButton + cancelPushButton + + + user.h + phone.h + gui.h + + + + + okPushButton + clicked() + SelectUserForm + validate() + + + 20 + 20 + + + 20 + 20 + + + + + cancelPushButton + clicked() + SelectUserForm + reject() + + + 20 + 20 + + + 20 + 20 + + + + + selectPushButton + clicked() + SelectUserForm + selectAll() + + + 20 + 20 + + + 20 + 20 + + + + + clearPushButton + clicked() + SelectUserForm + clearAll() + + + 20 + 20 + + + 20 + 20 + + + + + userListView + doubleClicked(Q3ListViewItem*) + SelectUserForm + toggle(Q3ListViewItem*) + + + 20 + 20 + + + 20 + 20 + + + + -- cgit v1.2.3