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