fixed #584 and some related small refactorings
This commit is contained in:
parent
24f72dee33
commit
d99ad7f628
|
@ -280,6 +280,8 @@ set(SOURCES
|
|||
services/abstract/category.h
|
||||
services/abstract/feed.cpp
|
||||
services/abstract/feed.h
|
||||
services/abstract/gui/accountdetails.cpp
|
||||
services/abstract/gui/accountdetails.h
|
||||
services/abstract/gui/authenticationdetails.cpp
|
||||
services/abstract/gui/authenticationdetails.h
|
||||
services/abstract/gui/custommessagepreviewer.cpp
|
||||
|
@ -471,6 +473,7 @@ set(UI_FILES
|
|||
network-web/adblock/adblockdialog.ui
|
||||
network-web/downloaditem.ui
|
||||
network-web/downloadmanager.ui
|
||||
services/abstract/gui/accountdetails.ui
|
||||
services/abstract/gui/authenticationdetails.ui
|
||||
services/abstract/gui/formaccountdetails.ui
|
||||
services/abstract/gui/formaddeditlabel.ui
|
||||
|
|
|
@ -322,34 +322,6 @@ bool FeedsProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right
|
|||
|
||||
bool FeedsProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const {
|
||||
bool should_show = filterAcceptsRowInternal(source_row, source_parent);
|
||||
|
||||
/*
|
||||
qDebugNN << LOGSEC_CORE << "Filter accepts row"
|
||||
<< QUOTE_W_SPACE(m_sourceModel->itemForIndex(m_sourceModel->index(source_row, 0, source_parent))->title())
|
||||
<< "and filter result is:" << QUOTE_W_SPACE_DOT(should_show);
|
||||
*/
|
||||
|
||||
/*
|
||||
if (should_show && (!filterRegularExpression().pattern().isEmpty() ||
|
||||
m_showUnreadOnly)) {
|
||||
emit expandAfterFilterIn(m_sourceModel->index(source_row, 0, source_parent));
|
||||
}
|
||||
*/
|
||||
|
||||
if (should_show && m_hiddenIndices.contains(QPair<int, QModelIndex>(source_row, source_parent))) {
|
||||
qDebugNN << LOGSEC_CORE << "Item was previously hidden and now shows up, expand.";
|
||||
|
||||
const_cast<FeedsProxyModel*>(this)->m_hiddenIndices.removeAll(QPair<int, QModelIndex>(source_row, source_parent));
|
||||
|
||||
// Now, item now should be displayed and previously it was not.
|
||||
// Expand!
|
||||
emit expandAfterFilterIn(m_sourceModel->index(source_row, 0, source_parent));
|
||||
}
|
||||
|
||||
if (!should_show) {
|
||||
const_cast<FeedsProxyModel*>(this)->m_hiddenIndices.append(QPair<int, QModelIndex>(source_row, source_parent));
|
||||
}
|
||||
|
||||
return should_show;
|
||||
}
|
||||
|
||||
|
@ -362,6 +334,22 @@ bool FeedsProxyModel::filterAcceptsRowInternal(int source_row, const QModelIndex
|
|||
|
||||
const RootItem* item = m_sourceModel->itemForIndex(idx);
|
||||
|
||||
if (item->kind() == RootItem::Kind::Important && !item->getParentServiceRoot()->nodeShowImportant()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item->kind() == RootItem::Kind::Unread && !item->getParentServiceRoot()->nodeShowUnread()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item->kind() == RootItem::Kind::Probes && !item->getParentServiceRoot()->nodeShowProbes()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item->kind() == RootItem::Kind::Labels && !item->getParentServiceRoot()->nodeShowLabels()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item->kind() != RootItem::Kind::Category && item->kind() != RootItem::Kind::Feed &&
|
||||
item->kind() != RootItem::Kind::Label) {
|
||||
// Some items are always visible.
|
||||
|
|
|
@ -78,7 +78,6 @@ class FeedsProxyModel : public QSortFilterProxyModel {
|
|||
bool m_showNodeProbes;
|
||||
bool m_showNodeLabels;
|
||||
bool m_showNodeImportant;
|
||||
QList<QPair<int, QModelIndex>> m_hiddenIndices;
|
||||
QList<RootItem::Kind> m_priorities;
|
||||
};
|
||||
|
||||
|
|
|
@ -71,11 +71,11 @@ void BaseToastNotification::setupTimedClosing() {
|
|||
}
|
||||
|
||||
bool BaseToastNotification::eventFilter(QObject* watched, QEvent* event) {
|
||||
if (event->type() == QEvent::Type::Enter) {
|
||||
if (watched == this && event->type() == QEvent::Type::Enter) {
|
||||
stopTimedClosing();
|
||||
}
|
||||
|
||||
if (event->type() == QEvent::Type::Leave) {
|
||||
if (watched == this && event->type() == QEvent::Type::Leave) {
|
||||
setupTimedClosing();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
#include "accountdetails.h"
|
||||
|
||||
AccountDetails::AccountDetails(QWidget* parent) : QWidget(parent) {
|
||||
m_ui.setupUi(this);
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
#ifndef ACCOUNTDETAILS_H
|
||||
#define ACCOUNTDETAILS_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "ui_accountdetails.h"
|
||||
|
||||
namespace Ui {
|
||||
class AccountDetails;
|
||||
}
|
||||
|
||||
class AccountDetails : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
friend class FormAccountDetails;
|
||||
|
||||
public:
|
||||
explicit AccountDetails(QWidget* parent = nullptr);
|
||||
|
||||
private:
|
||||
Ui::AccountDetails m_ui;
|
||||
};
|
||||
|
||||
#endif // ACCOUNTDETAILS_H
|
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AccountDetails</class>
|
||||
<widget class="QWidget" name="AccountDetails">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Display additional nodes</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cbImportant">
|
||||
<property name="text">
|
||||
<string>Important</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cbUnread">
|
||||
<property name="text">
|
||||
<string>Unread</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cbLabels">
|
||||
<property name="text">
|
||||
<string>Labels</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cbProbes">
|
||||
<property name="text">
|
||||
<string>Probes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>m_cbImportant</tabstop>
|
||||
<tabstop>m_cbUnread</tabstop>
|
||||
<tabstop>m_cbLabels</tabstop>
|
||||
<tabstop>m_cbProbes</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -5,21 +5,38 @@
|
|||
#include "gui/guiutilities.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "services/abstract/importantnode.h"
|
||||
#include "services/abstract/labelsnode.h"
|
||||
#include "services/abstract/searchsnode.h"
|
||||
#include "services/abstract/serviceroot.h"
|
||||
#include "services/abstract/unreadnode.h"
|
||||
|
||||
FormAccountDetails::FormAccountDetails(const QIcon& icon, QWidget* parent)
|
||||
: QDialog(parent), m_proxyDetails(new NetworkProxyDetails(this)), m_account(nullptr), m_creatingNew(false) {
|
||||
: QDialog(parent), m_proxyDetails(new NetworkProxyDetails(this)), m_accountDetails(new AccountDetails(this)),
|
||||
m_account(nullptr), m_creatingNew(false) {
|
||||
m_ui.setupUi(this);
|
||||
|
||||
insertCustomTab(m_proxyDetails, tr("Network proxy"), 0);
|
||||
GuiUtilities::applyDialogProperties(*this, icon.isNull()
|
||||
? qApp->icons()->fromTheme(QSL("emblem-system"))
|
||||
: icon);
|
||||
insertCustomTab(m_accountDetails, tr("Miscellaneous"), 0);
|
||||
insertCustomTab(m_proxyDetails, tr("Network proxy"), 1);
|
||||
|
||||
GuiUtilities::applyDialogProperties(*this, icon.isNull() ? qApp->icons()->fromTheme(QSL("emblem-system")) : icon);
|
||||
createConnections();
|
||||
}
|
||||
|
||||
void FormAccountDetails::apply() {
|
||||
m_account->setNodeShowImportant(m_accountDetails->m_ui.m_cbImportant->isChecked());
|
||||
m_account->setNodeShowLabels(m_accountDetails->m_ui.m_cbLabels->isChecked());
|
||||
m_account->setNodeShowProbes(m_accountDetails->m_ui.m_cbProbes->isChecked());
|
||||
m_account->setNodeShowUnread(m_accountDetails->m_ui.m_cbUnread->isChecked());
|
||||
|
||||
m_account->setNetworkProxy(m_proxyDetails->proxy());
|
||||
|
||||
if (!m_creatingNew) {
|
||||
m_account->itemChanged({m_account->importantNode(),
|
||||
m_account->labelsNode(),
|
||||
m_account->unreadNode(),
|
||||
m_account->probesNode()});
|
||||
}
|
||||
}
|
||||
|
||||
void FormAccountDetails::insertCustomTab(QWidget* custom_tab, const QString& title, int index) {
|
||||
|
@ -50,6 +67,11 @@ void FormAccountDetails::loadAccountData() {
|
|||
}
|
||||
}
|
||||
|
||||
m_accountDetails->m_ui.m_cbImportant->setChecked(m_account->nodeShowImportant());
|
||||
m_accountDetails->m_ui.m_cbLabels->setChecked(m_account->nodeShowLabels());
|
||||
m_accountDetails->m_ui.m_cbProbes->setChecked(m_account->nodeShowProbes());
|
||||
m_accountDetails->m_ui.m_cbUnread->setChecked(m_account->nodeShowUnread());
|
||||
|
||||
m_proxyDetails->setProxy(m_account->networkProxy());
|
||||
}
|
||||
|
||||
|
|
|
@ -11,19 +11,20 @@
|
|||
#include "database/databasequeries.h"
|
||||
#include "gui/reusable/networkproxydetails.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "services/abstract/gui/accountdetails.h"
|
||||
|
||||
class ServiceRoot;
|
||||
|
||||
class FormAccountDetails : public QDialog {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FormAccountDetails(const QIcon& icon, QWidget* parent = nullptr);
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
T* addEditAccount(T* account_to_edit = nullptr);
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
T* account() const;
|
||||
|
||||
protected slots:
|
||||
|
@ -34,7 +35,6 @@ class FormAccountDetails : public QDialog {
|
|||
virtual void apply();
|
||||
|
||||
protected:
|
||||
|
||||
void activateTab(int index);
|
||||
void clearTabs();
|
||||
void insertCustomTab(QWidget* custom_tab, const QString& title, int index);
|
||||
|
@ -50,11 +50,12 @@ class FormAccountDetails : public QDialog {
|
|||
protected:
|
||||
Ui::FormAccountDetails m_ui;
|
||||
NetworkProxyDetails* m_proxyDetails;
|
||||
AccountDetails* m_accountDetails;
|
||||
ServiceRoot* m_account;
|
||||
bool m_creatingNew;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
inline T* FormAccountDetails::addEditAccount(T* account_to_edit) {
|
||||
m_creatingNew = account_to_edit == nullptr;
|
||||
|
||||
|
@ -76,7 +77,7 @@ inline T* FormAccountDetails::addEditAccount(T* account_to_edit) {
|
|||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
inline T* FormAccountDetails::account() const {
|
||||
return qobject_cast<T*>(m_account);
|
||||
}
|
||||
|
|
|
@ -407,11 +407,17 @@ void ServiceRoot::saveAccountDataToDatabase() {
|
|||
}
|
||||
|
||||
QVariantHash ServiceRoot::customDatabaseData() const {
|
||||
return {};
|
||||
return {{QSL("show_node_unread"), m_nodeShowUnread},
|
||||
{QSL("show_node_important"), m_nodeShowImportant},
|
||||
{QSL("show_node_labels"), m_nodeShowLabels},
|
||||
{QSL("show_node_probes"), m_nodeShowProbes}};
|
||||
}
|
||||
|
||||
void ServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||
Q_UNUSED(data)
|
||||
m_nodeShowUnread = data.value(QSL("show_node_unread"), true).toBool();
|
||||
m_nodeShowImportant = data.value(QSL("show_node_important"), true).toBool();
|
||||
m_nodeShowLabels = data.value(QSL("show_node_labels"), true).toBool();
|
||||
m_nodeShowProbes = data.value(QSL("show_node_probes"), true).toBool();
|
||||
}
|
||||
|
||||
bool ServiceRoot::wantsBaggedIdsOfExistingMessages() const {
|
||||
|
@ -553,6 +559,38 @@ void ServiceRoot::restoreCustomCategoriesData(const QMap<QString, QVariantMap>&
|
|||
Q_UNUSED(cats)
|
||||
}
|
||||
|
||||
bool ServiceRoot::nodeShowProbes() const {
|
||||
return m_nodeShowProbes;
|
||||
}
|
||||
|
||||
void ServiceRoot::setNodeShowProbes(bool enabled) {
|
||||
m_nodeShowProbes = enabled;
|
||||
}
|
||||
|
||||
bool ServiceRoot::nodeShowLabels() const {
|
||||
return m_nodeShowLabels;
|
||||
}
|
||||
|
||||
void ServiceRoot::setNodeShowLabels(bool enabled) {
|
||||
m_nodeShowLabels = enabled;
|
||||
}
|
||||
|
||||
bool ServiceRoot::nodeShowImportant() const {
|
||||
return m_nodeShowImportant;
|
||||
}
|
||||
|
||||
void ServiceRoot::setNodeShowImportant(bool enabled) {
|
||||
m_nodeShowImportant = enabled;
|
||||
}
|
||||
|
||||
bool ServiceRoot::nodeShowUnread() const {
|
||||
return m_nodeShowUnread;
|
||||
}
|
||||
|
||||
void ServiceRoot::setNodeShowUnread(bool enabled) {
|
||||
m_nodeShowUnread = enabled;
|
||||
}
|
||||
|
||||
QNetworkProxy ServiceRoot::networkProxy() const {
|
||||
return m_networkProxy;
|
||||
}
|
||||
|
|
|
@ -248,6 +248,18 @@ class ServiceRoot : public RootItem {
|
|||
const QList<Label*>& labels,
|
||||
const QList<Search*>& probes);
|
||||
|
||||
bool nodeShowUnread() const;
|
||||
void setNodeShowUnread(bool enabled);
|
||||
|
||||
bool nodeShowImportant() const;
|
||||
void setNodeShowImportant(bool enabled);
|
||||
|
||||
bool nodeShowLabels() const;
|
||||
void setNodeShowLabels(bool enabled);
|
||||
|
||||
bool nodeShowProbes() const;
|
||||
void setNodeShowProbes(bool enabled);
|
||||
|
||||
public slots:
|
||||
virtual void addNewFeed(RootItem* selected_item, const QString& url = QString());
|
||||
virtual void addNewCategory(RootItem* selected_item);
|
||||
|
@ -315,6 +327,10 @@ class ServiceRoot : public RootItem {
|
|||
int m_accountId;
|
||||
QList<QAction*> m_serviceMenu;
|
||||
QNetworkProxy m_networkProxy;
|
||||
bool m_nodeShowUnread;
|
||||
bool m_nodeShowImportant;
|
||||
bool m_nodeShowLabels;
|
||||
bool m_nodeShowProbes;
|
||||
};
|
||||
|
||||
#if QT_VERSION_MAJOR == 6
|
||||
|
|
|
@ -48,7 +48,7 @@ void FeedlyServiceRoot::editItems(const QList<RootItem*>& items) {
|
|||
}
|
||||
|
||||
QVariantHash FeedlyServiceRoot::customDatabaseData() const {
|
||||
QVariantHash data;
|
||||
QVariantHash data = ServiceRoot::customDatabaseData();
|
||||
|
||||
data[QSL("username")] = m_network->username();
|
||||
data[QSL("dat")] = m_network->developerAccessToken();
|
||||
|
@ -65,6 +65,8 @@ QVariantHash FeedlyServiceRoot::customDatabaseData() const {
|
|||
}
|
||||
|
||||
void FeedlyServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||
ServiceRoot::setCustomDatabaseData(data);
|
||||
|
||||
m_network->setUsername(data[QSL("username")].toString());
|
||||
m_network->setDeveloperAccessToken(data[QSL("dat")].toString());
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void GmailServiceRoot::writeNewEmail() {
|
|||
}
|
||||
|
||||
QVariantHash GmailServiceRoot::customDatabaseData() const {
|
||||
QVariantHash data;
|
||||
QVariantHash data = ServiceRoot::customDatabaseData();
|
||||
|
||||
data[QSL("username")] = m_network->username();
|
||||
data[QSL("batch_size")] = m_network->batchSize();
|
||||
|
@ -86,6 +86,8 @@ QVariantHash GmailServiceRoot::customDatabaseData() const {
|
|||
}
|
||||
|
||||
void GmailServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||
ServiceRoot::setCustomDatabaseData(data);
|
||||
|
||||
m_network->setUsername(data[QSL("username")].toString());
|
||||
m_network->setBatchSize(data[QSL("batch_size")].toInt());
|
||||
m_network->setDownloadOnlyUnreadMessages(data[QSL("download_only_unread")].toBool());
|
||||
|
|
|
@ -45,7 +45,7 @@ void GreaderServiceRoot::editItems(const QList<RootItem*>& items) {
|
|||
}
|
||||
|
||||
QVariantHash GreaderServiceRoot::customDatabaseData() const {
|
||||
QVariantHash data;
|
||||
QVariantHash data = ServiceRoot::customDatabaseData();
|
||||
|
||||
data[QSL("service")] = int(m_network->service());
|
||||
data[QSL("username")] = m_network->username();
|
||||
|
@ -72,6 +72,8 @@ QVariantHash GreaderServiceRoot::customDatabaseData() const {
|
|||
}
|
||||
|
||||
void GreaderServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||
ServiceRoot::setCustomDatabaseData(data);
|
||||
|
||||
m_network->setService(GreaderServiceRoot::Service(data[QSL("service")].toInt()));
|
||||
m_network->setUsername(data[QSL("username")].toString());
|
||||
m_network->setPassword(TextFactory::decrypt(data[QSL("password")].toString()));
|
||||
|
|
|
@ -135,7 +135,7 @@ RootItem* OwnCloudServiceRoot::obtainNewTreeForSyncIn() const {
|
|||
}
|
||||
|
||||
QVariantHash OwnCloudServiceRoot::customDatabaseData() const {
|
||||
QVariantHash data;
|
||||
QVariantHash data = ServiceRoot::customDatabaseData();
|
||||
|
||||
data[QSL("auth_username")] = m_network->authUsername();
|
||||
data[QSL("auth_password")] = TextFactory::encrypt(m_network->authPassword());
|
||||
|
@ -148,6 +148,8 @@ QVariantHash OwnCloudServiceRoot::customDatabaseData() const {
|
|||
}
|
||||
|
||||
void OwnCloudServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||
ServiceRoot::setCustomDatabaseData(data);
|
||||
|
||||
m_network->setAuthUsername(data[QSL("auth_username")].toString());
|
||||
m_network->setAuthPassword(TextFactory::decrypt(data[QSL("auth_password")].toString()));
|
||||
m_network->setUrl(data[QSL("url")].toString());
|
||||
|
|
|
@ -36,7 +36,7 @@ RootItem* RedditServiceRoot::obtainNewTreeForSyncIn() const {
|
|||
}
|
||||
|
||||
QVariantHash RedditServiceRoot::customDatabaseData() const {
|
||||
QVariantHash data;
|
||||
QVariantHash data = ServiceRoot::customDatabaseData();
|
||||
|
||||
data[QSL("username")] = m_network->username();
|
||||
data[QSL("batch_size")] = m_network->batchSize();
|
||||
|
@ -50,6 +50,8 @@ QVariantHash RedditServiceRoot::customDatabaseData() const {
|
|||
}
|
||||
|
||||
void RedditServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||
ServiceRoot::setCustomDatabaseData(data);
|
||||
|
||||
m_network->setUsername(data[QSL("username")].toString());
|
||||
m_network->setBatchSize(data[QSL("batch_size")].toInt());
|
||||
m_network->setDownloadOnlyUnreadMessages(data[QSL("download_only_unread")].toBool());
|
||||
|
|
|
@ -227,7 +227,7 @@ void TtRssServiceRoot::saveAllCachedData(bool ignore_errors) {
|
|||
}
|
||||
|
||||
QVariantHash TtRssServiceRoot::customDatabaseData() const {
|
||||
QVariantHash data;
|
||||
QVariantHash data = ServiceRoot::customDatabaseData();
|
||||
|
||||
data[QSL("username")] = m_network->username();
|
||||
data[QSL("password")] = TextFactory::encrypt(m_network->password());
|
||||
|
@ -244,6 +244,8 @@ QVariantHash TtRssServiceRoot::customDatabaseData() const {
|
|||
}
|
||||
|
||||
void TtRssServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||
ServiceRoot::setCustomDatabaseData(data);
|
||||
|
||||
m_network->setUsername(data[QSL("username")].toString());
|
||||
m_network->setPassword(TextFactory::decrypt(data[QSL("password")].toString()));
|
||||
m_network->setAuthIsUsed(data[QSL("auth_protected")].toBool());
|
||||
|
|
Loading…
Reference in New Issue