Skip to content

Commit

Permalink
fixed #393
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Rotter committed Jan 18, 2022
1 parent f585667 commit 9c670b8
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 21 deletions.
9 changes: 5 additions & 4 deletions src/librssguard/core/feeddownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,18 @@ void FeedDownloader::synchronizeAccountCaches(const QList<CacheForServiceRoot*>&
void FeedDownloader::updateFeeds(const QList<Feed*>& feeds) {
QMutexLocker locker(m_mutex);

m_results.clear();
m_feeds = feeds;
m_feedsOriginalCount = m_feeds.size();
m_feedsUpdated = 0;

if (feeds.isEmpty()) {
qDebugNN << LOGSEC_FEEDDOWNLOADER << "No feeds to update in worker thread, aborting update.";
}
else {
qDebugNN << LOGSEC_FEEDDOWNLOADER
<< "Starting feed updates from worker in thread: '"
<< QThread::currentThreadId() << "'.";
m_feeds = feeds;
m_feedsOriginalCount = m_feeds.size();
m_results.clear();
m_feedsUpdated = 0;

// Job starts now.
emit updateStarted();
Expand Down
23 changes: 21 additions & 2 deletions src/librssguard/core/feedsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,15 @@ void FeedsModel::setupFonts() {
fon.fromString(qApp->settings()->value(GROUP(Feeds), Feeds::ListFont, Application::font("FeedsView").toString()).toString());

m_normalFont = fon;

m_boldFont = m_normalFont;
m_boldFont.setBold(true);

m_normalStrikedFont = m_normalFont;
m_normalStrikedFont.setStrikeOut(true);

m_boldStrikedFont = m_boldFont;
m_boldStrikedFont.setStrikeOut(true);
}

void FeedsModel::reloadWholeLayout() {
Expand Down Expand Up @@ -566,8 +573,20 @@ bool FeedsModel::markItemCleared(RootItem* item, bool clean_read_only) {

QVariant FeedsModel::data(const QModelIndex& index, int role) const {
switch (role) {
case Qt::ItemDataRole::FontRole:
return itemForIndex(index)->countOfUnreadMessages() > 0 ? m_boldFont : m_normalFont;
case Qt::ItemDataRole::FontRole: {
RootItem* it = itemForIndex(index);
bool is_bold = it->countOfUnreadMessages() > 0;
bool is_striked = it->kind() == RootItem::Kind::Feed
? qobject_cast<Feed*>(it)->isSwitchedOff()
: false;

if (is_bold) {
return is_striked ? m_boldStrikedFont : m_boldFont;
}
else {
return is_striked ? m_normalStrikedFont : m_normalFont;
}
}

case Qt::ItemDataRole::ToolTipRole:
if (!qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::EnableTooltipsFeedsMessages)).toBool()) {
Expand Down
2 changes: 2 additions & 0 deletions src/librssguard/core/feedsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ class RSSGUARD_DLLSPEC FeedsModel : public QAbstractItemModel {
QIcon m_countsIcon;
QFont m_normalFont;
QFont m_boldFont;
QFont m_normalStrikedFont;
QFont m_boldStrikedFont;
};

#endif // FEEDSMODEL_H
10 changes: 9 additions & 1 deletion src/librssguard/miscellaneous/feedreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ QList<ServiceEntryPoint*> FeedReader::feedServices() {
}

void FeedReader::updateFeeds(const QList<Feed*>& feeds) {
auto my_feeds = feeds;

for (int i = 0; i < my_feeds.size(); i++) {
if (my_feeds.at(i)->isSwitchedOff()) {
my_feeds.removeAt(i--);
}
}

if (!qApp->feedUpdateLock()->tryLock()) {
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot fetch articles at this point"),
Expand All @@ -84,7 +92,7 @@ void FeedReader::updateFeeds(const QList<Feed*>& feeds) {

QMetaObject::invokeMethod(m_feedDownloader, "updateFeeds",
Qt::ConnectionType::QueuedConnection,
Q_ARG(QList<Feed*>, feeds));
Q_ARG(QList<Feed*>, my_feeds));
}

void FeedReader::synchronizeMessageData(const QList<CacheForServiceRoot*>& caches) {
Expand Down
2 changes: 2 additions & 0 deletions src/librssguard/services/abstract/gui/formfeeddetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void FormFeedDetails::apply() {
m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
m_feed->setAutoUpdateInitialInterval(int(m_ui->m_spinAutoUpdateInterval->value()));
m_feed->setOpenArticlesDirectly(m_ui->m_cbOpenArticlesAutomatically->isChecked());
m_feed->setIsSwitchedOff(m_ui->m_cbDisableFeed->isChecked());

if (!m_creatingNew) {
// We need to make sure that common data are saved.
Expand Down Expand Up @@ -92,6 +93,7 @@ void FormFeedDetails::loadFeedData() {
m_ui->m_cmbAutoUpdateType->setCurrentIndex(m_ui->m_cmbAutoUpdateType->findData(QVariant::fromValue(int(m_feed->autoUpdateType()))));
m_ui->m_spinAutoUpdateInterval->setValue(m_feed->autoUpdateInitialInterval());
m_ui->m_cbOpenArticlesAutomatically->setChecked(m_feed->openArticlesDirectly());
m_ui->m_cbDisableFeed->setChecked(m_feed->isSwitchedOff());
}

void FormFeedDetails::acceptIfPossible() {
Expand Down
14 changes: 14 additions & 0 deletions src/librssguard/services/abstract/gui/formfeeddetails.ui
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tabMisc">
<attribute name="title">
<string>Miscellaneous</string>
</attribute>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="m_cbDisableFeed">
<property name="text">
<string>Disable this feed</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
Expand Down
14 changes: 0 additions & 14 deletions src/librssguard/services/standard/gui/formstandardfeeddetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,6 @@ void FormStandardFeedDetails::apply() {

try {
DatabaseQueries::createOverwriteFeed(database, std_feed, m_serviceRoot->accountId(), parent->id());

// Feed is added, save cookies.

/*if (std_feed->sourceType() == StandardFeed::SourceType::Url) {
auto cookies = qApp->web()->cookieJar()->extractCookiesFromUrl(std_feed->source());
if (!cookies.isEmpty()) {
qDebugNN << LOGSEC_NETWORK
<< "Detected some cookies in URL"
<< QUOTE_W_SPACE_DOT(std_feed->source());
qApp->web()->cookieJar()->insertCookies(cookies);
}
}*/
}
catch (const ApplicationException& ex) {
qFatal("Cannot save feed: '%s'.", qPrintable(ex.message()));
Expand Down

0 comments on commit 9c670b8

Please sign in to comment.