Finalized uncrustify config, will reformat it all.
This commit is contained in:
parent
7b62a456a6
commit
dd4a96f51f
@ -3,6 +3,10 @@
|
||||
set FOR foreach
|
||||
set FOR forever
|
||||
|
||||
# SIGNAL/SLOT Qt macros have special formatting options. See options_for_QT.cpp for details.
|
||||
# Default=True
|
||||
use_options_overriding_for_qt_macros = true # false/true
|
||||
|
||||
## General.
|
||||
|
||||
newlines = auto # auto/lf/crlf/cr
|
||||
@ -13,10 +17,270 @@ input_tab_size = 2 # number
|
||||
# The size of tabs in the output (only used if align_with_tabs=true)
|
||||
output_tab_size = 2 # number
|
||||
|
||||
# Control what to do with the UTF-8 BOM (recommend 'remove')
|
||||
utf8_bom = remove # ignore/add/remove/force
|
||||
|
||||
## Spaces.
|
||||
|
||||
# Add or remove space around arithmetic operator '+', '-', '/', '*', etc
|
||||
# also '>>>' '<<' '>>' '%' '|'
|
||||
sp_arith = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove space around assignment operator '=', '+=', etc
|
||||
sp_assign = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove space after ','
|
||||
sp_after_comma = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove space around '=' in C++11 lambda capture specifications. Overrides sp_assign
|
||||
sp_cpp_lambda_assign = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove space after the capture specification in C++11 lambda.
|
||||
sp_cpp_lambda_paren = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove space around assignment operator '=' in a prototype
|
||||
sp_assign_default = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove space around assignment '=' in enum
|
||||
sp_enum_assign = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove space before pointer star '*'
|
||||
sp_before_ptr_star = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove space before pointer star '*' that isn't followed by a variable name
|
||||
# If set to 'ignore', sp_before_ptr_star is used instead.
|
||||
sp_before_unnamed_ptr_star = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove space between pointer stars '*'
|
||||
sp_between_ptr_star = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove space after pointer star '*', if followed by a word.
|
||||
sp_after_ptr_star = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove space after pointer star '*', if followed by a qualifier.
|
||||
sp_after_ptr_star_qualifier = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove space after a pointer star '*', if followed by a func proto/def.
|
||||
sp_after_ptr_star_func = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove space after a pointer star '*', if followed by an open paren (function types).
|
||||
sp_ptr_star_paren = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove space before a pointer star '*', if followed by a func proto/def.
|
||||
sp_before_ptr_star_func = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove space before a reference sign '&'
|
||||
sp_before_byref = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove space before a reference sign '&' that isn't followed by a variable name
|
||||
# If set to 'ignore', sp_before_byref is used instead.
|
||||
sp_before_unnamed_byref = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove space after reference sign '&', if followed by a word.
|
||||
sp_after_byref = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove space after a reference sign '&', if followed by a func proto/def.
|
||||
sp_after_byref_func = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove space before a reference sign '&', if followed by a func proto/def.
|
||||
sp_before_byref_func = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove space between '>' and '>' in '>>' (template stuff C++/C# only). Default=Add
|
||||
sp_angle_shift = remove # ignore/add/remove/force
|
||||
|
||||
# Permit removal of the space between '>>' in 'foo<bar<int> >' (C++11 only). Default=False
|
||||
# sp_angle_shift cannot remove the space without this option.
|
||||
sp_permit_cpp11_shift = true # false/true
|
||||
|
||||
## Indents.
|
||||
|
||||
# The number of columns to indent per level.
|
||||
# Usually 2, 3, 4, or 8. Default=8
|
||||
indent_columns = 2 # unsigned number
|
||||
|
||||
# How to use tabs when indenting code
|
||||
# 0=spaces only
|
||||
# 1=indent with tabs to brace level, align with spaces (default)
|
||||
# 2=indent and align with tabs, using spaces when not on a tabstop
|
||||
indent_with_tabs = 0 # number
|
||||
|
||||
# Whether to indent strings broken by '\' so that they line up
|
||||
indent_align_string = true # false/true
|
||||
|
||||
# Whether the 'namespace' body is indented
|
||||
indent_namespace = true # false/true
|
||||
|
||||
# Whether the 'class' body is indented
|
||||
indent_class = true # false/true
|
||||
|
||||
# Same as indent_label, but for access specifiers that are followed by a colon. Default=1
|
||||
indent_access_spec = 2 # number
|
||||
|
||||
# Indent the code after an access specifier by one level.
|
||||
# If set, this option forces 'indent_access_spec=0'
|
||||
indent_access_spec_body = true # false/true
|
||||
|
||||
# Spaces to indent 'case' from 'switch'
|
||||
# Usually 0 or indent_columns.
|
||||
indent_switch_case = 2 # unsigned number
|
||||
|
||||
# indent the continuation of ternary operator.
|
||||
# 0: (Default) off
|
||||
# 1: When the `if_false` is a continuation, indent it under `if_false`
|
||||
# 2: When the `:` is a continuation, indent it under `?`
|
||||
indent_ternary_operator = 2 # unsigned number
|
||||
|
||||
## Newlines.
|
||||
|
||||
# Whether to collapse empty blocks between '{' and '}'
|
||||
nl_collapse_empty_body = true # false/true
|
||||
|
||||
# Add or remove newlines at the start of the file
|
||||
nl_start_of_file = remove # ignore/add/remove/force
|
||||
|
||||
# The number of blank lines after a block of variable definitions at the top of a function body
|
||||
# 0 = No change (default)
|
||||
nl_func_var_def_blk = 1 # unsigned number
|
||||
|
||||
# The number of newlines before a block of typedefs
|
||||
# 0 = No change (default)
|
||||
# the option 'nl_after_access_spec' takes preference over 'nl_typedef_blk_start'
|
||||
nl_typedef_blk_start = 2 # unsigned number
|
||||
|
||||
# The number of newlines after a block of typedefs
|
||||
# 0 = No change (default)
|
||||
nl_typedef_blk_end = 2 # unsigned number
|
||||
|
||||
# The maximum consecutive newlines within a block of typedefs
|
||||
# 0 = No change (default)
|
||||
nl_typedef_blk_in = 2 # unsigned number
|
||||
|
||||
# The number of newlines after a block of variable definitions not at the top of a function body
|
||||
# 0 = No change (default)
|
||||
nl_var_def_blk_end = 2 # unsigned number
|
||||
|
||||
# The maximum consecutive newlines within a block of variable definitions
|
||||
# 0 = No change (default)
|
||||
nl_var_def_blk_in = 1 # unsigned number
|
||||
|
||||
# Add or remove newline between 'enum' and '{'
|
||||
nl_enum_brace = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove newline between 'enum' and 'class'
|
||||
nl_enum_class = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove newline between 'enum class' and the identifier
|
||||
nl_enum_class_identifier = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove newline between 'if' and '{'
|
||||
nl_if_brace = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove newline between '}' and 'else'
|
||||
nl_brace_else = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove newline between 'else' and '{'
|
||||
nl_else_brace = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove newline between 'else' and 'if'
|
||||
nl_else_if = remove # ignore/add/remove/force
|
||||
|
||||
# Add or remove newline before 'if'/'else if' closing parenthesis
|
||||
nl_before_if_closing_paren = remove # ignore/add/remove/force
|
||||
|
||||
# Whether to put a newline after 'case' statement
|
||||
nl_after_case = false # false/true
|
||||
|
||||
# Whether to put a newline before 'case' statement, not after the first 'case'
|
||||
nl_before_case = true # false/true
|
||||
|
||||
# Whether to remove blanks after '#ifxx' and '#elxx', or before '#elxx' and '#endif'. Does not affect top-level #ifdefs.
|
||||
nl_squeeze_ifdef = true # false/true
|
||||
|
||||
# Add or remove blank line after 'if' statement.
|
||||
# Add/Force work only if the next token is not a closing brace
|
||||
nl_after_if = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove blank line after 'for' statement
|
||||
nl_after_for = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove blank line after 'while' statement
|
||||
nl_after_while = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove blank line after 'switch' statement
|
||||
nl_after_switch = force # ignore/add/remove/force
|
||||
|
||||
# Add or remove blank line after 'do/while' statement
|
||||
nl_after_do = force # ignore/add/remove/force
|
||||
|
||||
## Blank line options
|
||||
|
||||
# The maximum consecutive newlines (3 = 2 blank lines)
|
||||
nl_max = 2 # unsigned number
|
||||
|
||||
# The minimum number of newlines before a multi-line comment.
|
||||
# Doesn't apply if after a brace open or another multi-line comment.
|
||||
nl_before_block_comment = 2 # unsigned number
|
||||
|
||||
# The minimum number of newlines before a single-line C comment.
|
||||
# Doesn't apply if after a brace open or other single-line C comments.
|
||||
nl_before_c_comment = 2 # unsigned number
|
||||
|
||||
# The minimum number of newlines before a CPP comment.
|
||||
# Doesn't apply if after a brace open or other CPP comments.
|
||||
nl_before_cpp_comment = 2 # unsigned number
|
||||
|
||||
# The number of newlines before a class definition
|
||||
nl_before_class = 2 # unsigned number
|
||||
|
||||
# The number of newlines after '}' or ';' of a class definition
|
||||
nl_after_class = 2 # unsigned number
|
||||
|
||||
# The number of newlines after '}' of a multi-line function body
|
||||
nl_after_func_body = 2 # unsigned number
|
||||
|
||||
# The number of newlines after '}' of a multi-line function body in a class declaration
|
||||
nl_after_func_body_class = 2 # unsigned number
|
||||
|
||||
# The number of newlines after '}' of a single line function body
|
||||
nl_after_func_body_one_liner = 2 # unsigned number
|
||||
|
||||
# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label.
|
||||
# Will not change the newline count if after a brace open.
|
||||
# 0 = No change.
|
||||
nl_before_access_spec = 2 # unsigned number
|
||||
|
||||
# The number of newlines after a try-catch-finally block that isn't followed by a brace close.
|
||||
# 0 = No change.
|
||||
nl_after_try_catch_finally = 2 # unsigned number
|
||||
|
||||
# How aggressively to remove extra newlines not in preproc.
|
||||
# 0: No change
|
||||
# 1: Remove most newlines not handled by other config
|
||||
# 2: Remove all newlines and reformat completely by config
|
||||
nl_remove_extra_newlines = 0 # unsigned number
|
||||
|
||||
## Splitting.
|
||||
|
||||
# Try to limit code width to N number of columns
|
||||
code_width = 140 # unsigned number
|
||||
|
||||
# Whether to fully split long function protos/calls at commas
|
||||
ls_func_split_full = true # false/true
|
||||
|
||||
## Comments.
|
||||
|
||||
# Set the comment reflow mode (Default=0)
|
||||
# 0: no reflowing (apart from the line wrapping due to cmt_width)
|
||||
# 1: no touching at all
|
||||
# 2: full reflow
|
||||
cmt_reflow_mode = 2 # number
|
||||
|
||||
# Whether to convert all tabs to spaces in comments. Default is to leave tabs inside comments alone, unless used for indenting.
|
||||
cmt_convert_tab_to_spaces = true # false/true
|
||||
|
||||
# Whether to group c-comments that look like they are in a block
|
||||
cmt_c_group = true # false/true
|
||||
|
||||
## Modifications.
|
||||
|
||||
# If True, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C]
|
||||
|
@ -1,4 +1,5 @@
|
||||
// This file is part of RSS Guard.
|
||||
|
||||
//
|
||||
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
@ -18,45 +19,50 @@
|
||||
#include "core/feedsmodel.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "services/abstract/feed.h"
|
||||
#include "miscellaneous/databasefactory.h"
|
||||
#include "miscellaneous/feedreader.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "miscellaneous/textfactory.h"
|
||||
#include "services/abstract/category.h"
|
||||
#include "services/abstract/serviceroot.h"
|
||||
#include "services/abstract/feed.h"
|
||||
#include "services/abstract/recyclebin.h"
|
||||
#include "services/abstract/serviceentrypoint.h"
|
||||
#include "services/abstract/serviceroot.h"
|
||||
#include "services/standard/standardserviceentrypoint.h"
|
||||
#include "services/standard/standardserviceroot.h"
|
||||
#include "miscellaneous/textfactory.h"
|
||||
#include "miscellaneous/databasefactory.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "miscellaneous/feedreader.h"
|
||||
|
||||
#include <QMimeData>
|
||||
#include <QPair>
|
||||
#include <QSqlError>
|
||||
#include <QSqlRecord>
|
||||
#include <QPair>
|
||||
#include <QStack>
|
||||
#include <QMimeData>
|
||||
#include <QTimer>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
FeedsModel::FeedsModel(QObject* parent) : QAbstractItemModel(parent) {
|
||||
setObjectName(QSL("FeedsModel"));
|
||||
|
||||
// Create root item.
|
||||
m_rootItem = new RootItem();
|
||||
|
||||
// : Name of root item of feed list which can be seen in feed add/edit dialog.
|
||||
m_rootItem->setTitle(tr("Root"));
|
||||
m_rootItem->setIcon(qApp->icons()->fromTheme(QSL("folder")));
|
||||
|
||||
// Setup icons.
|
||||
m_countsIcon = qApp->icons()->fromTheme(QSL("mail-mark-unread"));
|
||||
|
||||
// : Title text in the feed list header.
|
||||
m_headerData << tr("Title");
|
||||
m_tooltipData << /*: Feed list header "titles" column tooltip.*/ tr("Titles of feeds/categories.")
|
||||
<< /*: Feed list header "counts" column tooltip.*/ tr("Counts of unread/all mesages.");
|
||||
m_tooltipData << /*: Feed list header "titles" column tooltip.*/ tr("Titles of feeds/categories.") <<
|
||||
|
||||
/*: Feed list header "counts" column tooltip.*/ tr("Counts of unread/all mesages.");
|
||||
}
|
||||
|
||||
FeedsModel::~FeedsModel() {
|
||||
qDebug("Destroying FeedsModel instance.");
|
||||
|
||||
// Delete all model items.
|
||||
delete m_rootItem;
|
||||
}
|
||||
@ -79,6 +85,7 @@ QMimeData* FeedsModel::mimeData(const QModelIndexList& indexes) const {
|
||||
}
|
||||
|
||||
mime_data->setData(QSL(MIME_TYPE_ITEM_POINTER), encoded_data);
|
||||
|
||||
return mime_data;
|
||||
}
|
||||
|
||||
@ -86,7 +93,8 @@ QStringList FeedsModel::mimeTypes() const {
|
||||
return QStringList() << QSL(MIME_TYPE_ITEM_POINTER);
|
||||
}
|
||||
|
||||
bool FeedsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) {
|
||||
bool FeedsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) {
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
|
||||
@ -106,8 +114,8 @@ bool FeedsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int
|
||||
QDataStream stream(&dragged_items_data, QIODevice::ReadOnly);
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
quintptr pointer_to_item;
|
||||
stream >> pointer_to_item;
|
||||
quintptr pointer_to_item; stream >> pointer_to_item;
|
||||
|
||||
// We have item we want to drag, we also determine the target item.
|
||||
RootItem* dragged_item = (RootItem*) pointer_to_item;
|
||||
RootItem* target_item = itemForIndex(parent);
|
||||
@ -148,9 +156,11 @@ Qt::DropActions FeedsModel::supportedDropActions() const {
|
||||
}
|
||||
|
||||
Qt::ItemFlags FeedsModel::flags(const QModelIndex& index) const {
|
||||
Qt::ItemFlags base_flags = QAbstractItemModel::flags(index);
|
||||
const RootItem* item_for_index = itemForIndex(index);
|
||||
|
||||
Qt::ItemFlags base_flags = QAbstractItemModel::flags(index);
|
||||
Qt::ItemFlags additional_flags = item_for_index->additionalFlags();
|
||||
|
||||
return base_flags | additional_flags;
|
||||
}
|
||||
|
||||
@ -244,6 +254,7 @@ void FeedsModel::removeItem(const QModelIndex& index) {
|
||||
RootItem* deleting_item = itemForIndex(index);
|
||||
QModelIndex parent_index = index.parent();
|
||||
RootItem* parent_item = deleting_item->parent();
|
||||
|
||||
beginRemoveRows(parent_index, index.row(), index.row());
|
||||
parent_item->removeChild(deleting_item);
|
||||
endRemoveRows();
|
||||
@ -257,6 +268,7 @@ void FeedsModel::removeItem(RootItem* deleting_item) {
|
||||
QModelIndex index = indexForItem(deleting_item);
|
||||
QModelIndex parent_index = index.parent();
|
||||
RootItem* parent_item = deleting_item->parent();
|
||||
|
||||
beginRemoveRows(parent_index, index.row(), index.row());
|
||||
parent_item->removeChild(deleting_item);
|
||||
endRemoveRows();
|
||||
@ -281,6 +293,7 @@ void FeedsModel::reassignNodeToNewParent(RootItem* original_node, RootItem* new_
|
||||
}
|
||||
|
||||
int new_index_of_item = new_parent->childCount();
|
||||
|
||||
// ... and insert it under the new parent.
|
||||
beginInsertRows(indexForItem(new_parent), new_index_of_item, new_index_of_item);
|
||||
new_parent->appendChild(original_node);
|
||||
@ -328,10 +341,12 @@ QList<Feed*>FeedsModel::feedsForScheduledUpdate(bool auto_update_now) {
|
||||
foreach (Feed* feed, m_rootItem->getSubTreeFeeds()) {
|
||||
switch (feed->autoUpdateType()) {
|
||||
case Feed::DontAutoUpdate:
|
||||
|
||||
// Do not auto-update this feed ever.
|
||||
continue;
|
||||
|
||||
case Feed::DefaultAutoUpdate:
|
||||
|
||||
if (auto_update_now) {
|
||||
feeds_for_update.append(feed);
|
||||
}
|
||||
@ -366,8 +381,7 @@ QList<Message>FeedsModel::messagesForItem(RootItem* item) const {
|
||||
}
|
||||
|
||||
int FeedsModel::columnCount(const QModelIndex& parent) const {
|
||||
Q_UNUSED(parent)
|
||||
return FEEDS_VIEW_COLUMN_COUNT;
|
||||
Q_UNUSED(parent) return FEEDS_VIEW_COLUMN_COUNT;
|
||||
}
|
||||
|
||||
RootItem* FeedsModel::itemForIndex(const QModelIndex& index) const {
|
||||
@ -381,6 +395,7 @@ RootItem* FeedsModel::itemForIndex(const QModelIndex& index) const {
|
||||
|
||||
QModelIndex FeedsModel::indexForItem(const RootItem* item) const {
|
||||
if (item == nullptr || item->kind() == RootItemKind::Root) {
|
||||
|
||||
// Root item lies on invalid index.
|
||||
return QModelIndex();
|
||||
}
|
||||
@ -398,7 +413,10 @@ QModelIndex FeedsModel::indexForItem(const RootItem* item) const {
|
||||
// We go through the stack and create our target index.
|
||||
while (!chain.isEmpty()) {
|
||||
const RootItem* parent_item = chain.pop();
|
||||
target_index = index(parent_item->parent()->childItems().indexOf(const_cast<RootItem* const>(parent_item)), 0, target_index);
|
||||
|
||||
target_index = index(parent_item->parent()->childItems().indexOf(const_cast<RootItem* const>(parent_item)),
|
||||
0,
|
||||
target_index);
|
||||
}
|
||||
|
||||
return target_index;
|
||||
@ -424,16 +442,17 @@ void FeedsModel::reloadChangedLayout(QModelIndexList list) {
|
||||
|
||||
if (indx.isValid()) {
|
||||
QModelIndex indx_parent = indx.parent();
|
||||
|
||||
// Underlying data are changed.
|
||||
emit dataChanged(index(indx.row(), 0, indx_parent), index(indx.row(), FDS_MODEL_COUNTS_INDEX, indx_parent));
|
||||
|
||||
list.append(indx_parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FeedsModel::reloadChangedItem(RootItem* item) {
|
||||
QModelIndex index_item = indexForItem(item);
|
||||
reloadChangedLayout(QModelIndexList() << index_item);
|
||||
reloadChangedLayout(QModelIndexList() << indexForItem(item));
|
||||
}
|
||||
|
||||
void FeedsModel::notifyWithCounts() {
|
||||
@ -463,9 +482,11 @@ void FeedsModel::reloadWholeLayout() {
|
||||
|
||||
bool FeedsModel::addServiceAccount(ServiceRoot* root, bool freshly_activated) {
|
||||
int new_row_index = m_rootItem->childCount();
|
||||
|
||||
beginInsertRows(indexForItem(m_rootItem), new_row_index, new_row_index);
|
||||
m_rootItem->appendChild(root);
|
||||
endInsertRows();
|
||||
|
||||
// Connect.
|
||||
connect(root, &ServiceRoot::itemRemovalRequested, this, static_cast<void (FeedsModel::*)(RootItem*)>(&FeedsModel::removeItem));
|
||||
connect(root, &ServiceRoot::itemReassignmentRequested, this, &FeedsModel::reassignNodeToNewParent);
|
||||
@ -474,6 +495,7 @@ bool FeedsModel::addServiceAccount(ServiceRoot* root, bool freshly_activated) {
|
||||
connect(root, &ServiceRoot::itemExpandRequested, this, &FeedsModel::itemExpandRequested);
|
||||
connect(root, &ServiceRoot::itemExpandStateSaveRequested, this, &FeedsModel::itemExpandStateSaveRequested);
|
||||
root->start(freshly_activated);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// This file is part of RSS Guard.
|
||||
|
||||
//
|
||||
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
@ -20,7 +21,6 @@
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
#include "core/message.h"
|
||||
#include "services/abstract/rootitem.h"
|
||||
|
||||
class Category;
|
||||
@ -33,7 +33,6 @@ class FeedsModel : public QAbstractItemModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit FeedsModel(QObject* parent = 0);
|
||||
virtual ~FeedsModel();
|
||||
|
||||
@ -45,6 +44,7 @@ class FeedsModel : public QAbstractItemModel {
|
||||
|
||||
// Drag & drop.
|
||||
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
||||
|
||||
QStringList mimeTypes() const;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
|
||||
Qt::DropActions supportedDropActions() const;
|
||||
@ -106,7 +106,6 @@ class FeedsModel : public QAbstractItemModel {
|
||||
RootItem* rootItem() const;
|
||||
|
||||
public slots:
|
||||
// Loads feed/categories from the database.
|
||||
void loadActivatedServiceAccounts();
|
||||
|
||||
// Stops all accounts before exit.
|
||||
@ -155,7 +154,6 @@ class FeedsModel : public QAbstractItemModel {
|
||||
void onItemDataChanged(const QList<RootItem*>& items);
|
||||
|
||||
signals:
|
||||
// Emitted if counts of messages are changed.
|
||||
void messageCountsChanged(int unread_messages, bool any_feed_has_unread_messages);
|
||||
|
||||
// Emitted if any item requested that any view should expand it.
|
||||
@ -174,6 +172,7 @@ class FeedsModel : public QAbstractItemModel {
|
||||
|
||||
private:
|
||||
RootItem* m_rootItem;
|
||||
|
||||
QList<QString> m_headerData;
|
||||
QList<QString> m_tooltipData;
|
||||
QIcon m_countsIcon;
|
||||
|
@ -220,7 +220,6 @@
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
|
||||
#define APP_DESKTOP_SOURCE_ENTRY_FILE "rssguard.desktop.autostart"
|
||||
#define APP_DESKTOP_ENTRY_FILE "rssguard.desktop"
|
||||
|
||||
@ -233,9 +232,7 @@
|
||||
#define APP_ICON_PATH QApplication::applicationDirPath() + QString("/../share/pixmaps/rssguard.png")
|
||||
#define APP_ICON_PLAIN_PATH QApplication::applicationDirPath() + QString("/../share/rssguard/icons/rssguard_plain.png")
|
||||
#define APP_INITIAL_FEEDS_PATH QApplication::applicationDirPath() + QString("/../share/rssguard/initial_feeds")
|
||||
|
||||
#elif defined(Q_OS_OSX)
|
||||
|
||||
#define APP_LANG_PATH QApplication::applicationDirPath() + QString("/../Resources/translations")
|
||||
#define APP_SKIN_PATH QApplication::applicationDirPath() + QString("/../Resources/skins")
|
||||
#define APP_INFO_PATH QApplication::applicationDirPath() + QString("/../Resources/information")
|
||||
@ -245,9 +242,7 @@
|
||||
#define APP_INFO_PATH QApplication::applicationDirPath() + QString("/../Resources/information")
|
||||
#define APP_ICON_PLAIN_PATH QApplication::applicationDirPath() + QString("/../Resources/icons/rssguard_plain.png")
|
||||
#define APP_INITIAL_FEEDS_PATH QApplication::applicationDirPath() + QString("/../Resources/initial_feeds")
|
||||
|
||||
#elif defined(Q_OS_WIN)
|
||||
|
||||
#define APP_LANG_PATH QApplication::applicationDirPath() + QString("/translations")
|
||||
#define APP_SKIN_PATH QApplication::applicationDirPath() + QString("/skins")
|
||||
#define APP_INFO_PATH QApplication::applicationDirPath()
|
||||
@ -256,7 +251,6 @@
|
||||
#define APP_ICON_PATH QApplication::applicationDirPath() + QString("/rssguard.png")
|
||||
#define APP_ICON_PLAIN_PATH QApplication::applicationDirPath() + QString("/rssguard_plain.png")
|
||||
#define APP_INITIAL_FEEDS_PATH QApplication::applicationDirPath() + QString("/initial_feeds")
|
||||
|
||||
#endif
|
||||
|
||||
#endif // DEFINITIONS_H
|
||||
|
@ -1,4 +1,5 @@
|
||||
// This file is part of RSS Guard.
|
||||
|
||||
//
|
||||
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
@ -17,16 +18,15 @@
|
||||
|
||||
#include "gui/dialogs/formabout.h"
|
||||
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "miscellaneous/textfactory.h"
|
||||
#include "miscellaneous/settingsproperties.h"
|
||||
#include "gui/guiutilities.h"
|
||||
#include "exceptions/applicationexception.h"
|
||||
#include "gui/guiutilities.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "miscellaneous/settingsproperties.h"
|
||||
#include "miscellaneous/textfactory.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
|
||||
FormAbout::FormAbout(QWidget* parent) : QDialog(parent) {
|
||||
m_ui.setupUi(this);
|
||||
m_ui.m_lblIcon->setPixmap(QPixmap(APP_ICON_PATH));
|
||||
@ -47,9 +47,7 @@ void FormAbout::loadSettingsAndPaths() {
|
||||
m_ui.m_txtPathsSettingsType->setText(tr("NOT portable"));
|
||||
}
|
||||
|
||||
m_ui.m_txtPathsDatabaseRoot->setText(QDir::toNativeSeparators(qApp->userDataFolder() +
|
||||
QDir::separator() +
|
||||
QString(APP_DB_SQLITE_PATH)));
|
||||
m_ui.m_txtPathsDatabaseRoot->setText(QDir::toNativeSeparators(qApp->userDataFolder() + QDir::separator() + QString(APP_DB_SQLITE_PATH)));
|
||||
m_ui.m_txtPathsSettingsFile->setText(QDir::toNativeSeparators(qApp->settings()->fileName()));
|
||||
m_ui.m_txtPathsSkinsRoot->setText(QDir::toNativeSeparators(qApp->skins()->customSkinBaseFolder()));
|
||||
}
|
||||
@ -84,18 +82,12 @@ void FormAbout::loadLicenseAndInformation() {
|
||||
}
|
||||
|
||||
// Set other informative texts.
|
||||
m_ui.m_lblDesc->setText(tr("<b>%8</b><br>"
|
||||
"<b>Version:</b> %1 (built on %2/%3)<br>"
|
||||
"<b>Revision:</b> %4<br>"
|
||||
"<b>Build date:</b> %5<br>"
|
||||
"<b>Qt:</b> %6 (compiled against %7)<br>").arg(qApp->applicationVersion(),
|
||||
APP_SYSTEM_NAME,
|
||||
APP_SYSTEM_VERSION,
|
||||
APP_REVISION,
|
||||
TextFactory::parseDateTime(QString("%1 %2").arg(__DATE__,
|
||||
__TIME__)).toString(Qt::DefaultLocaleShortDate),
|
||||
qVersion(),
|
||||
QT_VERSION_STR,
|
||||
m_ui.m_lblDesc->setText(tr("<b>%8</b><br>" "<b>Version:</b> %1 (built on %2/%3)<br>" "<b>Revision:</b> %4<br>" "<b>Build date:</b> %5<br>"
|
||||
"<b>Qt:</b> %6 (compiled against %7)<br>").arg(
|
||||
qApp->applicationVersion(), APP_SYSTEM_NAME, APP_SYSTEM_VERSION, APP_REVISION,
|
||||
TextFactory
|
||||
::parseDateTime(QString("%1 %2").arg(__DATE__, __TIME__)).toString(Qt::DefaultLocaleShortDate),
|
||||
qVersion(), QT_VERSION_STR,
|
||||
APP_NAME));
|
||||
m_ui.m_txtInfo->setText(tr("<body>%5 is a (very) tiny feed reader."
|
||||
"<br><br>This software is distributed under the terms of GNU General Public License, version 3."
|
||||
@ -103,9 +95,8 @@ void FormAbout::loadLicenseAndInformation() {
|
||||
"<ul><li><a href=\"mailto://%1\">%1</a> ~e-mail</li>"
|
||||
"<li><a href=\"%2\">%2</a> ~website</li></ul>"
|
||||
"You can obtain source code for %5 from its website."
|
||||
"<br><br><br>Copyright (C) 2011-%3 %4</body>").arg(APP_EMAIL,
|
||||
APP_URL,
|
||||
QString::number(QDateTime::currentDateTime().date().year()),
|
||||
APP_AUTHOR,
|
||||
APP_NAME));
|
||||
"<br><br><br>Copyright (C) 2011-%3 %4</body>").arg(APP_EMAIL, APP_URL,
|
||||
QString
|
||||
::number(QDateTime::currentDateTime().date().year()),
|
||||
APP_AUTHOR, APP_NAME));
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
// This file is part of RSS Guard.
|
||||
|
||||
//
|
||||
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
@ -17,16 +18,15 @@
|
||||
|
||||
#include "gui/dialogs/formrestoredatabasesettings.h"
|
||||
|
||||
#include "gui/messagebox.h"
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "exceptions/applicationexception.h"
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "gui/messagebox.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
|
||||
#include "QFileDialog"
|
||||
|
||||
|
||||
FormRestoreDatabaseSettings::FormRestoreDatabaseSettings(QWidget& parent)
|
||||
: QDialog(&parent), m_shouldRestart(false) {
|
||||
FormRestoreDatabaseSettings::FormRestoreDatabaseSettings(QWidget& parent) : QDialog(&parent),
|
||||
m_shouldRestart(false) {
|
||||
m_ui.setupUi(this);
|
||||
m_btnRestart = m_ui.m_buttonBox->addButton(tr("Restart"), QDialogButtonBox::ActionRole);
|
||||
m_ui.m_lblResult->setStatus(WidgetWithStatus::Warning, tr("No operation executed yet."), tr("No operation executed yet."));
|
||||
@ -53,12 +53,10 @@ void FormRestoreDatabaseSettings::performRestoration() {
|
||||
try {
|
||||
qApp->restoreDatabaseSettings(m_ui.m_groupDatabase->isChecked(),
|
||||
m_ui.m_groupSettings->isChecked(),
|
||||
m_ui.m_listDatabase->currentRow() >= 0 ?
|
||||
m_ui.m_listDatabase->currentItem()->data(Qt::UserRole).toString() :
|
||||
QString(),
|
||||
m_ui.m_listSettings->currentRow() >= 0 ?
|
||||
m_ui.m_listSettings->currentItem()->data(Qt::UserRole).toString() :
|
||||
QString());
|
||||
m_ui.m_listDatabase->currentRow() >= 0 ? m_ui.m_listDatabase->currentItem()->data(
|
||||
Qt::UserRole).toString() : QString(),
|
||||
m_ui.m_listSettings->currentRow() >= 0 ? m_ui.m_listSettings->currentItem()->data(
|
||||
Qt::UserRole).toString() : QString());
|
||||
m_btnRestart->setEnabled(true);
|
||||
m_ui.m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Restoration was initiated. Restart to proceed."),
|
||||
tr("You need to restart application for restoration process to finish."));
|
||||
@ -88,35 +86,33 @@ void FormRestoreDatabaseSettings::selectFolder(QString folder) {
|
||||
}
|
||||
|
||||
if (!folder.isEmpty()) {
|
||||
m_ui.m_lblSelectFolder->setStatus(WidgetWithStatus::Ok, QDir::toNativeSeparators(folder),
|
||||
tr("Good source directory is specified."));
|
||||
m_ui.m_lblSelectFolder->setStatus(WidgetWithStatus::Ok, QDir::toNativeSeparators(folder), tr("Good source directory is specified."));
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
const QDir selected_folder(folder);
|
||||
const QFileInfoList available_databases = selected_folder.entryInfoList(QStringList()
|
||||
<< QString("*") + BACKUP_SUFFIX_DATABASE,
|
||||
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable |
|
||||
QDir::CaseSensitive | QDir::NoSymLinks,
|
||||
const QFileInfoList available_databases = selected_folder.entryInfoList(QStringList() << QString("*") + BACKUP_SUFFIX_DATABASE,
|
||||
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable | QDir::CaseSensitive | QDir::NoSymLinks,
|
||||
QDir::Name);
|
||||
const QFileInfoList available_settings = selected_folder.entryInfoList(QStringList()
|
||||
<< QString("*") + BACKUP_SUFFIX_SETTINGS,
|
||||
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable |
|
||||
QDir::CaseSensitive | QDir::NoSymLinks,
|
||||
const QFileInfoList available_settings = selected_folder.entryInfoList(QStringList() << QString("*") + BACKUP_SUFFIX_SETTINGS,
|
||||
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable | QDir::CaseSensitive | QDir::NoSymLinks,
|
||||
QDir::Name);
|
||||
|
||||
m_ui.m_listDatabase->clear();
|
||||
m_ui.m_listSettings->clear();
|
||||
|
||||
foreach (const QFileInfo& database_file, available_databases) {
|
||||
QListWidgetItem* database_item = new QListWidgetItem(database_file.fileName(), m_ui.m_listDatabase);
|
||||
|
||||
database_item->setData(Qt::UserRole, database_file.absoluteFilePath());
|
||||
database_item->setToolTip(QDir::toNativeSeparators(database_file.absoluteFilePath()));
|
||||
}
|
||||
|
||||
foreach (const QFileInfo& settings_file, available_settings) {
|
||||
QListWidgetItem* settings_item = new QListWidgetItem(settings_file.fileName(), m_ui.m_listSettings);
|
||||
|
||||
settings_item->setData(Qt::UserRole, settings_file.absoluteFilePath());
|
||||
settings_item->setToolTip(QDir::toNativeSeparators(settings_file.absoluteFilePath()));
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
// This file is part of RSS Guard.
|
||||
|
||||
//
|
||||
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
@ -17,30 +18,30 @@
|
||||
|
||||
#include "gui/feedmessageviewer.h"
|
||||
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "miscellaneous/databasefactory.h"
|
||||
#include "miscellaneous/systemfactory.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "miscellaneous/mutex.h"
|
||||
#include "miscellaneous/databasecleaner.h"
|
||||
#include "miscellaneous/feedreader.h"
|
||||
#include "core/messagesproxymodel.h"
|
||||
#include "core/feeddownloader.h"
|
||||
#include "core/feedsproxymodel.h"
|
||||
#include "services/standard/standardserviceroot.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
#include "services/standard/standardfeedsimportexportmodel.h"
|
||||
#include "gui/messagesview.h"
|
||||
#include "core/messagesproxymodel.h"
|
||||
#include "gui/feedstoolbar.h"
|
||||
#include "gui/feedsview.h"
|
||||
#include "gui/statusbar.h"
|
||||
#include "gui/systemtrayicon.h"
|
||||
#include "gui/messagebox.h"
|
||||
#include "gui/messagestoolbar.h"
|
||||
#include "gui/feedstoolbar.h"
|
||||
#include "gui/messagesview.h"
|
||||
#include "gui/statusbar.h"
|
||||
#include "gui/systemtrayicon.h"
|
||||
#include "miscellaneous/databasecleaner.h"
|
||||
#include "miscellaneous/databasefactory.h"
|
||||
#include "miscellaneous/feedreader.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "miscellaneous/mutex.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "miscellaneous/systemfactory.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
#include "services/standard/standardfeedsimportexportmodel.h"
|
||||
#include "services/standard/standardserviceroot.h"
|
||||
|
||||
#include "exceptions/applicationexception.h"
|
||||
#include "gui/dialogs/formdatabasecleanup.h"
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "exceptions/applicationexception.h"
|
||||
|
||||
#if defined(USE_WEBENGINE)
|
||||
#include "gui/webbrowser.h"
|
||||
@ -48,34 +49,30 @@
|
||||
#include "gui/messagepreviewer.h"
|
||||
#endif
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QSplitter>
|
||||
#include <QToolBar>
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
#include <QLineEdit>
|
||||
#include <QAction>
|
||||
#include <QToolButton>
|
||||
#include <QMenu>
|
||||
#include <QWidgetAction>
|
||||
#include <QThread>
|
||||
#include <QProgressBar>
|
||||
#include <QStatusBar>
|
||||
#include <QPointer>
|
||||
#include <QProgressBar>
|
||||
#include <QSplitter>
|
||||
#include <QStatusBar>
|
||||
#include <QThread>
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidgetAction>
|
||||
|
||||
FeedMessageViewer::FeedMessageViewer(QWidget* parent) : TabContent(parent), m_toolBarsEnabled(true), m_listHeadersEnabled(true),
|
||||
m_toolBarFeeds(new FeedsToolBar(tr("Toolbar for feeds"), this)), m_toolBarMessages(new MessagesToolBar(tr("Toolbar for messages"), this)),
|
||||
m_messagesView(new MessagesView(this)), m_feedsView(new FeedsView(this)),
|
||||
|
||||
FeedMessageViewer::FeedMessageViewer(QWidget* parent)
|
||||
: TabContent(parent),
|
||||
m_toolBarsEnabled(true),
|
||||
m_listHeadersEnabled(true),
|
||||
m_toolBarFeeds(new FeedsToolBar(tr("Toolbar for feeds"), this)),
|
||||
m_toolBarMessages(new MessagesToolBar(tr("Toolbar for messages"), this)),
|
||||
m_messagesView(new MessagesView(this)),
|
||||
m_feedsView(new FeedsView(this)),
|
||||
#if defined(USE_WEBENGINE)
|
||||
m_messagesBrowser(new WebBrowser(this)) {
|
||||
#else
|
||||
m_messagesBrowser(new MessagePreviewer(this)) {
|
||||
#endif
|
||||
|
||||
initialize();
|
||||
initializeViews();
|
||||
loadMessageViewerFonts();
|
||||
@ -87,9 +84,11 @@ FeedMessageViewer::~FeedMessageViewer() {
|
||||
}
|
||||
|
||||
#if defined(USE_WEBENGINE)
|
||||
|
||||
WebBrowser* FeedMessageViewer::webBrowser() const {
|
||||
return m_messagesBrowser;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
FeedsView* FeedMessageViewer::feedsView() const {
|
||||
@ -110,11 +109,14 @@ FeedsToolBar* FeedMessageViewer::feedsToolBar() const {
|
||||
|
||||
void FeedMessageViewer::saveSize() {
|
||||
Settings* settings = qApp->settings();
|
||||
|
||||
m_feedsView->saveAllExpandStates();
|
||||
|
||||
// Store offsets of splitters.
|
||||
settings->setValue(GROUP(GUI), GUI::SplitterFeeds, QString(m_feedSplitter->saveState().toBase64()));
|
||||
settings->setValue(GROUP(GUI), GUI::SplitterMessages, QString(m_messageSplitter->saveState().toBase64()));
|
||||
settings->setValue(GROUP(GUI), GUI::MessageViewState, QString(m_messagesView->header()->saveState().toBase64()));
|
||||
|
||||
// Store "visibility" of toolbars and list headers.
|
||||
settings->setValue(GROUP(GUI), GUI::ToolbarsVisible, m_toolBarsEnabled);
|
||||
settings->setValue(GROUP(GUI), GUI::ListHeadersVisible, m_listHeadersEnabled);
|
||||
@ -122,6 +124,7 @@ void FeedMessageViewer::saveSize() {
|
||||
|
||||
void FeedMessageViewer::loadSize() {
|
||||
const Settings* settings = qApp->settings();
|
||||
|
||||
// Restore offsets of splitters.
|
||||
m_feedSplitter->restoreState(QByteArray::fromBase64(settings->value(GROUP(GUI), SETTING(GUI::SplitterFeeds)).toString().toLocal8Bit()));
|
||||
m_messageSplitter->restoreState(QByteArray::fromBase64(settings->value(GROUP(GUI),
|
||||
@ -189,29 +192,27 @@ void FeedMessageViewer::createConnections() {
|
||||
// Filtering & searching.
|
||||
connect(m_toolBarMessages, &MessagesToolBar::messageSearchPatternChanged, m_messagesView, &MessagesView::searchMessages);
|
||||
connect(m_toolBarMessages, &MessagesToolBar::messageFilterChanged, m_messagesView, &MessagesView::filterMessages);
|
||||
|
||||
#if defined(USE_WEBENGINE)
|
||||
connect(m_messagesView, &MessagesView::currentMessageRemoved, m_messagesBrowser, &WebBrowser::clear);
|
||||
connect(m_messagesView, &MessagesView::currentMessageChanged, m_messagesBrowser, &WebBrowser::loadMessage);
|
||||
connect(m_messagesBrowser, &WebBrowser::markMessageRead,
|
||||
m_messagesView->sourceModel(), &MessagesModel::setMessageReadById);
|
||||
connect(m_messagesBrowser, &WebBrowser::markMessageImportant,
|
||||
m_messagesView->sourceModel(), &MessagesModel::setMessageImportantById);
|
||||
connect(m_messagesBrowser, &WebBrowser::markMessageRead, m_messagesView->sourceModel(), &MessagesModel::setMessageReadById);
|
||||
connect(m_messagesBrowser, &WebBrowser::markMessageImportant, m_messagesView->sourceModel(), &MessagesModel::setMessageImportantById);
|
||||
#else
|
||||
connect(m_messagesView, &MessagesView::currentMessageRemoved, m_messagesBrowser, &MessagePreviewer::clear);
|
||||
connect(m_messagesView, &MessagesView::currentMessageChanged, m_messagesBrowser, &MessagePreviewer::loadMessage);
|
||||
connect(m_messagesBrowser, &MessagePreviewer::markMessageRead,
|
||||
m_messagesView->sourceModel(), &MessagesModel::setMessageReadById);
|
||||
connect(m_messagesBrowser, &MessagePreviewer::markMessageImportant,
|
||||
m_messagesView->sourceModel(), &MessagesModel::setMessageImportantById);
|
||||
connect(m_messagesBrowser, &MessagePreviewer::markMessageRead, m_messagesView->sourceModel(), &MessagesModel::setMessageReadById);
|
||||
connect(m_messagesBrowser, &MessagePreviewer::markMessageImportant, m_messagesView->sourceModel(),
|
||||
&MessagesModel::setMessageImportantById);
|
||||
#endif
|
||||
|
||||
// If user selects feeds, load their messages.
|
||||
connect(m_feedsView, &FeedsView::itemSelected, m_messagesView, &MessagesView::loadItem);
|
||||
connect(m_feedsView, &FeedsView::requestViewNextUnreadMessage, m_messagesView, &MessagesView::selectNextUnreadItem);
|
||||
|
||||
// State of many messages is changed, then we need
|
||||
// to reload selections.
|
||||
connect(m_feedsView->sourceModel(), &FeedsModel::reloadMessageListRequested,
|
||||
m_messagesView, &MessagesView::reloadSelections);
|
||||
connect(m_feedsView->sourceModel(), &FeedsModel::reloadMessageListRequested, m_messagesView, &MessagesView::reloadSelections);
|
||||
}
|
||||
|
||||
void FeedMessageViewer::initialize() {
|
||||
@ -225,6 +226,7 @@ void FeedMessageViewer::initialize() {
|
||||
m_toolBarFeeds->loadSavedActions();
|
||||
m_toolBarMessages->loadSavedActions();
|
||||
m_messagesBrowser->clear();
|
||||
|
||||
// Now refresh visual setup.
|
||||
refreshVisualProperties();
|
||||
}
|
||||
@ -234,10 +236,12 @@ void FeedMessageViewer::initializeViews() {
|
||||
m_messagesWidget = new QWidget(this);
|
||||
m_feedSplitter = new QSplitter(Qt::Horizontal, this);
|
||||
m_messageSplitter = new QSplitter(Qt::Vertical, this);
|
||||
|
||||
// Instantiate needed components.
|
||||
QVBoxLayout* central_layout = new QVBoxLayout(this);
|
||||
QVBoxLayout* feed_layout = new QVBoxLayout(m_feedsWidget);
|
||||
QVBoxLayout* message_layout = new QVBoxLayout(m_messagesWidget);
|
||||
|
||||
// Set layout properties.
|
||||
central_layout->setMargin(0);
|
||||
central_layout->setSpacing(0);
|
||||
@ -245,9 +249,11 @@ void FeedMessageViewer::initializeViews() {
|
||||
feed_layout->setSpacing(0);
|
||||
message_layout->setMargin(0);
|
||||
message_layout->setSpacing(0);
|
||||
|
||||
// Set views.
|
||||
m_feedsView->setFrameStyle(QFrame::NoFrame);
|
||||
m_messagesView->setFrameStyle(QFrame::NoFrame);
|
||||
|
||||
// Setup message splitter.
|
||||
m_messageSplitter->setObjectName(QSL("MessageSplitter"));
|
||||
m_messageSplitter->setHandleWidth(1);
|
||||
@ -255,18 +261,22 @@ void FeedMessageViewer::initializeViews() {
|
||||
m_messageSplitter->setChildrenCollapsible(false);
|
||||
m_messageSplitter->addWidget(m_messagesView);
|
||||
m_messageSplitter->addWidget(m_messagesBrowser);
|
||||
|
||||
// Assemble message-related components to single widget.
|
||||
message_layout->addWidget(m_toolBarMessages);
|
||||
message_layout->addWidget(m_messageSplitter);
|
||||
|
||||
// Assemble feed-related components to another widget.
|
||||
feed_layout->addWidget(m_toolBarFeeds);
|
||||
feed_layout->addWidget(m_feedsView);
|
||||
|
||||
// Assembler everything together.
|
||||
m_feedSplitter->setHandleWidth(1);
|
||||
m_feedSplitter->setOpaqueResize(false);
|
||||
m_feedSplitter->setChildrenCollapsible(false);
|
||||
m_feedSplitter->addWidget(m_feedsWidget);
|
||||
m_feedSplitter->addWidget(m_messagesWidget);
|
||||
|
||||
// Add toolbar and main feeds/messages widget to main layout.
|
||||
central_layout->addWidget(m_feedSplitter);
|
||||
setTabOrder(m_feedsView, m_messagesView);
|
||||
@ -276,8 +286,9 @@ void FeedMessageViewer::initializeViews() {
|
||||
}
|
||||
|
||||
void FeedMessageViewer::refreshVisualProperties() {
|
||||
const Qt::ToolButtonStyle button_style = static_cast<Qt::ToolButtonStyle>(qApp->settings()->value(GROUP(GUI),
|
||||
SETTING(GUI::ToolbarStyle)).toInt());
|
||||
const Qt::ToolButtonStyle button_style =
|
||||
static_cast<Qt::ToolButtonStyle>(qApp->settings()->value(GROUP(GUI), SETTING(GUI::ToolbarStyle)).toInt());
|
||||
|
||||
m_toolBarFeeds->setToolButtonStyle(button_style);
|
||||
m_toolBarMessages->setToolButtonStyle(button_style);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
// This file is part of RSS Guard.
|
||||
|
||||
//
|
||||
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
@ -44,7 +45,6 @@ class FeedMessageViewer : public TabContent {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit FeedMessageViewer(QWidget* parent = 0);
|
||||
virtual ~FeedMessageViewer();
|
||||
|
||||
@ -61,9 +61,6 @@ class FeedMessageViewer : public TabContent {
|
||||
bool areListHeadersEnabled() const;
|
||||
|
||||
public slots:
|
||||
// Loads/saves sizes and states of ALL
|
||||
// underlying widgets, this contains primarily
|
||||
// splitters, toolbar and views.
|
||||
void saveSize();
|
||||
void loadSize();
|
||||
|
||||
@ -87,7 +84,6 @@ class FeedMessageViewer : public TabContent {
|
||||
void toggleShowOnlyUnreadFeeds();
|
||||
|
||||
protected:
|
||||
// Initializes some properties of the widget.
|
||||
void initialize();
|
||||
|
||||
// Initializes both messages/feeds views.
|
||||
@ -101,10 +97,8 @@ class FeedMessageViewer : public TabContent {
|
||||
bool m_listHeadersEnabled;
|
||||
FeedsToolBar* m_toolBarFeeds;
|
||||
MessagesToolBar* m_toolBarMessages;
|
||||
|
||||
QSplitter* m_feedSplitter;
|
||||
QSplitter* m_messageSplitter;
|
||||
|
||||
MessagesView* m_messagesView;
|
||||
FeedsView* m_feedsView;
|
||||
QWidget* m_feedsWidget;
|
||||
|
@ -20,23 +20,22 @@
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QCheckBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QStyle>
|
||||
#include <QCheckBox>
|
||||
#include <QtGlobal>
|
||||
|
||||
|
||||
MessageBox::MessageBox(QWidget* parent) : QMessageBox(parent) {
|
||||
}
|
||||
MessageBox::MessageBox(QWidget* parent) : QMessageBox(parent) {}
|
||||
|
||||
MessageBox::~MessageBox() {
|
||||
}
|
||||
MessageBox::~MessageBox() {}
|
||||
|
||||
void MessageBox::setIcon(QMessageBox::Icon icon) {
|
||||
// Determine correct status icon size.
|
||||
const int icon_size = qApp->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, this);
|
||||
|
||||
// Setup status icon.
|
||||
setIconPixmap(iconForStatus(icon).pixmap(icon_size, icon_size));
|
||||
}
|
||||
@ -44,6 +43,7 @@ void MessageBox::setIcon(QMessageBox::Icon icon) {
|
||||
void MessageBox::setCheckBox(QMessageBox* msg_box, const QString& text, bool* data) {
|
||||
// Add "don't show this again checkbox.
|
||||
QCheckBox* check_box = new QCheckBox(msg_box);
|
||||
|
||||
check_box->setChecked(*data);
|
||||
check_box->setText(text);
|
||||
connect(check_box, &QCheckBox::toggled, [=](bool checked) {
|
||||
@ -72,17 +72,12 @@ QIcon MessageBox::iconForStatus(QMessageBox::Icon status) {
|
||||
}
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton MessageBox::show(QWidget* parent,
|
||||
QMessageBox::Icon icon,
|
||||
const QString& title,
|
||||
const QString& text,
|
||||
const QString& informative_text,
|
||||
const QString& detailed_text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton default_button,
|
||||
bool* dont_show_again) {
|
||||
QMessageBox::StandardButton MessageBox::show(QWidget* parent, QMessageBox::Icon icon, const QString& title, const QString& text,
|
||||
const QString& informative_text, const QString& detailed_text, QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton default_button, bool* dont_show_again) {
|
||||
// Create and find needed components.
|
||||
MessageBox msg_box(parent);
|
||||
|
||||
// Initialize message box properties.
|
||||
msg_box.setWindowTitle(title);
|
||||
msg_box.setText(text);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// This file is part of RSS Guard.
|
||||
//
|
||||
|
||||
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
// RSS Guard is free software: you can redistribute it and/or modify
|
||||
@ -17,30 +17,29 @@
|
||||
|
||||
#include "gui/messagesview.h"
|
||||
|
||||
#include "core/messagesproxymodel.h"
|
||||
#include "core/messagesmodel.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "core/messagesproxymodel.h"
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "gui/messagebox.h"
|
||||
#include "gui/styleditemdelegatewithoutfocus.h"
|
||||
#include "gui/treeviewcolumnsmenu.h"
|
||||
#include "miscellaneous/externaltool.h"
|
||||
#include "miscellaneous/feedreader.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "network-web/networkfactory.h"
|
||||
#include "network-web/webfactory.h"
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "miscellaneous/externaltool.h"
|
||||
#include "gui/messagebox.h"
|
||||
#include "gui/treeviewcolumnsmenu.h"
|
||||
#include "gui/styleditemdelegatewithoutfocus.h"
|
||||
|
||||
#include <QFileIconProvider>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QProcess>
|
||||
#include <QScrollBar>
|
||||
#include <QTimer>
|
||||
#include <QMenu>
|
||||
#include <QFileIconProvider>
|
||||
#include <QProcess>
|
||||
|
||||
|
||||
MessagesView::MessagesView(QWidget* parent)
|
||||
: QTreeView(parent), m_contextMenu(nullptr), m_columnsAdjusted(false) {
|
||||
MessagesView::MessagesView(QWidget* parent) : QTreeView(parent), m_contextMenu(nullptr), m_columnsAdjusted(false) {
|
||||
m_sourceModel = qApp->feedReader()->messagesModel();
|
||||
m_proxyModel = qApp->feedReader()->messagesProxyModel();
|
||||
|
||||
// Forward count changes to the view.
|
||||
createConnections();
|
||||
setModel(m_proxyModel);
|
||||
@ -75,6 +74,7 @@ void MessagesView::sort(int column, Qt::SortOrder order, bool repopulate_data, b
|
||||
|
||||
void MessagesView::createConnections() {
|
||||
connect(this, &MessagesView::doubleClicked, this, &MessagesView::openSelectedSourceMessagesExternally);
|
||||
|
||||
// Adjust columns when layout gets changed.
|
||||
connect(header(), &QHeaderView::geometriesChanged, this, &MessagesView::adjustColumns);
|
||||
connect(header(), &QHeaderView::sortIndicatorChanged, this, &MessagesView::onSortIndicatorChanged);
|
||||
@ -95,6 +95,7 @@ void MessagesView::reloadSelections() {
|
||||
const Message selected_message = m_sourceModel->messageAt(mapped_current_index.row());
|
||||
const int col = header()->sortIndicatorSection();
|
||||
const Qt::SortOrder ord = header()->sortIndicatorOrder();
|
||||
|
||||
// Reload the model now.
|
||||
sort(col, ord, true, false, false);
|
||||
|
||||
@ -132,6 +133,7 @@ void MessagesView::reloadSelections() {
|
||||
}
|
||||
|
||||
const QDateTime dt2 = QDateTime::currentDateTime();
|
||||
|
||||
qDebug("Reloading of msg selections took %lld miliseconds.", dt1.msecsTo(dt2));
|
||||
}
|
||||
|
||||
@ -168,6 +170,7 @@ void MessagesView::contextMenuEvent(QContextMenuEvent* event) {
|
||||
|
||||
if (!clicked_index.isValid()) {
|
||||
TreeViewColumnsMenu menu(header());
|
||||
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else {
|
||||
@ -186,6 +189,7 @@ void MessagesView::initializeContextMenu() {
|
||||
|
||||
QFileIconProvider icon_provider;
|
||||
QMenu* menu = new QMenu(tr("Open with external tool"), m_contextMenu);
|
||||
|
||||
menu->setIcon(qApp->icons()->fromTheme(QSL("document-open")));
|
||||
|
||||
foreach (const ExternalTool& tool, ExternalTool::toolsFromSettings()) {
|
||||
@ -201,19 +205,13 @@ void MessagesView::initializeContextMenu() {
|
||||
|
||||
if (menu->actions().isEmpty()) {
|
||||
QAction* act_not_tools = new QAction("No external tools activated");
|
||||
|
||||
act_not_tools->setEnabled(false);
|
||||
menu->addAction(act_not_tools);
|
||||
}
|
||||
|
||||
m_contextMenu->addMenu(menu);
|
||||
m_contextMenu->addActions(QList<QAction*>() <<
|
||||
qApp->mainForm()->m_ui->m_actionSendMessageViaEmail <<
|
||||
qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesExternally <<
|
||||
qApp->mainForm()->m_ui->m_actionOpenSelectedMessagesInternally <<
|
||||
qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsRead <<
|
||||
qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsUnread <<
|
||||
qApp->mainForm()->m_ui->m_actionSwitchImportanceOfSelectedMessages <<
|
||||
qApp->mainForm()->m_ui->m_actionDeleteSelectedMessages);
|
||||
m_contextMenu->addActions(QList<QAction*>() << qApp->mainForm()->m_ui->m_actionSendMessageViaEmail << qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesExternally << qApp->mainForm()->m_ui->m_actionOpenSelectedMessagesInternally << qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsRead << qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsUnread << qApp->mainForm()->m_ui->m_actionSwitchImportanceOfSelectedMessages << qApp->mainForm()->m_ui->m_actionDeleteSelectedMessages);
|
||||
|
||||
if (m_sourceModel->loadedItem() != nullptr && m_sourceModel->loadedItem()->kind() == RootItemKind::Bin) {
|
||||
m_contextMenu->addAction(qApp->mainForm()->m_ui->m_actionRestoreSelectedMessages);
|
||||
@ -268,16 +266,17 @@ void MessagesView::selectionChanged(const QItemSelection& selected, const QItemS
|
||||
const QModelIndexList selected_rows = selectionModel()->selectedRows();
|
||||
const QModelIndex current_index = currentIndex();
|
||||
const QModelIndex mapped_current_index = m_proxyModel->mapToSource(current_index);
|
||||
qDebug("Current row changed - row [%d,%d] source [%d, %d].",
|
||||
current_index.row(), current_index.column(),
|
||||
mapped_current_index.row(), mapped_current_index.column());
|
||||
|
||||
qDebug("Current row changed - row [%d,%d] source [%d, %d].",current_index.row(), current_index.column(),mapped_current_index.row(), mapped_current_index.column());
|
||||
|
||||
if (mapped_current_index.isValid() && selected_rows.count() > 0) {
|
||||
Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row());
|
||||
|
||||
// Set this message as read only if current item
|
||||
// wasn't changed by "mark selected messages unread" action.
|
||||
m_sourceModel->setMessageRead(mapped_current_index.row(), RootItem::Read);
|
||||
message.m_isRead = true;
|
||||
|
||||
emit currentMessageChanged(message, m_sourceModel->loadedItem());
|
||||
}
|
||||
else {
|
||||
@ -294,9 +293,11 @@ void MessagesView::selectionChanged(const QItemSelection& selected, const QItemS
|
||||
void MessagesView::loadItem(RootItem* item) {
|
||||
const int col = header()->sortIndicatorSection();
|
||||
const Qt::SortOrder ord = header()->sortIndicatorOrder();
|
||||
|
||||
scrollToTop();
|
||||
sort(col, ord, false, true, false);
|
||||
m_sourceModel->loadMessages(item);
|
||||
|
||||
// Messages are loaded, make sure that previously
|
||||
// active message is not shown in browser.
|
||||
// BUG: Qt 5 is probably bugged here. Selections
|
||||
@ -309,9 +310,7 @@ void MessagesView::openSelectedSourceMessagesExternally() {
|
||||
const QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()).m_url;
|
||||
|
||||
if (!qApp->web()->openUrlInExternalBrowser(link)) {
|
||||
qApp->showGuiMessage(tr("Problem with starting external web browser"),
|
||||
tr("External web browser could not be started."),
|
||||
QSystemTrayIcon::Critical);
|
||||
qApp->showGuiMessage(tr("Problem with starting external web browser"),tr("External web browser could not be started."),QSystemTrayIcon::Critical);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -339,10 +338,7 @@ void MessagesView::sendSelectedMessageViaEmail() {
|
||||
const Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(selectionModel()->selectedRows().at(0)).row());
|
||||
|
||||
if (!qApp->web()->sendMessageViaEmail(message)) {
|
||||
MessageBox::show(this,
|
||||
QMessageBox::Critical,
|
||||
tr("Problem with starting external e-mail client"),
|
||||
tr("External e-mail client could not be started."));
|
||||
MessageBox::show(this,QMessageBox::Critical,tr("Problem with starting external e-mail client"),tr("External e-mail client could not be started."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -364,6 +360,7 @@ void MessagesView::setSelectedMessagesReadStatus(RootItem::ReadStatus read) {
|
||||
|
||||
QModelIndexList selected_indexes = selectionModel()->selectedRows();
|
||||
const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
|
||||
|
||||
m_sourceModel->setBatchMessagesRead(mapped_indexes, read);
|
||||
current_index = m_proxyModel->index(current_index.row(), current_index.column());
|
||||
|
||||
@ -384,11 +381,13 @@ void MessagesView::deleteSelectedMessages() {
|
||||
|
||||
const QModelIndexList selected_indexes = selectionModel()->selectedRows();
|
||||
const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
|
||||
|
||||
m_sourceModel->setBatchMessagesDeleted(mapped_indexes);
|
||||
current_index = moveCursor(QAbstractItemView::MoveDown, Qt::NoModifier);
|
||||
|
||||
if (current_index.isValid()) {
|
||||
setCurrentIndex(current_index);
|
||||
|
||||
emit currentMessageChanged(m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()), m_sourceModel->loadedItem());
|
||||
}
|
||||
else {
|
||||
@ -405,6 +404,7 @@ void MessagesView::restoreSelectedMessages() {
|
||||
|
||||
const QModelIndexList selected_indexes = selectionModel()->selectedRows();
|
||||
const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
|
||||
|
||||
m_sourceModel->setBatchMessagesRestored(mapped_indexes);
|
||||
current_index = m_proxyModel->index(current_index.row(), current_index.column());
|
||||
|
||||
@ -425,6 +425,7 @@ void MessagesView::switchSelectedMessagesImportance() {
|
||||
|
||||
QModelIndexList selected_indexes = selectionModel()->selectedRows();
|
||||
const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
|
||||
|
||||
m_sourceModel->switchBatchMessageImportance(mapped_indexes);
|
||||
current_index = m_proxyModel->index(current_index.row(), current_index.column());
|
||||
|
||||
@ -519,8 +520,7 @@ void MessagesView::openSelectedMessagesWithExternalTool() {
|
||||
|
||||
if (!link.isEmpty()) {
|
||||
if (!QProcess::startDetached(tool.executable(), QStringList() << tool.parameters() << link)) {
|
||||
qApp->showGuiMessage(tr("Cannot run external tool"), tr("External tool '%1' could not be started.").arg(tool.executable()),
|
||||
QSystemTrayIcon::Critical);
|
||||
qApp->showGuiMessage(tr("Cannot run external tool"), tr("External tool '%1' could not be started.").arg(tool.executable()),QSystemTrayIcon::Critical);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -530,6 +530,7 @@ void MessagesView::openSelectedMessagesWithExternalTool() {
|
||||
void MessagesView::adjustColumns() {
|
||||
if (header()->count() > 0 && !m_columnsAdjusted) {
|
||||
m_columnsAdjusted = true;
|
||||
|
||||
// Setup column resize strategies.
|
||||
header()->setSectionResizeMode(MSG_DB_ID_INDEX, QHeaderView::Interactive);
|
||||
header()->setSectionResizeMode(MSG_DB_READ_INDEX, QHeaderView::ResizeToContents);
|
||||
@ -542,6 +543,7 @@ void MessagesView::adjustColumns() {
|
||||
header()->setSectionResizeMode(MSG_DB_DCREATED_INDEX, QHeaderView::Interactive);
|
||||
header()->setSectionResizeMode(MSG_DB_CONTENTS_INDEX, QHeaderView::Interactive);
|
||||
header()->setSectionResizeMode(MSG_DB_PDELETED_INDEX, QHeaderView::Interactive);
|
||||
|
||||
//header()->resizeSection(MSG_DB_READ_INDEX, MESSAGES_VIEW_MINIMUM_COL);
|
||||
//header()->resizeSection(MSG_DB_IMPORTANT_INDEX, MESSAGES_VIEW_MINIMUM_COL);
|
||||
// Hide columns.
|
||||
@ -562,5 +564,6 @@ void MessagesView::adjustColumns() {
|
||||
void MessagesView::onSortIndicatorChanged(int column, Qt::SortOrder order) {
|
||||
// Repopulate the shit.
|
||||
sort(column, order, true, false, false);
|
||||
|
||||
emit currentMessageRemoved();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
// This file is part of RSS Guard.
|
||||
|
||||
//
|
||||
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
@ -22,9 +23,8 @@
|
||||
|
||||
#include "services/abstract/rootitem.h"
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QHeaderView>
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
class MessagesProxyModel;
|
||||
|
||||
@ -32,7 +32,6 @@ class MessagesView : public QTreeView {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit MessagesView(QWidget* parent = 0);
|
||||
virtual ~MessagesView();
|
||||
|
||||
@ -89,7 +88,6 @@ class MessagesView : public QTreeView {
|
||||
void onSortIndicatorChanged(int column, Qt::SortOrder order);
|
||||
|
||||
signals:
|
||||
// Link/message openers.
|
||||
void openLinkNewTab(const QString& link);
|
||||
void openLinkMiniBrowser(const QString& link);
|
||||
void openMessagesInNewspaperView(RootItem* root, const QList<Message>& messages);
|
||||
@ -117,10 +115,8 @@ class MessagesView : public QTreeView {
|
||||
void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
|
||||
|
||||
QMenu* m_contextMenu;
|
||||
|
||||
MessagesProxyModel* m_proxyModel;
|
||||
MessagesModel* m_sourceModel;
|
||||
|
||||
bool m_columnsAdjusted;
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// This file is part of RSS Guard.
|
||||
|
||||
//
|
||||
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
@ -18,15 +19,14 @@
|
||||
#include "gui/statusbar.h"
|
||||
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "gui/tabwidget.h"
|
||||
#include "gui/plaintoolbutton.h"
|
||||
#include "miscellaneous/mutex.h"
|
||||
#include "gui/tabwidget.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "miscellaneous/mutex.h"
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QLabel>
|
||||
#include <QProgressBar>
|
||||
|
||||
#include <QToolButton>
|
||||
|
||||
StatusBar::StatusBar(QWidget* parent) : QStatusBar(parent), m_mutex(new Mutex(QMutex::NonRecursive, this)) {
|
||||
setSizeGripEnabled(false);
|
||||
@ -70,9 +70,10 @@ StatusBar::~StatusBar() {
|
||||
|
||||
QList<QAction*> StatusBar::availableActions() const {
|
||||
QList<QAction*> actions = qApp->userActions();
|
||||
|
||||
// Now, add placeholder actions for custom stuff.
|
||||
actions << m_barProgressDownloadAction << m_barProgressFeedsAction <<
|
||||
m_lblProgressDownloadAction << m_lblProgressFeedsAction;
|
||||
actions << m_barProgressDownloadAction << m_barProgressFeedsAction << m_lblProgressDownloadAction << m_lblProgressFeedsAction;
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
@ -82,6 +83,7 @@ QList<QAction*> StatusBar::changeableActions() const {
|
||||
|
||||
void StatusBar::saveChangeableActions(const QStringList& actions) {
|
||||
QMutexLocker locker(*m_mutex);
|
||||
|
||||
qApp->settings()->setValue(GROUP(GUI), GUI::StatusbarActions, actions.join(QSL(",")));
|
||||
loadSpecificActions(getSpecificActions(actions));
|
||||
}
|
||||
@ -95,13 +97,14 @@ QStringList StatusBar::savedActions() const {
|
||||
}
|
||||
|
||||
QList<QAction*> StatusBar::getSpecificActions(const QStringList& actions) {
|
||||
bool progress_visible = this->actions().contains(m_barProgressFeedsAction) &&
|
||||
m_lblProgressFeeds->isVisible() &&
|
||||
bool progress_visible = this->actions().contains(m_barProgressFeedsAction) && m_lblProgressFeeds->isVisible() &&
|
||||
m_barProgressFeeds->isVisible();
|
||||
|
||||
QList<QAction*> available_actions = availableActions();
|
||||
QList<QAction*> spec_actions;
|
||||
|
||||
// Iterate action names and add respectable actions into the toolbar.
|
||||
// Iterate action names and add respectable
|
||||
// actions into the toolbar.
|
||||
foreach (const QString& action_name, actions) {
|
||||
QAction* matching_action = findMatchingAction(action_name, available_actions);
|
||||
QAction* action_to_add;
|
||||
@ -130,6 +133,7 @@ QList<QAction*> StatusBar::getSpecificActions(const QStringList& actions) {
|
||||
else {
|
||||
if (action_name == SEPARATOR_ACTION_NAME) {
|
||||
QLabel* lbl = new QLabel(QString::fromUtf8("•"));
|
||||
|
||||
widget_to_add = lbl;
|
||||
action_to_add = new QAction(this);
|
||||
action_to_add->setSeparator(true);
|
||||
@ -137,6 +141,7 @@ QList<QAction*> StatusBar::getSpecificActions(const QStringList& actions) {
|
||||
}
|
||||
else if (action_name == SPACER_ACTION_NAME) {
|
||||
QLabel* lbl = new QLabel(QSL("\t\t"));
|
||||
|
||||
widget_to_add = lbl;
|
||||
action_to_add = new QAction(this);
|
||||
action_to_add->setProperty("should_remove_action", true);
|
||||
@ -147,6 +152,7 @@ QList<QAction*> StatusBar::getSpecificActions(const QStringList& actions) {
|
||||
else if (matching_action != nullptr) {
|
||||
// Add originally toolbar action.
|
||||
PlainToolButton* tool_button = new PlainToolButton(this);
|
||||
|
||||
tool_button->reactOnActionChange(matching_action);
|
||||
widget_to_add = tool_button;
|
||||
action_to_add = matching_action;
|
||||
@ -189,6 +195,7 @@ void StatusBar::loadSpecificActions(const QList<QAction*>& actions) {
|
||||
|
||||
foreach (QAction* act, actions) {
|
||||
QWidget* widget = act->property("widget").isValid() ? static_cast<QWidget*>(act->property("widget").value<void*>()) : nullptr;
|
||||
|
||||
addAction(act);
|
||||
|
||||
// And also add widget.
|
||||
@ -214,6 +221,7 @@ void StatusBar::clear() {
|
||||
QWidget* widget = act->property("widget").isValid() ? static_cast<QWidget*>(act->property("widget").value<void*>()) : nullptr;
|
||||
bool should_remove_widget = act->property("should_remove_widget").isValid();
|
||||
bool should_remove_action = act->property("should_remove_action").isValid();
|
||||
|
||||
removeAction(act);
|
||||
|
||||
if (widget != nullptr) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
// This file is part of RSS Guard.
|
||||
|
||||
//
|
||||
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
@ -22,7 +23,6 @@
|
||||
|
||||
#include "gui/basetoolbar.h"
|
||||
|
||||
|
||||
class QProgressBar;
|
||||
class PlainToolButton;
|
||||
class QLabel;
|
||||
@ -32,7 +32,6 @@ class StatusBar : public QStatusBar, public BaseBar {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit StatusBar(QWidget* parent = 0);
|
||||
virtual ~StatusBar();
|
||||
|
||||
@ -45,7 +44,6 @@ class StatusBar : public QStatusBar, public BaseBar {
|
||||
void loadSpecificActions(const QList<QAction*>& actions);
|
||||
|
||||
public slots:
|
||||
// Progress bar operations
|
||||
void showProgressFeeds(int progress, const QString& label);
|
||||
void clearProgressFeeds();
|
||||
|
||||
@ -59,16 +57,12 @@ class StatusBar : public QStatusBar, public BaseBar {
|
||||
void clear();
|
||||
|
||||
Mutex* m_mutex;
|
||||
|
||||
QProgressBar* m_barProgressFeeds;
|
||||
QAction* m_barProgressFeedsAction;
|
||||
|
||||
QLabel* m_lblProgressFeeds;
|
||||
QAction* m_lblProgressFeedsAction;
|
||||
|
||||
QProgressBar* m_barProgressDownload;
|
||||
QAction* m_barProgressDownloadAction;
|
||||
|
||||
QLabel* m_lblProgressDownload;
|
||||
QAction* m_lblProgressDownloadAction;
|
||||
};
|
||||
|
@ -17,12 +17,12 @@
|
||||
|
||||
#include "services/owncloud/network/owncloudnetworkfactory.h"
|
||||
|
||||
#include "services/owncloud/definitions.h"
|
||||
#include "network-web/networkfactory.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "miscellaneous/textfactory.h"
|
||||
#include "network-web/networkfactory.h"
|
||||
#include "services/abstract/rootitem.h"
|
||||
#include "services/owncloud/definitions.h"
|
||||
#include "services/owncloud/owncloudcategory.h"
|
||||
#include "services/owncloud/owncloudfeed.h"
|
||||
|
||||
@ -36,11 +36,9 @@ OwnCloudNetworkFactory::OwnCloudNetworkFactory()
|
||||
: m_url(QString()), m_fixedUrl(QString()), m_forceServerSideUpdate(false),
|
||||
m_authUsername(QString()), m_authPassword(QString()), m_batchSize(-1), m_urlUser(QString()), m_urlStatus(QString()),
|
||||
m_urlFolders(QString()), m_urlFeeds(QString()), m_urlMessages(QString()), m_urlFeedsUpdate(QString()),
|
||||
m_urlDeleteFeed(QString()), m_urlRenameFeed(QString()), m_userId(QString()) {
|
||||
}
|
||||
m_urlDeleteFeed(QString()), m_urlRenameFeed(QString()), m_userId(QString()) {}
|
||||
|
||||
OwnCloudNetworkFactory::~OwnCloudNetworkFactory() {
|
||||
}
|
||||
OwnCloudNetworkFactory::~OwnCloudNetworkFactory() {}
|
||||
|
||||
QString OwnCloudNetworkFactory::url() const {
|
||||
return m_url;
|
||||
@ -49,7 +47,8 @@ QString OwnCloudNetworkFactory::url() const {
|
||||
void OwnCloudNetworkFactory::setUrl(const QString& url) {
|
||||
m_url = url;
|
||||
|
||||
if (url.endsWith('/')) {
|
||||
if (url.endsWith('/')
|
||||
) {
|
||||
m_fixedUrl = url;
|
||||
}
|
||||
else {
|
||||
@ -109,7 +108,8 @@ OwnCloudUserResponse OwnCloudNetworkFactory::userInfo() {
|
||||
true);
|
||||
OwnCloudUserResponse user_response(QString::fromUtf8(result_raw));
|
||||
|
||||
if (network_reply.first != QNetworkReply::NoError) {
|
||||
if (network_reply.first != QNetworkReply::NoError
|
||||
) {
|
||||
qWarning("ownCloud: Obtaining user info failed with error %d.", network_reply.first);
|
||||
}
|
||||
|
||||
@ -128,7 +128,8 @@ OwnCloudStatusResponse OwnCloudNetworkFactory::status() {
|
||||
true);
|
||||
OwnCloudStatusResponse status_response(QString::fromUtf8(result_raw));
|
||||
|
||||
if (network_reply.first != QNetworkReply::NoError) {
|
||||
if (network_reply.first != QNetworkReply::NoError
|
||||
) {
|
||||
qWarning("ownCloud: Obtaining status info failed with error %d.", network_reply.first);
|
||||
}
|
||||
|
||||
@ -146,13 +147,16 @@ OwnCloudGetFeedsCategoriesResponse OwnCloudNetworkFactory::feedsCategories() {
|
||||
true, m_authUsername, m_authPassword,
|
||||
true);
|
||||
|
||||
if (network_reply.first != QNetworkReply::NoError) {
|
||||
if (network_reply.first != QNetworkReply::NoError
|
||||
) {
|
||||
qWarning("ownCloud: Obtaining of categories failed with error %d.", network_reply.first);
|
||||
m_lastError = network_reply.first;
|
||||
return OwnCloudGetFeedsCategoriesResponse();
|
||||
}
|
||||
|
||||
QString content_categories = QString::fromUtf8(result_raw);
|
||||
|
||||
|
||||
// Now, obtain feeds.
|
||||
network_reply = NetworkFactory::performNetworkOperation(m_urlFeeds,
|
||||
qApp->settings()->value(GROUP(Feeds),
|
||||
@ -162,13 +166,16 @@ OwnCloudGetFeedsCategoriesResponse OwnCloudNetworkFactory::feedsCategories() {
|
||||
true, m_authUsername, m_authPassword,
|
||||
true);
|
||||
|
||||
if (network_reply.first != QNetworkReply::NoError) {
|
||||
if (network_reply.first != QNetworkReply::NoError
|
||||
) {
|
||||
qWarning("ownCloud: Obtaining of feeds failed with error %d.", network_reply.first);
|
||||
m_lastError = network_reply.first;
|
||||
return OwnCloudGetFeedsCategoriesResponse();
|
||||
}
|
||||
|
||||
QString content_feeds = QString::fromUtf8(result_raw);
|
||||
|
||||
|
||||
m_lastError = network_reply.first;
|
||||
return OwnCloudGetFeedsCategoriesResponse(content_categories, content_feeds);
|
||||
}
|
||||
@ -182,9 +189,11 @@ bool OwnCloudNetworkFactory::deleteFeed(int feed_id) {
|
||||
QByteArray(), QString(),
|
||||
raw_output, QNetworkAccessManager::DeleteOperation,
|
||||
true, m_authUsername, m_authPassword, true);
|
||||
|
||||
m_lastError = network_reply.first;
|
||||
|
||||
if (network_reply.first != QNetworkReply::NoError) {
|
||||
if (network_reply.first != QNetworkReply::NoError
|
||||
) {
|
||||
qWarning("ownCloud: Obtaining of categories failed with error %d.", network_reply.first);
|
||||
return false;
|
||||
}
|
||||
@ -195,8 +204,10 @@ bool OwnCloudNetworkFactory::deleteFeed(int feed_id) {
|
||||
|
||||
bool OwnCloudNetworkFactory::createFeed(const QString& url, int parent_id) {
|
||||
QJsonObject json;
|
||||
|
||||
json["url"] = url;
|
||||
json["folderId"] = parent_id;
|
||||
|
||||
QByteArray result_raw;
|
||||
NetworkResult network_reply = NetworkFactory::performNetworkOperation(m_urlFeeds,
|
||||
qApp->settings()->value(GROUP(Feeds),
|
||||
@ -206,9 +217,12 @@ bool OwnCloudNetworkFactory::createFeed(const QString& url, int parent_id) {
|
||||
result_raw,
|
||||
QNetworkAccessManager::PostOperation,
|
||||
true, m_authUsername, m_authPassword, true);
|
||||
|
||||
|
||||
m_lastError = network_reply.first;
|
||||
|
||||
if (network_reply.first != QNetworkReply::NoError) {
|
||||
if (network_reply.first != QNetworkReply::NoError
|
||||
) {
|
||||
qWarning("ownCloud: Creating of category failed with error %d.", network_reply.first);
|
||||
return false;
|
||||
}
|
||||
@ -221,8 +235,11 @@ bool OwnCloudNetworkFactory::renameFeed(const QString& new_name, int feed_id) {
|
||||
QString final_url = m_urlRenameFeed.arg(QString::number(feed_id));
|
||||
QByteArray result_raw;
|
||||
QJsonObject json;
|
||||
|
||||
json["feedTitle"] = new_name;
|
||||
NetworkResult network_reply = NetworkFactory::performNetworkOperation(final_url,
|
||||
|
||||
NetworkResult network_reply = NetworkFactory::performNetworkOperation(
|
||||
final_url,
|
||||
qApp->settings()->value(GROUP(Feeds),
|
||||
SETTING(Feeds::UpdateTimeout)).toInt(),
|
||||
QJsonDocument(json).toJson(QJsonDocument::Compact),
|
||||
@ -230,9 +247,12 @@ bool OwnCloudNetworkFactory::renameFeed(const QString& new_name, int feed_id) {
|
||||
QNetworkAccessManager::PutOperation,
|
||||
true, m_authUsername, m_authPassword,
|
||||
true);
|
||||
|
||||
|
||||
m_lastError = network_reply.first;
|
||||
|
||||
if (network_reply.first != QNetworkReply::NoError) {
|
||||
if (network_reply.first != QNetworkReply::NoError
|
||||
) {
|
||||
qWarning("ownCloud: Renaming of feed failed with error %d.", network_reply.first);
|
||||
return false;
|
||||
}
|
||||
@ -242,7 +262,8 @@ bool OwnCloudNetworkFactory::renameFeed(const QString& new_name, int feed_id) {
|
||||
}
|
||||
|
||||
OwnCloudGetMessagesResponse OwnCloudNetworkFactory::getMessages(int feed_id) {
|
||||
if (forceServerSideUpdate()) {
|
||||
if (forceServerSideUpdate()
|
||||
) {
|
||||
triggerFeedUpdate(feed_id);
|
||||
}
|
||||
|
||||
@ -259,7 +280,9 @@ OwnCloudGetMessagesResponse OwnCloudNetworkFactory::getMessages(int feed_id) {
|
||||
true);
|
||||
OwnCloudGetMessagesResponse msgs_response(QString::fromUtf8(result_raw));
|
||||
|
||||
if (network_reply.first != QNetworkReply::NoError) {
|
||||
|
||||
if (network_reply.first != QNetworkReply::NoError
|
||||
) {
|
||||
qWarning("ownCloud: Obtaining messages failed with error %d.", network_reply.first);
|
||||
}
|
||||
|
||||
@ -268,11 +291,14 @@ OwnCloudGetMessagesResponse OwnCloudNetworkFactory::getMessages(int feed_id) {
|
||||
}
|
||||
|
||||
QNetworkReply::NetworkError OwnCloudNetworkFactory::triggerFeedUpdate(int feed_id) {
|
||||
if (userId().isEmpty()) {
|
||||
if (userId().isEmpty()
|
||||
) {
|
||||
// We need to get user ID first.
|
||||
OwnCloudUserResponse info = userInfo();
|
||||
|
||||
if (lastError() != QNetworkReply::NoError) {
|
||||
|
||||
if (lastError() != QNetworkReply::NoError
|
||||
) {
|
||||
return lastError();
|
||||
}
|
||||
else {
|
||||
@ -292,7 +318,8 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::triggerFeedUpdate(int feed_i
|
||||
true, m_authUsername, m_authPassword,
|
||||
true);
|
||||
|
||||
if (network_reply.first != QNetworkReply::NoError) {
|
||||
if (network_reply.first != QNetworkReply::NoError
|
||||
) {
|
||||
qWarning("ownCloud: Feeds update failed with error %d.", network_reply.first);
|
||||
}
|
||||
|
||||
@ -304,7 +331,8 @@ void OwnCloudNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const
|
||||
QJsonArray ids;
|
||||
QString final_url;
|
||||
|
||||
if (status == RootItem::Read) {
|
||||
if (status == RootItem::Read
|
||||
) {
|
||||
final_url = m_fixedUrl + API_PATH + "items/read/multiple";
|
||||
}
|
||||
else {
|
||||
@ -326,6 +354,7 @@ void OwnCloudNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const
|
||||
true, m_authUsername, m_authPassword,
|
||||
true);
|
||||
|
||||
|
||||
QObject::connect(downloader, &Downloader::completed, downloader, &Downloader::deleteLater);
|
||||
}
|
||||
|
||||
@ -336,7 +365,8 @@ void OwnCloudNetworkFactory::markMessagesStarred(RootItem::Importance importance
|
||||
QJsonArray ids;
|
||||
QString final_url;
|
||||
|
||||
if (importance == RootItem::Important) {
|
||||
if (importance == RootItem::Important
|
||||
) {
|
||||
final_url = m_fixedUrl + API_PATH + "items/star/multiple";
|
||||
}
|
||||
else {
|
||||
@ -345,12 +375,15 @@ void OwnCloudNetworkFactory::markMessagesStarred(RootItem::Importance importance
|
||||
|
||||
for (int i = 0; i < feed_ids.size(); i++) {
|
||||
QJsonObject item;
|
||||
|
||||
|
||||
item["feedId"] = feed_ids.at(i);
|
||||
item["guidHash"] = guid_hashes.at(i);
|
||||
ids.append(item);
|
||||
}
|
||||
|
||||
json["items"] = ids;
|
||||
|
||||
Downloader* downloader = NetworkFactory::performAsyncNetworkOperation(final_url,
|
||||
qApp->settings()->value(GROUP(Feeds),
|
||||
SETTING(Feeds::UpdateTimeout)).toInt(),
|
||||
@ -360,6 +393,7 @@ void OwnCloudNetworkFactory::markMessagesStarred(RootItem::Importance importance
|
||||
true, m_authUsername, m_authPassword,
|
||||
true);
|
||||
|
||||
|
||||
QObject::connect(downloader, &Downloader::completed, downloader, &Downloader::deleteLater);
|
||||
}
|
||||
|
||||
@ -384,8 +418,7 @@ OwnCloudResponse::OwnCloudResponse(const QString& raw_content) {
|
||||
m_emptyString = raw_content.isEmpty();
|
||||
}
|
||||
|
||||
OwnCloudResponse::~OwnCloudResponse() {
|
||||
}
|
||||
OwnCloudResponse::~OwnCloudResponse() {}
|
||||
|
||||
bool OwnCloudResponse::isLoaded() const {
|
||||
return !m_emptyString && !m_rawContent.isEmpty();
|
||||
@ -395,14 +428,13 @@ QString OwnCloudResponse::toString() const {
|
||||
return QJsonDocument(m_rawContent).toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
OwnCloudUserResponse::OwnCloudUserResponse(const QString& raw_content) : OwnCloudResponse(raw_content) {
|
||||
}
|
||||
OwnCloudUserResponse::OwnCloudUserResponse(const QString& raw_content) : OwnCloudResponse(raw_content) {}
|
||||
|
||||
OwnCloudUserResponse::~OwnCloudUserResponse() {
|
||||
}
|
||||
OwnCloudUserResponse::~OwnCloudUserResponse() {}
|
||||
|
||||
QString OwnCloudUserResponse::displayName() const {
|
||||
if (isLoaded()) {
|
||||
if (isLoaded()
|
||||
) {
|
||||
return m_rawContent["displayName"].toString();
|
||||
}
|
||||
else {
|
||||
@ -411,7 +443,8 @@ QString OwnCloudUserResponse::displayName() const {
|
||||
}
|
||||
|
||||
QString OwnCloudUserResponse::userId() const {
|
||||
if (isLoaded()) {
|
||||
if (isLoaded()
|
||||
) {
|
||||
return m_rawContent["userId"].toString();
|
||||
}
|
||||
else {
|
||||
@ -420,7 +453,8 @@ QString OwnCloudUserResponse::userId() const {
|
||||
}
|
||||
|
||||
QDateTime OwnCloudUserResponse::lastLoginTime() const {
|
||||
if (isLoaded()) {
|
||||
if (isLoaded()
|
||||
) {
|
||||
return QDateTime::fromMSecsSinceEpoch(m_rawContent["lastLoginTimestamp"].toDouble());
|
||||
}
|
||||
else {
|
||||
@ -429,12 +463,15 @@ QDateTime OwnCloudUserResponse::lastLoginTime() const {
|
||||
}
|
||||
|
||||
QIcon OwnCloudUserResponse::avatar() const {
|
||||
if (isLoaded()) {
|
||||
if (isLoaded()
|
||||
) {
|
||||
QString image_data = m_rawContent["avatar"].toObject()["data"].toString();
|
||||
QByteArray decoded_data = QByteArray::fromBase64(image_data.toLocal8Bit());
|
||||
QPixmap image;
|
||||
|
||||
if (image.loadFromData(decoded_data)) {
|
||||
|
||||
if (image.loadFromData(decoded_data)
|
||||
) {
|
||||
return QIcon(image);
|
||||
}
|
||||
}
|
||||
@ -443,14 +480,13 @@ QIcon OwnCloudUserResponse::avatar() const {
|
||||
}
|
||||
|
||||
|
||||
OwnCloudStatusResponse::OwnCloudStatusResponse(const QString& raw_content) : OwnCloudResponse(raw_content) {
|
||||
}
|
||||
OwnCloudStatusResponse::OwnCloudStatusResponse(const QString& raw_content) : OwnCloudResponse(raw_content) {}
|
||||
|
||||
OwnCloudStatusResponse::~OwnCloudStatusResponse() {
|
||||
}
|
||||
OwnCloudStatusResponse::~OwnCloudStatusResponse() {}
|
||||
|
||||
QString OwnCloudStatusResponse::version() const {
|
||||
if (isLoaded()) {
|
||||
if (isLoaded()
|
||||
) {
|
||||
return m_rawContent["version"].toString();
|
||||
}
|
||||
else {
|
||||
@ -459,7 +495,8 @@ QString OwnCloudStatusResponse::version() const {
|
||||
}
|
||||
|
||||
bool OwnCloudStatusResponse::misconfiguredCron() const {
|
||||
if (isLoaded()) {
|
||||
if (isLoaded()
|
||||
) {
|
||||
return m_rawContent["warnings"].toObject()["improperlyConfiguredCron"].toBool();
|
||||
}
|
||||
else {
|
||||
@ -470,14 +507,13 @@ bool OwnCloudStatusResponse::misconfiguredCron() const {
|
||||
|
||||
OwnCloudGetFeedsCategoriesResponse::OwnCloudGetFeedsCategoriesResponse(const QString& raw_categories,
|
||||
const QString& raw_feeds)
|
||||
: m_contentCategories(raw_categories), m_contentFeeds(raw_feeds) {
|
||||
}
|
||||
: m_contentCategories(raw_categories), m_contentFeeds(raw_feeds) {}
|
||||
|
||||
OwnCloudGetFeedsCategoriesResponse::~OwnCloudGetFeedsCategoriesResponse() {
|
||||
}
|
||||
OwnCloudGetFeedsCategoriesResponse::~OwnCloudGetFeedsCategoriesResponse() {}
|
||||
|
||||
RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons) const {
|
||||
RootItem* parent = new RootItem();
|
||||
|
||||
QMap<int, RootItem*>cats;
|
||||
cats.insert(0, parent);
|
||||
|
||||
@ -485,6 +521,8 @@ RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
|
||||
foreach (const QJsonValue& cat, QJsonDocument::fromJson(m_contentCategories.toUtf8()).object()["folders"].toArray()) {
|
||||
QJsonObject item = cat.toObject();
|
||||
OwnCloudCategory* category = new OwnCloudCategory();
|
||||
|
||||
|
||||
category->setTitle(item["name"].toString());
|
||||
category->setCustomId(item["id"].toInt());
|
||||
cats.insert(category->customId(), category);
|
||||
@ -497,17 +535,25 @@ RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
|
||||
QJsonObject item = fed.toObject();
|
||||
OwnCloudFeed* feed = new OwnCloudFeed();
|
||||
|
||||
if (obtain_icons) {
|
||||
|
||||
if (obtain_icons
|
||||
) {
|
||||
QString icon_path = item["faviconLink"].toString();
|
||||
|
||||
if (!icon_path.isEmpty()) {
|
||||
|
||||
if (!icon_path.isEmpty()
|
||||
) {
|
||||
QByteArray icon_data;
|
||||
|
||||
|
||||
if (NetworkFactory::performNetworkOperation(icon_path, DOWNLOAD_TIMEOUT,
|
||||
QByteArray(), QString(), icon_data,
|
||||
QNetworkAccessManager::GetOperation).first == QNetworkReply::NoError) {
|
||||
QNetworkAccessManager::GetOperation).first == QNetworkReply::NoError
|
||||
) {
|
||||
// Icon downloaded, set it up.
|
||||
QPixmap icon_pixmap;
|
||||
|
||||
|
||||
icon_pixmap.loadFromData(icon_data);
|
||||
feed->setIcon(QIcon(icon_pixmap));
|
||||
}
|
||||
@ -525,11 +571,9 @@ RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
|
||||
}
|
||||
|
||||
|
||||
OwnCloudGetMessagesResponse::OwnCloudGetMessagesResponse(const QString& raw_content) : OwnCloudResponse(raw_content) {
|
||||
}
|
||||
OwnCloudGetMessagesResponse::OwnCloudGetMessagesResponse(const QString& raw_content) : OwnCloudResponse(raw_content) {}
|
||||
|
||||
OwnCloudGetMessagesResponse::~OwnCloudGetMessagesResponse() {
|
||||
}
|
||||
OwnCloudGetMessagesResponse::~OwnCloudGetMessagesResponse() {}
|
||||
|
||||
QList<Message>OwnCloudGetMessagesResponse::messages() const {
|
||||
QList<Message>msgs;
|
||||
@ -537,16 +581,23 @@ QList<Message>OwnCloudGetMessagesResponse::messages() const {
|
||||
foreach (const QJsonValue& message, m_rawContent["items"].toArray()) {
|
||||
QJsonObject message_map = message.toObject();
|
||||
Message msg;
|
||||
|
||||
|
||||
msg.m_author = message_map["author"].toString();
|
||||
msg.m_contents = message_map["body"].toString();
|
||||
msg.m_created = TextFactory::parseDateTime(message_map["pubDate"].toDouble() * 1000);
|
||||
msg.m_createdFromFeed = true;
|
||||
msg.m_customId = QString::number(message_map["id"].toInt());
|
||||
msg.m_customHash = message_map["guidHash"].toString();
|
||||
|
||||
QString enclosure_link = message_map["enclosureLink"].toString();
|
||||
|
||||
if (!enclosure_link.isEmpty()) {
|
||||
|
||||
if (!enclosure_link.isEmpty()
|
||||
) {
|
||||
Enclosure enclosure;
|
||||
|
||||
|
||||
enclosure.m_mimeType = message_map["enclosureMime"].toString();
|
||||
enclosure.m_url = enclosure_link;
|
||||
msg.m_enclosures.append(enclosure);
|
||||
|
@ -22,10 +22,10 @@
|
||||
#include "services/abstract/rootitem.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
#include <QIcon>
|
||||
#include <QNetworkReply>
|
||||
#include <QJsonObject>
|
||||
#include <QNetworkReply>
|
||||
#include <QString>
|
||||
|
||||
|
||||
class OwnCloudResponse {
|
||||
|
Loading…
x
Reference in New Issue
Block a user