Many manyyyyyyyyyyy.
This commit is contained in:
parent
1c97bb852c
commit
81c30c504a
@ -9,7 +9,7 @@ set(APP_VERSION "2.0.0-prealpha-2")
|
|||||||
set(APP_AUTHOR "Martin Rotter")
|
set(APP_AUTHOR "Martin Rotter")
|
||||||
set(APP_URL "http://rssguard.sf.net")
|
set(APP_URL "http://rssguard.sf.net")
|
||||||
|
|
||||||
option(USE_QT_5 "Use Qt 5 for building" OFF)
|
option(USE_QT_5 "Use Qt 5 for building" ON)
|
||||||
|
|
||||||
message(STATUS "[${APP_LOW_NAME}] Welcome to ${APP_NAME} compilation process.")
|
message(STATUS "[${APP_LOW_NAME}] Welcome to ${APP_NAME} compilation process.")
|
||||||
message(STATUS "[${APP_LOW_NAME}] Compilation process begins right now.")
|
message(STATUS "[${APP_LOW_NAME}] Compilation process begins right now.")
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "qtsingleapplication/qtsingleapplication.h"
|
#include "qtsingleapplication/qtsingleapplication.h"
|
||||||
|
|
||||||
#include "core/defs.h"
|
#include "core/defs.h"
|
||||||
|
#include "core/datetime.h"
|
||||||
#include "core/messagesmodel.h"
|
#include "core/messagesmodel.h"
|
||||||
#include "core/databasefactory.h"
|
#include "core/databasefactory.h"
|
||||||
#include "gui/iconthemefactory.h"
|
#include "gui/iconthemefactory.h"
|
||||||
@ -43,13 +44,12 @@ void MessagesModel::fetchAll() {
|
|||||||
|
|
||||||
void MessagesModel::setupFonts() {
|
void MessagesModel::setupFonts() {
|
||||||
m_normalFont = QtSingleApplication::font("MessagesView");
|
m_normalFont = QtSingleApplication::font("MessagesView");
|
||||||
|
|
||||||
m_boldFont = m_normalFont;
|
m_boldFont = m_normalFont;
|
||||||
m_boldFont.setBold(true);
|
m_boldFont.setBold(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesModel::loadMessages(const QList<int> feed_ids) {
|
void MessagesModel::loadMessages(const QList<int> feed_ids) {
|
||||||
// TODO: Doplnit "AND deleted = 0"
|
|
||||||
|
|
||||||
// Conversion of parameter.
|
// Conversion of parameter.
|
||||||
QStringList stringy_ids;
|
QStringList stringy_ids;
|
||||||
stringy_ids.reserve(feed_ids.count());
|
stringy_ids.reserve(feed_ids.count());
|
||||||
@ -59,11 +59,24 @@ void MessagesModel::loadMessages(const QList<int> feed_ids) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: časem povolit.
|
// TODO: časem povolit.
|
||||||
//setFilter(QString("feed IN (%1) ").arg(stringy_ids.join(',')));
|
//setFilter(QString("feed IN (%1) AND deleted = 0").arg(stringy_ids.join(',')));
|
||||||
select();
|
select();
|
||||||
fetchAll();
|
fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Message MessagesModel::messageAt(int row_index) const {
|
||||||
|
QSqlRecord rec = record(row_index);
|
||||||
|
Message message;
|
||||||
|
|
||||||
|
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();
|
||||||
|
message.m_url = rec.value(MSG_DB_URL_INDEX).toString();
|
||||||
|
message.m_updated = DateTime::fromString(rec.value(MSG_DB_DUPDATED_INDEX).toString());
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
void MessagesModel::setupHeaderData() {
|
void MessagesModel::setupHeaderData() {
|
||||||
m_headerData << tr("Id") << tr("Read") << tr("Deleted") << tr("Important") <<
|
m_headerData << tr("Id") << tr("Read") << tr("Deleted") << tr("Important") <<
|
||||||
tr("Feed") << tr("Title") << tr("Url") << tr("Author") <<
|
tr("Feed") << tr("Title") << tr("Url") << tr("Author") <<
|
||||||
@ -84,7 +97,19 @@ Qt::ItemFlags MessagesModel::flags(const QModelIndex &idx) const {
|
|||||||
|
|
||||||
QVariant MessagesModel::data(const QModelIndex &idx, int role) const {
|
QVariant MessagesModel::data(const QModelIndex &idx, int role) const {
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
//
|
||||||
|
case Qt::DisplayRole: {
|
||||||
|
int index_column = idx.column();
|
||||||
|
if (index_column != MSG_DB_IMPORTANT_INDEX &&
|
||||||
|
index_column != MSG_DB_READ_INDEX) {
|
||||||
|
return QSqlTableModel::data(idx, role);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return RAW data for EditRole.
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return QSqlTableModel::data(idx, role);
|
return QSqlTableModel::data(idx, role);
|
||||||
|
|
||||||
@ -101,30 +126,19 @@ QVariant MessagesModel::data(const QModelIndex &idx, int role) const {
|
|||||||
m_readIcon :
|
m_readIcon :
|
||||||
m_unreadIcon;
|
m_unreadIcon;
|
||||||
}
|
}
|
||||||
|
else if (index_column == MSG_DB_IMPORTANT_INDEX) {
|
||||||
|
return record(idx.row()).value(MSG_DB_IMPORTANT_INDEX).toInt() == 1 ?
|
||||||
|
m_favoriteIcon :
|
||||||
|
QVariant();
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if (role == Qt::FontRole && idx.column() == 1) {
|
|
||||||
return record(idx.row()).value(1).toInt() == 1 ? m_normalFont : m_boldFont;
|
|
||||||
}
|
|
||||||
else if (role == Qt::DecorationRole && idx.column() == 3) {
|
|
||||||
if (record(idx.row()).value(1).toInt() == 1) {
|
|
||||||
return IconThemeFactory::getInstance()->fromTheme("mail-mark-read");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return IconThemeFactory::getInstance()->fromTheme("mail-mark-unread");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return QSqlTableModel::data(idx, role);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessagesModel::setData(const QModelIndex &idx, const QVariant &value, int role) {
|
bool MessagesModel::setData(const QModelIndex &idx, const QVariant &value, int role) {
|
||||||
|
@ -4,10 +4,27 @@
|
|||||||
#include <QSqlTableModel>
|
#include <QSqlTableModel>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
#include "core/defs.h"
|
#include "core/defs.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Represents single message.
|
||||||
|
// NOTE: This is primarily used for transfering data
|
||||||
|
// to WebBrowser responsible for displaying of messages.
|
||||||
|
class Message {
|
||||||
|
private:
|
||||||
|
QString m_title;
|
||||||
|
QString m_url;
|
||||||
|
QString m_author;
|
||||||
|
QString m_contents;
|
||||||
|
QDateTime m_updated;
|
||||||
|
|
||||||
|
friend class WebBrowser;
|
||||||
|
friend class MessagesModel;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class MessagesModel : public QSqlTableModel {
|
class MessagesModel : public QSqlTableModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -26,6 +43,9 @@ class MessagesModel : public QSqlTableModel {
|
|||||||
// Sets up all icons which are used directly by this model.
|
// Sets up all icons which are used directly by this model.
|
||||||
void setupIcons();
|
void setupIcons();
|
||||||
|
|
||||||
|
// Returns const reference to message at given index.
|
||||||
|
Message messageAt(int row_index) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Fetches ALL available data to the model.
|
// Fetches ALL available data to the model.
|
||||||
// NOTE: This is almost needed when sorting
|
// NOTE: This is almost needed when sorting
|
||||||
@ -48,6 +68,7 @@ class MessagesModel : public QSqlTableModel {
|
|||||||
|
|
||||||
QFont m_normalFont;
|
QFont m_normalFont;
|
||||||
QFont m_boldFont;
|
QFont m_boldFont;
|
||||||
|
|
||||||
QIcon m_favoriteIcon;
|
QIcon m_favoriteIcon;
|
||||||
QIcon m_readIcon;
|
QIcon m_readIcon;
|
||||||
QIcon m_unreadIcon;
|
QIcon m_unreadIcon;
|
||||||
|
@ -12,8 +12,28 @@ MessagesView::MessagesView(QWidget *parent) : QTreeView(parent) {
|
|||||||
|
|
||||||
setModel(m_proxyModel);
|
setModel(m_proxyModel);
|
||||||
|
|
||||||
hideColumn(0);
|
// Setup column resize strategies.
|
||||||
header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
|
header()->setSectionResizeMode(MSG_DB_ID_INDEX, QHeaderView::Interactive);
|
||||||
|
header()->setSectionResizeMode(MSG_DB_READ_INDEX, QHeaderView::ResizeToContents);
|
||||||
|
header()->setSectionResizeMode(MSG_DB_DELETED_INDEX, QHeaderView::Interactive);
|
||||||
|
header()->setSectionResizeMode(MSG_DB_IMPORTANT_INDEX, QHeaderView::ResizeToContents);
|
||||||
|
header()->setSectionResizeMode(MSG_DB_FEED_INDEX, QHeaderView::Interactive);
|
||||||
|
header()->setSectionResizeMode(MSG_DB_TITLE_INDEX, QHeaderView::Stretch);
|
||||||
|
header()->setSectionResizeMode(MSG_DB_URL_INDEX, QHeaderView::Interactive);
|
||||||
|
header()->setSectionResizeMode(MSG_DB_AUTHOR_INDEX, QHeaderView::Interactive);
|
||||||
|
header()->setSectionResizeMode(MSG_DB_DCREATED_INDEX, QHeaderView::Interactive);
|
||||||
|
header()->setSectionResizeMode(MSG_DB_DUPDATED_INDEX, QHeaderView::Interactive);
|
||||||
|
header()->setSectionResizeMode(MSG_DB_CONTENTS_INDEX, QHeaderView::Interactive);
|
||||||
|
|
||||||
|
// Hide columns.
|
||||||
|
hideColumn(MSG_DB_ID_INDEX);
|
||||||
|
hideColumn(MSG_DB_DELETED_INDEX);
|
||||||
|
hideColumn(MSG_DB_FEED_INDEX);
|
||||||
|
hideColumn(MSG_DB_URL_INDEX);
|
||||||
|
hideColumn(MSG_DB_CONTENTS_INDEX);
|
||||||
|
|
||||||
|
|
||||||
|
//hideColumn(0);
|
||||||
|
|
||||||
// NOTE: It is recommended to call this after the model is set
|
// NOTE: It is recommended to call this after the model is set
|
||||||
// due to sorting performance.
|
// due to sorting performance.
|
||||||
@ -32,9 +52,13 @@ MessagesProxyModel *MessagesView::model() {
|
|||||||
return m_proxyModel;
|
return m_proxyModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesView::setupAppearance() {
|
void MessagesView::setSortingEnabled(bool enable) {
|
||||||
header()->setStretchLastSection(true);
|
QTreeView::setSortingEnabled(enable);
|
||||||
|
header()->setSortIndicatorShown(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessagesView::setupAppearance() {
|
||||||
|
header()->setStretchLastSection(false);
|
||||||
setUniformRowHeights(true);
|
setUniformRowHeights(true);
|
||||||
setAcceptDrops(false);
|
setAcceptDrops(false);
|
||||||
setDragEnabled(false);
|
setDragEnabled(false);
|
||||||
@ -67,5 +91,7 @@ void MessagesView::currentChanged(const QModelIndex ¤t,
|
|||||||
|
|
||||||
m_sourceModel->setData(m_sourceModel->index(ind.row(), 1), 1, Qt::EditRole);
|
m_sourceModel->setData(m_sourceModel->index(ind.row(), 1), 1, Qt::EditRole);
|
||||||
|
|
||||||
|
emit currentMessageChanged(m_sourceModel->messageAt(ind.row()));
|
||||||
|
|
||||||
QTreeView::currentChanged(current, previous);
|
QTreeView::currentChanged(current, previous);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ class MessagesView : public QTreeView {
|
|||||||
explicit MessagesView(QWidget *parent = 0);
|
explicit MessagesView(QWidget *parent = 0);
|
||||||
virtual ~MessagesView();
|
virtual ~MessagesView();
|
||||||
|
|
||||||
|
void setSortingEnabled(bool enable);
|
||||||
|
|
||||||
// Model accessors.
|
// Model accessors.
|
||||||
MessagesProxyModel *model();
|
MessagesProxyModel *model();
|
||||||
MessagesModel *sourceModel();
|
MessagesModel *sourceModel();
|
||||||
@ -33,13 +35,12 @@ class MessagesView : public QTreeView {
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
// TODO: dodělat signál.
|
// TODO: dodělat signál.
|
||||||
void currentMessageChanged(/* const Message &message */);
|
void currentMessageChanged(const Message &message);
|
||||||
void currentMessageRemoved();
|
void currentMessageRemoved();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MessagesProxyModel *m_proxyModel;
|
MessagesProxyModel *m_proxyModel;
|
||||||
MessagesModel *m_sourceModel;
|
MessagesModel *m_sourceModel;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGESVIEW_H
|
#endif // MESSAGESVIEW_H
|
||||||
|
@ -167,21 +167,13 @@ void WebBrowser::navigateToUrl(const QUrl &url) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebBrowser::navigateToMessage() {
|
void WebBrowser::navigateToMessage(const Message &message) {
|
||||||
// TODO: dodělat.
|
// TODO: dodělat.
|
||||||
/*
|
m_webView->setHtml(SkinFactory::getInstance()->getCurrentMarkup().arg(message.m_title,
|
||||||
m_webView->setHtml(SkinFactory::getInstance()->getCurrentMarkup().arg(message.m_data.at(MSG_DB_TITLE_INDEX).toString(),
|
tr("Written by ") + message.m_author,
|
||||||
tr("Check your internet connection or website address"),
|
message.m_url,
|
||||||
QString(),
|
message.m_contents,
|
||||||
tr("This failure can be caused by:<br><ul>"
|
message.m_updated.toString(Qt::ISODate)));
|
||||||
"<li>non-functional internet connection,</li>"
|
|
||||||
"<li>incorrect website address,</li>"
|
|
||||||
"<li>bad proxy server settings,</li>"
|
|
||||||
"<li>target destination outage,</li>"
|
|
||||||
"<li>many other things.</li>"
|
|
||||||
"</ul>"),
|
|
||||||
"aa"));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebBrowser::updateZoomGui() {
|
void WebBrowser::updateZoomGui() {
|
||||||
|
@ -61,7 +61,7 @@ class WebBrowser : public TabContent {
|
|||||||
void navigateToUrl(const QUrl &url);
|
void navigateToUrl(const QUrl &url);
|
||||||
|
|
||||||
// Navigates to message.
|
// Navigates to message.
|
||||||
void navigateToMessage();
|
void navigateToMessage(const Message &message);
|
||||||
|
|
||||||
// Zoom manipulators.
|
// Zoom manipulators.
|
||||||
void increaseZoom();
|
void increaseZoom();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user