diff options
| author | Richard Maudsley <richard.maudsley@isode.com> | 2014-06-30 12:30:28 (GMT) |
|---|---|---|
| committer | Swift Review <review@swift.im> | 2014-07-09 13:04:52 (GMT) |
| commit | 16b1f85c1a7a0310b0a722c853e5fc8dd799570b (patch) | |
| tree | a52e93753da58e6b9f3c039c6ae4b886ee30f83e /Swift/QtUI | |
| parent | 1edfc36235cc67d303ceb2bcf0630affc509f2f7 (diff) | |
| download | swift-contrib-16b1f85c1a7a0310b0a722c853e5fc8dd799570b.zip swift-contrib-16b1f85c1a7a0310b0a722c853e5fc8dd799570b.tar.bz2 | |
Reset QtSuggestingJIDInput when a contact has been selected.
Test-Information:
Verified that the selected contact is added to the contact list when selecting from the drop-down list or by pressing the 'Add' button and that the JID field is reset after this happens.
Change-Id: I7ef047ec9dbacf1af8635849320371f082bb3d0d
Diffstat (limited to 'Swift/QtUI')
4 files changed, 10 insertions, 1 deletions
diff --git a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp index a4a4610..9b96627 100644 --- a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp +++ b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp @@ -85,18 +85,23 @@ void QtSuggestingJIDInput::setSuggestions(const std::vector<Contact::ref>& sugge positionPopup(); if (!suggestions.empty()) { treeViewPopup_->setCurrentIndex(contactListModel_->index(0, 0)); showPopup(); } else { currentContact_.reset(); } } +void QtSuggestingJIDInput::clear() { + setText(""); + currentContact_.reset(); +} + void QtSuggestingJIDInput::keyPressEvent(QKeyEvent* event) { if (event->key() == Qt::Key_Up) { if (contactListModel_->rowCount() > 0) { int row = treeViewPopup_->currentIndex().row(); row = (row + contactListModel_->rowCount() - 1) % contactListModel_->rowCount(); treeViewPopup_->setCurrentIndex(contactListModel_->index(row, 0)); } } else if (event->key() == Qt::Key_Down) { if (contactListModel_->rowCount() > 0) { @@ -132,19 +137,18 @@ void QtSuggestingJIDInput::handleApplicationFocusChanged(QWidget* /*old*/, QWidg void QtSuggestingJIDInput::handleSettingsChanged(const std::string& setting) { if (setting == QtUISettingConstants::COMPACT_ROSTER.getKey()) { contactListDelegate_->setCompact(settings_->getSetting(QtUISettingConstants::COMPACT_ROSTER)); } } void QtSuggestingJIDInput::handleClicked(const QModelIndex& index) { if (index.isValid()) { currentContact_ = contactListModel_->getContact(index.row()); - setText(""); onUserSelected(currentContact_->jid); hidePopup(); } } void QtSuggestingJIDInput::positionPopup() { QDesktopWidget* desktop = QApplication::desktop(); int screen = desktop->screenNumber(this); QPoint point = mapToGlobal(QPoint(0, height())); diff --git a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h index 25e7d42..71cd87d 100644 --- a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h +++ b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h @@ -27,18 +27,20 @@ class QtSuggestingJIDInput : public QLineEdit { Q_OBJECT public: QtSuggestingJIDInput(QWidget* parent, SettingsProvider* settings); virtual ~QtSuggestingJIDInput(); Contact::ref getContact(); void setSuggestions(const std::vector<Contact::ref>& suggestions); + void clear(); + boost::signal<void (const JID&)> onUserSelected; signals: void editingDone(); protected: virtual void keyPressEvent(QKeyEvent* event); private: diff --git a/Swift/QtUI/UserSearch/QtUserSearchFirstMultiJIDPage.cpp b/Swift/QtUI/UserSearch/QtUserSearchFirstMultiJIDPage.cpp index 8ea49c4..2c34aa6 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchFirstMultiJIDPage.cpp +++ b/Swift/QtUI/UserSearch/QtUserSearchFirstMultiJIDPage.cpp @@ -52,18 +52,19 @@ QtUserSearchFirstMultiJIDPage::QtUserSearchFirstMultiJIDPage(UserSearchWindow::T setAcceptDrops(true); } bool QtUserSearchFirstMultiJIDPage::isComplete() const { return !contactList_->getList().empty(); } void QtUserSearchFirstMultiJIDPage::reset() { + jid_->clear(); reason_->clear(); } void QtUserSearchFirstMultiJIDPage::emitCompletenessCheck() { emit completeChanged(); } void QtUserSearchFirstMultiJIDPage::handleEditingDone() { addContactButton_->setFocus(); diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp index 260ccfe..ca84759 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp @@ -152,18 +152,19 @@ void QtUserSearchWindow::handleAccepted() { void QtUserSearchWindow::handleContactSuggestionRequested(const QString& text) { std::string stdText = Q2PSTRING(text); onContactSuggestionsRequested(stdText); } void QtUserSearchWindow::addContact() { if (!!firstMultiJIDPage_->jid_->getContact()) { contactVector_.push_back(firstMultiJIDPage_->jid_->getContact()); + firstMultiJIDPage_->jid_->clear(); } firstMultiJIDPage_->contactList_->setList(contactVector_); firstMultiJIDPage_->emitCompletenessCheck(); if (type_ == ChatToContact) { firstMultiJIDPage_->groupBox->setEnabled(supportsImpromptu_ ? 1 : (contactVector_.size() < 1)); } } int QtUserSearchWindow::nextId() const { @@ -267,18 +268,19 @@ JID QtUserSearchWindow::getContactJID() const { jid = JID(Q2PSTRING(firstPage_->jid_->text().trimmed())); } return jid; } void QtUserSearchWindow::addSearchedJIDToList(const JID& jid) { std::vector<JID> jids; jids.push_back(jid); handleJIDsAdded(jids); + firstMultiJIDPage_->jid_->clear(); } void QtUserSearchWindow::show() { clear(); QWidget::show(); } void QtUserSearchWindow::addSavedServices(const std::vector<JID>& services) { if (type_ == AddContact) { |
Swift