Stick to astlye, refacatoring.
This commit is contained in:
parent
dedf70a8a9
commit
b0ff27c232
14 changed files with 423 additions and 2348 deletions
|
|
@ -28,7 +28,16 @@ if [ $# -eq 0 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ASTYLE_CMD="astyle"
|
ASTYLE_CMD="astyle"
|
||||||
ASTYLE_RC="$(dirname $0)/.astylerc"
|
|
||||||
|
if [[ "$(uname -o)" == "Cygwin" ]]; then
|
||||||
|
ASTYLE_RC="$(cygpath -w $(realpath $(dirname $0)))/.astylerc"
|
||||||
|
else
|
||||||
|
ASTYLE_RC="$(realpath $(dirname $0))/.astylerc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ASTYLE_RC="$(cygpath -w $(realpath $(dirname $0)))/.astylerc"
|
||||||
|
|
||||||
|
echo "ASTYLE config file: $ASTYLE_RC"
|
||||||
|
|
||||||
# Check all args.
|
# Check all args.
|
||||||
for dir in "$@"; do
|
for dir in "$@"; do
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -41,502 +41,502 @@
|
||||||
|
|
||||||
|
|
||||||
FeedsModel::FeedsModel(QObject* parent) : QAbstractItemModel(parent) {
|
FeedsModel::FeedsModel(QObject* parent) : QAbstractItemModel(parent) {
|
||||||
setObjectName(QSL("FeedsModel"));
|
setObjectName(QSL("FeedsModel"));
|
||||||
// Create root item.
|
// Create root item.
|
||||||
m_rootItem = new RootItem();
|
m_rootItem = new RootItem();
|
||||||
// : Name of root item of feed list which can be seen in feed add/edit dialog.
|
// : Name of root item of feed list which can be seen in feed add/edit dialog.
|
||||||
m_rootItem->setTitle(tr("Root"));
|
m_rootItem->setTitle(tr("Root"));
|
||||||
m_rootItem->setIcon(qApp->icons()->fromTheme(QSL("folder")));
|
m_rootItem->setIcon(qApp->icons()->fromTheme(QSL("folder")));
|
||||||
// Setup icons.
|
// Setup icons.
|
||||||
m_countsIcon = qApp->icons()->fromTheme(QSL("mail-mark-unread"));
|
m_countsIcon = qApp->icons()->fromTheme(QSL("mail-mark-unread"));
|
||||||
// : Title text in the feed list header.
|
// : Title text in the feed list header.
|
||||||
m_headerData << tr("Title");
|
m_headerData << tr("Title");
|
||||||
m_tooltipData << /*: Feed list header "titles" column tooltip.*/ tr("Titles of feeds/categories.")
|
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.");
|
<< /*: Feed list header "counts" column tooltip.*/ tr("Counts of unread/all mesages.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FeedsModel::~FeedsModel() {
|
FeedsModel::~FeedsModel() {
|
||||||
qDebug("Destroying FeedsModel instance.");
|
qDebug("Destroying FeedsModel instance.");
|
||||||
// Delete all model items.
|
// Delete all model items.
|
||||||
delete m_rootItem;
|
delete m_rootItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMimeData* FeedsModel::mimeData(const QModelIndexList& indexes) const {
|
QMimeData* FeedsModel::mimeData(const QModelIndexList& indexes) const {
|
||||||
QMimeData* mime_data = new QMimeData();
|
QMimeData* mime_data = new QMimeData();
|
||||||
QByteArray encoded_data;
|
QByteArray encoded_data;
|
||||||
QDataStream stream(&encoded_data, QIODevice::WriteOnly);
|
QDataStream stream(&encoded_data, QIODevice::WriteOnly);
|
||||||
|
|
||||||
foreach (const QModelIndex &index, indexes) {
|
foreach (const QModelIndex& index, indexes) {
|
||||||
if (index.column() != 0) {
|
if (index.column() != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
RootItem* item_for_index = itemForIndex(index);
|
RootItem* item_for_index = itemForIndex(index);
|
||||||
|
|
||||||
if (item_for_index->kind() != RootItemKind::Root) {
|
if (item_for_index->kind() != RootItemKind::Root) {
|
||||||
stream << (quintptr)item_for_index;
|
stream << (quintptr) item_for_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mime_data->setData(QSL(MIME_TYPE_ITEM_POINTER), encoded_data);
|
mime_data->setData(QSL(MIME_TYPE_ITEM_POINTER), encoded_data);
|
||||||
return mime_data;
|
return mime_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList FeedsModel::mimeTypes() const {
|
QStringList FeedsModel::mimeTypes() const {
|
||||||
return QStringList() << QSL(MIME_TYPE_ITEM_POINTER);
|
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(row)
|
||||||
Q_UNUSED(column)
|
Q_UNUSED(column)
|
||||||
|
|
||||||
if (action == Qt::IgnoreAction) {
|
if (action == Qt::IgnoreAction) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (action != Qt::MoveAction) {
|
else if (action != Qt::MoveAction) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray dragged_items_data = data->data(QSL(MIME_TYPE_ITEM_POINTER));
|
QByteArray dragged_items_data = data->data(QSL(MIME_TYPE_ITEM_POINTER));
|
||||||
|
|
||||||
if (dragged_items_data.isEmpty()) {
|
if (dragged_items_data.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QDataStream stream(&dragged_items_data, QIODevice::ReadOnly);
|
QDataStream stream(&dragged_items_data, QIODevice::ReadOnly);
|
||||||
|
|
||||||
while (!stream.atEnd()) {
|
while (!stream.atEnd()) {
|
||||||
quintptr pointer_to_item;
|
quintptr pointer_to_item;
|
||||||
stream >> pointer_to_item;
|
stream >> pointer_to_item;
|
||||||
// We have item we want to drag, we also determine the target item.
|
// We have item we want to drag, we also determine the target item.
|
||||||
RootItem* dragged_item = (RootItem*)pointer_to_item;
|
RootItem* dragged_item = (RootItem*) pointer_to_item;
|
||||||
RootItem* target_item = itemForIndex(parent);
|
RootItem* target_item = itemForIndex(parent);
|
||||||
ServiceRoot* dragged_item_root = dragged_item->getParentServiceRoot();
|
ServiceRoot* dragged_item_root = dragged_item->getParentServiceRoot();
|
||||||
ServiceRoot* target_item_root = target_item->getParentServiceRoot();
|
ServiceRoot* target_item_root = target_item->getParentServiceRoot();
|
||||||
|
|
||||||
if (dragged_item == target_item || dragged_item->parent() == target_item) {
|
if (dragged_item == target_item || dragged_item->parent() == target_item) {
|
||||||
qDebug("Dragged item is equal to target item or its parent is equal to target item. Cancelling drag-drop action.");
|
qDebug("Dragged item is equal to target item or its parent is equal to target item. Cancelling drag-drop action.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dragged_item_root != target_item_root) {
|
if (dragged_item_root != target_item_root) {
|
||||||
// Transferring of items between different accounts is not possible.
|
// Transferring of items between different accounts is not possible.
|
||||||
qApp->showGuiMessage(tr("Cannot perform drag & drop operation"),
|
qApp->showGuiMessage(tr("Cannot perform drag & drop operation"),
|
||||||
tr("You can't transfer dragged item into different account, this is not supported."),
|
tr("You can't transfer dragged item into different account, this is not supported."),
|
||||||
QSystemTrayIcon::Warning,
|
QSystemTrayIcon::Warning,
|
||||||
qApp->mainFormWidget(),
|
qApp->mainFormWidget(),
|
||||||
true);
|
true);
|
||||||
qDebug("Dragged item cannot be dragged into different account. Cancelling drag-drop action.");
|
qDebug("Dragged item cannot be dragged into different account. Cancelling drag-drop action.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dragged_item->performDragDropChange(target_item)) {
|
if (dragged_item->performDragDropChange(target_item)) {
|
||||||
// Drag & drop is supported by the dragged item and was
|
// Drag & drop is supported by the dragged item and was
|
||||||
// completed on data level and in item hierarchy.
|
// completed on data level and in item hierarchy.
|
||||||
emit requireItemValidationAfterDragDrop(indexForItem(dragged_item));
|
emit requireItemValidationAfterDragDrop(indexForItem(dragged_item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::DropActions FeedsModel::supportedDropActions() const {
|
Qt::DropActions FeedsModel::supportedDropActions() const {
|
||||||
return Qt::MoveAction;
|
return Qt::MoveAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags FeedsModel::flags(const QModelIndex& index) const {
|
Qt::ItemFlags FeedsModel::flags(const QModelIndex& index) const {
|
||||||
Qt::ItemFlags base_flags = QAbstractItemModel::flags(index);
|
Qt::ItemFlags base_flags = QAbstractItemModel::flags(index);
|
||||||
const RootItem* item_for_index = itemForIndex(index);
|
const RootItem* item_for_index = itemForIndex(index);
|
||||||
Qt::ItemFlags additional_flags = item_for_index->additionalFlags();
|
Qt::ItemFlags additional_flags = item_for_index->additionalFlags();
|
||||||
return base_flags | additional_flags;
|
return base_flags | additional_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant FeedsModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
QVariant FeedsModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||||
if (orientation != Qt::Horizontal) {
|
if (orientation != Qt::Horizontal) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
if (section == FDS_MODEL_TITLE_INDEX) {
|
if (section == FDS_MODEL_TITLE_INDEX) {
|
||||||
return m_headerData.at(FDS_MODEL_TITLE_INDEX);
|
return m_headerData.at(FDS_MODEL_TITLE_INDEX);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
return m_tooltipData.at(section);
|
return m_tooltipData.at(section);
|
||||||
|
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
if (section == FDS_MODEL_COUNTS_INDEX) {
|
if (section == FDS_MODEL_COUNTS_INDEX) {
|
||||||
return m_countsIcon;
|
return m_countsIcon;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex FeedsModel::index(int row, int column, const QModelIndex& parent) const {
|
QModelIndex FeedsModel::index(int row, int column, const QModelIndex& parent) const {
|
||||||
if (!hasIndex(row, column, parent)) {
|
if (!hasIndex(row, column, parent)) {
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
RootItem* parent_item = itemForIndex(parent);
|
RootItem* parent_item = itemForIndex(parent);
|
||||||
RootItem* child_item = parent_item->child(row);
|
RootItem* child_item = parent_item->child(row);
|
||||||
|
|
||||||
if (child_item) {
|
if (child_item) {
|
||||||
return createIndex(row, column, child_item);
|
return createIndex(row, column, child_item);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex FeedsModel::parent(const QModelIndex& child) const {
|
QModelIndex FeedsModel::parent(const QModelIndex& child) const {
|
||||||
if (!child.isValid()) {
|
if (!child.isValid()) {
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
RootItem* child_item = itemForIndex(child);
|
RootItem* child_item = itemForIndex(child);
|
||||||
RootItem* parent_item = child_item->parent();
|
RootItem* parent_item = child_item->parent();
|
||||||
|
|
||||||
if (parent_item == m_rootItem) {
|
if (parent_item == m_rootItem) {
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return createIndex(parent_item->row(), 0, parent_item);
|
return createIndex(parent_item->row(), 0, parent_item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FeedsModel::rowCount(const QModelIndex& parent) const {
|
int FeedsModel::rowCount(const QModelIndex& parent) const {
|
||||||
if (parent.column() > 0) {
|
if (parent.column() > 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return itemForIndex(parent)->childCount();
|
return itemForIndex(parent)->childCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FeedsModel::countOfAllMessages() const {
|
int FeedsModel::countOfAllMessages() const {
|
||||||
return m_rootItem->countOfAllMessages();
|
return m_rootItem->countOfAllMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
int FeedsModel::countOfUnreadMessages() const {
|
int FeedsModel::countOfUnreadMessages() const {
|
||||||
return m_rootItem->countOfUnreadMessages();
|
return m_rootItem->countOfUnreadMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::reloadCountsOfWholeModel() {
|
void FeedsModel::reloadCountsOfWholeModel() {
|
||||||
m_rootItem->updateCounts(true);
|
m_rootItem->updateCounts(true);
|
||||||
reloadWholeLayout();
|
reloadWholeLayout();
|
||||||
notifyWithCounts();
|
notifyWithCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::removeItem(const QModelIndex& index) {
|
void FeedsModel::removeItem(const QModelIndex& index) {
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
RootItem* deleting_item = itemForIndex(index);
|
RootItem* deleting_item = itemForIndex(index);
|
||||||
QModelIndex parent_index = index.parent();
|
QModelIndex parent_index = index.parent();
|
||||||
RootItem* parent_item = deleting_item->parent();
|
RootItem* parent_item = deleting_item->parent();
|
||||||
beginRemoveRows(parent_index, index.row(), index.row());
|
beginRemoveRows(parent_index, index.row(), index.row());
|
||||||
parent_item->removeChild(deleting_item);
|
parent_item->removeChild(deleting_item);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
deleting_item->deleteLater();
|
deleting_item->deleteLater();
|
||||||
notifyWithCounts();
|
notifyWithCounts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::removeItem(RootItem* deleting_item) {
|
void FeedsModel::removeItem(RootItem* deleting_item) {
|
||||||
if (deleting_item != nullptr) {
|
if (deleting_item != nullptr) {
|
||||||
QModelIndex index = indexForItem(deleting_item);
|
QModelIndex index = indexForItem(deleting_item);
|
||||||
QModelIndex parent_index = index.parent();
|
QModelIndex parent_index = index.parent();
|
||||||
RootItem* parent_item = deleting_item->parent();
|
RootItem* parent_item = deleting_item->parent();
|
||||||
beginRemoveRows(parent_index, index.row(), index.row());
|
beginRemoveRows(parent_index, index.row(), index.row());
|
||||||
parent_item->removeChild(deleting_item);
|
parent_item->removeChild(deleting_item);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
deleting_item->deleteLater();
|
deleting_item->deleteLater();
|
||||||
notifyWithCounts();
|
notifyWithCounts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::reassignNodeToNewParent(RootItem* original_node, RootItem* new_parent) {
|
void FeedsModel::reassignNodeToNewParent(RootItem* original_node, RootItem* new_parent) {
|
||||||
RootItem* original_parent = original_node->parent();
|
RootItem* original_parent = original_node->parent();
|
||||||
|
|
||||||
if (original_parent != new_parent) {
|
if (original_parent != new_parent) {
|
||||||
if (original_parent != nullptr) {
|
if (original_parent != nullptr) {
|
||||||
int original_index_of_item = original_parent->childItems().indexOf(original_node);
|
int original_index_of_item = original_parent->childItems().indexOf(original_node);
|
||||||
|
|
||||||
if (original_index_of_item >= 0) {
|
if (original_index_of_item >= 0) {
|
||||||
// Remove the original item from the model...
|
// Remove the original item from the model...
|
||||||
beginRemoveRows(indexForItem(original_parent), original_index_of_item, original_index_of_item);
|
beginRemoveRows(indexForItem(original_parent), original_index_of_item, original_index_of_item);
|
||||||
original_parent->removeChild(original_node);
|
original_parent->removeChild(original_node);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int new_index_of_item = new_parent->childCount();
|
int new_index_of_item = new_parent->childCount();
|
||||||
// ... and insert it under the new parent.
|
// ... and insert it under the new parent.
|
||||||
beginInsertRows(indexForItem(new_parent), new_index_of_item, new_index_of_item);
|
beginInsertRows(indexForItem(new_parent), new_index_of_item, new_index_of_item);
|
||||||
new_parent->appendChild(original_node);
|
new_parent->appendChild(original_node);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ServiceRoot*> FeedsModel::serviceRoots() const {
|
QList<ServiceRoot*>FeedsModel::serviceRoots() const {
|
||||||
QList<ServiceRoot*> roots;
|
QList<ServiceRoot*>roots;
|
||||||
|
|
||||||
foreach (RootItem* root, m_rootItem->childItems()) {
|
foreach (RootItem* root, m_rootItem->childItems()) {
|
||||||
if (root->kind() == RootItemKind::ServiceRoot) {
|
if (root->kind() == RootItemKind::ServiceRoot) {
|
||||||
roots.append(root->toServiceRoot());
|
roots.append(root->toServiceRoot());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return roots;
|
return roots;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FeedsModel::containsServiceRootFromEntryPoint(const ServiceEntryPoint* point) const {
|
bool FeedsModel::containsServiceRootFromEntryPoint(const ServiceEntryPoint* point) const {
|
||||||
foreach (const ServiceRoot* root, serviceRoots()) {
|
foreach (const ServiceRoot* root, serviceRoots()) {
|
||||||
if (root->code() == point->code()) {
|
if (root->code() == point->code()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
StandardServiceRoot* FeedsModel::standardServiceRoot() const {
|
StandardServiceRoot* FeedsModel::standardServiceRoot() const {
|
||||||
foreach (ServiceRoot* root, serviceRoots()) {
|
foreach (ServiceRoot* root, serviceRoots()) {
|
||||||
StandardServiceRoot* std_service_root;
|
StandardServiceRoot* std_service_root;
|
||||||
|
|
||||||
if ((std_service_root = dynamic_cast<StandardServiceRoot*>(root)) != nullptr) {
|
if ((std_service_root = dynamic_cast<StandardServiceRoot*>(root)) != nullptr) {
|
||||||
return std_service_root;
|
return std_service_root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Feed*> FeedsModel::feedsForScheduledUpdate(bool auto_update_now) {
|
QList<Feed*>FeedsModel::feedsForScheduledUpdate(bool auto_update_now) {
|
||||||
QList<Feed*> feeds_for_update;
|
QList<Feed*>feeds_for_update;
|
||||||
|
|
||||||
foreach (Feed* feed, m_rootItem->getSubTreeFeeds()) {
|
foreach (Feed* feed, m_rootItem->getSubTreeFeeds()) {
|
||||||
switch (feed->autoUpdateType()) {
|
switch (feed->autoUpdateType()) {
|
||||||
case Feed::DontAutoUpdate:
|
case Feed::DontAutoUpdate:
|
||||||
// Do not auto-update this feed ever.
|
// Do not auto-update this feed ever.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case Feed::DefaultAutoUpdate:
|
case Feed::DefaultAutoUpdate:
|
||||||
if (auto_update_now) {
|
if (auto_update_now) {
|
||||||
feeds_for_update.append(feed);
|
feeds_for_update.append(feed);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Feed::SpecificAutoUpdate:
|
case Feed::SpecificAutoUpdate:
|
||||||
default:
|
default:
|
||||||
int remaining_interval = feed->autoUpdateRemainingInterval();
|
int remaining_interval = feed->autoUpdateRemainingInterval();
|
||||||
|
|
||||||
if (--remaining_interval <= 0) {
|
if (--remaining_interval <= 0) {
|
||||||
// Interval of this feed passed, include this feed in the output list
|
// Interval of this feed passed, include this feed in the output list
|
||||||
// and reset the interval.
|
// and reset the interval.
|
||||||
feeds_for_update.append(feed);
|
feeds_for_update.append(feed);
|
||||||
feed->setAutoUpdateRemainingInterval(feed->autoUpdateInitialInterval());
|
feed->setAutoUpdateRemainingInterval(feed->autoUpdateInitialInterval());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Interval did not pass, set new decremented interval and do NOT
|
// Interval did not pass, set new decremented interval and do NOT
|
||||||
// include this feed in the output list.
|
// include this feed in the output list.
|
||||||
feed->setAutoUpdateRemainingInterval(remaining_interval);
|
feed->setAutoUpdateRemainingInterval(remaining_interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return feeds_for_update;
|
return feeds_for_update;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Message> FeedsModel::messagesForItem(RootItem* item) const {
|
QList<Message>FeedsModel::messagesForItem(RootItem* item) const {
|
||||||
return item->undeletedMessages();
|
return item->undeletedMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
int FeedsModel::columnCount(const QModelIndex& parent) const {
|
int FeedsModel::columnCount(const QModelIndex& parent) const {
|
||||||
Q_UNUSED(parent)
|
Q_UNUSED(parent)
|
||||||
return FEEDS_VIEW_COLUMN_COUNT;
|
return FEEDS_VIEW_COLUMN_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
RootItem* FeedsModel::itemForIndex(const QModelIndex& index) const {
|
RootItem* FeedsModel::itemForIndex(const QModelIndex& index) const {
|
||||||
if (index.isValid() && index.model() == this) {
|
if (index.isValid() && index.model() == this) {
|
||||||
return static_cast<RootItem*>(index.internalPointer());
|
return static_cast<RootItem*>(index.internalPointer());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return m_rootItem;
|
return m_rootItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex FeedsModel::indexForItem(const RootItem* item) const {
|
QModelIndex FeedsModel::indexForItem(const RootItem* item) const {
|
||||||
if (item == nullptr || item->kind() == RootItemKind::Root) {
|
if (item == nullptr || item->kind() == RootItemKind::Root) {
|
||||||
// Root item lies on invalid index.
|
// Root item lies on invalid index.
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStack<const RootItem*> chain;
|
QStack<const RootItem*>chain;
|
||||||
|
|
||||||
while (item->kind() != RootItemKind::Root) {
|
while (item->kind() != RootItemKind::Root) {
|
||||||
chain.push(item);
|
chain.push(item);
|
||||||
item = item->parent();
|
item = item->parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now, we have complete chain list: parent --- ..... --- parent --- leaf (item).
|
// Now, we have complete chain list: parent --- ..... --- parent --- leaf (item).
|
||||||
QModelIndex target_index = indexForItem(m_rootItem);
|
QModelIndex target_index = indexForItem(m_rootItem);
|
||||||
|
|
||||||
// We go through the stack and create our target index.
|
// We go through the stack and create our target index.
|
||||||
while (!chain.isEmpty()) {
|
while (!chain.isEmpty()) {
|
||||||
const RootItem* parent_item = chain.pop();
|
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;
|
return target_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FeedsModel::hasAnyFeedNewMessages() const {
|
bool FeedsModel::hasAnyFeedNewMessages() const {
|
||||||
foreach (const Feed * feed, m_rootItem->getSubTreeFeeds()) {
|
foreach (const Feed* feed, m_rootItem->getSubTreeFeeds()) {
|
||||||
if (feed->status() == Feed::NewMessages) {
|
if (feed->status() == Feed::NewMessages) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RootItem* FeedsModel::rootItem() const {
|
RootItem* FeedsModel::rootItem() const {
|
||||||
return m_rootItem;
|
return m_rootItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::reloadChangedLayout(QModelIndexList list) {
|
void FeedsModel::reloadChangedLayout(QModelIndexList list) {
|
||||||
while (!list.isEmpty()) {
|
while (!list.isEmpty()) {
|
||||||
QModelIndex indx = list.takeFirst();
|
QModelIndex indx = list.takeFirst();
|
||||||
|
|
||||||
if (indx.isValid()) {
|
if (indx.isValid()) {
|
||||||
QModelIndex indx_parent = indx.parent();
|
QModelIndex indx_parent = indx.parent();
|
||||||
// Underlying data are changed.
|
// Underlying data are changed.
|
||||||
emit dataChanged(index(indx.row(), 0, indx_parent), index(indx.row(), FDS_MODEL_COUNTS_INDEX, indx_parent));
|
emit dataChanged(index(indx.row(), 0, indx_parent), index(indx.row(), FDS_MODEL_COUNTS_INDEX, indx_parent));
|
||||||
list.append(indx_parent);
|
list.append(indx_parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::reloadChangedItem(RootItem* item) {
|
void FeedsModel::reloadChangedItem(RootItem* item) {
|
||||||
QModelIndex index_item = indexForItem(item);
|
QModelIndex index_item = indexForItem(item);
|
||||||
reloadChangedLayout(QModelIndexList() << index_item);
|
reloadChangedLayout(QModelIndexList() << index_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::notifyWithCounts() {
|
void FeedsModel::notifyWithCounts() {
|
||||||
emit messageCountsChanged(countOfUnreadMessages(), hasAnyFeedNewMessages());
|
emit messageCountsChanged(countOfUnreadMessages(), hasAnyFeedNewMessages());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::onItemDataChanged(const QList<RootItem*>& items) {
|
void FeedsModel::onItemDataChanged(const QList<RootItem*>& items) {
|
||||||
if (items.size() > RELOAD_MODEL_BORDER_NUM) {
|
if (items.size() > RELOAD_MODEL_BORDER_NUM) {
|
||||||
qDebug("There is request to reload feed model for more than %d items, reloading model fully.", RELOAD_MODEL_BORDER_NUM);
|
qDebug("There is request to reload feed model for more than %d items, reloading model fully.", RELOAD_MODEL_BORDER_NUM);
|
||||||
reloadWholeLayout();
|
reloadWholeLayout();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug("There is request to reload feed model, reloading the %d items individually.", items.size());
|
qDebug("There is request to reload feed model, reloading the %d items individually.", items.size());
|
||||||
|
|
||||||
foreach (RootItem * item, items) {
|
foreach (RootItem* item, items) {
|
||||||
reloadChangedItem(item);
|
reloadChangedItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyWithCounts();
|
notifyWithCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::reloadWholeLayout() {
|
void FeedsModel::reloadWholeLayout() {
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FeedsModel::addServiceAccount(ServiceRoot* root, bool freshly_activated) {
|
bool FeedsModel::addServiceAccount(ServiceRoot* root, bool freshly_activated) {
|
||||||
int new_row_index = m_rootItem->childCount();
|
int new_row_index = m_rootItem->childCount();
|
||||||
beginInsertRows(indexForItem(m_rootItem), new_row_index, new_row_index);
|
beginInsertRows(indexForItem(m_rootItem), new_row_index, new_row_index);
|
||||||
m_rootItem->appendChild(root);
|
m_rootItem->appendChild(root);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
// Connect.
|
// Connect.
|
||||||
connect(root, &ServiceRoot::itemRemovalRequested, this, static_cast<void (FeedsModel::*)(RootItem*)>(&FeedsModel::removeItem));
|
connect(root, &ServiceRoot::itemRemovalRequested, this, static_cast<void (FeedsModel::*)(RootItem*)>(&FeedsModel::removeItem));
|
||||||
connect(root, &ServiceRoot::itemReassignmentRequested, this, &FeedsModel::reassignNodeToNewParent);
|
connect(root, &ServiceRoot::itemReassignmentRequested, this, &FeedsModel::reassignNodeToNewParent);
|
||||||
connect(root, &ServiceRoot::dataChanged, this, &FeedsModel::onItemDataChanged);
|
connect(root, &ServiceRoot::dataChanged, this, &FeedsModel::onItemDataChanged);
|
||||||
connect(root, &ServiceRoot::reloadMessageListRequested, this, &FeedsModel::reloadMessageListRequested);
|
connect(root, &ServiceRoot::reloadMessageListRequested, this, &FeedsModel::reloadMessageListRequested);
|
||||||
connect(root, &ServiceRoot::itemExpandRequested, this, &FeedsModel::itemExpandRequested);
|
connect(root, &ServiceRoot::itemExpandRequested, this, &FeedsModel::itemExpandRequested);
|
||||||
connect(root, &ServiceRoot::itemExpandStateSaveRequested, this, &FeedsModel::itemExpandStateSaveRequested);
|
connect(root, &ServiceRoot::itemExpandStateSaveRequested, this, &FeedsModel::itemExpandStateSaveRequested);
|
||||||
root->start(freshly_activated);
|
root->start(freshly_activated);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FeedsModel::restoreAllBins() {
|
bool FeedsModel::restoreAllBins() {
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
foreach (ServiceRoot * root, serviceRoots()) {
|
foreach (ServiceRoot* root, serviceRoots()) {
|
||||||
RecycleBin* bin_of_root = root->recycleBin();
|
RecycleBin* bin_of_root = root->recycleBin();
|
||||||
|
|
||||||
if (bin_of_root != nullptr) {
|
if (bin_of_root != nullptr) {
|
||||||
result &= bin_of_root->restore();
|
result &= bin_of_root->restore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FeedsModel::emptyAllBins() {
|
bool FeedsModel::emptyAllBins() {
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
foreach (ServiceRoot * root, serviceRoots()) {
|
foreach (ServiceRoot* root, serviceRoots()) {
|
||||||
RecycleBin* bin_of_root = root->recycleBin();
|
RecycleBin* bin_of_root = root->recycleBin();
|
||||||
|
|
||||||
if (bin_of_root != nullptr) {
|
if (bin_of_root != nullptr) {
|
||||||
result &= bin_of_root->empty();
|
result &= bin_of_root->empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::loadActivatedServiceAccounts() {
|
void FeedsModel::loadActivatedServiceAccounts() {
|
||||||
// Iterate all globally available feed "service plugins".
|
// Iterate all globally available feed "service plugins".
|
||||||
foreach (const ServiceEntryPoint* entry_point, qApp->feedReader()->feedServices()) {
|
foreach (const ServiceEntryPoint* entry_point, qApp->feedReader()->feedServices()) {
|
||||||
// Load all stored root nodes from the entry point and add those to the model.
|
// Load all stored root nodes from the entry point and add those to the model.
|
||||||
QList<ServiceRoot*> roots = entry_point->initializeSubtree();
|
QList<ServiceRoot*>roots = entry_point->initializeSubtree();
|
||||||
|
|
||||||
foreach (ServiceRoot* root, roots) {
|
foreach (ServiceRoot* root, roots) {
|
||||||
addServiceAccount(root, false);
|
addServiceAccount(root, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serviceRoots().isEmpty()) {
|
if (serviceRoots().isEmpty()) {
|
||||||
QTimer::singleShot(2000, [this]() {
|
QTimer::singleShot(2000, [this]() {
|
||||||
addServiceAccount(StandardServiceEntryPoint().createNewRoot(), true);
|
addServiceAccount(StandardServiceEntryPoint().createNewRoot(), true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::stopServiceAccounts() {
|
void FeedsModel::stopServiceAccounts() {
|
||||||
foreach (ServiceRoot * account, serviceRoots()) {
|
foreach (ServiceRoot* account, serviceRoots()) {
|
||||||
account->stop();
|
account->stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Feed*> FeedsModel::feedsForIndex(const QModelIndex& index) const {
|
QList<Feed*>FeedsModel::feedsForIndex(const QModelIndex& index) const {
|
||||||
return itemForIndex(index)->getSubTreeFeeds();
|
return itemForIndex(index)->getSubTreeFeeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FeedsModel::markItemRead(RootItem* item, RootItem::ReadStatus read) {
|
bool FeedsModel::markItemRead(RootItem* item, RootItem::ReadStatus read) {
|
||||||
return item->markAsReadUnread(read);
|
return item->markAsReadUnread(read);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FeedsModel::markItemCleared(RootItem* item, bool clean_read_only) {
|
bool FeedsModel::markItemCleared(RootItem* item, bool clean_read_only) {
|
||||||
return item->cleanMessages(clean_read_only);
|
return item->cleanMessages(clean_read_only);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ class FeedsModel : public QAbstractItemModel {
|
||||||
// Returns all activated service roots.
|
// Returns all activated service roots.
|
||||||
// NOTE: Service root nodes are lying directly UNDER
|
// NOTE: Service root nodes are lying directly UNDER
|
||||||
// the model root item.
|
// the model root item.
|
||||||
QList<ServiceRoot*> serviceRoots() const;
|
QList<ServiceRoot*>serviceRoots() const;
|
||||||
|
|
||||||
// Determines if there is any account activated from given entry point.
|
// Determines if there is any account activated from given entry point.
|
||||||
bool containsServiceRootFromEntryPoint(const ServiceEntryPoint* point) const;
|
bool containsServiceRootFromEntryPoint(const ServiceEntryPoint* point) const;
|
||||||
|
|
@ -79,15 +79,15 @@ class FeedsModel : public QAbstractItemModel {
|
||||||
// so feeds with "default" auto-update strategy should be updated.
|
// so feeds with "default" auto-update strategy should be updated.
|
||||||
//
|
//
|
||||||
// This method might change some properties of some feeds.
|
// This method might change some properties of some feeds.
|
||||||
QList<Feed*> feedsForScheduledUpdate(bool auto_update_now);
|
QList<Feed*>feedsForScheduledUpdate(bool auto_update_now);
|
||||||
|
|
||||||
// Returns (undeleted) messages for given feeds.
|
// Returns (undeleted) messages for given feeds.
|
||||||
// This is usually used for displaying whole feeds
|
// This is usually used for displaying whole feeds
|
||||||
// in "newspaper" mode.
|
// in "newspaper" mode.
|
||||||
QList<Message> messagesForItem(RootItem* item) const;
|
QList<Message>messagesForItem(RootItem* item) const;
|
||||||
|
|
||||||
// Returns ALL RECURSIVE CHILD feeds contained within single index.
|
// Returns ALL RECURSIVE CHILD feeds contained within single index.
|
||||||
QList<Feed*> feedsForIndex(const QModelIndex& index) const;
|
QList<Feed*>feedsForIndex(const QModelIndex& index) const;
|
||||||
|
|
||||||
// Returns feed/category which lies at the specified index or
|
// Returns feed/category which lies at the specified index or
|
||||||
// root item if index is invalid.
|
// root item if index is invalid.
|
||||||
|
|
@ -159,7 +159,7 @@ class FeedsModel : public QAbstractItemModel {
|
||||||
void messageCountsChanged(int unread_messages, bool any_feed_has_unread_messages);
|
void messageCountsChanged(int unread_messages, bool any_feed_has_unread_messages);
|
||||||
|
|
||||||
// Emitted if any item requested that any view should expand it.
|
// Emitted if any item requested that any view should expand it.
|
||||||
void itemExpandRequested(QList<RootItem*> items, bool expand);
|
void itemExpandRequested(QList<RootItem*>items, bool expand);
|
||||||
|
|
||||||
// Emitted if any item requested that its expand states should be explicitly saved.
|
// Emitted if any item requested that its expand states should be explicitly saved.
|
||||||
// NOTE: Normally expand states are saved when application quits.
|
// NOTE: Normally expand states are saved when application quits.
|
||||||
|
|
@ -174,8 +174,8 @@ class FeedsModel : public QAbstractItemModel {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RootItem* m_rootItem;
|
RootItem* m_rootItem;
|
||||||
QList<QString> m_headerData;
|
QList<QString>m_headerData;
|
||||||
QList<QString> m_tooltipData;
|
QList<QString>m_tooltipData;
|
||||||
QIcon m_countsIcon;
|
QIcon m_countsIcon;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
#define ID_RECYCLE_BIN -2
|
#define ID_RECYCLE_BIN -2
|
||||||
#define TRAY_ICON_BUBBLE_TIMEOUT 20000
|
#define TRAY_ICON_BUBBLE_TIMEOUT 20000
|
||||||
#define CLOSE_LOCK_TIMEOUT 500
|
#define CLOSE_LOCK_TIMEOUT 500
|
||||||
#define DOWNLOAD_TIMEOUT 5000
|
#define DOWNLOAD_TIMEOUT 15000
|
||||||
#define MESSAGES_VIEW_DEFAULT_COL 170
|
#define MESSAGES_VIEW_DEFAULT_COL 170
|
||||||
#define MESSAGES_VIEW_MINIMUM_COL 36
|
#define MESSAGES_VIEW_MINIMUM_COL 36
|
||||||
#define FEEDS_VIEW_COLUMN_COUNT 2
|
#define FEEDS_VIEW_COLUMN_COUNT 2
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@
|
||||||
<number>100</number>
|
<number>100</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>45000</number>
|
<number>120000</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="singleStep">
|
<property name="singleStep">
|
||||||
<number>100</number>
|
<number>100</number>
|
||||||
|
|
|
||||||
|
|
@ -139,8 +139,8 @@ int main(int argc, char* argv[]) {
|
||||||
QObject::connect(qApp->system(), &SystemFactory::updatesChecked, [](QPair<QList<UpdateInfo>, QNetworkReply::NetworkError> updates) {
|
QObject::connect(qApp->system(), &SystemFactory::updatesChecked, [](QPair<QList<UpdateInfo>, QNetworkReply::NetworkError> updates) {
|
||||||
QObject::disconnect(qApp->system(), &SystemFactory::updatesChecked, nullptr, nullptr);
|
QObject::disconnect(qApp->system(), &SystemFactory::updatesChecked, nullptr, nullptr);
|
||||||
|
|
||||||
if (!updates.first.isEmpty() && updates.second == QNetworkReply::NoError &&
|
if (!updates.first.isEmpty() && updates.second == QNetworkReply::NoError &&
|
||||||
SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, APP_VERSION)) {
|
SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, APP_VERSION)) {
|
||||||
qApp->showGuiMessage(QObject::tr("New version available"),
|
qApp->showGuiMessage(QObject::tr("New version available"),
|
||||||
QObject::tr("Click the bubble for more information."),
|
QObject::tr("Click the bubble for more information."),
|
||||||
QSystemTrayIcon::Information, qApp->mainForm(), false,
|
QSystemTrayIcon::Information, qApp->mainForm(), false,
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ SystemFactory::AutoStartStatus SystemFactory::autoStartStatus() const {
|
||||||
// No correct path was found.
|
// No correct path was found.
|
||||||
if (desktop_file_location.isEmpty()) {
|
if (desktop_file_location.isEmpty()) {
|
||||||
qWarning("Searching for auto-start function status failed. HOME variable not found.");
|
qWarning("Searching for auto-start function status failed. HOME variable not found.");
|
||||||
return AutoStartStatus::Unavailable;
|
return AutoStartStatus::Unavailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We found correct path, now check if file exists and return correct status.
|
// We found correct path, now check if file exists and return correct status.
|
||||||
|
|
@ -79,15 +79,15 @@ SystemFactory::AutoStartStatus SystemFactory::autoStartStatus() const {
|
||||||
// File exists, we must read it and check if "Hidden" attribute is defined and what is its value.
|
// File exists, we must read it and check if "Hidden" attribute is defined and what is its value.
|
||||||
QSettings desktop_settings(desktop_file_location, QSettings::IniFormat);
|
QSettings desktop_settings(desktop_file_location, QSettings::IniFormat);
|
||||||
bool hidden_value = desktop_settings.value(QSL("Desktop Entry/Hidden"), false).toBool();
|
bool hidden_value = desktop_settings.value(QSL("Desktop Entry/Hidden"), false).toBool();
|
||||||
return hidden_value ? AutoStartStatus::Disabled : AutoStartStatus::Enabled;
|
return hidden_value ? AutoStartStatus::Disabled : AutoStartStatus::Enabled;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return AutoStartStatus::Disabled;
|
return AutoStartStatus::Disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// Disable auto-start functionality on unsupported platforms.
|
// Disable auto-start functionality on unsupported platforms.
|
||||||
return AutoStartStatus::Unavailable;
|
return AutoStartStatus::Unavailable;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,7 +216,7 @@ void SystemFactory::checkForUpdates() const {
|
||||||
|
|
||||||
emit updatesChecked(result);
|
emit updatesChecked(result);
|
||||||
downloader->deleteLater();
|
downloader->deleteLater();
|
||||||
});
|
});
|
||||||
downloader->downloadFile(RELEASES_LIST);
|
downloader->downloadFile(RELEASES_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
class UpdateUrl {
|
class UpdateUrl {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QString m_fileUrl;
|
QString m_fileUrl;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_size;
|
QString m_size;
|
||||||
|
|
@ -37,10 +38,12 @@ class UpdateUrl {
|
||||||
|
|
||||||
class UpdateInfo {
|
class UpdateInfo {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QString m_availableVersion;
|
QString m_availableVersion;
|
||||||
QString m_changes;
|
QString m_changes;
|
||||||
QList<UpdateUrl> m_urls;
|
|
||||||
QDateTime m_date;
|
QDateTime m_date;
|
||||||
|
|
||||||
|
QList<UpdateUrl> m_urls;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(UpdateInfo)
|
Q_DECLARE_METATYPE(UpdateInfo)
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,10 @@ Q_GLOBAL_STATIC(AdBlockManager, qz_adblock_manager)
|
||||||
|
|
||||||
|
|
||||||
AdBlockManager::AdBlockManager(QObject* parent)
|
AdBlockManager::AdBlockManager(QObject* parent)
|
||||||
: QObject(parent), m_loaded(false), m_enabled(true), m_matcher(new AdBlockMatcher(this)), m_interceptor(new AdBlockUrlInterceptor(this)) {
|
: QObject(parent), m_loaded(false), m_enabled(true), m_matcher(new AdBlockMatcher(this)), m_interceptor(new AdBlockUrlInterceptor(this)) {
|
||||||
load();
|
load();
|
||||||
m_adblockIcon = new AdBlockIcon(this);
|
m_adblockIcon = new AdBlockIcon(this);
|
||||||
m_adblockIcon->setObjectName(QSL("m_adblockIconAction"));
|
m_adblockIcon->setObjectName(QSL("m_adblockIconAction"));
|
||||||
}
|
}
|
||||||
|
|
||||||
AdBlockManager::~AdBlockManager() {
|
AdBlockManager::~AdBlockManager() {
|
||||||
|
|
|
||||||
|
|
@ -177,11 +177,11 @@ void WebFactory::createMenu(QMenu* menu) {
|
||||||
actions << createEngineSettingsAction(tr("Plugins enabled"), QWebEngineSettings::PluginsEnabled);
|
actions << createEngineSettingsAction(tr("Plugins enabled"), QWebEngineSettings::PluginsEnabled);
|
||||||
actions << createEngineSettingsAction(tr("Fullscreen enabled"), QWebEngineSettings::FullScreenSupportEnabled);
|
actions << createEngineSettingsAction(tr("Fullscreen enabled"), QWebEngineSettings::FullScreenSupportEnabled);
|
||||||
#if !defined(Q_OS_LINUX)
|
#if !defined(Q_OS_LINUX)
|
||||||
actions << createEngineSettingsAction(tr("Screen capture enabled"), QWebEngineSettings::ScreenCaptureEnabled);
|
actions << createEngineSettingsAction(tr("Screen capture enabled"), QWebEngineSettings::ScreenCaptureEnabled);
|
||||||
actions << createEngineSettingsAction(tr("WebGL enabled"), QWebEngineSettings::WebGLEnabled);
|
actions << createEngineSettingsAction(tr("WebGL enabled"), QWebEngineSettings::WebGLEnabled);
|
||||||
actions << createEngineSettingsAction(tr("Accelerate 2D canvas"), QWebEngineSettings::Accelerated2dCanvasEnabled);
|
actions << createEngineSettingsAction(tr("Accelerate 2D canvas"), QWebEngineSettings::Accelerated2dCanvasEnabled);
|
||||||
actions << createEngineSettingsAction(tr("Print element backgrounds"), QWebEngineSettings::PrintElementBackgrounds);
|
actions << createEngineSettingsAction(tr("Print element backgrounds"), QWebEngineSettings::PrintElementBackgrounds);
|
||||||
actions << createEngineSettingsAction(tr("Allow running insecure content"), QWebEngineSettings::AllowRunningInsecureContent);
|
actions << createEngineSettingsAction(tr("Allow running insecure content"), QWebEngineSettings::AllowRunningInsecureContent);
|
||||||
actions << createEngineSettingsAction(tr("Allow geolocation on insecure origins"), QWebEngineSettings::AllowGeolocationOnInsecureOrigins);
|
actions << createEngineSettingsAction(tr("Allow geolocation on insecure origins"), QWebEngineSettings::AllowGeolocationOnInsecureOrigins);
|
||||||
#endif
|
#endif
|
||||||
menu->addActions(actions);
|
menu->addActions(actions);
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,7 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::markMessagesStarred(RootItem
|
||||||
const QStringList& feed_ids,
|
const QStringList& feed_ids,
|
||||||
const QStringList& guid_hashes) {
|
const QStringList& guid_hashes) {
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
QJsonArray ids;
|
QJsonArray ids;
|
||||||
QByteArray raw_output;
|
QByteArray raw_output;
|
||||||
QString final_url;
|
QString final_url;
|
||||||
|
|
||||||
|
|
@ -482,7 +482,7 @@ OwnCloudGetFeedsCategoriesResponse::~OwnCloudGetFeedsCategoriesResponse() {
|
||||||
|
|
||||||
RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons) const {
|
RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons) const {
|
||||||
RootItem* parent = new RootItem();
|
RootItem* parent = new RootItem();
|
||||||
QMap<int, RootItem*> cats;
|
QMap<int, RootItem*>cats;
|
||||||
cats.insert(0, parent);
|
cats.insert(0, parent);
|
||||||
|
|
||||||
// Process categories first, then process feeds.
|
// Process categories first, then process feeds.
|
||||||
|
|
@ -535,8 +535,8 @@ OwnCloudGetMessagesResponse::OwnCloudGetMessagesResponse(const QString& raw_cont
|
||||||
OwnCloudGetMessagesResponse::~OwnCloudGetMessagesResponse() {
|
OwnCloudGetMessagesResponse::~OwnCloudGetMessagesResponse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Message> OwnCloudGetMessagesResponse::messages() const {
|
QList<Message>OwnCloudGetMessagesResponse::messages() const {
|
||||||
QList<Message> msgs;
|
QList<Message>msgs;
|
||||||
|
|
||||||
foreach (const QJsonValue& message, m_rawContent["items"].toArray()) {
|
foreach (const QJsonValue& message, m_rawContent["items"].toArray()) {
|
||||||
QJsonObject message_map = message.toObject();
|
QJsonObject message_map = message.toObject();
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ QList<Message> FeedParser::messages() {
|
||||||
messages.append(new_message);
|
messages.append(new_message);
|
||||||
}
|
}
|
||||||
catch (const ApplicationException& ex) {
|
catch (const ApplicationException& ex) {
|
||||||
qDebug() << ex.message();
|
qDebug() << ex.message();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return messages;
|
return messages;
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,8 @@
|
||||||
|
|
||||||
StandardServiceRoot::StandardServiceRoot(RootItem* parent)
|
StandardServiceRoot::StandardServiceRoot(RootItem* parent)
|
||||||
: ServiceRoot(parent), m_recycleBin(new RecycleBin(this)),
|
: ServiceRoot(parent), m_recycleBin(new RecycleBin(this)),
|
||||||
m_actionExportFeeds(nullptr), m_actionImportFeeds(nullptr), m_serviceMenu(QList<QAction*>()),
|
m_actionExportFeeds(nullptr), m_actionImportFeeds(nullptr), m_serviceMenu(QList<QAction*>()),
|
||||||
m_feedContextMenu(QList<QAction*>()), m_actionFeedFetchMetadata(nullptr) {
|
m_feedContextMenu(QList<QAction*>()), m_actionFeedFetchMetadata(nullptr) {
|
||||||
setTitle(qApp->system()->loggedInUser() + QL1S("@") + QL1S(APP_LOW_NAME));
|
setTitle(qApp->system()->loggedInUser() + QL1S("@") + QL1S(APP_LOW_NAME));
|
||||||
setIcon(StandardServiceEntryPoint().icon());
|
setIcon(StandardServiceEntryPoint().icon());
|
||||||
setDescription(tr("This is obligatory service account for standard RSS/RDF/ATOM feeds."));
|
setDescription(tr("This is obligatory service account for standard RSS/RDF/ATOM feeds."));
|
||||||
|
|
@ -59,7 +59,7 @@ StandardServiceRoot::~StandardServiceRoot() {
|
||||||
void StandardServiceRoot::start(bool freshly_activated) {
|
void StandardServiceRoot::start(bool freshly_activated) {
|
||||||
loadFromDatabase();
|
loadFromDatabase();
|
||||||
|
|
||||||
if (freshly_activated && getSubTree(RootItemKind::Feed).isEmpty()) {
|
if (freshly_activated && getSubTree(RootItemKind::Feed).isEmpty()) {
|
||||||
// In other words, if there are no feeds or categories added.
|
// In other words, if there are no feeds or categories added.
|
||||||
if (MessageBox::show(qApp->mainFormWidget(), QMessageBox::Question, QObject::tr("Load initial set of feeds"),
|
if (MessageBox::show(qApp->mainFormWidget(), QMessageBox::Question, QObject::tr("Load initial set of feeds"),
|
||||||
tr("This new account does not include any feeds. You can now add default set of feeds."),
|
tr("This new account does not include any feeds. You can now add default set of feeds."),
|
||||||
|
|
@ -143,17 +143,17 @@ void StandardServiceRoot::addNewFeed(const QString& url) {
|
||||||
|
|
||||||
QVariant StandardServiceRoot::data(int column, int role) const {
|
QVariant StandardServiceRoot::data(int column, int role) const {
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||||
return tr("This is service account for standard RSS/RDF/ATOM feeds.\n\nAccount ID: %1").arg(accountId());
|
return tr("This is service account for standard RSS/RDF/ATOM feeds.\n\nAccount ID: %1").arg(accountId());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return ServiceRoot::data(column, role);
|
return ServiceRoot::data(column, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return ServiceRoot::data(column, role);
|
return ServiceRoot::data(column, role);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags StandardServiceRoot::additionalFlags() const {
|
Qt::ItemFlags StandardServiceRoot::additionalFlags() const {
|
||||||
|
|
@ -178,7 +178,7 @@ void StandardServiceRoot::loadFromDatabase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StandardServiceRoot::checkArgumentsForFeedAdding() {
|
void StandardServiceRoot::checkArgumentsForFeedAdding() {
|
||||||
foreach (const QString &arg, qApp->arguments().mid(1)) {
|
foreach (const QString& arg, qApp->arguments().mid(1)) {
|
||||||
checkArgumentForFeedAdding(arg);
|
checkArgumentForFeedAdding(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue