From 23a1824e08ea34e660ab6a18d386bacd69a8f770 Mon Sep 17 00:00:00 2001 From: Lubos Dolezel Date: Wed, 3 Jun 2015 14:08:31 +0200 Subject: selectprofileform ported to Qt4 --- TODO | 1 - src/gui/selectprofileform.cpp | 97 +++--- src/gui/selectprofileform.h | 4 +- src/gui/selectprofileform.ui | 734 ++++++++++++++++++++++++------------------ 4 files changed, 468 insertions(+), 368 deletions(-) diff --git a/TODO b/TODO index 0ab5919..e326a8f 100644 --- a/TODO +++ b/TODO @@ -7,7 +7,6 @@ Remaining .ui/cpp/h files: * mphoneform - * selectprofileform * selectuserform * syssettingsform * userprofileform diff --git a/src/gui/selectprofileform.cpp b/src/gui/selectprofileform.cpp index 06465d6..6c39d71 100644 --- a/src/gui/selectprofileform.cpp +++ b/src/gui/selectprofileform.cpp @@ -29,7 +29,7 @@ #include "audits/memman.h" #include "wizardform.h" #include "syssettingsform.h" -#include +#include #include "service.h" #include "presence/buddy.h" #include "diamondcardprofileform.h" @@ -140,7 +140,7 @@ int SelectProfileForm::execForm() return QDialog::Rejected; } - if (profileListView->childCount() == 0) { + if (profileListView->count() == 0) { // No profile has been created. return QDialog::Rejected; } @@ -193,25 +193,26 @@ void SelectProfileForm::showForm(Q3MainWindow *_mainWindow) // Initialize profile list view fillProfileListView(profiles); - Q3ListViewItemIterator j(profileListView); - while (j.current()) { - Q3CheckListItem *item = (Q3CheckListItem *)j.current(); - QString profile = item->text(); + + for (int i = 0; i < profileListView->count(); i++) + { + QListWidgetItem* item = profileListView->item(i); + QString profile = item->text(); // Set pixmap of default profile list l = sys_config->get_start_user_profiles(); if (std::find(l.begin(), l.end(), profile.ascii()) != l.end()) { - item->setPixmap(0, QPixmap(":/icons/images/twinkle16.png")); + item->setData(Qt::DecorationRole, QPixmap(":/icons/images/twinkle16.png")); defaultSet = true; } // Tick check box of active profile + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + if (phone->ref_user_profile(profile.ascii())) { - item->setOn(true); + item->setCheckState(Qt::Checked); } - - j++; } sysPushButton->hide(); @@ -223,13 +224,13 @@ void SelectProfileForm::showForm(Q3MainWindow *_mainWindow) void SelectProfileForm::runProfile() { selectedProfiles.clear(); - Q3ListViewItemIterator i(profileListView, Q3ListViewItemIterator::Checked); - while (i.current()) { - Q3CheckListItem *item = (Q3CheckListItem *)i.current(); - QString profile =item->text(); + + for (int i = 0; i < profileListView->count(); i++) + { + QListWidgetItem* item = profileListView->item(i); + QString profile = item->text(); profile.append(USER_FILE_EXT); selectedProfiles.push_back(profile.ascii()); - i++; } if (selectedProfiles.empty()) { @@ -343,16 +344,17 @@ void SelectProfileForm::newProfileCreated() { // New profile created // Add the new profile to the profile list box - Q3CheckListItem *item = new Q3CheckListItem(profileListView, - user_config->get_profile_name().c_str(), - Q3CheckListItem::CheckBox); - item->setPixmap(0, QPixmap(":/icons/images/penguin-small.png")); + QListWidgetItem* item = new QListWidgetItem(QPixmap(":/icons/images/penguin-small.png"), + QString::fromStdString(user_config->get_profile_name()), + profileListView); + + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // Make the new profile the selected profile // Do not change this without changing the exec method. // When there are no profiles, the exec methods relies on the // fact that afer creation of the profile it is selected. - profileListView->setSelected(item, true); + profileListView->setCurrentItem(item); // Enable buttons that act on a profile editPushButton->setEnabled(true); @@ -418,7 +420,7 @@ void SelectProfileForm::deleteProfile() Q3CheckListItem *item = (Q3CheckListItem *)profileListView-> currentItem(); delete item; - if (profileListView->childCount() == 0) { + if (profileListView->count() == 0) { // There are no profiles anymore // Disable buttons that act on a profile editPushButton->setEnabled(false); @@ -427,8 +429,7 @@ void SelectProfileForm::deleteProfile() defaultPushButton->setEnabled(false); runPushButton->setEnabled(false); } else { - profileListView->setSelected(profileListView-> - firstChild(), true); + profileListView->setCurrentItem(profileListView->item(0)); } } } @@ -541,22 +542,23 @@ void SelectProfileForm::setAsDefault() defaultSet = true; // Restore all pixmaps - Q3ListViewItemIterator i(profileListView); - while (i.current()) { - i.current()->setPixmap(0, QPixmap(":/icons/images/penguin-small.png")); - i++; - } - - // Set pixmap of the default profiles. - // Set default profiles in system settings. - list l; - Q3ListViewItemIterator j(profileListView, Q3ListViewItemIterator::Checked); - while (j.current()) { - Q3CheckListItem *item = (Q3CheckListItem *)j.current(); - item->setPixmap(0, QPixmap(":/icons/images/twinkle16.png")); - l.push_back(item->text().ascii()); - j++; + // Set pixmap of the default profiles. + // Set default profiles in system settings. + list l; + for (int i = 0; i < profileListView->count(); i++) { + QListWidgetItem* item = profileListView->item(i); + + if (item->checkState() == Qt::Checked) + { + item->setData(Qt::DecorationRole, QPixmap(":/icons/images/twinkle16.png")); + l.push_back(item->text().ascii()); + } + else + { + item->setData(Qt::DecorationRole, QPixmap(":/icons/images/penguin-small.png")); + } } + sys_config->set_start_user_profiles(l); // Write default to system settings @@ -666,18 +668,23 @@ void SelectProfileForm::fillProfileListView(const QStringList &profiles) // Strip off the user file extension QString profile = *i; profile.truncate(profile.length() - strlen(USER_FILE_EXT)); - Q3CheckListItem *item = new Q3CheckListItem( - profileListView, profile, Q3CheckListItem::CheckBox); - item->setPixmap(0, QPixmap(":/icons/images/penguin-small.png")); + + QListWidgetItem* item = new QListWidgetItem(QPixmap(":/icons/images/penguin-small.png"), profile, profileListView); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(Qt::Unchecked); } // Highlight the first profile - profileListView->setSelected(profileListView->firstChild(), true); + profileListView->setCurrentItem(profileListView->item(0)); } -void SelectProfileForm::toggleItem(Q3ListViewItem *item) +void SelectProfileForm::toggleItem(QModelIndex index) { - Q3CheckListItem *checkItem = (Q3CheckListItem *)item; - checkItem->setOn(!checkItem->isOn()); + QListWidgetItem* item = profileListView->item(index.row()); + Qt::CheckState state = item->checkState(); + if (state == Qt::Checked) + item->setCheckState(Qt::Unchecked); + else + item->setCheckState(Qt::Checked); } diff --git a/src/gui/selectprofileform.h b/src/gui/selectprofileform.h index 81c2be5..7c9b0a5 100644 --- a/src/gui/selectprofileform.h +++ b/src/gui/selectprofileform.h @@ -6,7 +6,7 @@ extern t_phone *phone; #include #include #include "phone.h" -#include +#include #include "ui_selectprofileform.h" class SelectProfileForm : public QDialog, public Ui::SelectProfileForm @@ -38,7 +38,7 @@ public slots: virtual void diamondcardProfile( bool exec_mode ); virtual void sysSettings(); virtual void fillProfileListView( const QStringList & profiles ); - virtual void toggleItem( Q3ListViewItem * item ); + virtual void toggleItem( QModelIndex item ); signals: void selection(const list &); diff --git a/src/gui/selectprofileform.ui b/src/gui/selectprofileform.ui index 1b3df44..6510d04 100644 --- a/src/gui/selectprofileform.ui +++ b/src/gui/selectprofileform.ui @@ -1,330 +1,424 @@ - - - - - SelectProfileForm - - - - 0 - 0 - 501 - 513 - - - - Twinkle - Select user profile - - - - - - - 5 - 0 - 0 - 0 - + + SelectProfileForm + + + + 0 + 0 + 499 + 511 + + + + Twinkle - Select user profile + + + + + + + 0 + 0 + + + + Select user profile(s) to run: + + + Qt::AlignVCenter + + + true + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + Create profile + + + + + + Create a new profile with the profile editor. - Select user profile(s) to run: + Ed&itor - - Qt::AlignVCenter + + Alt+I - - true + + + + + + Create a new profile with the wizard. - - - - - - Q3ListView::LastColumn + + &Wizard + + + Alt+W + + + + + + + Create a profile for a Diamondcard account. With a Diamondcard account you can make worldwide calls to regular and cell phones and send SMS messages. + + + Dia&mondcard + + + Alt+M + + + + + + + + + + Modify profile + + + + + + Edit the highlighted profile. + + + &Edit + + + Alt+E + + + + + + + Delete the highlighted profile. + + + &Delete + + + Alt+D + + + + + + + Rename the highlighted profile. + + + Ren&ame + + + Alt+A + + + + + + + + + + Startup profile + + + + + + Make the selected profiles the default profiles. The next time you start Twinkle, these profiles will be automatically run. + + + &Set as default + + + Alt+S + + + + + + + Run Twinkle with the selected profiles. + + + &Run + + + Alt+R - - Tick the check boxes of the user profiles that you want to run and press run. + + true - - - User profile - - - true - - - true - - - - - - - - - - - 20 - 20 - - - - QSizePolicy::Expanding - - - Qt::Vertical - - - - - - - Create profile - - - - - - Ed&itor - - - Alt+I - - - Create a new profile with the profile editor. - - - - - - - &Wizard - - - Alt+W - - - Create a new profile with the wizard. - - - - - - - Dia&mondcard - - - Alt+M - - - Create a profile for a Diamondcard account. With a Diamondcard account you can make worldwide calls to regular and cell phones and send SMS messages. - - - - - - - - - - Modify profile - - - - - - &Edit - - - Alt+E - - - Edit the highlighted profile. - - - - - - - &Delete - - - Alt+D - - - Delete the highlighted profile. - - - - - - - Ren&ame - - - Alt+A - - - Rename the highlighted profile. - - - - - - - - - - Startup profile - - - - - - &Set as default - - - Alt+S - - - Make the selected profiles the default profiles. The next time you start Twinkle, these profiles will be automatically run. - - - - - - - &Run - - - Alt+R - - - true - - - Run Twinkle with the selected profiles. - - - - - - - - - - S&ystem settings - - - Alt+Y - - - Edit the system settings. - - - - - - - &Cancel - - - Alt+C - - - - - + + + + + + + + + Edit the system settings. + + + S&ystem settings + + + Alt+Y + + + + + + + &Cancel + + + Alt+C + + + - - - - - profileListView - newPushButton - wizardPushButton - diamondcardPushButton - editPushButton - deletePushButton - renamePushButton - defaultPushButton - runPushButton - sysPushButton - cancelPushButton - - - list - string - phone.h - q3mainwindow.h - - - - cancelPushButton - clicked() - SelectProfileForm - reject() - - - runPushButton - clicked() - SelectProfileForm - runProfile() - - - editPushButton - clicked() - SelectProfileForm - editProfile() - - - newPushButton - clicked() - SelectProfileForm - newProfile() - - - deletePushButton - clicked() - SelectProfileForm - deleteProfile() - - - renamePushButton - clicked() - SelectProfileForm - renameProfile() - - - wizardPushButton - clicked() - SelectProfileForm - wizardProfile() - - - defaultPushButton - clicked() - SelectProfileForm - setAsDefault() - - - sysPushButton - clicked() - SelectProfileForm - sysSettings() - - - profileListView - doubleClicked(Q3ListViewItem*) - SelectProfileForm - toggleItem(Q3ListViewItem*) - - - diamondcardPushButton - clicked() - SelectProfileForm - diamondcardProfile() - - + + + + + Tick the check boxes of the user profiles that you want to run and press run. + + + + + + + + profileListView + newPushButton + wizardPushButton + diamondcardPushButton + editPushButton + deletePushButton + renamePushButton + defaultPushButton + runPushButton + sysPushButton + cancelPushButton + + + list + string + phone.h + q3mainwindow.h + + + + + cancelPushButton + clicked() + SelectProfileForm + reject() + + + 392 + 501 + + + 20 + 20 + + + + + runPushButton + clicked() + SelectProfileForm + runProfile() + + + 400 + 435 + + + 20 + 20 + + + + + editPushButton + clicked() + SelectProfileForm + editProfile() + + + 400 + 289 + + + 20 + 20 + + + + + newPushButton + clicked() + SelectProfileForm + newProfile() + + + 400 + 172 + + + 20 + 20 + + + + + deletePushButton + clicked() + SelectProfileForm + deleteProfile() + + + 400 + 318 + + + 20 + 20 + + + + + renamePushButton + clicked() + SelectProfileForm + renameProfile() + + + 400 + 347 + + + 20 + 20 + + + + + wizardPushButton + clicked() + SelectProfileForm + wizardProfile() + + + 400 + 201 + + + 20 + 20 + + + + + defaultPushButton + clicked() + SelectProfileForm + setAsDefault() + + + 400 + 406 + + + 20 + 20 + + + + + sysPushButton + clicked() + SelectProfileForm + sysSettings() + + + 392 + 472 + + + 20 + 20 + + + + + diamondcardPushButton + clicked() + SelectProfileForm + diamondcardProfile() + + + 400 + 230 + + + 20 + 20 + + + + + profileListView + doubleClicked(QModelIndex) + SelectProfileForm + toggleItem(QModelIndex) + + + 228 + 131 + + + 433 + 27 + + + + + + toggleItem(QModelIndex) + -- cgit v1.2.3