Refactoring.
This commit is contained in:
parent
b91d7b926d
commit
ef33988ca6
@ -51,7 +51,7 @@ QList<QAction*> RootItem::contextMenu() {
|
|||||||
return QList<QAction*>();
|
return QList<QAction*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RootItem::canBeEdited() {
|
bool RootItem::canBeEdited() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ bool RootItem::editViaGui() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RootItem::canBeDeleted() {
|
bool RootItem::canBeDeleted() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,12 +359,12 @@ bool RootItem::removeChild(RootItem *child) {
|
|||||||
return m_childItems.removeOne(child);
|
return m_childItems.removeOne(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
Category *RootItem::toCategory() {
|
Category *RootItem::toCategory() const {
|
||||||
return static_cast<Category*>(this);
|
return static_cast<Category*>(const_cast<RootItem*>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
Feed *RootItem::toFeed() {
|
Feed *RootItem::toFeed() const {
|
||||||
return static_cast<Feed*>(this);
|
return static_cast<Feed*>(const_cast<RootItem*>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceRoot *RootItem::toServiceRoot() const {
|
ServiceRoot *RootItem::toServiceRoot() const {
|
||||||
|
@ -82,14 +82,14 @@ class RootItem : public QObject {
|
|||||||
virtual QList<QAction*> contextMenu();
|
virtual QList<QAction*> contextMenu();
|
||||||
|
|
||||||
// Can properties of this item be edited?
|
// Can properties of this item be edited?
|
||||||
virtual bool canBeEdited();
|
virtual bool canBeEdited() const;
|
||||||
|
|
||||||
// Performs editing of properties of this item (probably via dialog)
|
// Performs editing of properties of this item (probably via dialog)
|
||||||
// and returns result status.
|
// and returns result status.
|
||||||
virtual bool editViaGui();
|
virtual bool editViaGui();
|
||||||
|
|
||||||
// Can the item be deleted?
|
// Can the item be deleted?
|
||||||
virtual bool canBeDeleted();
|
virtual bool canBeDeleted() const;
|
||||||
|
|
||||||
// Performs deletion of the item, this
|
// Performs deletion of the item, this
|
||||||
// method should NOT display any additional dialogs.
|
// method should NOT display any additional dialogs.
|
||||||
@ -255,8 +255,8 @@ class RootItem : public QObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Converters
|
// Converters
|
||||||
Category *toCategory();
|
Category *toCategory() const;
|
||||||
Feed *toFeed();
|
Feed *toFeed() const;
|
||||||
ServiceRoot *toServiceRoot() const;
|
ServiceRoot *toServiceRoot() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -41,7 +41,7 @@ class ServiceEntryPoint {
|
|||||||
// some kind of first-time configuration dialog inside itself
|
// some kind of first-time configuration dialog inside itself
|
||||||
// before returning the root item.
|
// before returning the root item.
|
||||||
// Returns NULL if initialization of new root cannot be done.
|
// Returns NULL if initialization of new root cannot be done.
|
||||||
virtual ServiceRoot *createNewRoot() = 0;
|
virtual ServiceRoot *createNewRoot() const = 0;
|
||||||
|
|
||||||
// Performs initialization of all service accounts created using this entry
|
// Performs initialization of all service accounts created using this entry
|
||||||
// point from persistent DB.
|
// point from persistent DB.
|
||||||
|
@ -36,7 +36,7 @@ ServiceRoot::~ServiceRoot() {
|
|||||||
bool ServiceRoot::deleteViaGui() {
|
bool ServiceRoot::deleteViaGui() {
|
||||||
QSqlDatabase connection = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
QSqlDatabase connection = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||||
QSqlQuery query(connection);
|
QSqlQuery query(connection);
|
||||||
int account_id = accountId();
|
const int account_id = accountId();
|
||||||
query.setForwardOnly(true);
|
query.setForwardOnly(true);
|
||||||
|
|
||||||
QStringList queries;
|
QStringList queries;
|
||||||
@ -84,7 +84,7 @@ bool ServiceRoot::markAsReadUnread(RootItem::ReadStatus status) {
|
|||||||
|
|
||||||
QList<Message> ServiceRoot::undeletedMessages() const {
|
QList<Message> ServiceRoot::undeletedMessages() const {
|
||||||
QList<Message> messages;
|
QList<Message> messages;
|
||||||
int account_id = accountId();
|
const int account_id = accountId();
|
||||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||||
QSqlQuery query(database);
|
QSqlQuery query(database);
|
||||||
|
|
||||||
|
@ -82,6 +82,10 @@ class ServiceRoot : public RootItem {
|
|||||||
virtual void start(bool freshly_activated) = 0;
|
virtual void start(bool freshly_activated) = 0;
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
|
|
||||||
|
// Account ID corresponds with DB attribute Accounts (id).
|
||||||
|
int accountId() const;
|
||||||
|
void setAccountId(int account_id);
|
||||||
|
|
||||||
// Returns the UNIQUE code of the given service.
|
// Returns the UNIQUE code of the given service.
|
||||||
// NOTE: Keep in sync with ServiceEntryRoot::code().
|
// NOTE: Keep in sync with ServiceEntryRoot::code().
|
||||||
virtual QString code() const = 0;
|
virtual QString code() const = 0;
|
||||||
@ -156,10 +160,6 @@ class ServiceRoot : public RootItem {
|
|||||||
void requestItemReassignment(RootItem *item, RootItem *new_parent);
|
void requestItemReassignment(RootItem *item, RootItem *new_parent);
|
||||||
void requestItemRemoval(RootItem *item);
|
void requestItemRemoval(RootItem *item);
|
||||||
|
|
||||||
// Account ID corresponds with DB attribute Accounts (id).
|
|
||||||
int accountId() const;
|
|
||||||
void setAccountId(int account_id);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void addNewFeed(const QString &url = QString()) = 0;
|
virtual void addNewFeed(const QString &url = QString()) = 0;
|
||||||
virtual void addNewCategory() = 0;
|
virtual void addNewCategory() = 0;
|
||||||
|
@ -47,11 +47,11 @@ class StandardCategory : public Category {
|
|||||||
Qt::ItemFlags additionalFlags() const;
|
Qt::ItemFlags additionalFlags() const;
|
||||||
bool performDragDropChange(RootItem *target_item);
|
bool performDragDropChange(RootItem *target_item);
|
||||||
|
|
||||||
bool canBeEdited() {
|
bool canBeEdited() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canBeDeleted() {
|
bool canBeDeleted() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,11 +63,11 @@ class StandardFeed : public Feed {
|
|||||||
|
|
||||||
QList<QAction*> contextMenu();
|
QList<QAction*> contextMenu();
|
||||||
|
|
||||||
bool canBeEdited() {
|
bool canBeEdited() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canBeDeleted() {
|
bool canBeDeleted() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ QString StandardServiceEntryPoint::code() const {
|
|||||||
return SERVICE_CODE_STD_RSS;
|
return SERVICE_CODE_STD_RSS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceRoot *StandardServiceEntryPoint::createNewRoot() {
|
ServiceRoot *StandardServiceEntryPoint::createNewRoot() const {
|
||||||
// Switch DB.
|
// Switch DB.
|
||||||
QSqlDatabase database = qApp->database()->connection(QSL("StandardServiceEntryPoint"), DatabaseFactory::FromSettings);
|
QSqlDatabase database = qApp->database()->connection(QSL("StandardServiceEntryPoint"), DatabaseFactory::FromSettings);
|
||||||
QSqlQuery query(database);
|
QSqlQuery query(database);
|
||||||
|
@ -34,7 +34,7 @@ class StandardServiceEntryPoint : public ServiceEntryPoint {
|
|||||||
QIcon icon() const;
|
QIcon icon() const;
|
||||||
QString code() const;
|
QString code() const;
|
||||||
|
|
||||||
ServiceRoot *createNewRoot();
|
ServiceRoot *createNewRoot() const;
|
||||||
QList<ServiceRoot*> initializeSubtree() const;
|
QList<ServiceRoot*> initializeSubtree() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,11 +108,11 @@ QString StandardServiceRoot::code() const {
|
|||||||
return SERVICE_CODE_STD_RSS;
|
return SERVICE_CODE_STD_RSS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StandardServiceRoot::canBeEdited() {
|
bool StandardServiceRoot::canBeEdited() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StandardServiceRoot::canBeDeleted() {
|
bool StandardServiceRoot::canBeDeleted() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ class StandardServiceRoot : public ServiceRoot {
|
|||||||
|
|
||||||
QString code() const;
|
QString code() const;
|
||||||
|
|
||||||
bool canBeEdited();
|
bool canBeEdited() const;
|
||||||
bool canBeDeleted();
|
bool canBeDeleted() const;
|
||||||
bool deleteViaGui();
|
bool deleteViaGui();
|
||||||
|
|
||||||
bool markAsReadUnread(ReadStatus status);
|
bool markAsReadUnread(ReadStatus status);
|
||||||
|
@ -138,7 +138,7 @@ void TtRssFeed::updateCounts(bool including_total_count) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TtRssFeed::canBeEdited() {
|
bool TtRssFeed::canBeEdited() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class TtRssFeed : public Feed {
|
|||||||
|
|
||||||
void updateCounts(bool including_total_count);
|
void updateCounts(bool including_total_count);
|
||||||
|
|
||||||
bool canBeEdited();
|
bool canBeEdited() const;
|
||||||
bool editViaGui();
|
bool editViaGui();
|
||||||
|
|
||||||
int countOfAllMessages() const;
|
int countOfAllMessages() const;
|
||||||
|
@ -71,7 +71,7 @@ QString TtRssServiceEntryPoint::code() const {
|
|||||||
return SERVICE_CODE_TT_RSS;
|
return SERVICE_CODE_TT_RSS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceRoot *TtRssServiceEntryPoint::createNewRoot() {
|
ServiceRoot *TtRssServiceEntryPoint::createNewRoot() const {
|
||||||
QPointer<FormEditAccount> form_acc = new FormEditAccount(qApp->mainForm());
|
QPointer<FormEditAccount> form_acc = new FormEditAccount(qApp->mainForm());
|
||||||
TtRssServiceRoot *new_root = form_acc.data()->execForCreate();
|
TtRssServiceRoot *new_root = form_acc.data()->execForCreate();
|
||||||
delete form_acc.data();
|
delete form_acc.data();
|
||||||
|
@ -35,7 +35,7 @@ class TtRssServiceEntryPoint : public ServiceEntryPoint {
|
|||||||
QIcon icon() const;
|
QIcon icon() const;
|
||||||
QString code() const;
|
QString code() const;
|
||||||
|
|
||||||
ServiceRoot *createNewRoot();
|
ServiceRoot *createNewRoot() const;
|
||||||
QList<ServiceRoot*> initializeSubtree() const;
|
QList<ServiceRoot*> initializeSubtree() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -129,11 +129,11 @@ void TtRssServiceRoot::addNewCategory() {
|
|||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TtRssServiceRoot::canBeEdited() {
|
bool TtRssServiceRoot::canBeEdited() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TtRssServiceRoot::canBeDeleted() {
|
bool TtRssServiceRoot::canBeDeleted() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ class TtRssServiceRoot : public ServiceRoot {
|
|||||||
|
|
||||||
QString code() const;
|
QString code() const;
|
||||||
|
|
||||||
bool canBeEdited();
|
bool canBeEdited() const;
|
||||||
bool canBeDeleted();
|
bool canBeDeleted() const;
|
||||||
bool editViaGui();
|
bool editViaGui();
|
||||||
bool deleteViaGui();
|
bool deleteViaGui();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user