diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a1d15c59..8b6ed7f75 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,7 +253,6 @@ set(APP_SOURCES src/gui/feedsview.cpp src/gui/messagesview.cpp src/gui/statusbar.cpp - src/gui/messagebox.cpp src/gui/iconfactory.cpp # CORE sources. @@ -314,7 +313,6 @@ set(APP_HEADERS src/gui/feedsview.h src/gui/messagesview.h src/gui/statusbar.h - src/gui/messagebox.h # CORE headers. src/core/settings.h diff --git a/src/core/databasefactory.cpp b/src/core/databasefactory.cpp index e7289fdb3..d45a42551 100644 --- a/src/core/databasefactory.cpp +++ b/src/core/databasefactory.cpp @@ -127,6 +127,7 @@ QSqlDatabase DatabaseFactory::initialize(const QString &connection_name) { QSqlDatabase DatabaseFactory::addConnection(const QString &connection_name) { if (!m_initialized) { + m_initialized = true; return initialize(connection_name); } else { @@ -154,6 +155,11 @@ QSqlDatabase DatabaseFactory::addConnection(const QString &connection_name) { qFatal("Database was NOT opened. Delivered error message: '%s'", qPrintable(database.lastError().text())); } + else { + qDebug("Database connection '%s' to file '%s' seems to be established.", + qPrintable(connection_name), + qPrintable(QDir::toNativeSeparators(database.databaseName()))); + } return database; } diff --git a/src/core/databasefactory.h b/src/core/databasefactory.h index aef9a6333..a6f541777 100644 --- a/src/core/databasefactory.h +++ b/src/core/databasefactory.h @@ -36,8 +36,6 @@ class DatabaseFactory : public QObject { // Returns absolute file path to database file. QString getDatabasePath(); - // Database manipulators. - // NOTE: This returns OPENED database. QSqlDatabase addConnection(const QString &connection_name); diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index e2a72407d..b44732406 100644 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -23,6 +23,9 @@ FeedsModel::FeedsModel(QObject *parent) : QAbstractItemModel(parent) { tr("Counts of unread/all meesages."); loadFromDatabase(); + + loadFromDatabase(); + /* FeedsModelStandardCategory *cat1 = new FeedsModelStandardCategory(); FeedsModelStandardCategory *cat2 = new FeedsModelStandardCategory(); @@ -173,7 +176,9 @@ FeedsModelRootItem *FeedsModel::itemForIndex(const QModelIndex &index) { } void FeedsModel::loadFromDatabase() { + // Delete all childs of the root node and clear them from the memory. qDeleteAll(m_rootItem->childItems()); + m_rootItem->clearChilds(); QSqlDatabase database = DatabaseFactory::getInstance()->addConnection(objectName()); CategoryAssignment categories; diff --git a/src/core/feedsmodelrootitem.cpp b/src/core/feedsmodelrootitem.cpp index 1513f0d43..84cbbe957 100755 --- a/src/core/feedsmodelrootitem.cpp +++ b/src/core/feedsmodelrootitem.cpp @@ -94,3 +94,7 @@ void FeedsModelRootItem::setTitle(const QString &title) { QList FeedsModelRootItem::childItems() const { return m_childItems; } + +void FeedsModelRootItem::clearChilds() { + m_childItems.clear(); +} diff --git a/src/core/feedsmodelrootitem.h b/src/core/feedsmodelrootitem.h index 5d106d71f..2da4bd0db 100755 --- a/src/core/feedsmodelrootitem.h +++ b/src/core/feedsmodelrootitem.h @@ -57,6 +57,9 @@ class FeedsModelRootItem { // Acess to children. QList childItems() const; + // Removes all childs from this item. + void clearChilds(); + protected: Kind m_kind; QString m_title; diff --git a/src/core/feedsmodelstandardcategory.cpp b/src/core/feedsmodelstandardcategory.cpp index b30382874..dbf026d89 100755 --- a/src/core/feedsmodelstandardcategory.cpp +++ b/src/core/feedsmodelstandardcategory.cpp @@ -25,7 +25,6 @@ QVariant FeedsModelStandardCategory::data(int column, int role) const { m_creationDate.toString(Qt::DefaultLocaleShortDate)); } else if (column == FDS_MODEL_COUNTS_INDEX) { - // TODO: tady dat plural a singular return QObject::tr("%n unread message(s).", "", countOfUnreadMessages()); } else { diff --git a/src/gui/messagebox.cpp b/src/gui/messagebox.cpp deleted file mode 100644 index 8ce123064..000000000 --- a/src/gui/messagebox.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "gui/messagebox.h" - - -MessageBox::MessageBox(QWidget *parent) : QMessageBox(parent) { -} - -MessageBox::~MessageBox() { - qDebug("Destroying MessageBox instance."); -} diff --git a/src/gui/messagebox.h b/src/gui/messagebox.h deleted file mode 100644 index 2df520c6a..000000000 --- a/src/gui/messagebox.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef MESSAGEBOX_H -#define MESSAGEBOX_H - -#include - - -class MessageBox : public QMessageBox { - Q_OBJECT - - public: - explicit MessageBox(QWidget *parent = 0); - virtual ~MessageBox(); - - // TODO: http://libqxt.bitbucket.org/doc/0.6/qxtconfirmationmessage.html - - signals: - - public slots: - -}; - -#endif // MESSAGEBOX_H