diff --git a/resources/scripts/astyle/.astylerc b/resources/scripts/astyle/.astylerc index 310eab12b..1d9bc6838 100755 --- a/resources/scripts/astyle/.astylerc +++ b/resources/scripts/astyle/.astylerc @@ -21,5 +21,6 @@ --close-templates --max-code-length=140 --lineend=linux +--delete-empty-lines -t -p -M60Ucv \ No newline at end of file diff --git a/src/core/feeddownloader.cpp b/src/core/feeddownloader.cpp index da2220de8..d4a27d234 100755 --- a/src/core/feeddownloader.cpp +++ b/src/core/feeddownloader.cpp @@ -55,7 +55,6 @@ void FeedDownloader::updateAvailableFeeds() { m_feeds.removeFirst(); m_feedsUpdating++; } - else { // We want to start update of some feeds but all working threads are occupied. break; @@ -70,7 +69,6 @@ void FeedDownloader::updateFeeds(const QList& feeds) { qDebug("No feeds to update in worker thread, aborting update."); finalizeUpdate(); } - else { qDebug().nospace() << "Starting feed updates from worker in thread: \'" << QThread::currentThreadId() << "\'."; m_feeds = feeds; diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 8131fdb9a..ad4de563a 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -39,506 +39,496 @@ 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; - } + if (action == Qt::IgnoreAction) { + return true; + } + else if (action != Qt::MoveAction) { + return false; + } - 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; - } + 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(); - else { - QDataStream stream(&dragged_items_data, QIODevice::ReadOnly); + 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; + } - 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_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 == 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->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_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; - } + return true; + } - 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 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); - } + switch (role) { + case Qt::DisplayRole: + if (section == FDS_MODEL_TITLE_INDEX) { + return m_headerData.at(FDS_MODEL_TITLE_INDEX); + } + else { + return QVariant(); + } - 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 FeedsModel::serviceRoots() const { - QList roots; + QList 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(root)) != nullptr) { - return std_service_root; - } - } + if ((std_service_root = dynamic_cast(root)) != nullptr) { + return std_service_root; + } + } - return nullptr; + return nullptr; } QList FeedsModel::feedsForScheduledUpdate(bool auto_update_now) { - QList feeds_for_update; + QList 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()); - } + 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); + } - 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 FeedsModel::messagesForItem(RootItem* item) const { - return item->undeletedMessages(); + 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(index.internalPointer()); - } - - else { - return m_rootItem; - } + if (index.isValid() && index.model() == this) { + return static_cast(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 chain; + QStack 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(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(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& 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(); - } + 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()); - 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(&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(&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 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 roots = entry_point->initializeSubtree(); - foreach (ServiceRoot* root, roots) { - addServiceAccount(root, false); - } - } + foreach (ServiceRoot* root, roots) { + addServiceAccount(root, false); + } + } } void FeedsModel::stopServiceAccounts() { - foreach (ServiceRoot* account, serviceRoots()) { - account->stop(); - } + foreach (ServiceRoot* account, serviceRoots()) { + account->stop(); + } } QList FeedsModel::feedsForIndex(const QModelIndex& index) const { - return itemForIndex(index)->getSubTreeFeeds(); + 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); } diff --git a/src/core/feedsproxymodel.cpp b/src/core/feedsproxymodel.cpp index 9b7acea14..40c223490 100755 --- a/src/core/feedsproxymodel.cpp +++ b/src/core/feedsproxymodel.cpp @@ -71,7 +71,6 @@ QModelIndexList FeedsProxyModel::match(const QModelIndex& start, int role, const result.append(idx); } } - // QString based matching. else { if (entered_text.isEmpty()) { @@ -157,28 +156,23 @@ bool FeedsProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right // User wants to sort according to counts. return left_item->countOfUnreadMessages() < right_item->countOfUnreadMessages(); } - else { // In other cases, sort by title. return QString::localeAwareCompare(left_item->title(), right_item->title()) < 0; } } - else if (left_item->kind() == RootItemKind::Bin) { // Left item is recycle bin. Make sure it is "biggest" item if we have selected ascending order. return sortOrder() == Qt::DescendingOrder; } - else if (right_item->kind() == RootItemKind::Bin) { // Right item is recycle bin. Make sure it is "smallest" item if we have selected descending order. return sortOrder() == Qt::AscendingOrder; } - else if (left_item->kind() == RootItemKind::Feed) { // Left item is feed, right item is category. return false; } - else { // Left item is category, right item is feed. // NOTE: Category is in fact "more" than feed but we consider it to be "less" because it should be "placed" @@ -187,7 +181,6 @@ bool FeedsProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right return true; } } - else { return false; } @@ -226,12 +219,10 @@ bool FeedsProxyModel::filterAcceptsRowInternal(int source_row, const QModelIndex // Recycle bin is always displayed. return true; } - else if (item->isParentOf(m_selectedItem)/* || item->isChildOf(m_selectedItem)*/ || m_selectedItem == item) { // Currently selected item and all its parents and children must be displayed. return true; } - else { // NOTE: If item has < 0 of unread message it may mean, that the count // of unread messages is not (yet) known, display that item too. diff --git a/src/core/message.cpp b/src/core/message.cpp index fcbd679e8..e65708ce6 100755 --- a/src/core/message.cpp +++ b/src/core/message.cpp @@ -36,7 +36,6 @@ QList Enclosures::decodeEnclosuresFromString(const QString& enclosure enclosure.m_mimeType = QByteArray::fromBase64(mime_url.at(0).toLocal8Bit()); enclosure.m_url = QByteArray::fromBase64(mime_url.at(1).toLocal8Bit()); } - else { enclosure.m_url = QByteArray::fromBase64(single_enclosure.toLocal8Bit()); } @@ -54,7 +53,6 @@ QString Enclosures::encodeEnclosuresToString(const QList& enclosures) if (enclosure.m_mimeType.isEmpty()) { enclosures_str.append(enclosure.m_url.toLocal8Bit().toBase64()); } - else { enclosures_str.append(QString(enclosure.m_mimeType.toLocal8Bit().toBase64()) + ECNLOSURES_INNER_SEPARATOR + diff --git a/src/core/messagesmodel.cpp b/src/core/messagesmodel.cpp index 13ae977f8..473201441 100755 --- a/src/core/messagesmodel.cpp +++ b/src/core/messagesmodel.cpp @@ -82,7 +82,6 @@ void MessagesModel::loadMessages(RootItem* item) { if (item == nullptr) { setFilter(QSL(DEFAULT_SQL_MESSAGES_FILTER)); } - else { if (!item->getParentServiceRoot()->loadMessagesForItem(item, this)) { setFilter(QSL("true != true")); @@ -138,7 +137,6 @@ void MessagesModel::updateDateFormat() { if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::UseCustomDate)).toBool()) { m_customDateFormat = qApp->settings()->value(GROUP(Messages), SETTING(Messages::CustomDateFormat)).toString(); } - else { m_customDateFormat = QString(); } @@ -202,21 +200,17 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const { if (m_customDateFormat.isEmpty()) { return dt.toString(Qt::DefaultLocaleShortDate); } - else { return dt.toString(m_customDateFormat); } } - else if (index_column == MSG_DB_AUTHOR_INDEX) { const QString author_name = QSqlQueryModel::data(idx, role).toString(); return author_name.isEmpty() ? QSL("-") : author_name; } - else if (index_column != MSG_DB_IMPORTANT_INDEX && index_column != MSG_DB_READ_INDEX) { return QSqlQueryModel::data(idx, role); } - else { return QVariant(); } @@ -235,7 +229,6 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const { QModelIndex idx_del = index(idx.row(), MSG_DB_PDELETED_INDEX); is_deleted = data(idx_del, Qt::EditRole).toBool(); } - else { QModelIndex idx_del = index(idx.row(), MSG_DB_DELETED_INDEX); is_deleted = data(idx_del, Qt::EditRole).toBool(); @@ -246,7 +239,6 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const { if (data_read.toBool()) { return striked ? m_normalStrikedFont : m_normalFont; } - else { return striked ? m_boldStrikedFont : m_boldFont; } @@ -279,13 +271,11 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const { QVariant dta = m_cache->containsData(idx_read.row()) ? m_cache->data(idx_read) : QSqlQueryModel::data(idx_read); return dta.toInt() == 1 ? m_readIcon : m_unreadIcon; } - else if (index_column == MSG_DB_IMPORTANT_INDEX) { QModelIndex idx_important = index(idx.row(), MSG_DB_IMPORTANT_INDEX); QVariant dta = m_cache->containsData(idx_important.row()) ? m_cache->data(idx_important) : QSqlQueryModel::data(idx_important); return dta.toInt() == 1 ? m_favoriteIcon : QVariant(); } - else { return QVariant(); } @@ -322,7 +312,6 @@ bool MessagesModel::setMessageRead(int row_index, RootItem::ReadStatus read) { if (DatabaseQueries::markMessagesReadUnread(m_db, QStringList() << QString::number(message.m_id), read)) { return m_selectedItem->getParentServiceRoot()->onAfterSetMessagesRead(m_selectedItem, QList() << message, read); } - else { return false; } @@ -374,7 +363,6 @@ bool MessagesModel::switchMessageImportance(int row_index) { return m_selectedItem->getParentServiceRoot()->onAfterSwitchMessageImportance(m_selectedItem, QList>() << pair); } - else { return false; } @@ -407,7 +395,6 @@ bool MessagesModel::switchBatchMessageImportance(const QModelIndexList& messages if (DatabaseQueries::switchMessagesImportance(m_db, message_ids)) { return m_selectedItem->getParentServiceRoot()->onAfterSwitchMessageImportance(m_selectedItem, message_states); } - else { return false; } @@ -426,7 +413,6 @@ bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList& messages) { if (qobject_cast(m_selectedItem) != nullptr) { setData(index(message.row(), MSG_DB_PDELETED_INDEX), 1); } - else { setData(index(message.row(), MSG_DB_DELETED_INDEX), 1); } @@ -443,7 +429,6 @@ bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList& messages) { if (m_selectedItem->kind() != RootItemKind::Bin) { deleted = DatabaseQueries::deleteOrRestoreMessagesToFromBin(m_db, message_ids, true); } - else { deleted = DatabaseQueries::permanentlyDeleteMessages(m_db, message_ids); } @@ -451,7 +436,6 @@ bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList& messages) { if (deleted) { return m_selectedItem->getParentServiceRoot()->onAfterMessagesDelete(m_selectedItem, msgs); } - else { return false; } @@ -478,7 +462,6 @@ bool MessagesModel::setBatchMessagesRead(const QModelIndexList& messages, RootIt if (DatabaseQueries::markMessagesReadUnread(m_db, message_ids, read)) { return m_selectedItem->getParentServiceRoot()->onAfterSetMessagesRead(m_selectedItem, msgs, read); } - else { return false; } @@ -506,7 +489,6 @@ bool MessagesModel::setBatchMessagesRestored(const QModelIndexList& messages) { if (DatabaseQueries::deleteOrRestoreMessagesToFromBin(m_db, message_ids, false)) { return m_selectedItem->getParentServiceRoot()->onAfterMessagesRestoredFromBin(m_selectedItem, msgs); } - else { return false; } @@ -523,7 +505,6 @@ QVariant MessagesModel::headerData(int section, Qt::Orientation orientation, int if (section != MSG_DB_READ_INDEX && section != MSG_DB_IMPORTANT_INDEX) { return m_headerData.at(section); } - else { return QVariant(); } diff --git a/src/core/messagesmodelsqllayer.cpp b/src/core/messagesmodelsqllayer.cpp index 308c2766c..6ba71bc79 100755 --- a/src/core/messagesmodelsqllayer.cpp +++ b/src/core/messagesmodelsqllayer.cpp @@ -64,7 +64,6 @@ void MessagesModelSqlLayer::addSortState(int column, Qt::SortOrder order) { m_sortColumns.append(column); m_sortOrders.append(order); } - else { m_sortColumns.prepend(column); m_sortOrders.prepend(order); @@ -91,7 +90,6 @@ QString MessagesModelSqlLayer::orderByClause() const { if (m_sortColumns.isEmpty()) { return QString(); } - else { QStringList sorts; diff --git a/src/core/messagesproxymodel.cpp b/src/core/messagesproxymodel.cpp index 1ec36acb3..12b0e1595 100755 --- a/src/core/messagesproxymodel.cpp +++ b/src/core/messagesproxymodel.cpp @@ -59,7 +59,6 @@ QModelIndex MessagesProxyModel::getNextUnreadItemIndex(int default_row, int max_ // We found unread message, mark it. return proxy_index; } - else { default_row++; } @@ -83,7 +82,6 @@ QModelIndexList MessagesProxyModel::mapListFromSource(const QModelIndexList& ind // Construct new source index. mapped_indexes << mapFromSource(m_sourceModel->index(index.row(), index.column())); } - else { mapped_indexes << mapFromSource(index); } @@ -119,7 +117,6 @@ QModelIndexList MessagesProxyModel::match(const QModelIndex& start, int role, result.append(idx); } } - // QString based matching. else { if (entered_text.isEmpty()) { diff --git a/src/dynamic-shortcuts/dynamicshortcutswidget.cpp b/src/dynamic-shortcuts/dynamicshortcutswidget.cpp index 289d03b60..39f526665 100755 --- a/src/dynamic-shortcuts/dynamicshortcutswidget.cpp +++ b/src/dynamic-shortcuts/dynamicshortcutswidget.cpp @@ -48,7 +48,6 @@ bool DynamicShortcutsWidget::areShortcutsUnique() const { // Problem, two identical non-empty shortcuts found. return false; } - else { all_shortcuts.append(binding.second->shortcut()); } diff --git a/src/dynamic-shortcuts/shortcutbutton.cpp b/src/dynamic-shortcuts/shortcutbutton.cpp index f17d405c9..1b3f82182 100755 --- a/src/dynamic-shortcuts/shortcutbutton.cpp +++ b/src/dynamic-shortcuts/shortcutbutton.cpp @@ -99,7 +99,6 @@ void ShortcutButton::keyPressEvent(QKeyEvent* event) { if ((pressed_key == Qt::Key_Backtab) && (m_catcher->m_modifierKeys & Qt::SHIFT)) { pressed_key = Qt::Key_Tab | m_catcher->m_modifierKeys; } - else { pressed_key |= m_catcher->m_modifierKeys; } diff --git a/src/gui/dialogs/formabout.cpp b/src/gui/dialogs/formabout.cpp index 554d9d6fe..16b870a94 100755 --- a/src/gui/dialogs/formabout.cpp +++ b/src/gui/dialogs/formabout.cpp @@ -30,9 +30,7 @@ FormAbout::FormAbout(QWidget* parent) : QDialog(parent) { m_ui.setupUi(this); m_ui.m_lblIcon->setPixmap(QPixmap(APP_ICON_PATH)); - GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("help-about")), tr("About %1").arg(APP_NAME)); - loadLicenseAndInformation(); loadSettingsAndPaths(); } @@ -45,7 +43,6 @@ void FormAbout::loadSettingsAndPaths() { if (qApp->settings()->type() == SettingsProperties::Portable) { m_ui.m_txtPathsSettingsType->setText(tr("FULLY portable")); } - else { m_ui.m_txtPathsSettingsType->setText(tr("NOT portable")); } diff --git a/src/gui/dialogs/formaddaccount.cpp b/src/gui/dialogs/formaddaccount.cpp index ab3d87539..5adad3841 100755 --- a/src/gui/dialogs/formaddaccount.cpp +++ b/src/gui/dialogs/formaddaccount.cpp @@ -50,7 +50,6 @@ void FormAddAccount::addSelectedAccount() { if (new_root != nullptr) { m_model->addServiceAccount(new_root, true); } - else { qCritical("Cannot create new account."); } diff --git a/src/gui/dialogs/formbackupdatabasesettings.cpp b/src/gui/dialogs/formbackupdatabasesettings.cpp index 47f549dec..520963643 100755 --- a/src/gui/dialogs/formbackupdatabasesettings.cpp +++ b/src/gui/dialogs/formbackupdatabasesettings.cpp @@ -61,7 +61,6 @@ void FormBackupDatabaseSettings::performBackup() { tr("Backup was created successfully and stored in target directory."), tr("Backup was created successfully.")); } - catch (const ApplicationException& ex) { m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, ex.message(), tr("Backup failed.")); } @@ -86,7 +85,6 @@ void FormBackupDatabaseSettings::checkBackupNames(const QString& name) { if (name.simplified().isEmpty()) { m_ui->m_txtBackupName->setStatus(WidgetWithStatus::Error, tr("Backup name cannot be empty.")); } - else { m_ui->m_txtBackupName->setStatus(WidgetWithStatus::Ok, tr("Backup name looks okay.")); } diff --git a/src/gui/dialogs/formdatabasecleanup.cpp b/src/gui/dialogs/formdatabasecleanup.cpp index c7eef7055..1092134f9 100755 --- a/src/gui/dialogs/formdatabasecleanup.cpp +++ b/src/gui/dialogs/formdatabasecleanup.cpp @@ -59,7 +59,6 @@ void FormDatabaseCleanup::closeEvent(QCloseEvent* event) { if (m_ui->m_progressBar->isEnabled()) { event->ignore(); } - else { QDialog::closeEvent(event); } @@ -69,7 +68,6 @@ void FormDatabaseCleanup::keyPressEvent(QKeyEvent* event) { if (m_ui->m_progressBar->isEnabled()) { event->ignore(); } - else { QDialog::keyPressEvent(event); } @@ -110,7 +108,6 @@ void FormDatabaseCleanup::onPurgeFinished(bool finished) { if (finished) { m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Database cleanup is completed."), tr("Database cleanup is completed.")); } - else { m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Database cleanup failed."), tr("Database cleanup failed.")); } diff --git a/src/gui/dialogs/formmain.cpp b/src/gui/dialogs/formmain.cpp index 4cdafa1e7..67429eb3e 100755 --- a/src/gui/dialogs/formmain.cpp +++ b/src/gui/dialogs/formmain.cpp @@ -65,31 +65,24 @@ FormMain::FormMain(QWidget* parent, Qt::WindowFlags f) : QMainWindow(parent, f), m_ui(new Ui::FormMain) { m_ui->setupUi(this); qApp->setMainForm(this); - #if defined (USE_WEBENGINE) m_ui->m_menuWebBrowserTabs->addAction(AdBlockManager::instance()->adBlockIcon()); m_ui->m_menuWebBrowserTabs->addAction(qApp->web()->engineSettingsAction()); #endif - // Add these actions to the list of actions of the main window. // This allows to use actions via shortcuts // even if main menu is not visible. addActions(qApp->userActions()); - setStatusBar(m_statusBar = new StatusBar(this)); - // Prepare main window and tabs. prepareMenus(); - // Prepare tabs. tabWidget()->feedMessageViewer()->feedsToolBar()->loadSavedActions(); tabWidget()->feedMessageViewer()->messagesToolBar()->loadSavedActions(); - // Establish connections. createConnections(); updateMessageButtonsAvailability(); updateFeedButtonsAvailability(); - // Setup some appearance of the window. setupIcons(); loadSize(); @@ -121,7 +114,6 @@ void FormMain::showDbCleanupAssistant() { tabWidget()->feedMessageViewer()->messagesView()->reloadSelections(); qApp->feedReader()->feedsModel()->reloadCountsOfWholeModel(); } - else { qApp->showGuiMessage(tr("Cannot cleanup database"), tr("Cannot cleanup database, because another critical action is running."), @@ -224,12 +216,10 @@ void FormMain::switchFullscreenMode() { qApp->settings()->setValue(GROUP(GUI), GUI::IsMainWindowMaximizedBeforeFullscreen, isMaximized()); showFullScreen(); } - else { if (qApp->settings()->value(GROUP(GUI), SETTING(GUI::IsMainWindowMaximizedBeforeFullscreen)).toBool()) { setWindowState((windowState() & ~Qt::WindowFullScreen) | Qt::WindowMaximized); } - else { showNormal(); } @@ -279,7 +269,6 @@ void FormMain::updateAddItemMenu() { m_ui->m_menuAddItem->addAction(m_ui->m_actionAddCategoryIntoSelectedAccount); m_ui->m_menuAddItem->addAction(m_ui->m_actionAddFeedIntoSelectedAccount); } - else { m_ui->m_menuAddItem->addAction(m_ui->m_actionNoActions); } @@ -302,7 +291,6 @@ void FormMain::updateRecycleBinMenu() { no_action->setEnabled(false); root_menu->addAction(no_action); } - else if ((context_menu = bin->contextMenu()).isEmpty()) { QAction* no_action = new QAction(qApp->icons()->fromTheme(QSL("dialog-error")), tr("No actions possible"), @@ -310,7 +298,6 @@ void FormMain::updateRecycleBinMenu() { no_action->setEnabled(false); root_menu->addAction(no_action); } - else { root_menu->addActions(context_menu); } @@ -342,7 +329,6 @@ void FormMain::updateAccountsMenu() { no_action->setEnabled(false); root_menu->addAction(no_action); } - else { root_menu->addActions(root_actions); } @@ -425,13 +411,11 @@ void FormMain::switchVisibility(bool force_hide) { if (SystemTrayIcon::isSystemTrayActivated()) { hide(); } - else { // Window gets minimized in single-window mode. showMinimized(); } } - else { display(); } @@ -582,28 +566,23 @@ void FormMain::createConnections() { connect(m_ui->m_menuAccounts, &QMenu::aboutToShow, this, &FormMain::updateAccountsMenu); connect(m_ui->m_actionServiceDelete, &QAction::triggered, m_ui->m_actionDeleteSelectedItem, &QAction::triggered); connect(m_ui->m_actionServiceEdit, &QAction::triggered, m_ui->m_actionEditSelectedItem, &QAction::triggered); - // Menu "File" connections. connect(m_ui->m_actionBackupDatabaseSettings, &QAction::triggered, this, &FormMain::backupDatabaseSettings); connect(m_ui->m_actionRestoreDatabaseSettings, &QAction::triggered, this, &FormMain::restoreDatabaseSettings); connect(m_ui->m_actionQuit, &QAction::triggered, qApp, &Application::quit); connect(m_ui->m_actionServiceAdd, &QAction::triggered, this, &FormMain::showAddAccountDialog); connect(m_ui->m_actionRestart, &QAction::triggered, qApp, &Application::restart); - // Menu "View" connections. connect(m_ui->m_actionFullscreen, &QAction::toggled, this, &FormMain::switchFullscreenMode); connect(m_ui->m_actionSwitchMainMenu, &QAction::toggled, m_ui->m_menuBar, &QMenuBar::setVisible); connect(m_ui->m_actionSwitchMainWindow, &QAction::triggered, this, &FormMain::switchVisibility); connect(m_ui->m_actionSwitchStatusBar, &QAction::toggled, statusBar(), &StatusBar::setVisible); - // Menu "Tools" connections. connect(m_ui->m_actionSettings, &QAction::triggered, [this]() { FormSettings(*this).exec(); }); - connect(m_ui->m_actionDownloadManager, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::showDownloadManager); connect(m_ui->m_actionCleanupDatabase, &QAction::triggered, this, &FormMain::showDbCleanupAssistant); - // Menu "Help" connections. connect(m_ui->m_actionAboutGuard, &QAction::triggered, [this]() { FormAbout(this).exec(); @@ -614,7 +593,6 @@ void FormMain::createConnections() { connect(m_ui->m_actionReportBug, &QAction::triggered, this, &FormMain::reportABug); connect(m_ui->m_actionDonate, &QAction::triggered, this, &FormMain::donate); connect(m_ui->m_actionDisplayWiki, &QAction::triggered, this, &FormMain::showWiki); - // Tab widget connections. connect(m_ui->m_actionTabsCloseAllExceptCurrent, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::closeAllTabsExceptCurrent); connect(m_ui->m_actionTabsCloseAll, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::closeAllTabs); @@ -629,7 +607,6 @@ void FormMain::createConnections() { connect(qApp->feedReader(), &FeedReader::feedUpdatesStarted, this, &FormMain::onFeedUpdatesStarted); connect(qApp->feedReader(), &FeedReader::feedUpdatesProgress, this, &FormMain::onFeedUpdatesProgress); connect(qApp->feedReader(), &FeedReader::feedUpdatesFinished, this, &FormMain::onFeedUpdatesFinished); - // Toolbar forwardings. connect(m_ui->m_actionAddFeedIntoSelectedAccount, &QAction::triggered, tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::addFeedIntoSelectedAccount); diff --git a/src/gui/dialogs/formrestoredatabasesettings.cpp b/src/gui/dialogs/formrestoredatabasesettings.cpp index 4ad4d4313..87084646f 100755 --- a/src/gui/dialogs/formrestoredatabasesettings.cpp +++ b/src/gui/dialogs/formrestoredatabasesettings.cpp @@ -28,13 +28,10 @@ FormRestoreDatabaseSettings::FormRestoreDatabaseSettings(QWidget& parent) : QDialog(&parent), m_shouldRestart(false) { m_ui.setupUi(this); - m_btnRestart = m_ui.m_buttonBox->addButton(tr("Restart"), QDialogButtonBox::ActionRole); m_ui.m_lblResult->setStatus(WidgetWithStatus::Warning, tr("No operation executed yet."), tr("No operation executed yet.")); - setWindowIcon(qApp->icons()->fromTheme(QSL("document-import"))); setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint); - connect(m_btnRestart, &QPushButton::clicked, this, [ = ]() { m_shouldRestart = true; close(); @@ -94,7 +91,6 @@ void FormRestoreDatabaseSettings::selectFolder(QString folder) { m_ui.m_lblSelectFolder->setStatus(WidgetWithStatus::Ok, QDir::toNativeSeparators(folder), tr("Good source directory is specified.")); } - else { return; } diff --git a/src/gui/dialogs/formsettings.cpp b/src/gui/dialogs/formsettings.cpp index 59bea3169..d89f8eefb 100755 --- a/src/gui/dialogs/formsettings.cpp +++ b/src/gui/dialogs/formsettings.cpp @@ -36,13 +36,11 @@ FormSettings::FormSettings(QWidget& parent) : QDialog(&parent), m_panels(QList()), m_settings(*qApp->settings()) { m_ui.setupUi(this); - // Set flags and attributes. setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); setWindowIcon(qApp->icons()->fromTheme(QSL("emblem-system"))); m_btnApply = m_ui.m_buttonBox->button(QDialogButtonBox::Apply); m_btnApply->setEnabled(false); - // Establish needed connections. connect(m_ui.m_buttonBox, &QDialogButtonBox::accepted, this, &FormSettings::saveSettings); connect(m_ui.m_buttonBox, &QDialogButtonBox::rejected, this, &FormSettings::cancelSettings); @@ -55,7 +53,6 @@ FormSettings::FormSettings(QWidget& parent) addSettingsPanel(new SettingsBrowserMail(&m_settings, this)); addSettingsPanel(new SettingsDownloads(&m_settings, this)); addSettingsPanel(new SettingsFeedsMessages(&m_settings, this)); - m_ui.m_listSettings->setCurrentRow(0); } @@ -115,7 +112,6 @@ void FormSettings::cancelSettings() { if (changed_panels.isEmpty()) { reject(); } - else { const QStringList changed_settings_description = changed_panels.replaceInStrings(QRegExp(QSL("^")), QString::fromUtf8(" • ")); @@ -137,7 +133,6 @@ void FormSettings::addSettingsPanel(SettingsPanel* panel) { m_panels.append(panel); m_ui.m_stackedSettings->addWidget(panel); panel->loadSettings(); - connect(panel, &SettingsPanel::settingsChanged, [this]() { m_btnApply->setEnabled(true); }); diff --git a/src/gui/dialogs/formupdate.cpp b/src/gui/dialogs/formupdate.cpp index fb95d6a89..6065109f1 100755 --- a/src/gui/dialogs/formupdate.cpp +++ b/src/gui/dialogs/formupdate.cpp @@ -40,10 +40,8 @@ FormUpdate::FormUpdate(QWidget* parent) m_ui.m_lblCurrentRelease->setText(APP_VERSION); m_ui.m_tabInfo->removeTab(1); m_ui.m_buttonBox->setEnabled(false); - // Set flags and attributes. GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("help-about"))); - connect(&m_downloader, &Downloader::progress, this, &FormUpdate::updateProgress); connect(&m_downloader, &Downloader::completed, this, &FormUpdate::updateCompleted); @@ -111,7 +109,6 @@ void FormUpdate::checkForUpdates() { } } }); - qApp->system()->checkForUpdates(); } @@ -233,15 +230,12 @@ void FormUpdate::startUpdate() { #endif } - else if (update_for_this_system) { updateProgress(0, 100); - m_btnUpdate->setText(tr("Downloading update...")); m_btnUpdate->setEnabled(false); m_downloader.downloadFile(url_file); } - else { // Self-update and package are not available. if (!qApp->web()->openUrlInExternalBrowser(url_file)) { diff --git a/src/gui/discoverfeedsbutton.cpp b/src/gui/discoverfeedsbutton.cpp index 86843263d..e40d516d3 100755 --- a/src/gui/discoverfeedsbutton.cpp +++ b/src/gui/discoverfeedsbutton.cpp @@ -67,7 +67,6 @@ void DiscoverFeedsButton::linkTriggered(QAction* action) { if (root->supportsFeedAdding()) { root->addNewFeed(url); } - else { qApp->showGuiMessage(tr("Not supported"), tr("Given account does not support adding feeds."), diff --git a/src/gui/edittableview.cpp b/src/gui/edittableview.cpp index 15663d8e3..1a9b30cf6 100755 --- a/src/gui/edittableview.cpp +++ b/src/gui/edittableview.cpp @@ -28,7 +28,6 @@ void EditTableView::keyPressEvent(QKeyEvent* event) { removeSelected(); event->accept(); } - else { QAbstractItemView::keyPressEvent(event); } diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 488c45e29..a1a878148 100755 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -146,7 +146,6 @@ void FeedMessageViewer::switchMessageSplitterOrientation() { if (m_messageSplitter->orientation() == Qt::Vertical) { m_messageSplitter->setOrientation(Qt::Horizontal); } - else { m_messageSplitter->setOrientation(Qt::Vertical); } @@ -170,7 +169,6 @@ void FeedMessageViewer::switchFeedComponentVisibility() { if (sen != nullptr) { m_feedsWidget->setVisible(sen->isChecked()); } - else { m_feedsWidget->setVisible(!m_feedsWidget->isVisible()); } @@ -182,7 +180,6 @@ void FeedMessageViewer::toggleShowOnlyUnreadFeeds() { if (origin == nullptr) { m_feedsView->model()->invalidateReadFeedsFilter(true, false); } - else { m_feedsView->model()->invalidateReadFeedsFilter(true, origin->isChecked()); } diff --git a/src/gui/feedstoolbar.cpp b/src/gui/feedstoolbar.cpp index 8edd3755a..9d9c3314a 100755 --- a/src/gui/feedstoolbar.cpp +++ b/src/gui/feedstoolbar.cpp @@ -59,14 +59,12 @@ QList FeedsToolBar::getSpecificActions(const QStringList& actions) { // Add existing standard action. spec_actions.append(matching_action); } - else if (action_name == SEPARATOR_ACTION_NAME) { // Add new separator. QAction* act = new QAction(this); act->setSeparator(true); spec_actions.append(act); } - else if (action_name == SPACER_ACTION_NAME) { // Add new spacer. QWidget* spacer = new QWidget(this); diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 25bcf4ed0..2841a3ae1 100755 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -78,7 +78,6 @@ QList FeedsView::selectedFeeds() const { if (current_index.isValid()) { return m_sourceModel->feedsForIndex(m_proxyModel->mapToSource(current_index)); } - else { return QList(); } @@ -90,7 +89,6 @@ RootItem* FeedsView::selectedItem() const { if (selected_rows.isEmpty()) { return nullptr; } - else { RootItem* selected_item = m_sourceModel->itemForIndex(m_proxyModel->mapToSource(selected_rows.at(0))); return selected_item == m_sourceModel->rootItem() ? nullptr : selected_item; @@ -143,7 +141,6 @@ void FeedsView::sortByColumn(int column, Qt::SortOrder order) { if (column == old_column && order == old_order) { m_proxyModel->sort(column, order); } - else { QTreeView::sortByColumn(column, order); } @@ -158,7 +155,6 @@ void FeedsView::addFeedIntoSelectedAccount() { if (root->supportsFeedAdding()) { root->addNewFeed(); } - else { qApp->showGuiMessage(tr("Not supported"), tr("Selected account does not support adding of new feeds."), @@ -177,7 +173,6 @@ void FeedsView::addCategoryIntoSelectedAccount() { if (root->supportsCategoryAdding()) { root->addNewCategory(); } - else { qApp->showGuiMessage(tr("Not supported"), tr("Selected account does not support adding of new categories."), @@ -227,7 +222,6 @@ void FeedsView::editSelectedItem() { if (selectedItem()->canBeEdited()) { selectedItem()->editViaGui(); } - else { qApp->showGuiMessage(tr("Cannot edit item"), tr("Selected item cannot be edited, this is not (yet?) supported."), @@ -283,7 +277,6 @@ void FeedsView::deleteSelectedItem() { true); } } - else { qApp->showGuiMessage(tr("Cannot delete \"%1\"").arg(selected_item->title()), tr("This item cannot be deleted, because it does not support it\nor this functionality is not implemented yet."), @@ -371,7 +364,6 @@ QMenu* FeedsView::initializeContextMenuCategories(RootItem* clicked_item) { if (m_contextMenuCategories == nullptr) { m_contextMenuCategories = new QMenu(tr("Context menu for categories"), this); } - else { m_contextMenuCategories->clear(); } @@ -397,7 +389,6 @@ QMenu* FeedsView::initializeContextMenuFeeds(RootItem* clicked_item) { if (m_contextMenuFeeds == nullptr) { m_contextMenuFeeds = new QMenu(tr("Context menu for categories"), this); } - else { m_contextMenuFeeds->clear(); } @@ -433,7 +424,6 @@ QMenu* FeedsView::initializeContextMenuOtherItem(RootItem* clicked_item) { if (m_contextMenuOtherItems == nullptr) { m_contextMenuOtherItems = new QMenu(tr("Context menu for other items"), this); } - else { m_contextMenuOtherItems->clear(); } @@ -444,7 +434,6 @@ QMenu* FeedsView::initializeContextMenuOtherItem(RootItem* clicked_item) { m_contextMenuOtherItems->addSeparator(); m_contextMenuOtherItems->addActions(specific_actions); } - else { m_contextMenuOtherItems->addAction(qApp->mainForm()->m_ui->m_actionNoActions); } @@ -502,17 +491,14 @@ void FeedsView::contextMenuEvent(QContextMenuEvent* event) { // Display context menu for categories. initializeContextMenuCategories(clicked_item)->exec(event->globalPos()); } - else if (clicked_item->kind() == RootItemKind::Feed) { // Display context menu for feeds. initializeContextMenuFeeds(clicked_item)->exec(event->globalPos()); } - else { initializeContextMenuOtherItem(clicked_item)->exec(event->globalPos()); } } - else { // Display menu for empty space. initializeContextMenuEmptySpace()->exec(event->globalPos()); diff --git a/src/gui/guiutilities.cpp b/src/gui/guiutilities.cpp index 8e30a5907..00ab7aebe 100755 --- a/src/gui/guiutilities.cpp +++ b/src/gui/guiutilities.cpp @@ -26,7 +26,6 @@ void GuiUtilities::setLabelAsNotice(QLabel& label, bool is_warning) { if (is_warning) { label.setStyleSheet(QSL("font-weight: bold; font-style: italic; color: red")); } - else { label.setStyleSheet(QSL("font-style: italic;")); } diff --git a/src/gui/locationlineedit.cpp b/src/gui/locationlineedit.cpp index 64af9a514..9146b6fa7 100755 --- a/src/gui/locationlineedit.cpp +++ b/src/gui/locationlineedit.cpp @@ -45,7 +45,6 @@ void LocationLineEdit::mousePressEvent(QMouseEvent* event) { // User clicked and all text was selected. m_mouseSelectsAllText = false; } - else { BaseLineEdit::mousePressEvent(event); } diff --git a/src/gui/messagebox.cpp b/src/gui/messagebox.cpp index cd145bf5b..d251f732c 100755 --- a/src/gui/messagebox.cpp +++ b/src/gui/messagebox.cpp @@ -100,7 +100,6 @@ QMessageBox::StandardButton MessageBox::show(QWidget* parent, if (msg_box.exec() == -1) { return QMessageBox::Cancel; } - else { return msg_box.standardButton(msg_box.clickedButton()); } diff --git a/src/gui/messagepreviewer.cpp b/src/gui/messagepreviewer.cpp index ceae56b82..3bfc1fe4f 100755 --- a/src/gui/messagepreviewer.cpp +++ b/src/gui/messagepreviewer.cpp @@ -38,7 +38,6 @@ void MessagePreviewer::createConnections() { if (open_externally_now) { qApp->web()->openUrlInExternalBrowser(url.toString()); } - else { // User clicked some URL. Open it in external browser or download? MessageBox box(qApp->mainForm()); @@ -61,7 +60,6 @@ void MessagePreviewer::createConnections() { if (box.clickedButton() == btn_open) { qApp->web()->openUrlInExternalBrowser(url.toString()); } - else if (box.clickedButton() == btn_download) { qApp->downloadManager()->download(url); } @@ -71,7 +69,6 @@ void MessagePreviewer::createConnections() { btn_cancel->deleteLater(); } } - else { MessageBox::show(qApp->mainForm(), QMessageBox::Warning, tr("Incorrect link"), tr("Selected hyperlink is invalid.")); diff --git a/src/gui/messagestoolbar.cpp b/src/gui/messagestoolbar.cpp index cb7cad76d..d44c5da55 100755 --- a/src/gui/messagestoolbar.cpp +++ b/src/gui/messagestoolbar.cpp @@ -70,24 +70,20 @@ QList MessagesToolBar::getSpecificActions(const QStringList& actions) // Add existing standard action. spec_actions.append(matching_action); } - else if (action_name == SEPARATOR_ACTION_NAME) { // Add new separator. QAction* act = new QAction(this); act->setSeparator(true); spec_actions.append(act); } - else if (action_name == SEACRH_MESSAGES_ACTION_NAME) { // Add search box. spec_actions.append(m_actionSearchMessages); } - else if (action_name == HIGHLIGHTER_ACTION_NAME) { // Add filter button. spec_actions.append(m_actionMessageHighlighter); } - else if (action_name == SPACER_ACTION_NAME) { // Add new spacer. QWidget* spacer = new QWidget(this); diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp index 7382e72dd..c567e8995 100755 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -100,7 +100,6 @@ void MessagesView::reloadSelections() { if (m_proxyModel->rowCount() == 0) { current_index = QModelIndex(); } - else { for (int i = 0; i < m_proxyModel->rowCount(); i++) { QModelIndex msg_idx = m_proxyModel->index(i, MSG_DB_TITLE_INDEX); @@ -123,7 +122,6 @@ void MessagesView::reloadSelections() { setCurrentIndex(current_index); reselectIndexes(QModelIndexList() << current_index); } - else { // Messages were probably removed from the model, nothing can // be selected and no message can be displayed. @@ -169,7 +167,6 @@ void MessagesView::contextMenuEvent(QContextMenuEvent* event) { TreeViewColumnsMenu menu(header()); menu.exec(event->globalPos()); } - else { // Context menu is not initialized, initialize. initializeContextMenu(); @@ -257,7 +254,6 @@ void MessagesView::selectionChanged(const QItemSelection& selected, const QItemS message.m_isRead = true; emit currentMessageChanged(message, m_sourceModel->loadedItem()); } - else { emit currentMessageRemoved(); } @@ -348,7 +344,6 @@ void MessagesView::setSelectedMessagesReadStatus(RootItem::ReadStatus read) { if (current_index.isValid()) { emit currentMessageChanged(m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()), m_sourceModel->loadedItem()); } - else { emit currentMessageRemoved(); } @@ -370,7 +365,6 @@ void MessagesView::deleteSelectedMessages() { setCurrentIndex(current_index); emit currentMessageChanged(m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()), m_sourceModel->loadedItem()); } - else { emit currentMessageRemoved(); } @@ -391,7 +385,6 @@ void MessagesView::restoreSelectedMessages() { if (current_index.isValid()) { emit currentMessageChanged(m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()), m_sourceModel->loadedItem()); } - else { emit currentMessageRemoved(); } @@ -412,7 +405,6 @@ void MessagesView::switchSelectedMessagesImportance() { if (current_index.isValid()) { emit currentMessageChanged(m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()), m_sourceModel->loadedItem()); } - else { // Messages were probably removed from the model, nothing can // be selected and no message can be displayed. @@ -460,7 +452,6 @@ void MessagesView::selectNextUnreadItem() { // Okay, something is selected, start from it. active_row = selected_rows.at(0).row(); } - else { active_row = 0; } @@ -481,7 +472,6 @@ void MessagesView::searchMessages(const QString& pattern) { if (selectionModel()->selectedRows().size() == 0) { emit currentMessageRemoved(); } - else { // Scroll to selected message, it could become scrolled out due to filter change. scrollTo(selectionModel()->selectedRows().at(0)); diff --git a/src/gui/newspaperpreviewer.cpp b/src/gui/newspaperpreviewer.cpp index 3b04ee382..0c3c61b79 100755 --- a/src/gui/newspaperpreviewer.cpp +++ b/src/gui/newspaperpreviewer.cpp @@ -54,7 +54,6 @@ void NewspaperPreviewer::showMoreMessages() { m_ui->m_btnShowMoreMessages->setEnabled(!m_messages.isEmpty()); m_ui->scrollArea->verticalScrollBar()->setValue(current_scroll); } - else { qApp->showGuiMessage(tr("Cannot show more messages"), tr("Cannot show more messages because parent feed was removed."), diff --git a/src/gui/plaintoolbutton.cpp b/src/gui/plaintoolbutton.cpp index a72d40616..c0de956a8 100755 --- a/src/gui/plaintoolbutton.cpp +++ b/src/gui/plaintoolbutton.cpp @@ -43,7 +43,6 @@ void PlainToolButton::paintEvent(QPaintEvent* e) { p.setOpacity(0.7); } } - else { p.setOpacity(0.3); } diff --git a/src/gui/settings/settingsbrowsermail.cpp b/src/gui/settings/settingsbrowsermail.cpp index b374e3667..474951ccd 100755 --- a/src/gui/settings/settingsbrowsermail.cpp +++ b/src/gui/settings/settingsbrowsermail.cpp @@ -32,13 +32,11 @@ SettingsBrowserMail::SettingsBrowserMail(Settings* settings, QWidget* parent) GuiUtilities::setLabelAsNotice(*m_ui->label, false); GuiUtilities::setLabelAsNotice(*m_ui->m_lblExternalEmailInfo, false); GuiUtilities::setLabelAsNotice(*m_ui->m_lblProxyInfo, false); - #if defined(USE_WEBENGINE) m_ui->m_checkOpenLinksInExternal->setVisible(false); #else connect(m_ui->m_checkOpenLinksInExternal, &QCheckBox::stateChanged, this, &SettingsBrowserMail::dirtifySettings); #endif - connect(m_ui->m_cmbProxyType, static_cast(&QComboBox::currentIndexChanged), this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_txtProxyHost, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings); @@ -92,7 +90,6 @@ void SettingsBrowserMail::displayProxyPassword(int state) { if (state == Qt::Checked) { m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::Normal); } - else { m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::PasswordEchoOnEdit); } @@ -137,12 +134,10 @@ void SettingsBrowserMail::selectEmailExecutable() { void SettingsBrowserMail::loadSettings() { onBeginLoadSettings(); - #if !defined(USE_WEBENGINE) m_ui->m_checkOpenLinksInExternal->setChecked(settings()->value(GROUP(Browser), SETTING(Browser::OpenLinksInExternalBrowserRightAway)).toBool()); #endif - // Load settings of web browser GUI. m_ui->m_cmbExternalBrowserPreset->addItem(tr("Opera 12 or older"), QSL("-nosession %1")); m_ui->m_txtExternalBrowserExecutable->setText(settings()->value(GROUP(Browser), @@ -150,7 +145,6 @@ void SettingsBrowserMail::loadSettings() { m_ui->m_txtExternalBrowserArguments->setText(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserArguments)).toString()); m_ui->m_grpCustomExternalBrowser->setChecked(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserEnabled)).toBool()); - // Load settings of e-mail. m_ui->m_cmbExternalEmailPreset->addItem(tr("Mozilla Thunderbird"), QSL("-compose \"subject='%1',body='%2'\"")); m_ui->m_txtExternalEmailExecutable->setText(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailExecutable)).toString()); @@ -160,7 +154,6 @@ void SettingsBrowserMail::loadSettings() { m_ui->m_cmbProxyType->addItem(tr("System proxy"), QNetworkProxy::DefaultProxy); m_ui->m_cmbProxyType->addItem(tr("Socks5"), QNetworkProxy::Socks5Proxy); m_ui->m_cmbProxyType->addItem(tr("Http"), QNetworkProxy::HttpProxy); - // Load the settings. QNetworkProxy::ProxyType selected_proxy_type = static_cast(settings()->value(GROUP(Proxy), SETTING(Proxy::Type)).toInt()); @@ -174,16 +167,13 @@ void SettingsBrowserMail::loadSettings() { void SettingsBrowserMail::saveSettings() { onBeginSaveSettings(); - #if !defined(USE_WEBENGINE) settings()->setValue(GROUP(Browser), Browser::OpenLinksInExternalBrowserRightAway, m_ui->m_checkOpenLinksInExternal->isChecked()); #endif - // Save settings of GUI of web browser. settings()->setValue(GROUP(Browser), Browser::CustomExternalBrowserEnabled, m_ui->m_grpCustomExternalBrowser->isChecked()); settings()->setValue(GROUP(Browser), Browser::CustomExternalBrowserExecutable, m_ui->m_txtExternalBrowserExecutable->text()); settings()->setValue(GROUP(Browser), Browser::CustomExternalBrowserArguments, m_ui->m_txtExternalBrowserArguments->text()); - // Save settings of e-mail. settings()->setValue(GROUP(Browser), Browser::CustomExternalEmailExecutable, m_ui->m_txtExternalEmailExecutable->text()); settings()->setValue(GROUP(Browser), Browser::CustomExternalEmailArguments, m_ui->m_txtExternalEmailArguments->text()); @@ -193,7 +183,6 @@ void SettingsBrowserMail::saveSettings() { settings()->setValue(GROUP(Proxy), Proxy::Username, m_ui->m_txtProxyUsername->text()); settings()->setValue(GROUP(Proxy), Proxy::Password, TextFactory::encrypt(m_ui->m_txtProxyPassword->text())); settings()->setValue(GROUP(Proxy), Proxy::Port, m_ui->m_spinProxyPort->value()); - // Reload settings for all network access managers. SilentNetworkAccessManager::instance()->loadSettings(); onEndSaveSettings(); diff --git a/src/gui/settings/settingsdatabase.cpp b/src/gui/settings/settingsdatabase.cpp index 3e2d5290d..34002344e 100755 --- a/src/gui/settings/settingsdatabase.cpp +++ b/src/gui/settings/settingsdatabase.cpp @@ -84,7 +84,6 @@ void SettingsDatabase::onMysqlHostnameChanged(const QString& new_hostname) { if (new_hostname.isEmpty()) { m_ui->m_txtMysqlHostname->setStatus(LineEditWithStatus::Warning, tr("Hostname is empty.")); } - else { m_ui->m_txtMysqlHostname->setStatus(LineEditWithStatus::Ok, tr("Hostname looks ok.")); } @@ -94,7 +93,6 @@ void SettingsDatabase::onMysqlUsernameChanged(const QString& new_username) { if (new_username.isEmpty()) { m_ui->m_txtMysqlUsername->setStatus(LineEditWithStatus::Warning, tr("Username is empty.")); } - else { m_ui->m_txtMysqlUsername->setStatus(LineEditWithStatus::Ok, tr("Username looks ok.")); } @@ -104,7 +102,6 @@ void SettingsDatabase::onMysqlPasswordChanged(const QString& new_password) { if (new_password.isEmpty()) { m_ui->m_txtMysqlPassword->setStatus(LineEditWithStatus::Warning, tr("Password is empty.")); } - else { m_ui->m_txtMysqlPassword->setStatus(LineEditWithStatus::Ok, tr("Password looks ok.")); } @@ -114,7 +111,6 @@ void SettingsDatabase::onMysqlDatabaseChanged(const QString& new_database) { if (new_database.isEmpty()) { m_ui->m_txtMysqlDatabase->setStatus(LineEditWithStatus::Warning, tr("Working database is empty.")); } - else { m_ui->m_txtMysqlDatabase->setStatus(LineEditWithStatus::Ok, tr("Working database is ok.")); } @@ -126,11 +122,9 @@ void SettingsDatabase::selectSqlBackend(int index) { if (selected_db_driver == APP_DB_SQLITE_DRIVER) { m_ui->m_stackedDatabaseDriver->setCurrentIndex(0); } - else if (selected_db_driver == APP_DB_MYSQL_DRIVER) { m_ui->m_stackedDatabaseDriver->setCurrentIndex(1); } - else { qWarning("GUI for given database driver '%s' is not available.", qPrintable(selected_db_driver)); } diff --git a/src/gui/settings/settingsgeneral.cpp b/src/gui/settings/settingsgeneral.cpp index f42218ad5..606b555ac 100755 --- a/src/gui/settings/settingsgeneral.cpp +++ b/src/gui/settings/settingsgeneral.cpp @@ -71,7 +71,6 @@ void SettingsGeneral::saveSettings() { if (m_ui->m_checkAutostart->isChecked()) { qApp->system()->setAutoStartStatus(SystemFactory::AutoStartStatus::Enabled); } - else { qApp->system()->setAutoStartStatus(SystemFactory::AutoStartStatus::Disabled); } diff --git a/src/gui/settings/settingsgui.cpp b/src/gui/settings/settingsgui.cpp index 304600fb7..03d1ac65d 100755 --- a/src/gui/settings/settingsgui.cpp +++ b/src/gui/settings/settingsgui.cpp @@ -98,7 +98,6 @@ void SettingsGui::loadSettings() { if (SystemTrayIcon::isSystemTrayAvailable()) { m_ui->m_grpTray->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::UseTrayIcon)).toBool()); } - // Tray icon is not supported on this machine. else { m_ui->m_grpTray->setTitle(m_ui->m_grpTray->title() + QL1C(' ') + tr("(Tray icon is not available.)")); @@ -118,7 +117,6 @@ void SettingsGui::loadSettings() { //: Label for disabling icon theme. m_ui->m_cmbIconTheme->addItem(tr("no icon theme/system icon theme"), APP_NO_THEME); } - else { m_ui->m_cmbIconTheme->addItem(icon_theme_name, icon_theme_name); } @@ -129,7 +127,6 @@ void SettingsGui::loadSettings() { // Because "no icon theme" lies at the index 0. m_ui->m_cmbIconTheme->setCurrentIndex(0); } - else { m_ui->m_cmbIconTheme->setCurrentText(current_theme); } @@ -203,7 +200,6 @@ void SettingsGui::saveSettings() { if (m_ui->m_grpTray->isChecked()) { qApp->showTrayIcon(); } - else { qApp->deleteTrayIcon(); } diff --git a/src/gui/statusbar.cpp b/src/gui/statusbar.cpp index 1d7b4e760..64654f2e9 100755 --- a/src/gui/statusbar.cpp +++ b/src/gui/statusbar.cpp @@ -111,25 +111,21 @@ QList StatusBar::getSpecificActions(const QStringList& actions) { action_to_add = m_barProgressDownloadAction; widget_to_add->setVisible(false); } - else if (matching_action == m_barProgressFeedsAction) { widget_to_add = m_barProgressFeeds; action_to_add = m_barProgressFeedsAction; widget_to_add->setVisible(progress_visible); } - else if (matching_action == m_lblProgressDownloadAction) { widget_to_add = m_lblProgressDownload; action_to_add = m_lblProgressDownloadAction; widget_to_add->setVisible(false); } - else if (matching_action == m_lblProgressFeedsAction) { widget_to_add = m_lblProgressFeeds; action_to_add = m_lblProgressFeedsAction; widget_to_add->setVisible(progress_visible); } - else { if (action_name == SEPARATOR_ACTION_NAME) { QLabel* lbl = new QLabel(QString::fromUtf8("•")); @@ -138,7 +134,6 @@ QList StatusBar::getSpecificActions(const QStringList& actions) { action_to_add->setSeparator(true); action_to_add->setProperty("should_remove_action", true); } - else if (action_name == SPACER_ACTION_NAME) { QLabel* lbl = new QLabel(QSL("\t\t")); widget_to_add = lbl; @@ -148,7 +143,6 @@ QList StatusBar::getSpecificActions(const QStringList& actions) { action_to_add->setProperty("type", SPACER_ACTION_NAME); action_to_add->setProperty("name", tr("Toolbar spacer")); } - else if (matching_action != nullptr) { // Add originally toolbar action. PlainToolButton* tool_button = new PlainToolButton(this); @@ -158,7 +152,6 @@ QList StatusBar::getSpecificActions(const QStringList& actions) { connect(tool_button, &PlainToolButton::clicked, matching_action, &QAction::trigger); connect(matching_action, &QAction::changed, tool_button, &PlainToolButton::reactOnSenderActionChange); } - else { action_to_add = nullptr; widget_to_add = nullptr; diff --git a/src/gui/systemtrayicon.cpp b/src/gui/systemtrayicon.cpp index 3d4985718..dc62cb4eb 100755 --- a/src/gui/systemtrayicon.cpp +++ b/src/gui/systemtrayicon.cpp @@ -49,14 +49,12 @@ bool TrayIconMenu::event(QEvent* event) { SystemTrayIcon::SystemTrayIcon(const QString& normal_icon, const QString& plain_icon, FormMain* parent) : QSystemTrayIcon(parent), m_normalIcon(normal_icon), - m_plainPixmap(plain_icon) { + m_plainPixmap(plain_icon) { qDebug("Creating SystemTrayIcon instance."); m_font.setBold(true); - // Initialize icon. setNumber(); setContextMenu(parent->trayMenu()); - // Create necessary connections. connect(this, &SystemTrayIcon::activated, this, &SystemTrayIcon::onActivated); } @@ -96,11 +94,9 @@ void SystemTrayIcon::showPrivate() { // the settings window) gets closed. Behavior for main window // is handled explicitly by FormMain::closeEvent() method. qApp->setQuitOnLastWindowClosed(false); - // Display the tray icon. QSystemTrayIcon::show(); emit shown(); - qDebug("Tray icon displayed."); } @@ -125,7 +121,6 @@ void SystemTrayIcon::setNumber(int number, bool any_new_message) { setToolTip(tr("%1\nUnread news: %2").arg(QSL(APP_LONG_NAME), QString::number(number))); QPixmap background(m_plainPixmap); QPainter tray_painter; - // FIXME: Here draw different background instead of different color of number. tray_painter.begin(&background); tray_painter.setPen(any_new_message ? Qt::black : Qt::black); @@ -163,14 +158,14 @@ void SystemTrayIcon::setNumber(int number, bool any_new_message) { void SystemTrayIcon::showMessage(const QString& title, const QString& message, QSystemTrayIcon::MessageIcon icon, int milliseconds_timeout_hint, std::function functor) { - if (m_connection) { + if (m_connection) { // Disconnect previous bubble click signalling. - disconnect(m_connection); + disconnect(m_connection); } - if (functor) { + if (functor) { // Establish new connection for bubble click. - m_connection = connect(this, &SystemTrayIcon::messageClicked, functor); + m_connection = connect(this, &SystemTrayIcon::messageClicked, functor); } // NOTE: If connections do not work, then use QMetaObject::invokeMethod(...). diff --git a/src/gui/systemtrayicon.h b/src/gui/systemtrayicon.h index fda94675e..46e4a8c72 100755 --- a/src/gui/systemtrayicon.h +++ b/src/gui/systemtrayicon.h @@ -57,7 +57,7 @@ class SystemTrayIcon : public QSystemTrayIcon { void setNumber(int number = -1, bool any_new_message = false); void showMessage(const QString& title, const QString& message, MessageIcon icon = Information, - int milliseconds_timeout_hint = TRAY_ICON_BUBBLE_TIMEOUT, std::function functor = nullptr); + int milliseconds_timeout_hint = TRAY_ICON_BUBBLE_TIMEOUT, std::function functor = nullptr); // Returns true if tray icon CAN be constructed on this machine. static bool isSystemTrayAvailable(); @@ -82,9 +82,9 @@ class SystemTrayIcon : public QSystemTrayIcon { private: QIcon m_normalIcon; QPixmap m_plainPixmap; - QFont m_font = QFont(); + QFont m_font = QFont(); - QMetaObject::Connection m_connection; + QMetaObject::Connection m_connection; }; #endif // SYSTEMTRAYICON_H diff --git a/src/gui/tabbar.cpp b/src/gui/tabbar.cpp index dc373a808..cb507f3eb 100755 --- a/src/gui/tabbar.cpp +++ b/src/gui/tabbar.cpp @@ -93,7 +93,6 @@ void TabBar::wheelEvent(QWheelEvent* event) { number_of_tabs - 1 : current_index - 1); } - else if (event->delta() < 0) { // Scroll to the RIGHT tab. setCurrentIndex(current_index == number_of_tabs - 1 ? @@ -137,7 +136,6 @@ void TabBar::mouseDoubleClickEvent(QMouseEvent* event) { } } } - else { emit emptySpaceDoubleClicked(); } diff --git a/src/gui/tabwidget.cpp b/src/gui/tabwidget.cpp index 522b31e67..60282c56c 100755 --- a/src/gui/tabwidget.cpp +++ b/src/gui/tabwidget.cpp @@ -103,7 +103,6 @@ void TabWidget::checkTabBarVisibility() { setCornerWidget(m_btnMainMenu, Qt::TopLeftCorner); m_btnMainMenu->setVisible(true); } - else { setCornerWidget(0, Qt::TopLeftCorner); setCornerWidget(0, Qt::TopRightCorner); @@ -166,12 +165,10 @@ bool TabWidget::closeTab(int index) { removeTab(index, true); return true; } - else if (tabBar()->tabType(index) == TabBar::DownloadManager) { removeTab(index, false); return true; } - else { return false; } @@ -239,7 +236,6 @@ int TabWidget::addBrowser(bool move_after_current, bool make_active, const QUrl& final_index = insertTab(currentIndex() + 1, browser, qApp->icons()->fromTheme(QSL("text-html")), browser_tab_name, TabBar::Closable); } - else { // Add new browser as the last tab. final_index = addTab(browser, qApp->icons()->fromTheme(QSL("text-html")), diff --git a/src/gui/timespinbox.cpp b/src/gui/timespinbox.cpp index 490c9ffc7..67ecff894 100755 --- a/src/gui/timespinbox.cpp +++ b/src/gui/timespinbox.cpp @@ -37,7 +37,6 @@ double TimeSpinBox::valueFromText(const QString& text) const { if (ok) { return value; } - else { QRegExp rx("\\b[0-9]{1,}\\b"); QStringList numbers; @@ -56,7 +55,6 @@ double TimeSpinBox::valueFromText(const QString& text) const { if (numbers.size() == 2) { return (numbers.at(0).toDouble() * 60.0) + numbers.at(1).toDouble(); } - else { return -1.0; } diff --git a/src/gui/toolbareditor.cpp b/src/gui/toolbareditor.cpp index 6256d0606..801cf7753 100755 --- a/src/gui/toolbareditor.cpp +++ b/src/gui/toolbareditor.cpp @@ -90,13 +90,11 @@ void ToolBarEditor::loadEditor(const QList activated_actions, const QL action_item->setText(tr("Separator")); action_item->setToolTip(tr("Separator")); } - else if (action->property("type").isValid()) { action_item->setData(Qt::UserRole, action->property("type").toString()); action_item->setText(action->property("name").toString()); action_item->setToolTip(action_item->text()); } - else { action_item->setData(Qt::UserRole, action->objectName()); action_item->setToolTip(action->toolTip()); @@ -113,13 +111,11 @@ void ToolBarEditor::loadEditor(const QList activated_actions, const QL action_item->setToolTip(tr("Separator")); action_item->setIcon(qApp->icons()->fromTheme(QSL("insert-object"))); } - else if (action->property("type").isValid()) { action_item->setData(Qt::UserRole, action->property("type").toString()); action_item->setText(action->property("name").toString()); action_item->setToolTip(action_item->text()); } - else { action_item->setData(Qt::UserRole, action->objectName()); action_item->setToolTip(action->toolTip()); @@ -141,12 +137,10 @@ bool ToolBarEditor::eventFilter(QObject* object, QEvent* event) { deleteSelectedAction(); return true; } - else if (key_event->key() == Qt::Key_Down && key_event->modifiers() & Qt::ControlModifier) { moveActionDown(); return true; } - else if (key_event->key() == Qt::Key_Up && key_event->modifiers() & Qt::ControlModifier) { moveActionUp(); return true; @@ -238,7 +232,6 @@ void ToolBarEditor::deleteSelectedAction() { m_ui->m_listActivatedActions->takeItem(m_ui->m_listActivatedActions->row(selected_item)); updateActionsAvailability(); } - else { m_ui->m_listAvailableActions->insertItem( m_ui->m_listAvailableActions->currentRow() + 1, diff --git a/src/gui/treewidget.cpp b/src/gui/treewidget.cpp index 93b9e7160..3a55c1f96 100755 --- a/src/gui/treewidget.cpp +++ b/src/gui/treewidget.cpp @@ -108,7 +108,6 @@ void TreeWidget::filterString(const QString& string) { } } } - else { item->setHidden(true); @@ -125,7 +124,6 @@ void TreeWidget::filterString(const QString& string) { if (stringIsEmpty) { parentItem->setExpanded(m_showMode == ItemsExpanded); } - else { parentItem->setExpanded(true); } diff --git a/src/gui/webbrowser.cpp b/src/gui/webbrowser.cpp index 11b56c813..5cf770d61 100755 --- a/src/gui/webbrowser.cpp +++ b/src/gui/webbrowser.cpp @@ -158,7 +158,6 @@ void WebBrowser::onTitleChanged(const QString& new_title) { //: Webbrowser tab title when no title is available. emit titleChanged(m_index, tr("No title")); } - else { emit titleChanged(m_index, new_title); } @@ -223,7 +222,6 @@ void WebBrowser::onLoadingFinished(bool success) { this->m_btnDiscoverFeeds->setFeedAddresses(NetworkFactory::extractFeedLinksFromHtmlPage(m_webView->url(), result)); }); } - else { m_btnDiscoverFeeds->clearFeedAddresses(); } diff --git a/src/gui/webviewer.cpp b/src/gui/webviewer.cpp index 8b676215a..9167191cd 100755 --- a/src/gui/webviewer.cpp +++ b/src/gui/webviewer.cpp @@ -58,7 +58,6 @@ bool WebViewer::increaseWebPageZoom() { setZoomFactor(zoomFactor() + ZOOM_FACTOR_STEP); return true; } - else { return false; } @@ -69,7 +68,6 @@ bool WebViewer::decreaseWebPageZoom() { setZoomFactor(zoomFactor() - ZOOM_FACTOR_STEP); return true; } - else { return false; } @@ -82,7 +80,6 @@ bool WebViewer::resetWebPageZoom() { setZoomFactor(new_factor); return true; } - else { return false; } @@ -145,11 +142,9 @@ void WebViewer::clear() { void WebViewer::contextMenuEvent(QContextMenuEvent* event) { event->accept(); - QMenu* menu = page()->createStandardContextMenu(); menu->addAction(AdBlockManager::instance()->adBlockIcon()); menu->addAction(qApp->web()->engineSettingsAction()); - const QPoint pos = event->globalPos(); QPoint p(pos.x(), pos.y() + 1); menu->popup(p); @@ -162,7 +157,6 @@ QWebEngineView* WebViewer::createWindow(QWebEnginePage::WebWindowType type) { if (index >= 0) { return qApp->mainForm()->tabWidget()->widget(index)->webBrowser()->viewer(); } - else { return nullptr; } @@ -175,7 +169,6 @@ void WebViewer::wheelEvent(QWheelEvent* event) { if (event->delta() > 0) { increaseWebPageZoom(); } - else if (event->delta() < 0) { decreaseWebPageZoom(); } diff --git a/src/main.cpp b/src/main.cpp index d1b791931..379304b01 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -59,17 +59,13 @@ int main(int argc, char* argv[]) { //: Use ISO 639-1 code here combined with ISO 3166-1 (alpha-2) code. //: Examples: "cs", "en", "it", "cs_CZ", "en_GB", "en_US". QObject::tr("LANG_ABBREV"); - //: Name of translator - optional. QObject::tr("LANG_AUTHOR"); - // Ensure that ini format is used as application settings storage on Mac OS. QSettings::setDefaultFormat(QSettings::IniFormat); - // Setup debug output system. qInstallMessageHandler(Debugging::debugHandler); // Instantiate base application object. - Application application(APP_LOW_NAME, argc, argv); qDebug("Instantiated Application class."); @@ -88,36 +84,28 @@ int main(int argc, char* argv[]) { QApplication::setAttribute(Qt::AA_DontShowIconsInMenus); disableWindowTabbing(); #endif - // Register needed metatypes. qRegisterMetaType>("QList"); qRegisterMetaType>("QList"); - // Add an extra path for non-system icon themes and set current icon theme // and skin. qApp->icons()->setupSearchPaths(); qApp->icons()->loadCurrentIconTheme(); qApp->skins()->loadCurrentSkin(); - // These settings needs to be set before any QSettings object. Application::setApplicationName(APP_NAME); Application::setApplicationVersion(APP_VERSION); Application::setOrganizationDomain(APP_URL); Application::setWindowIcon(QIcon(APP_ICON_PATH)); - // Load activated accounts. qApp->feedReader()->feedsModel()->loadActivatedServiceAccounts(); - // Setup single-instance behavior. QObject::connect(&application, &Application::messageReceived, &application, &Application::processExecutionMessage); qDebug().nospace() << "Creating main application form in thread: \'" << QThread::currentThreadId() << "\'."; - // Instantiate main application window. FormMain main_window; - // Set correct information for main window. main_window.setWindowTitle(APP_LONG_NAME); - // Now is a good time to initialize dynamic keyboard shortcuts. DynamicShortcuts::load(qApp->userActions()); @@ -126,7 +114,6 @@ int main(int argc, char* argv[]) { qDebug("Hiding the main window when the application is starting."); main_window.switchVisibility(true); } - else { qDebug("Showing the main window when the application is starting."); main_window.show(); @@ -139,12 +126,11 @@ int main(int argc, char* argv[]) { if (qApp->isFirstRun() || qApp->isFirstRun(APP_VERSION)) { qApp->showGuiMessage(QSL(APP_NAME), QObject::tr("Welcome to %1.\n\nPlease, check NEW stuff included in this\n" - "version by clicking this popup notification.").arg(APP_LONG_NAME), - QSystemTrayIcon::NoIcon, 0, false, [] { - FormAbout(qApp->mainForm()).exec(); - }); + "version by clicking this popup notification.").arg(APP_LONG_NAME), + QSystemTrayIcon::NoIcon, 0, false, [] { + FormAbout(qApp->mainForm()).exec(); + }); } - else { qApp->showGuiMessage(QSL(APP_NAME), QObject::tr("Welcome to %1.").arg(APP_NAME), QSystemTrayIcon::NoIcon); } @@ -157,17 +143,16 @@ int main(int argc, char* argv[]) { !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, - [] { - FormUpdate(qApp->mainForm()).exec(); - }); + QSystemTrayIcon::Information, qApp->mainForm(), false, + [] { + FormUpdate(qApp->mainForm()).exec(); + }); } }); qApp->system()->checkForUpdates(); } qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->loadAllExpandStates(); - // Enter global event loop. return Application::exec(); } diff --git a/src/miscellaneous/application.cpp b/src/miscellaneous/application.cpp index 5994b85d4..dc1e7b8c9 100755 --- a/src/miscellaneous/application.cpp +++ b/src/miscellaneous/application.cpp @@ -65,15 +65,12 @@ Application::Application(const QString& id, int& argc, char** argv) connect(this, &Application::aboutToQuit, this, &Application::onAboutToQuit); connect(this, &Application::commitDataRequest, this, &Application::onCommitData); connect(this, &Application::saveStateRequest, this, &Application::onSaveState); - #if defined(USE_WEBENGINE) connect(QWebEngineProfile::defaultProfile(), &QWebEngineProfile::downloadRequested, this, &Application::downloadRequested); QWebEngineProfile::defaultProfile()->setRequestInterceptor(m_urlInterceptor); - // TODO: Call load settings when saving app settings from dialog. // Will need add that if I add more settings in the future. m_urlInterceptor->loadSettings(); - QWebEngineProfile::defaultProfile()->installUrlSchemeHandler( QByteArray(APP_LOW_NAME), new RssGuardSchemeHandler(QWebEngineProfile::defaultProfile())); @@ -91,7 +88,6 @@ FeedReader* Application::feedReader() { QList Application::userActions() { if (m_mainForm != nullptr && m_userActions.isEmpty()) { m_userActions = m_mainForm->allActions(); - #if defined(USE_WEBENGINE) m_userActions.append(AdBlockManager::instance()->adBlockIcon()); #endif @@ -109,7 +105,6 @@ bool Application::isFirstRun(const QString& version) { // Check this only if checked version is equal to actual version. return settings()->value(GROUP(General), QString(General::FirstRun) + QL1C('_') + version, true).toBool(); } - else { return false; } @@ -228,7 +223,6 @@ QString Application::userDataPath() { if (settings()->type() == SettingsProperties::Portable) { return getUserDataAppPath(); } - else { return getUserDataHomePath(); } @@ -241,7 +235,6 @@ QString Application::getUserDataHomePath() { if (QDir().exists(home_folder)) { return home_folder; } - else { return getConfigHomePath() + QDir::separator() + QSL(APP_NAME); } @@ -307,14 +300,12 @@ void Application::processExecutionMessage(const QString& message) { if (messages.contains(APP_QUIT_INSTANCE)) { quit(); } - else { foreach (const QString& msg, messages) { if (msg == APP_IS_RUNNING) { showGuiMessage(APP_NAME, tr("Application is already running."), QSystemTrayIcon::Information); mainForm()->display(); } - else if (msg.startsWith(QL1S(URI_SCHEME_FEED_SHORT))) { // Application was running, and someone wants to add new feed. StandardServiceRoot* root = qApp->feedReader()->feedsModel()->standardServiceRoot(); @@ -322,7 +313,6 @@ void Application::processExecutionMessage(const QString& message) { if (root != nullptr) { root->checkArgumentForFeedAdding(msg); } - else { showGuiMessage(tr("Cannot add feed"), tr("Feed cannot be added because standard RSS/ATOM account is not enabled."), diff --git a/src/miscellaneous/application.h b/src/miscellaneous/application.h index be3736c85..9d2b07732 100755 --- a/src/miscellaneous/application.h +++ b/src/miscellaneous/application.h @@ -118,7 +118,7 @@ class Application : public QtSingleApplication { // or in message box if tray icon is disabled. void showGuiMessage(const QString& title, const QString& message, QSystemTrayIcon::MessageIcon message_type, QWidget* parent = nullptr, bool show_at_least_msgbox = false, - std::function functor = nullptr); + std::function functor = nullptr); // Returns pointer to "GOD" application singleton. inline static Application* instance() { diff --git a/src/miscellaneous/autosaver.cpp b/src/miscellaneous/autosaver.cpp index 8774d9a13..daf1ffb91 100755 --- a/src/miscellaneous/autosaver.cpp +++ b/src/miscellaneous/autosaver.cpp @@ -47,7 +47,6 @@ void AutoSaver::changeOccurred() { if (m_firstChange.elapsed() > MAXWAIT) { saveIfNeccessary(); } - else { m_timer.start(AUTOSAVE_IN, this); } @@ -57,7 +56,6 @@ void AutoSaver::timerEvent(QTimerEvent* event) { if (event->timerId() == m_timer.timerId()) { saveIfNeccessary(); } - else { QObject::timerEvent(event); } diff --git a/src/miscellaneous/databasefactory.cpp b/src/miscellaneous/databasefactory.cpp index a24a7747c..ea98c2f1d 100755 --- a/src/miscellaneous/databasefactory.cpp +++ b/src/miscellaneous/databasefactory.cpp @@ -44,7 +44,6 @@ qint64 DatabaseFactory::getDatabaseFileSize() const { if (m_activeDatabaseDriver == SQLITE || m_activeDatabaseDriver == SQLITE_MEMORY) { return QFileInfo(sqliteDatabaseFilePath()).size(); } - else { return 0; } @@ -60,7 +59,6 @@ qint64 DatabaseFactory::getDatabaseDataSize() const { query.next(); result *= query.value(0).value(); } - else { return 0; } @@ -69,14 +67,12 @@ qint64 DatabaseFactory::getDatabaseDataSize() const { query.next(); result *= query.value(0).value(); } - else { return 0; } return result; } - else if (m_activeDatabaseDriver == MYSQL) { QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); qint64 result = 1; @@ -91,12 +87,10 @@ qint64 DatabaseFactory::getDatabaseDataSize() const { return result; } - else { return 0; } } - else { return 0; } @@ -120,18 +114,15 @@ DatabaseFactory::MySQLError DatabaseFactory::mysqlTestConnection(const QString& database.close(); return MySQLOk; } - else { database.close(); return MySQLUnknownError; } } - else if (database.lastError().isValid()) { // Connection failed, do cleanup and return specific error code. return static_cast(database.lastError().number()); } - else { return MySQLUnknownError; } @@ -187,7 +178,6 @@ void DatabaseFactory::finishRestoration() { QFile::remove(backup_database_file); qDebug("Database file was restored successully."); } - else { qCritical("Database file was NOT restored due to error when copying the file."); } @@ -205,7 +195,6 @@ QSqlDatabase DatabaseFactory::sqliteInitializeInMemoryDatabase() { if (!database.open()) { qFatal("In-memory SQLite database was NOT opened. Delivered error message: '%s'", qPrintable(database.lastError().text())); } - else { QSqlQuery query_db(database); query_db.setForwardOnly(true); @@ -244,7 +233,6 @@ QSqlDatabase DatabaseFactory::sqliteInitializeInMemoryDatabase() { database.commit(); qDebug("In-memory SQLite database backend should be ready now."); } - else { query_db.next(); qDebug("In-memory SQLite database connection seems to be established."); @@ -264,7 +252,6 @@ QSqlDatabase DatabaseFactory::sqliteInitializeInMemoryDatabase() { tables.append(copy_contents.value(0).toString()); } } - else { qFatal("Cannot obtain list of table names from file-base SQLite database."); } @@ -311,7 +298,6 @@ QSqlDatabase DatabaseFactory::sqliteInitializeFileBasedDatabase(const QString& c qFatal("File-based SQLite database was NOT opened. Delivered error message: '%s'", qPrintable(database.lastError().text())); } - else { QSqlQuery query_db(database); query_db.setForwardOnly(true); @@ -351,7 +337,6 @@ QSqlDatabase DatabaseFactory::sqliteInitializeFileBasedDatabase(const QString& c query_db.finish(); qDebug("File-based SQLite database backend should be ready now."); } - else { query_db.next(); const QString installed_db_schema = query_db.value(0).toString(); @@ -363,7 +348,6 @@ QSqlDatabase DatabaseFactory::sqliteInitializeFileBasedDatabase(const QString& c qPrintable(installed_db_schema), APP_DB_SCHEMA_VERSION); } - else { qFatal("Database schema was not updated from '%s' to '%s' successully.", qPrintable(installed_db_schema), @@ -395,7 +379,6 @@ bool DatabaseFactory::sqliteUpdateDatabaseSchema(QSqlDatabase database, const QS if (IOFactory::copyFile(sqliteDatabaseFilePath(), sqliteDatabaseFilePath() + ".bak")) { qDebug("Creating backup of SQLite DB file."); } - else { qFatal("Creation of backup SQLite DB file failed."); } @@ -500,11 +483,9 @@ QString DatabaseFactory::humanDriverName(const QString& driver_code) const { if (driver_code == APP_DB_SQLITE_DRIVER) { return humanDriverName(SQLITE); } - else if (driver_code == APP_DB_MYSQL_DRIVER) { return humanDriverName(MYSQL); } - else { return humanDriverName(SQLITE); } @@ -519,7 +500,6 @@ QString DatabaseFactory::obtainBeginTransactionSql() const { if (m_activeDatabaseDriver == DatabaseFactory::SQLITE || m_activeDatabaseDriver == DatabaseFactory::SQLITE_MEMORY) { return QSL("BEGIN IMMEDIATE TRANSACTION;"); } - else { return QSL("START TRANSACTION;"); } @@ -540,7 +520,6 @@ void DatabaseFactory::sqliteSaveMemoryDatabase() { tables.append(copy_contents.value(0).toString()); } } - else { qFatal("Cannot obtain list of table names from file-base SQLite database."); } @@ -563,7 +542,6 @@ void DatabaseFactory::determineDriver() { m_activeDatabaseDriver = MYSQL; qDebug("Working database source was as MySQL database."); } - else { // User wants to use SQLite, which is always available. Check if file-based // or in-memory database will be used. @@ -572,7 +550,6 @@ void DatabaseFactory::determineDriver() { m_activeDatabaseDriver = SQLITE_MEMORY; qDebug("Working database source was determined as SQLite in-memory database."); } - else { // Use strictly file-base SQLite database. m_activeDatabaseDriver = SQLITE; @@ -592,7 +569,6 @@ QSqlDatabase DatabaseFactory::mysqlConnection(const QString& connection_name) { // Return initialized database. return mysqlInitializeDatabase(connection_name); } - else { QSqlDatabase database; @@ -602,7 +578,6 @@ QSqlDatabase DatabaseFactory::mysqlConnection(const QString& connection_name) { // setup its properties. database = QSqlDatabase::database(connection_name); } - else { // Database connection with this name does not exist // yet, add it and set it up. @@ -618,7 +593,6 @@ QSqlDatabase DatabaseFactory::mysqlConnection(const QString& connection_name) { qFatal("MySQL database was NOT opened. Delivered error message: '%s'.", qPrintable(database.lastError().text())); } - else { qDebug("MySQL database connection '%s' to file '%s' seems to be established.", qPrintable(connection_name), @@ -649,7 +623,6 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString& connection_ "and make adjustments in application settings.").arg(APP_NAME)); return connection(objectName(), FromSettings); } - else { QSqlQuery query_db(database); query_db.setForwardOnly(true); @@ -683,7 +656,6 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString& connection_ database.commit(); qDebug("MySQL database backend should be ready now."); } - else { // Database was previously initialized. Now just check the schema version. query_db.next(); @@ -695,7 +667,6 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString& connection_ qPrintable(installed_db_schema), APP_DB_SCHEMA_VERSION); } - else { qFatal("Database schema was not updated from '%s' to '%s' successully.", qPrintable(installed_db_schema), @@ -727,7 +698,6 @@ QSqlDatabase DatabaseFactory::sqliteConnection(const QString& connection_name, D // It is not initialized yet. return sqliteInitializeInMemoryDatabase(); } - else { QSqlDatabase database = QSqlDatabase::database(); database.setDatabaseName(QSL(":memory:")); @@ -736,7 +706,6 @@ QSqlDatabase DatabaseFactory::sqliteConnection(const QString& connection_name, D qFatal("In-memory SQLite database was NOT opened. Delivered error message: '%s'.", qPrintable(database.lastError().text())); } - else { qDebug("In-memory SQLite database connection seems to be established."); } @@ -744,14 +713,12 @@ QSqlDatabase DatabaseFactory::sqliteConnection(const QString& connection_name, D return database; } } - else { // We request file-based database. if (!m_sqliteFileBasedDatabaseinitialized) { // File-based database is not yet initialised. return sqliteInitializeFileBasedDatabase(connection_name); } - else { QSqlDatabase database; @@ -761,7 +728,6 @@ QSqlDatabase DatabaseFactory::sqliteConnection(const QString& connection_name, D // setup its properties. database = QSqlDatabase::database(connection_name); } - else { // Database connection with this name does not exist // yet, add it and set it up. @@ -776,7 +742,6 @@ QSqlDatabase DatabaseFactory::sqliteConnection(const QString& connection_name, D qFatal("File-based SQLite database was NOT opened. Delivered error message: '%s'.", qPrintable(database.lastError().text())); } - else { qDebug("File-based SQLite database connection '%s' to file '%s' seems to be established.", qPrintable(connection_name), @@ -794,12 +759,10 @@ bool DatabaseFactory::sqliteVacuumDatabase() { if (m_activeDatabaseDriver == SQLITE) { database = sqliteConnection(objectName(), StrictlyFileBased); } - else if (m_activeDatabaseDriver == SQLITE_MEMORY) { sqliteSaveMemoryDatabase(); database = sqliteConnection(objectName(), StrictlyFileBased); } - else { return false; } diff --git a/src/miscellaneous/databasequeries.cpp b/src/miscellaneous/databasequeries.cpp index a060cd37d..f33646fab 100755 --- a/src/miscellaneous/databasequeries.cpp +++ b/src/miscellaneous/databasequeries.cpp @@ -169,7 +169,6 @@ bool including_total_counts, bool* ok) { "WHERE feed IN (SELECT custom_id FROM Feeds WHERE category = :category AND account_id = :account_id) AND is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id " "GROUP BY feed;"); } - else { q.prepare("SELECT feed, sum((is_read + 1) % 2) FROM Messages " "WHERE feed IN (SELECT custom_id FROM Feeds WHERE category = :category AND account_id = :account_id) AND is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id " @@ -188,7 +187,6 @@ bool including_total_counts, bool* ok) { int total_count = q.value(2).toInt(); counts.insert(feed_id, QPair(unread_count, total_count)); } - else { counts.insert(feed_id, QPair(unread_count, 0)); } @@ -198,7 +196,6 @@ bool including_total_counts, bool* ok) { *ok = true; } } - else { if (ok != nullptr) { *ok = false; @@ -219,7 +216,6 @@ bool including_total_counts, bool* ok) { "WHERE is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id " "GROUP BY feed;"); } - else { q.prepare("SELECT feed, sum((is_read + 1) % 2) FROM Messages " "WHERE is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id " @@ -237,7 +233,6 @@ bool including_total_counts, bool* ok) { int total_count = q.value(2).toInt(); counts.insert(feed_id, QPair(unread_count, total_count)); } - else { counts.insert(feed_id, QPair(unread_count, 0)); } @@ -247,7 +242,6 @@ bool including_total_counts, bool* ok) { *ok = true; } } - else { if (ok != nullptr) { *ok = false; @@ -266,7 +260,6 @@ int DatabaseQueries::getMessageCountsForFeed(QSqlDatabase db, int feed_custom_id q.prepare("SELECT count(*) FROM Messages " "WHERE feed = :feed AND is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id;"); } - else { q.prepare("SELECT count(*) FROM Messages " "WHERE feed = :feed AND is_deleted = 0 AND is_pdeleted = 0 AND is_read = 0 AND account_id = :account_id;"); @@ -282,7 +275,6 @@ int DatabaseQueries::getMessageCountsForFeed(QSqlDatabase db, int feed_custom_id return q.value(0).toInt(); } - else { if (ok != nullptr) { *ok = false; @@ -300,7 +292,6 @@ int DatabaseQueries::getMessageCountsForBin(QSqlDatabase db, int account_id, boo q.prepare("SELECT count(*) FROM Messages " "WHERE is_deleted = 1 AND is_pdeleted = 0 AND account_id = :account_id;"); } - else { q.prepare("SELECT count(*) FROM Messages " "WHERE is_read = 0 AND is_deleted = 1 AND is_pdeleted = 0 AND account_id = :account_id;"); @@ -315,7 +306,6 @@ int DatabaseQueries::getMessageCountsForBin(QSqlDatabase db, int account_id, boo return q.value(0).toInt(); } - else { if (ok != nullptr) { *ok = false; @@ -349,7 +339,6 @@ QList DatabaseQueries::getUndeletedMessagesForFeed(QSqlDatabase db, int *ok = true; } } - else { if (ok != nullptr) { *ok = false; @@ -382,7 +371,6 @@ QList DatabaseQueries::getUndeletedMessagesForBin(QSqlDatabase db, int *ok = true; } } - else { if (ok != nullptr) { *ok = false; @@ -415,7 +403,6 @@ QList DatabaseQueries::getUndeletedMessagesForAccount(QSqlDatabase db, *ok = true; } } - else { if (ok != nullptr) { *ok = false; @@ -482,7 +469,6 @@ int DatabaseQueries::updateMessages(QSqlDatabase db, if (message.m_url.startsWith(QL1S("//"))) { message.m_url = QString(URI_SCHEME_HTTP) + message.m_url.mid(2); } - else if (message.m_url.startsWith(QL1S("/"))) { QString new_message_url = QUrl(url).toString(QUrl::RemoveUserInfo | QUrl::RemovePath | @@ -515,14 +501,12 @@ int DatabaseQueries::updateMessages(QSqlDatabase db, is_important_existing_message = query_select_with_url.value(3).toBool(); contents_existing_message = query_select_with_url.value(4).toString(); } - else if (query_select_with_url.lastError().isValid()) { qWarning("Failed to check for existing message in DB via URL: '%s'.", qPrintable(query_select_with_url.lastError().text())); } query_select_with_url.finish(); } - else { // We can recognize existing messages via their custom ID. // NOTE: This concerns messages from custom accounts, like TT-RSS or ownCloud News. @@ -536,7 +520,6 @@ int DatabaseQueries::updateMessages(QSqlDatabase db, is_important_existing_message = query_select_with_id.value(3).toBool(); contents_existing_message = query_select_with_id.value(4).toString(); } - else if (query_select_with_id.lastError().isValid()) { qDebug("Failed to check for existing message in DB via ID: '%s'.", qPrintable(query_select_with_id.lastError().text())); } @@ -571,7 +554,6 @@ int DatabaseQueries::updateMessages(QSqlDatabase db, if (query_update.exec() && !message.m_isRead) { updated_messages++; } - else if (query_update.lastError().isValid()) { qWarning("Failed to update message in DB: '%s'.", qPrintable(query_update.lastError().text())); } @@ -580,7 +562,6 @@ int DatabaseQueries::updateMessages(QSqlDatabase db, qDebug("Updating message '%s' in DB.", qPrintable(message.m_title)); } } - else { // Message with this URL is not fetched in this feed yet. query_insert.bindValue(QSL(":feed"), feed_custom_id); @@ -600,7 +581,6 @@ int DatabaseQueries::updateMessages(QSqlDatabase db, updated_messages++; qDebug("Added new message '%s' to DB.", qPrintable(message.m_title)); } - else if (query_insert.lastError().isValid()) { qWarning("Failed to insert message to DB: '%s' - message title is '%s'.", qPrintable(query_insert.lastError().text()), @@ -628,7 +608,6 @@ int DatabaseQueries::updateMessages(QSqlDatabase db, updated_messages = 0; } } - else { if (ok != nullptr) { *ok = true; @@ -645,7 +624,6 @@ bool DatabaseQueries::purgeMessagesFromBin(QSqlDatabase db, bool clear_only_read if (clear_only_read) { q.prepare(QSL("UPDATE Messages SET is_pdeleted = 1 WHERE is_read = 1 AND is_deleted = 1 AND account_id = :account_id;")); } - else { q.prepare(QSL("UPDATE Messages SET is_pdeleted = 1 WHERE is_deleted = 1 AND account_id = :account_id;")); } @@ -671,7 +649,6 @@ bool DatabaseQueries::deleteAccount(QSqlDatabase db, int account_id) { qCritical("Removing of account from DB failed, this is critical: '%s'.", qPrintable(query.lastError().text())); return false; } - else { query.finish(); } @@ -709,7 +686,6 @@ bool DatabaseQueries::cleanFeeds(QSqlDatabase db, const QStringList& ids, bool c "WHERE feed IN (%1) AND is_deleted = 0 AND is_pdeleted = 0 AND is_read = 1 AND account_id = :account_id;") .arg(ids.join(QSL(", ")))); } - else { q.prepare(QString("UPDATE Messages SET is_deleted = :deleted " "WHERE feed IN (%1) AND is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id;") @@ -723,7 +699,6 @@ bool DatabaseQueries::cleanFeeds(QSqlDatabase db, const QStringList& ids, bool c qDebug("Cleaning of feeds failed: '%s'.", qPrintable(q.lastError().text())); return false; } - else { return true; } @@ -740,7 +715,6 @@ bool DatabaseQueries::purgeLeftoverMessages(QSqlDatabase db, int account_id) { qWarning("Removing of left over messages failed: '%s'.", qPrintable(q.lastError().text())); return false; } - else { return true; } @@ -767,12 +741,10 @@ bool DatabaseQueries::storeAccountTree(QSqlDatabase db, RootItem* tree_root, int if (query_category.exec()) { child->setId(query_category.lastInsertId().toInt()); } - else { return false; } } - else if (child->kind() == RootItemKind::Feed) { Feed* feed = child->toFeed(); query_feed.bindValue(QSL(":title"), feed->title()); @@ -787,7 +759,6 @@ bool DatabaseQueries::storeAccountTree(QSqlDatabase db, RootItem* tree_root, int if (query_feed.exec()) { feed->setId(query_feed.lastInsertId().toInt()); } - else { return false; } @@ -807,7 +778,6 @@ QStringList DatabaseQueries::customIdsOfMessagesFromAccount(QSqlDatabase db, int if (ok != nullptr) { *ok = q.exec(); } - else { q.exec(); } @@ -829,7 +799,6 @@ QStringList DatabaseQueries::customIdsOfMessagesFromBin(QSqlDatabase db, int acc if (ok != nullptr) { *ok = q.exec(); } - else { q.exec(); } @@ -852,7 +821,6 @@ QStringList DatabaseQueries::customIdsOfMessagesFromFeed(QSqlDatabase db, int fe if (ok != nullptr) { *ok = q.exec(); } - else { q.exec(); } @@ -885,7 +853,6 @@ QList DatabaseQueries::getOwnCloudAccounts(QSqlDatabase db, bool* *ok = true; } } - else { qWarning("OwnCloud: Getting list of activated accounts failed: '%s'.", qPrintable(query.lastError().text())); @@ -921,7 +888,6 @@ QList DatabaseQueries::getTtRssAccounts(QSqlDatabase db, bool* ok) *ok = true; } } - else { qWarning("TT-RSS: Getting list of activated accounts failed: '%s'.", qPrintable(query.lastError().text())); @@ -956,7 +922,6 @@ bool DatabaseQueries::overwriteOwnCloudAccount(QSqlDatabase db, const QString& u if (query.exec()) { return true; } - else { qWarning("ownCloud: Updating account failed: '%s'.", qPrintable(query.lastError().text())); return false; @@ -978,7 +943,6 @@ bool DatabaseQueries::createOwnCloudAccount(QSqlDatabase db, int id_to_assign, c if (q.exec()) { return true; } - else { qWarning("ownCloud: Inserting of new account failed: '%s'.", qPrintable(q.lastError().text())); return false; @@ -1011,7 +975,6 @@ int DatabaseQueries::createAccount(QSqlDatabase db, const QString& code, bool* o return id_to_assign; } - else { if (ok != nullptr) { *ok = false; @@ -1134,7 +1097,6 @@ int DatabaseQueries::addCategory(QSqlDatabase db, int parent_id, int account_id, // Query failed. return 0; } - else { if (ok != nullptr) { *ok = true; @@ -1191,7 +1153,6 @@ int DatabaseQueries::addFeed(QSqlDatabase db, int parent_id, int account_id, con if (password.isEmpty()) { q.bindValue(QSL(":password"), password); } - else { q.bindValue(QSL(":password"), TextFactory::encrypt(password)); } @@ -1214,7 +1175,6 @@ int DatabaseQueries::addFeed(QSqlDatabase db, int parent_id, int account_id, con return new_id; } - else { if (ok != nullptr) { *ok = false; @@ -1248,7 +1208,6 @@ bool DatabaseQueries::editFeed(QSqlDatabase db, int parent_id, int feed_id, cons if (password.isEmpty()) { q.bindValue(QSL(":password"), password); } - else { q.bindValue(QSL(":password"), TextFactory::encrypt(password)); } @@ -1291,7 +1250,6 @@ QList DatabaseQueries::getAccounts(QSqlDatabase db, bool* ok) { *ok = true; } } - else { if (ok != nullptr) { *ok = false; @@ -1317,7 +1275,6 @@ Assignment DatabaseQueries::getCategories(QSqlDatabase db, int account_id, bool* *ok = false; } } - else { if (ok != nullptr) { *ok = true; @@ -1409,7 +1366,6 @@ bool DatabaseQueries::overwriteTtRssAccount(QSqlDatabase db, const QString& user if (q.exec()) { return true; } - else { qWarning("TT-RSS: Updating account failed: '%s'.", qPrintable(q.lastError().text())); return false; @@ -1435,7 +1391,6 @@ bool DatabaseQueries::createTtRssAccount(QSqlDatabase db, int id_to_assign, cons if (q.exec()) { return true; } - else { qWarning("TT-RSS: Saving of new account failed: '%s'.", qPrintable(q.lastError().text())); return false; @@ -1457,7 +1412,6 @@ Assignment DatabaseQueries::getTtRssCategories(QSqlDatabase db, int account_id, *ok = false; } } - else { if (ok != nullptr) { *ok = true; @@ -1489,7 +1443,6 @@ Assignment DatabaseQueries::getTtRssFeeds(QSqlDatabase db, int account_id, bool* *ok = false; } } - else { if (ok != nullptr) { *ok = true; diff --git a/src/miscellaneous/debugging.cpp b/src/miscellaneous/debugging.cpp index e7c879514..63faf9a58 100755 --- a/src/miscellaneous/debugging.cpp +++ b/src/miscellaneous/debugging.cpp @@ -40,7 +40,6 @@ void Debugging::performLog(const char* message, QtMsgType type, const char* file if (file == 0 || function == 0 || line < 0) { fprintf(stderr, "[%s] %s: %s (%s)\n", APP_LOW_NAME, type_string, message, mbstr); } - else { fprintf(stderr, "[%s] %s (%s)\n Type: %s\n File: %s (line %d)\n Function: %s\n\n", APP_LOW_NAME, message, mbstr, type_string, file, line, function); diff --git a/src/miscellaneous/feedreader.cpp b/src/miscellaneous/feedreader.cpp index ab8ebcb31..ecf64c1fe 100755 --- a/src/miscellaneous/feedreader.cpp +++ b/src/miscellaneous/feedreader.cpp @@ -114,7 +114,6 @@ void FeedReader::updateAutoUpdateStatus() { m_autoUpdateTimer->start(); qDebug("Auto-update timer started with interval %d.", m_autoUpdateTimer->interval()); } - else { qDebug("Auto-update timer is already running."); } @@ -222,7 +221,6 @@ void FeedReader::checkServicesForAsyncOperations(bool wait_for_future) { qWarning("Waiting for previously started saving of cached service data."); m_cacheSaveFutureWatcher->future().waitForFinished(); } - else { qWarning("Some cached service data are being saved now, so aborting this saving cycle."); // Some cache saving is now running. @@ -241,7 +239,6 @@ void FeedReader::checkServicesForAsyncOperations(bool wait_for_future) { qDebug("Waiting for saving of cached service data to finish."); future.waitForFinished(); } - else { m_cacheSaveFutureWatcher->setFuture(future); } diff --git a/src/miscellaneous/iconfactory.cpp b/src/miscellaneous/iconfactory.cpp index 3ba309b4f..c171b139f 100755 --- a/src/miscellaneous/iconfactory.cpp +++ b/src/miscellaneous/iconfactory.cpp @@ -56,7 +56,6 @@ QPixmap IconFactory::pixmap(const QString& name) { if (QIcon::themeName() == APP_NO_THEME) { return QPixmap(); } - else { return QIcon::fromTheme(name).pixmap(64, 64); } @@ -106,7 +105,6 @@ void IconFactory::loadCurrentIconTheme() { qDebug("Loading icon theme '%s'.", qPrintable(theme_name_from_settings)); QIcon::setThemeName(theme_name_from_settings); } - else { // Desired icon theme is not currently available. // Install "default" icon theme instead. diff --git a/src/miscellaneous/iofactory.cpp b/src/miscellaneous/iofactory.cpp index 247486ebe..ece033507 100755 --- a/src/miscellaneous/iofactory.cpp +++ b/src/miscellaneous/iofactory.cpp @@ -62,7 +62,6 @@ QString IOFactory::ensureUniqueFilename(const QString& name, const QString& appe if (index < 0) { tmp_filename.append(append_string); } - else { tmp_filename = tmp_filename.left(index) + append_string + tmp_filename.mid(index); } @@ -94,7 +93,6 @@ QByteArray IOFactory::readTextFile(const QString& file_path) { input_file.close(); return input_data; } - else { throw IOException(tr("Cannot open file '%1' for reading.").arg(QDir::toNativeSeparators(file_path))); } @@ -111,7 +109,6 @@ void IOFactory::writeTextFile(const QString& file_path, const QByteArray& data, input_file.flush(); input_file.close(); } - else { throw IOException(tr("Cannot open file '%1' for writting.").arg(QDir::toNativeSeparators(file_path))); } diff --git a/src/miscellaneous/localization.cpp b/src/miscellaneous/localization.cpp index 09908de6b..461ace39e 100755 --- a/src/miscellaneous/localization.cpp +++ b/src/miscellaneous/localization.cpp @@ -50,7 +50,6 @@ void Localization::loadActiveLanguage() { qPrintable(real_loaded_locale)); desired_localization = real_loaded_locale; } - else { qWarning("Application localization '%s' was not loaded. Loading '%s' instead.", qPrintable(desired_localization), @@ -62,7 +61,6 @@ void Localization::loadActiveLanguage() { Application::installTranslator(qt_translator); qDebug("Qt localization '%s' loaded successfully.", qPrintable(desired_localization)); } - else { qWarning("Qt localization '%s' was not loaded.", qPrintable(desired_localization)); } diff --git a/src/miscellaneous/settings.cpp b/src/miscellaneous/settings.cpp index b1bc1b59b..924e6c54e 100755 --- a/src/miscellaneous/settings.cpp +++ b/src/miscellaneous/settings.cpp @@ -324,7 +324,6 @@ void Settings::finishRestoration(const QString& desired_settings_file_path) { QFile::remove(backup_settings_file); qDebug("Settings file was restored successully."); } - else { qCritical("Settings file was NOT restored due to error when copying the file."); } @@ -345,7 +344,6 @@ Settings* Settings::setupSettings(QObject* parent) { if (properties.m_type == SettingsProperties::Portable) { qDebug("Initializing settings in '%s' (portable way).", qPrintable(QDir::toNativeSeparators(properties.m_absoluteSettingsFileName))); } - else { qDebug("Initializing settings in '%s' (non-portable way).", qPrintable(QDir::toNativeSeparators(properties.m_absoluteSettingsFileName))); } @@ -375,7 +373,6 @@ SettingsProperties Settings::determineProperties() { properties.m_type = SettingsProperties::Portable; properties.m_baseDirectory = app_path; } - else { properties.m_type = SettingsProperties::NonPortable; properties.m_baseDirectory = home_path; diff --git a/src/miscellaneous/simplecrypt/simplecrypt.cpp b/src/miscellaneous/simplecrypt/simplecrypt.cpp index a78584cf0..0a4ce60ac 100755 --- a/src/miscellaneous/simplecrypt/simplecrypt.cpp +++ b/src/miscellaneous/simplecrypt/simplecrypt.cpp @@ -91,7 +91,6 @@ QByteArray SimpleCrypt::encryptToByteArray(QByteArray plaintext) { ba = qCompress(ba, 9); //maximum compression flags |= CryptoFlagCompression; } - else if (m_compressionMode == CompressionAuto) { QByteArray compressed = qCompress(ba, 9); @@ -108,7 +107,6 @@ QByteArray SimpleCrypt::encryptToByteArray(QByteArray plaintext) { QDataStream s(&integrityProtection, QIODevice::WriteOnly); s << qChecksum(ba.constData(), ba.length()); } - else if (m_protectionMode == ProtectionHash) { flags |= CryptoFlagHash; QCryptographicHash hash(QCryptographicHash::Sha1); @@ -221,7 +219,6 @@ QByteArray SimpleCrypt::decryptToByteArray(QByteArray cypher) { quint16 checksum = qChecksum(ba.constData(), ba.length()); integrityOk = (checksum == storedChecksum); } - else if (flags.testFlag(CryptoFlagHash)) { if (ba.length() < 20) { m_lastError = ErrorIntegrityFailed; diff --git a/src/miscellaneous/simpleregexp.cpp b/src/miscellaneous/simpleregexp.cpp index ae3944883..c4b09bbd4 100755 --- a/src/miscellaneous/simpleregexp.cpp +++ b/src/miscellaneous/simpleregexp.cpp @@ -40,7 +40,6 @@ void SimpleRegExp::setMinimal(bool minimal) { if (minimal) { opt = patternOptions() | QRegularExpression::InvertedGreedinessOption; } - else { opt = patternOptions() & ~QRegularExpression::InvertedGreedinessOption; } @@ -57,7 +56,6 @@ int SimpleRegExp::indexIn(const QString& str, int offset) const { that->m_capturedTexts.clear(); return -1; } - else { that->m_matchedLength = m.capturedLength(); that->m_capturedTexts = m.capturedTexts(); @@ -73,7 +71,6 @@ QString SimpleRegExp::cap(int nth) const { if (nth >= 0 && m_capturedTexts.size() > nth) { return m_capturedTexts.at(nth); } - else { return QString(); } diff --git a/src/miscellaneous/skinfactory.cpp b/src/miscellaneous/skinfactory.cpp index e279f2171..d4cadb85e 100755 --- a/src/miscellaneous/skinfactory.cpp +++ b/src/miscellaneous/skinfactory.cpp @@ -50,7 +50,6 @@ void SkinFactory::loadCurrentSkin() { qDebug("Skin '%s' loaded.", qPrintable(skin_name)); return; } - else { qWarning("Failed to load skin '%s'.", qPrintable(skin_name)); } @@ -84,7 +83,6 @@ QString SkinFactory::adBlockedPage(const QString& subscription, const QString& r tr("Blocked by set: \"%1\"
Blocked by filter: \"%2\"") .arg(subscription, rule)); - return currentSkin().m_layoutMarkupWrapper.arg(tr("This page was blocked by AdBlock"), adblocked); } diff --git a/src/miscellaneous/systemfactory.cpp b/src/miscellaneous/systemfactory.cpp index 36d70f6ba..2b59b8cc2 100755 --- a/src/miscellaneous/systemfactory.cpp +++ b/src/miscellaneous/systemfactory.cpp @@ -59,7 +59,6 @@ SystemFactory::AutoStartStatus SystemFactory::autoStartStatus() const { if (autostart_enabled) { return AutoStartStatus::Enabled; } - else { return AutoStartStatus::Disabled; } @@ -82,7 +81,6 @@ SystemFactory::AutoStartStatus SystemFactory::autoStartStatus() const { bool hidden_value = desktop_settings.value(QSL("Desktop Entry/Hidden"), false).toBool(); return hidden_value ? SystemFactory::Disabled : SystemFactory::Enabled; } - else { return SystemFactory::Disabled; } @@ -103,7 +101,6 @@ QString SystemFactory::autostartDesktopFileLocation() const { // in 'autostart' subdirectory. desktop_file_location = xdg_config_path + QSL("/autostart/") + APP_DESKTOP_ENTRY_FILE; } - else { // Desired variable is not set, look for the default 'autostart' subdirectory. const QString home_directory(qgetenv("HOME")); @@ -186,7 +183,6 @@ bool SystemFactory::removeTrolltechJunkRegistryKeys() { registry_key.sync(); return registry_key.status() == QSettings::NoError; } - else { return false; } @@ -209,7 +205,6 @@ QString SystemFactory::loggedInUser() const { void SystemFactory::checkForUpdates() const { Downloader* downloader = new Downloader(); - connect(downloader, &Downloader::completed, [this, downloader]() { QPair, QNetworkReply::NetworkError> result; result.second = downloader->lastOutputError(); @@ -220,10 +215,8 @@ void SystemFactory::checkForUpdates() const { } emit updatesChecked(result); - downloader->deleteLater(); }); - downloader->downloadFile(RELEASES_LIST); } @@ -239,7 +232,6 @@ bool SystemFactory::isVersionNewer(const QString& new_version, const QString& ba // New version is indeed higher thatn current version. return true; } - else if (new_number < base_number) { return false; } @@ -250,12 +242,10 @@ bool SystemFactory::isVersionNewer(const QString& new_version, const QString& ba // Versions are the same. return false; } - else { if (new_version_tkn.isEmpty()) { return false; } - else { return new_version_tkn.join(QString()).toInt() > 0; } diff --git a/src/miscellaneous/textfactory.cpp b/src/miscellaneous/textfactory.cpp index 280b565db..536b0f085 100755 --- a/src/miscellaneous/textfactory.cpp +++ b/src/miscellaneous/textfactory.cpp @@ -96,13 +96,11 @@ QDateTime TextFactory::parseDateTime(const QString& date_time) { // the original UTC. return dt.addSecs(- QTime(0, 0, 0, 0).secsTo(time_zone_offset)); } - else { // Vice versa. return dt.addSecs(QTime(0, 0, 0, 0).secsTo(time_zone_offset)); } } - else { return dt; } @@ -129,7 +127,6 @@ QString TextFactory::shorten(const QString& input, int text_length_limit) { if (input.size() > text_length_limit) { return input.left(text_length_limit - ELLIPSIS_LENGTH) + QString(ELLIPSIS_LENGTH, QL1C('.')); } - else { return input; } @@ -143,7 +140,6 @@ quint64 TextFactory::initializeSecretEncryptionKey() { try { s_encryptionKey = (quint64) QString(IOFactory::readTextFile(encryption_file_path)).toLongLong(); } - catch (ApplicationException) { // Well, key does not exist or is invalid, generate and save one. s_encryptionKey = generateSecretEncryptionKey(); diff --git a/src/network-web/adblock/adblockaddsubscriptiondialog.cpp b/src/network-web/adblock/adblockaddsubscriptiondialog.cpp index c70d47fb9..79cba641b 100755 --- a/src/network-web/adblock/adblockaddsubscriptiondialog.cpp +++ b/src/network-web/adblock/adblockaddsubscriptiondialog.cpp @@ -57,10 +57,8 @@ AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget* parent) connect(m_ui->m_cmbPresets, static_cast(&QComboBox::currentIndexChanged), this, &AdBlockAddSubscriptionDialog::indexChanged); connect(m_ui->m_cbUsePredefined, &QCheckBox::toggled, this, &AdBlockAddSubscriptionDialog::presetsEnabledChanged); - m_ui->m_cbUsePredefined->setChecked(true); indexChanged(0); - setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint); setWindowIcon(qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE)); } diff --git a/src/network-web/adblock/adblockdialog.cpp b/src/network-web/adblock/adblockdialog.cpp index c6035f0fc..a5bf6bb27 100755 --- a/src/network-web/adblock/adblockdialog.cpp +++ b/src/network-web/adblock/adblockdialog.cpp @@ -39,37 +39,26 @@ AdBlockDialog::AdBlockDialog(QWidget* parent) m_loaded(false) { m_ui->setupUi(this); m_ui->m_cbEnable->setChecked(m_manager->isEnabled()); - setAttribute(Qt::WA_DeleteOnClose); setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint); setWindowIcon(qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE)); - QPushButton* btn_options = m_ui->m_buttonBox->addButton(QDialogButtonBox::FirstButton); btn_options->setText(tr("Options")); - QMenu* menu = new QMenu(btn_options); - m_actionAddRule = menu->addAction(tr("Add rule"), this, &AdBlockDialog::addRule); m_actionRemoveRule = menu->addAction(tr("Remove rule"), this, &AdBlockDialog::removeRule); - menu->addSeparator(); - m_actionAddSubscription = menu->addAction(tr("Add subscription"), this, &AdBlockDialog::addSubscription); m_actionRemoveSubscription = menu->addAction(tr("Remove subscription"), this, &AdBlockDialog::removeSubscription); - menu->addAction(tr("Update subscriptions"), m_manager, &AdBlockManager::updateAllSubscriptions); menu->addSeparator(); menu->addAction(tr("Learn about writing rules..."), this, &AdBlockDialog::learnAboutRules); btn_options->setMenu(menu); - - - connect(menu, &QMenu::aboutToShow, this, &AdBlockDialog::aboutToShowMenu); connect(m_ui->m_cbEnable, &QCheckBox::toggled, this, &AdBlockDialog::enableAdBlock); connect(m_ui->m_tabSubscriptions, &QTabWidget::currentChanged, this, &AdBlockDialog::currentChanged); connect(m_ui->m_buttonBox, &QDialogButtonBox::rejected, this, &AdBlockDialog::close); load(); - m_ui->m_buttonBox->setFocus(); } diff --git a/src/network-web/adblock/adblockicon.cpp b/src/network-web/adblock/adblockicon.cpp index c1b64a8e7..6e637ee5c 100755 --- a/src/network-web/adblock/adblockicon.cpp +++ b/src/network-web/adblock/adblockicon.cpp @@ -38,7 +38,6 @@ AdBlockIcon::AdBlockIcon(AdBlockManager* parent) setText(QSL("AdBlock")); setMenu(new QMenu()); setIcon(m_enabled ? qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE) : qApp->icons()->miscIcon(ADBLOCK_ICON_DISABLED)); - connect(m_manager, SIGNAL(enabledChanged(bool)), this, SLOT(setEnabled(bool))); connect(menu(), SIGNAL(aboutToShow()), this, SLOT(createMenu())); connect(this, &QAction::triggered, m_manager, &AdBlockManager::showDialog); @@ -136,7 +135,6 @@ void AdBlockIcon::toggleCustomFilter() { if (customList->containsFilter(filter)) { customList->removeFilter(filter); } - else { AdBlockRule* rule = new AdBlockRule(filter, customList); customList->addRule(rule); @@ -154,7 +152,6 @@ void AdBlockIcon::animateIcon() { if (icon().isNull()) { setIcon(qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE)); } - else { setIcon(QIcon()); } diff --git a/src/network-web/adblock/adblockmanager.cpp b/src/network-web/adblock/adblockmanager.cpp index d79e19786..bb26c8cd9 100755 --- a/src/network-web/adblock/adblockmanager.cpp +++ b/src/network-web/adblock/adblockmanager.cpp @@ -43,10 +43,8 @@ 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)) { - m_adblockIcon = new AdBlockIcon(this); m_adblockIcon->setObjectName(QSL("m_adblockIconAction")); - load(); } @@ -74,7 +72,6 @@ void AdBlockManager::setEnabled(bool enabled) { if (m_enabled) { m_matcher->update(); } - else { m_matcher->clear(); } @@ -106,14 +103,11 @@ bool AdBlockManager::block(QWebEngineUrlRequestInfo& request) { if (request.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame) { QUrlQuery query; QUrl url(QSL("rssguard:adblockedpage")); - query.addQueryItem(QSL("rule"), blockedRule->filter()); query.addQueryItem(QSL("subscription"), blockedRule->subscription()->title()); url.setQuery(query); - request.redirect(url); } - else { res = true; request.block(true); @@ -146,7 +140,6 @@ bool AdBlockManager::addSubscriptionFromUrl(const QUrl& url) { if (pair.first == QL1S("location")) { subscriptionUrl = pair.second; } - else if (pair.first == QL1S("title")) { subscriptionTitle = pair.second; } @@ -339,7 +332,6 @@ QString AdBlockManager::elementHidingRules(const QUrl& url) const { if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url)) { return QString(); } - else { return m_matcher->elementHidingRules(); } @@ -349,7 +341,6 @@ QString AdBlockManager::elementHidingRulesForDomain(const QUrl& url) const { if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url)) { return QString(); } - else { return m_matcher->elementHidingRulesForDomain(url.host()); } diff --git a/src/network-web/adblock/adblockmatcher.cpp b/src/network-web/adblock/adblockmatcher.cpp index 73712f898..88e1e9864 100755 --- a/src/network-web/adblock/adblockmatcher.cpp +++ b/src/network-web/adblock/adblockmatcher.cpp @@ -116,7 +116,6 @@ QString AdBlockMatcher::elementHidingRulesForDomain(const QString& domain) const rules.append(QSL("{display:none !important;}\n")); addedRulesCount = 0; } - else { rules.append(rule->cssSelector() + QLatin1Char(',')); addedRulesCount++; @@ -153,26 +152,21 @@ void AdBlockMatcher::update() { if (rule->isException()) { exceptionCssRules.append(rule); } - else { cssRulesHash.insert(rule->cssSelector(), rule); } } - else if (rule->isDocument()) { m_documentRules.append(rule); } - else if (rule->isElemhide()) { m_elemhideRules.append(rule); } - else if (rule->isException()) { if (!m_networkExceptionTree.add(rule)) { m_networkExceptionRules.append(rule); } } - else { if (!m_networkBlockTree.add(rule)) { m_networkBlockRules.append(rule); @@ -209,13 +203,11 @@ void AdBlockMatcher::update() { if (rule->isDomainRestricted()) { m_domainRestrictedCssRules.append(rule); } - else if (Q_UNLIKELY(hidingRulesCount == 1000)) { m_elementHidingRules.append(rule->cssSelector()); m_elementHidingRules.append(QL1S("{display:none !important;} ")); hidingRulesCount = 0; } - else { m_elementHidingRules.append(rule->cssSelector() + QLatin1Char(',')); hidingRulesCount++; diff --git a/src/network-web/adblock/adblockrule.cpp b/src/network-web/adblock/adblockrule.cpp index da68b7da7..a87061c36 100755 --- a/src/network-web/adblock/adblockrule.cpp +++ b/src/network-web/adblock/adblockrule.cpp @@ -178,7 +178,6 @@ bool AdBlockRule::urlMatch(const QUrl& url) const { if (!hasOption(DocumentOption) && !hasOption(ElementHideOption)) { return false; } - else { const QString encodedUrl = url.toEncoded(); const QString domain = url.host(); @@ -259,7 +258,6 @@ bool AdBlockRule::matchDomain(const QString& domain) const { } } } - else if (m_allowedDomains.isEmpty()) { foreach (const QString& d, m_blockedDomains) { if (isMatchingDomain(domain, d)) { @@ -269,7 +267,6 @@ bool AdBlockRule::matchDomain(const QString& domain) const { return true; } - else { foreach (const QString& d, m_blockedDomains) { if (isMatchingDomain(domain, d)) { @@ -378,70 +375,58 @@ void AdBlockRule::parseFilter() { parseDomains(option.mid(7), QL1C('|')); ++handledOptions; } - else if (option == QL1S("match-case")) { m_caseSensitivity = Qt::CaseSensitive; ++handledOptions; } - else if (option.endsWith(QL1S("third-party"))) { setOption(ThirdPartyOption); setException(ThirdPartyOption, option.startsWith(QL1C('~'))); ++handledOptions; } - else if (option.endsWith(QL1S("object"))) { setOption(ObjectOption); setException(ObjectOption, option.startsWith(QL1C('~'))); ++handledOptions; } - else if (option.endsWith(QL1S("subdocument"))) { setOption(SubdocumentOption); setException(SubdocumentOption, option.startsWith(QL1C('~'))); ++handledOptions; } - else if (option.endsWith(QL1S("xmlhttprequest"))) { setOption(XMLHttpRequestOption); setException(XMLHttpRequestOption, option.startsWith(QL1C('~'))); ++handledOptions; } - else if (option.endsWith(QL1S("image"))) { setOption(ImageOption); setException(ImageOption, option.startsWith(QL1C('~'))); ++handledOptions; } - else if (option.endsWith(QL1S("script"))) { setOption(ScriptOption); setException(ScriptOption, option.startsWith(QL1C('~'))); ++handledOptions; } - else if (option.endsWith(QL1S("stylesheet"))) { setOption(StyleSheetOption); setException(StyleSheetOption, option.startsWith(QL1C('~'))); ++handledOptions; } - else if (option.endsWith(QL1S("object-subrequest"))) { setOption(ObjectSubrequestOption); setException(ObjectSubrequestOption, option.startsWith(QL1C('~'))); ++handledOptions; } - else if (option == QL1S("document") && m_isException) { setOption(DocumentOption); ++handledOptions; } - else if (option == QL1S("elemhide") && m_isException) { setOption(ElementHideOption); ++handledOptions; } - else if (option == QL1S("collapse")) { // Hiding placeholders of blocked elements is enabled by default. ++handledOptions; @@ -521,7 +506,6 @@ void AdBlockRule::parseDomains(const QString& domains, const QChar& separator) { if (domain.startsWith(QL1C('~'))) { m_blockedDomains.append(domain.mid(1)); } - else { m_allowedDomains.append(domain); } @@ -603,14 +587,12 @@ QString AdBlockRule::createRegExpFromFilter(const QString& filter) const { parsed.append(QL1S("^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?")); i++; } - else { parsed.append('^'); } break; } - else if (i == filter.size() - 1) { parsed.append(QL1C('$')); break; @@ -622,7 +604,6 @@ QString AdBlockRule::createRegExpFromFilter(const QString& filter) const { if (!wordCharacter(c)) { parsed.append(QL1C('\\') + c); } - else { parsed.append(c); } @@ -649,20 +630,16 @@ bool AdBlockRule::stringMatch(const QString& domain, const QString& encodedUrl) if (m_type == StringContainsMatchRule) { return encodedUrl.contains(m_matchString, m_caseSensitivity); } - else if (m_type == DomainMatchRule) { return isMatchingDomain(domain, m_matchString); } - else if (m_type == StringEndsMatchRule) { return encodedUrl.endsWith(m_matchString, m_caseSensitivity); } - else if (m_type == RegExpMatchRule) { if (!isMatchingRegExpStrings(encodedUrl)) { return false; } - else { return (m_regExp->regExp.indexIn(encodedUrl) != -1); } diff --git a/src/network-web/adblock/adblocksubscription.cpp b/src/network-web/adblock/adblocksubscription.cpp index 7c262b2e4..cdfe32d9a 100755 --- a/src/network-web/adblock/adblocksubscription.cpp +++ b/src/network-web/adblock/adblocksubscription.cpp @@ -176,7 +176,6 @@ bool AdBlockSubscription::saveDownloadedData(const QByteArray& data) { qWarning("Unable to open AdBlock file '%s' for writing.", qPrintable(m_filePath)); return false; } - else { // Write subscription header file.write(QString("Title: %1\nUrl: %2\n").arg(title(), url().toString()).toUtf8()); @@ -190,7 +189,6 @@ const AdBlockRule* AdBlockSubscription::rule(int offset) const { if (IS_IN_ARRAY(offset, m_rules)) { return m_rules[offset]; } - else { return 0; } @@ -213,7 +211,6 @@ const AdBlockRule* AdBlockSubscription::enableRule(int offset) { return rule; } - else { return 0; } @@ -282,7 +279,6 @@ void AdBlockCustomList::loadSubscription(const QStringList& disabledRules) { try { rules = QString::fromUtf8(IOFactory::readTextFile(filePath())); } - catch (ApplicationException&) { } diff --git a/src/network-web/adblock/adblocktreewidget.cpp b/src/network-web/adblock/adblocktreewidget.cpp index 053343319..ed823e786 100755 --- a/src/network-web/adblock/adblocktreewidget.cpp +++ b/src/network-web/adblock/adblocktreewidget.cpp @@ -35,7 +35,6 @@ AdBlockTreeWidget::AdBlockTreeWidget(AdBlockSubscription* subscription, QWidget* setAlternatingRowColors(true); setLayoutDirection(Qt::LeftToRight); setIndentation(5); - connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint))); connect(this, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(itemChanged(QTreeWidgetItem*))); connect(m_subscription, SIGNAL(subscriptionUpdated()), this, SLOT(subscriptionUpdated())); @@ -50,7 +49,6 @@ void AdBlockTreeWidget::showRule(const AdBlockRule* rule) { if (!m_topItem && rule) { m_ruleToBeSelected = rule->filter(); } - else if (!m_ruleToBeSelected.isEmpty()) { QList items = findItems(m_ruleToBeSelected, Qt::MatchRecursive); @@ -101,13 +99,11 @@ void AdBlockTreeWidget::itemChanged(QTreeWidgetItem* item) { const AdBlockRule* rule = m_subscription->disableRule(offset); adjustItemFeatures(item, rule); } - else if (item->checkState(0) == Qt::Checked && !oldRule->isEnabled()) { // Enable rule. const AdBlockRule* rule = m_subscription->enableRule(offset); adjustItemFeatures(item, rule); } - else if (m_subscription->canEditRules()) { // Custom rule has been changed. AdBlockRule* newRule = new AdBlockRule(item->text(0), m_subscription); @@ -199,7 +195,6 @@ void AdBlockTreeWidget::adjustItemFeatures(QTreeWidgetItem* item, const AdBlockR item->setForeground(0, QColor(Qt::darkGreen)); item->setFont(0, QFont()); } - else if (rule->isCssRule()) { item->setForeground(0, QColor(Qt::darkBlue)); item->setFont(0, QFont()); diff --git a/src/network-web/basenetworkaccessmanager.cpp b/src/network-web/basenetworkaccessmanager.cpp index 03e989397..a609a065a 100755 --- a/src/network-web/basenetworkaccessmanager.cpp +++ b/src/network-web/basenetworkaccessmanager.cpp @@ -43,11 +43,9 @@ void BaseNetworkAccessManager::loadSettings() { // No extra setting is needed, set new proxy and exit this method. setProxy(QNetworkProxy::NoProxy); } - else if (selected_proxy_type == QNetworkProxy::DefaultProxy) { setProxy(QNetworkProxy::applicationProxy()); } - else { const Settings* settings = qApp->settings(); // Custom proxy is selected, set it up. diff --git a/src/network-web/downloader.cpp b/src/network-web/downloader.cpp index 051f89faf..4982b7ec4 100755 --- a/src/network-web/downloader.cpp +++ b/src/network-web/downloader.cpp @@ -65,7 +65,6 @@ void Downloader::manipulateData(const QString& url, QNetworkAccessManager::Opera qDebug("Replacing URI schemes for '%s'.", qPrintable(non_const_url)); request.setUrl(non_const_url.replace(QRegExp(QString('^') + URI_SCHEME_FEED), QString(URI_SCHEME_HTTP))); } - else { request.setUrl(non_const_url); } @@ -77,15 +76,12 @@ void Downloader::manipulateData(const QString& url, QNetworkAccessManager::Opera if (operation == QNetworkAccessManager::PostOperation) { runPostRequest(request, m_inputData); } - else if (operation == QNetworkAccessManager::GetOperation) { runGetRequest(request); } - else if (operation == QNetworkAccessManager::PutOperation) { runPutRequest(request, m_inputData); } - else if (operation == QNetworkAccessManager::DeleteOperation) { runDeleteRequest(request); } @@ -106,7 +102,6 @@ void Downloader::finished() { if (redirection_url.host().isEmpty()) { request.setUrl(QUrl(reply->request().url().scheme() + QSL("://") + reply->request().url().host() + redirection_url.toString())); } - else { request.setUrl(redirection_url); } @@ -117,20 +112,16 @@ void Downloader::finished() { if (reply_operation == QNetworkAccessManager::GetOperation) { runGetRequest(request); } - else if (reply_operation == QNetworkAccessManager::PostOperation) { runPostRequest(request, m_inputData); } - else if (reply_operation == QNetworkAccessManager::PutOperation) { runPutRequest(request, m_inputData); } - else if (reply_operation == QNetworkAccessManager::DeleteOperation) { runDeleteRequest(request); } } - else { // No redirection is indicated. Final file is obtained in our "reply" object. // Read the data into output buffer. @@ -187,7 +178,6 @@ void Downloader::runGetRequest(const QNetworkRequest& request) { m_activeReply->setProperty("protected", m_targetProtected); m_activeReply->setProperty("username", m_targetUsername); m_activeReply->setProperty("password", m_targetPassword); - connect(m_activeReply, &QNetworkReply::downloadProgress, this, &Downloader::progressInternal); connect(m_activeReply, &QNetworkReply::finished, this, &Downloader::finished); } diff --git a/src/network-web/downloadmanager.cpp b/src/network-web/downloadmanager.cpp index f02407427..7d2c143eb 100755 --- a/src/network-web/downloadmanager.cpp +++ b/src/network-web/downloadmanager.cpp @@ -264,7 +264,6 @@ void DownloadItem::downloadReadyRead() { m_ui->m_lblInfoDownload->setText(tr("Error when saving file: %1").arg(m_output.errorString())); m_ui->m_btnStopDownload->click(); } - else { m_startedSaving = true; @@ -344,7 +343,6 @@ double DownloadItem::currentSpeed() const { if (!downloading()) { return -1.0; } - else { return m_bytesReceived * 1000.0 / m_downloadTime.elapsed(); } @@ -373,12 +371,10 @@ void DownloadItem::updateDownloadInfoLabel() { DownloadManager::dataString((int)speed), remaining); } - else { if (m_bytesReceived == bytes_total) { info = DownloadManager::dataString(m_output.size()); } - else { info = tr("%1 of %2 - download completed").arg(DownloadManager::dataString(m_bytesReceived), DownloadManager::dataString(m_bytesReceived)); @@ -416,9 +412,9 @@ void DownloadItem::finished() { if (downloadedSuccessfully()) { qApp->showGuiMessage(tr("Download finished"), tr("File '%1' is downloaded.\nClick here to open parent directory.").arg(QDir::toNativeSeparators(m_output.fileName())), - QSystemTrayIcon::Information, 0, false, [this] { - openFolder(); - }); + QSystemTrayIcon::Information, 0, false, [this] { + openFolder(); + }); } } @@ -474,7 +470,6 @@ int DownloadManager::downloadProgress() const { if (bytes_total <= 0) { return -1; } - else { return (bytes_received * 100.0) / bytes_total; } @@ -552,7 +547,6 @@ void DownloadManager::itemProgress() { if (progress < 0) { emit downloadFinished(); } - else { emit downloadProgressed(progress, tr("Downloading %n file(s)...", "", activeDownloads())); } @@ -688,7 +682,6 @@ QString DownloadManager::timeString(double time_remaining) { time_remaining = floor(time_remaining); remaining = tr("%n minutes remaining", "", (int) time_remaining); } - else { time_remaining = floor(time_remaining); remaining = tr("%n seconds remaining", "", (int) time_remaining); @@ -705,17 +698,14 @@ QString DownloadManager::dataString(qint64 size) { new_size = size; unit = tr("bytes"); } - else if (size < 1024 * 1024) { new_size = (double)size / (double)1024; unit = tr("kB"); } - else if (size < 1024 * 1024 * 1024) { new_size = (double)size / (double)(1024 * 1024); unit = tr("MB"); } - else { new_size = (double)size / (double)(1024 * 1024 * 1024); unit = tr("GB"); diff --git a/src/network-web/networkfactory.cpp b/src/network-web/networkfactory.cpp index 9bd71f04a..314624c8f 100755 --- a/src/network-web/networkfactory.cpp +++ b/src/network-web/networkfactory.cpp @@ -47,7 +47,6 @@ QStringList NetworkFactory::extractFeedLinksFromHtmlPage(const QUrl& url, const if (feed_link.startsWith(QL1S("//"))) { feed_link = QString(URI_SCHEME_HTTP) + feed_link.mid(2); } - else if (feed_link.startsWith(QL1C('/'))) { feed_link = url.toString(QUrl::RemovePath | QUrl::RemoveQuery | QUrl::StripTrailingSlash) + feed_link; } diff --git a/src/network-web/rssguardschemehandler.cpp b/src/network-web/rssguardschemehandler.cpp index f7fa803a1..6381e47e7 100755 --- a/src/network-web/rssguardschemehandler.cpp +++ b/src/network-web/rssguardschemehandler.cpp @@ -43,7 +43,6 @@ void RssGuardSchemeHandler::requestStarted(QWebEngineUrlRequestJob* job) { else { QBuffer* buf = new QBuffer(job); buf->setData(data); - job->reply(QByteArray("text/html"), buf); } } @@ -53,10 +52,8 @@ QByteArray RssGuardSchemeHandler::targetData(const QUrl& url) { if (url_string.contains(QSL(ADBLOCK_ADBLOCKED_PAGE))) { QUrlQuery query(url); - const QString& subscription = query.queryItemValue(QSL("subscription")); const QString& rule = query.queryItemValue(QSL("rule")); - return qApp->skins()->adBlockedPage(subscription, rule).toUtf8(); } else { diff --git a/src/network-web/silentnetworkaccessmanager.cpp b/src/network-web/silentnetworkaccessmanager.cpp index 3a83105ef..a3a5e3010 100755 --- a/src/network-web/silentnetworkaccessmanager.cpp +++ b/src/network-web/silentnetworkaccessmanager.cpp @@ -47,7 +47,6 @@ void SilentNetworkAccessManager::onAuthenticationRequired(QNetworkReply* reply, reply->setProperty("authentication-given", true); qDebug("Item '%s' requested authentication and got it.", qPrintable(reply->url().toString())); } - else { reply->setProperty("authentication-given", false); // Authentication is required but this feed does not contain it. diff --git a/src/network-web/webfactory.cpp b/src/network-web/webfactory.cpp index d78713575..e9bc34379 100755 --- a/src/network-web/webfactory.cpp +++ b/src/network-web/webfactory.cpp @@ -54,7 +54,6 @@ bool WebFactory::sendMessageViaEmail(const Message& message) { return QProcess::startDetached(QString("\"") + browser + QSL("\" ") + arguments.arg(message.m_title, stripTags(message.m_contents))); } - else { // Send it via mailto protocol. // NOTE: http://en.wikipedia.org/wiki/Mailto @@ -77,7 +76,6 @@ bool WebFactory::openUrlInExternalBrowser(const QString& url) { return result; } - else { return QDesktopServices::openUrl(url); } @@ -145,7 +143,6 @@ QAction* WebFactory::engineSettingsAction() { if (m_engineSettings == nullptr) { m_engineSettings = new QAction(qApp->icons()->fromTheme(QSL("applications-internet")), tr("Web engine settings"), this); m_engineSettings->setMenu(new QMenu()); - createMenu(m_engineSettings->menu()); connect(m_engineSettings->menu(), SIGNAL(aboutToShow()), this, SLOT(createMenu())); } @@ -163,7 +160,6 @@ void WebFactory::createMenu(QMenu* menu) { } menu->clear(); - QList actions; actions << createEngineSettingsAction(tr("Auto-load images"), QWebEngineSettings::AutoLoadImages); actions << createEngineSettingsAction(tr("JS enabled"), QWebEngineSettings::JavascriptEnabled); @@ -185,33 +181,26 @@ void WebFactory::createMenu(QMenu* menu) { 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); - #if !defined(Q_OS_LINUX) actions << createEngineSettingsAction(tr("Allow geolocation on insecure origins"), QWebEngineSettings::AllowGeolocationOnInsecureOrigins); #endif - menu->addActions(actions); } void WebFactory::webEngineSettingChanged(bool enabled) { const QAction* const act = qobject_cast(sender()); QWebEngineSettings::WebAttribute attribute = static_cast(act->data().toInt()); - qApp->settings()->setValue(WebEngineAttributes::ID, QString::number(static_cast(attribute)), enabled); QWebEngineProfile::defaultProfile()->settings()->setAttribute(attribute, act->isChecked()); } QAction* WebFactory::createEngineSettingsAction(const QString& title, QWebEngineSettings::WebAttribute attribute) { QAction* act = new QAction(title, m_engineSettings->menu()); - act->setData(attribute); act->setCheckable(true); - act->setChecked(qApp->settings()->value(WebEngineAttributes::ID, QString::number(static_cast(attribute)), true).toBool()); QWebEngineProfile::defaultProfile()->settings()->setAttribute(attribute, act->isChecked()); - connect(act, &QAction::toggled, this, &WebFactory::webEngineSettingChanged); - return act; } #endif diff --git a/src/network-web/webpage.cpp b/src/network-web/webpage.cpp index ac4e32219..98886cdfc 100755 --- a/src/network-web/webpage.cpp +++ b/src/network-web/webpage.cpp @@ -42,24 +42,19 @@ void WebPage::javaScriptAlert(const QUrl& securityOrigin, const QString& msg) { if (action == QSL("read")) { emit messageStatusChangeRequested(message_id, MarkRead); } - else if (action == QSL("unread")) { emit messageStatusChangeRequested(message_id, MarkUnread); } - else if (action == QSL("starred")) { emit messageStatusChangeRequested(message_id, MarkStarred); } - else if (action == QSL("unstarred")) { emit messageStatusChangeRequested(message_id, MarkUnstarred); } - else { QWebEnginePage::javaScriptAlert(securityOrigin, msg); } } - else { QWebEnginePage::javaScriptAlert(securityOrigin, msg); } diff --git a/src/qtsingleapplication/qtlockedfile_win.cpp b/src/qtsingleapplication/qtlockedfile_win.cpp index 5ffae9f66..f439b92af 100755 --- a/src/qtsingleapplication/qtlockedfile_win.cpp +++ b/src/qtsingleapplication/qtlockedfile_win.cpp @@ -74,7 +74,6 @@ Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) { return 0; } } - else { QT_WA({ mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); }); @@ -159,7 +158,6 @@ bool QtLockedFile::lock(LockMode mode, bool block) { rmutex = 0; ok = false; } - else if (!rmutex) { rmutex = getMutexHandle(idx, true); @@ -179,7 +177,6 @@ bool QtLockedFile::lock(LockMode mode, bool block) { return false; } } - else { Q_ASSERT(rmutexes.isEmpty()); @@ -226,7 +223,6 @@ bool QtLockedFile::unlock() { CloseHandle(rmutex); rmutex = 0; } - else { foreach (Qt::HANDLE mutex, rmutexes) { ReleaseMutex(mutex); diff --git a/src/qtsingleapplication/qtsingleapplication.cpp b/src/qtsingleapplication/qtsingleapplication.cpp index 54d114f05..f4ae963ab 100755 --- a/src/qtsingleapplication/qtsingleapplication.cpp +++ b/src/qtsingleapplication/qtsingleapplication.cpp @@ -280,7 +280,6 @@ void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessag if (activateOnMessage) { connect(peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::activateWindow); } - else { disconnect(peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::activateWindow); } diff --git a/src/services/abstract/accountcheckmodel.cpp b/src/services/abstract/accountcheckmodel.cpp index 1b8b94d00..84325acaf 100755 --- a/src/services/abstract/accountcheckmodel.cpp +++ b/src/services/abstract/accountcheckmodel.cpp @@ -33,7 +33,6 @@ RootItem* AccountCheckModel::itemForIndex(const QModelIndex& index) const { if (index.isValid() && index.model() == this) { return static_cast(index.internalPointer()); } - else { return m_rootItem; } @@ -82,7 +81,6 @@ QModelIndex AccountCheckModel::index(int row, int column, const QModelIndex& par if (child_item) { return createIndex(row, column, child_item); } - else { return QModelIndex(); } @@ -112,7 +110,6 @@ QModelIndex AccountCheckModel::indexForItem(RootItem* item) const { // We found our item. return index(candidate_index, 0, active_index); } - else { // Item is not found, add all "categories" from active_item. for (int i = 0; i < row_count; i++) { @@ -140,7 +137,6 @@ QModelIndex AccountCheckModel::parent(const QModelIndex& child) const { if (parent_item == m_rootItem) { return QModelIndex(); } - else { return createIndex(parent_item->row(), 0, parent_item); } @@ -150,14 +146,12 @@ int AccountCheckModel::rowCount(const QModelIndex& parent) const { if (parent.column() > 0) { return 0; } - else { RootItem* item = itemForIndex(parent); if (item != nullptr) { return item->childCount(); } - else { return 0; } @@ -180,12 +174,10 @@ QVariant AccountCheckModel::data(const QModelIndex& index, int role) const { if (m_checkStates.contains(item)) { return m_checkStates.value(item); } - else { return static_cast(Qt::Unchecked); } } - else if (role == Qt::DecorationRole) { switch (item->kind()) { case RootItemKind::Category: @@ -197,7 +189,6 @@ QVariant AccountCheckModel::data(const QModelIndex& index, int role) const { return QVariant(); } } - else if (role == Qt::DisplayRole) { switch (item->kind()) { case RootItemKind::Category: @@ -210,7 +201,6 @@ QVariant AccountCheckModel::data(const QModelIndex& index, int role) const { return item->title(); } } - else { return QVariant(); } diff --git a/src/services/abstract/category.cpp b/src/services/abstract/category.cpp index d1e4d628d..544d35224 100755 --- a/src/services/abstract/category.cpp +++ b/src/services/abstract/category.cpp @@ -37,7 +37,6 @@ void Category::updateCounts(bool including_total_count) { if (child->kind() == RootItemKind::Feed) { feeds.append(child->toFeed()); } - else if (child->kind() != RootItemKind::Category && child->kind() != RootItemKind::ServiceRoot) { child->updateCounts(including_total_count); } diff --git a/src/services/abstract/feed.cpp b/src/services/abstract/feed.cpp index 9d0c8bb4b..9c2d3f8b2 100755 --- a/src/services/abstract/feed.cpp +++ b/src/services/abstract/feed.cpp @@ -55,7 +55,6 @@ QVariant Feed::data(int column, int role) const { description().isEmpty() ? QString() : QString('\n') + description(), getAutoUpdateStatusDescription()); } - else { return RootItem::data(column, role); } diff --git a/src/services/abstract/gui/formfeeddetails.cpp b/src/services/abstract/gui/formfeeddetails.cpp index 6237042dc..3c89f76d2 100755 --- a/src/services/abstract/gui/formfeeddetails.cpp +++ b/src/services/abstract/gui/formfeeddetails.cpp @@ -77,7 +77,6 @@ int FormFeedDetails::addEditFeed(Feed* input_feed, RootItem* parent_to_select, c if (parent_to_select->kind() == RootItemKind::Category) { m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select))); } - else if (parent_to_select->kind() == RootItemKind::Feed) { int target_item = m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select->parent())); @@ -90,12 +89,10 @@ int FormFeedDetails::addEditFeed(Feed* input_feed, RootItem* parent_to_select, c if (!url.isEmpty()) { m_ui->m_txtUrl->lineEdit()->setText(url); } - else if (Application::clipboard()->mimeData()->hasText()) { m_ui->m_txtUrl->lineEdit()->setText(Application::clipboard()->text()); } } - else { // User is editing existing category. setWindowTitle(tr("Edit feed '%1'").arg(input_feed->title())); @@ -110,7 +107,6 @@ void FormFeedDetails::onTitleChanged(const QString& new_title) { if (new_title.simplified().size() >= MIN_CATEGORY_NAME_LENGTH) { m_ui->m_txtTitle->setStatus(LineEditWithStatus::Ok, tr("Feed name is ok.")); } - else { m_ui->m_txtTitle->setStatus(LineEditWithStatus::Error, tr("Feed name is too short.")); } @@ -120,7 +116,6 @@ void FormFeedDetails::onDescriptionChanged(const QString& new_description) { if (new_description.simplified().isEmpty()) { m_ui->m_txtDescription->setStatus(LineEditWithStatus::Warning, tr("Description is empty.")); } - else { m_ui->m_txtDescription->setStatus(LineEditWithStatus::Ok, tr("The description is ok.")); } @@ -131,13 +126,11 @@ void FormFeedDetails::onUrlChanged(const QString& new_url) { // New url is well-formed. m_ui->m_txtUrl->setStatus(LineEditWithStatus::Ok, tr("The URL is ok.")); } - else if (!new_url.simplified().isEmpty()) { // New url is not well-formed but is not empty on the other hand. m_ui->m_txtUrl->setStatus(LineEditWithStatus::Warning, tr("The URL does not meet standard pattern. Does your URL start with \"http://\" or \"https://\" prefix.")); } - else { // New url is empty. m_ui->m_txtUrl->setStatus(LineEditWithStatus::Error, tr("The URL is empty.")); @@ -230,7 +223,6 @@ void FormFeedDetails::guessFeed() { if (encoding_index >= 0) { m_ui->m_cmbEncoding->setCurrentIndex(encoding_index); } - else { m_ui->m_cmbEncoding->setCurrentIndex(m_ui->m_cmbEncoding->findText(DEFAULT_FEED_ENCODING, Qt::MatchFixedString)); @@ -241,7 +233,6 @@ void FormFeedDetails::guessFeed() { tr("All metadata fetched successfully."), tr("Feed and icon metadata fetched.")); } - else { m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Warning, tr("Result: %1.").arg(NetworkFactory::networkErrorText(result.second)), @@ -251,7 +242,6 @@ void FormFeedDetails::guessFeed() { // Remove temporary feed object. delete result.first; } - else { // No feed guessed, even no icon available. m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Error, @@ -274,7 +264,6 @@ void FormFeedDetails::guessIconOnly() { tr("Icon fetched successfully."), tr("Icon metadata fetched.")); } - else { m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Warning, tr("Result: %1.").arg(NetworkFactory::networkErrorText(result.second)), @@ -284,7 +273,6 @@ void FormFeedDetails::guessIconOnly() { // Remove temporary feed object. delete result.first; } - else { // No feed guessed, even no icon available. m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Error, diff --git a/src/services/abstract/recyclebin.cpp b/src/services/abstract/recyclebin.cpp index a7465ee20..0da224791 100755 --- a/src/services/abstract/recyclebin.cpp +++ b/src/services/abstract/recyclebin.cpp @@ -102,7 +102,6 @@ bool RecycleBin::markAsReadUnread(RootItem::ReadStatus status) { parent_root->requestReloadMessageList(status == RootItem::Read); return true; } - else { return false; } @@ -118,7 +117,6 @@ bool RecycleBin::cleanMessages(bool clear_only_read) { parent_root->requestReloadMessageList(true); return true;; } - else { return false; } @@ -138,7 +136,6 @@ bool RecycleBin::restore() { parent_root->requestReloadMessageList(true); return true; } - else { return false; } diff --git a/src/services/abstract/rootitem.cpp b/src/services/abstract/rootitem.cpp index c2a0fb88e..dd87a0656 100755 --- a/src/services/abstract/rootitem.cpp +++ b/src/services/abstract/rootitem.cpp @@ -121,7 +121,6 @@ int RootItem::row() const { if (m_parentItem) { return m_parentItem->m_childItems.indexOf(const_cast(this)); } - else { // This item has no parent. Therefore, its row index is 0. return 0; @@ -137,12 +136,10 @@ QVariant RootItem::data(int column, int role) const { if (column == FDS_MODEL_TITLE_INDEX) { return m_title; } - else if (column == FDS_MODEL_COUNTS_INDEX) { //: Tooltip for "unread" column of feed list. return tr("%n unread message(s).", 0, countOfUnreadMessages()); } - else { return QVariant(); } @@ -151,11 +148,9 @@ QVariant RootItem::data(int column, int role) const { if (column == FDS_MODEL_TITLE_INDEX) { return m_title; } - else if (column == FDS_MODEL_COUNTS_INDEX) { return countOfUnreadMessages(); } - else { return QVariant(); } @@ -167,7 +162,6 @@ QVariant RootItem::data(int column, int role) const { if (column == FDS_MODEL_TITLE_INDEX) { return m_title; } - else if (column == FDS_MODEL_COUNTS_INDEX) { int count_all = countOfAllMessages(); int count_unread = countOfUnreadMessages(); @@ -175,7 +169,6 @@ QVariant RootItem::data(int column, int role) const { .replace(PLACEHOLDER_UNREAD_COUNTS, count_unread < 0 ? QSL("-") : QString::number(count_unread)) .replace(PLACEHOLDER_ALL_COUNTS, count_all < 0 ? QSL("-") : QString::number(count_all)); } - else { return QVariant(); } @@ -184,7 +177,6 @@ QVariant RootItem::data(int column, int role) const { if (column == FDS_MODEL_TITLE_INDEX) { return icon(); } - else { return QVariant(); } @@ -193,7 +185,6 @@ QVariant RootItem::data(int column, int role) const { if (column == FDS_MODEL_COUNTS_INDEX) { return Qt::AlignCenter; } - else { return QVariant(); } @@ -233,7 +224,6 @@ bool RootItem::isChildOf(const RootItem* root) const { if (root->childItems().contains(const_cast(this_item))) { return true; } - else { this_item = this_item->parent(); } @@ -246,7 +236,6 @@ bool RootItem::isParentOf(const RootItem* child) const { if (child == nullptr) { return false; } - else { return child->isChildOf(this); } @@ -369,7 +358,6 @@ ServiceRoot* RootItem::getParentServiceRoot() const { if (working_parent->kind() == RootItemKind::ServiceRoot) { return working_parent->toServiceRoot(); } - else { working_parent = working_parent->parent(); } @@ -481,7 +469,6 @@ bool RootItem::removeChild(int index) { m_childItems.removeAt(index); return true; } - else { return false; } diff --git a/src/services/abstract/serviceroot.cpp b/src/services/abstract/serviceroot.cpp index 5cca7ed4e..ceab15cc3 100755 --- a/src/services/abstract/serviceroot.cpp +++ b/src/services/abstract/serviceroot.cpp @@ -43,7 +43,6 @@ bool ServiceRoot::deleteViaGui() { requestItemRemoval(this); return true; } - else { return false; } @@ -58,7 +57,6 @@ bool ServiceRoot::markAsReadUnread(RootItem::ReadStatus status) { requestReloadMessageList(status == RootItem::Read); return true; } - else { return false; } @@ -83,7 +81,6 @@ void ServiceRoot::updateCounts(bool including_total_count) { if (child->kind() == RootItemKind::Feed) { feeds.append(child->toFeed()); } - else if (child->kind() != RootItemKind::Category && child->kind() != RootItemKind::ServiceRoot) { child->updateCounts(including_total_count); } @@ -106,7 +103,6 @@ void ServiceRoot::updateCounts(bool including_total_count) { feed->setCountOfAllMessages(counts.value(feed->customId()).second); } } - else { feed->setCountOfUnreadMessages(0); @@ -163,7 +159,6 @@ bool ServiceRoot::cleanFeeds(QList items, bool clean_read_only) { requestReloadMessageList(true); return true; } - else { return false; } @@ -280,7 +275,6 @@ QStringList ServiceRoot::customIDSOfMessagesForItem(RootItem* item) { // Not item from this account. return QStringList(); } - else { QStringList list; @@ -335,7 +329,6 @@ bool ServiceRoot::markFeedsReadUnread(QList items, RootItem::ReadStatus r requestReloadMessageList(read == RootItem::Read); return true; } - else { return false; } @@ -385,7 +378,6 @@ bool ServiceRoot::loadMessagesForItem(RootItem* item, MessagesModel* model) { model->setFilter(QString("Messages.is_deleted = 1 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1").arg(QString::number( accountId()))); } - else { QList children = item->getSubTreeFeeds(); QString filter_clause = textualFeedIds(children).join(QSL(", ")); @@ -440,13 +432,11 @@ bool ServiceRoot::onAfterMessagesDelete(RootItem* selected_item, const QListkind() == RootItemKind::Bin) { itemChanged(QList() << bin); } - else { if (bin != nullptr) { bin->updateCounts(true); itemChanged(QList() << selected_item << bin); } - else { itemChanged(QList() << selected_item); } @@ -477,12 +467,10 @@ void ServiceRoot::assembleFeeds(Assignment feeds) { // This is top-level feed, add it to the root item. appendChild(feed.second); } - else if (categories.contains(feed.first)) { // This feed belongs to this category. categories.value(feed.first)->appendChild(feed.second); } - else { qWarning("Feed '%s' is loose, skipping it.", qPrintable(feed.second->title())); } diff --git a/src/services/owncloud/gui/formeditowncloudaccount.cpp b/src/services/owncloud/gui/formeditowncloudaccount.cpp index 8f418f713..b19e9a9f0 100755 --- a/src/services/owncloud/gui/formeditowncloudaccount.cpp +++ b/src/services/owncloud/gui/formeditowncloudaccount.cpp @@ -101,7 +101,6 @@ void FormEditOwnCloudAccount::performTest() { MINIMAL_OC_VERSION), tr("Selected ownCloud News server is running unsupported version.")); } - else { m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Ok, tr("ownCloud News server is okay, running with version %1, while at least version %2 is required.").arg(result.version(), @@ -109,13 +108,11 @@ void FormEditOwnCloudAccount::performTest() { tr("ownCloud News server is okay.")); } } - else if (factory.lastError() != QNetworkReply::NoError) { m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error, tr("Network error: '%1'.").arg(NetworkFactory::networkErrorText(factory.lastError())), tr("Network error, have you entered correct ownCloud endpoint and password?")); } - else { m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error, tr("Unspecified error, did you enter correct URL?"), @@ -156,7 +153,6 @@ void FormEditOwnCloudAccount::onUsernameChanged() { if (username.isEmpty()) { m_ui->m_txtUsername->setStatus(WidgetWithStatus::Error, tr("Username cannot be empty.")); } - else { m_ui->m_txtUsername->setStatus(WidgetWithStatus::Ok, tr("Username is okay.")); } @@ -168,7 +164,6 @@ void FormEditOwnCloudAccount::onPasswordChanged() { if (password.isEmpty()) { m_ui->m_txtPassword->setStatus(WidgetWithStatus::Error, tr("Password cannot be empty.")); } - else { m_ui->m_txtPassword->setStatus(WidgetWithStatus::Ok, tr("Password is okay.")); } @@ -180,7 +175,6 @@ void FormEditOwnCloudAccount::onUrlChanged() { if (url.isEmpty()) { m_ui->m_txtUrl->setStatus(WidgetWithStatus::Error, tr("URL cannot be empty.")); } - else { m_ui->m_txtUrl->setStatus(WidgetWithStatus::Ok, tr("URL is okay.")); } diff --git a/src/services/owncloud/gui/formowncloudfeeddetails.cpp b/src/services/owncloud/gui/formowncloudfeeddetails.cpp index 196e54ce0..07f1a74b1 100755 --- a/src/services/owncloud/gui/formowncloudfeeddetails.cpp +++ b/src/services/owncloud/gui/formowncloudfeeddetails.cpp @@ -47,7 +47,6 @@ void FormOwnCloudFeedDetails::apply() { m_editableFeed->customId())) { qWarning("ownCloud: Došlo k problému při prejmenování kanálu s ownCloud ID '%d'.", m_editableFeed->customId()); } - else { renamed = true; } @@ -65,7 +64,6 @@ void FormOwnCloudFeedDetails::apply() { QTimer::singleShot(200, m_serviceRoot, SLOT(syncIn())); } } - else { const RootItem* parent = static_cast(m_ui->m_cmbParentCategory->itemData( m_ui->m_cmbParentCategory->currentIndex()).value()); @@ -79,7 +77,6 @@ void FormOwnCloudFeedDetails::apply() { qApp->showGuiMessage(tr("Feed added"), tr("Feed was added, triggering sync in now."), QSystemTrayIcon::Information); QTimer::singleShot(100, m_serviceRoot, SLOT(syncIn())); } - else { reject(); qApp->showGuiMessage(tr("Cannot add feed"), diff --git a/src/services/owncloud/network/owncloudnetworkfactory.cpp b/src/services/owncloud/network/owncloudnetworkfactory.cpp index 14a94801b..8b8b12aab 100755 --- a/src/services/owncloud/network/owncloudnetworkfactory.cpp +++ b/src/services/owncloud/network/owncloudnetworkfactory.cpp @@ -52,7 +52,6 @@ void OwnCloudNetworkFactory::setUrl(const QString& url) { if (url.endsWith('/')) { m_fixedUrl = url; } - else { m_fixedUrl = url + '/'; } @@ -189,7 +188,6 @@ bool OwnCloudNetworkFactory::deleteFeed(int feed_id) { qWarning("ownCloud: Obtaining of categories failed with error %d.", network_reply.first); return false; } - else { return true; } @@ -214,7 +212,6 @@ bool OwnCloudNetworkFactory::createFeed(const QString& url, int parent_id) { qWarning("ownCloud: Creating of category failed with error %d.", network_reply.first); return false; } - else { return true; } @@ -239,7 +236,6 @@ bool OwnCloudNetworkFactory::renameFeed(const QString& new_name, int feed_id) { qWarning("ownCloud: Renaming of feed failed with error %d.", network_reply.first); return false; } - else { return true; } @@ -279,7 +275,6 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::triggerFeedUpdate(int feed_i if (lastError() != QNetworkReply::NoError) { return lastError(); } - else { // We have new user ID, set it up. setUserId(info.userId()); @@ -314,7 +309,6 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::markMessagesRead(RootItem::R if (status == RootItem::Read) { final_url = m_fixedUrl + API_PATH + "items/read/multiple"; } - else { final_url = m_fixedUrl + API_PATH + "items/unread/multiple"; } @@ -353,7 +347,6 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::markMessagesStarred(RootItem if (importance == RootItem::Important) { final_url = m_fixedUrl + API_PATH + "items/star/multiple"; } - else { final_url = m_fixedUrl + API_PATH + "items/unstar/multiple"; } @@ -417,7 +410,6 @@ QString OwnCloudUserResponse::displayName() const { if (isLoaded()) { return m_rawContent["displayName"].toString(); } - else { return QString(); } @@ -427,7 +419,6 @@ QString OwnCloudUserResponse::userId() const { if (isLoaded()) { return m_rawContent["userId"].toString(); } - else { return QString(); } @@ -437,7 +428,6 @@ QDateTime OwnCloudUserResponse::lastLoginTime() const { if (isLoaded()) { return QDateTime::fromMSecsSinceEpoch(m_rawContent["lastLoginTimestamp"].toDouble()); } - else { return QDateTime(); } @@ -468,7 +458,6 @@ QString OwnCloudStatusResponse::version() const { if (isLoaded()) { return m_rawContent["version"].toString(); } - else { return QString(); } @@ -478,7 +467,6 @@ bool OwnCloudStatusResponse::misconfiguredCron() const { if (isLoaded()) { return m_rawContent["warnings"].toObject()["improperlyConfiguredCron"].toBool(); } - else { return false; } diff --git a/src/services/owncloud/owncloudfeed.cpp b/src/services/owncloud/owncloudfeed.cpp index 9e290dabe..59adf1960 100755 --- a/src/services/owncloud/owncloudfeed.cpp +++ b/src/services/owncloud/owncloudfeed.cpp @@ -62,7 +62,6 @@ bool OwnCloudFeed::deleteViaGui() { serviceRoot()->requestItemRemoval(this); return true; } - else { return false; } @@ -76,7 +75,6 @@ bool OwnCloudFeed::editItself(OwnCloudFeed* new_feed_data) { // Persistent storage update failed, no way to continue now. return false; } - else { setAutoUpdateType(new_feed_data->autoUpdateType()); setAutoUpdateInitialInterval(new_feed_data->autoUpdateInitialInterval()); @@ -111,7 +109,6 @@ QList OwnCloudFeed::obtainNewMessages(bool* error_during_obtaining) { serviceRoot()->itemChanged(QList() << this); return QList(); } - else { *error_during_obtaining = false; return messages.messages(); diff --git a/src/services/owncloud/owncloudserviceroot.cpp b/src/services/owncloud/owncloudserviceroot.cpp index 12115bac4..0cb2a9ca4 100755 --- a/src/services/owncloud/owncloudserviceroot.cpp +++ b/src/services/owncloud/owncloudserviceroot.cpp @@ -62,7 +62,6 @@ bool OwnCloudServiceRoot::deleteViaGui() { if (DatabaseQueries::deleteOwnCloudAccount(database, accountId())) { return ServiceRoot::deleteViaGui(); } - else { return false; } @@ -170,7 +169,6 @@ bool OwnCloudServiceRoot::onBeforeSwitchMessageImportance(RootItem* selected_ite if (pair.second == RootItem::Important) { mark_starred_msgs.append(pair.first); } - else { mark_unstarred_msgs.append(pair.first); } @@ -208,7 +206,6 @@ void OwnCloudServiceRoot::saveAccountDataToDatabase() { itemChanged(QList() << this); } } - else { bool saved; int id_to_assign = DatabaseQueries::createAccount(database, code(), &saved); @@ -280,7 +277,6 @@ RootItem* OwnCloudServiceRoot::obtainNewTreeForSyncIn() const { if (m_network->lastError() == QNetworkReply::NoError) { return feed_cats_response.feedsCategories(true); } - else { return nullptr; } diff --git a/src/services/standard/atomparser.cpp b/src/services/standard/atomparser.cpp index 306b6006c..e74fa4592 100755 --- a/src/services/standard/atomparser.cpp +++ b/src/services/standard/atomparser.cpp @@ -90,11 +90,9 @@ Message AtomParser::extractMessage(const QDomElement& msg_element, QDateTime cur new_message.m_enclosures.append(Enclosure(link.attribute(QSL("href")), link.attribute(QSL("type")))); qDebug("Adding enclosure '%s' for the message.", qPrintable(new_message.m_enclosures.last().m_url)); } - else if (attribute.isEmpty() || attribute == QSL("alternate")) { last_link_alternate = link.attribute(QSL("href")); } - else { last_link_other = link.attribute(QSL("href")); } @@ -103,11 +101,9 @@ Message AtomParser::extractMessage(const QDomElement& msg_element, QDateTime cur if (!last_link_alternate.isEmpty()) { new_message.m_url = last_link_alternate; } - else if (!last_link_other.isEmpty()) { new_message.m_url = last_link_other; } - else if (!new_message.m_enclosures.isEmpty()) { new_message.m_url = new_message.m_enclosures.first().m_url; } diff --git a/src/services/standard/feedparser.cpp b/src/services/standard/feedparser.cpp index e2b8a1445..2181be3f0 100755 --- a/src/services/standard/feedparser.cpp +++ b/src/services/standard/feedparser.cpp @@ -46,7 +46,6 @@ QList FeedParser::messages() { messages.append(new_message); } - catch (const ApplicationException& ex) { qDebug(qPrintable(ex.message())); } diff --git a/src/services/standard/gui/formstandardcategorydetails.cpp b/src/services/standard/gui/formstandardcategorydetails.cpp index b36559cba..3053306a4 100755 --- a/src/services/standard/gui/formstandardcategorydetails.cpp +++ b/src/services/standard/gui/formstandardcategorydetails.cpp @@ -87,7 +87,6 @@ int FormStandardCategoryDetails::addEditCategory(StandardCategory* input_categor if (parent_to_select->kind() == RootItemKind::Category) { m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select))); } - else if (parent_to_select->kind() == RootItemKind::Feed) { int target_item = m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select->parent())); @@ -97,7 +96,6 @@ int FormStandardCategoryDetails::addEditCategory(StandardCategory* input_categor } } } - else { // User is editing existing category. setWindowTitle(tr("Edit existing category")); @@ -122,7 +120,6 @@ void FormStandardCategoryDetails::apply() { m_serviceRoot->requestItemReassignment(new_category, parent); accept(); } - else { delete new_category; qApp->showGuiMessage(tr("Cannot add category"), @@ -131,7 +128,6 @@ void FormStandardCategoryDetails::apply() { qApp->mainFormWidget(), true); } } - else { new_category->setParent(parent); bool edited = m_editableCategory->editItself(new_category); @@ -140,7 +136,6 @@ void FormStandardCategoryDetails::apply() { m_serviceRoot->requestItemReassignment(m_editableCategory, new_category->parent()); accept(); } - else { qApp->showGuiMessage(tr("Cannot edit category"), tr("Category was not edited due to error."), @@ -156,7 +151,6 @@ void FormStandardCategoryDetails::onTitleChanged(const QString& new_title) { m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); m_ui->m_txtTitle->setStatus(WidgetWithStatus::Ok, tr("Category name is ok.")); } - else { m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); m_ui->m_txtTitle->setStatus(WidgetWithStatus::Error, tr("Category name is too short.")); @@ -167,7 +161,6 @@ void FormStandardCategoryDetails::onDescriptionChanged(const QString& new_descri if (new_description.simplified().isEmpty()) { m_ui->m_txtDescription->setStatus(LineEditWithStatus::Warning, tr("Description is empty.")); } - else { m_ui->m_txtDescription->setStatus(LineEditWithStatus::Ok, tr("The description is ok.")); } diff --git a/src/services/standard/gui/formstandardfeeddetails.cpp b/src/services/standard/gui/formstandardfeeddetails.cpp index 4bd85bbf8..614c8bb69 100755 --- a/src/services/standard/gui/formstandardfeeddetails.cpp +++ b/src/services/standard/gui/formstandardfeeddetails.cpp @@ -51,7 +51,6 @@ void FormStandardFeedDetails::apply() { m_serviceRoot->requestItemReassignment(new_feed, parent); accept(); } - else { delete new_feed; qApp->showGuiMessage(tr("Cannot add feed"), @@ -59,7 +58,6 @@ void FormStandardFeedDetails::apply() { QSystemTrayIcon::Critical, this, true); } } - else { new_feed->setParent(parent); // Edit the feed. @@ -69,7 +67,6 @@ void FormStandardFeedDetails::apply() { m_serviceRoot->requestItemReassignment(m_editableFeed, new_feed->parent()); accept(); } - else { qApp->showGuiMessage(tr("Cannot edit feed"), tr("Feed was not edited due to error."), diff --git a/src/services/standard/gui/formstandardimportexport.cpp b/src/services/standard/gui/formstandardimportexport.cpp index 58ef4730a..6c42d8f86 100755 --- a/src/services/standard/gui/formstandardimportexport.cpp +++ b/src/services/standard/gui/formstandardimportexport.cpp @@ -129,7 +129,6 @@ void FormStandardImportExport::onParsingFinished(int count_failed, int count_suc m_ui->m_treeFeeds->setModel(m_model); m_ui->m_treeFeeds->expandAll(); } - else { m_ui->m_groupFeeds->setEnabled(false); m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Error, file is not well-formed. Select another file."), @@ -164,7 +163,6 @@ void FormStandardImportExport::selectExportFile() { selected_file += QL1S(".opml"); } } - else if (selected_filter == filter_txt_url_per_line) { m_conversionType = TXTUrlPerLine; @@ -195,7 +193,6 @@ void FormStandardImportExport::selectImportFile() { if (selected_filter == filter_opml20) { m_conversionType = OPML20; } - else if (selected_filter == filter_txt_url_per_line) { m_conversionType = TXTUrlPerLine; } @@ -218,7 +215,6 @@ void FormStandardImportExport::parseImportFile(const QString& file_name, bool fe input_data = input_file.readAll(); input_file.close(); } - else { m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Cannot open source file."), tr("Cannot open source file.")); return; @@ -275,12 +271,10 @@ void FormStandardImportExport::exportFeeds() { IOFactory::writeTextFile(m_ui->m_lblSelectFile->label()->text(), result_data); m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Feeds were exported successfully."), tr("Feeds were exported successfully.")); } - catch (IOException& ex) { m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Cannot write into destination file: '%1'."), ex.message()); } } - else { m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Critical error occurred."), tr("Critical error occurred.")); } @@ -294,7 +288,6 @@ void FormStandardImportExport::importFeeds() { m_serviceRoot->requestItemExpand(parent->getSubTree(), true); m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, output_message, output_message); } - else { m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, output_message, output_message); } diff --git a/src/services/standard/rdfparser.cpp b/src/services/standard/rdfparser.cpp index d32fae319..1edfe0a81 100755 --- a/src/services/standard/rdfparser.cpp +++ b/src/services/standard/rdfparser.cpp @@ -51,14 +51,12 @@ QList RdfParser::parseXmlData(const QString& data) { // BOTH title and description are empty, skip this message. continue; } - else { // Title is empty but description is not. new_message.m_title = qApp->web()->escapeHtml(qApp->web()->stripTags(elem_description.simplified())); new_message.m_contents = elem_description; } } - else { // Title is really not empty, description does not matter. new_message.m_title = qApp->web()->escapeHtml(qApp->web()->stripTags(elem_title)); diff --git a/src/services/standard/rssparser.cpp b/src/services/standard/rssparser.cpp index ee95bc2f8..bb3345d1a 100755 --- a/src/services/standard/rssparser.cpp +++ b/src/services/standard/rssparser.cpp @@ -38,7 +38,6 @@ QDomNodeList RssParser::messageElements() { if (channel_elem.isNull()) { return QDomNodeList(); } - else { return channel_elem.toElement().elementsByTagName(QSL("item")); } @@ -62,14 +61,12 @@ Message RssParser::extractMessage(const QDomElement& msg_element, QDateTime curr // BOTH title and description are empty, skip this message. throw new ApplicationException(QSL("Not enough data for the message.")); } - else { // Title is empty but description is not. new_message.m_title = qApp->web()->stripTags(elem_description.simplified()); new_message.m_contents = elem_description; } } - else { // Title is really not empty, description does not matter. new_message.m_title = qApp->web()->stripTags(elem_title); diff --git a/src/services/standard/standardcategory.cpp b/src/services/standard/standardcategory.cpp index ded3a076a..f5f7a1653 100755 --- a/src/services/standard/standardcategory.cpp +++ b/src/services/standard/standardcategory.cpp @@ -67,7 +67,6 @@ QVariant StandardCategory::data(int column, int role) const { tr("\nThis category does not contain any nested items.") : QString()); } - else { return Category::data(column, role); } @@ -91,7 +90,6 @@ bool StandardCategory::performDragDropChange(RootItem* target_item) { delete category_new; return true; } - else { delete category_new; return false; @@ -109,7 +107,6 @@ bool StandardCategory::deleteViaGui() { serviceRoot()->requestItemRemoval(this); return true; } - else { return false; } @@ -132,7 +129,6 @@ bool StandardCategory::removeItself() { if (child->kind() == RootItemKind::Category) { children_removed &= static_cast(child)->removeItself(); } - else if (child->kind() == RootItemKind::Feed) { children_removed &= static_cast(child)->removeItself(); } @@ -143,7 +139,6 @@ bool StandardCategory::removeItself() { QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); return DatabaseQueries::deleteCategory(database, id()); } - else { return false; } @@ -158,7 +153,6 @@ bool StandardCategory::addItself(RootItem* parent) { if (new_id <= 0) { return false; } - else { setId(new_id); setCustomId(new_id); @@ -181,7 +175,6 @@ bool StandardCategory::editItself(StandardCategory* new_category_data) { // Editing is done. return true; } - else { return false; } diff --git a/src/services/standard/standardfeed.cpp b/src/services/standard/standardfeed.cpp index 56430d0e1..7b8c781dc 100755 --- a/src/services/standard/standardfeed.cpp +++ b/src/services/standard/standardfeed.cpp @@ -101,7 +101,6 @@ bool StandardFeed::deleteViaGui() { serviceRoot()->requestItemRemoval(this); return true; } - else { return false; } @@ -131,7 +130,6 @@ QVariant StandardFeed::data(int column, int role) const { getAutoUpdateStatusDescription(), NetworkFactory::networkErrorText(m_networkError)); } - else { return QVariant(); } @@ -176,7 +174,6 @@ void StandardFeed::fetchMetadataForItself() { // this item, particularly the icon. serviceRoot()->itemChanged(QList() << this); } - else { qApp->showGuiMessage(tr("Metadata not fetched"), tr("Metadata was not fetched because: %1.").arg(NetworkFactory::networkErrorText(metadata.second)), @@ -226,7 +223,6 @@ QPair StandardFeed::guessFeed(const xml_contents_encoded = custom_codec->toUnicode(feed_contents); result.first->setEncoding(xml_schema_encoding); } - else { // Feed encoding probably not guessed, set it as // default. @@ -270,7 +266,6 @@ QPair StandardFeed::guessFeed(const icon_possible_locations.prepend(source_link); } } - else if (root_tag_name == QL1S("rss")) { // We found RSS 0.91/0.92/0.93/2.0/2.0.1 feed. QString rss_type = root_element.attribute("version", "2.0"); @@ -278,7 +273,6 @@ QPair StandardFeed::guessFeed(const if (rss_type == QL1S("0.91") || rss_type == QL1S("0.92") || rss_type == QL1S("0.93")) { result.first->setType(Rss0X); } - else { result.first->setType(Rss2X); } @@ -292,7 +286,6 @@ QPair StandardFeed::guessFeed(const icon_possible_locations.prepend(source_link); } } - else if (root_tag_name == QL1S("feed")) { // We found ATOM feed. result.first->setType(Atom10); @@ -304,7 +297,6 @@ QPair StandardFeed::guessFeed(const icon_possible_locations.prepend(source_link); } } - else { // File was downloaded and it really was XML file // but feed format was NOT recognized. @@ -338,7 +330,6 @@ bool StandardFeed::performDragDropChange(RootItem* target_item) { delete feed_new; return true; } - else { delete feed_new; return false; @@ -362,7 +353,6 @@ bool StandardFeed::addItself(RootItem* parent) { // Query failed. return false; } - else { // New feed was added, fetch is primary id from the database. setId(new_id); @@ -415,7 +405,6 @@ QList StandardFeed::obtainNewMessages(bool* error_during_obtaining) { *error_during_obtaining = true; return QList(); } - else if (status() != NewMessages) { setStatus(Normal); *error_during_obtaining = false; @@ -430,7 +419,6 @@ QList StandardFeed::obtainNewMessages(bool* error_during_obtaining) { // Use non-converted data. formatted_feed_contents = feed_contents; } - else { formatted_feed_contents = codec->toUnicode(feed_contents); } @@ -478,7 +466,6 @@ StandardFeed::StandardFeed(const QSqlRecord& record) : Feed(nullptr) { if (record.value(FDS_DB_PASSWORD_INDEX).toString().isEmpty()) { setPassword(record.value(FDS_DB_PASSWORD_INDEX).toString()); } - else { setPassword(TextFactory::decrypt(record.value(FDS_DB_PASSWORD_INDEX).toString())); } diff --git a/src/services/standard/standardfeedsimportexportmodel.cpp b/src/services/standard/standardfeedsimportexportmodel.cpp index b9d4f7151..a3a86d127 100755 --- a/src/services/standard/standardfeedsimportexportmodel.cpp +++ b/src/services/standard/standardfeedsimportexportmodel.cpp @@ -187,7 +187,6 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m active_model_item->appendChild(guessed.first); succeded++; } - else { QString feed_title = child_element.attribute(QSL("text")); QString feed_encoding = child_element.attribute(QSL("encoding"), DEFAULT_FEED_ENCODING); @@ -205,11 +204,9 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m if (feed_type == QL1S("RSS1")) { new_feed->setType(StandardFeed::Rdf); } - else if (feed_type == QL1S("ATOM")) { new_feed->setType(StandardFeed::Atom10); } - else { new_feed->setType(StandardFeed::Rss2X); } @@ -219,14 +216,12 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m if (fetch_metadata_online && guessed.second != QNetworkReply::NoError) { failed++; } - else { succeded++; } } } } - else { // This must be CATEGORY. // Add category and continue. @@ -293,7 +288,6 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool root_item->appendChild(guessed.first); succeded++; } - else { StandardFeed* feed = new StandardFeed(); feed->setUrl(url); @@ -306,7 +300,6 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool if (fetch_metadata_online && guessed.second != QNetworkReply::NoError) { failed++; } - else { succeded++; } @@ -314,7 +307,6 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool qApp->processEvents(); } - else { qWarning("Detected empty URL when parsing input TXT [one URL per line] data."); failed++; diff --git a/src/services/standard/standardserviceentrypoint.cpp b/src/services/standard/standardserviceentrypoint.cpp index 351a01871..82cb9e928 100755 --- a/src/services/standard/standardserviceentrypoint.cpp +++ b/src/services/standard/standardserviceentrypoint.cpp @@ -69,7 +69,6 @@ ServiceRoot* StandardServiceEntryPoint::createNewRoot() const { root->setAccountId(new_id); return root; } - else { return nullptr; } diff --git a/src/services/standard/standardserviceroot.cpp b/src/services/standard/standardserviceroot.cpp index 973b16631..355173003 100755 --- a/src/services/standard/standardserviceroot.cpp +++ b/src/services/standard/standardserviceroot.cpp @@ -72,7 +72,6 @@ void StandardServiceRoot::start(bool freshly_activated) { if (QFile::exists(target_opml_file.arg(current_locale))) { file_to_load = target_opml_file.arg(current_locale); } - else if (QFile::exists(target_opml_file.arg(DEFAULT_LOCALE))) { file_to_load = target_opml_file.arg(DEFAULT_LOCALE); } @@ -88,7 +87,6 @@ void StandardServiceRoot::start(bool freshly_activated) { requestItemExpand(getSubTree(), true); } } - catch (ApplicationException& ex) { MessageBox::show(qApp->mainFormWidget(), QMessageBox::Critical, tr("Error when loading initial feeds"), ex.message()); } @@ -149,7 +147,6 @@ QVariant StandardServiceRoot::data(int column, int role) const { 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); } @@ -202,12 +199,10 @@ QString StandardServiceRoot::processFeedUrl(const QString& feed_url) { if (without_feed_prefix.startsWith(QL1S("https:")) || without_feed_prefix.startsWith(QL1S("http:"))) { return without_feed_prefix; } - else { return feed_url; } } - else { return feed_url; } @@ -264,7 +259,6 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel* model, original_parents.push(new_category); new_parents.push(source_category); } - else { delete new_category; // Add category failed, but this can mean that the same category (with same title) @@ -282,13 +276,11 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel* model, original_parents.push(existing_category); new_parents.push(source_category); } - else { some_feed_category_error = true; } } } - else if (source_item->kind() == RootItemKind::Feed) { StandardFeed* source_feed = static_cast(source_item); StandardFeed* new_feed = new StandardFeed(*source_feed); @@ -297,7 +289,6 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel* model, if (new_feed->addItself(target_parent)) { requestItemReassignment(new_feed, target_parent); } - else { delete new_feed; some_feed_category_error = true; @@ -309,7 +300,6 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel* model, if (some_feed_category_error) { output_message = tr("Import successful, but some feeds/categories were not imported due to error."); } - else { output_message = tr("Import was completely successful."); } diff --git a/src/services/tt-rss/gui/formeditttrssaccount.cpp b/src/services/tt-rss/gui/formeditttrssaccount.cpp index 7b934fd41..c7039ce20 100755 --- a/src/services/tt-rss/gui/formeditttrssaccount.cpp +++ b/src/services/tt-rss/gui/formeditttrssaccount.cpp @@ -128,20 +128,17 @@ void FormEditTtRssAccount::performTest() { tr("API access on selected server is not enabled."), tr("API access on selected server is not enabled.")); } - else if (error == LOGIN_ERROR) { m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error, tr("Entered credentials are incorrect."), tr("Entered credentials are incorrect.")); } - else { m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error, tr("Other error occurred, contact developers."), tr("Other error occurred, contact developers.")); } } - else if (result.apiLevel() < MINIMAL_API_LEVEL) { m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error, tr("Selected Tiny Tiny RSS server is running unsupported version of API (%1). At least API level %2 is required.").arg(QString::number( @@ -149,7 +146,6 @@ void FormEditTtRssAccount::performTest() { QString::number(MINIMAL_API_LEVEL)), tr("Selected Tiny Tiny RSS server is running unsupported version of API.")); } - else { m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Ok, tr("Tiny Tiny RSS server is okay, running with API level %1, while at least API level %2 is required.").arg(QString::number( @@ -158,13 +154,11 @@ void FormEditTtRssAccount::performTest() { tr("Tiny Tiny RSS server is okay.")); } } - else if (factory.lastError() != QNetworkReply::NoError) { m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error, tr("Network error: '%1'.").arg(NetworkFactory::networkErrorText(factory.lastError())), tr("Network error, have you entered correct Tiny Tiny RSS API endpoint and password?")); } - else { m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error, tr("Unspecified error, did you enter correct URL?"), @@ -209,7 +203,6 @@ void FormEditTtRssAccount::onUsernameChanged() { if (username.isEmpty()) { m_ui->m_txtUsername->setStatus(WidgetWithStatus::Error, tr("Username cannot be empty.")); } - else { m_ui->m_txtUsername->setStatus(WidgetWithStatus::Ok, tr("Username is okay.")); } @@ -221,7 +214,6 @@ void FormEditTtRssAccount::onPasswordChanged() { if (password.isEmpty()) { m_ui->m_txtPassword->setStatus(WidgetWithStatus::Error, tr("Password cannot be empty.")); } - else { m_ui->m_txtPassword->setStatus(WidgetWithStatus::Ok, tr("Password is okay.")); } @@ -253,11 +245,9 @@ void FormEditTtRssAccount::onUrlChanged() { if (url.isEmpty()) { m_ui->m_txtUrl->setStatus(WidgetWithStatus::Error, tr("URL cannot be empty.")); } - else if (url.endsWith(QL1S("/api/")) || url.endsWith(QL1S("/api"))) { m_ui->m_txtUrl->setStatus(WidgetWithStatus::Warning, tr("URL should NOT end with \"/api/\".")); } - else { m_ui->m_txtUrl->setStatus(WidgetWithStatus::Ok, tr("URL is okay.")); } diff --git a/src/services/tt-rss/gui/formttrssfeeddetails.cpp b/src/services/tt-rss/gui/formttrssfeeddetails.cpp index d7b3cce63..e4e62e459 100755 --- a/src/services/tt-rss/gui/formttrssfeeddetails.cpp +++ b/src/services/tt-rss/gui/formttrssfeeddetails.cpp @@ -49,7 +49,6 @@ void FormTtRssFeedDetails::apply() { qobject_cast(m_editableFeed)->editItself(new_feed_data); delete new_feed_data; } - else { RootItem* parent = static_cast(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value()); TtRssServiceRoot* root = parent->kind() == RootItemKind::Category ? @@ -70,7 +69,6 @@ void FormTtRssFeedDetails::apply() { qApp->showGuiMessage(tr("Feed added"), tr("Feed was added, triggering sync in now."), QSystemTrayIcon::Information); QTimer::singleShot(100, root, SLOT(syncIn())); } - else { reject(); qApp->showGuiMessage(tr("Cannot add feed"), diff --git a/src/services/tt-rss/network/ttrssnetworkfactory.cpp b/src/services/tt-rss/network/ttrssnetworkfactory.cpp index f4a3fbae5..452f6ba61 100755 --- a/src/services/tt-rss/network/ttrssnetworkfactory.cpp +++ b/src/services/tt-rss/network/ttrssnetworkfactory.cpp @@ -57,7 +57,6 @@ void TtRssNetworkFactory::setUrl(const QString& url) { if (!m_bareUrl.endsWith(QSL("api/"))) { m_fullUrl = m_bareUrl + QSL("api/"); } - else { m_fullUrl = m_bareUrl; } @@ -109,7 +108,6 @@ TtRssLoginResponse TtRssNetworkFactory::login() { m_sessionId = login_response.sessionId(); m_lastLoginTime = QDateTime::currentDateTime(); } - else { qWarning("TT-RSS: Login failed with error %d.", network_reply.first); } @@ -134,14 +132,12 @@ TtRssResponse TtRssNetworkFactory::logout() { if (m_lastError == QNetworkReply::NoError) { m_sessionId.clear(); } - else { qWarning("TT-RSS: Logout failed with error %d.", network_reply.first); } return TtRssResponse(QString::fromUtf8(result_raw)); } - else { qWarning("TT-RSS: Cannot logout because session ID is empty."); m_lastError = QNetworkReply::NoError; @@ -383,7 +379,6 @@ int TtRssResponse::seq() const { if (!isLoaded()) { return CONTENT_NOT_LOADED; } - else { return m_rawContent["seq"].toInt(); } @@ -393,7 +388,6 @@ int TtRssResponse::status() const { if (!isLoaded()) { return CONTENT_NOT_LOADED; } - else { return m_rawContent["status"].toInt(); } @@ -417,7 +411,6 @@ int TtRssLoginResponse::apiLevel() const { if (!isLoaded()) { return CONTENT_NOT_LOADED; } - else { return m_rawContent["content"].toObject()["api_level"].toInt(); } @@ -427,7 +420,6 @@ QString TtRssLoginResponse::sessionId() const { if (!isLoaded()) { return QString(); } - else { return m_rawContent["content"].toObject()["session_id"].toString(); } @@ -437,7 +429,6 @@ QString TtRssResponse::error() const { if (!isLoaded()) { return QString(); } - else { return m_rawContent["content"].toObject()["error"].toString(); } @@ -447,7 +438,6 @@ bool TtRssResponse::hasError() const { if (!isLoaded()) { return false; } - else { return m_rawContent["content"].toObject().contains("error"); } @@ -492,7 +482,6 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS } } } - else { TtRssCategory* category = new TtRssCategory(); category->setTitle(item["name"].toString()); @@ -506,7 +495,6 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS } } } - else { // We have feed. TtRssFeed* feed = new TtRssFeed(); @@ -595,7 +583,6 @@ QString TtRssUpdateArticleResponse::updateStatus() const { if (m_rawContent.contains(QSL("content"))) { return m_rawContent["content"].toObject()["status"].toString(); } - else { return QString(); } @@ -605,7 +592,6 @@ int TtRssUpdateArticleResponse::articlesUpdated() const { if (m_rawContent.contains(QSL("content"))) { return m_rawContent["content"].toObject()["updated"].toInt(); } - else { return 0; } @@ -621,7 +607,6 @@ int TtRssSubscribeToFeedResponse::code() const { if (m_rawContent.contains(QSL("content"))) { return m_rawContent["content"].toObject()["status"].toObject()["code"].toInt(); } - else { return STF_UNKNOWN; } @@ -641,7 +626,6 @@ QString TtRssUnsubscribeFeedResponse::code() const { if (map.contains(QSL("error"))) { return map["error"].toString(); } - else if (map.contains(QSL("status"))) { return map["status"].toString(); } diff --git a/src/services/tt-rss/ttrsscategory.cpp b/src/services/tt-rss/ttrsscategory.cpp index 7f237bda1..3f1f8ec5b 100755 --- a/src/services/tt-rss/ttrsscategory.cpp +++ b/src/services/tt-rss/ttrsscategory.cpp @@ -55,7 +55,6 @@ bool TtRssCategory::markAsReadUnread(RootItem::ReadStatus status) { if (serviceRoot()->network()->lastError() != QNetworkReply::NoError || response.updateStatus() != STATUS_OK) { return false; } - else { return serviceRoot()->markFeedsReadUnread(getSubTreeFeeds(), status); } diff --git a/src/services/tt-rss/ttrssfeed.cpp b/src/services/tt-rss/ttrssfeed.cpp index 85cc362ba..0fb22af4e 100755 --- a/src/services/tt-rss/ttrssfeed.cpp +++ b/src/services/tt-rss/ttrssfeed.cpp @@ -86,7 +86,6 @@ QVariant TtRssFeed::data(int column, int role) const { description().isEmpty() ? QString() : QString('\n') + description(), auto_update_string); } - else { return Feed::data(column, role); } @@ -118,7 +117,6 @@ bool TtRssFeed::deleteViaGui() { serviceRoot()->requestItemRemoval(this); return true; } - else { qWarning("TT-RSS: Unsubscribing from feed failed, received JSON: '%s'", qPrintable(response.toString())); return false; @@ -143,7 +141,6 @@ bool TtRssFeed::editItself(TtRssFeed* new_feed_data) { setAutoUpdateInitialInterval(new_feed_data->autoUpdateInitialInterval()); return true; } - else { return false; } @@ -165,7 +162,6 @@ QList TtRssFeed::obtainNewMessages(bool* error_during_obtaining) { serviceRoot()->itemChanged(QList() << this); return QList(); } - else { QList new_messages = headlines.messages(); messages.append(new_messages); diff --git a/src/services/tt-rss/ttrssserviceroot.cpp b/src/services/tt-rss/ttrssserviceroot.cpp index e14e755ac..3d0640c6f 100755 --- a/src/services/tt-rss/ttrssserviceroot.cpp +++ b/src/services/tt-rss/ttrssserviceroot.cpp @@ -80,7 +80,6 @@ bool TtRssServiceRoot::deleteViaGui() { if (DatabaseQueries::deleteTtRssAccount(database, accountId())) { return ServiceRoot::deleteViaGui(); } - else { return false; } @@ -141,7 +140,6 @@ QVariant TtRssServiceRoot::data(int column, int role) const { m_network->lastLoginTime().toString(Qt::DefaultLocaleShortDate) : QSL("-")); } - else { return ServiceRoot::data(column, role); } @@ -215,7 +213,6 @@ bool TtRssServiceRoot::onBeforeSwitchMessageImportance(RootItem* selected_item, if (pair.second == RootItem::Important) { mark_starred_msgs.append(pair.first); } - else { mark_unstarred_msgs.append(pair.first); } @@ -249,7 +246,6 @@ void TtRssServiceRoot::saveAccountDataToDatabase() { itemChanged(QList() << this); } } - else { bool saved; int id_to_assign = DatabaseQueries::createAccount(database, code(), &saved); @@ -295,7 +291,6 @@ RootItem* TtRssServiceRoot::obtainNewTreeForSyncIn() const { if (m_network->lastError() == QNetworkReply::NoError) { return feed_cats_response.feedsCategories(true, m_network->url()); } - else { return nullptr; }