summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtHighlightEditor.cpp8
-rw-r--r--Swift/QtUI/QtHighlightEditor.h2
-rw-r--r--Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp8
-rw-r--r--Swift/QtUI/UserSearch/QtSuggestingJIDInput.h2
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchWindow.cpp12
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchWindow.h3
6 files changed, 24 insertions, 11 deletions
diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp
index 5aa4560..97774be 100644
--- a/Swift/QtUI/QtHighlightEditor.cpp
+++ b/Swift/QtUI/QtHighlightEditor.cpp
@@ -344,21 +344,25 @@ void QtHighlightEditor::handleContactSuggestionRequested(const QString& text)
onContactSuggestionsRequested(stdText);
}
void QtHighlightEditor::selectSoundFile()
{
QString path = QFileDialog::getOpenFileName(this, tr("Select sound file..."), QString(), "Sounds (*.wav)");
ui_.soundFile->setText(path);
}
-void QtHighlightEditor::handleOnUserSelected(const JID& jid) {
+void QtHighlightEditor::handleOnUserSelected(const Contact::ref& contact) {
/* this might seem like it should be standard behaviour for the suggesting input box, but is not desirable in all cases */
- jid_->setText(P2QSTRING(jid.toString()));
+ if (contact->jid.isValid()) {
+ jid_->setText(P2QSTRING(contact->jid.toString()));
+ } else {
+ jid_->setText(P2QSTRING(contact->name));
+ }
}
void QtHighlightEditor::populateList()
{
previousRow_ = -1;
ui_.listWidget->clear();
HighlightRulesListPtr rules = highlightManager_->getRules();
for (size_t i = 0; i < rules->getSize(); ++i) {
const HighlightRule& rule = rules->getRule(i);
diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h
index e0595ad..93a19b6 100644
--- a/Swift/QtUI/QtHighlightEditor.h
+++ b/Swift/QtUI/QtHighlightEditor.h
@@ -47,19 +47,19 @@ namespace Swift {
void onCancelButtonClick();
void onOkButtonClick();
void setChildWidgetStates();
void widgetClick();
void disableDialog();
void handleContactSuggestionRequested(const QString& text);
void selectSoundFile();
private:
- void handleOnUserSelected(const JID& jid);
+ void handleOnUserSelected(const Contact::ref& contact);
void populateList();
void selectRow(int row);
int getSelectedRow() const;
HighlightRule ruleFromDialog();
void ruleToDialog(const HighlightRule& rule);
Ui::QtHighlightEditor ui_;
QtSettingsProvider* settings_;
HighlightManager* highlightManager_;
diff --git a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp
index 78842a2..57033d8 100644
--- a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp
+++ b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp
@@ -108,19 +108,23 @@ void QtSuggestingJIDInput::keyPressEvent(QKeyEvent* event) {
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_Return && treeViewPopup_->isVisible()) {
QModelIndex index = treeViewPopup_->currentIndex();
if (!contactListModel_->getList().empty() && index.isValid()) {
currentContact_ = contactListModel_->getContact(index.row());
- setText(P2QSTRING(currentContact_->jid.toString()));
+ if (currentContact_->jid.isValid()) {
+ setText(P2QSTRING(currentContact_->jid.toString()));
+ } else {
+ setText(P2QSTRING(currentContact_->name));
+ }
hidePopup();
clearFocus();
} else {
currentContact_.reset();
}
editingDone();
} else {
QLineEdit::keyPressEvent(event);
}
@@ -138,19 +142,19 @@ 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());
- onUserSelected(currentContact_->jid);
+ onUserSelected(currentContact_);
hidePopup();
}
}
void QtSuggestingJIDInput::positionPopup() {
QDesktopWidget* desktop = QApplication::desktop();
int screen = desktop->screenNumber(this);
QPoint point = mapToGlobal(QPoint(0, height()));
QRect geometry = desktop->availableGeometry(screen);
diff --git a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h
index 71cd87d..23e7b94 100644
--- a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h
+++ b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h
@@ -29,19 +29,19 @@ class QtSuggestingJIDInput : public QLineEdit {
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;
+ boost::signal<void (const Contact::ref&)> onUserSelected;
signals:
void editingDone();
protected:
virtual void keyPressEvent(QKeyEvent* event);
private:
void handleSettingsChanged(const std::string& setting);
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
index 17214e4..e5bd5d0 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
@@ -72,19 +72,19 @@ QtUserSearchWindow::~QtUserSearchWindow() {
}
void QtUserSearchWindow::handleCurrentChanged(int page) {
searchNext_ = false;
if (firstMultiJIDPage_) {
firstMultiJIDPage_->reset();
}
resultsPage_->emitCompletenessCheck();
if (page == 1 && lastPage_ == 3) {
- addSearchedJIDToList(getContactJID());
+ addSearchedJIDToList(getContact());
setSecondPage();
}
else if (page == 2 && lastPage_ == 1) {
setError("");
/* next won't be called if JID is selected */
JID server = getServerToSearch();
clearForm();
onFormRequested(server);
setThirdPage();
@@ -264,21 +264,25 @@ JID QtUserSearchWindow::getContactJID() const {
}
}
}
else {
jid = JID(Q2PSTRING(firstPage_->jid_->text().trimmed()));
}
return jid;
}
-void QtUserSearchWindow::addSearchedJIDToList(const JID& jid) {
+Contact::ref QtUserSearchWindow::getContact() const {
+ return boost::make_shared<Contact>("", getContactJID(), StatusShow::None, "");
+}
+
+void QtUserSearchWindow::addSearchedJIDToList(const Contact::ref& contact) {
std::vector<JID> jids;
- jids.push_back(jid);
+ jids.push_back(contact->jid);
handleJIDsAdded(jids);
firstMultiJIDPage_->jid_->clear();
}
void QtUserSearchWindow::show() {
clear();
QWidget::show();
}
@@ -337,19 +341,19 @@ void QtUserSearchWindow::setContactSuggestions(const std::vector<Contact::ref>&
if (type_ == AddContact) {
firstPage_->jid_->setSuggestions(suggestions);
} else {
firstMultiJIDPage_->jid_->setSuggestions(suggestions);
}
}
void QtUserSearchWindow::setJIDs(const std::vector<JID> &jids) {
foreach(JID jid, jids) {
- addSearchedJIDToList(jid);
+ addSearchedJIDToList(boost::make_shared<Contact>("", jid, StatusShow::None, ""));
}
onJIDUpdateRequested(jids);
}
void QtUserSearchWindow::setRoomJID(const JID& roomJID) {
roomJID_ = roomJID;
}
std::string QtUserSearchWindow::getReason() const {
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.h b/Swift/QtUI/UserSearch/QtUserSearchWindow.h
index 0349ba4..0318b3d 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.h
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.h
@@ -71,19 +71,20 @@ namespace Swift {
void setSecondPage();
void setThirdPage();
private:
void clearForm();
void setError(const QString& error);
JID getServerToSearch();
void handleSearch();
JID getContactJID() const;
- void addSearchedJIDToList(const JID& jid);
+ Contact::ref getContact() const;
+ void addSearchedJIDToList(const Contact::ref& contact);
private:
UIEventStream* eventStream_;
UserSearchWindow::Type type_;
QAbstractItemModel* model_;
UserSearchDelegate* delegate_;
QtUserSearchFirstPage* firstPage_;
QtUserSearchFirstMultiJIDPage* firstMultiJIDPage_;
QtUserSearchFieldsPage* fieldsPage_;