From 1acbc04d3f2dbb20c0426dc6166832b62af0463c Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 15 Jan 2016 19:31:11 +0100 Subject: [PATCH] Refactor. --- src/services/tt-rss/gui/formeditaccount.cpp | 11 ++++---- src/services/tt-rss/gui/formeditaccount.h | 2 +- src/services/tt-rss/gui/formeditfeed.cpp | 25 +++++++++---------- src/services/tt-rss/gui/formeditfeed.h | 2 +- .../tt-rss/network/ttrssnetworkfactory.h | 1 - src/services/tt-rss/ttrsscategory.cpp | 2 +- 6 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/services/tt-rss/gui/formeditaccount.cpp b/src/services/tt-rss/gui/formeditaccount.cpp index 62281815d..0be5421ab 100755 --- a/src/services/tt-rss/gui/formeditaccount.cpp +++ b/src/services/tt-rss/gui/formeditaccount.cpp @@ -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.")); diff --git a/src/services/tt-rss/gui/formeditaccount.h b/src/services/tt-rss/gui/formeditaccount.h index f5c75ac35..92d11097d 100755 --- a/src/services/tt-rss/gui/formeditaccount.h +++ b/src/services/tt-rss/gui/formeditaccount.h @@ -55,7 +55,7 @@ class FormEditAccount : public QDialog { void checkOkButton(); private: - Ui::FormEditAccount *m_ui; + QScopedPointer m_ui; TtRssServiceRoot *m_editableRoot; QPushButton *m_btnOk; }; diff --git a/src/services/tt-rss/gui/formeditfeed.cpp b/src/services/tt-rss/gui/formeditfeed.cpp index 0673b1bd8..656c04205 100755 --- a/src/services/tt-rss/gui/formeditfeed.cpp +++ b/src/services/tt-rss/gui/formeditfeed.cpp @@ -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(m_ui->m_cmbAutoUpdateType->itemData(new_index).toInt()); + const Feed::AutoUpdateType auto_update_type = static_cast(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,17 +206,17 @@ void FormEditFeed::saveFeed() { void FormEditFeed::addNewFeed() { RootItem *parent = static_cast(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value()); - TtRssServiceRoot *root = parent->kind() == RootItemKind::Category ? + const TtRssServiceRoot *root = parent->kind() == RootItemKind::Category ? qobject_cast(parent)->serviceRoot() : qobject_cast(parent); - int category_id = parent->kind() == RootItemKind::ServiceRoot ? - 0 : - qobject_cast(parent)->customId(); - TtRssSubscribeToFeedResponse response = root->network()->subscribeToFeed(m_ui->m_txtUrl->lineEdit()->text(), - category_id, - m_ui->m_gbAuthentication->isChecked(), - m_ui->m_txtUsername->lineEdit()->text(), - m_ui->m_txtPassword->lineEdit()->text()); + const int category_id = parent->kind() == RootItemKind::ServiceRoot ? + 0 : + qobject_cast(parent)->customId(); + 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(), + m_ui->m_txtPassword->lineEdit()->text()); if (response.code() == STF_INSERTED || response.code() == STF_UPDATED) { // Feed was added online. diff --git a/src/services/tt-rss/gui/formeditfeed.h b/src/services/tt-rss/gui/formeditfeed.h index 4818cda58..561e3633a 100755 --- a/src/services/tt-rss/gui/formeditfeed.h +++ b/src/services/tt-rss/gui/formeditfeed.h @@ -57,7 +57,7 @@ class FormEditFeed : public QDialog { void addNewFeed(); void loadCategories(const QList categories, RootItem *root_item); - Ui::FormEditFeed *m_ui; + QScopedPointer m_ui; TtRssServiceRoot *m_root; TtRssFeed *m_loadedFeed; }; diff --git a/src/services/tt-rss/network/ttrssnetworkfactory.h b/src/services/tt-rss/network/ttrssnetworkfactory.h index 4727fa722..209747107 100755 --- a/src/services/tt-rss/network/ttrssnetworkfactory.h +++ b/src/services/tt-rss/network/ttrssnetworkfactory.h @@ -151,7 +151,6 @@ class TtRssNetworkFactory { // Metadata. QDateTime lastLoginTime() const; - QNetworkReply::NetworkError lastError() const; // Operations. diff --git a/src/services/tt-rss/ttrsscategory.cpp b/src/services/tt-rss/ttrsscategory.cpp index 5e5f8be3d..1f5caa1a5 100755 --- a/src/services/tt-rss/ttrsscategory.cpp +++ b/src/services/tt-rss/ttrsscategory.cpp @@ -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 :