Removed some parts, fixed leaks in database backend.
This commit is contained in:
parent
7e07707296
commit
714057eea0
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -94,3 +94,7 @@ void FeedsModelRootItem::setTitle(const QString &title) {
|
|||
QList<FeedsModelRootItem *> FeedsModelRootItem::childItems() const {
|
||||
return m_childItems;
|
||||
}
|
||||
|
||||
void FeedsModelRootItem::clearChilds() {
|
||||
m_childItems.clear();
|
||||
}
|
||||
|
|
|
@ -57,6 +57,9 @@ class FeedsModelRootItem {
|
|||
// Acess to children.
|
||||
QList<FeedsModelRootItem *> childItems() const;
|
||||
|
||||
// Removes all childs from this item.
|
||||
void clearChilds();
|
||||
|
||||
protected:
|
||||
Kind m_kind;
|
||||
QString m_title;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
#include "gui/messagebox.h"
|
||||
|
||||
|
||||
MessageBox::MessageBox(QWidget *parent) : QMessageBox(parent) {
|
||||
}
|
||||
|
||||
MessageBox::~MessageBox() {
|
||||
qDebug("Destroying MessageBox instance.");
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef MESSAGEBOX_H
|
||||
#define MESSAGEBOX_H
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
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
|
Loading…
Reference in New Issue