h
This commit is contained in:
parent
81c30c504a
commit
db5274da66
7 changed files with 138 additions and 85 deletions
|
@ -1,50 +1,50 @@
|
|||
DROP TABLE IF EXISTS Information;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Information (
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT NOT NULL
|
||||
);
|
||||
-- !
|
||||
INSERT INTO Information VALUES ('schema_version', '0.0.1');
|
||||
-- !
|
||||
DROP TABLE IF EXISTS Categories;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Categories (
|
||||
id INTEGER PRIMARY KEY,
|
||||
title TEXT NOT NULL UNIQUE CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created TEXT NOT NULL CHECK (date_created != ''),
|
||||
icon BLOB
|
||||
);
|
||||
-- !
|
||||
DROP TABLE IF EXISTS Feeds;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Feeds (
|
||||
id INTEGER PRIMARY KEY,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created TEXT NOT NULL CHECK (date_created != ''),
|
||||
icon BLOB,
|
||||
category INTEGER NOT NULL CHECK (category >= -1),
|
||||
encoding TEXT NOT NULL CHECK (encoding != ''),
|
||||
url TEXT NOT NULL UNIQUE CHECK (url != ''),
|
||||
type INTEGER NOT NULL
|
||||
);
|
||||
-- !
|
||||
DROP TABLE IF EXISTS Messages;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Messages (
|
||||
id INTEGER PRIMARY KEY,
|
||||
read INTEGER(1) NOT NULL CHECK (read >= 0 AND read <= 1) DEFAULT (0),
|
||||
deleted INTEGER(1) NOT NULL CHECK (deleted >= 0 AND deleted <= 1) DEFAULT (0),
|
||||
important INTEGER(1) NOT NULL CHECK (important >= 0 AND important <= 1) DEFAULT (0),
|
||||
feed INTEGER NOT NULL,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
url TEXT,
|
||||
author TEXT,
|
||||
date_created TEXT NOT NULL CHECK (date_created != ''),
|
||||
date_updated TEXT,
|
||||
contents TEXT,
|
||||
|
||||
FOREIGN KEY (feed) REFERENCES Feeds (id)
|
||||
DROP TABLE IF EXISTS Information;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Information (
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT NOT NULL
|
||||
);
|
||||
-- !
|
||||
INSERT INTO Information VALUES ('schema_version', '0.0.1');
|
||||
-- !
|
||||
DROP TABLE IF EXISTS Categories;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Categories (
|
||||
id INTEGER PRIMARY KEY,
|
||||
title TEXT NOT NULL UNIQUE CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created TEXT NOT NULL CHECK (date_created != ''),
|
||||
icon BLOB
|
||||
);
|
||||
-- !
|
||||
DROP TABLE IF EXISTS Feeds;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Feeds (
|
||||
id INTEGER PRIMARY KEY,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created TEXT NOT NULL CHECK (date_created != ''),
|
||||
icon BLOB,
|
||||
category INTEGER NOT NULL CHECK (category >= -1),
|
||||
encoding TEXT NOT NULL CHECK (encoding != ''),
|
||||
url TEXT NOT NULL UNIQUE CHECK (url != ''),
|
||||
type INTEGER NOT NULL
|
||||
);
|
||||
-- !
|
||||
DROP TABLE IF EXISTS Messages;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Messages (
|
||||
id INTEGER PRIMARY KEY,
|
||||
read INTEGER(1) NOT NULL CHECK (read >= 0 AND read <= 1) DEFAULT (0),
|
||||
deleted INTEGER(1) NOT NULL CHECK (deleted >= 0 AND deleted <= 1) DEFAULT (0),
|
||||
important INTEGER(1) NOT NULL CHECK (important >= 0 AND important <= 1) DEFAULT (0),
|
||||
feed INTEGER NOT NULL,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
url TEXT,
|
||||
author TEXT,
|
||||
date_created TEXT NOT NULL CHECK (date_created != ''),
|
||||
date_updated TEXT,
|
||||
contents TEXT,
|
||||
|
||||
FOREIGN KEY (feed) REFERENCES Feeds (id)
|
||||
);
|
|
@ -6,31 +6,40 @@
|
|||
<email>rotter.martinos@gmail.com</email>
|
||||
</author>
|
||||
<style/>
|
||||
<markup>PGh0bWw+IDxoZWFkPiA8c3R5bGU+cHJle3doaXRlLXNwYWNlOnByZS13cmFwfS5oZWFkZXJ0ZXh0
|
||||
e2ZvbnQtc2l6ZToxOXB4O21hcmdpbi1ib3R0b206MTBweH0uaGVhZGVye2ZvbnQtc2l6ZToxNXB4
|
||||
Oy13ZWJraXQtdHJhbnNpdGlvbjpiYWNrZ3JvdW5kIDFzIGVhc2Utb3V0O2JhY2tncm91bmQ6LXdl
|
||||
YmtpdC1ncmFkaWVudChsaW5lYXIsbGVmdCB0b3AsbGVmdCBib3R0b20sY29sb3Itc3RvcCgwJSwj
|
||||
NDU0ODRkKSxjb2xvci1zdG9wKDEwMCUsIzAwMDAwMCkpO2JhY2tncm91bmQ6LXdlYmtpdC1saW5l
|
||||
YXItZ3JhZGllbnQodG9wLCM0NTQ4NGQgMCwjMDAwMDAwIDEwMCUpOy13ZWJraXQtYm9yZGVyLXJh
|
||||
ZGl1czozcHg7dGV4dC1zaGFkb3c6MCAwIDFweCAjZmZmO2ZpbHRlcjpkcm9wc2hhZG93KGNvbG9y
|
||||
PSNmZmZmZmYsb2ZmeD0wLG9mZnk9MCk7cGFkZGluZzo4cHg7bWFyZ2luOjVweCBhdXRvIDVweCBh
|
||||
dXRvO2NvbG9yOndoaXRlfS5oZWFkZXIgYXtjb2xvcjp3aGl0ZX0uY29udGVudHtmb250LXNpemU6
|
||||
MTRweDtiYWNrZ3JvdW5kOi13ZWJraXQtZ3JhZGllbnQobGluZWFyLGxlZnQgdG9wLGxlZnQgYm90
|
||||
dG9tLGNvbG9yLXN0b3AoMCUscmdiYSgyMzgsMjM4LDIzOCwwLjY2KSksY29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XQtYm9yZGVyLXJh
|
||||
ZGl1czoxcHg7DQogICAgICAgIHRleHQtc2hhZG93OjAgMCAxcHggI2ZmZjsNCiAgICAgICAgZmls
|
||||
dGVyOmRyb3BzaGFkb3coY29sb3I9I2ZmZmZmZixvZmZ4PTAsb2ZmeT0wKTsNCiAgICAgICAgcGFk
|
||||
ZGluZzo4cHg7DQogICAgICAgIG1hcmdpbjo1cHggYXV0byA1cHggYXV0bzsNCiAgICAgICAgY29s
|
||||
b3I6d2hpdGV9DQogICAgPC9zdHlsZT4NCiAgICA8dGl0bGU+DQogICAgICAlMQ0KICAgIDwvdGl0
|
||||
bGU+DQogIDwvaGVhZD4NCiAgPGJvZHk+DQogICAgPGRpdiBjbGFzcz0iaGVhZGVyIj4NCiAgICAg
|
||||
IDxkaXYgY2xhc3M9ImhlYWRlcnRleHQiPg0KICAgICAgICAlMQ0KICAgICAgPC9kaXY+DQogICAg
|
||||
ICAlMg0KICAgICAgPGJyPg0KICAgICAgPGEgaHJlZj0iJTMiPg0KICAgICAgICAlMw0KICAgICAg
|
||||
PC9hPg0KICAgIDwvZGl2Pg0KICAgIDxkaXYgY2xhc3M9ImNvbnRlbnQiPg0KICAgICAgJTQgDQog
|
||||
ICAgPC9kaXY+DQogICAgPGRpdiBjbGFzcz0iZm9vdGVyIj4NCiAgICAgICU1IA0KICAgIDwvZGl2
|
||||
Pg0KICA8L2JvZHk+DQo8L2h0bWw+</markup>
|
||||
<data/>
|
||||
</skin>
|
|
@ -20,7 +20,7 @@ MessagesModel::MessagesModel(QObject *parent)
|
|||
setupHeaderData();
|
||||
|
||||
// Set desired table and edit strategy.
|
||||
setEditStrategy(QSqlTableModel::OnFieldChange);
|
||||
setEditStrategy(QSqlTableModel::OnManualSubmit);
|
||||
setTable("Messages");
|
||||
|
||||
loadMessages(QList<int>());
|
||||
|
@ -50,7 +50,11 @@ void MessagesModel::setupFonts() {
|
|||
}
|
||||
|
||||
void MessagesModel::loadMessages(const QList<int> feed_ids) {
|
||||
// Submit changes first.
|
||||
submitAll();
|
||||
|
||||
// Conversion of parameter.
|
||||
m_currentFeeds = feed_ids;
|
||||
QStringList stringy_ids;
|
||||
stringy_ids.reserve(feed_ids.count());
|
||||
|
||||
|
@ -68,6 +72,7 @@ Message MessagesModel::messageAt(int row_index) const {
|
|||
QSqlRecord rec = record(row_index);
|
||||
Message message;
|
||||
|
||||
// Fill Message object with details.
|
||||
message.m_author = rec.value(MSG_DB_AUTHOR_INDEX).toString();
|
||||
message.m_contents = rec.value(MSG_DB_CONTENTS_INDEX).toString();
|
||||
message.m_title = rec.value(MSG_DB_TITLE_INDEX).toString();
|
||||
|
@ -95,6 +100,10 @@ Qt::ItemFlags MessagesModel::flags(const QModelIndex &idx) const {
|
|||
}
|
||||
}
|
||||
|
||||
QVariant MessagesModel::data(int row, int column, int role) const {
|
||||
return data(index(row, column), role);
|
||||
}
|
||||
|
||||
QVariant MessagesModel::data(const QModelIndex &idx, int role) const {
|
||||
switch (role) {
|
||||
//
|
||||
|
@ -142,10 +151,6 @@ QVariant MessagesModel::data(const QModelIndex &idx, int role) const {
|
|||
}
|
||||
|
||||
bool MessagesModel::setData(const QModelIndex &idx, const QVariant &value, int role) {
|
||||
if (!idx.isValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_isInEditingMode = true;
|
||||
bool set_data_result = QSqlTableModel::setData(idx, value, role);
|
||||
m_isInEditingMode = false;
|
||||
|
@ -153,6 +158,25 @@ bool MessagesModel::setData(const QModelIndex &idx, const QVariant &value, int r
|
|||
return set_data_result;
|
||||
}
|
||||
|
||||
bool MessagesModel::setMessageRead(int row_index, int read) {
|
||||
return setData(index(row_index, MSG_DB_READ_INDEX),
|
||||
read);
|
||||
}
|
||||
|
||||
bool MessagesModel::setMessageDeleted(int row_index, int deleted) {
|
||||
return setData(index(row_index, MSG_DB_DELETED_INDEX),
|
||||
deleted);
|
||||
}
|
||||
|
||||
bool MessagesModel::switchMessageImportance(int row_index) {
|
||||
QModelIndex target_index = index(row_index, MSG_DB_IMPORTANT_INDEX);
|
||||
int current_importance = data(target_index).toInt();
|
||||
|
||||
return current_importance == 1 ?
|
||||
setData(target_index, 0) :
|
||||
setData(target_index, 1);
|
||||
}
|
||||
|
||||
QVariant MessagesModel::headerData(int section,
|
||||
Qt::Orientation orientation,
|
||||
int role) const {
|
||||
|
|
|
@ -35,7 +35,8 @@ class MessagesModel : public QSqlTableModel {
|
|||
|
||||
// Model implementation.
|
||||
bool setData(const QModelIndex &idx, const QVariant &value, int role = Qt::EditRole);
|
||||
QVariant data(const QModelIndex &idx, int role) const;
|
||||
QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const;
|
||||
QVariant data(int row, int column, int role = Qt::DisplayRole) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &idx) const;
|
||||
|
||||
|
@ -43,12 +44,17 @@ class MessagesModel : public QSqlTableModel {
|
|||
// Sets up all icons which are used directly by this model.
|
||||
void setupIcons();
|
||||
|
||||
// Returns const reference to message at given index.
|
||||
// Returns message at given index.
|
||||
Message messageAt(int row_index) const;
|
||||
|
||||
public slots:
|
||||
// Message manipulators.
|
||||
bool switchMessageImportance(int row_index);
|
||||
bool setMessageDeleted(int row_index, int deleted);
|
||||
bool setMessageRead(int row_index, int read);
|
||||
|
||||
// Fetches ALL available data to the model.
|
||||
// NOTE: This is almost needed when sorting
|
||||
// NOTE: This is almost always needed when sorting
|
||||
// and makes the model more predictable.
|
||||
void fetchAll();
|
||||
|
||||
|
@ -63,6 +69,7 @@ class MessagesModel : public QSqlTableModel {
|
|||
void setupFonts();
|
||||
|
||||
private:
|
||||
QList<int> m_currentFeeds;
|
||||
QList<QString> m_headerData;
|
||||
bool m_isInEditingMode;
|
||||
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
#include <QToolBar>
|
||||
#include <QApplication>
|
||||
#include <QLineEdit>
|
||||
#include <QAction>
|
||||
|
||||
#include "gui/feedmessageviewer.h"
|
||||
#include "gui/webbrowser.h"
|
||||
#include "gui/messagesview.h"
|
||||
#include "gui/feedsview.h"
|
||||
#include "core/messagesproxymodel.h"
|
||||
|
||||
|
||||
FeedMessageViewer::FeedMessageViewer(QWidget *parent)
|
||||
|
@ -31,7 +33,11 @@ void FeedMessageViewer::initialize() {
|
|||
m_toolBar->setMovable(false);
|
||||
m_toolBar->setAllowedAreas(Qt::TopToolBarArea);
|
||||
|
||||
// TODO: testovaci
|
||||
m_toolBar->addAction(QIcon::fromTheme("application-exit"), "aaa");
|
||||
QAction *ac = m_toolBar->actions().at(0);
|
||||
connect(ac, SIGNAL(triggered()),
|
||||
m_messagesView->model()->sourceModel(), SLOT(submitAll()));
|
||||
|
||||
// Finish web/message browser setup.
|
||||
m_messagesBrowser->setNavigationBarVisible(false);
|
||||
|
|
|
@ -89,7 +89,7 @@ void MessagesView::currentChanged(const QModelIndex ¤t,
|
|||
current.row(), current.column(),
|
||||
ind.row(), ind.column());
|
||||
|
||||
m_sourceModel->setData(m_sourceModel->index(ind.row(), 1), 1, Qt::EditRole);
|
||||
m_sourceModel->setMessageRead(ind.row(), 1);
|
||||
|
||||
emit currentMessageChanged(m_sourceModel->messageAt(ind.row()));
|
||||
|
||||
|
|
|
@ -22,6 +22,14 @@ class MessagesView : public QTreeView {
|
|||
MessagesProxyModel *model();
|
||||
MessagesModel *sourceModel();
|
||||
|
||||
public slots:
|
||||
// Message manipulators.
|
||||
// TODO: sem pridat metody jako
|
||||
// setSelectedMessagesRead....
|
||||
// setSelectedMessagesUnread.....
|
||||
// deleteSelectedMessages....
|
||||
// ......
|
||||
|
||||
protected:
|
||||
void setupAppearance();
|
||||
|
||||
|
@ -34,7 +42,6 @@ class MessagesView : public QTreeView {
|
|||
const QItemSelection &deselected);
|
||||
|
||||
signals:
|
||||
// TODO: dodělat signál.
|
||||
void currentMessageChanged(const Message &message);
|
||||
void currentMessageRemoved();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue