Refactoring.

This commit is contained in:
Martin Rotter 2017-08-28 07:16:37 +02:00
parent cad2fffa87
commit 070bb7a389
110 changed files with 344 additions and 986 deletions

View File

@ -21,5 +21,6 @@
--close-templates --close-templates
--max-code-length=140 --max-code-length=140
--lineend=linux --lineend=linux
--delete-empty-lines
-t -p -t -p
-M60Ucv -M60Ucv

View File

@ -55,7 +55,6 @@ void FeedDownloader::updateAvailableFeeds() {
m_feeds.removeFirst(); m_feeds.removeFirst();
m_feedsUpdating++; m_feedsUpdating++;
} }
else { else {
// We want to start update of some feeds but all working threads are occupied. // We want to start update of some feeds but all working threads are occupied.
break; break;
@ -70,7 +69,6 @@ void FeedDownloader::updateFeeds(const QList<Feed*>& feeds) {
qDebug("No feeds to update in worker thread, aborting update."); qDebug("No feeds to update in worker thread, aborting update.");
finalizeUpdate(); finalizeUpdate();
} }
else { else {
qDebug().nospace() << "Starting feed updates from worker in thread: \'" << QThread::currentThreadId() << "\'."; qDebug().nospace() << "Starting feed updates from worker in thread: \'" << QThread::currentThreadId() << "\'.";
m_feeds = feeds; m_feeds = feeds;

View File

@ -39,506 +39,496 @@
FeedsModel::FeedsModel(QObject* parent) : QAbstractItemModel(parent) { FeedsModel::FeedsModel(QObject* parent) : QAbstractItemModel(parent) {
setObjectName(QSL("FeedsModel")); setObjectName(QSL("FeedsModel"));
// Create root item. // Create root item.
m_rootItem = new RootItem(); m_rootItem = new RootItem();
//: Name of root item of feed list which can be seen in feed add/edit dialog. //: Name of root item of feed list which can be seen in feed add/edit dialog.
m_rootItem->setTitle(tr("Root")); m_rootItem->setTitle(tr("Root"));
m_rootItem->setIcon(qApp->icons()->fromTheme(QSL("folder"))); m_rootItem->setIcon(qApp->icons()->fromTheme(QSL("folder")));
// Setup icons. // Setup icons.
m_countsIcon = qApp->icons()->fromTheme(QSL("mail-mark-unread")); m_countsIcon = qApp->icons()->fromTheme(QSL("mail-mark-unread"));
//: Title text in the feed list header. //: Title text in the feed list header.
m_headerData << tr("Title"); m_headerData << tr("Title");
m_tooltipData << /*: Feed list header "titles" column tooltip.*/ tr("Titles of feeds/categories.") << m_tooltipData << /*: Feed list header "titles" column tooltip.*/ tr("Titles of feeds/categories.") <<
/*: Feed list header "counts" column tooltip.*/ tr("Counts of unread/all mesages."); /*: Feed list header "counts" column tooltip.*/ tr("Counts of unread/all mesages.");
} }
FeedsModel::~FeedsModel() { FeedsModel::~FeedsModel() {
qDebug("Destroying FeedsModel instance."); qDebug("Destroying FeedsModel instance.");
// Delete all model items. // Delete all model items.
delete m_rootItem; delete m_rootItem;
} }
QMimeData* FeedsModel::mimeData(const QModelIndexList& indexes) const { QMimeData* FeedsModel::mimeData(const QModelIndexList& indexes) const {
QMimeData* mime_data = new QMimeData(); QMimeData* mime_data = new QMimeData();
QByteArray encoded_data; QByteArray encoded_data;
QDataStream stream(&encoded_data, QIODevice::WriteOnly); QDataStream stream(&encoded_data, QIODevice::WriteOnly);
foreach (const QModelIndex& index, indexes) { foreach (const QModelIndex& index, indexes) {
if (index.column() != 0) { if (index.column() != 0) {
continue; continue;
} }
RootItem* item_for_index = itemForIndex(index); RootItem* item_for_index = itemForIndex(index);
if (item_for_index->kind() != RootItemKind::Root) { if (item_for_index->kind() != RootItemKind::Root) {
stream << (quintptr) item_for_index; stream << (quintptr) item_for_index;
} }
} }
mime_data->setData(QSL(MIME_TYPE_ITEM_POINTER), encoded_data); mime_data->setData(QSL(MIME_TYPE_ITEM_POINTER), encoded_data);
return mime_data; return mime_data;
} }
QStringList FeedsModel::mimeTypes() const { QStringList FeedsModel::mimeTypes() const {
return QStringList() << QSL(MIME_TYPE_ITEM_POINTER); return QStringList() << QSL(MIME_TYPE_ITEM_POINTER);
} }
bool FeedsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) { bool FeedsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) {
Q_UNUSED(row) Q_UNUSED(row)
Q_UNUSED(column) Q_UNUSED(column)
if (action == Qt::IgnoreAction) { if (action == Qt::IgnoreAction) {
return true; return true;
} }
else if (action != Qt::MoveAction) {
return false;
}
else if (action != Qt::MoveAction) { QByteArray dragged_items_data = data->data(QSL(MIME_TYPE_ITEM_POINTER));
return false;
}
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()) { while (!stream.atEnd()) {
return false; 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 { if (dragged_item == target_item || dragged_item->parent() == target_item) {
QDataStream stream(&dragged_items_data, QIODevice::ReadOnly); 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()) { if (dragged_item_root != target_item_root) {
quintptr pointer_to_item; // Transferring of items between different accounts is not possible.
stream >> pointer_to_item; qApp->showGuiMessage(tr("Cannot perform drag & drop operation"),
// We have item we want to drag, we also determine the target item. tr("You can't transfer dragged item into different account, this is not supported."),
RootItem* dragged_item = (RootItem*) pointer_to_item; QSystemTrayIcon::Warning,
RootItem* target_item = itemForIndex(parent); qApp->mainFormWidget(),
ServiceRoot* dragged_item_root = dragged_item->getParentServiceRoot(); true);
ServiceRoot* target_item_root = target_item->getParentServiceRoot(); 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) { if (dragged_item->performDragDropChange(target_item)) {
qDebug("Dragged item is equal to target item or its parent is equal to target item. Cancelling drag-drop action."); // Drag & drop is supported by the dragged item and was
return false; // completed on data level and in item hierarchy.
} emit requireItemValidationAfterDragDrop(indexForItem(dragged_item));
}
}
if (dragged_item_root != target_item_root) { return true;
// Transferring of items between different accounts is not possible. }
qApp->showGuiMessage(tr("Cannot perform drag & drop operation"),
tr("You can't transfer dragged item into different account, this is not supported."),
QSystemTrayIcon::Warning,
qApp->mainFormWidget(),
true);
qDebug("Dragged item cannot be dragged into different account. Cancelling drag-drop action.");
return false;
}
if (dragged_item->performDragDropChange(target_item)) { return false;
// 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;
} }
Qt::DropActions FeedsModel::supportedDropActions() const { Qt::DropActions FeedsModel::supportedDropActions() const {
return Qt::MoveAction; return Qt::MoveAction;
} }
Qt::ItemFlags FeedsModel::flags(const QModelIndex& index) const { Qt::ItemFlags FeedsModel::flags(const QModelIndex& index) const {
Qt::ItemFlags base_flags = QAbstractItemModel::flags(index); Qt::ItemFlags base_flags = QAbstractItemModel::flags(index);
const RootItem* item_for_index = itemForIndex(index); const RootItem* item_for_index = itemForIndex(index);
Qt::ItemFlags additional_flags = item_for_index->additionalFlags(); Qt::ItemFlags additional_flags = item_for_index->additionalFlags();
return base_flags | additional_flags; return base_flags | additional_flags;
} }
QVariant FeedsModel::headerData(int section, Qt::Orientation orientation, int role) const { QVariant FeedsModel::headerData(int section, Qt::Orientation orientation, int role) const {
if (orientation != Qt::Horizontal) { if (orientation != Qt::Horizontal) {
return QVariant(); return QVariant();
} }
switch (role) { switch (role) {
case Qt::DisplayRole: case Qt::DisplayRole:
if (section == FDS_MODEL_TITLE_INDEX) { if (section == FDS_MODEL_TITLE_INDEX) {
return m_headerData.at(FDS_MODEL_TITLE_INDEX); return m_headerData.at(FDS_MODEL_TITLE_INDEX);
} }
else {
return QVariant();
}
else { case Qt::ToolTipRole:
return QVariant(); return m_tooltipData.at(section);
}
case Qt::ToolTipRole: case Qt::DecorationRole:
return m_tooltipData.at(section); if (section == FDS_MODEL_COUNTS_INDEX) {
return m_countsIcon;
}
else {
return QVariant();
}
case Qt::DecorationRole: default:
if (section == FDS_MODEL_COUNTS_INDEX) { return QVariant();
return m_countsIcon; }
}
else {
return QVariant();
}
default:
return QVariant();
}
} }
QModelIndex FeedsModel::index(int row, int column, const QModelIndex& parent) const { QModelIndex FeedsModel::index(int row, int column, const QModelIndex& parent) const {
if (!hasIndex(row, column, parent)) { if (!hasIndex(row, column, parent)) {
return QModelIndex(); return QModelIndex();
} }
RootItem* parent_item = itemForIndex(parent); RootItem* parent_item = itemForIndex(parent);
RootItem* child_item = parent_item->child(row); RootItem* child_item = parent_item->child(row);
if (child_item) { if (child_item) {
return createIndex(row, column, child_item); return createIndex(row, column, child_item);
} }
else {
else { return QModelIndex();
return QModelIndex(); }
}
} }
QModelIndex FeedsModel::parent(const QModelIndex& child) const { QModelIndex FeedsModel::parent(const QModelIndex& child) const {
if (!child.isValid()) { if (!child.isValid()) {
return QModelIndex(); return QModelIndex();
} }
RootItem* child_item = itemForIndex(child); RootItem* child_item = itemForIndex(child);
RootItem* parent_item = child_item->parent(); RootItem* parent_item = child_item->parent();
if (parent_item == m_rootItem) { if (parent_item == m_rootItem) {
return QModelIndex(); return QModelIndex();
} }
else {
else { return createIndex(parent_item->row(), 0, parent_item);
return createIndex(parent_item->row(), 0, parent_item); }
}
} }
int FeedsModel::rowCount(const QModelIndex& parent) const { int FeedsModel::rowCount(const QModelIndex& parent) const {
if (parent.column() > 0) { if (parent.column() > 0) {
return 0; return 0;
} }
else {
else { return itemForIndex(parent)->childCount();
return itemForIndex(parent)->childCount(); }
}
} }
int FeedsModel::countOfAllMessages() const { int FeedsModel::countOfAllMessages() const {
return m_rootItem->countOfAllMessages(); return m_rootItem->countOfAllMessages();
} }
int FeedsModel::countOfUnreadMessages() const { int FeedsModel::countOfUnreadMessages() const {
return m_rootItem->countOfUnreadMessages(); return m_rootItem->countOfUnreadMessages();
} }
void FeedsModel::reloadCountsOfWholeModel() { void FeedsModel::reloadCountsOfWholeModel() {
m_rootItem->updateCounts(true); m_rootItem->updateCounts(true);
reloadWholeLayout(); reloadWholeLayout();
notifyWithCounts(); notifyWithCounts();
} }
void FeedsModel::removeItem(const QModelIndex& index) { void FeedsModel::removeItem(const QModelIndex& index) {
if (index.isValid()) { if (index.isValid()) {
RootItem* deleting_item = itemForIndex(index); RootItem* deleting_item = itemForIndex(index);
QModelIndex parent_index = index.parent(); QModelIndex parent_index = index.parent();
RootItem* parent_item = deleting_item->parent(); RootItem* parent_item = deleting_item->parent();
beginRemoveRows(parent_index, index.row(), index.row()); beginRemoveRows(parent_index, index.row(), index.row());
parent_item->removeChild(deleting_item); parent_item->removeChild(deleting_item);
endRemoveRows(); endRemoveRows();
deleting_item->deleteLater(); deleting_item->deleteLater();
notifyWithCounts(); notifyWithCounts();
} }
} }
void FeedsModel::removeItem(RootItem* deleting_item) { void FeedsModel::removeItem(RootItem* deleting_item) {
if (deleting_item != nullptr) { if (deleting_item != nullptr) {
QModelIndex index = indexForItem(deleting_item); QModelIndex index = indexForItem(deleting_item);
QModelIndex parent_index = index.parent(); QModelIndex parent_index = index.parent();
RootItem* parent_item = deleting_item->parent(); RootItem* parent_item = deleting_item->parent();
beginRemoveRows(parent_index, index.row(), index.row()); beginRemoveRows(parent_index, index.row(), index.row());
parent_item->removeChild(deleting_item); parent_item->removeChild(deleting_item);
endRemoveRows(); endRemoveRows();
deleting_item->deleteLater(); deleting_item->deleteLater();
notifyWithCounts(); notifyWithCounts();
} }
} }
void FeedsModel::reassignNodeToNewParent(RootItem* original_node, RootItem* new_parent) { void FeedsModel::reassignNodeToNewParent(RootItem* original_node, RootItem* new_parent) {
RootItem* original_parent = original_node->parent(); RootItem* original_parent = original_node->parent();
if (original_parent != new_parent) { if (original_parent != new_parent) {
if (original_parent != nullptr) { if (original_parent != nullptr) {
int original_index_of_item = original_parent->childItems().indexOf(original_node); int original_index_of_item = original_parent->childItems().indexOf(original_node);
if (original_index_of_item >= 0) { if (original_index_of_item >= 0) {
// Remove the original item from the model... // Remove the original item from the model...
beginRemoveRows(indexForItem(original_parent), original_index_of_item, original_index_of_item); beginRemoveRows(indexForItem(original_parent), original_index_of_item, original_index_of_item);
original_parent->removeChild(original_node); original_parent->removeChild(original_node);
endRemoveRows(); endRemoveRows();
} }
} }
int new_index_of_item = new_parent->childCount(); int new_index_of_item = new_parent->childCount();
// ... and insert it under the new parent. // ... and insert it under the new parent.
beginInsertRows(indexForItem(new_parent), new_index_of_item, new_index_of_item); beginInsertRows(indexForItem(new_parent), new_index_of_item, new_index_of_item);
new_parent->appendChild(original_node); new_parent->appendChild(original_node);
endInsertRows(); endInsertRows();
} }
} }
QList<ServiceRoot*> FeedsModel::serviceRoots() const { QList<ServiceRoot*> FeedsModel::serviceRoots() const {
QList<ServiceRoot*> roots; QList<ServiceRoot*> roots;
foreach (RootItem* root, m_rootItem->childItems()) { foreach (RootItem* root, m_rootItem->childItems()) {
if (root->kind() == RootItemKind::ServiceRoot) { if (root->kind() == RootItemKind::ServiceRoot) {
roots.append(root->toServiceRoot()); roots.append(root->toServiceRoot());
} }
} }
return roots; return roots;
} }
bool FeedsModel::containsServiceRootFromEntryPoint(const ServiceEntryPoint* point) const { bool FeedsModel::containsServiceRootFromEntryPoint(const ServiceEntryPoint* point) const {
foreach (const ServiceRoot* root, serviceRoots()) { foreach (const ServiceRoot* root, serviceRoots()) {
if (root->code() == point->code()) { if (root->code() == point->code()) {
return true; return true;
} }
} }
return false; return false;
} }
StandardServiceRoot* FeedsModel::standardServiceRoot() const { StandardServiceRoot* FeedsModel::standardServiceRoot() const {
foreach (ServiceRoot* root, serviceRoots()) { foreach (ServiceRoot* root, serviceRoots()) {
StandardServiceRoot* std_service_root; StandardServiceRoot* std_service_root;
if ((std_service_root = dynamic_cast<StandardServiceRoot*>(root)) != nullptr) { if ((std_service_root = dynamic_cast<StandardServiceRoot*>(root)) != nullptr) {
return std_service_root; return std_service_root;
} }
} }
return nullptr; return nullptr;
} }
QList<Feed*> FeedsModel::feedsForScheduledUpdate(bool auto_update_now) { QList<Feed*> FeedsModel::feedsForScheduledUpdate(bool auto_update_now) {
QList<Feed*> feeds_for_update; QList<Feed*> feeds_for_update;
foreach (Feed* feed, m_rootItem->getSubTreeFeeds()) { foreach (Feed* feed, m_rootItem->getSubTreeFeeds()) {
switch (feed->autoUpdateType()) { switch (feed->autoUpdateType()) {
case Feed::DontAutoUpdate: case Feed::DontAutoUpdate:
// Do not auto-update this feed ever. // Do not auto-update this feed ever.
continue; continue;
case Feed::DefaultAutoUpdate: case Feed::DefaultAutoUpdate:
if (auto_update_now) { if (auto_update_now) {
feeds_for_update.append(feed); feeds_for_update.append(feed);
} }
break; break;
case Feed::SpecificAutoUpdate: case Feed::SpecificAutoUpdate:
default: default:
int remaining_interval = feed->autoUpdateRemainingInterval(); int remaining_interval = feed->autoUpdateRemainingInterval();
if (--remaining_interval <= 0) { if (--remaining_interval <= 0) {
// Interval of this feed passed, include this feed in the output list // Interval of this feed passed, include this feed in the output list
// and reset the interval. // and reset the interval.
feeds_for_update.append(feed); feeds_for_update.append(feed);
feed->setAutoUpdateRemainingInterval(feed->autoUpdateInitialInterval()); feed->setAutoUpdateRemainingInterval(feed->autoUpdateInitialInterval());
} }
else {
// Interval did not pass, set new decremented interval and do NOT
// include this feed in the output list.
feed->setAutoUpdateRemainingInterval(remaining_interval);
}
else { break;
// Interval did not pass, set new decremented interval and do NOT }
// include this feed in the output list. }
feed->setAutoUpdateRemainingInterval(remaining_interval);
}
break; return feeds_for_update;
}
}
return feeds_for_update;
} }
QList<Message> FeedsModel::messagesForItem(RootItem* item) const { QList<Message> FeedsModel::messagesForItem(RootItem* item) const {
return item->undeletedMessages(); return item->undeletedMessages();
} }
int FeedsModel::columnCount(const QModelIndex& parent) const { int FeedsModel::columnCount(const QModelIndex& parent) const {
Q_UNUSED(parent) Q_UNUSED(parent)
return FEEDS_VIEW_COLUMN_COUNT; return FEEDS_VIEW_COLUMN_COUNT;
} }
RootItem* FeedsModel::itemForIndex(const QModelIndex& index) const { RootItem* FeedsModel::itemForIndex(const QModelIndex& index) const {
if (index.isValid() && index.model() == this) { if (index.isValid() && index.model() == this) {
return static_cast<RootItem*>(index.internalPointer()); return static_cast<RootItem*>(index.internalPointer());
} }
else {
else { return m_rootItem;
return m_rootItem; }
}
} }
QModelIndex FeedsModel::indexForItem(const RootItem* item) const { QModelIndex FeedsModel::indexForItem(const RootItem* item) const {
if (item == nullptr || item->kind() == RootItemKind::Root) { if (item == nullptr || item->kind() == RootItemKind::Root) {
// Root item lies on invalid index. // Root item lies on invalid index.
return QModelIndex(); return QModelIndex();
} }
QStack<const RootItem*> chain; QStack<const RootItem*> chain;
while (item->kind() != RootItemKind::Root) { while (item->kind() != RootItemKind::Root) {
chain.push(item); chain.push(item);
item = item->parent(); item = item->parent();
} }
// Now, we have complete chain list: parent --- ..... --- parent --- leaf (item). // Now, we have complete chain list: parent --- ..... --- parent --- leaf (item).
QModelIndex target_index = indexForItem(m_rootItem); QModelIndex target_index = indexForItem(m_rootItem);
// We go through the stack and create our target index. // We go through the stack and create our target index.
while (!chain.isEmpty()) { while (!chain.isEmpty()) {
const RootItem* parent_item = chain.pop(); const RootItem* parent_item = chain.pop();
target_index = index(parent_item->parent()->childItems().indexOf(const_cast<RootItem* const>(parent_item)), 0, target_index); target_index = index(parent_item->parent()->childItems().indexOf(const_cast<RootItem* const>(parent_item)), 0, target_index);
} }
return target_index; return target_index;
} }
bool FeedsModel::hasAnyFeedNewMessages() const { bool FeedsModel::hasAnyFeedNewMessages() const {
foreach (const Feed* feed, m_rootItem->getSubTreeFeeds()) { foreach (const Feed* feed, m_rootItem->getSubTreeFeeds()) {
if (feed->status() == Feed::NewMessages) { if (feed->status() == Feed::NewMessages) {
return true; return true;
} }
} }
return false; return false;
} }
RootItem* FeedsModel::rootItem() const { RootItem* FeedsModel::rootItem() const {
return m_rootItem; return m_rootItem;
} }
void FeedsModel::reloadChangedLayout(QModelIndexList list) { void FeedsModel::reloadChangedLayout(QModelIndexList list) {
while (!list.isEmpty()) { while (!list.isEmpty()) {
QModelIndex indx = list.takeFirst(); QModelIndex indx = list.takeFirst();
if (indx.isValid()) { if (indx.isValid()) {
QModelIndex indx_parent = indx.parent(); QModelIndex indx_parent = indx.parent();
// Underlying data are changed. // Underlying data are changed.
emit dataChanged(index(indx.row(), 0, indx_parent), index(indx.row(), FDS_MODEL_COUNTS_INDEX, indx_parent)); emit dataChanged(index(indx.row(), 0, indx_parent), index(indx.row(), FDS_MODEL_COUNTS_INDEX, indx_parent));
list.append(indx_parent); list.append(indx_parent);
} }
} }
} }
void FeedsModel::reloadChangedItem(RootItem* item) { void FeedsModel::reloadChangedItem(RootItem* item) {
QModelIndex index_item = indexForItem(item); QModelIndex index_item = indexForItem(item);
reloadChangedLayout(QModelIndexList() << index_item); reloadChangedLayout(QModelIndexList() << index_item);
} }
void FeedsModel::notifyWithCounts() { void FeedsModel::notifyWithCounts() {
emit messageCountsChanged(countOfUnreadMessages(), hasAnyFeedNewMessages()); emit messageCountsChanged(countOfUnreadMessages(), hasAnyFeedNewMessages());
} }
void FeedsModel::onItemDataChanged(const QList<RootItem*>& items) { void FeedsModel::onItemDataChanged(const QList<RootItem*>& items) {
if (items.size() > RELOAD_MODEL_BORDER_NUM) { if (items.size() > RELOAD_MODEL_BORDER_NUM) {
qDebug("There is request to reload feed model for more than %d items, reloading model fully.", RELOAD_MODEL_BORDER_NUM); qDebug("There is request to reload feed model for more than %d items, reloading model fully.", RELOAD_MODEL_BORDER_NUM);
reloadWholeLayout(); reloadWholeLayout();
} }
else {
qDebug("There is request to reload feed model, reloading the %d items individually.", items.size());
else { foreach (RootItem* item, items) {
qDebug("There is request to reload feed model, reloading the %d items individually.", items.size()); reloadChangedItem(item);
}
}
foreach (RootItem* item, items) { notifyWithCounts();
reloadChangedItem(item);
}
}
notifyWithCounts();
} }
void FeedsModel::reloadWholeLayout() { void FeedsModel::reloadWholeLayout() {
emit layoutAboutToBeChanged(); emit layoutAboutToBeChanged();
emit layoutChanged(); emit layoutChanged();
} }
bool FeedsModel::addServiceAccount(ServiceRoot* root, bool freshly_activated) { bool FeedsModel::addServiceAccount(ServiceRoot* root, bool freshly_activated) {
int new_row_index = m_rootItem->childCount(); int new_row_index = m_rootItem->childCount();
beginInsertRows(indexForItem(m_rootItem), new_row_index, new_row_index); beginInsertRows(indexForItem(m_rootItem), new_row_index, new_row_index);
m_rootItem->appendChild(root); m_rootItem->appendChild(root);
endInsertRows(); endInsertRows();
// Connect. // Connect.
connect(root, &ServiceRoot::itemRemovalRequested, this, static_cast<void (FeedsModel::*)(RootItem*)>(&FeedsModel::removeItem)); connect(root, &ServiceRoot::itemRemovalRequested, this, static_cast<void (FeedsModel::*)(RootItem*)>(&FeedsModel::removeItem));
connect(root, &ServiceRoot::itemReassignmentRequested, this, &FeedsModel::reassignNodeToNewParent); connect(root, &ServiceRoot::itemReassignmentRequested, this, &FeedsModel::reassignNodeToNewParent);
connect(root, &ServiceRoot::dataChanged, this, &FeedsModel::onItemDataChanged); connect(root, &ServiceRoot::dataChanged, this, &FeedsModel::onItemDataChanged);
connect(root, &ServiceRoot::reloadMessageListRequested, this, &FeedsModel::reloadMessageListRequested); connect(root, &ServiceRoot::reloadMessageListRequested, this, &FeedsModel::reloadMessageListRequested);
connect(root, &ServiceRoot::itemExpandRequested, this, &FeedsModel::itemExpandRequested); connect(root, &ServiceRoot::itemExpandRequested, this, &FeedsModel::itemExpandRequested);
connect(root, &ServiceRoot::itemExpandStateSaveRequested, this, &FeedsModel::itemExpandStateSaveRequested); connect(root, &ServiceRoot::itemExpandStateSaveRequested, this, &FeedsModel::itemExpandStateSaveRequested);
root->start(freshly_activated); root->start(freshly_activated);
return true; return true;
} }
bool FeedsModel::restoreAllBins() { bool FeedsModel::restoreAllBins() {
bool result = true; bool result = true;
foreach (ServiceRoot* root, serviceRoots()) { foreach (ServiceRoot* root, serviceRoots()) {
RecycleBin* bin_of_root = root->recycleBin(); RecycleBin* bin_of_root = root->recycleBin();
if (bin_of_root != nullptr) { if (bin_of_root != nullptr) {
result &= bin_of_root->restore(); result &= bin_of_root->restore();
} }
} }
return result; return result;
} }
bool FeedsModel::emptyAllBins() { bool FeedsModel::emptyAllBins() {
bool result = true; bool result = true;
foreach (ServiceRoot* root, serviceRoots()) { foreach (ServiceRoot* root, serviceRoots()) {
RecycleBin* bin_of_root = root->recycleBin(); RecycleBin* bin_of_root = root->recycleBin();
if (bin_of_root != nullptr) { if (bin_of_root != nullptr) {
result &= bin_of_root->empty(); result &= bin_of_root->empty();
} }
} }
return result; return result;
} }
void FeedsModel::loadActivatedServiceAccounts() { void FeedsModel::loadActivatedServiceAccounts() {
// Iterate all globally available feed "service plugins". // Iterate all globally available feed "service plugins".
foreach (const ServiceEntryPoint* entry_point, qApp->feedReader()->feedServices()) { foreach (const ServiceEntryPoint* entry_point, qApp->feedReader()->feedServices()) {
// Load all stored root nodes from the entry point and add those to the model. // Load all stored root nodes from the entry point and add those to the model.
QList<ServiceRoot*> roots = entry_point->initializeSubtree(); QList<ServiceRoot*> roots = entry_point->initializeSubtree();
foreach (ServiceRoot* root, roots) { foreach (ServiceRoot* root, roots) {
addServiceAccount(root, false); addServiceAccount(root, false);
} }
} }
} }
void FeedsModel::stopServiceAccounts() { void FeedsModel::stopServiceAccounts() {
foreach (ServiceRoot* account, serviceRoots()) { foreach (ServiceRoot* account, serviceRoots()) {
account->stop(); account->stop();
} }
} }
QList<Feed*> FeedsModel::feedsForIndex(const QModelIndex& index) const { QList<Feed*> FeedsModel::feedsForIndex(const QModelIndex& index) const {
return itemForIndex(index)->getSubTreeFeeds(); return itemForIndex(index)->getSubTreeFeeds();
} }
bool FeedsModel::markItemRead(RootItem* item, RootItem::ReadStatus read) { bool FeedsModel::markItemRead(RootItem* item, RootItem::ReadStatus read) {
return item->markAsReadUnread(read); return item->markAsReadUnread(read);
} }
bool FeedsModel::markItemCleared(RootItem* item, bool clean_read_only) { bool FeedsModel::markItemCleared(RootItem* item, bool clean_read_only) {
return item->cleanMessages(clean_read_only); return item->cleanMessages(clean_read_only);
} }

View File

@ -71,7 +71,6 @@ QModelIndexList FeedsProxyModel::match(const QModelIndex& start, int role, const
result.append(idx); result.append(idx);
} }
} }
// QString based matching. // QString based matching.
else { else {
if (entered_text.isEmpty()) { if (entered_text.isEmpty()) {
@ -157,28 +156,23 @@ bool FeedsProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right
// User wants to sort according to counts. // User wants to sort according to counts.
return left_item->countOfUnreadMessages() < right_item->countOfUnreadMessages(); return left_item->countOfUnreadMessages() < right_item->countOfUnreadMessages();
} }
else { else {
// In other cases, sort by title. // In other cases, sort by title.
return QString::localeAwareCompare(left_item->title(), right_item->title()) < 0; return QString::localeAwareCompare(left_item->title(), right_item->title()) < 0;
} }
} }
else if (left_item->kind() == RootItemKind::Bin) { else if (left_item->kind() == RootItemKind::Bin) {
// Left item is recycle bin. Make sure it is "biggest" item if we have selected ascending order. // Left item is recycle bin. Make sure it is "biggest" item if we have selected ascending order.
return sortOrder() == Qt::DescendingOrder; return sortOrder() == Qt::DescendingOrder;
} }
else if (right_item->kind() == RootItemKind::Bin) { else if (right_item->kind() == RootItemKind::Bin) {
// Right item is recycle bin. Make sure it is "smallest" item if we have selected descending order. // Right item is recycle bin. Make sure it is "smallest" item if we have selected descending order.
return sortOrder() == Qt::AscendingOrder; return sortOrder() == Qt::AscendingOrder;
} }
else if (left_item->kind() == RootItemKind::Feed) { else if (left_item->kind() == RootItemKind::Feed) {
// Left item is feed, right item is category. // Left item is feed, right item is category.
return false; return false;
} }
else { else {
// Left item is category, right item is feed. // 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" // 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; return true;
} }
} }
else { else {
return false; return false;
} }
@ -226,12 +219,10 @@ bool FeedsProxyModel::filterAcceptsRowInternal(int source_row, const QModelIndex
// Recycle bin is always displayed. // Recycle bin is always displayed.
return true; return true;
} }
else if (item->isParentOf(m_selectedItem)/* || item->isChildOf(m_selectedItem)*/ || m_selectedItem == item) { 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. // Currently selected item and all its parents and children must be displayed.
return true; return true;
} }
else { else {
// NOTE: If item has < 0 of unread message it may mean, that the count // 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. // of unread messages is not (yet) known, display that item too.

View File

@ -36,7 +36,6 @@ QList<Enclosure> Enclosures::decodeEnclosuresFromString(const QString& enclosure
enclosure.m_mimeType = QByteArray::fromBase64(mime_url.at(0).toLocal8Bit()); enclosure.m_mimeType = QByteArray::fromBase64(mime_url.at(0).toLocal8Bit());
enclosure.m_url = QByteArray::fromBase64(mime_url.at(1).toLocal8Bit()); enclosure.m_url = QByteArray::fromBase64(mime_url.at(1).toLocal8Bit());
} }
else { else {
enclosure.m_url = QByteArray::fromBase64(single_enclosure.toLocal8Bit()); enclosure.m_url = QByteArray::fromBase64(single_enclosure.toLocal8Bit());
} }
@ -54,7 +53,6 @@ QString Enclosures::encodeEnclosuresToString(const QList<Enclosure>& enclosures)
if (enclosure.m_mimeType.isEmpty()) { if (enclosure.m_mimeType.isEmpty()) {
enclosures_str.append(enclosure.m_url.toLocal8Bit().toBase64()); enclosures_str.append(enclosure.m_url.toLocal8Bit().toBase64());
} }
else { else {
enclosures_str.append(QString(enclosure.m_mimeType.toLocal8Bit().toBase64()) + enclosures_str.append(QString(enclosure.m_mimeType.toLocal8Bit().toBase64()) +
ECNLOSURES_INNER_SEPARATOR + ECNLOSURES_INNER_SEPARATOR +

View File

@ -82,7 +82,6 @@ void MessagesModel::loadMessages(RootItem* item) {
if (item == nullptr) { if (item == nullptr) {
setFilter(QSL(DEFAULT_SQL_MESSAGES_FILTER)); setFilter(QSL(DEFAULT_SQL_MESSAGES_FILTER));
} }
else { else {
if (!item->getParentServiceRoot()->loadMessagesForItem(item, this)) { if (!item->getParentServiceRoot()->loadMessagesForItem(item, this)) {
setFilter(QSL("true != true")); setFilter(QSL("true != true"));
@ -138,7 +137,6 @@ void MessagesModel::updateDateFormat() {
if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::UseCustomDate)).toBool()) { if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::UseCustomDate)).toBool()) {
m_customDateFormat = qApp->settings()->value(GROUP(Messages), SETTING(Messages::CustomDateFormat)).toString(); m_customDateFormat = qApp->settings()->value(GROUP(Messages), SETTING(Messages::CustomDateFormat)).toString();
} }
else { else {
m_customDateFormat = QString(); m_customDateFormat = QString();
} }
@ -202,21 +200,17 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
if (m_customDateFormat.isEmpty()) { if (m_customDateFormat.isEmpty()) {
return dt.toString(Qt::DefaultLocaleShortDate); return dt.toString(Qt::DefaultLocaleShortDate);
} }
else { else {
return dt.toString(m_customDateFormat); return dt.toString(m_customDateFormat);
} }
} }
else if (index_column == MSG_DB_AUTHOR_INDEX) { else if (index_column == MSG_DB_AUTHOR_INDEX) {
const QString author_name = QSqlQueryModel::data(idx, role).toString(); const QString author_name = QSqlQueryModel::data(idx, role).toString();
return author_name.isEmpty() ? QSL("-") : author_name; return author_name.isEmpty() ? QSL("-") : author_name;
} }
else if (index_column != MSG_DB_IMPORTANT_INDEX && index_column != MSG_DB_READ_INDEX) { else if (index_column != MSG_DB_IMPORTANT_INDEX && index_column != MSG_DB_READ_INDEX) {
return QSqlQueryModel::data(idx, role); return QSqlQueryModel::data(idx, role);
} }
else { else {
return QVariant(); 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); QModelIndex idx_del = index(idx.row(), MSG_DB_PDELETED_INDEX);
is_deleted = data(idx_del, Qt::EditRole).toBool(); is_deleted = data(idx_del, Qt::EditRole).toBool();
} }
else { else {
QModelIndex idx_del = index(idx.row(), MSG_DB_DELETED_INDEX); QModelIndex idx_del = index(idx.row(), MSG_DB_DELETED_INDEX);
is_deleted = data(idx_del, Qt::EditRole).toBool(); 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()) { if (data_read.toBool()) {
return striked ? m_normalStrikedFont : m_normalFont; return striked ? m_normalStrikedFont : m_normalFont;
} }
else { else {
return striked ? m_boldStrikedFont : m_boldFont; 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); 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; return dta.toInt() == 1 ? m_readIcon : m_unreadIcon;
} }
else if (index_column == MSG_DB_IMPORTANT_INDEX) { else if (index_column == MSG_DB_IMPORTANT_INDEX) {
QModelIndex idx_important = index(idx.row(), 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); QVariant dta = m_cache->containsData(idx_important.row()) ? m_cache->data(idx_important) : QSqlQueryModel::data(idx_important);
return dta.toInt() == 1 ? m_favoriteIcon : QVariant(); return dta.toInt() == 1 ? m_favoriteIcon : QVariant();
} }
else { else {
return QVariant(); 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)) { if (DatabaseQueries::markMessagesReadUnread(m_db, QStringList() << QString::number(message.m_id), read)) {
return m_selectedItem->getParentServiceRoot()->onAfterSetMessagesRead(m_selectedItem, QList<Message>() << message, read); return m_selectedItem->getParentServiceRoot()->onAfterSetMessagesRead(m_selectedItem, QList<Message>() << message, read);
} }
else { else {
return false; return false;
} }
@ -374,7 +363,6 @@ bool MessagesModel::switchMessageImportance(int row_index) {
return m_selectedItem->getParentServiceRoot()->onAfterSwitchMessageImportance(m_selectedItem, return m_selectedItem->getParentServiceRoot()->onAfterSwitchMessageImportance(m_selectedItem,
QList<QPair<Message, RootItem::Importance>>() << pair); QList<QPair<Message, RootItem::Importance>>() << pair);
} }
else { else {
return false; return false;
} }
@ -407,7 +395,6 @@ bool MessagesModel::switchBatchMessageImportance(const QModelIndexList& messages
if (DatabaseQueries::switchMessagesImportance(m_db, message_ids)) { if (DatabaseQueries::switchMessagesImportance(m_db, message_ids)) {
return m_selectedItem->getParentServiceRoot()->onAfterSwitchMessageImportance(m_selectedItem, message_states); return m_selectedItem->getParentServiceRoot()->onAfterSwitchMessageImportance(m_selectedItem, message_states);
} }
else { else {
return false; return false;
} }
@ -426,7 +413,6 @@ bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList& messages) {
if (qobject_cast<RecycleBin*>(m_selectedItem) != nullptr) { if (qobject_cast<RecycleBin*>(m_selectedItem) != nullptr) {
setData(index(message.row(), MSG_DB_PDELETED_INDEX), 1); setData(index(message.row(), MSG_DB_PDELETED_INDEX), 1);
} }
else { else {
setData(index(message.row(), MSG_DB_DELETED_INDEX), 1); 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) { if (m_selectedItem->kind() != RootItemKind::Bin) {
deleted = DatabaseQueries::deleteOrRestoreMessagesToFromBin(m_db, message_ids, true); deleted = DatabaseQueries::deleteOrRestoreMessagesToFromBin(m_db, message_ids, true);
} }
else { else {
deleted = DatabaseQueries::permanentlyDeleteMessages(m_db, message_ids); deleted = DatabaseQueries::permanentlyDeleteMessages(m_db, message_ids);
} }
@ -451,7 +436,6 @@ bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList& messages) {
if (deleted) { if (deleted) {
return m_selectedItem->getParentServiceRoot()->onAfterMessagesDelete(m_selectedItem, msgs); return m_selectedItem->getParentServiceRoot()->onAfterMessagesDelete(m_selectedItem, msgs);
} }
else { else {
return false; return false;
} }
@ -478,7 +462,6 @@ bool MessagesModel::setBatchMessagesRead(const QModelIndexList& messages, RootIt
if (DatabaseQueries::markMessagesReadUnread(m_db, message_ids, read)) { if (DatabaseQueries::markMessagesReadUnread(m_db, message_ids, read)) {
return m_selectedItem->getParentServiceRoot()->onAfterSetMessagesRead(m_selectedItem, msgs, read); return m_selectedItem->getParentServiceRoot()->onAfterSetMessagesRead(m_selectedItem, msgs, read);
} }
else { else {
return false; return false;
} }
@ -506,7 +489,6 @@ bool MessagesModel::setBatchMessagesRestored(const QModelIndexList& messages) {
if (DatabaseQueries::deleteOrRestoreMessagesToFromBin(m_db, message_ids, false)) { if (DatabaseQueries::deleteOrRestoreMessagesToFromBin(m_db, message_ids, false)) {
return m_selectedItem->getParentServiceRoot()->onAfterMessagesRestoredFromBin(m_selectedItem, msgs); return m_selectedItem->getParentServiceRoot()->onAfterMessagesRestoredFromBin(m_selectedItem, msgs);
} }
else { else {
return false; 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) { if (section != MSG_DB_READ_INDEX && section != MSG_DB_IMPORTANT_INDEX) {
return m_headerData.at(section); return m_headerData.at(section);
} }
else { else {
return QVariant(); return QVariant();
} }

View File

@ -64,7 +64,6 @@ void MessagesModelSqlLayer::addSortState(int column, Qt::SortOrder order) {
m_sortColumns.append(column); m_sortColumns.append(column);
m_sortOrders.append(order); m_sortOrders.append(order);
} }
else { else {
m_sortColumns.prepend(column); m_sortColumns.prepend(column);
m_sortOrders.prepend(order); m_sortOrders.prepend(order);
@ -91,7 +90,6 @@ QString MessagesModelSqlLayer::orderByClause() const {
if (m_sortColumns.isEmpty()) { if (m_sortColumns.isEmpty()) {
return QString(); return QString();
} }
else { else {
QStringList sorts; QStringList sorts;

View File

@ -59,7 +59,6 @@ QModelIndex MessagesProxyModel::getNextUnreadItemIndex(int default_row, int max_
// We found unread message, mark it. // We found unread message, mark it.
return proxy_index; return proxy_index;
} }
else { else {
default_row++; default_row++;
} }
@ -83,7 +82,6 @@ QModelIndexList MessagesProxyModel::mapListFromSource(const QModelIndexList& ind
// Construct new source index. // Construct new source index.
mapped_indexes << mapFromSource(m_sourceModel->index(index.row(), index.column())); mapped_indexes << mapFromSource(m_sourceModel->index(index.row(), index.column()));
} }
else { else {
mapped_indexes << mapFromSource(index); mapped_indexes << mapFromSource(index);
} }
@ -119,7 +117,6 @@ QModelIndexList MessagesProxyModel::match(const QModelIndex& start, int role,
result.append(idx); result.append(idx);
} }
} }
// QString based matching. // QString based matching.
else { else {
if (entered_text.isEmpty()) { if (entered_text.isEmpty()) {

View File

@ -48,7 +48,6 @@ bool DynamicShortcutsWidget::areShortcutsUnique() const {
// Problem, two identical non-empty shortcuts found. // Problem, two identical non-empty shortcuts found.
return false; return false;
} }
else { else {
all_shortcuts.append(binding.second->shortcut()); all_shortcuts.append(binding.second->shortcut());
} }

View File

@ -99,7 +99,6 @@ void ShortcutButton::keyPressEvent(QKeyEvent* event) {
if ((pressed_key == Qt::Key_Backtab) && (m_catcher->m_modifierKeys & Qt::SHIFT)) { if ((pressed_key == Qt::Key_Backtab) && (m_catcher->m_modifierKeys & Qt::SHIFT)) {
pressed_key = Qt::Key_Tab | m_catcher->m_modifierKeys; pressed_key = Qt::Key_Tab | m_catcher->m_modifierKeys;
} }
else { else {
pressed_key |= m_catcher->m_modifierKeys; pressed_key |= m_catcher->m_modifierKeys;
} }

View File

@ -30,9 +30,7 @@
FormAbout::FormAbout(QWidget* parent) : QDialog(parent) { FormAbout::FormAbout(QWidget* parent) : QDialog(parent) {
m_ui.setupUi(this); m_ui.setupUi(this);
m_ui.m_lblIcon->setPixmap(QPixmap(APP_ICON_PATH)); m_ui.m_lblIcon->setPixmap(QPixmap(APP_ICON_PATH));
GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("help-about")), tr("About %1").arg(APP_NAME)); GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("help-about")), tr("About %1").arg(APP_NAME));
loadLicenseAndInformation(); loadLicenseAndInformation();
loadSettingsAndPaths(); loadSettingsAndPaths();
} }
@ -45,7 +43,6 @@ void FormAbout::loadSettingsAndPaths() {
if (qApp->settings()->type() == SettingsProperties::Portable) { if (qApp->settings()->type() == SettingsProperties::Portable) {
m_ui.m_txtPathsSettingsType->setText(tr("FULLY portable")); m_ui.m_txtPathsSettingsType->setText(tr("FULLY portable"));
} }
else { else {
m_ui.m_txtPathsSettingsType->setText(tr("NOT portable")); m_ui.m_txtPathsSettingsType->setText(tr("NOT portable"));
} }

View File

@ -50,7 +50,6 @@ void FormAddAccount::addSelectedAccount() {
if (new_root != nullptr) { if (new_root != nullptr) {
m_model->addServiceAccount(new_root, true); m_model->addServiceAccount(new_root, true);
} }
else { else {
qCritical("Cannot create new account."); qCritical("Cannot create new account.");
} }

View File

@ -61,7 +61,6 @@ void FormBackupDatabaseSettings::performBackup() {
tr("Backup was created successfully and stored in target directory."), tr("Backup was created successfully and stored in target directory."),
tr("Backup was created successfully.")); tr("Backup was created successfully."));
} }
catch (const ApplicationException& ex) { catch (const ApplicationException& ex) {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, ex.message(), tr("Backup failed.")); 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()) { if (name.simplified().isEmpty()) {
m_ui->m_txtBackupName->setStatus(WidgetWithStatus::Error, tr("Backup name cannot be empty.")); m_ui->m_txtBackupName->setStatus(WidgetWithStatus::Error, tr("Backup name cannot be empty."));
} }
else { else {
m_ui->m_txtBackupName->setStatus(WidgetWithStatus::Ok, tr("Backup name looks okay.")); m_ui->m_txtBackupName->setStatus(WidgetWithStatus::Ok, tr("Backup name looks okay."));
} }

View File

@ -59,7 +59,6 @@ void FormDatabaseCleanup::closeEvent(QCloseEvent* event) {
if (m_ui->m_progressBar->isEnabled()) { if (m_ui->m_progressBar->isEnabled()) {
event->ignore(); event->ignore();
} }
else { else {
QDialog::closeEvent(event); QDialog::closeEvent(event);
} }
@ -69,7 +68,6 @@ void FormDatabaseCleanup::keyPressEvent(QKeyEvent* event) {
if (m_ui->m_progressBar->isEnabled()) { if (m_ui->m_progressBar->isEnabled()) {
event->ignore(); event->ignore();
} }
else { else {
QDialog::keyPressEvent(event); QDialog::keyPressEvent(event);
} }
@ -110,7 +108,6 @@ void FormDatabaseCleanup::onPurgeFinished(bool finished) {
if (finished) { if (finished) {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Database cleanup is completed."), tr("Database cleanup is completed.")); m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Database cleanup is completed."), tr("Database cleanup is completed."));
} }
else { else {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Database cleanup failed."), tr("Database cleanup failed.")); m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Database cleanup failed."), tr("Database cleanup failed."));
} }

View File

@ -65,31 +65,24 @@ FormMain::FormMain(QWidget* parent, Qt::WindowFlags f)
: QMainWindow(parent, f), m_ui(new Ui::FormMain) { : QMainWindow(parent, f), m_ui(new Ui::FormMain) {
m_ui->setupUi(this); m_ui->setupUi(this);
qApp->setMainForm(this); qApp->setMainForm(this);
#if defined (USE_WEBENGINE) #if defined (USE_WEBENGINE)
m_ui->m_menuWebBrowserTabs->addAction(AdBlockManager::instance()->adBlockIcon()); m_ui->m_menuWebBrowserTabs->addAction(AdBlockManager::instance()->adBlockIcon());
m_ui->m_menuWebBrowserTabs->addAction(qApp->web()->engineSettingsAction()); m_ui->m_menuWebBrowserTabs->addAction(qApp->web()->engineSettingsAction());
#endif #endif
// Add these actions to the list of actions of the main window. // Add these actions to the list of actions of the main window.
// This allows to use actions via shortcuts // This allows to use actions via shortcuts
// even if main menu is not visible. // even if main menu is not visible.
addActions(qApp->userActions()); addActions(qApp->userActions());
setStatusBar(m_statusBar = new StatusBar(this)); setStatusBar(m_statusBar = new StatusBar(this));
// Prepare main window and tabs. // Prepare main window and tabs.
prepareMenus(); prepareMenus();
// Prepare tabs. // Prepare tabs.
tabWidget()->feedMessageViewer()->feedsToolBar()->loadSavedActions(); tabWidget()->feedMessageViewer()->feedsToolBar()->loadSavedActions();
tabWidget()->feedMessageViewer()->messagesToolBar()->loadSavedActions(); tabWidget()->feedMessageViewer()->messagesToolBar()->loadSavedActions();
// Establish connections. // Establish connections.
createConnections(); createConnections();
updateMessageButtonsAvailability(); updateMessageButtonsAvailability();
updateFeedButtonsAvailability(); updateFeedButtonsAvailability();
// Setup some appearance of the window. // Setup some appearance of the window.
setupIcons(); setupIcons();
loadSize(); loadSize();
@ -121,7 +114,6 @@ void FormMain::showDbCleanupAssistant() {
tabWidget()->feedMessageViewer()->messagesView()->reloadSelections(); tabWidget()->feedMessageViewer()->messagesView()->reloadSelections();
qApp->feedReader()->feedsModel()->reloadCountsOfWholeModel(); qApp->feedReader()->feedsModel()->reloadCountsOfWholeModel();
} }
else { else {
qApp->showGuiMessage(tr("Cannot cleanup database"), qApp->showGuiMessage(tr("Cannot cleanup database"),
tr("Cannot cleanup database, because another critical action is running."), 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()); qApp->settings()->setValue(GROUP(GUI), GUI::IsMainWindowMaximizedBeforeFullscreen, isMaximized());
showFullScreen(); showFullScreen();
} }
else { else {
if (qApp->settings()->value(GROUP(GUI), SETTING(GUI::IsMainWindowMaximizedBeforeFullscreen)).toBool()) { if (qApp->settings()->value(GROUP(GUI), SETTING(GUI::IsMainWindowMaximizedBeforeFullscreen)).toBool()) {
setWindowState((windowState() & ~Qt::WindowFullScreen) | Qt::WindowMaximized); setWindowState((windowState() & ~Qt::WindowFullScreen) | Qt::WindowMaximized);
} }
else { else {
showNormal(); 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_actionAddCategoryIntoSelectedAccount);
m_ui->m_menuAddItem->addAction(m_ui->m_actionAddFeedIntoSelectedAccount); m_ui->m_menuAddItem->addAction(m_ui->m_actionAddFeedIntoSelectedAccount);
} }
else { else {
m_ui->m_menuAddItem->addAction(m_ui->m_actionNoActions); m_ui->m_menuAddItem->addAction(m_ui->m_actionNoActions);
} }
@ -302,7 +291,6 @@ void FormMain::updateRecycleBinMenu() {
no_action->setEnabled(false); no_action->setEnabled(false);
root_menu->addAction(no_action); root_menu->addAction(no_action);
} }
else if ((context_menu = bin->contextMenu()).isEmpty()) { else if ((context_menu = bin->contextMenu()).isEmpty()) {
QAction* no_action = new QAction(qApp->icons()->fromTheme(QSL("dialog-error")), QAction* no_action = new QAction(qApp->icons()->fromTheme(QSL("dialog-error")),
tr("No actions possible"), tr("No actions possible"),
@ -310,7 +298,6 @@ void FormMain::updateRecycleBinMenu() {
no_action->setEnabled(false); no_action->setEnabled(false);
root_menu->addAction(no_action); root_menu->addAction(no_action);
} }
else { else {
root_menu->addActions(context_menu); root_menu->addActions(context_menu);
} }
@ -342,7 +329,6 @@ void FormMain::updateAccountsMenu() {
no_action->setEnabled(false); no_action->setEnabled(false);
root_menu->addAction(no_action); root_menu->addAction(no_action);
} }
else { else {
root_menu->addActions(root_actions); root_menu->addActions(root_actions);
} }
@ -425,13 +411,11 @@ void FormMain::switchVisibility(bool force_hide) {
if (SystemTrayIcon::isSystemTrayActivated()) { if (SystemTrayIcon::isSystemTrayActivated()) {
hide(); hide();
} }
else { else {
// Window gets minimized in single-window mode. // Window gets minimized in single-window mode.
showMinimized(); showMinimized();
} }
} }
else { else {
display(); display();
} }
@ -582,28 +566,23 @@ void FormMain::createConnections() {
connect(m_ui->m_menuAccounts, &QMenu::aboutToShow, this, &FormMain::updateAccountsMenu); 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_actionServiceDelete, &QAction::triggered, m_ui->m_actionDeleteSelectedItem, &QAction::triggered);
connect(m_ui->m_actionServiceEdit, &QAction::triggered, m_ui->m_actionEditSelectedItem, &QAction::triggered); connect(m_ui->m_actionServiceEdit, &QAction::triggered, m_ui->m_actionEditSelectedItem, &QAction::triggered);
// Menu "File" connections. // Menu "File" connections.
connect(m_ui->m_actionBackupDatabaseSettings, &QAction::triggered, this, &FormMain::backupDatabaseSettings); connect(m_ui->m_actionBackupDatabaseSettings, &QAction::triggered, this, &FormMain::backupDatabaseSettings);
connect(m_ui->m_actionRestoreDatabaseSettings, &QAction::triggered, this, &FormMain::restoreDatabaseSettings); connect(m_ui->m_actionRestoreDatabaseSettings, &QAction::triggered, this, &FormMain::restoreDatabaseSettings);
connect(m_ui->m_actionQuit, &QAction::triggered, qApp, &Application::quit); connect(m_ui->m_actionQuit, &QAction::triggered, qApp, &Application::quit);
connect(m_ui->m_actionServiceAdd, &QAction::triggered, this, &FormMain::showAddAccountDialog); connect(m_ui->m_actionServiceAdd, &QAction::triggered, this, &FormMain::showAddAccountDialog);
connect(m_ui->m_actionRestart, &QAction::triggered, qApp, &Application::restart); connect(m_ui->m_actionRestart, &QAction::triggered, qApp, &Application::restart);
// Menu "View" connections. // Menu "View" connections.
connect(m_ui->m_actionFullscreen, &QAction::toggled, this, &FormMain::switchFullscreenMode); 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_actionSwitchMainMenu, &QAction::toggled, m_ui->m_menuBar, &QMenuBar::setVisible);
connect(m_ui->m_actionSwitchMainWindow, &QAction::triggered, this, &FormMain::switchVisibility); connect(m_ui->m_actionSwitchMainWindow, &QAction::triggered, this, &FormMain::switchVisibility);
connect(m_ui->m_actionSwitchStatusBar, &QAction::toggled, statusBar(), &StatusBar::setVisible); connect(m_ui->m_actionSwitchStatusBar, &QAction::toggled, statusBar(), &StatusBar::setVisible);
// Menu "Tools" connections. // Menu "Tools" connections.
connect(m_ui->m_actionSettings, &QAction::triggered, [this]() { connect(m_ui->m_actionSettings, &QAction::triggered, [this]() {
FormSettings(*this).exec(); FormSettings(*this).exec();
}); });
connect(m_ui->m_actionDownloadManager, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::showDownloadManager); connect(m_ui->m_actionDownloadManager, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::showDownloadManager);
connect(m_ui->m_actionCleanupDatabase, &QAction::triggered, this, &FormMain::showDbCleanupAssistant); connect(m_ui->m_actionCleanupDatabase, &QAction::triggered, this, &FormMain::showDbCleanupAssistant);
// Menu "Help" connections. // Menu "Help" connections.
connect(m_ui->m_actionAboutGuard, &QAction::triggered, [this]() { connect(m_ui->m_actionAboutGuard, &QAction::triggered, [this]() {
FormAbout(this).exec(); FormAbout(this).exec();
@ -614,7 +593,6 @@ void FormMain::createConnections() {
connect(m_ui->m_actionReportBug, &QAction::triggered, this, &FormMain::reportABug); connect(m_ui->m_actionReportBug, &QAction::triggered, this, &FormMain::reportABug);
connect(m_ui->m_actionDonate, &QAction::triggered, this, &FormMain::donate); connect(m_ui->m_actionDonate, &QAction::triggered, this, &FormMain::donate);
connect(m_ui->m_actionDisplayWiki, &QAction::triggered, this, &FormMain::showWiki); connect(m_ui->m_actionDisplayWiki, &QAction::triggered, this, &FormMain::showWiki);
// Tab widget connections. // Tab widget connections.
connect(m_ui->m_actionTabsCloseAllExceptCurrent, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::closeAllTabsExceptCurrent); 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); 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::feedUpdatesStarted, this, &FormMain::onFeedUpdatesStarted);
connect(qApp->feedReader(), &FeedReader::feedUpdatesProgress, this, &FormMain::onFeedUpdatesProgress); connect(qApp->feedReader(), &FeedReader::feedUpdatesProgress, this, &FormMain::onFeedUpdatesProgress);
connect(qApp->feedReader(), &FeedReader::feedUpdatesFinished, this, &FormMain::onFeedUpdatesFinished); connect(qApp->feedReader(), &FeedReader::feedUpdatesFinished, this, &FormMain::onFeedUpdatesFinished);
// Toolbar forwardings. // Toolbar forwardings.
connect(m_ui->m_actionAddFeedIntoSelectedAccount, &QAction::triggered, connect(m_ui->m_actionAddFeedIntoSelectedAccount, &QAction::triggered,
tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::addFeedIntoSelectedAccount); tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::addFeedIntoSelectedAccount);

View File

@ -28,13 +28,10 @@
FormRestoreDatabaseSettings::FormRestoreDatabaseSettings(QWidget& parent) FormRestoreDatabaseSettings::FormRestoreDatabaseSettings(QWidget& parent)
: QDialog(&parent), m_shouldRestart(false) { : QDialog(&parent), m_shouldRestart(false) {
m_ui.setupUi(this); m_ui.setupUi(this);
m_btnRestart = m_ui.m_buttonBox->addButton(tr("Restart"), QDialogButtonBox::ActionRole); 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.")); m_ui.m_lblResult->setStatus(WidgetWithStatus::Warning, tr("No operation executed yet."), tr("No operation executed yet."));
setWindowIcon(qApp->icons()->fromTheme(QSL("document-import"))); setWindowIcon(qApp->icons()->fromTheme(QSL("document-import")));
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint); setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint);
connect(m_btnRestart, &QPushButton::clicked, this, [ = ]() { connect(m_btnRestart, &QPushButton::clicked, this, [ = ]() {
m_shouldRestart = true; m_shouldRestart = true;
close(); close();
@ -94,7 +91,6 @@ void FormRestoreDatabaseSettings::selectFolder(QString folder) {
m_ui.m_lblSelectFolder->setStatus(WidgetWithStatus::Ok, QDir::toNativeSeparators(folder), m_ui.m_lblSelectFolder->setStatus(WidgetWithStatus::Ok, QDir::toNativeSeparators(folder),
tr("Good source directory is specified.")); tr("Good source directory is specified."));
} }
else { else {
return; return;
} }

View File

@ -36,13 +36,11 @@
FormSettings::FormSettings(QWidget& parent) FormSettings::FormSettings(QWidget& parent)
: QDialog(&parent), m_panels(QList<SettingsPanel*>()), m_settings(*qApp->settings()) { : QDialog(&parent), m_panels(QList<SettingsPanel*>()), m_settings(*qApp->settings()) {
m_ui.setupUi(this); m_ui.setupUi(this);
// Set flags and attributes. // Set flags and attributes.
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint);
setWindowIcon(qApp->icons()->fromTheme(QSL("emblem-system"))); setWindowIcon(qApp->icons()->fromTheme(QSL("emblem-system")));
m_btnApply = m_ui.m_buttonBox->button(QDialogButtonBox::Apply); m_btnApply = m_ui.m_buttonBox->button(QDialogButtonBox::Apply);
m_btnApply->setEnabled(false); m_btnApply->setEnabled(false);
// Establish needed connections. // Establish needed connections.
connect(m_ui.m_buttonBox, &QDialogButtonBox::accepted, this, &FormSettings::saveSettings); connect(m_ui.m_buttonBox, &QDialogButtonBox::accepted, this, &FormSettings::saveSettings);
connect(m_ui.m_buttonBox, &QDialogButtonBox::rejected, this, &FormSettings::cancelSettings); 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 SettingsBrowserMail(&m_settings, this));
addSettingsPanel(new SettingsDownloads(&m_settings, this)); addSettingsPanel(new SettingsDownloads(&m_settings, this));
addSettingsPanel(new SettingsFeedsMessages(&m_settings, this)); addSettingsPanel(new SettingsFeedsMessages(&m_settings, this));
m_ui.m_listSettings->setCurrentRow(0); m_ui.m_listSettings->setCurrentRow(0);
} }
@ -115,7 +112,6 @@ void FormSettings::cancelSettings() {
if (changed_panels.isEmpty()) { if (changed_panels.isEmpty()) {
reject(); reject();
} }
else { else {
const QStringList changed_settings_description = changed_panels.replaceInStrings(QRegExp(QSL("^")), QString::fromUtf8("")); 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_panels.append(panel);
m_ui.m_stackedSettings->addWidget(panel); m_ui.m_stackedSettings->addWidget(panel);
panel->loadSettings(); panel->loadSettings();
connect(panel, &SettingsPanel::settingsChanged, [this]() { connect(panel, &SettingsPanel::settingsChanged, [this]() {
m_btnApply->setEnabled(true); m_btnApply->setEnabled(true);
}); });

View File

@ -40,10 +40,8 @@ FormUpdate::FormUpdate(QWidget* parent)
m_ui.m_lblCurrentRelease->setText(APP_VERSION); m_ui.m_lblCurrentRelease->setText(APP_VERSION);
m_ui.m_tabInfo->removeTab(1); m_ui.m_tabInfo->removeTab(1);
m_ui.m_buttonBox->setEnabled(false); m_ui.m_buttonBox->setEnabled(false);
// Set flags and attributes. // Set flags and attributes.
GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("help-about"))); GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("help-about")));
connect(&m_downloader, &Downloader::progress, this, &FormUpdate::updateProgress); connect(&m_downloader, &Downloader::progress, this, &FormUpdate::updateProgress);
connect(&m_downloader, &Downloader::completed, this, &FormUpdate::updateCompleted); connect(&m_downloader, &Downloader::completed, this, &FormUpdate::updateCompleted);
@ -111,7 +109,6 @@ void FormUpdate::checkForUpdates() {
} }
} }
}); });
qApp->system()->checkForUpdates(); qApp->system()->checkForUpdates();
} }
@ -233,15 +230,12 @@ void FormUpdate::startUpdate() {
#endif #endif
} }
else if (update_for_this_system) { else if (update_for_this_system) {
updateProgress(0, 100); updateProgress(0, 100);
m_btnUpdate->setText(tr("Downloading update...")); m_btnUpdate->setText(tr("Downloading update..."));
m_btnUpdate->setEnabled(false); m_btnUpdate->setEnabled(false);
m_downloader.downloadFile(url_file); m_downloader.downloadFile(url_file);
} }
else { else {
// Self-update and package are not available. // Self-update and package are not available.
if (!qApp->web()->openUrlInExternalBrowser(url_file)) { if (!qApp->web()->openUrlInExternalBrowser(url_file)) {

View File

@ -67,7 +67,6 @@ void DiscoverFeedsButton::linkTriggered(QAction* action) {
if (root->supportsFeedAdding()) { if (root->supportsFeedAdding()) {
root->addNewFeed(url); root->addNewFeed(url);
} }
else { else {
qApp->showGuiMessage(tr("Not supported"), qApp->showGuiMessage(tr("Not supported"),
tr("Given account does not support adding feeds."), tr("Given account does not support adding feeds."),

View File

@ -28,7 +28,6 @@ void EditTableView::keyPressEvent(QKeyEvent* event) {
removeSelected(); removeSelected();
event->accept(); event->accept();
} }
else { else {
QAbstractItemView::keyPressEvent(event); QAbstractItemView::keyPressEvent(event);
} }

View File

@ -146,7 +146,6 @@ void FeedMessageViewer::switchMessageSplitterOrientation() {
if (m_messageSplitter->orientation() == Qt::Vertical) { if (m_messageSplitter->orientation() == Qt::Vertical) {
m_messageSplitter->setOrientation(Qt::Horizontal); m_messageSplitter->setOrientation(Qt::Horizontal);
} }
else { else {
m_messageSplitter->setOrientation(Qt::Vertical); m_messageSplitter->setOrientation(Qt::Vertical);
} }
@ -170,7 +169,6 @@ void FeedMessageViewer::switchFeedComponentVisibility() {
if (sen != nullptr) { if (sen != nullptr) {
m_feedsWidget->setVisible(sen->isChecked()); m_feedsWidget->setVisible(sen->isChecked());
} }
else { else {
m_feedsWidget->setVisible(!m_feedsWidget->isVisible()); m_feedsWidget->setVisible(!m_feedsWidget->isVisible());
} }
@ -182,7 +180,6 @@ void FeedMessageViewer::toggleShowOnlyUnreadFeeds() {
if (origin == nullptr) { if (origin == nullptr) {
m_feedsView->model()->invalidateReadFeedsFilter(true, false); m_feedsView->model()->invalidateReadFeedsFilter(true, false);
} }
else { else {
m_feedsView->model()->invalidateReadFeedsFilter(true, origin->isChecked()); m_feedsView->model()->invalidateReadFeedsFilter(true, origin->isChecked());
} }

View File

@ -59,14 +59,12 @@ QList<QAction*> FeedsToolBar::getSpecificActions(const QStringList& actions) {
// Add existing standard action. // Add existing standard action.
spec_actions.append(matching_action); spec_actions.append(matching_action);
} }
else if (action_name == SEPARATOR_ACTION_NAME) { else if (action_name == SEPARATOR_ACTION_NAME) {
// Add new separator. // Add new separator.
QAction* act = new QAction(this); QAction* act = new QAction(this);
act->setSeparator(true); act->setSeparator(true);
spec_actions.append(act); spec_actions.append(act);
} }
else if (action_name == SPACER_ACTION_NAME) { else if (action_name == SPACER_ACTION_NAME) {
// Add new spacer. // Add new spacer.
QWidget* spacer = new QWidget(this); QWidget* spacer = new QWidget(this);

View File

@ -78,7 +78,6 @@ QList<Feed*> FeedsView::selectedFeeds() const {
if (current_index.isValid()) { if (current_index.isValid()) {
return m_sourceModel->feedsForIndex(m_proxyModel->mapToSource(current_index)); return m_sourceModel->feedsForIndex(m_proxyModel->mapToSource(current_index));
} }
else { else {
return QList<Feed*>(); return QList<Feed*>();
} }
@ -90,7 +89,6 @@ RootItem* FeedsView::selectedItem() const {
if (selected_rows.isEmpty()) { if (selected_rows.isEmpty()) {
return nullptr; return nullptr;
} }
else { else {
RootItem* selected_item = m_sourceModel->itemForIndex(m_proxyModel->mapToSource(selected_rows.at(0))); RootItem* selected_item = m_sourceModel->itemForIndex(m_proxyModel->mapToSource(selected_rows.at(0)));
return selected_item == m_sourceModel->rootItem() ? nullptr : selected_item; 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) { if (column == old_column && order == old_order) {
m_proxyModel->sort(column, order); m_proxyModel->sort(column, order);
} }
else { else {
QTreeView::sortByColumn(column, order); QTreeView::sortByColumn(column, order);
} }
@ -158,7 +155,6 @@ void FeedsView::addFeedIntoSelectedAccount() {
if (root->supportsFeedAdding()) { if (root->supportsFeedAdding()) {
root->addNewFeed(); root->addNewFeed();
} }
else { else {
qApp->showGuiMessage(tr("Not supported"), qApp->showGuiMessage(tr("Not supported"),
tr("Selected account does not support adding of new feeds."), tr("Selected account does not support adding of new feeds."),
@ -177,7 +173,6 @@ void FeedsView::addCategoryIntoSelectedAccount() {
if (root->supportsCategoryAdding()) { if (root->supportsCategoryAdding()) {
root->addNewCategory(); root->addNewCategory();
} }
else { else {
qApp->showGuiMessage(tr("Not supported"), qApp->showGuiMessage(tr("Not supported"),
tr("Selected account does not support adding of new categories."), tr("Selected account does not support adding of new categories."),
@ -227,7 +222,6 @@ void FeedsView::editSelectedItem() {
if (selectedItem()->canBeEdited()) { if (selectedItem()->canBeEdited()) {
selectedItem()->editViaGui(); selectedItem()->editViaGui();
} }
else { else {
qApp->showGuiMessage(tr("Cannot edit item"), qApp->showGuiMessage(tr("Cannot edit item"),
tr("Selected item cannot be edited, this is not (yet?) supported."), tr("Selected item cannot be edited, this is not (yet?) supported."),
@ -283,7 +277,6 @@ void FeedsView::deleteSelectedItem() {
true); true);
} }
} }
else { else {
qApp->showGuiMessage(tr("Cannot delete \"%1\"").arg(selected_item->title()), 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."), 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) { if (m_contextMenuCategories == nullptr) {
m_contextMenuCategories = new QMenu(tr("Context menu for categories"), this); m_contextMenuCategories = new QMenu(tr("Context menu for categories"), this);
} }
else { else {
m_contextMenuCategories->clear(); m_contextMenuCategories->clear();
} }
@ -397,7 +389,6 @@ QMenu* FeedsView::initializeContextMenuFeeds(RootItem* clicked_item) {
if (m_contextMenuFeeds == nullptr) { if (m_contextMenuFeeds == nullptr) {
m_contextMenuFeeds = new QMenu(tr("Context menu for categories"), this); m_contextMenuFeeds = new QMenu(tr("Context menu for categories"), this);
} }
else { else {
m_contextMenuFeeds->clear(); m_contextMenuFeeds->clear();
} }
@ -433,7 +424,6 @@ QMenu* FeedsView::initializeContextMenuOtherItem(RootItem* clicked_item) {
if (m_contextMenuOtherItems == nullptr) { if (m_contextMenuOtherItems == nullptr) {
m_contextMenuOtherItems = new QMenu(tr("Context menu for other items"), this); m_contextMenuOtherItems = new QMenu(tr("Context menu for other items"), this);
} }
else { else {
m_contextMenuOtherItems->clear(); m_contextMenuOtherItems->clear();
} }
@ -444,7 +434,6 @@ QMenu* FeedsView::initializeContextMenuOtherItem(RootItem* clicked_item) {
m_contextMenuOtherItems->addSeparator(); m_contextMenuOtherItems->addSeparator();
m_contextMenuOtherItems->addActions(specific_actions); m_contextMenuOtherItems->addActions(specific_actions);
} }
else { else {
m_contextMenuOtherItems->addAction(qApp->mainForm()->m_ui->m_actionNoActions); m_contextMenuOtherItems->addAction(qApp->mainForm()->m_ui->m_actionNoActions);
} }
@ -502,17 +491,14 @@ void FeedsView::contextMenuEvent(QContextMenuEvent* event) {
// Display context menu for categories. // Display context menu for categories.
initializeContextMenuCategories(clicked_item)->exec(event->globalPos()); initializeContextMenuCategories(clicked_item)->exec(event->globalPos());
} }
else if (clicked_item->kind() == RootItemKind::Feed) { else if (clicked_item->kind() == RootItemKind::Feed) {
// Display context menu for feeds. // Display context menu for feeds.
initializeContextMenuFeeds(clicked_item)->exec(event->globalPos()); initializeContextMenuFeeds(clicked_item)->exec(event->globalPos());
} }
else { else {
initializeContextMenuOtherItem(clicked_item)->exec(event->globalPos()); initializeContextMenuOtherItem(clicked_item)->exec(event->globalPos());
} }
} }
else { else {
// Display menu for empty space. // Display menu for empty space.
initializeContextMenuEmptySpace()->exec(event->globalPos()); initializeContextMenuEmptySpace()->exec(event->globalPos());

View File

@ -26,7 +26,6 @@ void GuiUtilities::setLabelAsNotice(QLabel& label, bool is_warning) {
if (is_warning) { if (is_warning) {
label.setStyleSheet(QSL("font-weight: bold; font-style: italic; color: red")); label.setStyleSheet(QSL("font-weight: bold; font-style: italic; color: red"));
} }
else { else {
label.setStyleSheet(QSL("font-style: italic;")); label.setStyleSheet(QSL("font-style: italic;"));
} }

View File

@ -45,7 +45,6 @@ void LocationLineEdit::mousePressEvent(QMouseEvent* event) {
// User clicked and all text was selected. // User clicked and all text was selected.
m_mouseSelectsAllText = false; m_mouseSelectsAllText = false;
} }
else { else {
BaseLineEdit::mousePressEvent(event); BaseLineEdit::mousePressEvent(event);
} }

View File

@ -100,7 +100,6 @@ QMessageBox::StandardButton MessageBox::show(QWidget* parent,
if (msg_box.exec() == -1) { if (msg_box.exec() == -1) {
return QMessageBox::Cancel; return QMessageBox::Cancel;
} }
else { else {
return msg_box.standardButton(msg_box.clickedButton()); return msg_box.standardButton(msg_box.clickedButton());
} }

View File

@ -38,7 +38,6 @@ void MessagePreviewer::createConnections() {
if (open_externally_now) { if (open_externally_now) {
qApp->web()->openUrlInExternalBrowser(url.toString()); qApp->web()->openUrlInExternalBrowser(url.toString());
} }
else { else {
// User clicked some URL. Open it in external browser or download? // User clicked some URL. Open it in external browser or download?
MessageBox box(qApp->mainForm()); MessageBox box(qApp->mainForm());
@ -61,7 +60,6 @@ void MessagePreviewer::createConnections() {
if (box.clickedButton() == btn_open) { if (box.clickedButton() == btn_open) {
qApp->web()->openUrlInExternalBrowser(url.toString()); qApp->web()->openUrlInExternalBrowser(url.toString());
} }
else if (box.clickedButton() == btn_download) { else if (box.clickedButton() == btn_download) {
qApp->downloadManager()->download(url); qApp->downloadManager()->download(url);
} }
@ -71,7 +69,6 @@ void MessagePreviewer::createConnections() {
btn_cancel->deleteLater(); btn_cancel->deleteLater();
} }
} }
else { else {
MessageBox::show(qApp->mainForm(), QMessageBox::Warning, tr("Incorrect link"), MessageBox::show(qApp->mainForm(), QMessageBox::Warning, tr("Incorrect link"),
tr("Selected hyperlink is invalid.")); tr("Selected hyperlink is invalid."));

View File

@ -70,24 +70,20 @@ QList<QAction*> MessagesToolBar::getSpecificActions(const QStringList& actions)
// Add existing standard action. // Add existing standard action.
spec_actions.append(matching_action); spec_actions.append(matching_action);
} }
else if (action_name == SEPARATOR_ACTION_NAME) { else if (action_name == SEPARATOR_ACTION_NAME) {
// Add new separator. // Add new separator.
QAction* act = new QAction(this); QAction* act = new QAction(this);
act->setSeparator(true); act->setSeparator(true);
spec_actions.append(act); spec_actions.append(act);
} }
else if (action_name == SEACRH_MESSAGES_ACTION_NAME) { else if (action_name == SEACRH_MESSAGES_ACTION_NAME) {
// Add search box. // Add search box.
spec_actions.append(m_actionSearchMessages); spec_actions.append(m_actionSearchMessages);
} }
else if (action_name == HIGHLIGHTER_ACTION_NAME) { else if (action_name == HIGHLIGHTER_ACTION_NAME) {
// Add filter button. // Add filter button.
spec_actions.append(m_actionMessageHighlighter); spec_actions.append(m_actionMessageHighlighter);
} }
else if (action_name == SPACER_ACTION_NAME) { else if (action_name == SPACER_ACTION_NAME) {
// Add new spacer. // Add new spacer.
QWidget* spacer = new QWidget(this); QWidget* spacer = new QWidget(this);

View File

@ -100,7 +100,6 @@ void MessagesView::reloadSelections() {
if (m_proxyModel->rowCount() == 0) { if (m_proxyModel->rowCount() == 0) {
current_index = QModelIndex(); current_index = QModelIndex();
} }
else { else {
for (int i = 0; i < m_proxyModel->rowCount(); i++) { for (int i = 0; i < m_proxyModel->rowCount(); i++) {
QModelIndex msg_idx = m_proxyModel->index(i, MSG_DB_TITLE_INDEX); QModelIndex msg_idx = m_proxyModel->index(i, MSG_DB_TITLE_INDEX);
@ -123,7 +122,6 @@ void MessagesView::reloadSelections() {
setCurrentIndex(current_index); setCurrentIndex(current_index);
reselectIndexes(QModelIndexList() << current_index); reselectIndexes(QModelIndexList() << current_index);
} }
else { else {
// Messages were probably removed from the model, nothing can // Messages were probably removed from the model, nothing can
// be selected and no message can be displayed. // be selected and no message can be displayed.
@ -169,7 +167,6 @@ void MessagesView::contextMenuEvent(QContextMenuEvent* event) {
TreeViewColumnsMenu menu(header()); TreeViewColumnsMenu menu(header());
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
else { else {
// Context menu is not initialized, initialize. // Context menu is not initialized, initialize.
initializeContextMenu(); initializeContextMenu();
@ -257,7 +254,6 @@ void MessagesView::selectionChanged(const QItemSelection& selected, const QItemS
message.m_isRead = true; message.m_isRead = true;
emit currentMessageChanged(message, m_sourceModel->loadedItem()); emit currentMessageChanged(message, m_sourceModel->loadedItem());
} }
else { else {
emit currentMessageRemoved(); emit currentMessageRemoved();
} }
@ -348,7 +344,6 @@ void MessagesView::setSelectedMessagesReadStatus(RootItem::ReadStatus read) {
if (current_index.isValid()) { if (current_index.isValid()) {
emit currentMessageChanged(m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()), m_sourceModel->loadedItem()); emit currentMessageChanged(m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()), m_sourceModel->loadedItem());
} }
else { else {
emit currentMessageRemoved(); emit currentMessageRemoved();
} }
@ -370,7 +365,6 @@ void MessagesView::deleteSelectedMessages() {
setCurrentIndex(current_index); setCurrentIndex(current_index);
emit currentMessageChanged(m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()), m_sourceModel->loadedItem()); emit currentMessageChanged(m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()), m_sourceModel->loadedItem());
} }
else { else {
emit currentMessageRemoved(); emit currentMessageRemoved();
} }
@ -391,7 +385,6 @@ void MessagesView::restoreSelectedMessages() {
if (current_index.isValid()) { if (current_index.isValid()) {
emit currentMessageChanged(m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()), m_sourceModel->loadedItem()); emit currentMessageChanged(m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()), m_sourceModel->loadedItem());
} }
else { else {
emit currentMessageRemoved(); emit currentMessageRemoved();
} }
@ -412,7 +405,6 @@ void MessagesView::switchSelectedMessagesImportance() {
if (current_index.isValid()) { if (current_index.isValid()) {
emit currentMessageChanged(m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()), m_sourceModel->loadedItem()); emit currentMessageChanged(m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()), m_sourceModel->loadedItem());
} }
else { else {
// Messages were probably removed from the model, nothing can // Messages were probably removed from the model, nothing can
// be selected and no message can be displayed. // be selected and no message can be displayed.
@ -460,7 +452,6 @@ void MessagesView::selectNextUnreadItem() {
// Okay, something is selected, start from it. // Okay, something is selected, start from it.
active_row = selected_rows.at(0).row(); active_row = selected_rows.at(0).row();
} }
else { else {
active_row = 0; active_row = 0;
} }
@ -481,7 +472,6 @@ void MessagesView::searchMessages(const QString& pattern) {
if (selectionModel()->selectedRows().size() == 0) { if (selectionModel()->selectedRows().size() == 0) {
emit currentMessageRemoved(); emit currentMessageRemoved();
} }
else { else {
// Scroll to selected message, it could become scrolled out due to filter change. // Scroll to selected message, it could become scrolled out due to filter change.
scrollTo(selectionModel()->selectedRows().at(0)); scrollTo(selectionModel()->selectedRows().at(0));

View File

@ -54,7 +54,6 @@ void NewspaperPreviewer::showMoreMessages() {
m_ui->m_btnShowMoreMessages->setEnabled(!m_messages.isEmpty()); m_ui->m_btnShowMoreMessages->setEnabled(!m_messages.isEmpty());
m_ui->scrollArea->verticalScrollBar()->setValue(current_scroll); m_ui->scrollArea->verticalScrollBar()->setValue(current_scroll);
} }
else { else {
qApp->showGuiMessage(tr("Cannot show more messages"), qApp->showGuiMessage(tr("Cannot show more messages"),
tr("Cannot show more messages because parent feed was removed."), tr("Cannot show more messages because parent feed was removed."),

View File

@ -43,7 +43,6 @@ void PlainToolButton::paintEvent(QPaintEvent* e) {
p.setOpacity(0.7); p.setOpacity(0.7);
} }
} }
else { else {
p.setOpacity(0.3); p.setOpacity(0.3);
} }

View File

@ -32,13 +32,11 @@ SettingsBrowserMail::SettingsBrowserMail(Settings* settings, QWidget* parent)
GuiUtilities::setLabelAsNotice(*m_ui->label, false); GuiUtilities::setLabelAsNotice(*m_ui->label, false);
GuiUtilities::setLabelAsNotice(*m_ui->m_lblExternalEmailInfo, false); GuiUtilities::setLabelAsNotice(*m_ui->m_lblExternalEmailInfo, false);
GuiUtilities::setLabelAsNotice(*m_ui->m_lblProxyInfo, false); GuiUtilities::setLabelAsNotice(*m_ui->m_lblProxyInfo, false);
#if defined(USE_WEBENGINE) #if defined(USE_WEBENGINE)
m_ui->m_checkOpenLinksInExternal->setVisible(false); m_ui->m_checkOpenLinksInExternal->setVisible(false);
#else #else
connect(m_ui->m_checkOpenLinksInExternal, &QCheckBox::stateChanged, this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_checkOpenLinksInExternal, &QCheckBox::stateChanged, this, &SettingsBrowserMail::dirtifySettings);
#endif #endif
connect(m_ui->m_cmbProxyType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, connect(m_ui->m_cmbProxyType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&SettingsBrowserMail::dirtifySettings); &SettingsBrowserMail::dirtifySettings);
connect(m_ui->m_txtProxyHost, &QLineEdit::textChanged, 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) { if (state == Qt::Checked) {
m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::Normal); m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::Normal);
} }
else { else {
m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::PasswordEchoOnEdit); m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::PasswordEchoOnEdit);
} }
@ -137,12 +134,10 @@ void SettingsBrowserMail::selectEmailExecutable() {
void SettingsBrowserMail::loadSettings() { void SettingsBrowserMail::loadSettings() {
onBeginLoadSettings(); onBeginLoadSettings();
#if !defined(USE_WEBENGINE) #if !defined(USE_WEBENGINE)
m_ui->m_checkOpenLinksInExternal->setChecked(settings()->value(GROUP(Browser), m_ui->m_checkOpenLinksInExternal->setChecked(settings()->value(GROUP(Browser),
SETTING(Browser::OpenLinksInExternalBrowserRightAway)).toBool()); SETTING(Browser::OpenLinksInExternalBrowserRightAway)).toBool());
#endif #endif
// Load settings of web browser GUI. // Load settings of web browser GUI.
m_ui->m_cmbExternalBrowserPreset->addItem(tr("Opera 12 or older"), QSL("-nosession %1")); m_ui->m_cmbExternalBrowserPreset->addItem(tr("Opera 12 or older"), QSL("-nosession %1"));
m_ui->m_txtExternalBrowserExecutable->setText(settings()->value(GROUP(Browser), 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), m_ui->m_txtExternalBrowserArguments->setText(settings()->value(GROUP(Browser),
SETTING(Browser::CustomExternalBrowserArguments)).toString()); SETTING(Browser::CustomExternalBrowserArguments)).toString());
m_ui->m_grpCustomExternalBrowser->setChecked(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserEnabled)).toBool()); m_ui->m_grpCustomExternalBrowser->setChecked(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserEnabled)).toBool());
// Load settings of e-mail. // Load settings of e-mail.
m_ui->m_cmbExternalEmailPreset->addItem(tr("Mozilla Thunderbird"), QSL("-compose \"subject='%1',body='%2'\"")); 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()); 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("System proxy"), QNetworkProxy::DefaultProxy);
m_ui->m_cmbProxyType->addItem(tr("Socks5"), QNetworkProxy::Socks5Proxy); m_ui->m_cmbProxyType->addItem(tr("Socks5"), QNetworkProxy::Socks5Proxy);
m_ui->m_cmbProxyType->addItem(tr("Http"), QNetworkProxy::HttpProxy); m_ui->m_cmbProxyType->addItem(tr("Http"), QNetworkProxy::HttpProxy);
// Load the settings. // Load the settings.
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(settings()->value(GROUP(Proxy), QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(settings()->value(GROUP(Proxy),
SETTING(Proxy::Type)).toInt()); SETTING(Proxy::Type)).toInt());
@ -174,16 +167,13 @@ void SettingsBrowserMail::loadSettings() {
void SettingsBrowserMail::saveSettings() { void SettingsBrowserMail::saveSettings() {
onBeginSaveSettings(); onBeginSaveSettings();
#if !defined(USE_WEBENGINE) #if !defined(USE_WEBENGINE)
settings()->setValue(GROUP(Browser), Browser::OpenLinksInExternalBrowserRightAway, m_ui->m_checkOpenLinksInExternal->isChecked()); settings()->setValue(GROUP(Browser), Browser::OpenLinksInExternalBrowserRightAway, m_ui->m_checkOpenLinksInExternal->isChecked());
#endif #endif
// Save settings of GUI of web browser. // Save settings of GUI of web browser.
settings()->setValue(GROUP(Browser), Browser::CustomExternalBrowserEnabled, m_ui->m_grpCustomExternalBrowser->isChecked()); 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::CustomExternalBrowserExecutable, m_ui->m_txtExternalBrowserExecutable->text());
settings()->setValue(GROUP(Browser), Browser::CustomExternalBrowserArguments, m_ui->m_txtExternalBrowserArguments->text()); settings()->setValue(GROUP(Browser), Browser::CustomExternalBrowserArguments, m_ui->m_txtExternalBrowserArguments->text());
// Save settings of e-mail. // Save settings of e-mail.
settings()->setValue(GROUP(Browser), Browser::CustomExternalEmailExecutable, m_ui->m_txtExternalEmailExecutable->text()); settings()->setValue(GROUP(Browser), Browser::CustomExternalEmailExecutable, m_ui->m_txtExternalEmailExecutable->text());
settings()->setValue(GROUP(Browser), Browser::CustomExternalEmailArguments, m_ui->m_txtExternalEmailArguments->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::Username, m_ui->m_txtProxyUsername->text());
settings()->setValue(GROUP(Proxy), Proxy::Password, TextFactory::encrypt(m_ui->m_txtProxyPassword->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()); settings()->setValue(GROUP(Proxy), Proxy::Port, m_ui->m_spinProxyPort->value());
// Reload settings for all network access managers. // Reload settings for all network access managers.
SilentNetworkAccessManager::instance()->loadSettings(); SilentNetworkAccessManager::instance()->loadSettings();
onEndSaveSettings(); onEndSaveSettings();

View File

@ -84,7 +84,6 @@ void SettingsDatabase::onMysqlHostnameChanged(const QString& new_hostname) {
if (new_hostname.isEmpty()) { if (new_hostname.isEmpty()) {
m_ui->m_txtMysqlHostname->setStatus(LineEditWithStatus::Warning, tr("Hostname is empty.")); m_ui->m_txtMysqlHostname->setStatus(LineEditWithStatus::Warning, tr("Hostname is empty."));
} }
else { else {
m_ui->m_txtMysqlHostname->setStatus(LineEditWithStatus::Ok, tr("Hostname looks ok.")); 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()) { if (new_username.isEmpty()) {
m_ui->m_txtMysqlUsername->setStatus(LineEditWithStatus::Warning, tr("Username is empty.")); m_ui->m_txtMysqlUsername->setStatus(LineEditWithStatus::Warning, tr("Username is empty."));
} }
else { else {
m_ui->m_txtMysqlUsername->setStatus(LineEditWithStatus::Ok, tr("Username looks ok.")); 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()) { if (new_password.isEmpty()) {
m_ui->m_txtMysqlPassword->setStatus(LineEditWithStatus::Warning, tr("Password is empty.")); m_ui->m_txtMysqlPassword->setStatus(LineEditWithStatus::Warning, tr("Password is empty."));
} }
else { else {
m_ui->m_txtMysqlPassword->setStatus(LineEditWithStatus::Ok, tr("Password looks ok.")); 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()) { if (new_database.isEmpty()) {
m_ui->m_txtMysqlDatabase->setStatus(LineEditWithStatus::Warning, tr("Working database is empty.")); m_ui->m_txtMysqlDatabase->setStatus(LineEditWithStatus::Warning, tr("Working database is empty."));
} }
else { else {
m_ui->m_txtMysqlDatabase->setStatus(LineEditWithStatus::Ok, tr("Working database is ok.")); 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) { if (selected_db_driver == APP_DB_SQLITE_DRIVER) {
m_ui->m_stackedDatabaseDriver->setCurrentIndex(0); m_ui->m_stackedDatabaseDriver->setCurrentIndex(0);
} }
else if (selected_db_driver == APP_DB_MYSQL_DRIVER) { else if (selected_db_driver == APP_DB_MYSQL_DRIVER) {
m_ui->m_stackedDatabaseDriver->setCurrentIndex(1); m_ui->m_stackedDatabaseDriver->setCurrentIndex(1);
} }
else { else {
qWarning("GUI for given database driver '%s' is not available.", qPrintable(selected_db_driver)); qWarning("GUI for given database driver '%s' is not available.", qPrintable(selected_db_driver));
} }

View File

@ -71,7 +71,6 @@ void SettingsGeneral::saveSettings() {
if (m_ui->m_checkAutostart->isChecked()) { if (m_ui->m_checkAutostart->isChecked()) {
qApp->system()->setAutoStartStatus(SystemFactory::AutoStartStatus::Enabled); qApp->system()->setAutoStartStatus(SystemFactory::AutoStartStatus::Enabled);
} }
else { else {
qApp->system()->setAutoStartStatus(SystemFactory::AutoStartStatus::Disabled); qApp->system()->setAutoStartStatus(SystemFactory::AutoStartStatus::Disabled);
} }

View File

@ -98,7 +98,6 @@ void SettingsGui::loadSettings() {
if (SystemTrayIcon::isSystemTrayAvailable()) { if (SystemTrayIcon::isSystemTrayAvailable()) {
m_ui->m_grpTray->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::UseTrayIcon)).toBool()); m_ui->m_grpTray->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::UseTrayIcon)).toBool());
} }
// Tray icon is not supported on this machine. // Tray icon is not supported on this machine.
else { else {
m_ui->m_grpTray->setTitle(m_ui->m_grpTray->title() + QL1C(' ') + tr("(Tray icon is not available.)")); 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. //: Label for disabling icon theme.
m_ui->m_cmbIconTheme->addItem(tr("no icon theme/system icon theme"), APP_NO_THEME); m_ui->m_cmbIconTheme->addItem(tr("no icon theme/system icon theme"), APP_NO_THEME);
} }
else { else {
m_ui->m_cmbIconTheme->addItem(icon_theme_name, icon_theme_name); 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. // Because "no icon theme" lies at the index 0.
m_ui->m_cmbIconTheme->setCurrentIndex(0); m_ui->m_cmbIconTheme->setCurrentIndex(0);
} }
else { else {
m_ui->m_cmbIconTheme->setCurrentText(current_theme); m_ui->m_cmbIconTheme->setCurrentText(current_theme);
} }
@ -203,7 +200,6 @@ void SettingsGui::saveSettings() {
if (m_ui->m_grpTray->isChecked()) { if (m_ui->m_grpTray->isChecked()) {
qApp->showTrayIcon(); qApp->showTrayIcon();
} }
else { else {
qApp->deleteTrayIcon(); qApp->deleteTrayIcon();
} }

View File

@ -111,25 +111,21 @@ QList<QAction*> StatusBar::getSpecificActions(const QStringList& actions) {
action_to_add = m_barProgressDownloadAction; action_to_add = m_barProgressDownloadAction;
widget_to_add->setVisible(false); widget_to_add->setVisible(false);
} }
else if (matching_action == m_barProgressFeedsAction) { else if (matching_action == m_barProgressFeedsAction) {
widget_to_add = m_barProgressFeeds; widget_to_add = m_barProgressFeeds;
action_to_add = m_barProgressFeedsAction; action_to_add = m_barProgressFeedsAction;
widget_to_add->setVisible(progress_visible); widget_to_add->setVisible(progress_visible);
} }
else if (matching_action == m_lblProgressDownloadAction) { else if (matching_action == m_lblProgressDownloadAction) {
widget_to_add = m_lblProgressDownload; widget_to_add = m_lblProgressDownload;
action_to_add = m_lblProgressDownloadAction; action_to_add = m_lblProgressDownloadAction;
widget_to_add->setVisible(false); widget_to_add->setVisible(false);
} }
else if (matching_action == m_lblProgressFeedsAction) { else if (matching_action == m_lblProgressFeedsAction) {
widget_to_add = m_lblProgressFeeds; widget_to_add = m_lblProgressFeeds;
action_to_add = m_lblProgressFeedsAction; action_to_add = m_lblProgressFeedsAction;
widget_to_add->setVisible(progress_visible); widget_to_add->setVisible(progress_visible);
} }
else { else {
if (action_name == SEPARATOR_ACTION_NAME) { if (action_name == SEPARATOR_ACTION_NAME) {
QLabel* lbl = new QLabel(QString::fromUtf8("")); QLabel* lbl = new QLabel(QString::fromUtf8(""));
@ -138,7 +134,6 @@ QList<QAction*> StatusBar::getSpecificActions(const QStringList& actions) {
action_to_add->setSeparator(true); action_to_add->setSeparator(true);
action_to_add->setProperty("should_remove_action", true); action_to_add->setProperty("should_remove_action", true);
} }
else if (action_name == SPACER_ACTION_NAME) { else if (action_name == SPACER_ACTION_NAME) {
QLabel* lbl = new QLabel(QSL("\t\t")); QLabel* lbl = new QLabel(QSL("\t\t"));
widget_to_add = lbl; widget_to_add = lbl;
@ -148,7 +143,6 @@ QList<QAction*> StatusBar::getSpecificActions(const QStringList& actions) {
action_to_add->setProperty("type", SPACER_ACTION_NAME); action_to_add->setProperty("type", SPACER_ACTION_NAME);
action_to_add->setProperty("name", tr("Toolbar spacer")); action_to_add->setProperty("name", tr("Toolbar spacer"));
} }
else if (matching_action != nullptr) { else if (matching_action != nullptr) {
// Add originally toolbar action. // Add originally toolbar action.
PlainToolButton* tool_button = new PlainToolButton(this); PlainToolButton* tool_button = new PlainToolButton(this);
@ -158,7 +152,6 @@ QList<QAction*> StatusBar::getSpecificActions(const QStringList& actions) {
connect(tool_button, &PlainToolButton::clicked, matching_action, &QAction::trigger); connect(tool_button, &PlainToolButton::clicked, matching_action, &QAction::trigger);
connect(matching_action, &QAction::changed, tool_button, &PlainToolButton::reactOnSenderActionChange); connect(matching_action, &QAction::changed, tool_button, &PlainToolButton::reactOnSenderActionChange);
} }
else { else {
action_to_add = nullptr; action_to_add = nullptr;
widget_to_add = nullptr; widget_to_add = nullptr;

View File

@ -49,14 +49,12 @@ bool TrayIconMenu::event(QEvent* event) {
SystemTrayIcon::SystemTrayIcon(const QString& normal_icon, const QString& plain_icon, FormMain* parent) SystemTrayIcon::SystemTrayIcon(const QString& normal_icon, const QString& plain_icon, FormMain* parent)
: QSystemTrayIcon(parent), : QSystemTrayIcon(parent),
m_normalIcon(normal_icon), m_normalIcon(normal_icon),
m_plainPixmap(plain_icon) { m_plainPixmap(plain_icon) {
qDebug("Creating SystemTrayIcon instance."); qDebug("Creating SystemTrayIcon instance.");
m_font.setBold(true); m_font.setBold(true);
// Initialize icon. // Initialize icon.
setNumber(); setNumber();
setContextMenu(parent->trayMenu()); setContextMenu(parent->trayMenu());
// Create necessary connections. // Create necessary connections.
connect(this, &SystemTrayIcon::activated, this, &SystemTrayIcon::onActivated); connect(this, &SystemTrayIcon::activated, this, &SystemTrayIcon::onActivated);
} }
@ -96,11 +94,9 @@ void SystemTrayIcon::showPrivate() {
// the settings window) gets closed. Behavior for main window // the settings window) gets closed. Behavior for main window
// is handled explicitly by FormMain::closeEvent() method. // is handled explicitly by FormMain::closeEvent() method.
qApp->setQuitOnLastWindowClosed(false); qApp->setQuitOnLastWindowClosed(false);
// Display the tray icon. // Display the tray icon.
QSystemTrayIcon::show(); QSystemTrayIcon::show();
emit shown(); emit shown();
qDebug("Tray icon displayed."); 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))); setToolTip(tr("%1\nUnread news: %2").arg(QSL(APP_LONG_NAME), QString::number(number)));
QPixmap background(m_plainPixmap); QPixmap background(m_plainPixmap);
QPainter tray_painter; QPainter tray_painter;
// FIXME: Here draw different background instead of different color of number. // FIXME: Here draw different background instead of different color of number.
tray_painter.begin(&background); tray_painter.begin(&background);
tray_painter.setPen(any_new_message ? Qt::black : Qt::black); 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, void SystemTrayIcon::showMessage(const QString& title, const QString& message, QSystemTrayIcon::MessageIcon icon,
int milliseconds_timeout_hint, std::function<void()> functor) { int milliseconds_timeout_hint, std::function<void()> functor) {
if (m_connection) { if (m_connection) {
// Disconnect previous bubble click signalling. // Disconnect previous bubble click signalling.
disconnect(m_connection); disconnect(m_connection);
} }
if (functor) { if (functor) {
// Establish new connection for bubble click. // 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(...). // NOTE: If connections do not work, then use QMetaObject::invokeMethod(...).

View File

@ -57,7 +57,7 @@ class SystemTrayIcon : public QSystemTrayIcon {
void setNumber(int number = -1, bool any_new_message = false); void setNumber(int number = -1, bool any_new_message = false);
void showMessage(const QString& title, const QString& message, MessageIcon icon = Information, void showMessage(const QString& title, const QString& message, MessageIcon icon = Information,
int milliseconds_timeout_hint = TRAY_ICON_BUBBLE_TIMEOUT, std::function<void()> functor = nullptr); int milliseconds_timeout_hint = TRAY_ICON_BUBBLE_TIMEOUT, std::function<void()> functor = nullptr);
// Returns true if tray icon CAN be constructed on this machine. // Returns true if tray icon CAN be constructed on this machine.
static bool isSystemTrayAvailable(); static bool isSystemTrayAvailable();
@ -82,9 +82,9 @@ class SystemTrayIcon : public QSystemTrayIcon {
private: private:
QIcon m_normalIcon; QIcon m_normalIcon;
QPixmap m_plainPixmap; QPixmap m_plainPixmap;
QFont m_font = QFont(); QFont m_font = QFont();
QMetaObject::Connection m_connection; QMetaObject::Connection m_connection;
}; };
#endif // SYSTEMTRAYICON_H #endif // SYSTEMTRAYICON_H

View File

@ -93,7 +93,6 @@ void TabBar::wheelEvent(QWheelEvent* event) {
number_of_tabs - 1 : number_of_tabs - 1 :
current_index - 1); current_index - 1);
} }
else if (event->delta() < 0) { else if (event->delta() < 0) {
// Scroll to the RIGHT tab. // Scroll to the RIGHT tab.
setCurrentIndex(current_index == number_of_tabs - 1 ? setCurrentIndex(current_index == number_of_tabs - 1 ?
@ -137,7 +136,6 @@ void TabBar::mouseDoubleClickEvent(QMouseEvent* event) {
} }
} }
} }
else { else {
emit emptySpaceDoubleClicked(); emit emptySpaceDoubleClicked();
} }

View File

@ -103,7 +103,6 @@ void TabWidget::checkTabBarVisibility() {
setCornerWidget(m_btnMainMenu, Qt::TopLeftCorner); setCornerWidget(m_btnMainMenu, Qt::TopLeftCorner);
m_btnMainMenu->setVisible(true); m_btnMainMenu->setVisible(true);
} }
else { else {
setCornerWidget(0, Qt::TopLeftCorner); setCornerWidget(0, Qt::TopLeftCorner);
setCornerWidget(0, Qt::TopRightCorner); setCornerWidget(0, Qt::TopRightCorner);
@ -166,12 +165,10 @@ bool TabWidget::closeTab(int index) {
removeTab(index, true); removeTab(index, true);
return true; return true;
} }
else if (tabBar()->tabType(index) == TabBar::DownloadManager) { else if (tabBar()->tabType(index) == TabBar::DownloadManager) {
removeTab(index, false); removeTab(index, false);
return true; return true;
} }
else { else {
return false; 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")), final_index = insertTab(currentIndex() + 1, browser, qApp->icons()->fromTheme(QSL("text-html")),
browser_tab_name, TabBar::Closable); browser_tab_name, TabBar::Closable);
} }
else { else {
// Add new browser as the last tab. // Add new browser as the last tab.
final_index = addTab(browser, qApp->icons()->fromTheme(QSL("text-html")), final_index = addTab(browser, qApp->icons()->fromTheme(QSL("text-html")),

View File

@ -37,7 +37,6 @@ double TimeSpinBox::valueFromText(const QString& text) const {
if (ok) { if (ok) {
return value; return value;
} }
else { else {
QRegExp rx("\\b[0-9]{1,}\\b"); QRegExp rx("\\b[0-9]{1,}\\b");
QStringList numbers; QStringList numbers;
@ -56,7 +55,6 @@ double TimeSpinBox::valueFromText(const QString& text) const {
if (numbers.size() == 2) { if (numbers.size() == 2) {
return (numbers.at(0).toDouble() * 60.0) + numbers.at(1).toDouble(); return (numbers.at(0).toDouble() * 60.0) + numbers.at(1).toDouble();
} }
else { else {
return -1.0; return -1.0;
} }

View File

@ -90,13 +90,11 @@ void ToolBarEditor::loadEditor(const QList<QAction*> activated_actions, const QL
action_item->setText(tr("Separator")); action_item->setText(tr("Separator"));
action_item->setToolTip(tr("Separator")); action_item->setToolTip(tr("Separator"));
} }
else if (action->property("type").isValid()) { else if (action->property("type").isValid()) {
action_item->setData(Qt::UserRole, action->property("type").toString()); action_item->setData(Qt::UserRole, action->property("type").toString());
action_item->setText(action->property("name").toString()); action_item->setText(action->property("name").toString());
action_item->setToolTip(action_item->text()); action_item->setToolTip(action_item->text());
} }
else { else {
action_item->setData(Qt::UserRole, action->objectName()); action_item->setData(Qt::UserRole, action->objectName());
action_item->setToolTip(action->toolTip()); action_item->setToolTip(action->toolTip());
@ -113,13 +111,11 @@ void ToolBarEditor::loadEditor(const QList<QAction*> activated_actions, const QL
action_item->setToolTip(tr("Separator")); action_item->setToolTip(tr("Separator"));
action_item->setIcon(qApp->icons()->fromTheme(QSL("insert-object"))); action_item->setIcon(qApp->icons()->fromTheme(QSL("insert-object")));
} }
else if (action->property("type").isValid()) { else if (action->property("type").isValid()) {
action_item->setData(Qt::UserRole, action->property("type").toString()); action_item->setData(Qt::UserRole, action->property("type").toString());
action_item->setText(action->property("name").toString()); action_item->setText(action->property("name").toString());
action_item->setToolTip(action_item->text()); action_item->setToolTip(action_item->text());
} }
else { else {
action_item->setData(Qt::UserRole, action->objectName()); action_item->setData(Qt::UserRole, action->objectName());
action_item->setToolTip(action->toolTip()); action_item->setToolTip(action->toolTip());
@ -141,12 +137,10 @@ bool ToolBarEditor::eventFilter(QObject* object, QEvent* event) {
deleteSelectedAction(); deleteSelectedAction();
return true; return true;
} }
else if (key_event->key() == Qt::Key_Down && key_event->modifiers() & Qt::ControlModifier) { else if (key_event->key() == Qt::Key_Down && key_event->modifiers() & Qt::ControlModifier) {
moveActionDown(); moveActionDown();
return true; return true;
} }
else if (key_event->key() == Qt::Key_Up && key_event->modifiers() & Qt::ControlModifier) { else if (key_event->key() == Qt::Key_Up && key_event->modifiers() & Qt::ControlModifier) {
moveActionUp(); moveActionUp();
return true; return true;
@ -238,7 +232,6 @@ void ToolBarEditor::deleteSelectedAction() {
m_ui->m_listActivatedActions->takeItem(m_ui->m_listActivatedActions->row(selected_item)); m_ui->m_listActivatedActions->takeItem(m_ui->m_listActivatedActions->row(selected_item));
updateActionsAvailability(); updateActionsAvailability();
} }
else { else {
m_ui->m_listAvailableActions->insertItem( m_ui->m_listAvailableActions->insertItem(
m_ui->m_listAvailableActions->currentRow() + 1, m_ui->m_listAvailableActions->currentRow() + 1,

View File

@ -108,7 +108,6 @@ void TreeWidget::filterString(const QString& string) {
} }
} }
} }
else { else {
item->setHidden(true); item->setHidden(true);
@ -125,7 +124,6 @@ void TreeWidget::filterString(const QString& string) {
if (stringIsEmpty) { if (stringIsEmpty) {
parentItem->setExpanded(m_showMode == ItemsExpanded); parentItem->setExpanded(m_showMode == ItemsExpanded);
} }
else { else {
parentItem->setExpanded(true); parentItem->setExpanded(true);
} }

View File

@ -158,7 +158,6 @@ void WebBrowser::onTitleChanged(const QString& new_title) {
//: Webbrowser tab title when no title is available. //: Webbrowser tab title when no title is available.
emit titleChanged(m_index, tr("No title")); emit titleChanged(m_index, tr("No title"));
} }
else { else {
emit titleChanged(m_index, new_title); 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)); this->m_btnDiscoverFeeds->setFeedAddresses(NetworkFactory::extractFeedLinksFromHtmlPage(m_webView->url(), result));
}); });
} }
else { else {
m_btnDiscoverFeeds->clearFeedAddresses(); m_btnDiscoverFeeds->clearFeedAddresses();
} }

View File

@ -58,7 +58,6 @@ bool WebViewer::increaseWebPageZoom() {
setZoomFactor(zoomFactor() + ZOOM_FACTOR_STEP); setZoomFactor(zoomFactor() + ZOOM_FACTOR_STEP);
return true; return true;
} }
else { else {
return false; return false;
} }
@ -69,7 +68,6 @@ bool WebViewer::decreaseWebPageZoom() {
setZoomFactor(zoomFactor() - ZOOM_FACTOR_STEP); setZoomFactor(zoomFactor() - ZOOM_FACTOR_STEP);
return true; return true;
} }
else { else {
return false; return false;
} }
@ -82,7 +80,6 @@ bool WebViewer::resetWebPageZoom() {
setZoomFactor(new_factor); setZoomFactor(new_factor);
return true; return true;
} }
else { else {
return false; return false;
} }
@ -145,11 +142,9 @@ void WebViewer::clear() {
void WebViewer::contextMenuEvent(QContextMenuEvent* event) { void WebViewer::contextMenuEvent(QContextMenuEvent* event) {
event->accept(); event->accept();
QMenu* menu = page()->createStandardContextMenu(); QMenu* menu = page()->createStandardContextMenu();
menu->addAction(AdBlockManager::instance()->adBlockIcon()); menu->addAction(AdBlockManager::instance()->adBlockIcon());
menu->addAction(qApp->web()->engineSettingsAction()); menu->addAction(qApp->web()->engineSettingsAction());
const QPoint pos = event->globalPos(); const QPoint pos = event->globalPos();
QPoint p(pos.x(), pos.y() + 1); QPoint p(pos.x(), pos.y() + 1);
menu->popup(p); menu->popup(p);
@ -162,7 +157,6 @@ QWebEngineView* WebViewer::createWindow(QWebEnginePage::WebWindowType type) {
if (index >= 0) { if (index >= 0) {
return qApp->mainForm()->tabWidget()->widget(index)->webBrowser()->viewer(); return qApp->mainForm()->tabWidget()->widget(index)->webBrowser()->viewer();
} }
else { else {
return nullptr; return nullptr;
} }
@ -175,7 +169,6 @@ void WebViewer::wheelEvent(QWheelEvent* event) {
if (event->delta() > 0) { if (event->delta() > 0) {
increaseWebPageZoom(); increaseWebPageZoom();
} }
else if (event->delta() < 0) { else if (event->delta() < 0) {
decreaseWebPageZoom(); decreaseWebPageZoom();
} }

View File

@ -59,17 +59,13 @@ int main(int argc, char* argv[]) {
//: Use ISO 639-1 code here combined with ISO 3166-1 (alpha-2) code. //: Use ISO 639-1 code here combined with ISO 3166-1 (alpha-2) code.
//: Examples: "cs", "en", "it", "cs_CZ", "en_GB", "en_US". //: Examples: "cs", "en", "it", "cs_CZ", "en_GB", "en_US".
QObject::tr("LANG_ABBREV"); QObject::tr("LANG_ABBREV");
//: Name of translator - optional. //: Name of translator - optional.
QObject::tr("LANG_AUTHOR"); QObject::tr("LANG_AUTHOR");
// Ensure that ini format is used as application settings storage on Mac OS. // Ensure that ini format is used as application settings storage on Mac OS.
QSettings::setDefaultFormat(QSettings::IniFormat); QSettings::setDefaultFormat(QSettings::IniFormat);
// Setup debug output system. // Setup debug output system.
qInstallMessageHandler(Debugging::debugHandler); qInstallMessageHandler(Debugging::debugHandler);
// Instantiate base application object. // Instantiate base application object.
Application application(APP_LOW_NAME, argc, argv); Application application(APP_LOW_NAME, argc, argv);
qDebug("Instantiated Application class."); qDebug("Instantiated Application class.");
@ -88,36 +84,28 @@ int main(int argc, char* argv[]) {
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus); QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
disableWindowTabbing(); disableWindowTabbing();
#endif #endif
// Register needed metatypes. // Register needed metatypes.
qRegisterMetaType<QList<Message>>("QList<Message>"); qRegisterMetaType<QList<Message>>("QList<Message>");
qRegisterMetaType<QList<RootItem*>>("QList<RootItem*>"); qRegisterMetaType<QList<RootItem*>>("QList<RootItem*>");
// Add an extra path for non-system icon themes and set current icon theme // Add an extra path for non-system icon themes and set current icon theme
// and skin. // and skin.
qApp->icons()->setupSearchPaths(); qApp->icons()->setupSearchPaths();
qApp->icons()->loadCurrentIconTheme(); qApp->icons()->loadCurrentIconTheme();
qApp->skins()->loadCurrentSkin(); qApp->skins()->loadCurrentSkin();
// These settings needs to be set before any QSettings object. // These settings needs to be set before any QSettings object.
Application::setApplicationName(APP_NAME); Application::setApplicationName(APP_NAME);
Application::setApplicationVersion(APP_VERSION); Application::setApplicationVersion(APP_VERSION);
Application::setOrganizationDomain(APP_URL); Application::setOrganizationDomain(APP_URL);
Application::setWindowIcon(QIcon(APP_ICON_PATH)); Application::setWindowIcon(QIcon(APP_ICON_PATH));
// Load activated accounts. // Load activated accounts.
qApp->feedReader()->feedsModel()->loadActivatedServiceAccounts(); qApp->feedReader()->feedsModel()->loadActivatedServiceAccounts();
// Setup single-instance behavior. // Setup single-instance behavior.
QObject::connect(&application, &Application::messageReceived, &application, &Application::processExecutionMessage); QObject::connect(&application, &Application::messageReceived, &application, &Application::processExecutionMessage);
qDebug().nospace() << "Creating main application form in thread: \'" << QThread::currentThreadId() << "\'."; qDebug().nospace() << "Creating main application form in thread: \'" << QThread::currentThreadId() << "\'.";
// Instantiate main application window. // Instantiate main application window.
FormMain main_window; FormMain main_window;
// Set correct information for main window. // Set correct information for main window.
main_window.setWindowTitle(APP_LONG_NAME); main_window.setWindowTitle(APP_LONG_NAME);
// Now is a good time to initialize dynamic keyboard shortcuts. // Now is a good time to initialize dynamic keyboard shortcuts.
DynamicShortcuts::load(qApp->userActions()); DynamicShortcuts::load(qApp->userActions());
@ -126,7 +114,6 @@ int main(int argc, char* argv[]) {
qDebug("Hiding the main window when the application is starting."); qDebug("Hiding the main window when the application is starting.");
main_window.switchVisibility(true); main_window.switchVisibility(true);
} }
else { else {
qDebug("Showing the main window when the application is starting."); qDebug("Showing the main window when the application is starting.");
main_window.show(); main_window.show();
@ -139,12 +126,11 @@ int main(int argc, char* argv[]) {
if (qApp->isFirstRun() || qApp->isFirstRun(APP_VERSION)) { 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" 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), "version by clicking this popup notification.").arg(APP_LONG_NAME),
QSystemTrayIcon::NoIcon, 0, false, [] { QSystemTrayIcon::NoIcon, 0, false, [] {
FormAbout(qApp->mainForm()).exec(); FormAbout(qApp->mainForm()).exec();
}); });
} }
else { else {
qApp->showGuiMessage(QSL(APP_NAME), QObject::tr("Welcome to %1.").arg(APP_NAME), QSystemTrayIcon::NoIcon); 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)) { !SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, APP_VERSION)) {
qApp->showGuiMessage(QObject::tr("New version available"), qApp->showGuiMessage(QObject::tr("New version available"),
QObject::tr("Click the bubble for more information."), QObject::tr("Click the bubble for more information."),
QSystemTrayIcon::Information, qApp->mainForm(), false, QSystemTrayIcon::Information, qApp->mainForm(), false,
[] { [] {
FormUpdate(qApp->mainForm()).exec(); FormUpdate(qApp->mainForm()).exec();
}); });
} }
}); });
qApp->system()->checkForUpdates(); qApp->system()->checkForUpdates();
} }
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->loadAllExpandStates(); qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->loadAllExpandStates();
// Enter global event loop. // Enter global event loop.
return Application::exec(); return Application::exec();
} }

View File

@ -65,15 +65,12 @@ Application::Application(const QString& id, int& argc, char** argv)
connect(this, &Application::aboutToQuit, this, &Application::onAboutToQuit); connect(this, &Application::aboutToQuit, this, &Application::onAboutToQuit);
connect(this, &Application::commitDataRequest, this, &Application::onCommitData); connect(this, &Application::commitDataRequest, this, &Application::onCommitData);
connect(this, &Application::saveStateRequest, this, &Application::onSaveState); connect(this, &Application::saveStateRequest, this, &Application::onSaveState);
#if defined(USE_WEBENGINE) #if defined(USE_WEBENGINE)
connect(QWebEngineProfile::defaultProfile(), &QWebEngineProfile::downloadRequested, this, &Application::downloadRequested); connect(QWebEngineProfile::defaultProfile(), &QWebEngineProfile::downloadRequested, this, &Application::downloadRequested);
QWebEngineProfile::defaultProfile()->setRequestInterceptor(m_urlInterceptor); QWebEngineProfile::defaultProfile()->setRequestInterceptor(m_urlInterceptor);
// TODO: Call load settings when saving app settings from dialog. // TODO: Call load settings when saving app settings from dialog.
// Will need add that if I add more settings in the future. // Will need add that if I add more settings in the future.
m_urlInterceptor->loadSettings(); m_urlInterceptor->loadSettings();
QWebEngineProfile::defaultProfile()->installUrlSchemeHandler( QWebEngineProfile::defaultProfile()->installUrlSchemeHandler(
QByteArray(APP_LOW_NAME), QByteArray(APP_LOW_NAME),
new RssGuardSchemeHandler(QWebEngineProfile::defaultProfile())); new RssGuardSchemeHandler(QWebEngineProfile::defaultProfile()));
@ -91,7 +88,6 @@ FeedReader* Application::feedReader() {
QList<QAction*> Application::userActions() { QList<QAction*> Application::userActions() {
if (m_mainForm != nullptr && m_userActions.isEmpty()) { if (m_mainForm != nullptr && m_userActions.isEmpty()) {
m_userActions = m_mainForm->allActions(); m_userActions = m_mainForm->allActions();
#if defined(USE_WEBENGINE) #if defined(USE_WEBENGINE)
m_userActions.append(AdBlockManager::instance()->adBlockIcon()); m_userActions.append(AdBlockManager::instance()->adBlockIcon());
#endif #endif
@ -109,7 +105,6 @@ bool Application::isFirstRun(const QString& version) {
// Check this only if checked version is equal to actual version. // Check this only if checked version is equal to actual version.
return settings()->value(GROUP(General), QString(General::FirstRun) + QL1C('_') + version, true).toBool(); return settings()->value(GROUP(General), QString(General::FirstRun) + QL1C('_') + version, true).toBool();
} }
else { else {
return false; return false;
} }
@ -228,7 +223,6 @@ QString Application::userDataPath() {
if (settings()->type() == SettingsProperties::Portable) { if (settings()->type() == SettingsProperties::Portable) {
return getUserDataAppPath(); return getUserDataAppPath();
} }
else { else {
return getUserDataHomePath(); return getUserDataHomePath();
} }
@ -241,7 +235,6 @@ QString Application::getUserDataHomePath() {
if (QDir().exists(home_folder)) { if (QDir().exists(home_folder)) {
return home_folder; return home_folder;
} }
else { else {
return getConfigHomePath() + QDir::separator() + QSL(APP_NAME); return getConfigHomePath() + QDir::separator() + QSL(APP_NAME);
} }
@ -307,14 +300,12 @@ void Application::processExecutionMessage(const QString& message) {
if (messages.contains(APP_QUIT_INSTANCE)) { if (messages.contains(APP_QUIT_INSTANCE)) {
quit(); quit();
} }
else { else {
foreach (const QString& msg, messages) { foreach (const QString& msg, messages) {
if (msg == APP_IS_RUNNING) { if (msg == APP_IS_RUNNING) {
showGuiMessage(APP_NAME, tr("Application is already running."), QSystemTrayIcon::Information); showGuiMessage(APP_NAME, tr("Application is already running."), QSystemTrayIcon::Information);
mainForm()->display(); mainForm()->display();
} }
else if (msg.startsWith(QL1S(URI_SCHEME_FEED_SHORT))) { else if (msg.startsWith(QL1S(URI_SCHEME_FEED_SHORT))) {
// Application was running, and someone wants to add new feed. // Application was running, and someone wants to add new feed.
StandardServiceRoot* root = qApp->feedReader()->feedsModel()->standardServiceRoot(); StandardServiceRoot* root = qApp->feedReader()->feedsModel()->standardServiceRoot();
@ -322,7 +313,6 @@ void Application::processExecutionMessage(const QString& message) {
if (root != nullptr) { if (root != nullptr) {
root->checkArgumentForFeedAdding(msg); root->checkArgumentForFeedAdding(msg);
} }
else { else {
showGuiMessage(tr("Cannot add feed"), showGuiMessage(tr("Cannot add feed"),
tr("Feed cannot be added because standard RSS/ATOM account is not enabled."), tr("Feed cannot be added because standard RSS/ATOM account is not enabled."),

View File

@ -118,7 +118,7 @@ class Application : public QtSingleApplication {
// or in message box if tray icon is disabled. // or in message box if tray icon is disabled.
void showGuiMessage(const QString& title, const QString& message, QSystemTrayIcon::MessageIcon message_type, void showGuiMessage(const QString& title, const QString& message, QSystemTrayIcon::MessageIcon message_type,
QWidget* parent = nullptr, bool show_at_least_msgbox = false, QWidget* parent = nullptr, bool show_at_least_msgbox = false,
std::function<void()> functor = nullptr); std::function<void()> functor = nullptr);
// Returns pointer to "GOD" application singleton. // Returns pointer to "GOD" application singleton.
inline static Application* instance() { inline static Application* instance() {

View File

@ -47,7 +47,6 @@ void AutoSaver::changeOccurred() {
if (m_firstChange.elapsed() > MAXWAIT) { if (m_firstChange.elapsed() > MAXWAIT) {
saveIfNeccessary(); saveIfNeccessary();
} }
else { else {
m_timer.start(AUTOSAVE_IN, this); m_timer.start(AUTOSAVE_IN, this);
} }
@ -57,7 +56,6 @@ void AutoSaver::timerEvent(QTimerEvent* event) {
if (event->timerId() == m_timer.timerId()) { if (event->timerId() == m_timer.timerId()) {
saveIfNeccessary(); saveIfNeccessary();
} }
else { else {
QObject::timerEvent(event); QObject::timerEvent(event);
} }

View File

@ -44,7 +44,6 @@ qint64 DatabaseFactory::getDatabaseFileSize() const {
if (m_activeDatabaseDriver == SQLITE || m_activeDatabaseDriver == SQLITE_MEMORY) { if (m_activeDatabaseDriver == SQLITE || m_activeDatabaseDriver == SQLITE_MEMORY) {
return QFileInfo(sqliteDatabaseFilePath()).size(); return QFileInfo(sqliteDatabaseFilePath()).size();
} }
else { else {
return 0; return 0;
} }
@ -60,7 +59,6 @@ qint64 DatabaseFactory::getDatabaseDataSize() const {
query.next(); query.next();
result *= query.value(0).value<qint64>(); result *= query.value(0).value<qint64>();
} }
else { else {
return 0; return 0;
} }
@ -69,14 +67,12 @@ qint64 DatabaseFactory::getDatabaseDataSize() const {
query.next(); query.next();
result *= query.value(0).value<qint64>(); result *= query.value(0).value<qint64>();
} }
else { else {
return 0; return 0;
} }
return result; return result;
} }
else if (m_activeDatabaseDriver == MYSQL) { else if (m_activeDatabaseDriver == MYSQL) {
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
qint64 result = 1; qint64 result = 1;
@ -91,12 +87,10 @@ qint64 DatabaseFactory::getDatabaseDataSize() const {
return result; return result;
} }
else { else {
return 0; return 0;
} }
} }
else { else {
return 0; return 0;
} }
@ -120,18 +114,15 @@ DatabaseFactory::MySQLError DatabaseFactory::mysqlTestConnection(const QString&
database.close(); database.close();
return MySQLOk; return MySQLOk;
} }
else { else {
database.close(); database.close();
return MySQLUnknownError; return MySQLUnknownError;
} }
} }
else if (database.lastError().isValid()) { else if (database.lastError().isValid()) {
// Connection failed, do cleanup and return specific error code. // Connection failed, do cleanup and return specific error code.
return static_cast<MySQLError>(database.lastError().number()); return static_cast<MySQLError>(database.lastError().number());
} }
else { else {
return MySQLUnknownError; return MySQLUnknownError;
} }
@ -187,7 +178,6 @@ void DatabaseFactory::finishRestoration() {
QFile::remove(backup_database_file); QFile::remove(backup_database_file);
qDebug("Database file was restored successully."); qDebug("Database file was restored successully.");
} }
else { else {
qCritical("Database file was NOT restored due to error when copying the file."); qCritical("Database file was NOT restored due to error when copying the file.");
} }
@ -205,7 +195,6 @@ QSqlDatabase DatabaseFactory::sqliteInitializeInMemoryDatabase() {
if (!database.open()) { if (!database.open()) {
qFatal("In-memory SQLite database was NOT opened. Delivered error message: '%s'", qPrintable(database.lastError().text())); qFatal("In-memory SQLite database was NOT opened. Delivered error message: '%s'", qPrintable(database.lastError().text()));
} }
else { else {
QSqlQuery query_db(database); QSqlQuery query_db(database);
query_db.setForwardOnly(true); query_db.setForwardOnly(true);
@ -244,7 +233,6 @@ QSqlDatabase DatabaseFactory::sqliteInitializeInMemoryDatabase() {
database.commit(); database.commit();
qDebug("In-memory SQLite database backend should be ready now."); qDebug("In-memory SQLite database backend should be ready now.");
} }
else { else {
query_db.next(); query_db.next();
qDebug("In-memory SQLite database connection seems to be established."); qDebug("In-memory SQLite database connection seems to be established.");
@ -264,7 +252,6 @@ QSqlDatabase DatabaseFactory::sqliteInitializeInMemoryDatabase() {
tables.append(copy_contents.value(0).toString()); tables.append(copy_contents.value(0).toString());
} }
} }
else { else {
qFatal("Cannot obtain list of table names from file-base SQLite database."); 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'", qFatal("File-based SQLite database was NOT opened. Delivered error message: '%s'",
qPrintable(database.lastError().text())); qPrintable(database.lastError().text()));
} }
else { else {
QSqlQuery query_db(database); QSqlQuery query_db(database);
query_db.setForwardOnly(true); query_db.setForwardOnly(true);
@ -351,7 +337,6 @@ QSqlDatabase DatabaseFactory::sqliteInitializeFileBasedDatabase(const QString& c
query_db.finish(); query_db.finish();
qDebug("File-based SQLite database backend should be ready now."); qDebug("File-based SQLite database backend should be ready now.");
} }
else { else {
query_db.next(); query_db.next();
const QString installed_db_schema = query_db.value(0).toString(); const QString installed_db_schema = query_db.value(0).toString();
@ -363,7 +348,6 @@ QSqlDatabase DatabaseFactory::sqliteInitializeFileBasedDatabase(const QString& c
qPrintable(installed_db_schema), qPrintable(installed_db_schema),
APP_DB_SCHEMA_VERSION); APP_DB_SCHEMA_VERSION);
} }
else { else {
qFatal("Database schema was not updated from '%s' to '%s' successully.", qFatal("Database schema was not updated from '%s' to '%s' successully.",
qPrintable(installed_db_schema), qPrintable(installed_db_schema),
@ -395,7 +379,6 @@ bool DatabaseFactory::sqliteUpdateDatabaseSchema(QSqlDatabase database, const QS
if (IOFactory::copyFile(sqliteDatabaseFilePath(), sqliteDatabaseFilePath() + ".bak")) { if (IOFactory::copyFile(sqliteDatabaseFilePath(), sqliteDatabaseFilePath() + ".bak")) {
qDebug("Creating backup of SQLite DB file."); qDebug("Creating backup of SQLite DB file.");
} }
else { else {
qFatal("Creation of backup SQLite DB file failed."); 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) { if (driver_code == APP_DB_SQLITE_DRIVER) {
return humanDriverName(SQLITE); return humanDriverName(SQLITE);
} }
else if (driver_code == APP_DB_MYSQL_DRIVER) { else if (driver_code == APP_DB_MYSQL_DRIVER) {
return humanDriverName(MYSQL); return humanDriverName(MYSQL);
} }
else { else {
return humanDriverName(SQLITE); return humanDriverName(SQLITE);
} }
@ -519,7 +500,6 @@ QString DatabaseFactory::obtainBeginTransactionSql() const {
if (m_activeDatabaseDriver == DatabaseFactory::SQLITE || m_activeDatabaseDriver == DatabaseFactory::SQLITE_MEMORY) { if (m_activeDatabaseDriver == DatabaseFactory::SQLITE || m_activeDatabaseDriver == DatabaseFactory::SQLITE_MEMORY) {
return QSL("BEGIN IMMEDIATE TRANSACTION;"); return QSL("BEGIN IMMEDIATE TRANSACTION;");
} }
else { else {
return QSL("START TRANSACTION;"); return QSL("START TRANSACTION;");
} }
@ -540,7 +520,6 @@ void DatabaseFactory::sqliteSaveMemoryDatabase() {
tables.append(copy_contents.value(0).toString()); tables.append(copy_contents.value(0).toString());
} }
} }
else { else {
qFatal("Cannot obtain list of table names from file-base SQLite database."); qFatal("Cannot obtain list of table names from file-base SQLite database.");
} }
@ -563,7 +542,6 @@ void DatabaseFactory::determineDriver() {
m_activeDatabaseDriver = MYSQL; m_activeDatabaseDriver = MYSQL;
qDebug("Working database source was as MySQL database."); qDebug("Working database source was as MySQL database.");
} }
else { else {
// User wants to use SQLite, which is always available. Check if file-based // User wants to use SQLite, which is always available. Check if file-based
// or in-memory database will be used. // or in-memory database will be used.
@ -572,7 +550,6 @@ void DatabaseFactory::determineDriver() {
m_activeDatabaseDriver = SQLITE_MEMORY; m_activeDatabaseDriver = SQLITE_MEMORY;
qDebug("Working database source was determined as SQLite in-memory database."); qDebug("Working database source was determined as SQLite in-memory database.");
} }
else { else {
// Use strictly file-base SQLite database. // Use strictly file-base SQLite database.
m_activeDatabaseDriver = SQLITE; m_activeDatabaseDriver = SQLITE;
@ -592,7 +569,6 @@ QSqlDatabase DatabaseFactory::mysqlConnection(const QString& connection_name) {
// Return initialized database. // Return initialized database.
return mysqlInitializeDatabase(connection_name); return mysqlInitializeDatabase(connection_name);
} }
else { else {
QSqlDatabase database; QSqlDatabase database;
@ -602,7 +578,6 @@ QSqlDatabase DatabaseFactory::mysqlConnection(const QString& connection_name) {
// setup its properties. // setup its properties.
database = QSqlDatabase::database(connection_name); database = QSqlDatabase::database(connection_name);
} }
else { else {
// Database connection with this name does not exist // Database connection with this name does not exist
// yet, add it and set it up. // 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'.", qFatal("MySQL database was NOT opened. Delivered error message: '%s'.",
qPrintable(database.lastError().text())); qPrintable(database.lastError().text()));
} }
else { else {
qDebug("MySQL database connection '%s' to file '%s' seems to be established.", qDebug("MySQL database connection '%s' to file '%s' seems to be established.",
qPrintable(connection_name), qPrintable(connection_name),
@ -649,7 +623,6 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString& connection_
"and make adjustments in application settings.").arg(APP_NAME)); "and make adjustments in application settings.").arg(APP_NAME));
return connection(objectName(), FromSettings); return connection(objectName(), FromSettings);
} }
else { else {
QSqlQuery query_db(database); QSqlQuery query_db(database);
query_db.setForwardOnly(true); query_db.setForwardOnly(true);
@ -683,7 +656,6 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString& connection_
database.commit(); database.commit();
qDebug("MySQL database backend should be ready now."); qDebug("MySQL database backend should be ready now.");
} }
else { else {
// Database was previously initialized. Now just check the schema version. // Database was previously initialized. Now just check the schema version.
query_db.next(); query_db.next();
@ -695,7 +667,6 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString& connection_
qPrintable(installed_db_schema), qPrintable(installed_db_schema),
APP_DB_SCHEMA_VERSION); APP_DB_SCHEMA_VERSION);
} }
else { else {
qFatal("Database schema was not updated from '%s' to '%s' successully.", qFatal("Database schema was not updated from '%s' to '%s' successully.",
qPrintable(installed_db_schema), qPrintable(installed_db_schema),
@ -727,7 +698,6 @@ QSqlDatabase DatabaseFactory::sqliteConnection(const QString& connection_name, D
// It is not initialized yet. // It is not initialized yet.
return sqliteInitializeInMemoryDatabase(); return sqliteInitializeInMemoryDatabase();
} }
else { else {
QSqlDatabase database = QSqlDatabase::database(); QSqlDatabase database = QSqlDatabase::database();
database.setDatabaseName(QSL(":memory:")); 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'.", qFatal("In-memory SQLite database was NOT opened. Delivered error message: '%s'.",
qPrintable(database.lastError().text())); qPrintable(database.lastError().text()));
} }
else { else {
qDebug("In-memory SQLite database connection seems to be established."); qDebug("In-memory SQLite database connection seems to be established.");
} }
@ -744,14 +713,12 @@ QSqlDatabase DatabaseFactory::sqliteConnection(const QString& connection_name, D
return database; return database;
} }
} }
else { else {
// We request file-based database. // We request file-based database.
if (!m_sqliteFileBasedDatabaseinitialized) { if (!m_sqliteFileBasedDatabaseinitialized) {
// File-based database is not yet initialised. // File-based database is not yet initialised.
return sqliteInitializeFileBasedDatabase(connection_name); return sqliteInitializeFileBasedDatabase(connection_name);
} }
else { else {
QSqlDatabase database; QSqlDatabase database;
@ -761,7 +728,6 @@ QSqlDatabase DatabaseFactory::sqliteConnection(const QString& connection_name, D
// setup its properties. // setup its properties.
database = QSqlDatabase::database(connection_name); database = QSqlDatabase::database(connection_name);
} }
else { else {
// Database connection with this name does not exist // Database connection with this name does not exist
// yet, add it and set it up. // 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'.", qFatal("File-based SQLite database was NOT opened. Delivered error message: '%s'.",
qPrintable(database.lastError().text())); qPrintable(database.lastError().text()));
} }
else { else {
qDebug("File-based SQLite database connection '%s' to file '%s' seems to be established.", qDebug("File-based SQLite database connection '%s' to file '%s' seems to be established.",
qPrintable(connection_name), qPrintable(connection_name),
@ -794,12 +759,10 @@ bool DatabaseFactory::sqliteVacuumDatabase() {
if (m_activeDatabaseDriver == SQLITE) { if (m_activeDatabaseDriver == SQLITE) {
database = sqliteConnection(objectName(), StrictlyFileBased); database = sqliteConnection(objectName(), StrictlyFileBased);
} }
else if (m_activeDatabaseDriver == SQLITE_MEMORY) { else if (m_activeDatabaseDriver == SQLITE_MEMORY) {
sqliteSaveMemoryDatabase(); sqliteSaveMemoryDatabase();
database = sqliteConnection(objectName(), StrictlyFileBased); database = sqliteConnection(objectName(), StrictlyFileBased);
} }
else { else {
return false; return false;
} }

View File

@ -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 " "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;"); "GROUP BY feed;");
} }
else { else {
q.prepare("SELECT feed, sum((is_read + 1) % 2) FROM Messages " 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 " "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(); int total_count = q.value(2).toInt();
counts.insert(feed_id, QPair<int, int>(unread_count, total_count)); counts.insert(feed_id, QPair<int, int>(unread_count, total_count));
} }
else { else {
counts.insert(feed_id, QPair<int, int>(unread_count, 0)); counts.insert(feed_id, QPair<int, int>(unread_count, 0));
} }
@ -198,7 +196,6 @@ bool including_total_counts, bool* ok) {
*ok = true; *ok = true;
} }
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = false; *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 " "WHERE is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id "
"GROUP BY feed;"); "GROUP BY feed;");
} }
else { else {
q.prepare("SELECT feed, sum((is_read + 1) % 2) FROM Messages " q.prepare("SELECT feed, sum((is_read + 1) % 2) FROM Messages "
"WHERE is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id " "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(); int total_count = q.value(2).toInt();
counts.insert(feed_id, QPair<int, int>(unread_count, total_count)); counts.insert(feed_id, QPair<int, int>(unread_count, total_count));
} }
else { else {
counts.insert(feed_id, QPair<int, int>(unread_count, 0)); counts.insert(feed_id, QPair<int, int>(unread_count, 0));
} }
@ -247,7 +242,6 @@ bool including_total_counts, bool* ok) {
*ok = true; *ok = true;
} }
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = false; *ok = false;
@ -266,7 +260,6 @@ int DatabaseQueries::getMessageCountsForFeed(QSqlDatabase db, int feed_custom_id
q.prepare("SELECT count(*) FROM Messages " q.prepare("SELECT count(*) FROM Messages "
"WHERE feed = :feed AND is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id;"); "WHERE feed = :feed AND is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id;");
} }
else { else {
q.prepare("SELECT count(*) FROM Messages " 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;"); "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(); return q.value(0).toInt();
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = false; *ok = false;
@ -300,7 +292,6 @@ int DatabaseQueries::getMessageCountsForBin(QSqlDatabase db, int account_id, boo
q.prepare("SELECT count(*) FROM Messages " q.prepare("SELECT count(*) FROM Messages "
"WHERE is_deleted = 1 AND is_pdeleted = 0 AND account_id = :account_id;"); "WHERE is_deleted = 1 AND is_pdeleted = 0 AND account_id = :account_id;");
} }
else { else {
q.prepare("SELECT count(*) FROM Messages " q.prepare("SELECT count(*) FROM Messages "
"WHERE is_read = 0 AND is_deleted = 1 AND is_pdeleted = 0 AND account_id = :account_id;"); "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(); return q.value(0).toInt();
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = false; *ok = false;
@ -349,7 +339,6 @@ QList<Message> DatabaseQueries::getUndeletedMessagesForFeed(QSqlDatabase db, int
*ok = true; *ok = true;
} }
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = false; *ok = false;
@ -382,7 +371,6 @@ QList<Message> DatabaseQueries::getUndeletedMessagesForBin(QSqlDatabase db, int
*ok = true; *ok = true;
} }
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = false; *ok = false;
@ -415,7 +403,6 @@ QList<Message> DatabaseQueries::getUndeletedMessagesForAccount(QSqlDatabase db,
*ok = true; *ok = true;
} }
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = false; *ok = false;
@ -482,7 +469,6 @@ int DatabaseQueries::updateMessages(QSqlDatabase db,
if (message.m_url.startsWith(QL1S("//"))) { if (message.m_url.startsWith(QL1S("//"))) {
message.m_url = QString(URI_SCHEME_HTTP) + message.m_url.mid(2); message.m_url = QString(URI_SCHEME_HTTP) + message.m_url.mid(2);
} }
else if (message.m_url.startsWith(QL1S("/"))) { else if (message.m_url.startsWith(QL1S("/"))) {
QString new_message_url = QUrl(url).toString(QUrl::RemoveUserInfo | QString new_message_url = QUrl(url).toString(QUrl::RemoveUserInfo |
QUrl::RemovePath | QUrl::RemovePath |
@ -515,14 +501,12 @@ int DatabaseQueries::updateMessages(QSqlDatabase db,
is_important_existing_message = query_select_with_url.value(3).toBool(); is_important_existing_message = query_select_with_url.value(3).toBool();
contents_existing_message = query_select_with_url.value(4).toString(); contents_existing_message = query_select_with_url.value(4).toString();
} }
else if (query_select_with_url.lastError().isValid()) { 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())); qWarning("Failed to check for existing message in DB via URL: '%s'.", qPrintable(query_select_with_url.lastError().text()));
} }
query_select_with_url.finish(); query_select_with_url.finish();
} }
else { else {
// We can recognize existing messages via their custom ID. // We can recognize existing messages via their custom ID.
// NOTE: This concerns messages from custom accounts, like TT-RSS or ownCloud News. // 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(); is_important_existing_message = query_select_with_id.value(3).toBool();
contents_existing_message = query_select_with_id.value(4).toString(); contents_existing_message = query_select_with_id.value(4).toString();
} }
else if (query_select_with_id.lastError().isValid()) { 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())); 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) { if (query_update.exec() && !message.m_isRead) {
updated_messages++; updated_messages++;
} }
else if (query_update.lastError().isValid()) { else if (query_update.lastError().isValid()) {
qWarning("Failed to update message in DB: '%s'.", qPrintable(query_update.lastError().text())); 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)); qDebug("Updating message '%s' in DB.", qPrintable(message.m_title));
} }
} }
else { else {
// Message with this URL is not fetched in this feed yet. // Message with this URL is not fetched in this feed yet.
query_insert.bindValue(QSL(":feed"), feed_custom_id); query_insert.bindValue(QSL(":feed"), feed_custom_id);
@ -600,7 +581,6 @@ int DatabaseQueries::updateMessages(QSqlDatabase db,
updated_messages++; updated_messages++;
qDebug("Added new message '%s' to DB.", qPrintable(message.m_title)); qDebug("Added new message '%s' to DB.", qPrintable(message.m_title));
} }
else if (query_insert.lastError().isValid()) { else if (query_insert.lastError().isValid()) {
qWarning("Failed to insert message to DB: '%s' - message title is '%s'.", qWarning("Failed to insert message to DB: '%s' - message title is '%s'.",
qPrintable(query_insert.lastError().text()), qPrintable(query_insert.lastError().text()),
@ -628,7 +608,6 @@ int DatabaseQueries::updateMessages(QSqlDatabase db,
updated_messages = 0; updated_messages = 0;
} }
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = true; *ok = true;
@ -645,7 +624,6 @@ bool DatabaseQueries::purgeMessagesFromBin(QSqlDatabase db, bool clear_only_read
if (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;")); q.prepare(QSL("UPDATE Messages SET is_pdeleted = 1 WHERE is_read = 1 AND is_deleted = 1 AND account_id = :account_id;"));
} }
else { else {
q.prepare(QSL("UPDATE Messages SET is_pdeleted = 1 WHERE is_deleted = 1 AND account_id = :account_id;")); 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())); qCritical("Removing of account from DB failed, this is critical: '%s'.", qPrintable(query.lastError().text()));
return false; return false;
} }
else { else {
query.finish(); 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;") "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(", ")))); .arg(ids.join(QSL(", "))));
} }
else { else {
q.prepare(QString("UPDATE Messages SET is_deleted = :deleted " 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;") "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())); qDebug("Cleaning of feeds failed: '%s'.", qPrintable(q.lastError().text()));
return false; return false;
} }
else { else {
return true; 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())); qWarning("Removing of left over messages failed: '%s'.", qPrintable(q.lastError().text()));
return false; return false;
} }
else { else {
return true; return true;
} }
@ -767,12 +741,10 @@ bool DatabaseQueries::storeAccountTree(QSqlDatabase db, RootItem* tree_root, int
if (query_category.exec()) { if (query_category.exec()) {
child->setId(query_category.lastInsertId().toInt()); child->setId(query_category.lastInsertId().toInt());
} }
else { else {
return false; return false;
} }
} }
else if (child->kind() == RootItemKind::Feed) { else if (child->kind() == RootItemKind::Feed) {
Feed* feed = child->toFeed(); Feed* feed = child->toFeed();
query_feed.bindValue(QSL(":title"), feed->title()); query_feed.bindValue(QSL(":title"), feed->title());
@ -787,7 +759,6 @@ bool DatabaseQueries::storeAccountTree(QSqlDatabase db, RootItem* tree_root, int
if (query_feed.exec()) { if (query_feed.exec()) {
feed->setId(query_feed.lastInsertId().toInt()); feed->setId(query_feed.lastInsertId().toInt());
} }
else { else {
return false; return false;
} }
@ -807,7 +778,6 @@ QStringList DatabaseQueries::customIdsOfMessagesFromAccount(QSqlDatabase db, int
if (ok != nullptr) { if (ok != nullptr) {
*ok = q.exec(); *ok = q.exec();
} }
else { else {
q.exec(); q.exec();
} }
@ -829,7 +799,6 @@ QStringList DatabaseQueries::customIdsOfMessagesFromBin(QSqlDatabase db, int acc
if (ok != nullptr) { if (ok != nullptr) {
*ok = q.exec(); *ok = q.exec();
} }
else { else {
q.exec(); q.exec();
} }
@ -852,7 +821,6 @@ QStringList DatabaseQueries::customIdsOfMessagesFromFeed(QSqlDatabase db, int fe
if (ok != nullptr) { if (ok != nullptr) {
*ok = q.exec(); *ok = q.exec();
} }
else { else {
q.exec(); q.exec();
} }
@ -885,7 +853,6 @@ QList<ServiceRoot*> DatabaseQueries::getOwnCloudAccounts(QSqlDatabase db, bool*
*ok = true; *ok = true;
} }
} }
else { else {
qWarning("OwnCloud: Getting list of activated accounts failed: '%s'.", qPrintable(query.lastError().text())); qWarning("OwnCloud: Getting list of activated accounts failed: '%s'.", qPrintable(query.lastError().text()));
@ -921,7 +888,6 @@ QList<ServiceRoot*> DatabaseQueries::getTtRssAccounts(QSqlDatabase db, bool* ok)
*ok = true; *ok = true;
} }
} }
else { else {
qWarning("TT-RSS: Getting list of activated accounts failed: '%s'.", qPrintable(query.lastError().text())); 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()) { if (query.exec()) {
return true; return true;
} }
else { else {
qWarning("ownCloud: Updating account failed: '%s'.", qPrintable(query.lastError().text())); qWarning("ownCloud: Updating account failed: '%s'.", qPrintable(query.lastError().text()));
return false; return false;
@ -978,7 +943,6 @@ bool DatabaseQueries::createOwnCloudAccount(QSqlDatabase db, int id_to_assign, c
if (q.exec()) { if (q.exec()) {
return true; return true;
} }
else { else {
qWarning("ownCloud: Inserting of new account failed: '%s'.", qPrintable(q.lastError().text())); qWarning("ownCloud: Inserting of new account failed: '%s'.", qPrintable(q.lastError().text()));
return false; return false;
@ -1011,7 +975,6 @@ int DatabaseQueries::createAccount(QSqlDatabase db, const QString& code, bool* o
return id_to_assign; return id_to_assign;
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = false; *ok = false;
@ -1134,7 +1097,6 @@ int DatabaseQueries::addCategory(QSqlDatabase db, int parent_id, int account_id,
// Query failed. // Query failed.
return 0; return 0;
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = true; *ok = true;
@ -1191,7 +1153,6 @@ int DatabaseQueries::addFeed(QSqlDatabase db, int parent_id, int account_id, con
if (password.isEmpty()) { if (password.isEmpty()) {
q.bindValue(QSL(":password"), password); q.bindValue(QSL(":password"), password);
} }
else { else {
q.bindValue(QSL(":password"), TextFactory::encrypt(password)); 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; return new_id;
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = false; *ok = false;
@ -1248,7 +1208,6 @@ bool DatabaseQueries::editFeed(QSqlDatabase db, int parent_id, int feed_id, cons
if (password.isEmpty()) { if (password.isEmpty()) {
q.bindValue(QSL(":password"), password); q.bindValue(QSL(":password"), password);
} }
else { else {
q.bindValue(QSL(":password"), TextFactory::encrypt(password)); q.bindValue(QSL(":password"), TextFactory::encrypt(password));
} }
@ -1291,7 +1250,6 @@ QList<ServiceRoot*> DatabaseQueries::getAccounts(QSqlDatabase db, bool* ok) {
*ok = true; *ok = true;
} }
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = false; *ok = false;
@ -1317,7 +1275,6 @@ Assignment DatabaseQueries::getCategories(QSqlDatabase db, int account_id, bool*
*ok = false; *ok = false;
} }
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = true; *ok = true;
@ -1409,7 +1366,6 @@ bool DatabaseQueries::overwriteTtRssAccount(QSqlDatabase db, const QString& user
if (q.exec()) { if (q.exec()) {
return true; return true;
} }
else { else {
qWarning("TT-RSS: Updating account failed: '%s'.", qPrintable(q.lastError().text())); qWarning("TT-RSS: Updating account failed: '%s'.", qPrintable(q.lastError().text()));
return false; return false;
@ -1435,7 +1391,6 @@ bool DatabaseQueries::createTtRssAccount(QSqlDatabase db, int id_to_assign, cons
if (q.exec()) { if (q.exec()) {
return true; return true;
} }
else { else {
qWarning("TT-RSS: Saving of new account failed: '%s'.", qPrintable(q.lastError().text())); qWarning("TT-RSS: Saving of new account failed: '%s'.", qPrintable(q.lastError().text()));
return false; return false;
@ -1457,7 +1412,6 @@ Assignment DatabaseQueries::getTtRssCategories(QSqlDatabase db, int account_id,
*ok = false; *ok = false;
} }
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = true; *ok = true;
@ -1489,7 +1443,6 @@ Assignment DatabaseQueries::getTtRssFeeds(QSqlDatabase db, int account_id, bool*
*ok = false; *ok = false;
} }
} }
else { else {
if (ok != nullptr) { if (ok != nullptr) {
*ok = true; *ok = true;

View File

@ -40,7 +40,6 @@ void Debugging::performLog(const char* message, QtMsgType type, const char* file
if (file == 0 || function == 0 || line < 0) { if (file == 0 || function == 0 || line < 0) {
fprintf(stderr, "[%s] %s: %s (%s)\n", APP_LOW_NAME, type_string, message, mbstr); fprintf(stderr, "[%s] %s: %s (%s)\n", APP_LOW_NAME, type_string, message, mbstr);
} }
else { else {
fprintf(stderr, "[%s] %s (%s)\n Type: %s\n File: %s (line %d)\n Function: %s\n\n", 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); APP_LOW_NAME, message, mbstr, type_string, file, line, function);

View File

@ -114,7 +114,6 @@ void FeedReader::updateAutoUpdateStatus() {
m_autoUpdateTimer->start(); m_autoUpdateTimer->start();
qDebug("Auto-update timer started with interval %d.", m_autoUpdateTimer->interval()); qDebug("Auto-update timer started with interval %d.", m_autoUpdateTimer->interval());
} }
else { else {
qDebug("Auto-update timer is already running."); 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."); qWarning("Waiting for previously started saving of cached service data.");
m_cacheSaveFutureWatcher->future().waitForFinished(); m_cacheSaveFutureWatcher->future().waitForFinished();
} }
else { else {
qWarning("Some cached service data are being saved now, so aborting this saving cycle."); qWarning("Some cached service data are being saved now, so aborting this saving cycle.");
// Some cache saving is now running. // 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."); qDebug("Waiting for saving of cached service data to finish.");
future.waitForFinished(); future.waitForFinished();
} }
else { else {
m_cacheSaveFutureWatcher->setFuture(future); m_cacheSaveFutureWatcher->setFuture(future);
} }

View File

@ -56,7 +56,6 @@ QPixmap IconFactory::pixmap(const QString& name) {
if (QIcon::themeName() == APP_NO_THEME) { if (QIcon::themeName() == APP_NO_THEME) {
return QPixmap(); return QPixmap();
} }
else { else {
return QIcon::fromTheme(name).pixmap(64, 64); return QIcon::fromTheme(name).pixmap(64, 64);
} }
@ -106,7 +105,6 @@ void IconFactory::loadCurrentIconTheme() {
qDebug("Loading icon theme '%s'.", qPrintable(theme_name_from_settings)); qDebug("Loading icon theme '%s'.", qPrintable(theme_name_from_settings));
QIcon::setThemeName(theme_name_from_settings); QIcon::setThemeName(theme_name_from_settings);
} }
else { else {
// Desired icon theme is not currently available. // Desired icon theme is not currently available.
// Install "default" icon theme instead. // Install "default" icon theme instead.

View File

@ -62,7 +62,6 @@ QString IOFactory::ensureUniqueFilename(const QString& name, const QString& appe
if (index < 0) { if (index < 0) {
tmp_filename.append(append_string); tmp_filename.append(append_string);
} }
else { else {
tmp_filename = tmp_filename.left(index) + append_string + tmp_filename.mid(index); 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(); input_file.close();
return input_data; return input_data;
} }
else { else {
throw IOException(tr("Cannot open file '%1' for reading.").arg(QDir::toNativeSeparators(file_path))); 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.flush();
input_file.close(); input_file.close();
} }
else { else {
throw IOException(tr("Cannot open file '%1' for writting.").arg(QDir::toNativeSeparators(file_path))); throw IOException(tr("Cannot open file '%1' for writting.").arg(QDir::toNativeSeparators(file_path)));
} }

View File

@ -50,7 +50,6 @@ void Localization::loadActiveLanguage() {
qPrintable(real_loaded_locale)); qPrintable(real_loaded_locale));
desired_localization = real_loaded_locale; desired_localization = real_loaded_locale;
} }
else { else {
qWarning("Application localization '%s' was not loaded. Loading '%s' instead.", qWarning("Application localization '%s' was not loaded. Loading '%s' instead.",
qPrintable(desired_localization), qPrintable(desired_localization),
@ -62,7 +61,6 @@ void Localization::loadActiveLanguage() {
Application::installTranslator(qt_translator); Application::installTranslator(qt_translator);
qDebug("Qt localization '%s' loaded successfully.", qPrintable(desired_localization)); qDebug("Qt localization '%s' loaded successfully.", qPrintable(desired_localization));
} }
else { else {
qWarning("Qt localization '%s' was not loaded.", qPrintable(desired_localization)); qWarning("Qt localization '%s' was not loaded.", qPrintable(desired_localization));
} }

View File

@ -324,7 +324,6 @@ void Settings::finishRestoration(const QString& desired_settings_file_path) {
QFile::remove(backup_settings_file); QFile::remove(backup_settings_file);
qDebug("Settings file was restored successully."); qDebug("Settings file was restored successully.");
} }
else { else {
qCritical("Settings file was NOT restored due to error when copying the file."); 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) { if (properties.m_type == SettingsProperties::Portable) {
qDebug("Initializing settings in '%s' (portable way).", qPrintable(QDir::toNativeSeparators(properties.m_absoluteSettingsFileName))); qDebug("Initializing settings in '%s' (portable way).", qPrintable(QDir::toNativeSeparators(properties.m_absoluteSettingsFileName)));
} }
else { else {
qDebug("Initializing settings in '%s' (non-portable way).", qPrintable(QDir::toNativeSeparators(properties.m_absoluteSettingsFileName))); 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_type = SettingsProperties::Portable;
properties.m_baseDirectory = app_path; properties.m_baseDirectory = app_path;
} }
else { else {
properties.m_type = SettingsProperties::NonPortable; properties.m_type = SettingsProperties::NonPortable;
properties.m_baseDirectory = home_path; properties.m_baseDirectory = home_path;

View File

@ -91,7 +91,6 @@ QByteArray SimpleCrypt::encryptToByteArray(QByteArray plaintext) {
ba = qCompress(ba, 9); //maximum compression ba = qCompress(ba, 9); //maximum compression
flags |= CryptoFlagCompression; flags |= CryptoFlagCompression;
} }
else if (m_compressionMode == CompressionAuto) { else if (m_compressionMode == CompressionAuto) {
QByteArray compressed = qCompress(ba, 9); QByteArray compressed = qCompress(ba, 9);
@ -108,7 +107,6 @@ QByteArray SimpleCrypt::encryptToByteArray(QByteArray plaintext) {
QDataStream s(&integrityProtection, QIODevice::WriteOnly); QDataStream s(&integrityProtection, QIODevice::WriteOnly);
s << qChecksum(ba.constData(), ba.length()); s << qChecksum(ba.constData(), ba.length());
} }
else if (m_protectionMode == ProtectionHash) { else if (m_protectionMode == ProtectionHash) {
flags |= CryptoFlagHash; flags |= CryptoFlagHash;
QCryptographicHash hash(QCryptographicHash::Sha1); QCryptographicHash hash(QCryptographicHash::Sha1);
@ -221,7 +219,6 @@ QByteArray SimpleCrypt::decryptToByteArray(QByteArray cypher) {
quint16 checksum = qChecksum(ba.constData(), ba.length()); quint16 checksum = qChecksum(ba.constData(), ba.length());
integrityOk = (checksum == storedChecksum); integrityOk = (checksum == storedChecksum);
} }
else if (flags.testFlag(CryptoFlagHash)) { else if (flags.testFlag(CryptoFlagHash)) {
if (ba.length() < 20) { if (ba.length() < 20) {
m_lastError = ErrorIntegrityFailed; m_lastError = ErrorIntegrityFailed;

View File

@ -40,7 +40,6 @@ void SimpleRegExp::setMinimal(bool minimal) {
if (minimal) { if (minimal) {
opt = patternOptions() | QRegularExpression::InvertedGreedinessOption; opt = patternOptions() | QRegularExpression::InvertedGreedinessOption;
} }
else { else {
opt = patternOptions() & ~QRegularExpression::InvertedGreedinessOption; opt = patternOptions() & ~QRegularExpression::InvertedGreedinessOption;
} }
@ -57,7 +56,6 @@ int SimpleRegExp::indexIn(const QString& str, int offset) const {
that->m_capturedTexts.clear(); that->m_capturedTexts.clear();
return -1; return -1;
} }
else { else {
that->m_matchedLength = m.capturedLength(); that->m_matchedLength = m.capturedLength();
that->m_capturedTexts = m.capturedTexts(); that->m_capturedTexts = m.capturedTexts();
@ -73,7 +71,6 @@ QString SimpleRegExp::cap(int nth) const {
if (nth >= 0 && m_capturedTexts.size() > nth) { if (nth >= 0 && m_capturedTexts.size() > nth) {
return m_capturedTexts.at(nth); return m_capturedTexts.at(nth);
} }
else { else {
return QString(); return QString();
} }

View File

@ -50,7 +50,6 @@ void SkinFactory::loadCurrentSkin() {
qDebug("Skin '%s' loaded.", qPrintable(skin_name)); qDebug("Skin '%s' loaded.", qPrintable(skin_name));
return; return;
} }
else { else {
qWarning("Failed to load skin '%s'.", qPrintable(skin_name)); 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\"<br/>Blocked by filter: \"%2\"") tr("Blocked by set: \"%1\"<br/>Blocked by filter: \"%2\"")
.arg(subscription, .arg(subscription,
rule)); rule));
return currentSkin().m_layoutMarkupWrapper.arg(tr("This page was blocked by AdBlock"), adblocked); return currentSkin().m_layoutMarkupWrapper.arg(tr("This page was blocked by AdBlock"), adblocked);
} }

View File

@ -59,7 +59,6 @@ SystemFactory::AutoStartStatus SystemFactory::autoStartStatus() const {
if (autostart_enabled) { if (autostart_enabled) {
return AutoStartStatus::Enabled; return AutoStartStatus::Enabled;
} }
else { else {
return AutoStartStatus::Disabled; return AutoStartStatus::Disabled;
} }
@ -82,7 +81,6 @@ SystemFactory::AutoStartStatus SystemFactory::autoStartStatus() const {
bool hidden_value = desktop_settings.value(QSL("Desktop Entry/Hidden"), false).toBool(); bool hidden_value = desktop_settings.value(QSL("Desktop Entry/Hidden"), false).toBool();
return hidden_value ? SystemFactory::Disabled : SystemFactory::Enabled; return hidden_value ? SystemFactory::Disabled : SystemFactory::Enabled;
} }
else { else {
return SystemFactory::Disabled; return SystemFactory::Disabled;
} }
@ -103,7 +101,6 @@ QString SystemFactory::autostartDesktopFileLocation() const {
// in 'autostart' subdirectory. // in 'autostart' subdirectory.
desktop_file_location = xdg_config_path + QSL("/autostart/") + APP_DESKTOP_ENTRY_FILE; desktop_file_location = xdg_config_path + QSL("/autostart/") + APP_DESKTOP_ENTRY_FILE;
} }
else { else {
// Desired variable is not set, look for the default 'autostart' subdirectory. // Desired variable is not set, look for the default 'autostart' subdirectory.
const QString home_directory(qgetenv("HOME")); const QString home_directory(qgetenv("HOME"));
@ -186,7 +183,6 @@ bool SystemFactory::removeTrolltechJunkRegistryKeys() {
registry_key.sync(); registry_key.sync();
return registry_key.status() == QSettings::NoError; return registry_key.status() == QSettings::NoError;
} }
else { else {
return false; return false;
} }
@ -209,7 +205,6 @@ QString SystemFactory::loggedInUser() const {
void SystemFactory::checkForUpdates() const { void SystemFactory::checkForUpdates() const {
Downloader* downloader = new Downloader(); Downloader* downloader = new Downloader();
connect(downloader, &Downloader::completed, [this, downloader]() { connect(downloader, &Downloader::completed, [this, downloader]() {
QPair<QList<UpdateInfo>, QNetworkReply::NetworkError> result; QPair<QList<UpdateInfo>, QNetworkReply::NetworkError> result;
result.second = downloader->lastOutputError(); result.second = downloader->lastOutputError();
@ -220,10 +215,8 @@ void SystemFactory::checkForUpdates() const {
} }
emit updatesChecked(result); emit updatesChecked(result);
downloader->deleteLater(); downloader->deleteLater();
}); });
downloader->downloadFile(RELEASES_LIST); 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. // New version is indeed higher thatn current version.
return true; return true;
} }
else if (new_number < base_number) { else if (new_number < base_number) {
return false; return false;
} }
@ -250,12 +242,10 @@ bool SystemFactory::isVersionNewer(const QString& new_version, const QString& ba
// Versions are the same. // Versions are the same.
return false; return false;
} }
else { else {
if (new_version_tkn.isEmpty()) { if (new_version_tkn.isEmpty()) {
return false; return false;
} }
else { else {
return new_version_tkn.join(QString()).toInt() > 0; return new_version_tkn.join(QString()).toInt() > 0;
} }

View File

@ -96,13 +96,11 @@ QDateTime TextFactory::parseDateTime(const QString& date_time) {
// the original UTC. // the original UTC.
return dt.addSecs(- QTime(0, 0, 0, 0).secsTo(time_zone_offset)); return dt.addSecs(- QTime(0, 0, 0, 0).secsTo(time_zone_offset));
} }
else { else {
// Vice versa. // Vice versa.
return dt.addSecs(QTime(0, 0, 0, 0).secsTo(time_zone_offset)); return dt.addSecs(QTime(0, 0, 0, 0).secsTo(time_zone_offset));
} }
} }
else { else {
return dt; return dt;
} }
@ -129,7 +127,6 @@ QString TextFactory::shorten(const QString& input, int text_length_limit) {
if (input.size() > text_length_limit) { if (input.size() > text_length_limit) {
return input.left(text_length_limit - ELLIPSIS_LENGTH) + QString(ELLIPSIS_LENGTH, QL1C('.')); return input.left(text_length_limit - ELLIPSIS_LENGTH) + QString(ELLIPSIS_LENGTH, QL1C('.'));
} }
else { else {
return input; return input;
} }
@ -143,7 +140,6 @@ quint64 TextFactory::initializeSecretEncryptionKey() {
try { try {
s_encryptionKey = (quint64) QString(IOFactory::readTextFile(encryption_file_path)).toLongLong(); s_encryptionKey = (quint64) QString(IOFactory::readTextFile(encryption_file_path)).toLongLong();
} }
catch (ApplicationException) { catch (ApplicationException) {
// Well, key does not exist or is invalid, generate and save one. // Well, key does not exist or is invalid, generate and save one.
s_encryptionKey = generateSecretEncryptionKey(); s_encryptionKey = generateSecretEncryptionKey();

View File

@ -57,10 +57,8 @@ AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget* parent)
connect(m_ui->m_cmbPresets, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, connect(m_ui->m_cmbPresets, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&AdBlockAddSubscriptionDialog::indexChanged); &AdBlockAddSubscriptionDialog::indexChanged);
connect(m_ui->m_cbUsePredefined, &QCheckBox::toggled, this, &AdBlockAddSubscriptionDialog::presetsEnabledChanged); connect(m_ui->m_cbUsePredefined, &QCheckBox::toggled, this, &AdBlockAddSubscriptionDialog::presetsEnabledChanged);
m_ui->m_cbUsePredefined->setChecked(true); m_ui->m_cbUsePredefined->setChecked(true);
indexChanged(0); indexChanged(0);
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint); setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint);
setWindowIcon(qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE)); setWindowIcon(qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE));
} }

View File

@ -39,37 +39,26 @@ AdBlockDialog::AdBlockDialog(QWidget* parent)
m_loaded(false) { m_loaded(false) {
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->m_cbEnable->setChecked(m_manager->isEnabled()); m_ui->m_cbEnable->setChecked(m_manager->isEnabled());
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint); setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint);
setWindowIcon(qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE)); setWindowIcon(qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE));
QPushButton* btn_options = m_ui->m_buttonBox->addButton(QDialogButtonBox::FirstButton); QPushButton* btn_options = m_ui->m_buttonBox->addButton(QDialogButtonBox::FirstButton);
btn_options->setText(tr("Options")); btn_options->setText(tr("Options"));
QMenu* menu = new QMenu(btn_options); QMenu* menu = new QMenu(btn_options);
m_actionAddRule = menu->addAction(tr("Add rule"), this, &AdBlockDialog::addRule); m_actionAddRule = menu->addAction(tr("Add rule"), this, &AdBlockDialog::addRule);
m_actionRemoveRule = menu->addAction(tr("Remove rule"), this, &AdBlockDialog::removeRule); m_actionRemoveRule = menu->addAction(tr("Remove rule"), this, &AdBlockDialog::removeRule);
menu->addSeparator(); menu->addSeparator();
m_actionAddSubscription = menu->addAction(tr("Add subscription"), this, &AdBlockDialog::addSubscription); m_actionAddSubscription = menu->addAction(tr("Add subscription"), this, &AdBlockDialog::addSubscription);
m_actionRemoveSubscription = menu->addAction(tr("Remove subscription"), this, &AdBlockDialog::removeSubscription); m_actionRemoveSubscription = menu->addAction(tr("Remove subscription"), this, &AdBlockDialog::removeSubscription);
menu->addAction(tr("Update subscriptions"), m_manager, &AdBlockManager::updateAllSubscriptions); menu->addAction(tr("Update subscriptions"), m_manager, &AdBlockManager::updateAllSubscriptions);
menu->addSeparator(); menu->addSeparator();
menu->addAction(tr("Learn about writing rules..."), this, &AdBlockDialog::learnAboutRules); menu->addAction(tr("Learn about writing rules..."), this, &AdBlockDialog::learnAboutRules);
btn_options->setMenu(menu); btn_options->setMenu(menu);
connect(menu, &QMenu::aboutToShow, this, &AdBlockDialog::aboutToShowMenu); connect(menu, &QMenu::aboutToShow, this, &AdBlockDialog::aboutToShowMenu);
connect(m_ui->m_cbEnable, &QCheckBox::toggled, this, &AdBlockDialog::enableAdBlock); connect(m_ui->m_cbEnable, &QCheckBox::toggled, this, &AdBlockDialog::enableAdBlock);
connect(m_ui->m_tabSubscriptions, &QTabWidget::currentChanged, this, &AdBlockDialog::currentChanged); connect(m_ui->m_tabSubscriptions, &QTabWidget::currentChanged, this, &AdBlockDialog::currentChanged);
connect(m_ui->m_buttonBox, &QDialogButtonBox::rejected, this, &AdBlockDialog::close); connect(m_ui->m_buttonBox, &QDialogButtonBox::rejected, this, &AdBlockDialog::close);
load(); load();
m_ui->m_buttonBox->setFocus(); m_ui->m_buttonBox->setFocus();
} }

View File

@ -38,7 +38,6 @@ AdBlockIcon::AdBlockIcon(AdBlockManager* parent)
setText(QSL("AdBlock")); setText(QSL("AdBlock"));
setMenu(new QMenu()); setMenu(new QMenu());
setIcon(m_enabled ? qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE) : qApp->icons()->miscIcon(ADBLOCK_ICON_DISABLED)); 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(m_manager, SIGNAL(enabledChanged(bool)), this, SLOT(setEnabled(bool)));
connect(menu(), SIGNAL(aboutToShow()), this, SLOT(createMenu())); connect(menu(), SIGNAL(aboutToShow()), this, SLOT(createMenu()));
connect(this, &QAction::triggered, m_manager, &AdBlockManager::showDialog); connect(this, &QAction::triggered, m_manager, &AdBlockManager::showDialog);
@ -136,7 +135,6 @@ void AdBlockIcon::toggleCustomFilter() {
if (customList->containsFilter(filter)) { if (customList->containsFilter(filter)) {
customList->removeFilter(filter); customList->removeFilter(filter);
} }
else { else {
AdBlockRule* rule = new AdBlockRule(filter, customList); AdBlockRule* rule = new AdBlockRule(filter, customList);
customList->addRule(rule); customList->addRule(rule);
@ -154,7 +152,6 @@ void AdBlockIcon::animateIcon() {
if (icon().isNull()) { if (icon().isNull()) {
setIcon(qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE)); setIcon(qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE));
} }
else { else {
setIcon(QIcon()); setIcon(QIcon());
} }

View File

@ -43,10 +43,8 @@ Q_GLOBAL_STATIC(AdBlockManager, qz_adblock_manager)
AdBlockManager::AdBlockManager(QObject* parent) AdBlockManager::AdBlockManager(QObject* parent)
: QObject(parent), m_loaded(false), m_enabled(true), m_matcher(new AdBlockMatcher(this)), m_interceptor(new AdBlockUrlInterceptor(this)) { : QObject(parent), m_loaded(false), m_enabled(true), m_matcher(new AdBlockMatcher(this)), m_interceptor(new AdBlockUrlInterceptor(this)) {
m_adblockIcon = new AdBlockIcon(this); m_adblockIcon = new AdBlockIcon(this);
m_adblockIcon->setObjectName(QSL("m_adblockIconAction")); m_adblockIcon->setObjectName(QSL("m_adblockIconAction"));
load(); load();
} }
@ -74,7 +72,6 @@ void AdBlockManager::setEnabled(bool enabled) {
if (m_enabled) { if (m_enabled) {
m_matcher->update(); m_matcher->update();
} }
else { else {
m_matcher->clear(); m_matcher->clear();
} }
@ -106,14 +103,11 @@ bool AdBlockManager::block(QWebEngineUrlRequestInfo& request) {
if (request.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame) { if (request.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame) {
QUrlQuery query; QUrlQuery query;
QUrl url(QSL("rssguard:adblockedpage")); QUrl url(QSL("rssguard:adblockedpage"));
query.addQueryItem(QSL("rule"), blockedRule->filter()); query.addQueryItem(QSL("rule"), blockedRule->filter());
query.addQueryItem(QSL("subscription"), blockedRule->subscription()->title()); query.addQueryItem(QSL("subscription"), blockedRule->subscription()->title());
url.setQuery(query); url.setQuery(query);
request.redirect(url); request.redirect(url);
} }
else { else {
res = true; res = true;
request.block(true); request.block(true);
@ -146,7 +140,6 @@ bool AdBlockManager::addSubscriptionFromUrl(const QUrl& url) {
if (pair.first == QL1S("location")) { if (pair.first == QL1S("location")) {
subscriptionUrl = pair.second; subscriptionUrl = pair.second;
} }
else if (pair.first == QL1S("title")) { else if (pair.first == QL1S("title")) {
subscriptionTitle = pair.second; subscriptionTitle = pair.second;
} }
@ -339,7 +332,6 @@ QString AdBlockManager::elementHidingRules(const QUrl& url) const {
if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url)) { if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url)) {
return QString(); return QString();
} }
else { else {
return m_matcher->elementHidingRules(); return m_matcher->elementHidingRules();
} }
@ -349,7 +341,6 @@ QString AdBlockManager::elementHidingRulesForDomain(const QUrl& url) const {
if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url)) { if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url)) {
return QString(); return QString();
} }
else { else {
return m_matcher->elementHidingRulesForDomain(url.host()); return m_matcher->elementHidingRulesForDomain(url.host());
} }

View File

@ -116,7 +116,6 @@ QString AdBlockMatcher::elementHidingRulesForDomain(const QString& domain) const
rules.append(QSL("{display:none !important;}\n")); rules.append(QSL("{display:none !important;}\n"));
addedRulesCount = 0; addedRulesCount = 0;
} }
else { else {
rules.append(rule->cssSelector() + QLatin1Char(',')); rules.append(rule->cssSelector() + QLatin1Char(','));
addedRulesCount++; addedRulesCount++;
@ -153,26 +152,21 @@ void AdBlockMatcher::update() {
if (rule->isException()) { if (rule->isException()) {
exceptionCssRules.append(rule); exceptionCssRules.append(rule);
} }
else { else {
cssRulesHash.insert(rule->cssSelector(), rule); cssRulesHash.insert(rule->cssSelector(), rule);
} }
} }
else if (rule->isDocument()) { else if (rule->isDocument()) {
m_documentRules.append(rule); m_documentRules.append(rule);
} }
else if (rule->isElemhide()) { else if (rule->isElemhide()) {
m_elemhideRules.append(rule); m_elemhideRules.append(rule);
} }
else if (rule->isException()) { else if (rule->isException()) {
if (!m_networkExceptionTree.add(rule)) { if (!m_networkExceptionTree.add(rule)) {
m_networkExceptionRules.append(rule); m_networkExceptionRules.append(rule);
} }
} }
else { else {
if (!m_networkBlockTree.add(rule)) { if (!m_networkBlockTree.add(rule)) {
m_networkBlockRules.append(rule); m_networkBlockRules.append(rule);
@ -209,13 +203,11 @@ void AdBlockMatcher::update() {
if (rule->isDomainRestricted()) { if (rule->isDomainRestricted()) {
m_domainRestrictedCssRules.append(rule); m_domainRestrictedCssRules.append(rule);
} }
else if (Q_UNLIKELY(hidingRulesCount == 1000)) { else if (Q_UNLIKELY(hidingRulesCount == 1000)) {
m_elementHidingRules.append(rule->cssSelector()); m_elementHidingRules.append(rule->cssSelector());
m_elementHidingRules.append(QL1S("{display:none !important;} ")); m_elementHidingRules.append(QL1S("{display:none !important;} "));
hidingRulesCount = 0; hidingRulesCount = 0;
} }
else { else {
m_elementHidingRules.append(rule->cssSelector() + QLatin1Char(',')); m_elementHidingRules.append(rule->cssSelector() + QLatin1Char(','));
hidingRulesCount++; hidingRulesCount++;

View File

@ -178,7 +178,6 @@ bool AdBlockRule::urlMatch(const QUrl& url) const {
if (!hasOption(DocumentOption) && !hasOption(ElementHideOption)) { if (!hasOption(DocumentOption) && !hasOption(ElementHideOption)) {
return false; return false;
} }
else { else {
const QString encodedUrl = url.toEncoded(); const QString encodedUrl = url.toEncoded();
const QString domain = url.host(); const QString domain = url.host();
@ -259,7 +258,6 @@ bool AdBlockRule::matchDomain(const QString& domain) const {
} }
} }
} }
else if (m_allowedDomains.isEmpty()) { else if (m_allowedDomains.isEmpty()) {
foreach (const QString& d, m_blockedDomains) { foreach (const QString& d, m_blockedDomains) {
if (isMatchingDomain(domain, d)) { if (isMatchingDomain(domain, d)) {
@ -269,7 +267,6 @@ bool AdBlockRule::matchDomain(const QString& domain) const {
return true; return true;
} }
else { else {
foreach (const QString& d, m_blockedDomains) { foreach (const QString& d, m_blockedDomains) {
if (isMatchingDomain(domain, d)) { if (isMatchingDomain(domain, d)) {
@ -378,70 +375,58 @@ void AdBlockRule::parseFilter() {
parseDomains(option.mid(7), QL1C('|')); parseDomains(option.mid(7), QL1C('|'));
++handledOptions; ++handledOptions;
} }
else if (option == QL1S("match-case")) { else if (option == QL1S("match-case")) {
m_caseSensitivity = Qt::CaseSensitive; m_caseSensitivity = Qt::CaseSensitive;
++handledOptions; ++handledOptions;
} }
else if (option.endsWith(QL1S("third-party"))) { else if (option.endsWith(QL1S("third-party"))) {
setOption(ThirdPartyOption); setOption(ThirdPartyOption);
setException(ThirdPartyOption, option.startsWith(QL1C('~'))); setException(ThirdPartyOption, option.startsWith(QL1C('~')));
++handledOptions; ++handledOptions;
} }
else if (option.endsWith(QL1S("object"))) { else if (option.endsWith(QL1S("object"))) {
setOption(ObjectOption); setOption(ObjectOption);
setException(ObjectOption, option.startsWith(QL1C('~'))); setException(ObjectOption, option.startsWith(QL1C('~')));
++handledOptions; ++handledOptions;
} }
else if (option.endsWith(QL1S("subdocument"))) { else if (option.endsWith(QL1S("subdocument"))) {
setOption(SubdocumentOption); setOption(SubdocumentOption);
setException(SubdocumentOption, option.startsWith(QL1C('~'))); setException(SubdocumentOption, option.startsWith(QL1C('~')));
++handledOptions; ++handledOptions;
} }
else if (option.endsWith(QL1S("xmlhttprequest"))) { else if (option.endsWith(QL1S("xmlhttprequest"))) {
setOption(XMLHttpRequestOption); setOption(XMLHttpRequestOption);
setException(XMLHttpRequestOption, option.startsWith(QL1C('~'))); setException(XMLHttpRequestOption, option.startsWith(QL1C('~')));
++handledOptions; ++handledOptions;
} }
else if (option.endsWith(QL1S("image"))) { else if (option.endsWith(QL1S("image"))) {
setOption(ImageOption); setOption(ImageOption);
setException(ImageOption, option.startsWith(QL1C('~'))); setException(ImageOption, option.startsWith(QL1C('~')));
++handledOptions; ++handledOptions;
} }
else if (option.endsWith(QL1S("script"))) { else if (option.endsWith(QL1S("script"))) {
setOption(ScriptOption); setOption(ScriptOption);
setException(ScriptOption, option.startsWith(QL1C('~'))); setException(ScriptOption, option.startsWith(QL1C('~')));
++handledOptions; ++handledOptions;
} }
else if (option.endsWith(QL1S("stylesheet"))) { else if (option.endsWith(QL1S("stylesheet"))) {
setOption(StyleSheetOption); setOption(StyleSheetOption);
setException(StyleSheetOption, option.startsWith(QL1C('~'))); setException(StyleSheetOption, option.startsWith(QL1C('~')));
++handledOptions; ++handledOptions;
} }
else if (option.endsWith(QL1S("object-subrequest"))) { else if (option.endsWith(QL1S("object-subrequest"))) {
setOption(ObjectSubrequestOption); setOption(ObjectSubrequestOption);
setException(ObjectSubrequestOption, option.startsWith(QL1C('~'))); setException(ObjectSubrequestOption, option.startsWith(QL1C('~')));
++handledOptions; ++handledOptions;
} }
else if (option == QL1S("document") && m_isException) { else if (option == QL1S("document") && m_isException) {
setOption(DocumentOption); setOption(DocumentOption);
++handledOptions; ++handledOptions;
} }
else if (option == QL1S("elemhide") && m_isException) { else if (option == QL1S("elemhide") && m_isException) {
setOption(ElementHideOption); setOption(ElementHideOption);
++handledOptions; ++handledOptions;
} }
else if (option == QL1S("collapse")) { else if (option == QL1S("collapse")) {
// Hiding placeholders of blocked elements is enabled by default. // Hiding placeholders of blocked elements is enabled by default.
++handledOptions; ++handledOptions;
@ -521,7 +506,6 @@ void AdBlockRule::parseDomains(const QString& domains, const QChar& separator) {
if (domain.startsWith(QL1C('~'))) { if (domain.startsWith(QL1C('~'))) {
m_blockedDomains.append(domain.mid(1)); m_blockedDomains.append(domain.mid(1));
} }
else { else {
m_allowedDomains.append(domain); m_allowedDomains.append(domain);
} }
@ -603,14 +587,12 @@ QString AdBlockRule::createRegExpFromFilter(const QString& filter) const {
parsed.append(QL1S("^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?")); parsed.append(QL1S("^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?"));
i++; i++;
} }
else { else {
parsed.append('^'); parsed.append('^');
} }
break; break;
} }
else if (i == filter.size() - 1) { else if (i == filter.size() - 1) {
parsed.append(QL1C('$')); parsed.append(QL1C('$'));
break; break;
@ -622,7 +604,6 @@ QString AdBlockRule::createRegExpFromFilter(const QString& filter) const {
if (!wordCharacter(c)) { if (!wordCharacter(c)) {
parsed.append(QL1C('\\') + c); parsed.append(QL1C('\\') + c);
} }
else { else {
parsed.append(c); parsed.append(c);
} }
@ -649,20 +630,16 @@ bool AdBlockRule::stringMatch(const QString& domain, const QString& encodedUrl)
if (m_type == StringContainsMatchRule) { if (m_type == StringContainsMatchRule) {
return encodedUrl.contains(m_matchString, m_caseSensitivity); return encodedUrl.contains(m_matchString, m_caseSensitivity);
} }
else if (m_type == DomainMatchRule) { else if (m_type == DomainMatchRule) {
return isMatchingDomain(domain, m_matchString); return isMatchingDomain(domain, m_matchString);
} }
else if (m_type == StringEndsMatchRule) { else if (m_type == StringEndsMatchRule) {
return encodedUrl.endsWith(m_matchString, m_caseSensitivity); return encodedUrl.endsWith(m_matchString, m_caseSensitivity);
} }
else if (m_type == RegExpMatchRule) { else if (m_type == RegExpMatchRule) {
if (!isMatchingRegExpStrings(encodedUrl)) { if (!isMatchingRegExpStrings(encodedUrl)) {
return false; return false;
} }
else { else {
return (m_regExp->regExp.indexIn(encodedUrl) != -1); return (m_regExp->regExp.indexIn(encodedUrl) != -1);
} }

View File

@ -176,7 +176,6 @@ bool AdBlockSubscription::saveDownloadedData(const QByteArray& data) {
qWarning("Unable to open AdBlock file '%s' for writing.", qPrintable(m_filePath)); qWarning("Unable to open AdBlock file '%s' for writing.", qPrintable(m_filePath));
return false; return false;
} }
else { else {
// Write subscription header // Write subscription header
file.write(QString("Title: %1\nUrl: %2\n").arg(title(), url().toString()).toUtf8()); 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)) { if (IS_IN_ARRAY(offset, m_rules)) {
return m_rules[offset]; return m_rules[offset];
} }
else { else {
return 0; return 0;
} }
@ -213,7 +211,6 @@ const AdBlockRule* AdBlockSubscription::enableRule(int offset) {
return rule; return rule;
} }
else { else {
return 0; return 0;
} }
@ -282,7 +279,6 @@ void AdBlockCustomList::loadSubscription(const QStringList& disabledRules) {
try { try {
rules = QString::fromUtf8(IOFactory::readTextFile(filePath())); rules = QString::fromUtf8(IOFactory::readTextFile(filePath()));
} }
catch (ApplicationException&) { catch (ApplicationException&) {
} }

View File

@ -35,7 +35,6 @@ AdBlockTreeWidget::AdBlockTreeWidget(AdBlockSubscription* subscription, QWidget*
setAlternatingRowColors(true); setAlternatingRowColors(true);
setLayoutDirection(Qt::LeftToRight); setLayoutDirection(Qt::LeftToRight);
setIndentation(5); setIndentation(5);
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint))); connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
connect(this, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(itemChanged(QTreeWidgetItem*))); connect(this, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(itemChanged(QTreeWidgetItem*)));
connect(m_subscription, SIGNAL(subscriptionUpdated()), this, SLOT(subscriptionUpdated())); connect(m_subscription, SIGNAL(subscriptionUpdated()), this, SLOT(subscriptionUpdated()));
@ -50,7 +49,6 @@ void AdBlockTreeWidget::showRule(const AdBlockRule* rule) {
if (!m_topItem && rule) { if (!m_topItem && rule) {
m_ruleToBeSelected = rule->filter(); m_ruleToBeSelected = rule->filter();
} }
else if (!m_ruleToBeSelected.isEmpty()) { else if (!m_ruleToBeSelected.isEmpty()) {
QList<QTreeWidgetItem*> items = findItems(m_ruleToBeSelected, Qt::MatchRecursive); QList<QTreeWidgetItem*> items = findItems(m_ruleToBeSelected, Qt::MatchRecursive);
@ -101,13 +99,11 @@ void AdBlockTreeWidget::itemChanged(QTreeWidgetItem* item) {
const AdBlockRule* rule = m_subscription->disableRule(offset); const AdBlockRule* rule = m_subscription->disableRule(offset);
adjustItemFeatures(item, rule); adjustItemFeatures(item, rule);
} }
else if (item->checkState(0) == Qt::Checked && !oldRule->isEnabled()) { else if (item->checkState(0) == Qt::Checked && !oldRule->isEnabled()) {
// Enable rule. // Enable rule.
const AdBlockRule* rule = m_subscription->enableRule(offset); const AdBlockRule* rule = m_subscription->enableRule(offset);
adjustItemFeatures(item, rule); adjustItemFeatures(item, rule);
} }
else if (m_subscription->canEditRules()) { else if (m_subscription->canEditRules()) {
// Custom rule has been changed. // Custom rule has been changed.
AdBlockRule* newRule = new AdBlockRule(item->text(0), m_subscription); 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->setForeground(0, QColor(Qt::darkGreen));
item->setFont(0, QFont()); item->setFont(0, QFont());
} }
else if (rule->isCssRule()) { else if (rule->isCssRule()) {
item->setForeground(0, QColor(Qt::darkBlue)); item->setForeground(0, QColor(Qt::darkBlue));
item->setFont(0, QFont()); item->setFont(0, QFont());

View File

@ -43,11 +43,9 @@ void BaseNetworkAccessManager::loadSettings() {
// No extra setting is needed, set new proxy and exit this method. // No extra setting is needed, set new proxy and exit this method.
setProxy(QNetworkProxy::NoProxy); setProxy(QNetworkProxy::NoProxy);
} }
else if (selected_proxy_type == QNetworkProxy::DefaultProxy) { else if (selected_proxy_type == QNetworkProxy::DefaultProxy) {
setProxy(QNetworkProxy::applicationProxy()); setProxy(QNetworkProxy::applicationProxy());
} }
else { else {
const Settings* settings = qApp->settings(); const Settings* settings = qApp->settings();
// Custom proxy is selected, set it up. // Custom proxy is selected, set it up.

View File

@ -65,7 +65,6 @@ void Downloader::manipulateData(const QString& url, QNetworkAccessManager::Opera
qDebug("Replacing URI schemes for '%s'.", qPrintable(non_const_url)); 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))); request.setUrl(non_const_url.replace(QRegExp(QString('^') + URI_SCHEME_FEED), QString(URI_SCHEME_HTTP)));
} }
else { else {
request.setUrl(non_const_url); request.setUrl(non_const_url);
} }
@ -77,15 +76,12 @@ void Downloader::manipulateData(const QString& url, QNetworkAccessManager::Opera
if (operation == QNetworkAccessManager::PostOperation) { if (operation == QNetworkAccessManager::PostOperation) {
runPostRequest(request, m_inputData); runPostRequest(request, m_inputData);
} }
else if (operation == QNetworkAccessManager::GetOperation) { else if (operation == QNetworkAccessManager::GetOperation) {
runGetRequest(request); runGetRequest(request);
} }
else if (operation == QNetworkAccessManager::PutOperation) { else if (operation == QNetworkAccessManager::PutOperation) {
runPutRequest(request, m_inputData); runPutRequest(request, m_inputData);
} }
else if (operation == QNetworkAccessManager::DeleteOperation) { else if (operation == QNetworkAccessManager::DeleteOperation) {
runDeleteRequest(request); runDeleteRequest(request);
} }
@ -106,7 +102,6 @@ void Downloader::finished() {
if (redirection_url.host().isEmpty()) { if (redirection_url.host().isEmpty()) {
request.setUrl(QUrl(reply->request().url().scheme() + QSL("://") + reply->request().url().host() + redirection_url.toString())); request.setUrl(QUrl(reply->request().url().scheme() + QSL("://") + reply->request().url().host() + redirection_url.toString()));
} }
else { else {
request.setUrl(redirection_url); request.setUrl(redirection_url);
} }
@ -117,20 +112,16 @@ void Downloader::finished() {
if (reply_operation == QNetworkAccessManager::GetOperation) { if (reply_operation == QNetworkAccessManager::GetOperation) {
runGetRequest(request); runGetRequest(request);
} }
else if (reply_operation == QNetworkAccessManager::PostOperation) { else if (reply_operation == QNetworkAccessManager::PostOperation) {
runPostRequest(request, m_inputData); runPostRequest(request, m_inputData);
} }
else if (reply_operation == QNetworkAccessManager::PutOperation) { else if (reply_operation == QNetworkAccessManager::PutOperation) {
runPutRequest(request, m_inputData); runPutRequest(request, m_inputData);
} }
else if (reply_operation == QNetworkAccessManager::DeleteOperation) { else if (reply_operation == QNetworkAccessManager::DeleteOperation) {
runDeleteRequest(request); runDeleteRequest(request);
} }
} }
else { else {
// No redirection is indicated. Final file is obtained in our "reply" object. // No redirection is indicated. Final file is obtained in our "reply" object.
// Read the data into output buffer. // 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("protected", m_targetProtected);
m_activeReply->setProperty("username", m_targetUsername); m_activeReply->setProperty("username", m_targetUsername);
m_activeReply->setProperty("password", m_targetPassword); m_activeReply->setProperty("password", m_targetPassword);
connect(m_activeReply, &QNetworkReply::downloadProgress, this, &Downloader::progressInternal); connect(m_activeReply, &QNetworkReply::downloadProgress, this, &Downloader::progressInternal);
connect(m_activeReply, &QNetworkReply::finished, this, &Downloader::finished); connect(m_activeReply, &QNetworkReply::finished, this, &Downloader::finished);
} }

View File

@ -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_lblInfoDownload->setText(tr("Error when saving file: %1").arg(m_output.errorString()));
m_ui->m_btnStopDownload->click(); m_ui->m_btnStopDownload->click();
} }
else { else {
m_startedSaving = true; m_startedSaving = true;
@ -344,7 +343,6 @@ double DownloadItem::currentSpeed() const {
if (!downloading()) { if (!downloading()) {
return -1.0; return -1.0;
} }
else { else {
return m_bytesReceived * 1000.0 / m_downloadTime.elapsed(); return m_bytesReceived * 1000.0 / m_downloadTime.elapsed();
} }
@ -373,12 +371,10 @@ void DownloadItem::updateDownloadInfoLabel() {
DownloadManager::dataString((int)speed), DownloadManager::dataString((int)speed),
remaining); remaining);
} }
else { else {
if (m_bytesReceived == bytes_total) { if (m_bytesReceived == bytes_total) {
info = DownloadManager::dataString(m_output.size()); info = DownloadManager::dataString(m_output.size());
} }
else { else {
info = tr("%1 of %2 - download completed").arg(DownloadManager::dataString(m_bytesReceived), info = tr("%1 of %2 - download completed").arg(DownloadManager::dataString(m_bytesReceived),
DownloadManager::dataString(m_bytesReceived)); DownloadManager::dataString(m_bytesReceived));
@ -416,9 +412,9 @@ void DownloadItem::finished() {
if (downloadedSuccessfully()) { if (downloadedSuccessfully()) {
qApp->showGuiMessage(tr("Download finished"), qApp->showGuiMessage(tr("Download finished"),
tr("File '%1' is downloaded.\nClick here to open parent directory.").arg(QDir::toNativeSeparators(m_output.fileName())), tr("File '%1' is downloaded.\nClick here to open parent directory.").arg(QDir::toNativeSeparators(m_output.fileName())),
QSystemTrayIcon::Information, 0, false, [this] { QSystemTrayIcon::Information, 0, false, [this] {
openFolder(); openFolder();
}); });
} }
} }
@ -474,7 +470,6 @@ int DownloadManager::downloadProgress() const {
if (bytes_total <= 0) { if (bytes_total <= 0) {
return -1; return -1;
} }
else { else {
return (bytes_received * 100.0) / bytes_total; return (bytes_received * 100.0) / bytes_total;
} }
@ -552,7 +547,6 @@ void DownloadManager::itemProgress() {
if (progress < 0) { if (progress < 0) {
emit downloadFinished(); emit downloadFinished();
} }
else { else {
emit downloadProgressed(progress, tr("Downloading %n file(s)...", "", activeDownloads())); emit downloadProgressed(progress, tr("Downloading %n file(s)...", "", activeDownloads()));
} }
@ -688,7 +682,6 @@ QString DownloadManager::timeString(double time_remaining) {
time_remaining = floor(time_remaining); time_remaining = floor(time_remaining);
remaining = tr("%n minutes remaining", "", (int) time_remaining); remaining = tr("%n minutes remaining", "", (int) time_remaining);
} }
else { else {
time_remaining = floor(time_remaining); time_remaining = floor(time_remaining);
remaining = tr("%n seconds remaining", "", (int) time_remaining); remaining = tr("%n seconds remaining", "", (int) time_remaining);
@ -705,17 +698,14 @@ QString DownloadManager::dataString(qint64 size) {
new_size = size; new_size = size;
unit = tr("bytes"); unit = tr("bytes");
} }
else if (size < 1024 * 1024) { else if (size < 1024 * 1024) {
new_size = (double)size / (double)1024; new_size = (double)size / (double)1024;
unit = tr("kB"); unit = tr("kB");
} }
else if (size < 1024 * 1024 * 1024) { else if (size < 1024 * 1024 * 1024) {
new_size = (double)size / (double)(1024 * 1024); new_size = (double)size / (double)(1024 * 1024);
unit = tr("MB"); unit = tr("MB");
} }
else { else {
new_size = (double)size / (double)(1024 * 1024 * 1024); new_size = (double)size / (double)(1024 * 1024 * 1024);
unit = tr("GB"); unit = tr("GB");

View File

@ -47,7 +47,6 @@ QStringList NetworkFactory::extractFeedLinksFromHtmlPage(const QUrl& url, const
if (feed_link.startsWith(QL1S("//"))) { if (feed_link.startsWith(QL1S("//"))) {
feed_link = QString(URI_SCHEME_HTTP) + feed_link.mid(2); feed_link = QString(URI_SCHEME_HTTP) + feed_link.mid(2);
} }
else if (feed_link.startsWith(QL1C('/'))) { else if (feed_link.startsWith(QL1C('/'))) {
feed_link = url.toString(QUrl::RemovePath | QUrl::RemoveQuery | QUrl::StripTrailingSlash) + feed_link; feed_link = url.toString(QUrl::RemovePath | QUrl::RemoveQuery | QUrl::StripTrailingSlash) + feed_link;
} }

View File

@ -43,7 +43,6 @@ void RssGuardSchemeHandler::requestStarted(QWebEngineUrlRequestJob* job) {
else { else {
QBuffer* buf = new QBuffer(job); QBuffer* buf = new QBuffer(job);
buf->setData(data); buf->setData(data);
job->reply(QByteArray("text/html"), buf); job->reply(QByteArray("text/html"), buf);
} }
} }
@ -53,10 +52,8 @@ QByteArray RssGuardSchemeHandler::targetData(const QUrl& url) {
if (url_string.contains(QSL(ADBLOCK_ADBLOCKED_PAGE))) { if (url_string.contains(QSL(ADBLOCK_ADBLOCKED_PAGE))) {
QUrlQuery query(url); QUrlQuery query(url);
const QString& subscription = query.queryItemValue(QSL("subscription")); const QString& subscription = query.queryItemValue(QSL("subscription"));
const QString& rule = query.queryItemValue(QSL("rule")); const QString& rule = query.queryItemValue(QSL("rule"));
return qApp->skins()->adBlockedPage(subscription, rule).toUtf8(); return qApp->skins()->adBlockedPage(subscription, rule).toUtf8();
} }
else { else {

View File

@ -47,7 +47,6 @@ void SilentNetworkAccessManager::onAuthenticationRequired(QNetworkReply* reply,
reply->setProperty("authentication-given", true); reply->setProperty("authentication-given", true);
qDebug("Item '%s' requested authentication and got it.", qPrintable(reply->url().toString())); qDebug("Item '%s' requested authentication and got it.", qPrintable(reply->url().toString()));
} }
else { else {
reply->setProperty("authentication-given", false); reply->setProperty("authentication-given", false);
// Authentication is required but this feed does not contain it. // Authentication is required but this feed does not contain it.

View File

@ -54,7 +54,6 @@ bool WebFactory::sendMessageViaEmail(const Message& message) {
return QProcess::startDetached(QString("\"") + browser + QSL("\" ") + arguments.arg(message.m_title, return QProcess::startDetached(QString("\"") + browser + QSL("\" ") + arguments.arg(message.m_title,
stripTags(message.m_contents))); stripTags(message.m_contents)));
} }
else { else {
// Send it via mailto protocol. // Send it via mailto protocol.
// NOTE: http://en.wikipedia.org/wiki/Mailto // NOTE: http://en.wikipedia.org/wiki/Mailto
@ -77,7 +76,6 @@ bool WebFactory::openUrlInExternalBrowser(const QString& url) {
return result; return result;
} }
else { else {
return QDesktopServices::openUrl(url); return QDesktopServices::openUrl(url);
} }
@ -145,7 +143,6 @@ QAction* WebFactory::engineSettingsAction() {
if (m_engineSettings == nullptr) { if (m_engineSettings == nullptr) {
m_engineSettings = new QAction(qApp->icons()->fromTheme(QSL("applications-internet")), tr("Web engine settings"), this); m_engineSettings = new QAction(qApp->icons()->fromTheme(QSL("applications-internet")), tr("Web engine settings"), this);
m_engineSettings->setMenu(new QMenu()); m_engineSettings->setMenu(new QMenu());
createMenu(m_engineSettings->menu()); createMenu(m_engineSettings->menu());
connect(m_engineSettings->menu(), SIGNAL(aboutToShow()), this, SLOT(createMenu())); connect(m_engineSettings->menu(), SIGNAL(aboutToShow()), this, SLOT(createMenu()));
} }
@ -163,7 +160,6 @@ void WebFactory::createMenu(QMenu* menu) {
} }
menu->clear(); menu->clear();
QList<QAction*> actions; QList<QAction*> actions;
actions << createEngineSettingsAction(tr("Auto-load images"), QWebEngineSettings::AutoLoadImages); actions << createEngineSettingsAction(tr("Auto-load images"), QWebEngineSettings::AutoLoadImages);
actions << createEngineSettingsAction(tr("JS enabled"), QWebEngineSettings::JavascriptEnabled); 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("Accelerate 2D canvas"), QWebEngineSettings::Accelerated2dCanvasEnabled);
actions << createEngineSettingsAction(tr("Print element backgrounds"), QWebEngineSettings::PrintElementBackgrounds); actions << createEngineSettingsAction(tr("Print element backgrounds"), QWebEngineSettings::PrintElementBackgrounds);
actions << createEngineSettingsAction(tr("Allow running insecure content"), QWebEngineSettings::AllowRunningInsecureContent); actions << createEngineSettingsAction(tr("Allow running insecure content"), QWebEngineSettings::AllowRunningInsecureContent);
#if !defined(Q_OS_LINUX) #if !defined(Q_OS_LINUX)
actions << createEngineSettingsAction(tr("Allow geolocation on insecure origins"), QWebEngineSettings::AllowGeolocationOnInsecureOrigins); actions << createEngineSettingsAction(tr("Allow geolocation on insecure origins"), QWebEngineSettings::AllowGeolocationOnInsecureOrigins);
#endif #endif
menu->addActions(actions); menu->addActions(actions);
} }
void WebFactory::webEngineSettingChanged(bool enabled) { void WebFactory::webEngineSettingChanged(bool enabled) {
const QAction* const act = qobject_cast<QAction*>(sender()); const QAction* const act = qobject_cast<QAction*>(sender());
QWebEngineSettings::WebAttribute attribute = static_cast<QWebEngineSettings::WebAttribute>(act->data().toInt()); QWebEngineSettings::WebAttribute attribute = static_cast<QWebEngineSettings::WebAttribute>(act->data().toInt());
qApp->settings()->setValue(WebEngineAttributes::ID, QString::number(static_cast<int>(attribute)), enabled); qApp->settings()->setValue(WebEngineAttributes::ID, QString::number(static_cast<int>(attribute)), enabled);
QWebEngineProfile::defaultProfile()->settings()->setAttribute(attribute, act->isChecked()); QWebEngineProfile::defaultProfile()->settings()->setAttribute(attribute, act->isChecked());
} }
QAction* WebFactory::createEngineSettingsAction(const QString& title, QWebEngineSettings::WebAttribute attribute) { QAction* WebFactory::createEngineSettingsAction(const QString& title, QWebEngineSettings::WebAttribute attribute) {
QAction* act = new QAction(title, m_engineSettings->menu()); QAction* act = new QAction(title, m_engineSettings->menu());
act->setData(attribute); act->setData(attribute);
act->setCheckable(true); act->setCheckable(true);
act->setChecked(qApp->settings()->value(WebEngineAttributes::ID, QString::number(static_cast<int>(attribute)), true).toBool()); act->setChecked(qApp->settings()->value(WebEngineAttributes::ID, QString::number(static_cast<int>(attribute)), true).toBool());
QWebEngineProfile::defaultProfile()->settings()->setAttribute(attribute, act->isChecked()); QWebEngineProfile::defaultProfile()->settings()->setAttribute(attribute, act->isChecked());
connect(act, &QAction::toggled, this, &WebFactory::webEngineSettingChanged); connect(act, &QAction::toggled, this, &WebFactory::webEngineSettingChanged);
return act; return act;
} }
#endif #endif

View File

@ -42,24 +42,19 @@ void WebPage::javaScriptAlert(const QUrl& securityOrigin, const QString& msg) {
if (action == QSL("read")) { if (action == QSL("read")) {
emit messageStatusChangeRequested(message_id, MarkRead); emit messageStatusChangeRequested(message_id, MarkRead);
} }
else if (action == QSL("unread")) { else if (action == QSL("unread")) {
emit messageStatusChangeRequested(message_id, MarkUnread); emit messageStatusChangeRequested(message_id, MarkUnread);
} }
else if (action == QSL("starred")) { else if (action == QSL("starred")) {
emit messageStatusChangeRequested(message_id, MarkStarred); emit messageStatusChangeRequested(message_id, MarkStarred);
} }
else if (action == QSL("unstarred")) { else if (action == QSL("unstarred")) {
emit messageStatusChangeRequested(message_id, MarkUnstarred); emit messageStatusChangeRequested(message_id, MarkUnstarred);
} }
else { else {
QWebEnginePage::javaScriptAlert(securityOrigin, msg); QWebEnginePage::javaScriptAlert(securityOrigin, msg);
} }
} }
else { else {
QWebEnginePage::javaScriptAlert(securityOrigin, msg); QWebEnginePage::javaScriptAlert(securityOrigin, msg);
} }

View File

@ -74,7 +74,6 @@ Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) {
return 0; return 0;
} }
} }
else { else {
QT_WA({ mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, QT_WA({ mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
{ mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); }); { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); });
@ -159,7 +158,6 @@ bool QtLockedFile::lock(LockMode mode, bool block) {
rmutex = 0; rmutex = 0;
ok = false; ok = false;
} }
else if (!rmutex) { else if (!rmutex) {
rmutex = getMutexHandle(idx, true); rmutex = getMutexHandle(idx, true);
@ -179,7 +177,6 @@ bool QtLockedFile::lock(LockMode mode, bool block) {
return false; return false;
} }
} }
else { else {
Q_ASSERT(rmutexes.isEmpty()); Q_ASSERT(rmutexes.isEmpty());
@ -226,7 +223,6 @@ bool QtLockedFile::unlock() {
CloseHandle(rmutex); CloseHandle(rmutex);
rmutex = 0; rmutex = 0;
} }
else { else {
foreach (Qt::HANDLE mutex, rmutexes) { foreach (Qt::HANDLE mutex, rmutexes) {
ReleaseMutex(mutex); ReleaseMutex(mutex);

View File

@ -280,7 +280,6 @@ void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessag
if (activateOnMessage) { if (activateOnMessage) {
connect(peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::activateWindow); connect(peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::activateWindow);
} }
else { else {
disconnect(peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::activateWindow); disconnect(peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::activateWindow);
} }

View File

@ -33,7 +33,6 @@ RootItem* AccountCheckModel::itemForIndex(const QModelIndex& index) const {
if (index.isValid() && index.model() == this) { if (index.isValid() && index.model() == this) {
return static_cast<RootItem*>(index.internalPointer()); return static_cast<RootItem*>(index.internalPointer());
} }
else { else {
return m_rootItem; return m_rootItem;
} }
@ -82,7 +81,6 @@ QModelIndex AccountCheckModel::index(int row, int column, const QModelIndex& par
if (child_item) { if (child_item) {
return createIndex(row, column, child_item); return createIndex(row, column, child_item);
} }
else { else {
return QModelIndex(); return QModelIndex();
} }
@ -112,7 +110,6 @@ QModelIndex AccountCheckModel::indexForItem(RootItem* item) const {
// We found our item. // We found our item.
return index(candidate_index, 0, active_index); return index(candidate_index, 0, active_index);
} }
else { else {
// Item is not found, add all "categories" from active_item. // Item is not found, add all "categories" from active_item.
for (int i = 0; i < row_count; i++) { for (int i = 0; i < row_count; i++) {
@ -140,7 +137,6 @@ QModelIndex AccountCheckModel::parent(const QModelIndex& child) const {
if (parent_item == m_rootItem) { if (parent_item == m_rootItem) {
return QModelIndex(); return QModelIndex();
} }
else { else {
return createIndex(parent_item->row(), 0, parent_item); return createIndex(parent_item->row(), 0, parent_item);
} }
@ -150,14 +146,12 @@ int AccountCheckModel::rowCount(const QModelIndex& parent) const {
if (parent.column() > 0) { if (parent.column() > 0) {
return 0; return 0;
} }
else { else {
RootItem* item = itemForIndex(parent); RootItem* item = itemForIndex(parent);
if (item != nullptr) { if (item != nullptr) {
return item->childCount(); return item->childCount();
} }
else { else {
return 0; return 0;
} }
@ -180,12 +174,10 @@ QVariant AccountCheckModel::data(const QModelIndex& index, int role) const {
if (m_checkStates.contains(item)) { if (m_checkStates.contains(item)) {
return m_checkStates.value(item); return m_checkStates.value(item);
} }
else { else {
return static_cast<int>(Qt::Unchecked); return static_cast<int>(Qt::Unchecked);
} }
} }
else if (role == Qt::DecorationRole) { else if (role == Qt::DecorationRole) {
switch (item->kind()) { switch (item->kind()) {
case RootItemKind::Category: case RootItemKind::Category:
@ -197,7 +189,6 @@ QVariant AccountCheckModel::data(const QModelIndex& index, int role) const {
return QVariant(); return QVariant();
} }
} }
else if (role == Qt::DisplayRole) { else if (role == Qt::DisplayRole) {
switch (item->kind()) { switch (item->kind()) {
case RootItemKind::Category: case RootItemKind::Category:
@ -210,7 +201,6 @@ QVariant AccountCheckModel::data(const QModelIndex& index, int role) const {
return item->title(); return item->title();
} }
} }
else { else {
return QVariant(); return QVariant();
} }

View File

@ -37,7 +37,6 @@ void Category::updateCounts(bool including_total_count) {
if (child->kind() == RootItemKind::Feed) { if (child->kind() == RootItemKind::Feed) {
feeds.append(child->toFeed()); feeds.append(child->toFeed());
} }
else if (child->kind() != RootItemKind::Category && child->kind() != RootItemKind::ServiceRoot) { else if (child->kind() != RootItemKind::Category && child->kind() != RootItemKind::ServiceRoot) {
child->updateCounts(including_total_count); child->updateCounts(including_total_count);
} }

View File

@ -55,7 +55,6 @@ QVariant Feed::data(int column, int role) const {
description().isEmpty() ? QString() : QString('\n') + description(), description().isEmpty() ? QString() : QString('\n') + description(),
getAutoUpdateStatusDescription()); getAutoUpdateStatusDescription());
} }
else { else {
return RootItem::data(column, role); return RootItem::data(column, role);
} }

View File

@ -77,7 +77,6 @@ int FormFeedDetails::addEditFeed(Feed* input_feed, RootItem* parent_to_select, c
if (parent_to_select->kind() == RootItemKind::Category) { if (parent_to_select->kind() == RootItemKind::Category) {
m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select))); m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select)));
} }
else if (parent_to_select->kind() == RootItemKind::Feed) { else if (parent_to_select->kind() == RootItemKind::Feed) {
int target_item = m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select->parent())); 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()) { if (!url.isEmpty()) {
m_ui->m_txtUrl->lineEdit()->setText(url); m_ui->m_txtUrl->lineEdit()->setText(url);
} }
else if (Application::clipboard()->mimeData()->hasText()) { else if (Application::clipboard()->mimeData()->hasText()) {
m_ui->m_txtUrl->lineEdit()->setText(Application::clipboard()->text()); m_ui->m_txtUrl->lineEdit()->setText(Application::clipboard()->text());
} }
} }
else { else {
// User is editing existing category. // User is editing existing category.
setWindowTitle(tr("Edit feed '%1'").arg(input_feed->title())); 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) { if (new_title.simplified().size() >= MIN_CATEGORY_NAME_LENGTH) {
m_ui->m_txtTitle->setStatus(LineEditWithStatus::Ok, tr("Feed name is ok.")); m_ui->m_txtTitle->setStatus(LineEditWithStatus::Ok, tr("Feed name is ok."));
} }
else { else {
m_ui->m_txtTitle->setStatus(LineEditWithStatus::Error, tr("Feed name is too short.")); 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()) { if (new_description.simplified().isEmpty()) {
m_ui->m_txtDescription->setStatus(LineEditWithStatus::Warning, tr("Description is empty.")); m_ui->m_txtDescription->setStatus(LineEditWithStatus::Warning, tr("Description is empty."));
} }
else { else {
m_ui->m_txtDescription->setStatus(LineEditWithStatus::Ok, tr("The description is ok.")); 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. // New url is well-formed.
m_ui->m_txtUrl->setStatus(LineEditWithStatus::Ok, tr("The URL is ok.")); m_ui->m_txtUrl->setStatus(LineEditWithStatus::Ok, tr("The URL is ok."));
} }
else if (!new_url.simplified().isEmpty()) { else if (!new_url.simplified().isEmpty()) {
// New url is not well-formed but is not empty on the other hand. // New url is not well-formed but is not empty on the other hand.
m_ui->m_txtUrl->setStatus(LineEditWithStatus::Warning, m_ui->m_txtUrl->setStatus(LineEditWithStatus::Warning,
tr("The URL does not meet standard pattern. Does your URL start with \"http://\" or \"https://\" prefix.")); tr("The URL does not meet standard pattern. Does your URL start with \"http://\" or \"https://\" prefix."));
} }
else { else {
// New url is empty. // New url is empty.
m_ui->m_txtUrl->setStatus(LineEditWithStatus::Error, tr("The 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) { if (encoding_index >= 0) {
m_ui->m_cmbEncoding->setCurrentIndex(encoding_index); m_ui->m_cmbEncoding->setCurrentIndex(encoding_index);
} }
else { else {
m_ui->m_cmbEncoding->setCurrentIndex(m_ui->m_cmbEncoding->findText(DEFAULT_FEED_ENCODING, m_ui->m_cmbEncoding->setCurrentIndex(m_ui->m_cmbEncoding->findText(DEFAULT_FEED_ENCODING,
Qt::MatchFixedString)); Qt::MatchFixedString));
@ -241,7 +233,6 @@ void FormFeedDetails::guessFeed() {
tr("All metadata fetched successfully."), tr("All metadata fetched successfully."),
tr("Feed and icon metadata fetched.")); tr("Feed and icon metadata fetched."));
} }
else { else {
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Warning, m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Warning,
tr("Result: %1.").arg(NetworkFactory::networkErrorText(result.second)), tr("Result: %1.").arg(NetworkFactory::networkErrorText(result.second)),
@ -251,7 +242,6 @@ void FormFeedDetails::guessFeed() {
// Remove temporary feed object. // Remove temporary feed object.
delete result.first; delete result.first;
} }
else { else {
// No feed guessed, even no icon available. // No feed guessed, even no icon available.
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Error, m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Error,
@ -274,7 +264,6 @@ void FormFeedDetails::guessIconOnly() {
tr("Icon fetched successfully."), tr("Icon fetched successfully."),
tr("Icon metadata fetched.")); tr("Icon metadata fetched."));
} }
else { else {
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Warning, m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Warning,
tr("Result: %1.").arg(NetworkFactory::networkErrorText(result.second)), tr("Result: %1.").arg(NetworkFactory::networkErrorText(result.second)),
@ -284,7 +273,6 @@ void FormFeedDetails::guessIconOnly() {
// Remove temporary feed object. // Remove temporary feed object.
delete result.first; delete result.first;
} }
else { else {
// No feed guessed, even no icon available. // No feed guessed, even no icon available.
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Error, m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Error,

View File

@ -102,7 +102,6 @@ bool RecycleBin::markAsReadUnread(RootItem::ReadStatus status) {
parent_root->requestReloadMessageList(status == RootItem::Read); parent_root->requestReloadMessageList(status == RootItem::Read);
return true; return true;
} }
else { else {
return false; return false;
} }
@ -118,7 +117,6 @@ bool RecycleBin::cleanMessages(bool clear_only_read) {
parent_root->requestReloadMessageList(true); parent_root->requestReloadMessageList(true);
return true;; return true;;
} }
else { else {
return false; return false;
} }
@ -138,7 +136,6 @@ bool RecycleBin::restore() {
parent_root->requestReloadMessageList(true); parent_root->requestReloadMessageList(true);
return true; return true;
} }
else { else {
return false; return false;
} }

View File

@ -121,7 +121,6 @@ int RootItem::row() const {
if (m_parentItem) { if (m_parentItem) {
return m_parentItem->m_childItems.indexOf(const_cast<RootItem*>(this)); return m_parentItem->m_childItems.indexOf(const_cast<RootItem*>(this));
} }
else { else {
// This item has no parent. Therefore, its row index is 0. // This item has no parent. Therefore, its row index is 0.
return 0; return 0;
@ -137,12 +136,10 @@ QVariant RootItem::data(int column, int role) const {
if (column == FDS_MODEL_TITLE_INDEX) { if (column == FDS_MODEL_TITLE_INDEX) {
return m_title; return m_title;
} }
else if (column == FDS_MODEL_COUNTS_INDEX) { else if (column == FDS_MODEL_COUNTS_INDEX) {
//: Tooltip for "unread" column of feed list. //: Tooltip for "unread" column of feed list.
return tr("%n unread message(s).", 0, countOfUnreadMessages()); return tr("%n unread message(s).", 0, countOfUnreadMessages());
} }
else { else {
return QVariant(); return QVariant();
} }
@ -151,11 +148,9 @@ QVariant RootItem::data(int column, int role) const {
if (column == FDS_MODEL_TITLE_INDEX) { if (column == FDS_MODEL_TITLE_INDEX) {
return m_title; return m_title;
} }
else if (column == FDS_MODEL_COUNTS_INDEX) { else if (column == FDS_MODEL_COUNTS_INDEX) {
return countOfUnreadMessages(); return countOfUnreadMessages();
} }
else { else {
return QVariant(); return QVariant();
} }
@ -167,7 +162,6 @@ QVariant RootItem::data(int column, int role) const {
if (column == FDS_MODEL_TITLE_INDEX) { if (column == FDS_MODEL_TITLE_INDEX) {
return m_title; return m_title;
} }
else if (column == FDS_MODEL_COUNTS_INDEX) { else if (column == FDS_MODEL_COUNTS_INDEX) {
int count_all = countOfAllMessages(); int count_all = countOfAllMessages();
int count_unread = countOfUnreadMessages(); 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_UNREAD_COUNTS, count_unread < 0 ? QSL("-") : QString::number(count_unread))
.replace(PLACEHOLDER_ALL_COUNTS, count_all < 0 ? QSL("-") : QString::number(count_all)); .replace(PLACEHOLDER_ALL_COUNTS, count_all < 0 ? QSL("-") : QString::number(count_all));
} }
else { else {
return QVariant(); return QVariant();
} }
@ -184,7 +177,6 @@ QVariant RootItem::data(int column, int role) const {
if (column == FDS_MODEL_TITLE_INDEX) { if (column == FDS_MODEL_TITLE_INDEX) {
return icon(); return icon();
} }
else { else {
return QVariant(); return QVariant();
} }
@ -193,7 +185,6 @@ QVariant RootItem::data(int column, int role) const {
if (column == FDS_MODEL_COUNTS_INDEX) { if (column == FDS_MODEL_COUNTS_INDEX) {
return Qt::AlignCenter; return Qt::AlignCenter;
} }
else { else {
return QVariant(); return QVariant();
} }
@ -233,7 +224,6 @@ bool RootItem::isChildOf(const RootItem* root) const {
if (root->childItems().contains(const_cast<RootItem* const>(this_item))) { if (root->childItems().contains(const_cast<RootItem* const>(this_item))) {
return true; return true;
} }
else { else {
this_item = this_item->parent(); this_item = this_item->parent();
} }
@ -246,7 +236,6 @@ bool RootItem::isParentOf(const RootItem* child) const {
if (child == nullptr) { if (child == nullptr) {
return false; return false;
} }
else { else {
return child->isChildOf(this); return child->isChildOf(this);
} }
@ -369,7 +358,6 @@ ServiceRoot* RootItem::getParentServiceRoot() const {
if (working_parent->kind() == RootItemKind::ServiceRoot) { if (working_parent->kind() == RootItemKind::ServiceRoot) {
return working_parent->toServiceRoot(); return working_parent->toServiceRoot();
} }
else { else {
working_parent = working_parent->parent(); working_parent = working_parent->parent();
} }
@ -481,7 +469,6 @@ bool RootItem::removeChild(int index) {
m_childItems.removeAt(index); m_childItems.removeAt(index);
return true; return true;
} }
else { else {
return false; return false;
} }

View File

@ -43,7 +43,6 @@ bool ServiceRoot::deleteViaGui() {
requestItemRemoval(this); requestItemRemoval(this);
return true; return true;
} }
else { else {
return false; return false;
} }
@ -58,7 +57,6 @@ bool ServiceRoot::markAsReadUnread(RootItem::ReadStatus status) {
requestReloadMessageList(status == RootItem::Read); requestReloadMessageList(status == RootItem::Read);
return true; return true;
} }
else { else {
return false; return false;
} }
@ -83,7 +81,6 @@ void ServiceRoot::updateCounts(bool including_total_count) {
if (child->kind() == RootItemKind::Feed) { if (child->kind() == RootItemKind::Feed) {
feeds.append(child->toFeed()); feeds.append(child->toFeed());
} }
else if (child->kind() != RootItemKind::Category && child->kind() != RootItemKind::ServiceRoot) { else if (child->kind() != RootItemKind::Category && child->kind() != RootItemKind::ServiceRoot) {
child->updateCounts(including_total_count); child->updateCounts(including_total_count);
} }
@ -106,7 +103,6 @@ void ServiceRoot::updateCounts(bool including_total_count) {
feed->setCountOfAllMessages(counts.value(feed->customId()).second); feed->setCountOfAllMessages(counts.value(feed->customId()).second);
} }
} }
else { else {
feed->setCountOfUnreadMessages(0); feed->setCountOfUnreadMessages(0);
@ -163,7 +159,6 @@ bool ServiceRoot::cleanFeeds(QList<Feed*> items, bool clean_read_only) {
requestReloadMessageList(true); requestReloadMessageList(true);
return true; return true;
} }
else { else {
return false; return false;
} }
@ -280,7 +275,6 @@ QStringList ServiceRoot::customIDSOfMessagesForItem(RootItem* item) {
// Not item from this account. // Not item from this account.
return QStringList(); return QStringList();
} }
else { else {
QStringList list; QStringList list;
@ -335,7 +329,6 @@ bool ServiceRoot::markFeedsReadUnread(QList<Feed*> items, RootItem::ReadStatus r
requestReloadMessageList(read == RootItem::Read); requestReloadMessageList(read == RootItem::Read);
return true; return true;
} }
else { else {
return false; 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( model->setFilter(QString("Messages.is_deleted = 1 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1").arg(QString::number(
accountId()))); accountId())));
} }
else { else {
QList<Feed*> children = item->getSubTreeFeeds(); QList<Feed*> children = item->getSubTreeFeeds();
QString filter_clause = textualFeedIds(children).join(QSL(", ")); QString filter_clause = textualFeedIds(children).join(QSL(", "));
@ -440,13 +432,11 @@ bool ServiceRoot::onAfterMessagesDelete(RootItem* selected_item, const QList<Mes
if (selected_item->kind() == RootItemKind::Bin) { if (selected_item->kind() == RootItemKind::Bin) {
itemChanged(QList<RootItem*>() << bin); itemChanged(QList<RootItem*>() << bin);
} }
else { else {
if (bin != nullptr) { if (bin != nullptr) {
bin->updateCounts(true); bin->updateCounts(true);
itemChanged(QList<RootItem*>() << selected_item << bin); itemChanged(QList<RootItem*>() << selected_item << bin);
} }
else { else {
itemChanged(QList<RootItem*>() << selected_item); itemChanged(QList<RootItem*>() << selected_item);
} }
@ -477,12 +467,10 @@ void ServiceRoot::assembleFeeds(Assignment feeds) {
// This is top-level feed, add it to the root item. // This is top-level feed, add it to the root item.
appendChild(feed.second); appendChild(feed.second);
} }
else if (categories.contains(feed.first)) { else if (categories.contains(feed.first)) {
// This feed belongs to this category. // This feed belongs to this category.
categories.value(feed.first)->appendChild(feed.second); categories.value(feed.first)->appendChild(feed.second);
} }
else { else {
qWarning("Feed '%s' is loose, skipping it.", qPrintable(feed.second->title())); qWarning("Feed '%s' is loose, skipping it.", qPrintable(feed.second->title()));
} }

View File

@ -101,7 +101,6 @@ void FormEditOwnCloudAccount::performTest() {
MINIMAL_OC_VERSION), MINIMAL_OC_VERSION),
tr("Selected ownCloud News server is running unsupported version.")); tr("Selected ownCloud News server is running unsupported version."));
} }
else { else {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Ok, 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(), 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.")); tr("ownCloud News server is okay."));
} }
} }
else if (factory.lastError() != QNetworkReply::NoError) { else if (factory.lastError() != QNetworkReply::NoError) {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error, m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
tr("Network error: '%1'.").arg(NetworkFactory::networkErrorText(factory.lastError())), tr("Network error: '%1'.").arg(NetworkFactory::networkErrorText(factory.lastError())),
tr("Network error, have you entered correct ownCloud endpoint and password?")); tr("Network error, have you entered correct ownCloud endpoint and password?"));
} }
else { else {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error, m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
tr("Unspecified error, did you enter correct URL?"), tr("Unspecified error, did you enter correct URL?"),
@ -156,7 +153,6 @@ void FormEditOwnCloudAccount::onUsernameChanged() {
if (username.isEmpty()) { if (username.isEmpty()) {
m_ui->m_txtUsername->setStatus(WidgetWithStatus::Error, tr("Username cannot be empty.")); m_ui->m_txtUsername->setStatus(WidgetWithStatus::Error, tr("Username cannot be empty."));
} }
else { else {
m_ui->m_txtUsername->setStatus(WidgetWithStatus::Ok, tr("Username is okay.")); m_ui->m_txtUsername->setStatus(WidgetWithStatus::Ok, tr("Username is okay."));
} }
@ -168,7 +164,6 @@ void FormEditOwnCloudAccount::onPasswordChanged() {
if (password.isEmpty()) { if (password.isEmpty()) {
m_ui->m_txtPassword->setStatus(WidgetWithStatus::Error, tr("Password cannot be empty.")); m_ui->m_txtPassword->setStatus(WidgetWithStatus::Error, tr("Password cannot be empty."));
} }
else { else {
m_ui->m_txtPassword->setStatus(WidgetWithStatus::Ok, tr("Password is okay.")); m_ui->m_txtPassword->setStatus(WidgetWithStatus::Ok, tr("Password is okay."));
} }
@ -180,7 +175,6 @@ void FormEditOwnCloudAccount::onUrlChanged() {
if (url.isEmpty()) { if (url.isEmpty()) {
m_ui->m_txtUrl->setStatus(WidgetWithStatus::Error, tr("URL cannot be empty.")); m_ui->m_txtUrl->setStatus(WidgetWithStatus::Error, tr("URL cannot be empty."));
} }
else { else {
m_ui->m_txtUrl->setStatus(WidgetWithStatus::Ok, tr("URL is okay.")); m_ui->m_txtUrl->setStatus(WidgetWithStatus::Ok, tr("URL is okay."));
} }

View File

@ -47,7 +47,6 @@ void FormOwnCloudFeedDetails::apply() {
m_editableFeed->customId())) { m_editableFeed->customId())) {
qWarning("ownCloud: Došlo k problému při prejmenování kanálu s ownCloud ID '%d'.", m_editableFeed->customId()); qWarning("ownCloud: Došlo k problému při prejmenování kanálu s ownCloud ID '%d'.", m_editableFeed->customId());
} }
else { else {
renamed = true; renamed = true;
} }
@ -65,7 +64,6 @@ void FormOwnCloudFeedDetails::apply() {
QTimer::singleShot(200, m_serviceRoot, SLOT(syncIn())); QTimer::singleShot(200, m_serviceRoot, SLOT(syncIn()));
} }
} }
else { else {
const RootItem* parent = static_cast<RootItem*>(m_ui->m_cmbParentCategory->itemData( const RootItem* parent = static_cast<RootItem*>(m_ui->m_cmbParentCategory->itemData(
m_ui->m_cmbParentCategory->currentIndex()).value<void*>()); m_ui->m_cmbParentCategory->currentIndex()).value<void*>());
@ -79,7 +77,6 @@ void FormOwnCloudFeedDetails::apply() {
qApp->showGuiMessage(tr("Feed added"), tr("Feed was added, triggering sync in now."), QSystemTrayIcon::Information); qApp->showGuiMessage(tr("Feed added"), tr("Feed was added, triggering sync in now."), QSystemTrayIcon::Information);
QTimer::singleShot(100, m_serviceRoot, SLOT(syncIn())); QTimer::singleShot(100, m_serviceRoot, SLOT(syncIn()));
} }
else { else {
reject(); reject();
qApp->showGuiMessage(tr("Cannot add feed"), qApp->showGuiMessage(tr("Cannot add feed"),

View File

@ -52,7 +52,6 @@ void OwnCloudNetworkFactory::setUrl(const QString& url) {
if (url.endsWith('/')) { if (url.endsWith('/')) {
m_fixedUrl = url; m_fixedUrl = url;
} }
else { else {
m_fixedUrl = url + '/'; 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); qWarning("ownCloud: Obtaining of categories failed with error %d.", network_reply.first);
return false; return false;
} }
else { else {
return true; 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); qWarning("ownCloud: Creating of category failed with error %d.", network_reply.first);
return false; return false;
} }
else { else {
return true; 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); qWarning("ownCloud: Renaming of feed failed with error %d.", network_reply.first);
return false; return false;
} }
else { else {
return true; return true;
} }
@ -279,7 +275,6 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::triggerFeedUpdate(int feed_i
if (lastError() != QNetworkReply::NoError) { if (lastError() != QNetworkReply::NoError) {
return lastError(); return lastError();
} }
else { else {
// We have new user ID, set it up. // We have new user ID, set it up.
setUserId(info.userId()); setUserId(info.userId());
@ -314,7 +309,6 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::markMessagesRead(RootItem::R
if (status == RootItem::Read) { if (status == RootItem::Read) {
final_url = m_fixedUrl + API_PATH + "items/read/multiple"; final_url = m_fixedUrl + API_PATH + "items/read/multiple";
} }
else { else {
final_url = m_fixedUrl + API_PATH + "items/unread/multiple"; final_url = m_fixedUrl + API_PATH + "items/unread/multiple";
} }
@ -353,7 +347,6 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::markMessagesStarred(RootItem
if (importance == RootItem::Important) { if (importance == RootItem::Important) {
final_url = m_fixedUrl + API_PATH + "items/star/multiple"; final_url = m_fixedUrl + API_PATH + "items/star/multiple";
} }
else { else {
final_url = m_fixedUrl + API_PATH + "items/unstar/multiple"; final_url = m_fixedUrl + API_PATH + "items/unstar/multiple";
} }
@ -417,7 +410,6 @@ QString OwnCloudUserResponse::displayName() const {
if (isLoaded()) { if (isLoaded()) {
return m_rawContent["displayName"].toString(); return m_rawContent["displayName"].toString();
} }
else { else {
return QString(); return QString();
} }
@ -427,7 +419,6 @@ QString OwnCloudUserResponse::userId() const {
if (isLoaded()) { if (isLoaded()) {
return m_rawContent["userId"].toString(); return m_rawContent["userId"].toString();
} }
else { else {
return QString(); return QString();
} }
@ -437,7 +428,6 @@ QDateTime OwnCloudUserResponse::lastLoginTime() const {
if (isLoaded()) { if (isLoaded()) {
return QDateTime::fromMSecsSinceEpoch(m_rawContent["lastLoginTimestamp"].toDouble()); return QDateTime::fromMSecsSinceEpoch(m_rawContent["lastLoginTimestamp"].toDouble());
} }
else { else {
return QDateTime(); return QDateTime();
} }
@ -468,7 +458,6 @@ QString OwnCloudStatusResponse::version() const {
if (isLoaded()) { if (isLoaded()) {
return m_rawContent["version"].toString(); return m_rawContent["version"].toString();
} }
else { else {
return QString(); return QString();
} }
@ -478,7 +467,6 @@ bool OwnCloudStatusResponse::misconfiguredCron() const {
if (isLoaded()) { if (isLoaded()) {
return m_rawContent["warnings"].toObject()["improperlyConfiguredCron"].toBool(); return m_rawContent["warnings"].toObject()["improperlyConfiguredCron"].toBool();
} }
else { else {
return false; return false;
} }

View File

@ -62,7 +62,6 @@ bool OwnCloudFeed::deleteViaGui() {
serviceRoot()->requestItemRemoval(this); serviceRoot()->requestItemRemoval(this);
return true; return true;
} }
else { else {
return false; return false;
} }
@ -76,7 +75,6 @@ bool OwnCloudFeed::editItself(OwnCloudFeed* new_feed_data) {
// Persistent storage update failed, no way to continue now. // Persistent storage update failed, no way to continue now.
return false; return false;
} }
else { else {
setAutoUpdateType(new_feed_data->autoUpdateType()); setAutoUpdateType(new_feed_data->autoUpdateType());
setAutoUpdateInitialInterval(new_feed_data->autoUpdateInitialInterval()); setAutoUpdateInitialInterval(new_feed_data->autoUpdateInitialInterval());
@ -111,7 +109,6 @@ QList<Message> OwnCloudFeed::obtainNewMessages(bool* error_during_obtaining) {
serviceRoot()->itemChanged(QList<RootItem*>() << this); serviceRoot()->itemChanged(QList<RootItem*>() << this);
return QList<Message>(); return QList<Message>();
} }
else { else {
*error_during_obtaining = false; *error_during_obtaining = false;
return messages.messages(); return messages.messages();

View File

@ -62,7 +62,6 @@ bool OwnCloudServiceRoot::deleteViaGui() {
if (DatabaseQueries::deleteOwnCloudAccount(database, accountId())) { if (DatabaseQueries::deleteOwnCloudAccount(database, accountId())) {
return ServiceRoot::deleteViaGui(); return ServiceRoot::deleteViaGui();
} }
else { else {
return false; return false;
} }
@ -170,7 +169,6 @@ bool OwnCloudServiceRoot::onBeforeSwitchMessageImportance(RootItem* selected_ite
if (pair.second == RootItem::Important) { if (pair.second == RootItem::Important) {
mark_starred_msgs.append(pair.first); mark_starred_msgs.append(pair.first);
} }
else { else {
mark_unstarred_msgs.append(pair.first); mark_unstarred_msgs.append(pair.first);
} }
@ -208,7 +206,6 @@ void OwnCloudServiceRoot::saveAccountDataToDatabase() {
itemChanged(QList<RootItem*>() << this); itemChanged(QList<RootItem*>() << this);
} }
} }
else { else {
bool saved; bool saved;
int id_to_assign = DatabaseQueries::createAccount(database, code(), &saved); int id_to_assign = DatabaseQueries::createAccount(database, code(), &saved);
@ -280,7 +277,6 @@ RootItem* OwnCloudServiceRoot::obtainNewTreeForSyncIn() const {
if (m_network->lastError() == QNetworkReply::NoError) { if (m_network->lastError() == QNetworkReply::NoError) {
return feed_cats_response.feedsCategories(true); return feed_cats_response.feedsCategories(true);
} }
else { else {
return nullptr; return nullptr;
} }

View File

@ -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")))); 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)); qDebug("Adding enclosure '%s' for the message.", qPrintable(new_message.m_enclosures.last().m_url));
} }
else if (attribute.isEmpty() || attribute == QSL("alternate")) { else if (attribute.isEmpty() || attribute == QSL("alternate")) {
last_link_alternate = link.attribute(QSL("href")); last_link_alternate = link.attribute(QSL("href"));
} }
else { else {
last_link_other = link.attribute(QSL("href")); 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()) { if (!last_link_alternate.isEmpty()) {
new_message.m_url = last_link_alternate; new_message.m_url = last_link_alternate;
} }
else if (!last_link_other.isEmpty()) { else if (!last_link_other.isEmpty()) {
new_message.m_url = last_link_other; new_message.m_url = last_link_other;
} }
else if (!new_message.m_enclosures.isEmpty()) { else if (!new_message.m_enclosures.isEmpty()) {
new_message.m_url = new_message.m_enclosures.first().m_url; new_message.m_url = new_message.m_enclosures.first().m_url;
} }

View File

@ -46,7 +46,6 @@ QList<Message> FeedParser::messages() {
messages.append(new_message); messages.append(new_message);
} }
catch (const ApplicationException& ex) { catch (const ApplicationException& ex) {
qDebug(qPrintable(ex.message())); qDebug(qPrintable(ex.message()));
} }

View File

@ -87,7 +87,6 @@ int FormStandardCategoryDetails::addEditCategory(StandardCategory* input_categor
if (parent_to_select->kind() == RootItemKind::Category) { if (parent_to_select->kind() == RootItemKind::Category) {
m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select))); m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select)));
} }
else if (parent_to_select->kind() == RootItemKind::Feed) { else if (parent_to_select->kind() == RootItemKind::Feed) {
int target_item = m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select->parent())); 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 { else {
// User is editing existing category. // User is editing existing category.
setWindowTitle(tr("Edit existing category")); setWindowTitle(tr("Edit existing category"));
@ -122,7 +120,6 @@ void FormStandardCategoryDetails::apply() {
m_serviceRoot->requestItemReassignment(new_category, parent); m_serviceRoot->requestItemReassignment(new_category, parent);
accept(); accept();
} }
else { else {
delete new_category; delete new_category;
qApp->showGuiMessage(tr("Cannot add category"), qApp->showGuiMessage(tr("Cannot add category"),
@ -131,7 +128,6 @@ void FormStandardCategoryDetails::apply() {
qApp->mainFormWidget(), true); qApp->mainFormWidget(), true);
} }
} }
else { else {
new_category->setParent(parent); new_category->setParent(parent);
bool edited = m_editableCategory->editItself(new_category); bool edited = m_editableCategory->editItself(new_category);
@ -140,7 +136,6 @@ void FormStandardCategoryDetails::apply() {
m_serviceRoot->requestItemReassignment(m_editableCategory, new_category->parent()); m_serviceRoot->requestItemReassignment(m_editableCategory, new_category->parent());
accept(); accept();
} }
else { else {
qApp->showGuiMessage(tr("Cannot edit category"), qApp->showGuiMessage(tr("Cannot edit category"),
tr("Category was not edited due to error."), 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_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
m_ui->m_txtTitle->setStatus(WidgetWithStatus::Ok, tr("Category name is ok.")); m_ui->m_txtTitle->setStatus(WidgetWithStatus::Ok, tr("Category name is ok."));
} }
else { else {
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
m_ui->m_txtTitle->setStatus(WidgetWithStatus::Error, tr("Category name is too short.")); 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()) { if (new_description.simplified().isEmpty()) {
m_ui->m_txtDescription->setStatus(LineEditWithStatus::Warning, tr("Description is empty.")); m_ui->m_txtDescription->setStatus(LineEditWithStatus::Warning, tr("Description is empty."));
} }
else { else {
m_ui->m_txtDescription->setStatus(LineEditWithStatus::Ok, tr("The description is ok.")); m_ui->m_txtDescription->setStatus(LineEditWithStatus::Ok, tr("The description is ok."));
} }

View File

@ -51,7 +51,6 @@ void FormStandardFeedDetails::apply() {
m_serviceRoot->requestItemReassignment(new_feed, parent); m_serviceRoot->requestItemReassignment(new_feed, parent);
accept(); accept();
} }
else { else {
delete new_feed; delete new_feed;
qApp->showGuiMessage(tr("Cannot add feed"), qApp->showGuiMessage(tr("Cannot add feed"),
@ -59,7 +58,6 @@ void FormStandardFeedDetails::apply() {
QSystemTrayIcon::Critical, this, true); QSystemTrayIcon::Critical, this, true);
} }
} }
else { else {
new_feed->setParent(parent); new_feed->setParent(parent);
// Edit the feed. // Edit the feed.
@ -69,7 +67,6 @@ void FormStandardFeedDetails::apply() {
m_serviceRoot->requestItemReassignment(m_editableFeed, new_feed->parent()); m_serviceRoot->requestItemReassignment(m_editableFeed, new_feed->parent());
accept(); accept();
} }
else { else {
qApp->showGuiMessage(tr("Cannot edit feed"), qApp->showGuiMessage(tr("Cannot edit feed"),
tr("Feed was not edited due to error."), tr("Feed was not edited due to error."),

View File

@ -129,7 +129,6 @@ void FormStandardImportExport::onParsingFinished(int count_failed, int count_suc
m_ui->m_treeFeeds->setModel(m_model); m_ui->m_treeFeeds->setModel(m_model);
m_ui->m_treeFeeds->expandAll(); m_ui->m_treeFeeds->expandAll();
} }
else { else {
m_ui->m_groupFeeds->setEnabled(false); m_ui->m_groupFeeds->setEnabled(false);
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Error, file is not well-formed. Select another file."), 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"); selected_file += QL1S(".opml");
} }
} }
else if (selected_filter == filter_txt_url_per_line) { else if (selected_filter == filter_txt_url_per_line) {
m_conversionType = TXTUrlPerLine; m_conversionType = TXTUrlPerLine;
@ -195,7 +193,6 @@ void FormStandardImportExport::selectImportFile() {
if (selected_filter == filter_opml20) { if (selected_filter == filter_opml20) {
m_conversionType = OPML20; m_conversionType = OPML20;
} }
else if (selected_filter == filter_txt_url_per_line) { else if (selected_filter == filter_txt_url_per_line) {
m_conversionType = TXTUrlPerLine; m_conversionType = TXTUrlPerLine;
} }
@ -218,7 +215,6 @@ void FormStandardImportExport::parseImportFile(const QString& file_name, bool fe
input_data = input_file.readAll(); input_data = input_file.readAll();
input_file.close(); input_file.close();
} }
else { else {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Cannot open source file."), tr("Cannot open source file.")); m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Cannot open source file."), tr("Cannot open source file."));
return; return;
@ -275,12 +271,10 @@ void FormStandardImportExport::exportFeeds() {
IOFactory::writeTextFile(m_ui->m_lblSelectFile->label()->text(), result_data); 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.")); m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Feeds were exported successfully."), tr("Feeds were exported successfully."));
} }
catch (IOException& ex) { catch (IOException& ex) {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Cannot write into destination file: '%1'."), ex.message()); m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Cannot write into destination file: '%1'."), ex.message());
} }
} }
else { else {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Critical error occurred."), tr("Critical error occurred.")); 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_serviceRoot->requestItemExpand(parent->getSubTree(), true);
m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, output_message, output_message); m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, output_message, output_message);
} }
else { else {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, output_message, output_message); m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, output_message, output_message);
} }

View File

@ -51,14 +51,12 @@ QList<Message> RdfParser::parseXmlData(const QString& data) {
// BOTH title and description are empty, skip this message. // BOTH title and description are empty, skip this message.
continue; continue;
} }
else { else {
// Title is empty but description is not. // Title is empty but description is not.
new_message.m_title = qApp->web()->escapeHtml(qApp->web()->stripTags(elem_description.simplified())); new_message.m_title = qApp->web()->escapeHtml(qApp->web()->stripTags(elem_description.simplified()));
new_message.m_contents = elem_description; new_message.m_contents = elem_description;
} }
} }
else { else {
// Title is really not empty, description does not matter. // Title is really not empty, description does not matter.
new_message.m_title = qApp->web()->escapeHtml(qApp->web()->stripTags(elem_title)); new_message.m_title = qApp->web()->escapeHtml(qApp->web()->stripTags(elem_title));

View File

@ -38,7 +38,6 @@ QDomNodeList RssParser::messageElements() {
if (channel_elem.isNull()) { if (channel_elem.isNull()) {
return QDomNodeList(); return QDomNodeList();
} }
else { else {
return channel_elem.toElement().elementsByTagName(QSL("item")); 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. // BOTH title and description are empty, skip this message.
throw new ApplicationException(QSL("Not enough data for the message.")); throw new ApplicationException(QSL("Not enough data for the message."));
} }
else { else {
// Title is empty but description is not. // Title is empty but description is not.
new_message.m_title = qApp->web()->stripTags(elem_description.simplified()); new_message.m_title = qApp->web()->stripTags(elem_description.simplified());
new_message.m_contents = elem_description; new_message.m_contents = elem_description;
} }
} }
else { else {
// Title is really not empty, description does not matter. // Title is really not empty, description does not matter.
new_message.m_title = qApp->web()->stripTags(elem_title); new_message.m_title = qApp->web()->stripTags(elem_title);

View File

@ -67,7 +67,6 @@ QVariant StandardCategory::data(int column, int role) const {
tr("\nThis category does not contain any nested items.") : tr("\nThis category does not contain any nested items.") :
QString()); QString());
} }
else { else {
return Category::data(column, role); return Category::data(column, role);
} }
@ -91,7 +90,6 @@ bool StandardCategory::performDragDropChange(RootItem* target_item) {
delete category_new; delete category_new;
return true; return true;
} }
else { else {
delete category_new; delete category_new;
return false; return false;
@ -109,7 +107,6 @@ bool StandardCategory::deleteViaGui() {
serviceRoot()->requestItemRemoval(this); serviceRoot()->requestItemRemoval(this);
return true; return true;
} }
else { else {
return false; return false;
} }
@ -132,7 +129,6 @@ bool StandardCategory::removeItself() {
if (child->kind() == RootItemKind::Category) { if (child->kind() == RootItemKind::Category) {
children_removed &= static_cast<StandardCategory*>(child)->removeItself(); children_removed &= static_cast<StandardCategory*>(child)->removeItself();
} }
else if (child->kind() == RootItemKind::Feed) { else if (child->kind() == RootItemKind::Feed) {
children_removed &= static_cast<StandardFeed*>(child)->removeItself(); children_removed &= static_cast<StandardFeed*>(child)->removeItself();
} }
@ -143,7 +139,6 @@ bool StandardCategory::removeItself() {
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
return DatabaseQueries::deleteCategory(database, id()); return DatabaseQueries::deleteCategory(database, id());
} }
else { else {
return false; return false;
} }
@ -158,7 +153,6 @@ bool StandardCategory::addItself(RootItem* parent) {
if (new_id <= 0) { if (new_id <= 0) {
return false; return false;
} }
else { else {
setId(new_id); setId(new_id);
setCustomId(new_id); setCustomId(new_id);
@ -181,7 +175,6 @@ bool StandardCategory::editItself(StandardCategory* new_category_data) {
// Editing is done. // Editing is done.
return true; return true;
} }
else { else {
return false; return false;
} }

Some files were not shown because too many files have changed in this diff Show More