mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-02 18:36:49 +01:00
Refactor.
This commit is contained in:
parent
7b1490e99f
commit
1acbc04d3f
@ -81,7 +81,6 @@ FormEditAccount::FormEditAccount(QWidget *parent)
|
||||
}
|
||||
|
||||
FormEditAccount::~FormEditAccount() {
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
TtRssServiceRoot *FormEditAccount::execForCreate() {
|
||||
@ -204,7 +203,7 @@ void FormEditAccount::onClickedCancel() {
|
||||
}
|
||||
|
||||
void FormEditAccount::onUsernameChanged() {
|
||||
QString username = m_ui->m_txtUsername->lineEdit()->text();
|
||||
const QString username = m_ui->m_txtUsername->lineEdit()->text();
|
||||
|
||||
if (username.isEmpty()) {
|
||||
m_ui->m_txtUsername->setStatus(WidgetWithStatus::Error, tr("Username cannot be empty."));
|
||||
@ -215,7 +214,7 @@ void FormEditAccount::onUsernameChanged() {
|
||||
}
|
||||
|
||||
void FormEditAccount::onPasswordChanged() {
|
||||
QString password = m_ui->m_txtPassword->lineEdit()->text();
|
||||
const QString password = m_ui->m_txtPassword->lineEdit()->text();
|
||||
|
||||
if (password.isEmpty()) {
|
||||
m_ui->m_txtPassword->setStatus(WidgetWithStatus::Error, tr("Password cannot be empty."));
|
||||
@ -226,7 +225,7 @@ void FormEditAccount::onPasswordChanged() {
|
||||
}
|
||||
|
||||
void FormEditAccount::onHttpUsernameChanged() {
|
||||
bool is_username_ok = !m_ui->m_gbHttpAuthentication->isChecked() || !m_ui->m_txtHttpUsername->lineEdit()->text().isEmpty();
|
||||
const bool is_username_ok = !m_ui->m_gbHttpAuthentication->isChecked() || !m_ui->m_txtHttpUsername->lineEdit()->text().isEmpty();
|
||||
|
||||
m_ui->m_txtHttpUsername->setStatus(is_username_ok ?
|
||||
LineEditWithStatus::Ok :
|
||||
@ -237,7 +236,7 @@ void FormEditAccount::onHttpUsernameChanged() {
|
||||
}
|
||||
|
||||
void FormEditAccount::onHttpPasswordChanged() {
|
||||
bool is_username_ok = !m_ui->m_gbHttpAuthentication->isChecked() || !m_ui->m_txtHttpPassword->lineEdit()->text().isEmpty();
|
||||
const bool is_username_ok = !m_ui->m_gbHttpAuthentication->isChecked() || !m_ui->m_txtHttpPassword->lineEdit()->text().isEmpty();
|
||||
|
||||
m_ui->m_txtHttpPassword->setStatus(is_username_ok ?
|
||||
LineEditWithStatus::Ok :
|
||||
@ -248,7 +247,7 @@ void FormEditAccount::onHttpPasswordChanged() {
|
||||
}
|
||||
|
||||
void FormEditAccount::onUrlChanged() {
|
||||
QString url = m_ui->m_txtUrl->lineEdit()->text();
|
||||
const QString url = m_ui->m_txtUrl->lineEdit()->text();
|
||||
|
||||
if (url.isEmpty()) {
|
||||
m_ui->m_txtUrl->setStatus(WidgetWithStatus::Error, tr("URL cannot be empty."));
|
||||
|
@ -55,7 +55,7 @@ class FormEditAccount : public QDialog {
|
||||
void checkOkButton();
|
||||
|
||||
private:
|
||||
Ui::FormEditAccount *m_ui;
|
||||
QScopedPointer<Ui::FormEditAccount> m_ui;
|
||||
TtRssServiceRoot *m_editableRoot;
|
||||
QPushButton *m_btnOk;
|
||||
};
|
||||
|
@ -44,7 +44,6 @@ FormEditFeed::FormEditFeed(TtRssServiceRoot *root, QWidget *parent)
|
||||
}
|
||||
|
||||
FormEditFeed::~FormEditFeed() {
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
int FormEditFeed::execForEdit(TtRssFeed *input_feed) {
|
||||
@ -76,7 +75,7 @@ void FormEditFeed::onAuthenticationSwitched() {
|
||||
}
|
||||
|
||||
void FormEditFeed::onAutoUpdateTypeChanged(int new_index) {
|
||||
Feed::AutoUpdateType auto_update_type = static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(new_index).toInt());
|
||||
const Feed::AutoUpdateType auto_update_type = static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(new_index).toInt());
|
||||
|
||||
switch (auto_update_type) {
|
||||
case Feed::DontAutoUpdate:
|
||||
@ -118,7 +117,7 @@ void FormEditFeed::onUrlChanged(const QString &new_url) {
|
||||
}
|
||||
|
||||
void FormEditFeed::onUsernameChanged(const QString &new_username) {
|
||||
bool is_username_ok = !m_ui->m_gbAuthentication->isChecked() || !new_username.isEmpty();
|
||||
const bool is_username_ok = !m_ui->m_gbAuthentication->isChecked() || !new_username.isEmpty();
|
||||
|
||||
m_ui->m_txtUsername->setStatus(is_username_ok ?
|
||||
LineEditWithStatus::Ok :
|
||||
@ -129,7 +128,7 @@ void FormEditFeed::onUsernameChanged(const QString &new_username) {
|
||||
}
|
||||
|
||||
void FormEditFeed::onPasswordChanged(const QString &new_password) {
|
||||
bool is_password_ok = !m_ui->m_gbAuthentication->isChecked() || !new_password.isEmpty();
|
||||
const bool is_password_ok = !m_ui->m_gbAuthentication->isChecked() || !new_password.isEmpty();
|
||||
|
||||
m_ui->m_txtPassword->setStatus(is_password_ok ?
|
||||
LineEditWithStatus::Ok :
|
||||
@ -207,13 +206,13 @@ void FormEditFeed::saveFeed() {
|
||||
|
||||
void FormEditFeed::addNewFeed() {
|
||||
RootItem *parent = static_cast<RootItem*>(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value<void*>());
|
||||
TtRssServiceRoot *root = parent->kind() == RootItemKind::Category ?
|
||||
const TtRssServiceRoot *root = parent->kind() == RootItemKind::Category ?
|
||||
qobject_cast<TtRssCategory*>(parent)->serviceRoot() :
|
||||
qobject_cast<TtRssServiceRoot*>(parent);
|
||||
int category_id = parent->kind() == RootItemKind::ServiceRoot ?
|
||||
const int category_id = parent->kind() == RootItemKind::ServiceRoot ?
|
||||
0 :
|
||||
qobject_cast<TtRssCategory*>(parent)->customId();
|
||||
TtRssSubscribeToFeedResponse response = root->network()->subscribeToFeed(m_ui->m_txtUrl->lineEdit()->text(),
|
||||
const TtRssSubscribeToFeedResponse response = root->network()->subscribeToFeed(m_ui->m_txtUrl->lineEdit()->text(),
|
||||
category_id,
|
||||
m_ui->m_gbAuthentication->isChecked(),
|
||||
m_ui->m_txtUsername->lineEdit()->text(),
|
||||
|
@ -57,7 +57,7 @@ class FormEditFeed : public QDialog {
|
||||
void addNewFeed();
|
||||
void loadCategories(const QList<Category*> categories, RootItem *root_item);
|
||||
|
||||
Ui::FormEditFeed *m_ui;
|
||||
QScopedPointer<Ui::FormEditFeed> m_ui;
|
||||
TtRssServiceRoot *m_root;
|
||||
TtRssFeed *m_loadedFeed;
|
||||
};
|
||||
|
@ -151,7 +151,6 @@ class TtRssNetworkFactory {
|
||||
|
||||
// Metadata.
|
||||
QDateTime lastLoginTime() const;
|
||||
|
||||
QNetworkReply::NetworkError lastError() const;
|
||||
|
||||
// Operations.
|
||||
|
@ -53,7 +53,7 @@ TtRssServiceRoot *TtRssCategory::serviceRoot() {
|
||||
}
|
||||
|
||||
bool TtRssCategory::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
QStringList ids = serviceRoot()->customIDSOfMessagesForItem(this);
|
||||
const QStringList ids = serviceRoot()->customIDSOfMessagesForItem(this);
|
||||
TtRssUpdateArticleResponse response = serviceRoot()->network()->updateArticles(ids, UpdateArticle::Unread,
|
||||
status == RootItem::Unread ?
|
||||
UpdateArticle::SetToTrue :
|
||||
|
Loading…
x
Reference in New Issue
Block a user