Refactorings...

This commit is contained in:
Martin Rotter 2013-12-22 11:29:10 +01:00
parent a0dc1e1d66
commit 86c22db046
8 changed files with 48 additions and 2 deletions

View File

@ -1,5 +1,19 @@
#include "core/feeddownloader.h"
#include "core/feedsmodelfeed.h"
#include <QThread>
#include <QDebug>
FeedDownloader::FeedDownloader(QObject *parent) : QObject(parent) {
}
FeedDownloader::~FeedDownloader() {
qDebug("Destroying FeedDownloader instance.");
}
void FeedDownloader::updateFeeds(const QList<FeedsModelFeed *> &feeds) {
qDebug().nospace() << "Creating main application form in thread: \'" <<
QThread::currentThreadId() << "\'.";
}

View File

@ -4,16 +4,34 @@
#include <QObject>
class FeedsModelFeed;
// This class offers means to "update" feeds
// and "special" categories.
// NOTE: This class is used withing separate thread.
class FeedDownloader : public QObject {
Q_OBJECT
public:
// Constructors and destructors.
explicit FeedDownloader(QObject *parent = 0);
virtual ~FeedDownloader();
signals:
// Emitted if all items from update queue are
// processed.
void finished();
// Emitted if any item is processed.
// "Current" counts
void progress(FeedsModelFeed *feed, int current, int total);
public slots:
// Performs update of all feeds from the "feeds" parameter.
// New messages are downloaded for each feed and they
// are stored persistently in the database.
// Appropriate signals are emitted.
void updateFeeds(const QList<FeedsModelFeed*> &feeds);
};
#endif // FEEDDOWNLOADER_H

View File

@ -17,6 +17,8 @@ FeedsModel::FeedsModel(QObject *parent) : QAbstractItemModel(parent) {
setObjectName("FeedsModel");
m_rootItem = new FeedsModelRootItem();
m_rootItem->setTitle(tr("root"));
m_countsIcon = IconThemeFactory::getInstance()->fromTheme("mail-mark-unread");
m_headerData << tr("Title");

View File

@ -46,6 +46,8 @@ class FeedsModel : public QAbstractItemModel {
QList<FeedsModelFeed*> feedsForIndex(const QModelIndex &index);
public slots:
// Signals that properties (probably counts)
// of ALL items have changed.
void reloadWholeLayout();
// Signals that SOME data of this model need

View File

@ -6,7 +6,8 @@
FeedsModelRootItem::FeedsModelRootItem(FeedsModelRootItem *parent_item)
: m_kind(FeedsModelRootItem::RootItem), m_parentItem(parent_item) {
: m_kind(FeedsModelRootItem::RootItem),
m_parentItem(parent_item) {
}
FeedsModelRootItem::~FeedsModelRootItem() {

View File

@ -2,6 +2,7 @@
#include "core/settings.h"
#include "core/messagesproxymodel.h"
#include "core/feeddownloader.h"
#include "gui/webbrowser.h"
#include "gui/formmain.h"
#include "gui/iconthemefactory.h"

View File

@ -7,6 +7,7 @@
class WebBrowser;
class FeedsView;
class MessagesView;
class FeedDownloader;
class QToolBar;
class QSplitter;
@ -46,6 +47,8 @@ class FeedMessageViewer : public TabContent {
MessagesView *m_messagesView;
FeedsView *m_feedsView;
WebBrowser *m_messagesBrowser;
FeedDownloader *m_feedDownloader;
};
#endif // FEEDMESSAGEVIEWER_H

View File

@ -16,7 +16,9 @@
#include <QSettings>
#endif
#include <QThread>
#include <QTranslator>
#include <QDebug>
// TODO: Check if extra UNIX signalling is needed.
@ -77,6 +79,9 @@ int main(int argc, char *argv[]) {
QtSingleApplication::setOrganizationDomain(APP_URL);
QtSingleApplication::setWindowIcon(QIcon(APP_ICON_PATH));
qDebug().nospace() << "Creating main application form in thread: \'" <<
QThread::currentThreadId() << "\'.";
// Instantiate main application window.
FormMain window;