squawk/ui/widgets/joinconference.cpp

80 lines
2.3 KiB
C++
Raw Normal View History

/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
2019-09-04 16:38:52 +00:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
2019-09-04 16:38:52 +00:00
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
2019-09-04 16:38:52 +00:00
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2019-09-04 16:38:52 +00:00
#include "joinconference.h"
#include "ui_joinconference.h"
#include <QDebug>
2019-09-04 16:38:52 +00:00
JoinConference::JoinConference(const Models::Accounts* accounts, QWidget* parent):
QDialog(parent),
2019-09-04 16:38:52 +00:00
m_ui(new Ui::JoinConference())
{
m_ui->setupUi ( this );
std::deque<QString> names = accounts->getNames();
for (std::deque<QString>::const_iterator i = names.begin(), end = names.end(); i != end; i++) {
m_ui->account->addItem(*i);
}
m_ui->account->setCurrentIndex(0);
}
2019-09-04 16:38:52 +00:00
JoinConference::JoinConference(const QString& acc, const Models::Accounts* accounts, QWidget* parent):
QDialog(parent),
2019-09-04 16:38:52 +00:00
m_ui(new Ui::JoinConference())
{
m_ui->setupUi ( this );
std::deque<QString> names = accounts->getNames();
int index = 0;
bool found = false;
for (std::deque<QString>::const_iterator i = names.begin(), end = names.end(); i != end; i++) {
const QString& name = *i;
m_ui->account->addItem(name);
if (!found) {
if (name == acc) {
found = true;
} else {
index++;
}
}
}
if (!found) {
2019-09-04 16:38:52 +00:00
qDebug() << "Couldn't find a correct account among available accounts creating JoinConference dialog, setting to 0";
}
m_ui->account->setCurrentIndex(index);
}
2019-09-04 16:38:52 +00:00
JoinConference::~JoinConference()
{
}
2019-09-04 16:38:52 +00:00
JoinConference::Data JoinConference::value() const
{
return {
m_ui->jid->text(),
2019-09-04 16:38:52 +00:00
m_ui->nick->text(),
m_ui->account->currentText(),
2019-09-04 16:38:52 +00:00
m_ui->autoJoin->isChecked(),
""
};
}