/***************************************************************************
- * Copyright (C) 2005-2018 by the Quassel Project *
+ * Copyright (C) 2005-2019 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include "icon.h"
#include "util.h"
-CoreAccountSettingsPage::CoreAccountSettingsPage(QWidget *parent)
- : SettingsPage(tr("Remote Cores"), QString(), parent),
- _lastAccountId(0),
- _lastAutoConnectId(0)
+CoreAccountSettingsPage::CoreAccountSettingsPage(QWidget* parent)
+ : SettingsPage(tr("Remote Cores"), QString(), parent)
+ , _lastAccountId(0)
+ , _lastAutoConnectId(0)
{
ui.setupUi(this);
initAutoWidgets();
setWidgetStates();
}
-
void CoreAccountSettingsPage::setStandAlone(bool standalone)
{
_standalone = standalone;
}
-
void CoreAccountSettingsPage::load()
{
model()->update(Client::coreAccountModel());
setChangedState(false);
}
-
void CoreAccountSettingsPage::save()
{
SettingsPage::save();
ui.autoConnectAccount->setProperty("storedValue", ui.autoConnectAccount->currentIndex());
}
-
// TODO: Qt 4.6 - replace by proper rowsMoved() semantics
// NOTE: This is the filtered model
-void CoreAccountSettingsPage::rowsAboutToBeRemoved(const QModelIndex &index, int start, int end)
+void CoreAccountSettingsPage::rowsAboutToBeRemoved(const QModelIndex& index, int start, int end)
{
_lastAutoConnectId = _lastAccountId = 0;
if (index.isValid() || start != end)
_lastAutoConnectId = id;
}
-
-void CoreAccountSettingsPage::rowsInserted(const QModelIndex &index, int start, int end)
+void CoreAccountSettingsPage::rowsInserted(const QModelIndex& index, int start, int end)
{
if (index.isValid() || start != end)
return;
_lastAccountId = _lastAutoConnectId = 0;
}
-
AccountId CoreAccountSettingsPage::selectedAccount() const
{
QModelIndex index = ui.accountView->currentIndex();
return index.data(CoreAccountModel::AccountIdRole).value<AccountId>();
}
-
void CoreAccountSettingsPage::setSelectedAccount(AccountId accId)
{
QModelIndex index = filteredModel()->mapFromSource(model()->accountIndex(accId));
ui.accountView->setCurrentIndex(index);
}
-
void CoreAccountSettingsPage::on_addAccountButton_clicked()
{
CoreAccountEditDlg dlg(CoreAccount(), this);
}
}
-
void CoreAccountSettingsPage::on_editAccountButton_clicked()
{
QModelIndex idx = ui.accountView->selectionModel()->currentIndex();
editAccount(idx);
}
-
-void CoreAccountSettingsPage::editAccount(const QModelIndex &index)
+void CoreAccountSettingsPage::editAccount(const QModelIndex& index)
{
if (!index.isValid())
return;
}
}
-
void CoreAccountSettingsPage::on_deleteAccountButton_clicked()
{
if (!ui.accountView->selectionModel()->selectedIndexes().count())
}
}
-
-void CoreAccountSettingsPage::on_accountView_doubleClicked(const QModelIndex &index)
+void CoreAccountSettingsPage::on_accountView_doubleClicked(const QModelIndex& index)
{
if (!index.isValid())
return;
editAccount(index);
}
-
void CoreAccountSettingsPage::setWidgetStates()
{
AccountId accId = selectedAccount();
ui.deleteAccountButton->setEnabled(editable);
}
-
void CoreAccountSettingsPage::widgetHasChanged()
{
setChangedState(testHasChanged());
setWidgetStates();
}
-
bool CoreAccountSettingsPage::testHasChanged()
{
- if (ui.autoConnectAccount->currentIndex() !=
- ui.autoConnectAccount->property("storedValue").toInt()) {
+ if (ui.autoConnectAccount->currentIndex() != ui.autoConnectAccount->property("storedValue").toInt()) {
return true;
}
if (*model() != *Client::coreAccountModel()) {
return false;
}
-
/*****************************************************************************************
* CoreAccountEditDlg
*****************************************************************************************/
-CoreAccountEditDlg::CoreAccountEditDlg(const CoreAccount &acct, QWidget *parent)
+CoreAccountEditDlg::CoreAccountEditDlg(const CoreAccount& acct, QWidget* parent)
: QDialog(parent)
{
ui.setupUi(this);
setWindowTitle(tr("Add Core Account"));
}
-
CoreAccount CoreAccountEditDlg::account()
{
_account.setAccountName(ui.accountName->text().trimmed());
int checkedId = ui.buttonGroupProxyType->checkedId();
switch (checkedId) {
- case NoProxy: // QNetworkProxy::NoProxy
+ case NoProxy: // QNetworkProxy::NoProxy
QNetworkProxyFactory::setUseSystemConfiguration(false);
_account.setProxyType(proxyType);
break;
- case SystemProxy: // QNetworkProxy::DefaultProxy:
+ case SystemProxy: // QNetworkProxy::DefaultProxy:
QNetworkProxyFactory::setUseSystemConfiguration(true);
_account.setProxyType(QNetworkProxy::DefaultProxy);
break;
- case ManualProxy: // QNetworkProxy::Socks5Proxy || QNetworkProxy::HttpProxy
- proxyType = ui.proxyType->currentIndex() == 0 ?
- QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy;
+ case ManualProxy: // QNetworkProxy::Socks5Proxy || QNetworkProxy::HttpProxy
+ proxyType = ui.proxyType->currentIndex() == 0 ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy;
QNetworkProxyFactory::setUseSystemConfiguration(false);
_account.setProxyHostName(ui.proxyHostName->text().trimmed());
_account.setProxyPort(ui.proxyPort->value());
return _account;
}
-
void CoreAccountEditDlg::setWidgetStates()
{
- bool ok = !ui.accountName->text().trimmed().isEmpty()
- && !ui.user->text().trimmed().isEmpty()
- && !ui.hostName->text().isEmpty();
+ bool ok = !ui.accountName->text().trimmed().isEmpty() && !ui.user->text().trimmed().isEmpty() && !ui.hostName->text().isEmpty();
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
}
-
-void CoreAccountEditDlg::on_hostName_textChanged(const QString &text)
+void CoreAccountEditDlg::on_hostName_textChanged(const QString& text)
{
Q_UNUSED(text);
setWidgetStates();
}
-
-void CoreAccountEditDlg::on_accountName_textChanged(const QString &text)
+void CoreAccountEditDlg::on_accountName_textChanged(const QString& text)
{
Q_UNUSED(text);
setWidgetStates();
}
-
-void CoreAccountEditDlg::on_user_textChanged(const QString &text)
+void CoreAccountEditDlg::on_user_textChanged(const QString& text)
{
Q_UNUSED(text)
setWidgetStates();
ui.proxyPassword->setEnabled(checked);
}
-
/*****************************************************************************************
* FilteredCoreAccountModel
*****************************************************************************************/
-FilteredCoreAccountModel::FilteredCoreAccountModel(CoreAccountModel *model, QObject *parent) : QSortFilterProxyModel(parent)
+FilteredCoreAccountModel::FilteredCoreAccountModel(CoreAccountModel* model, QObject* parent)
+ : QSortFilterProxyModel(parent)
{
_internalAccount = model->internalAccount();
setSourceModel(model);
}
-
-bool FilteredCoreAccountModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
+bool FilteredCoreAccountModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
{
if (Quassel::runMode() == Quassel::Monolithic)
return true;