Removed some parts, fixed leaks in database backend.

This commit is contained in:
Martin Rotter 2013-12-17 17:08:11 +01:00
parent 7e07707296
commit 714057eea0
9 changed files with 18 additions and 36 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -94,3 +94,7 @@ void FeedsModelRootItem::setTitle(const QString &title) {
QList<FeedsModelRootItem *> FeedsModelRootItem::childItems() const {
return m_childItems;
}
void FeedsModelRootItem::clearChilds() {
m_childItems.clear();
}

View File

@ -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;

View File

@ -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 {

View File

@ -1,9 +0,0 @@
#include "gui/messagebox.h"
MessageBox::MessageBox(QWidget *parent) : QMessageBox(parent) {
}
MessageBox::~MessageBox() {
qDebug("Destroying MessageBox instance.");
}

View File

@ -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