diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-02-26 14:34:03 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-02-26 14:34:03 (GMT) |
commit | e4807335c4e38dc2f047d400641c65448854b062 (patch) | |
tree | 1fa0dba9152e41b40e3c5794fd9ab993b9348230 /Swift/QtUI | |
parent | 3ea985154d59de3a3994c43d9b3dd36d089cfe2c (diff) | |
download | swift-contrib-e4807335c4e38dc2f047d400641c65448854b062.zip swift-contrib-e4807335c4e38dc2f047d400641c65448854b062.tar.bz2 |
Add "Edit details" section to Add User widget.
Resolves: #618
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtContactEditWidget.cpp | 7 | ||||
-rw-r--r-- | Swift/QtUI/QtContactEditWidget.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtUIFactory.cpp | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtUIFactory.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/SConscript | 1 | ||||
-rw-r--r-- | Swift/QtUI/UserSearch/QtUserSearchResultsPage.cpp | 2 | ||||
-rw-r--r-- | Swift/QtUI/UserSearch/QtUserSearchResultsPage.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/UserSearch/QtUserSearchWindow.cpp | 27 | ||||
-rw-r--r-- | Swift/QtUI/UserSearch/QtUserSearchWindow.h | 5 |
9 files changed, 38 insertions, 14 deletions
diff --git a/Swift/QtUI/QtContactEditWidget.cpp b/Swift/QtUI/QtContactEditWidget.cpp index fbc9685..a5134e4 100644 --- a/Swift/QtUI/QtContactEditWidget.cpp +++ b/Swift/QtUI/QtContactEditWidget.cpp @@ -90,4 +90,11 @@ std::set<std::string> QtContactEditWidget::getSelectedGroups() const { return groups; } +void QtContactEditWidget::clear() { + name_->clear(); + setSelectedGroups(std::vector<std::string>()); + newGroup_->setChecked(false); + newGroupName_->clear(); +} + } diff --git a/Swift/QtUI/QtContactEditWidget.h b/Swift/QtUI/QtContactEditWidget.h index 26a9968..8ff267d 100644 --- a/Swift/QtUI/QtContactEditWidget.h +++ b/Swift/QtUI/QtContactEditWidget.h @@ -30,6 +30,8 @@ namespace Swift { void setSelectedGroups(const std::vector<std::string>& groups); std::set<std::string> getSelectedGroups() const; + void clear(); + private: typedef std::map<std::string, QCheckBox*> CheckBoxMap; CheckBoxMap checkBoxes_; diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp index 4832205..35fbfcd 100644 --- a/Swift/QtUI/QtUIFactory.cpp +++ b/Swift/QtUI/QtUIFactory.cpp @@ -83,8 +83,8 @@ ChatWindow* QtUIFactory::createChatWindow(const JID& contact, UIEventStream* eve return chatWindowFactory->createChatWindow(contact, eventStream); } -UserSearchWindow* QtUIFactory::createUserSearchWindow(UserSearchWindow::Type type, UIEventStream* eventStream) { - return new QtUserSearchWindow(eventStream, type); +UserSearchWindow* QtUIFactory::createUserSearchWindow(UserSearchWindow::Type type, UIEventStream* eventStream, const std::set<std::string>& groups) { + return new QtUserSearchWindow(eventStream, type, groups); }; JoinMUCWindow* QtUIFactory::createJoinMUCWindow() { diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h index aa88fa3..ddaaf6e 100644 --- a/Swift/QtUI/QtUIFactory.h +++ b/Swift/QtUI/QtUIFactory.h @@ -33,7 +33,7 @@ namespace Swift { virtual ChatListWindow* createChatListWindow(UIEventStream*); virtual MUCSearchWindow* createMUCSearchWindow(); virtual ChatWindow* createChatWindow(const JID &contact, UIEventStream* eventStream); - virtual UserSearchWindow* createUserSearchWindow(UserSearchWindow::Type type, UIEventStream* eventStream); + virtual UserSearchWindow* createUserSearchWindow(UserSearchWindow::Type type, UIEventStream* eventStream, const std::set<std::string>& groups); virtual JoinMUCWindow* createJoinMUCWindow(); virtual ProfileWindow* createProfileWindow(); virtual ContactEditWindow* createContactEditWindow(); diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index ee720a1..b8c3ebe 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -121,6 +121,7 @@ sources = [ "UserSearch/QtUserSearchFirstPage.cpp", "UserSearch/QtUserSearchFieldsPage.cpp", "UserSearch/QtUserSearchResultsPage.cpp", + "UserSearch/QtUserSearchDetailsPage.cpp", "UserSearch/QtUserSearchWindow.cpp", "UserSearch/UserSearchModel.cpp", "UserSearch/UserSearchDelegate.cpp", diff --git a/Swift/QtUI/UserSearch/QtUserSearchResultsPage.cpp b/Swift/QtUI/UserSearch/QtUserSearchResultsPage.cpp index c5fa85a..bc6933e7 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchResultsPage.cpp +++ b/Swift/QtUI/UserSearch/QtUserSearchResultsPage.cpp @@ -11,7 +11,7 @@ namespace Swift { QtUserSearchResultsPage::QtUserSearchResultsPage() { setupUi(this); connect(results_, SIGNAL(activated(const QModelIndex&)), this, SLOT(emitCompletenessCheck())); - connect(results_, SIGNAL(activated(const QModelIndex&)), this, SIGNAL(onUserTriggersFinish())); + connect(results_, SIGNAL(activated(const QModelIndex&)), this, SIGNAL(onUserTriggersContinue())); connect(results_, SIGNAL(clicked(const QModelIndex&)), this, SLOT(emitCompletenessCheck())); connect(results_, SIGNAL(entered(const QModelIndex&)), this, SLOT(emitCompletenessCheck())); results_->setExpandsOnDoubleClick(false); diff --git a/Swift/QtUI/UserSearch/QtUserSearchResultsPage.h b/Swift/QtUI/UserSearch/QtUserSearchResultsPage.h index 855d6b3..2bb4fa5 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchResultsPage.h +++ b/Swift/QtUI/UserSearch/QtUserSearchResultsPage.h @@ -17,7 +17,7 @@ namespace Swift { QtUserSearchResultsPage(); virtual bool isComplete() const; signals: - void onUserTriggersFinish(); + void onUserTriggersContinue(); public slots: void emitCompletenessCheck(); }; diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp index 2927c9b..2c1de3d 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp @@ -6,10 +6,10 @@ #include "Swift/QtUI/UserSearch/QtUserSearchWindow.h" -#include <qdebug.h> #include <QModelIndex> #include <QWizardPage> #include <QMovie> +#include <boost/smart_ptr/make_shared.hpp> #include "Swift/Controllers/UIEvents/UIEventStream.h" #include "Swift/Controllers/UIEvents/RequestChatUIEvent.h" @@ -20,10 +20,11 @@ #include "QtUserSearchFirstPage.h" #include "QtUserSearchFieldsPage.h" #include "QtUserSearchResultsPage.h" +#include "QtUserSearchDetailsPage.h" namespace Swift { -QtUserSearchWindow::QtUserSearchWindow(UIEventStream* eventStream, UserSearchWindow::Type type) : eventStream_(eventStream), type_(type) { +QtUserSearchWindow::QtUserSearchWindow(UIEventStream* eventStream, UserSearchWindow::Type type, const std::set<std::string>& groups) : eventStream_(eventStream), type_(type) { setupUi(this); #ifndef Q_WS_MAC setWindowIcon(QIcon(":/logo-icon-16.png")); @@ -56,8 +57,16 @@ QtUserSearchWindow::QtUserSearchWindow(UIEventStream* eventStream, UserSearchWin #ifdef SWIFT_PLATFORM_MACOSX resultsPage_->results_->setAlternatingRowColors(true); #endif + if (type == AddContact) { + connect(resultsPage_, SIGNAL(onUserTriggersContinue()), this, SLOT(next())); + } + else { + connect(resultsPage_, SIGNAL(onUserTriggersContinue()), this, SLOT(accept())); + } setPage(3, resultsPage_); - connect(resultsPage_, SIGNAL(onUserTriggersFinish()), this, SLOT(accept())); + + detailsPage_ = new QtUserSearchDetailsPage(groups); + setPage(4, detailsPage_); connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(handleCurrentChanged(int))); connect(this, SIGNAL(accepted()), this, SLOT(handleAccepted())); @@ -79,6 +88,9 @@ void QtUserSearchWindow::handleCurrentChanged(int page) { else if (page == 3 && lastPage_ == 2) { handleSearch(); } + else if (page == 4) { + detailsPage_->clear(); + } lastPage_ = page; } @@ -97,10 +109,9 @@ void QtUserSearchWindow::handleAccepted() { else { jid = JID(Q2PSTRING(firstPage_->jid_->text())); } + if (type_ == AddContact) { - /* FIXME: allow specifying a nick */ - boost::shared_ptr<UIEvent> event(new AddContactUIEvent(jid, jid.toString())); - eventStream_->send(event); + eventStream_->send(boost::make_shared<AddContactUIEvent>(jid, detailsPage_->getName(), detailsPage_->getSelectedGroups())); } else { boost::shared_ptr<UIEvent> event(new RequestChatUIEvent(jid)); @@ -110,9 +121,9 @@ void QtUserSearchWindow::handleAccepted() { int QtUserSearchWindow::nextId() const { switch (currentId()) { - case 1: return firstPage_->byJID_->isChecked() ? -1 : 2; + case 1: return firstPage_->byJID_->isChecked() ? (type_ == AddContact ? 4 : -1) : 2; case 2: return 3; - case 3: return 4; + case 3: return type_ == AddContact ? 4 : -1; case 4: return -1; default: return -1; } diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.h b/Swift/QtUI/UserSearch/QtUserSearchWindow.h index 6c90731..bb40cd3 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.h +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.h @@ -7,6 +7,7 @@ #pragma once #include <QWizard> +#include <set> #include <Swift/QtUI/UserSearch/ui_QtUserSearchWizard.h> #include <Swift/Controllers/UIInterfaces/UserSearchWindow.h> @@ -19,11 +20,12 @@ namespace Swift { class QtUserSearchFirstPage; class QtUserSearchFieldsPage; class QtUserSearchResultsPage; + class QtUserSearchDetailsPage; class QtUserSearchWindow : public QWizard, public UserSearchWindow, private Ui::QtUserSearchWizard { Q_OBJECT public: - QtUserSearchWindow(UIEventStream* eventStream, UserSearchWindow::Type type); + QtUserSearchWindow(UIEventStream* eventStream, UserSearchWindow::Type type, const std::set<std::string>& groups); virtual ~QtUserSearchWindow(); virtual void addSavedServices(const std::vector<JID>& services); @@ -55,6 +57,7 @@ namespace Swift { QtUserSearchFirstPage* firstPage_; QtUserSearchFieldsPage* fieldsPage_; QtUserSearchResultsPage* resultsPage_; + QtUserSearchDetailsPage* detailsPage_; JID myServer_; int lastPage_; }; |