summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2017-04-04 07:17:53 (GMT)
committerTobias Markmann <tm@ayena.de>2017-04-04 07:18:28 (GMT)
commit38f35935581b826940a10246b0a624c643dccc2e (patch)
treebc1e27b5209acc0bba2611dee50d0c419563effb /Swift
parentf4034579f0d4adc6d2e7cb293e91cabd6d598887 (diff)
downloadswift-38f35935581b826940a10246b0a624c643dccc2e.zip
swift-38f35935581b826940a10246b0a624c643dccc2e.tar.bz2
Test against dialog type instead of nullptr in QtUserSearchWindow
If the dialog is not of type AddContact, firstMultiJIDPage_ is initialised and this states more clearly that the reset is only done when the dialog is in this mode. Coverity raised this issue. Test-Information: Added a user from search and started a chat from user search. All unit tests pass on macOS 10.12.4. Change-Id: I55f6df5b4f48e2c6718922846a424bf17f363b16
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchWindow.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
index 7575a13..f150557 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
@@ -50,105 +50,106 @@ QtUserSearchWindow::QtUserSearchWindow(UIEventStream* eventStream, UserSearchWin
break;
case ChatToContact:
title = tr("Chat to Users");
break;
case InviteToChat:
title = tr("Add Users to Chat");
break;
}
setWindowTitle(title);
delegate_ = new UserSearchDelegate(this);
setFirstPage(title);
setSecondPage();
setThirdPage();
detailsPage_ = new QtUserSearchDetailsPage(groups);
setPage(4, detailsPage_);
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(handleCurrentChanged(int)));
connect(this, SIGNAL(accepted()), this, SLOT(handleAccepted()));
clear();
}
QtUserSearchWindow::~QtUserSearchWindow() {
delete model_;
}
void QtUserSearchWindow::handleCurrentChanged(int page) {
searchNext_ = false;
- if (firstMultiJIDPage_) {
+ if (type_ != AddContact) {
firstMultiJIDPage_->reset();
}
resultsPage_->emitCompletenessCheck();
if (firstMultiJIDPage_ && page == 1 && lastPage_ == 3) {
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();
}
else if (page == 3 && lastPage_ == 2) {
JID server = getServerToSearch();
handleSearch();
if (type_ == AddContact) {
bool remote = firstPage_->byRemoteSearch_->isChecked();
firstPage_->byRemoteSearch_->setChecked(remote);
firstPage_->service_->setEditText(P2QSTRING(server.toString()));
} else {
bool remote = firstMultiJIDPage_->byRemoteSearch_->isChecked();
setFirstPage();
firstMultiJIDPage_->byRemoteSearch_->setChecked(remote);
if (remote) {
firstMultiJIDPage_->service_->setEditText(P2QSTRING(server.toString()));
}
}
}
else if (page == 4) {
detailsPage_->clear();
detailsPage_->setJID(getContactJID());
onNameSuggestionRequested(getContactJID());
}
lastPage_ = page;
}
JID QtUserSearchWindow::getServerToSearch() {
if (type_ == AddContact) {
return firstPage_->byRemoteSearch_->isChecked() ? JID(Q2PSTRING(firstPage_->service_->currentText().trimmed())) : myServer_;
- } else {
+ }
+ else {
return firstMultiJIDPage_->byRemoteSearch_->isChecked() ? JID(Q2PSTRING(firstMultiJIDPage_->service_->currentText().trimmed())) : myServer_;
}
}
void QtUserSearchWindow::handleAccepted() {
JID jid;
std::vector<JID> jids;
switch(type_) {
case AddContact:
jid = getContactJID();
eventStream_->send(std::make_shared<AddContactUIEvent>(jid, detailsPage_->getName(), detailsPage_->getSelectedGroups()));
break;
case ChatToContact:
if (contactVector_.size() == 1) {
std::shared_ptr<UIEvent> event(new RequestChatUIEvent(contactVector_[0]->jid));
eventStream_->send(event);
break;
}
for (Contact::ref contact : contactVector_) {
jids.push_back(contact->jid);
}
eventStream_->send(std::make_shared<CreateImpromptuMUCUIEvent>(jids, Q2PSTRING(firstMultiJIDPage_->reason_->text())));
break;
case InviteToChat:
for (Contact::ref contact : contactVector_) {
jids.push_back(contact->jid);
}
eventStream_->send(std::make_shared<InviteToMUCUIEvent>(originatorJID_, jids, Q2PSTRING(firstMultiJIDPage_->reason_->text())));