diff options
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/ContactEditController.cpp | 5 | ||||
-rw-r--r-- | Swift/Controllers/ContactEditController.h | 3 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/ContactEditWindow.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtContactEditWidget.cpp | 1 | ||||
-rw-r--r-- | Swift/QtUI/QtContactEditWindow.cpp | 69 | ||||
-rw-r--r-- | Swift/QtUI/QtContactEditWindow.h | 18 | ||||
-rw-r--r-- | Swift/QtUI/SConscript | 1 | ||||
-rw-r--r-- | Swift/QtUI/UserSearch/QtUserSearchWindow.cpp | 35 |
8 files changed, 42 insertions, 92 deletions
diff --git a/Swift/Controllers/ContactEditController.cpp b/Swift/Controllers/ContactEditController.cpp index a8f7811..de99895 100644 --- a/Swift/Controllers/ContactEditController.cpp +++ b/Swift/Controllers/ContactEditController.cpp @@ -60,14 +60,13 @@ void ContactEditController::handleRemoveContactRequest() { contactEditWindow->hide(); } -void ContactEditController::handleChangeContactRequest(const String& name, const std::vector<String>& groups) { +void ContactEditController::handleChangeContactRequest(const String& name, const std::set<String>& newGroups) { std::vector<String> oldGroupsVector = currentContact->getGroups(); std::set<String> oldGroups(oldGroupsVector.begin(), oldGroupsVector.end()); - std::set<String> newGroups(groups.begin(), groups.end()); if (oldGroups != newGroups || currentContact->getName() != name) { XMPPRosterItem newContact(*currentContact); newContact.setName(name); - newContact.setGroups(groups); + newContact.setGroups(std::vector<String>(newGroups.begin(), newGroups.end())); rosterController->updateItem(newContact); } contactEditWindow->hide(); diff --git a/Swift/Controllers/ContactEditController.h b/Swift/Controllers/ContactEditController.h index 31917b1..b5c8101 100644 --- a/Swift/Controllers/ContactEditController.h +++ b/Swift/Controllers/ContactEditController.h @@ -7,6 +7,7 @@ #pragma once #include <vector> +#include <set> #include <boost/optional.hpp> #include <Swiften/JID/JID.h> @@ -29,7 +30,7 @@ namespace Swift { private: void handleRemoveContactRequest(); - void handleChangeContactRequest(const String& name, const std::vector<String>& groups); + void handleChangeContactRequest(const String& name, const std::set<String>& groups); private: void handleUIEvent(UIEvent::ref event); diff --git a/Swift/Controllers/UIInterfaces/ContactEditWindow.h b/Swift/Controllers/UIInterfaces/ContactEditWindow.h index 3feb718..fe552c2 100644 --- a/Swift/Controllers/UIInterfaces/ContactEditWindow.h +++ b/Swift/Controllers/UIInterfaces/ContactEditWindow.h @@ -28,6 +28,6 @@ namespace Swift { virtual void hide() = 0; boost::signal<void ()> onRemoveContactRequest; - boost::signal<void (const String& /* name */, const std::vector<String>& /* groups */)> onChangeContactRequest; + boost::signal<void (const String& /* name */, const std::set<String>& /* groups */)> onChangeContactRequest; }; } diff --git a/Swift/QtUI/QtContactEditWidget.cpp b/Swift/QtUI/QtContactEditWidget.cpp index 50d964b..1f97a37 100644 --- a/Swift/QtUI/QtContactEditWidget.cpp +++ b/Swift/QtUI/QtContactEditWidget.cpp @@ -21,6 +21,7 @@ namespace Swift { QtContactEditWidget::QtContactEditWidget(const std::set<String>& allGroups, QWidget* parent) : QWidget(parent), groups_(NULL) { QBoxLayout* layout = new QVBoxLayout(this); setContentsMargins(0,0,0,0); + layout->setContentsMargins(0,0,0,0); QHBoxLayout* nameLayout = new QHBoxLayout(); diff --git a/Swift/QtUI/QtContactEditWindow.cpp b/Swift/QtUI/QtContactEditWindow.cpp index 6eb4316..0781f64 100644 --- a/Swift/QtUI/QtContactEditWindow.cpp +++ b/Swift/QtUI/QtContactEditWindow.cpp @@ -13,40 +13,28 @@ #include <QLabel> #include <QCheckBox> #include <QLineEdit> -#include <QDialogButtonBox> #include <QMessageBox> #include <QPushButton> #include "Swift/QtUI/QtSwiftUtil.h" +#include "QtContactEditWidget.h" namespace Swift { -QtContactEditWindow::QtContactEditWindow() : groups_(NULL) { +QtContactEditWindow::QtContactEditWindow() : contactEditWidget_(NULL) { resize(300,300); setWindowTitle("Edit contact"); + setContentsMargins(0,0,0,0); QBoxLayout* layout = new QVBoxLayout(this); - setContentsMargins(0,0,0,0); jidLabel_ = new QLabel(this); jidLabel_->setAlignment(Qt::AlignHCenter); layout->addWidget(jidLabel_); - QHBoxLayout* nameLayout = new QHBoxLayout(); - - QLabel* label = new QLabel("Name:", this); - nameLayout->addWidget(label); - name_ = new QLineEdit(this); - nameLayout->addWidget(name_); - layout->addLayout(nameLayout); - - layout->addWidget(new QLabel("Groups:", this)); - - groupsArea_ = new QScrollArea(this); - layout->addWidget(groupsArea_); - groupsArea_->setWidgetResizable(true); - groupsArea_->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - groupsArea_->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + groupsLayout_ = new QVBoxLayout(); + groupsLayout_->setContentsMargins(0,0,0,0); + layout->addLayout(groupsLayout_); QHBoxLayout* buttonLayout = new QHBoxLayout(); layout->addLayout(buttonLayout); @@ -60,38 +48,14 @@ QtContactEditWindow::QtContactEditWindow() : groups_(NULL) { } void QtContactEditWindow::setContact(const JID& jid, const String& name, const std::vector<String>& groups, const std::set<String>& allGroups) { + delete contactEditWidget_; jid_ = jid; - jidLabel_->setText("<b>" + P2QSTRING(jid.toString()) + "</b>"); - name_->setText(P2QSTRING(name)); - - delete groups_; - checkBoxes_.clear(); - groups_ = new QWidget(groupsArea_); - groupsArea_->setWidget(groups_); - QVBoxLayout* scrollLayout = new QVBoxLayout(groups_); - - foreach (String group, allGroups) { - QCheckBox* check = new QCheckBox(groups_); - check->setText(P2QSTRING(group)); - check->setCheckState(Qt::Unchecked); - checkBoxes_[group] = check; - scrollLayout->addWidget(check); - } - foreach (String group, groups) { - checkBoxes_[group]->setCheckState(Qt::Checked); - } - - QHBoxLayout* newGroupLayout = new QHBoxLayout(); - newGroup_ = new QCheckBox(groups_); - newGroup_->setText("New Group:"); - newGroup_->setCheckState(Qt::Unchecked); - newGroupLayout->addWidget(newGroup_); - newGroupName_ = new QLineEdit(groups_); - newGroupLayout->addWidget(newGroupName_); - scrollLayout->addLayout(newGroupLayout); - scrollLayout->addItem(new QSpacerItem(20, 73, QSizePolicy::Minimum, QSizePolicy::Expanding)); + contactEditWidget_ = new QtContactEditWidget(allGroups, this); + groupsLayout_->addWidget(contactEditWidget_); + contactEditWidget_->setName(name); + contactEditWidget_->setSelectedGroups(groups); } void QtContactEditWindow::setEnabled(bool b) { @@ -121,16 +85,7 @@ void QtContactEditWindow::handleRemoveContact() { } void QtContactEditWindow::handleUpdateContact() { - std::vector<String> groups; - foreach(const CheckBoxMap::value_type& group, checkBoxes_) { - if (group.second->checkState() == Qt::Checked) { - groups.push_back(group.first); - } - } - if (newGroup_->checkState() == Qt::Checked && !newGroupName_->text().isEmpty()) { - groups.push_back(Q2PSTRING(newGroupName_->text())); - } - onChangeContactRequest(Q2PSTRING(name_->text()), groups); + onChangeContactRequest(contactEditWidget_->getName(), contactEditWidget_->getSelectedGroups()); } } diff --git a/Swift/QtUI/QtContactEditWindow.h b/Swift/QtUI/QtContactEditWindow.h index a731480..25ea9b7 100644 --- a/Swift/QtUI/QtContactEditWindow.h +++ b/Swift/QtUI/QtContactEditWindow.h @@ -6,21 +6,18 @@ #pragma once -#include <map> -#include <boost/shared_ptr.hpp> - #include <QWidget> #include <Swift/Controllers/UIInterfaces/ContactEditWindow.h> #include <Swiften/Base/String.h> #include <Swiften/JID/JID.h> -class QScrollArea; class QLabel; -class QLineEdit; -class QCheckBox; +class QVBoxLayout; namespace Swift { + class QtContactEditWidget; + class QtContactEditWindow : public QWidget, public ContactEditWindow { Q_OBJECT @@ -38,15 +35,10 @@ namespace Swift { void handleUpdateContact(); private: - typedef std::map<String, QCheckBox*> CheckBoxMap; JID jid_; + QVBoxLayout* groupsLayout_; QLabel* jidLabel_; - CheckBoxMap checkBoxes_; - QLineEdit* name_; - QScrollArea* groupsArea_; - QWidget* groups_; - QCheckBox* newGroup_; - QLineEdit* newGroupName_; + QtContactEditWidget* contactEditWidget_; }; } diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index e0d29a0..6238693 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -91,6 +91,7 @@ sources = [ "QtAddBookmarkWindow.cpp", "QtEditBookmarkWindow.cpp", "QtContactEditWindow.cpp", + "QtContactEditWidget.cpp", "ChatSnippet.cpp", "MessageSnippet.cpp", "SystemMessageSnippet.cpp", diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp index 6a97e3a..911d410 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp @@ -28,17 +28,6 @@ QtUserSearchFirstPage::QtUserSearchFirstPage(UserSearchWindow::Type type, const connect(service_, SIGNAL(textChanged(const QString&)), this, SLOT(emitCompletenessCheck())); } -QtUserSearchFieldsPage::QtUserSearchFieldsPage() { - setupUi(this); -} - -QtUserSearchResultsPage::QtUserSearchResultsPage() { - setupUi(this); - connect(results_, SIGNAL(activated(const QModelIndex&)), this, SLOT(emitCompletenessCheck())); - connect(results_, SIGNAL(clicked(const QModelIndex&)), this, SLOT(emitCompletenessCheck())); - connect(results_, SIGNAL(entered(const QModelIndex&)), this, SLOT(emitCompletenessCheck())); -} - bool QtUserSearchFirstPage::isComplete() const { bool complete = false; if (byJID_->isChecked()) { @@ -51,22 +40,34 @@ bool QtUserSearchFirstPage::isComplete() const { return complete; } -bool QtUserSearchFieldsPage::isComplete() const { - return nickInput_->isEnabled() || firstInput_->isEnabled() || lastInput_->isEnabled() || emailInput_->isEnabled(); +void QtUserSearchFirstPage::emitCompletenessCheck() { + emit completeChanged(); } -bool QtUserSearchResultsPage::isComplete() const { - return results_->currentIndex().isValid(); + +QtUserSearchFieldsPage::QtUserSearchFieldsPage() { + setupUi(this); } -void QtUserSearchFirstPage::emitCompletenessCheck() { - emit completeChanged(); +bool QtUserSearchFieldsPage::isComplete() const { + return nickInput_->isEnabled() || firstInput_->isEnabled() || lastInput_->isEnabled() || emailInput_->isEnabled(); } void QtUserSearchFieldsPage::emitCompletenessCheck() { emit completeChanged(); } +QtUserSearchResultsPage::QtUserSearchResultsPage() { + setupUi(this); + connect(results_, SIGNAL(activated(const QModelIndex&)), this, SLOT(emitCompletenessCheck())); + connect(results_, SIGNAL(clicked(const QModelIndex&)), this, SLOT(emitCompletenessCheck())); + connect(results_, SIGNAL(entered(const QModelIndex&)), this, SLOT(emitCompletenessCheck())); +} + +bool QtUserSearchResultsPage::isComplete() const { + return results_->currentIndex().isValid(); +} + void QtUserSearchResultsPage::emitCompletenessCheck() { emit completeChanged(); } |