diff options
author | Richard Maudsley <richard.maudsley@isode.com> | 2014-01-20 11:35:33 (GMT) |
---|---|---|
committer | Richard Maudsley <richard.maudsley@isode.com> | 2014-01-20 11:35:33 (GMT) |
commit | a4c19849c82745c8bde496f2e0a928c14fcbb56d (patch) | |
tree | cd60d2b2e7a309624607219a5e3b170ae663506a | |
parent | 3a4a3a1804a0a43dd23c97287fe8d302be323bdd (diff) | |
download | swift-a4c19849c82745c8bde496f2e0a928c14fcbb56d.zip swift-a4c19849c82745c8bde496f2e0a928c14fcbb56d.tar.bz2 |
Added SuggestingJIDInput.
Change-Id: I34690b0a019da2b882a3eba28ba77e87f61bbe7a
-rw-r--r-- | Swift/Controllers/HighlightEditorController.cpp | 13 | ||||
-rw-r--r-- | Swift/Controllers/HighlightEditorController.h | 3 | ||||
-rw-r--r-- | Swift/Controllers/MainController.cpp | 3 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/HighlightEditorWindow.h | 10 | ||||
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.cpp | 16 | ||||
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.h | 2 |
6 files changed, 40 insertions, 7 deletions
diff --git a/Swift/Controllers/HighlightEditorController.cpp b/Swift/Controllers/HighlightEditorController.cpp index 66a9f25..cb2c3b8 100644 --- a/Swift/Controllers/HighlightEditorController.cpp +++ b/Swift/Controllers/HighlightEditorController.cpp @@ -15,8 +15,8 @@ namespace Swift { -HighlightEditorController::HighlightEditorController(UIEventStream* uiEventStream, ContactSuggester* contactSuggester, HighlightEditorWindowFactory* highlightEditorWindowFactory, HighlightManager* highlightManager) -: highlightEditorWindowFactory_(highlightEditorWindowFactory), highlightEditorWindow_(NULL), highlightManager_(highlightManager), contactSuggester_(contactSuggester) +HighlightEditorController::HighlightEditorController(UIEventStream* uiEventStream, HighlightEditorWindowFactory* highlightEditorWindowFactory, HighlightManager* highlightManager) +: highlightEditorWindowFactory_(highlightEditorWindowFactory), highlightEditorWindow_(NULL), highlightManager_(highlightManager), contactSuggester_(0) { uiEventStream->onUIEvent.connect(boost::bind(&HighlightEditorController::handleUIEvent, this, _1)); } @@ -34,7 +34,7 @@ void HighlightEditorController::handleUIEvent(boost::shared_ptr<UIEvent> rawEven if (!highlightEditorWindow_) { highlightEditorWindow_ = highlightEditorWindowFactory_->createHighlightEditorWindow(); highlightEditorWindow_->setHighlightManager(highlightManager_); - //highlightEditorWindow_->onContactSuggestionsRequested.connect(boost::bind(&HighlightEditorController::handleContactSuggestionsRequested, this, _1)); + highlightEditorWindow_->onContactSuggestionsRequested.connect(boost::bind(&HighlightEditorController::handleContactSuggestionsRequested, this, _1)); } highlightEditorWindow_->show(); } @@ -42,7 +42,12 @@ void HighlightEditorController::handleUIEvent(boost::shared_ptr<UIEvent> rawEven void HighlightEditorController::handleContactSuggestionsRequested(const std::string& text) { - //highlightEditorWindow_->setContactSuggestions(contactSuggester_->getSuggestions(text)); + if (contactSuggester_) { + std::cout << "PASSING JID SUGGESTIONS TO WINDOW!" << std::endl; + highlightEditorWindow_->setContactSuggestions(contactSuggester_->getSuggestions(text)); + } else { + std::cout << "PASSING JID SUGGESTIONS TO WINDOW: FAILED - OFFLINE!" << std::endl; + } } } diff --git a/Swift/Controllers/HighlightEditorController.h b/Swift/Controllers/HighlightEditorController.h index f784248..c8d9bef 100644 --- a/Swift/Controllers/HighlightEditorController.h +++ b/Swift/Controllers/HighlightEditorController.h @@ -22,10 +22,11 @@ namespace Swift { class HighlightEditorController { public: - HighlightEditorController(UIEventStream* uiEventStream, ContactSuggester* contactSuggester, HighlightEditorWindowFactory* highlightEditorWindowFactory, HighlightManager* highlightManager); + HighlightEditorController(UIEventStream* uiEventStream, HighlightEditorWindowFactory* highlightEditorWindowFactory, HighlightManager* highlightManager); ~HighlightEditorController(); HighlightManager* getHighlightManager() const { return highlightManager_; } + void setContactSuggester(ContactSuggester *suggester) { contactSuggester_ = suggester; } private: void handleUIEvent(boost::shared_ptr<UIEvent> event); diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index b527583..89836c9 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -167,7 +167,7 @@ MainController::MainController( loginWindow_->setShowNotificationToggle(!notifier->isExternallyConfigured()); highlightManager_ = new HighlightManager(settings_); - highlightEditorController_ = new HighlightEditorController(uiEventStream_, contactSuggesterWithRoster_, uiFactory_, highlightManager_); + highlightEditorController_ = new HighlightEditorController(uiEventStream_, uiFactory_, highlightManager_); soundEventController_ = new SoundEventController(eventController_, soundPlayer, settings, highlightManager_); @@ -369,6 +369,7 @@ void MainController::handleConnected() { contactSuggesterWithoutRoster_->addContactProvider(chatsManager_); contactSuggesterWithRoster_->addContactProvider(chatsManager_); contactSuggesterWithRoster_->addContactProvider(contactsFromRosterProvider_); + highlightEditorController_->setContactSuggester(contactSuggesterWithoutRoster_); client_->onMessageReceived.connect(boost::bind(&ChatsManager::handleIncomingMessage, chatsManager_, _1)); chatsManager_->setAvatarManager(client_->getAvatarManager()); diff --git a/Swift/Controllers/UIInterfaces/HighlightEditorWindow.h b/Swift/Controllers/UIInterfaces/HighlightEditorWindow.h index abc8741..90623ba 100644 --- a/Swift/Controllers/UIInterfaces/HighlightEditorWindow.h +++ b/Swift/Controllers/UIInterfaces/HighlightEditorWindow.h @@ -4,6 +4,10 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ +#include <vector> +#include <Swiften/Base/boost_bsignals.h> +#include <Swift/Controllers/Contact.h> + namespace Swift { class HighlightManager; @@ -12,8 +16,12 @@ class HighlightEditorWindow { public: HighlightEditorWindow(); virtual ~HighlightEditorWindow(); - virtual void setHighlightManager(HighlightManager *highlightManager) = 0; virtual void show() = 0; + virtual void setHighlightManager(HighlightManager *highlightManager) = 0; + virtual void setContactSuggestions(const std::vector<Contact>& suggestions) = 0; + +public: + boost::signal<void (const std::string&)> onContactSuggestionsRequested; }; } diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp index c7ccf60..f014ce6 100644 --- a/Swift/QtUI/QtHighlightEditor.cpp +++ b/Swift/QtUI/QtHighlightEditor.cpp @@ -51,6 +51,9 @@ QtHighlightEditor::QtHighlightEditor(QtSettingsProvider* settings, QWidget* pare jid_ = new QtSuggestingJIDInput(this, settings); ui_.senderName->addWidget(jid_); + /* handle autocomplete */ + connect(jid_, SIGNAL(textEdited(QString)), SLOT(handleContactSuggestionRequested(QString))); + /* we need to be notified if any of the state changes so that we can update our textual rule description */ connect(ui_.chatCheck, SIGNAL(clicked()), SLOT(updateRuleDescription())); connect(ui_.roomCheck, SIGNAL(clicked()), SLOT(updateRuleDescription())); @@ -166,6 +169,12 @@ void QtHighlightEditor::setHighlightManager(HighlightManager* highlightManager) //ui_.moveDownButton->setEnabled(false); } +void QtHighlightEditor::setContactSuggestions(const std::vector<Contact>& suggestions) +{ + std::cout << "SETTINGS SUGGESTIONS!" << std::endl; + jid_->setSuggestions(suggestions); +} + void QtHighlightEditor::colorOtherSelect() { ui_.foregroundColor->setEnabled(false); @@ -302,6 +311,13 @@ void QtHighlightEditor::enableDialog(bool state) ui_.customSoundRadio->setEnabled(state); } +void QtHighlightEditor::handleContactSuggestionRequested(const QString& text) +{ + std::cout << "GOT TEXT INPUT EVENT" << std::endl; + std::string stdText = Q2PSTRING(text); + onContactSuggestionsRequested(stdText); +} + void QtHighlightEditor::selectRow(int row) { for (int i = 0; i < ui_.listWidget->count(); ++i) { diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h index 2c3a819..5c0d618 100644 --- a/Swift/QtUI/QtHighlightEditor.h +++ b/Swift/QtUI/QtHighlightEditor.h @@ -30,6 +30,7 @@ namespace Swift { virtual void show(); virtual void setHighlightManager(HighlightManager* highlightManager); + virtual void setContactSuggestions(const std::vector<Contact>& suggestions); private slots: void colorOtherSelect(); @@ -44,6 +45,7 @@ namespace Swift { void onOkButtonClick(); void updateRuleDescription(); void enableDialog(bool state); + void handleContactSuggestionRequested(const QString& text); private: |