Stick to astlye, refacatoring.
This commit is contained in:
parent
dedf70a8a9
commit
b0ff27c232
@ -28,7 +28,16 @@ if [ $# -eq 0 ]; then
|
||||
fi
|
||||
|
||||
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.
|
||||
for dir in "$@"; do
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -41,502 +41,502 @@
|
||||
|
||||
|
||||
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.");
|
||||
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.");
|
||||
}
|
||||
|
||||
FeedsModel::~FeedsModel() {
|
||||
qDebug("Destroying FeedsModel instance.");
|
||||
// Delete all model items.
|
||||
delete m_rootItem;
|
||||
qDebug("Destroying FeedsModel instance.");
|
||||
// Delete all model items.
|
||||
delete m_rootItem;
|
||||
}
|
||||
|
||||
QMimeData* FeedsModel::mimeData(const QModelIndexList& indexes) const {
|
||||
QMimeData* mime_data = new QMimeData();
|
||||
QByteArray encoded_data;
|
||||
QDataStream stream(&encoded_data, QIODevice::WriteOnly);
|
||||
QMimeData* mime_data = new QMimeData();
|
||||
QByteArray encoded_data;
|
||||
QDataStream stream(&encoded_data, QIODevice::WriteOnly);
|
||||
|
||||
foreach (const QModelIndex &index, indexes) {
|
||||
if (index.column() != 0) {
|
||||
continue;
|
||||
}
|
||||
foreach (const QModelIndex& index, indexes) {
|
||||
if (index.column() != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RootItem* item_for_index = itemForIndex(index);
|
||||
RootItem* item_for_index = itemForIndex(index);
|
||||
|
||||
if (item_for_index->kind() != RootItemKind::Root) {
|
||||
stream << (quintptr)item_for_index;
|
||||
}
|
||||
}
|
||||
if (item_for_index->kind() != RootItemKind::Root) {
|
||||
stream << (quintptr) item_for_index;
|
||||
}
|
||||
}
|
||||
|
||||
mime_data->setData(QSL(MIME_TYPE_ITEM_POINTER), encoded_data);
|
||||
return mime_data;
|
||||
mime_data->setData(QSL(MIME_TYPE_ITEM_POINTER), encoded_data);
|
||||
return mime_data;
|
||||
}
|
||||
|
||||
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) {
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
|
||||
if (action == Qt::IgnoreAction) {
|
||||
return true;
|
||||
}
|
||||
else if (action != Qt::MoveAction) {
|
||||
return false;
|
||||
}
|
||||
if (action == Qt::IgnoreAction) {
|
||||
return true;
|
||||
}
|
||||
else if (action != Qt::MoveAction) {
|
||||
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()) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
QDataStream stream(&dragged_items_data, QIODevice::ReadOnly);
|
||||
if (dragged_items_data.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
QDataStream stream(&dragged_items_data, QIODevice::ReadOnly);
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
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);
|
||||
ServiceRoot* dragged_item_root = dragged_item->getParentServiceRoot();
|
||||
ServiceRoot* target_item_root = target_item->getParentServiceRoot();
|
||||
while (!stream.atEnd()) {
|
||||
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);
|
||||
ServiceRoot* dragged_item_root = dragged_item->getParentServiceRoot();
|
||||
ServiceRoot* target_item_root = target_item->getParentServiceRoot();
|
||||
|
||||
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.");
|
||||
return false;
|
||||
}
|
||||
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.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dragged_item_root != target_item_root) {
|
||||
// Transferring of items between different accounts is not possible.
|
||||
qApp->showGuiMessage(tr("Cannot perform drag & drop operation"),
|
||||
tr("You can't transfer dragged item into different account, this is not supported."),
|
||||
QSystemTrayIcon::Warning,
|
||||
qApp->mainFormWidget(),
|
||||
true);
|
||||
qDebug("Dragged item cannot be dragged into different account. Cancelling drag-drop action.");
|
||||
return false;
|
||||
}
|
||||
if (dragged_item_root != target_item_root) {
|
||||
// Transferring of items between different accounts is not possible.
|
||||
qApp->showGuiMessage(tr("Cannot perform drag & drop operation"),
|
||||
tr("You can't transfer dragged item into different account, this is not supported."),
|
||||
QSystemTrayIcon::Warning,
|
||||
qApp->mainFormWidget(),
|
||||
true);
|
||||
qDebug("Dragged item cannot be dragged into different account. Cancelling drag-drop action.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dragged_item->performDragDropChange(target_item)) {
|
||||
// Drag & drop is supported by the dragged item and was
|
||||
// completed on data level and in item hierarchy.
|
||||
emit requireItemValidationAfterDragDrop(indexForItem(dragged_item));
|
||||
}
|
||||
}
|
||||
if (dragged_item->performDragDropChange(target_item)) {
|
||||
// Drag & drop is supported by the dragged item and was
|
||||
// completed on data level and in item hierarchy.
|
||||
emit requireItemValidationAfterDragDrop(indexForItem(dragged_item));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::DropActions FeedsModel::supportedDropActions() const {
|
||||
return Qt::MoveAction;
|
||||
return Qt::MoveAction;
|
||||
}
|
||||
|
||||
Qt::ItemFlags FeedsModel::flags(const QModelIndex& index) const {
|
||||
Qt::ItemFlags base_flags = QAbstractItemModel::flags(index);
|
||||
const RootItem* item_for_index = itemForIndex(index);
|
||||
Qt::ItemFlags additional_flags = item_for_index->additionalFlags();
|
||||
return base_flags | additional_flags;
|
||||
Qt::ItemFlags base_flags = QAbstractItemModel::flags(index);
|
||||
const RootItem* item_for_index = itemForIndex(index);
|
||||
Qt::ItemFlags additional_flags = item_for_index->additionalFlags();
|
||||
return base_flags | additional_flags;
|
||||
}
|
||||
|
||||
QVariant FeedsModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
if (orientation != Qt::Horizontal) {
|
||||
return QVariant();
|
||||
}
|
||||
if (orientation != Qt::Horizontal) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
if (section == FDS_MODEL_TITLE_INDEX) {
|
||||
return m_headerData.at(FDS_MODEL_TITLE_INDEX);
|
||||
}
|
||||
else {
|
||||
return QVariant();
|
||||
}
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
if (section == FDS_MODEL_TITLE_INDEX) {
|
||||
return m_headerData.at(FDS_MODEL_TITLE_INDEX);
|
||||
}
|
||||
else {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
case Qt::ToolTipRole:
|
||||
return m_tooltipData.at(section);
|
||||
case Qt::ToolTipRole:
|
||||
return m_tooltipData.at(section);
|
||||
|
||||
case Qt::DecorationRole:
|
||||
if (section == FDS_MODEL_COUNTS_INDEX) {
|
||||
return m_countsIcon;
|
||||
}
|
||||
else {
|
||||
return QVariant();
|
||||
}
|
||||
case Qt::DecorationRole:
|
||||
if (section == FDS_MODEL_COUNTS_INDEX) {
|
||||
return m_countsIcon;
|
||||
}
|
||||
else {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex FeedsModel::index(int row, int column, const QModelIndex& parent) const {
|
||||
if (!hasIndex(row, column, parent)) {
|
||||
return QModelIndex();
|
||||
}
|
||||
if (!hasIndex(row, column, parent)) {
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
RootItem* parent_item = itemForIndex(parent);
|
||||
RootItem* child_item = parent_item->child(row);
|
||||
RootItem* parent_item = itemForIndex(parent);
|
||||
RootItem* child_item = parent_item->child(row);
|
||||
|
||||
if (child_item) {
|
||||
return createIndex(row, column, child_item);
|
||||
}
|
||||
else {
|
||||
return QModelIndex();
|
||||
}
|
||||
if (child_item) {
|
||||
return createIndex(row, column, child_item);
|
||||
}
|
||||
else {
|
||||
return QModelIndex();
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex FeedsModel::parent(const QModelIndex& child) const {
|
||||
if (!child.isValid()) {
|
||||
return QModelIndex();
|
||||
}
|
||||
if (!child.isValid()) {
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
RootItem* child_item = itemForIndex(child);
|
||||
RootItem* parent_item = child_item->parent();
|
||||
RootItem* child_item = itemForIndex(child);
|
||||
RootItem* parent_item = child_item->parent();
|
||||
|
||||
if (parent_item == m_rootItem) {
|
||||
return QModelIndex();
|
||||
}
|
||||
else {
|
||||
return createIndex(parent_item->row(), 0, parent_item);
|
||||
}
|
||||
if (parent_item == m_rootItem) {
|
||||
return QModelIndex();
|
||||
}
|
||||
else {
|
||||
return createIndex(parent_item->row(), 0, parent_item);
|
||||
}
|
||||
}
|
||||
|
||||
int FeedsModel::rowCount(const QModelIndex& parent) const {
|
||||
if (parent.column() > 0) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return itemForIndex(parent)->childCount();
|
||||
}
|
||||
if (parent.column() > 0) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return itemForIndex(parent)->childCount();
|
||||
}
|
||||
}
|
||||
|
||||
int FeedsModel::countOfAllMessages() const {
|
||||
return m_rootItem->countOfAllMessages();
|
||||
return m_rootItem->countOfAllMessages();
|
||||
}
|
||||
|
||||
int FeedsModel::countOfUnreadMessages() const {
|
||||
return m_rootItem->countOfUnreadMessages();
|
||||
return m_rootItem->countOfUnreadMessages();
|
||||
}
|
||||
|
||||
void FeedsModel::reloadCountsOfWholeModel() {
|
||||
m_rootItem->updateCounts(true);
|
||||
reloadWholeLayout();
|
||||
notifyWithCounts();
|
||||
m_rootItem->updateCounts(true);
|
||||
reloadWholeLayout();
|
||||
notifyWithCounts();
|
||||
}
|
||||
|
||||
void FeedsModel::removeItem(const QModelIndex& index) {
|
||||
if (index.isValid()) {
|
||||
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();
|
||||
deleting_item->deleteLater();
|
||||
notifyWithCounts();
|
||||
}
|
||||
if (index.isValid()) {
|
||||
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();
|
||||
deleting_item->deleteLater();
|
||||
notifyWithCounts();
|
||||
}
|
||||
}
|
||||
|
||||
void FeedsModel::removeItem(RootItem* deleting_item) {
|
||||
if (deleting_item != nullptr) {
|
||||
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();
|
||||
deleting_item->deleteLater();
|
||||
notifyWithCounts();
|
||||
}
|
||||
if (deleting_item != nullptr) {
|
||||
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();
|
||||
deleting_item->deleteLater();
|
||||
notifyWithCounts();
|
||||
}
|
||||
}
|
||||
|
||||
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 != nullptr) {
|
||||
int original_index_of_item = original_parent->childItems().indexOf(original_node);
|
||||
if (original_parent != new_parent) {
|
||||
if (original_parent != nullptr) {
|
||||
int original_index_of_item = original_parent->childItems().indexOf(original_node);
|
||||
|
||||
if (original_index_of_item >= 0) {
|
||||
// Remove the original item from the model...
|
||||
beginRemoveRows(indexForItem(original_parent), original_index_of_item, original_index_of_item);
|
||||
original_parent->removeChild(original_node);
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
if (original_index_of_item >= 0) {
|
||||
// Remove the original item from the model...
|
||||
beginRemoveRows(indexForItem(original_parent), original_index_of_item, original_index_of_item);
|
||||
original_parent->removeChild(original_node);
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
endInsertRows();
|
||||
}
|
||||
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);
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
|
||||
QList<ServiceRoot*> FeedsModel::serviceRoots() const {
|
||||
QList<ServiceRoot*> roots;
|
||||
QList<ServiceRoot*>FeedsModel::serviceRoots() const {
|
||||
QList<ServiceRoot*>roots;
|
||||
|
||||
foreach (RootItem* root, m_rootItem->childItems()) {
|
||||
if (root->kind() == RootItemKind::ServiceRoot) {
|
||||
roots.append(root->toServiceRoot());
|
||||
}
|
||||
}
|
||||
foreach (RootItem* root, m_rootItem->childItems()) {
|
||||
if (root->kind() == RootItemKind::ServiceRoot) {
|
||||
roots.append(root->toServiceRoot());
|
||||
}
|
||||
}
|
||||
|
||||
return roots;
|
||||
return roots;
|
||||
}
|
||||
|
||||
bool FeedsModel::containsServiceRootFromEntryPoint(const ServiceEntryPoint* point) const {
|
||||
foreach (const ServiceRoot* root, serviceRoots()) {
|
||||
if (root->code() == point->code()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
foreach (const ServiceRoot* root, serviceRoots()) {
|
||||
if (root->code() == point->code()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
StandardServiceRoot* FeedsModel::standardServiceRoot() const {
|
||||
foreach (ServiceRoot* root, serviceRoots()) {
|
||||
StandardServiceRoot* std_service_root;
|
||||
foreach (ServiceRoot* root, serviceRoots()) {
|
||||
StandardServiceRoot* std_service_root;
|
||||
|
||||
if ((std_service_root = dynamic_cast<StandardServiceRoot*>(root)) != nullptr) {
|
||||
return std_service_root;
|
||||
}
|
||||
}
|
||||
if ((std_service_root = dynamic_cast<StandardServiceRoot*>(root)) != nullptr) {
|
||||
return std_service_root;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QList<Feed*> FeedsModel::feedsForScheduledUpdate(bool auto_update_now) {
|
||||
QList<Feed*> feeds_for_update;
|
||||
QList<Feed*>FeedsModel::feedsForScheduledUpdate(bool auto_update_now) {
|
||||
QList<Feed*>feeds_for_update;
|
||||
|
||||
foreach (Feed* feed, m_rootItem->getSubTreeFeeds()) {
|
||||
switch (feed->autoUpdateType()) {
|
||||
case Feed::DontAutoUpdate:
|
||||
// Do not auto-update this feed ever.
|
||||
continue;
|
||||
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);
|
||||
}
|
||||
case Feed::DefaultAutoUpdate:
|
||||
if (auto_update_now) {
|
||||
feeds_for_update.append(feed);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case Feed::SpecificAutoUpdate:
|
||||
default:
|
||||
int remaining_interval = feed->autoUpdateRemainingInterval();
|
||||
case Feed::SpecificAutoUpdate:
|
||||
default:
|
||||
int remaining_interval = feed->autoUpdateRemainingInterval();
|
||||
|
||||
if (--remaining_interval <= 0) {
|
||||
// Interval of this feed passed, include this feed in the output list
|
||||
// and reset the interval.
|
||||
feeds_for_update.append(feed);
|
||||
feed->setAutoUpdateRemainingInterval(feed->autoUpdateInitialInterval());
|
||||
}
|
||||
else {
|
||||
// Interval did not pass, set new decremented interval and do NOT
|
||||
// include this feed in the output list.
|
||||
feed->setAutoUpdateRemainingInterval(remaining_interval);
|
||||
}
|
||||
if (--remaining_interval <= 0) {
|
||||
// Interval of this feed passed, include this feed in the output list
|
||||
// and reset the interval.
|
||||
feeds_for_update.append(feed);
|
||||
feed->setAutoUpdateRemainingInterval(feed->autoUpdateInitialInterval());
|
||||
}
|
||||
else {
|
||||
// Interval did not pass, set new decremented interval and do NOT
|
||||
// include this feed in the output list.
|
||||
feed->setAutoUpdateRemainingInterval(remaining_interval);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return feeds_for_update;
|
||||
return feeds_for_update;
|
||||
}
|
||||
|
||||
QList<Message> FeedsModel::messagesForItem(RootItem* item) const {
|
||||
return item->undeletedMessages();
|
||||
QList<Message>FeedsModel::messagesForItem(RootItem* item) const {
|
||||
return item->undeletedMessages();
|
||||
}
|
||||
|
||||
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 {
|
||||
if (index.isValid() && index.model() == this) {
|
||||
return static_cast<RootItem*>(index.internalPointer());
|
||||
}
|
||||
else {
|
||||
return m_rootItem;
|
||||
}
|
||||
if (index.isValid() && index.model() == this) {
|
||||
return static_cast<RootItem*>(index.internalPointer());
|
||||
}
|
||||
else {
|
||||
return m_rootItem;
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex FeedsModel::indexForItem(const RootItem* item) const {
|
||||
if (item == nullptr || item->kind() == RootItemKind::Root) {
|
||||
// Root item lies on invalid index.
|
||||
return QModelIndex();
|
||||
}
|
||||
if (item == nullptr || item->kind() == RootItemKind::Root) {
|
||||
// Root item lies on invalid index.
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QStack<const RootItem*> chain;
|
||||
QStack<const RootItem*>chain;
|
||||
|
||||
while (item->kind() != RootItemKind::Root) {
|
||||
chain.push(item);
|
||||
item = item->parent();
|
||||
}
|
||||
while (item->kind() != RootItemKind::Root) {
|
||||
chain.push(item);
|
||||
item = item->parent();
|
||||
}
|
||||
|
||||
// Now, we have complete chain list: parent --- ..... --- parent --- leaf (item).
|
||||
QModelIndex target_index = indexForItem(m_rootItem);
|
||||
// Now, we have complete chain list: parent --- ..... --- parent --- leaf (item).
|
||||
QModelIndex target_index = indexForItem(m_rootItem);
|
||||
|
||||
// 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);
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
|
||||
return target_index;
|
||||
return target_index;
|
||||
}
|
||||
|
||||
bool FeedsModel::hasAnyFeedNewMessages() const {
|
||||
foreach (const Feed * feed, m_rootItem->getSubTreeFeeds()) {
|
||||
if (feed->status() == Feed::NewMessages) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
foreach (const Feed* feed, m_rootItem->getSubTreeFeeds()) {
|
||||
if (feed->status() == Feed::NewMessages) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
RootItem* FeedsModel::rootItem() const {
|
||||
return m_rootItem;
|
||||
return m_rootItem;
|
||||
}
|
||||
|
||||
void FeedsModel::reloadChangedLayout(QModelIndexList list) {
|
||||
while (!list.isEmpty()) {
|
||||
QModelIndex indx = list.takeFirst();
|
||||
while (!list.isEmpty()) {
|
||||
QModelIndex indx = list.takeFirst();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
QModelIndex index_item = indexForItem(item);
|
||||
reloadChangedLayout(QModelIndexList() << index_item);
|
||||
}
|
||||
|
||||
void FeedsModel::notifyWithCounts() {
|
||||
emit messageCountsChanged(countOfUnreadMessages(), hasAnyFeedNewMessages());
|
||||
emit messageCountsChanged(countOfUnreadMessages(), hasAnyFeedNewMessages());
|
||||
}
|
||||
|
||||
void FeedsModel::onItemDataChanged(const QList<RootItem*>& items) {
|
||||
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);
|
||||
reloadWholeLayout();
|
||||
}
|
||||
else {
|
||||
qDebug("There is request to reload feed model, reloading the %d items individually.", items.size());
|
||||
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);
|
||||
reloadWholeLayout();
|
||||
}
|
||||
else {
|
||||
qDebug("There is request to reload feed model, reloading the %d items individually.", items.size());
|
||||
|
||||
foreach (RootItem * item, items) {
|
||||
reloadChangedItem(item);
|
||||
}
|
||||
}
|
||||
foreach (RootItem* item, items) {
|
||||
reloadChangedItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
notifyWithCounts();
|
||||
notifyWithCounts();
|
||||
}
|
||||
|
||||
void FeedsModel::reloadWholeLayout() {
|
||||
emit layoutAboutToBeChanged();
|
||||
emit layoutChanged();
|
||||
emit layoutAboutToBeChanged();
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
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);
|
||||
connect(root, &ServiceRoot::dataChanged, this, &FeedsModel::onItemDataChanged);
|
||||
connect(root, &ServiceRoot::reloadMessageListRequested, this, &FeedsModel::reloadMessageListRequested);
|
||||
connect(root, &ServiceRoot::itemExpandRequested, this, &FeedsModel::itemExpandRequested);
|
||||
connect(root, &ServiceRoot::itemExpandStateSaveRequested, this, &FeedsModel::itemExpandStateSaveRequested);
|
||||
root->start(freshly_activated);
|
||||
return true;
|
||||
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);
|
||||
connect(root, &ServiceRoot::dataChanged, this, &FeedsModel::onItemDataChanged);
|
||||
connect(root, &ServiceRoot::reloadMessageListRequested, this, &FeedsModel::reloadMessageListRequested);
|
||||
connect(root, &ServiceRoot::itemExpandRequested, this, &FeedsModel::itemExpandRequested);
|
||||
connect(root, &ServiceRoot::itemExpandStateSaveRequested, this, &FeedsModel::itemExpandStateSaveRequested);
|
||||
root->start(freshly_activated);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FeedsModel::restoreAllBins() {
|
||||
bool result = true;
|
||||
bool result = true;
|
||||
|
||||
foreach (ServiceRoot * root, serviceRoots()) {
|
||||
RecycleBin* bin_of_root = root->recycleBin();
|
||||
foreach (ServiceRoot* root, serviceRoots()) {
|
||||
RecycleBin* bin_of_root = root->recycleBin();
|
||||
|
||||
if (bin_of_root != nullptr) {
|
||||
result &= bin_of_root->restore();
|
||||
}
|
||||
}
|
||||
if (bin_of_root != nullptr) {
|
||||
result &= bin_of_root->restore();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool FeedsModel::emptyAllBins() {
|
||||
bool result = true;
|
||||
bool result = true;
|
||||
|
||||
foreach (ServiceRoot * root, serviceRoots()) {
|
||||
RecycleBin* bin_of_root = root->recycleBin();
|
||||
foreach (ServiceRoot* root, serviceRoots()) {
|
||||
RecycleBin* bin_of_root = root->recycleBin();
|
||||
|
||||
if (bin_of_root != nullptr) {
|
||||
result &= bin_of_root->empty();
|
||||
}
|
||||
}
|
||||
if (bin_of_root != nullptr) {
|
||||
result &= bin_of_root->empty();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
void FeedsModel::loadActivatedServiceAccounts() {
|
||||
// Iterate all globally available feed "service plugins".
|
||||
foreach (const ServiceEntryPoint* entry_point, qApp->feedReader()->feedServices()) {
|
||||
// Load all stored root nodes from the entry point and add those to the model.
|
||||
QList<ServiceRoot*> roots = entry_point->initializeSubtree();
|
||||
// Iterate all globally available feed "service plugins".
|
||||
foreach (const ServiceEntryPoint* entry_point, qApp->feedReader()->feedServices()) {
|
||||
// Load all stored root nodes from the entry point and add those to the model.
|
||||
QList<ServiceRoot*>roots = entry_point->initializeSubtree();
|
||||
|
||||
foreach (ServiceRoot* root, roots) {
|
||||
addServiceAccount(root, false);
|
||||
}
|
||||
}
|
||||
foreach (ServiceRoot* root, roots) {
|
||||
addServiceAccount(root, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (serviceRoots().isEmpty()) {
|
||||
QTimer::singleShot(2000, [this]() {
|
||||
addServiceAccount(StandardServiceEntryPoint().createNewRoot(), true);
|
||||
});
|
||||
}
|
||||
if (serviceRoots().isEmpty()) {
|
||||
QTimer::singleShot(2000, [this]() {
|
||||
addServiceAccount(StandardServiceEntryPoint().createNewRoot(), true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void FeedsModel::stopServiceAccounts() {
|
||||
foreach (ServiceRoot * account, serviceRoots()) {
|
||||
account->stop();
|
||||
}
|
||||
foreach (ServiceRoot* account, serviceRoots()) {
|
||||
account->stop();
|
||||
}
|
||||
}
|
||||
|
||||
QList<Feed*> FeedsModel::feedsForIndex(const QModelIndex& index) const {
|
||||
return itemForIndex(index)->getSubTreeFeeds();
|
||||
QList<Feed*>FeedsModel::feedsForIndex(const QModelIndex& index) const {
|
||||
return itemForIndex(index)->getSubTreeFeeds();
|
||||
}
|
||||
|
||||
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) {
|
||||
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.
|
||||
// NOTE: Service root nodes are lying directly UNDER
|
||||
// the model root item.
|
||||
QList<ServiceRoot*> serviceRoots() const;
|
||||
QList<ServiceRoot*>serviceRoots() const;
|
||||
|
||||
// Determines if there is any account activated from given entry point.
|
||||
bool containsServiceRootFromEntryPoint(const ServiceEntryPoint* point) const;
|
||||
@ -79,15 +79,15 @@ class FeedsModel : public QAbstractItemModel {
|
||||
// so feeds with "default" auto-update strategy should be updated.
|
||||
//
|
||||
// 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.
|
||||
// This is usually used for displaying whole feeds
|
||||
// in "newspaper" mode.
|
||||
QList<Message> messagesForItem(RootItem* item) const;
|
||||
QList<Message>messagesForItem(RootItem* item) const;
|
||||
|
||||
// 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
|
||||
// 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);
|
||||
|
||||
// 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.
|
||||
// NOTE: Normally expand states are saved when application quits.
|
||||
@ -174,8 +174,8 @@ class FeedsModel : public QAbstractItemModel {
|
||||
|
||||
private:
|
||||
RootItem* m_rootItem;
|
||||
QList<QString> m_headerData;
|
||||
QList<QString> m_tooltipData;
|
||||
QList<QString>m_headerData;
|
||||
QList<QString>m_tooltipData;
|
||||
QIcon m_countsIcon;
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@
|
||||
#define ID_RECYCLE_BIN -2
|
||||
#define TRAY_ICON_BUBBLE_TIMEOUT 20000
|
||||
#define CLOSE_LOCK_TIMEOUT 500
|
||||
#define DOWNLOAD_TIMEOUT 5000
|
||||
#define DOWNLOAD_TIMEOUT 15000
|
||||
#define MESSAGES_VIEW_DEFAULT_COL 170
|
||||
#define MESSAGES_VIEW_MINIMUM_COL 36
|
||||
#define FEEDS_VIEW_COLUMN_COUNT 2
|
||||
|
@ -82,7 +82,7 @@
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>45000</number>
|
||||
<number>120000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<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::disconnect(qApp->system(), &SystemFactory::updatesChecked, nullptr, nullptr);
|
||||
|
||||
if (!updates.first.isEmpty() && updates.second == QNetworkReply::NoError &&
|
||||
SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, APP_VERSION)) {
|
||||
if (!updates.first.isEmpty() && updates.second == QNetworkReply::NoError &&
|
||||
SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, APP_VERSION)) {
|
||||
qApp->showGuiMessage(QObject::tr("New version available"),
|
||||
QObject::tr("Click the bubble for more information."),
|
||||
QSystemTrayIcon::Information, qApp->mainForm(), false,
|
||||
|
@ -71,7 +71,7 @@ SystemFactory::AutoStartStatus SystemFactory::autoStartStatus() const {
|
||||
// No correct path was found.
|
||||
if (desktop_file_location.isEmpty()) {
|
||||
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.
|
||||
@ -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.
|
||||
QSettings desktop_settings(desktop_file_location, QSettings::IniFormat);
|
||||
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 {
|
||||
return AutoStartStatus::Disabled;
|
||||
return AutoStartStatus::Disabled;
|
||||
}
|
||||
|
||||
#else
|
||||
// Disable auto-start functionality on unsupported platforms.
|
||||
return AutoStartStatus::Unavailable;
|
||||
return AutoStartStatus::Unavailable;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ void SystemFactory::checkForUpdates() const {
|
||||
|
||||
emit updatesChecked(result);
|
||||
downloader->deleteLater();
|
||||
});
|
||||
});
|
||||
downloader->downloadFile(RELEASES_LIST);
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
class UpdateUrl {
|
||||
public:
|
||||
|
||||
QString m_fileUrl;
|
||||
QString m_name;
|
||||
QString m_size;
|
||||
@ -37,10 +38,12 @@ class UpdateUrl {
|
||||
|
||||
class UpdateInfo {
|
||||
public:
|
||||
|
||||
QString m_availableVersion;
|
||||
QString m_changes;
|
||||
QList<UpdateUrl> m_urls;
|
||||
QDateTime m_date;
|
||||
|
||||
QList<UpdateUrl> m_urls;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(UpdateInfo)
|
||||
|
@ -42,10 +42,10 @@ Q_GLOBAL_STATIC(AdBlockManager, qz_adblock_manager)
|
||||
|
||||
|
||||
AdBlockManager::AdBlockManager(QObject* parent)
|
||||
: QObject(parent), m_loaded(false), m_enabled(true), m_matcher(new AdBlockMatcher(this)), m_interceptor(new AdBlockUrlInterceptor(this)) {
|
||||
load();
|
||||
m_adblockIcon = new AdBlockIcon(this);
|
||||
m_adblockIcon->setObjectName(QSL("m_adblockIconAction"));
|
||||
: QObject(parent), m_loaded(false), m_enabled(true), m_matcher(new AdBlockMatcher(this)), m_interceptor(new AdBlockUrlInterceptor(this)) {
|
||||
load();
|
||||
m_adblockIcon = new AdBlockIcon(this);
|
||||
m_adblockIcon->setObjectName(QSL("m_adblockIconAction"));
|
||||
}
|
||||
|
||||
AdBlockManager::~AdBlockManager() {
|
||||
|
@ -177,11 +177,11 @@ void WebFactory::createMenu(QMenu* menu) {
|
||||
actions << createEngineSettingsAction(tr("Plugins enabled"), QWebEngineSettings::PluginsEnabled);
|
||||
actions << createEngineSettingsAction(tr("Fullscreen enabled"), QWebEngineSettings::FullScreenSupportEnabled);
|
||||
#if !defined(Q_OS_LINUX)
|
||||
actions << createEngineSettingsAction(tr("Screen capture enabled"), QWebEngineSettings::ScreenCaptureEnabled);
|
||||
actions << createEngineSettingsAction(tr("WebGL enabled"), QWebEngineSettings::WebGLEnabled);
|
||||
actions << createEngineSettingsAction(tr("Accelerate 2D canvas"), QWebEngineSettings::Accelerated2dCanvasEnabled);
|
||||
actions << createEngineSettingsAction(tr("Print element backgrounds"), QWebEngineSettings::PrintElementBackgrounds);
|
||||
actions << createEngineSettingsAction(tr("Allow running insecure content"), QWebEngineSettings::AllowRunningInsecureContent);
|
||||
actions << createEngineSettingsAction(tr("Screen capture enabled"), QWebEngineSettings::ScreenCaptureEnabled);
|
||||
actions << createEngineSettingsAction(tr("WebGL enabled"), QWebEngineSettings::WebGLEnabled);
|
||||
actions << createEngineSettingsAction(tr("Accelerate 2D canvas"), QWebEngineSettings::Accelerated2dCanvasEnabled);
|
||||
actions << createEngineSettingsAction(tr("Print element backgrounds"), QWebEngineSettings::PrintElementBackgrounds);
|
||||
actions << createEngineSettingsAction(tr("Allow running insecure content"), QWebEngineSettings::AllowRunningInsecureContent);
|
||||
actions << createEngineSettingsAction(tr("Allow geolocation on insecure origins"), QWebEngineSettings::AllowGeolocationOnInsecureOrigins);
|
||||
#endif
|
||||
menu->addActions(actions);
|
||||
|
@ -339,7 +339,7 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::markMessagesStarred(RootItem
|
||||
const QStringList& feed_ids,
|
||||
const QStringList& guid_hashes) {
|
||||
QJsonObject json;
|
||||
QJsonArray ids;
|
||||
QJsonArray ids;
|
||||
QByteArray raw_output;
|
||||
QString final_url;
|
||||
|
||||
@ -482,7 +482,7 @@ OwnCloudGetFeedsCategoriesResponse::~OwnCloudGetFeedsCategoriesResponse() {
|
||||
|
||||
RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons) const {
|
||||
RootItem* parent = new RootItem();
|
||||
QMap<int, RootItem*> cats;
|
||||
QMap<int, RootItem*>cats;
|
||||
cats.insert(0, parent);
|
||||
|
||||
// Process categories first, then process feeds.
|
||||
@ -535,8 +535,8 @@ OwnCloudGetMessagesResponse::OwnCloudGetMessagesResponse(const QString& raw_cont
|
||||
OwnCloudGetMessagesResponse::~OwnCloudGetMessagesResponse() {
|
||||
}
|
||||
|
||||
QList<Message> OwnCloudGetMessagesResponse::messages() const {
|
||||
QList<Message> msgs;
|
||||
QList<Message>OwnCloudGetMessagesResponse::messages() const {
|
||||
QList<Message>msgs;
|
||||
|
||||
foreach (const QJsonValue& message, m_rawContent["items"].toArray()) {
|
||||
QJsonObject message_map = message.toObject();
|
||||
|
@ -49,8 +49,8 @@ QList<Message> FeedParser::messages() {
|
||||
messages.append(new_message);
|
||||
}
|
||||
catch (const ApplicationException& ex) {
|
||||
qDebug() << ex.message();
|
||||
}
|
||||
qDebug() << ex.message();
|
||||
}
|
||||
}
|
||||
|
||||
return messages;
|
||||
|
@ -44,8 +44,8 @@
|
||||
|
||||
StandardServiceRoot::StandardServiceRoot(RootItem* parent)
|
||||
: ServiceRoot(parent), m_recycleBin(new RecycleBin(this)),
|
||||
m_actionExportFeeds(nullptr), m_actionImportFeeds(nullptr), m_serviceMenu(QList<QAction*>()),
|
||||
m_feedContextMenu(QList<QAction*>()), m_actionFeedFetchMetadata(nullptr) {
|
||||
m_actionExportFeeds(nullptr), m_actionImportFeeds(nullptr), m_serviceMenu(QList<QAction*>()),
|
||||
m_feedContextMenu(QList<QAction*>()), m_actionFeedFetchMetadata(nullptr) {
|
||||
setTitle(qApp->system()->loggedInUser() + QL1S("@") + QL1S(APP_LOW_NAME));
|
||||
setIcon(StandardServiceEntryPoint().icon());
|
||||
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) {
|
||||
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.
|
||||
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."),
|
||||
@ -143,17 +143,17 @@ void StandardServiceRoot::addNewFeed(const QString& url) {
|
||||
|
||||
QVariant StandardServiceRoot::data(int column, int role) const {
|
||||
switch (role) {
|
||||
case Qt::ToolTipRole:
|
||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||
return tr("This is service account for standard RSS/RDF/ATOM feeds.\n\nAccount ID: %1").arg(accountId());
|
||||
}
|
||||
else {
|
||||
return ServiceRoot::data(column, role);
|
||||
}
|
||||
case Qt::ToolTipRole:
|
||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||
return tr("This is service account for standard RSS/RDF/ATOM feeds.\n\nAccount ID: %1").arg(accountId());
|
||||
}
|
||||
else {
|
||||
return ServiceRoot::data(column, role);
|
||||
}
|
||||
|
||||
default:
|
||||
return ServiceRoot::data(column, role);
|
||||
}
|
||||
default:
|
||||
return ServiceRoot::data(column, role);
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ItemFlags StandardServiceRoot::additionalFlags() const {
|
||||
@ -178,7 +178,7 @@ void StandardServiceRoot::loadFromDatabase() {
|
||||
}
|
||||
|
||||
void StandardServiceRoot::checkArgumentsForFeedAdding() {
|
||||
foreach (const QString &arg, qApp->arguments().mid(1)) {
|
||||
foreach (const QString& arg, qApp->arguments().mid(1)) {
|
||||
checkArgumentForFeedAdding(arg);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user