fix #1267 and some other minor bugs and stuff
This commit is contained in:
parent
2e93bbd688
commit
ea8bac60d6
@ -247,28 +247,6 @@ void FeedDownloader::updateOneFeed(ServiceRoot* acc,
|
||||
msg.sanitize(feed, fix_future_datetimes);
|
||||
}
|
||||
|
||||
if (!feed->addAnyDatetimeArticles()) {
|
||||
QDateTime dt_to_avoid;
|
||||
|
||||
if (feed->datetimeToAvoid().toMSecsSinceEpoch() > 0) {
|
||||
dt_to_avoid = feed->datetimeToAvoid();
|
||||
}
|
||||
else if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::AvoidOldArticles)).toBool()) {
|
||||
dt_to_avoid = qApp->settings()->value(GROUP(Messages), SETTING(Messages::DateTimeToAvoidArticle)).toDateTime();
|
||||
}
|
||||
|
||||
if (dt_to_avoid.isValid()) {
|
||||
for (int i = 0; i < msgs.size(); i++) {
|
||||
const auto& mss = msgs.at(i);
|
||||
|
||||
if (mss.m_createdFromFeed && mss.m_created < dt_to_avoid) {
|
||||
qDebugNN << LOGSEC_CORE << "Removing message" << QUOTE_W_SPACE(mss.m_title) << "for being too old.";
|
||||
msgs.removeAt(i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QMutexLocker lck(&m_mutexDb);
|
||||
|
||||
if (!feed->messageFilters().isEmpty()) {
|
||||
@ -414,6 +392,7 @@ void FeedDownloader::updateOneFeed(ServiceRoot* acc,
|
||||
}
|
||||
|
||||
removeDuplicateMessages(msgs);
|
||||
removeTooOldMessages(feed, msgs);
|
||||
|
||||
tmr.restart();
|
||||
auto updated_messages = acc->updateMessages(msgs, feed, false, nullptr);
|
||||
@ -538,6 +517,43 @@ void FeedDownloader::removeDuplicateMessages(QList<Message>& messages) {
|
||||
}
|
||||
}
|
||||
|
||||
void FeedDownloader::removeTooOldMessages(Feed* feed, QList<Message>& msgs) {
|
||||
if (!feed->addAnyDatetimeArticles()) {
|
||||
QDateTime dt_to_avoid;
|
||||
|
||||
if (feed->datetimeToAvoid().isValid() && feed->datetimeToAvoid().toMSecsSinceEpoch() > 0) {
|
||||
dt_to_avoid = feed->datetimeToAvoid();
|
||||
}
|
||||
else if (feed->hoursToAvoid() > 0) {
|
||||
dt_to_avoid = QDateTime::currentDateTimeUtc().addSecs((feed->hoursToAvoid() * -3600));
|
||||
}
|
||||
else if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::AvoidOldArticles)).toBool()) {
|
||||
QDateTime global_dt_to_avoid =
|
||||
qApp->settings()->value(GROUP(Messages), SETTING(Messages::DateTimeToAvoidArticle)).toDateTime();
|
||||
int global_hours_to_avoid =
|
||||
qApp->settings()->value(GROUP(Messages), SETTING(Messages::HoursToAvoidArticle)).toInt();
|
||||
|
||||
if (global_dt_to_avoid.isValid() && global_dt_to_avoid.toMSecsSinceEpoch() > 0) {
|
||||
dt_to_avoid = global_dt_to_avoid;
|
||||
}
|
||||
else if (global_hours_to_avoid > 0) {
|
||||
dt_to_avoid = QDateTime::currentDateTimeUtc().addSecs(global_hours_to_avoid * -3600);
|
||||
}
|
||||
}
|
||||
|
||||
if (dt_to_avoid.isValid()) {
|
||||
for (int i = 0; i < msgs.size(); i++) {
|
||||
const auto& mss = msgs.at(i);
|
||||
|
||||
if (mss.m_createdFromFeed && mss.m_created < dt_to_avoid) {
|
||||
qDebugNN << LOGSEC_CORE << "Removing message" << QUOTE_W_SPACE(mss.m_title) << "for being too old.";
|
||||
msgs.removeAt(i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString FeedDownloadResults::overview(int how_many_feeds) const {
|
||||
QStringList result;
|
||||
|
||||
|
@ -71,6 +71,7 @@ class FeedDownloader : public QObject {
|
||||
const QHash<QString, QStringList>& tagged_messages);
|
||||
void finalizeUpdate();
|
||||
void removeDuplicateMessages(QList<Message>& messages);
|
||||
void removeTooOldMessages(Feed* feed, QList<Message>& msgs);
|
||||
|
||||
FeedUpdateResult updateThreadedFeed(const FeedUpdateRequest& fd);
|
||||
|
||||
|
@ -2556,7 +2556,9 @@ void DatabaseQueries::createOverwriteFeed(const QSqlDatabase& db, Feed* feed, in
|
||||
q.bindValue(QSL(":is_rtl"), feed->isRtl());
|
||||
q.bindValue(QSL(":add_any_datetime_articles"), feed->addAnyDatetimeArticles());
|
||||
q.bindValue(QSL(":datetime_to_avoid"),
|
||||
feed->datetimeToAvoid().isValid() ? feed->datetimeToAvoid().toMSecsSinceEpoch() : 0);
|
||||
(feed->datetimeToAvoid().isValid() && feed->datetimeToAvoid().toMSecsSinceEpoch() > 0)
|
||||
? feed->datetimeToAvoid().toMSecsSinceEpoch()
|
||||
: feed->hoursToAvoid());
|
||||
|
||||
auto custom_data = feed->customDatabaseData();
|
||||
QString serialized_custom_data = serializeCustomData(custom_data);
|
||||
|
@ -382,7 +382,16 @@ Assignment DatabaseQueries::getFeeds(const QSqlDatabase& db,
|
||||
feed->setIsQuiet(query.value(FDS_DB_IS_QUIET_INDEX).toBool());
|
||||
feed->setIsRtl(query.value(FDS_DB_IS_RTL_INDEX).toBool());
|
||||
feed->setAddAnyDatetimeArticles(query.value(FDS_DB_ADD_ANY_DATETIME_ARTICLES_INDEX).toBool());
|
||||
feed->setDatetimeToAvoid(TextFactory::parseDateTime(query.value(FDS_DB_DATETIME_TO_AVOID_INDEX).value<qint64>()));
|
||||
|
||||
qint64 time_to_avoid = query.value(FDS_DB_DATETIME_TO_AVOID_INDEX).value<qint64>();
|
||||
|
||||
if (time_to_avoid > 10000) {
|
||||
feed->setDatetimeToAvoid(TextFactory::parseDateTime(time_to_avoid));
|
||||
}
|
||||
else {
|
||||
feed->setHoursToAvoid(time_to_avoid);
|
||||
}
|
||||
|
||||
feed->setOpenArticlesDirectly(query.value(FDS_DB_OPEN_ARTICLES_INDEX).toBool());
|
||||
|
||||
qDebugNN << LOGSEC_CORE << "Custom ID of feed when loading from DB is" << QUOTE_W_SPACE_DOT(feed->customId());
|
||||
|
@ -134,10 +134,10 @@ void LibMpvWidget::initializeGL() {
|
||||
}
|
||||
|
||||
void LibMpvWidget::paintGL() {
|
||||
auto scaling_ratio = window()->devicePixelRatio();
|
||||
qreal scaling_ratio = window()->devicePixelRatio();
|
||||
mpv_opengl_fbo mpfbo{static_cast<int>(defaultFramebufferObject()),
|
||||
width() * scaling_ratio,
|
||||
height() * scaling_ratio,
|
||||
int(width() * scaling_ratio),
|
||||
int(height() * scaling_ratio),
|
||||
0};
|
||||
int flip_y{1};
|
||||
|
||||
|
@ -23,21 +23,22 @@ double TimeSpinBox::valueFromText(const QString& text) const {
|
||||
else {
|
||||
static QRegularExpression rx(QSL("\\b[0-9]{1,}\\b"));
|
||||
QStringList numbers;
|
||||
int pos = 0;
|
||||
int count = 0;
|
||||
QRegularExpressionMatchIterator i = rx.globalMatch(text);
|
||||
|
||||
while (i.hasNext()) {
|
||||
numbers.append(i.next().captured());
|
||||
|
||||
if (pos >= 0) {
|
||||
++pos;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
if (numbers.size() == 2) {
|
||||
return (numbers.at(0).toDouble() * 60.0) + numbers.at(1).toDouble();
|
||||
switch (m_mode) {
|
||||
case TimeSpinBox::Mode::DaysHours:
|
||||
return (numbers.at(0).toDouble() * 24.0) + numbers.at(1).toDouble();
|
||||
|
||||
default:
|
||||
case TimeSpinBox::Mode::HoursMinutes:
|
||||
case TimeSpinBox::Mode::MinutesSeconds:
|
||||
return (numbers.at(0).toDouble() * 60.0) + numbers.at(1).toDouble();
|
||||
}
|
||||
}
|
||||
else {
|
||||
return -1.0;
|
||||
@ -46,25 +47,40 @@ double TimeSpinBox::valueFromText(const QString& text) const {
|
||||
}
|
||||
|
||||
QString TimeSpinBox::textFromValue(double val) const {
|
||||
if (mode() == TimeSpinBox::Mode::HoursMinutes) {
|
||||
// "val" is number of minutes.
|
||||
int minutes_total = int(val);
|
||||
int minutes_val = minutes_total % 60;
|
||||
int hours_val = (minutes_total - minutes_val) / 60;
|
||||
QString hours = tr("%n hour(s)", "", hours_val);
|
||||
QString minutes = tr("%n minute(s)", "", minutes_val);
|
||||
switch (m_mode) {
|
||||
case TimeSpinBox::Mode::MinutesSeconds: {
|
||||
// "val" is number of seconds.
|
||||
int seconds_val = int(val);
|
||||
int minutes_total = seconds_val / 60;
|
||||
int seconds_total = seconds_val - (minutes_total * 60);
|
||||
QString seconds = tr("%n second(s)", nullptr, seconds_total);
|
||||
QString minutes = tr("%n minute(s)", nullptr, minutes_total);
|
||||
|
||||
return hours + tr(" and ") + minutes;
|
||||
}
|
||||
else {
|
||||
// "val" is number of seconds.
|
||||
int seconds_val = int(val);
|
||||
int minutes_total = seconds_val / 60;
|
||||
int seconds_total = seconds_val - (minutes_total * 60);
|
||||
QString seconds = tr("%n second(s)", "", seconds_total);
|
||||
QString minutes = tr("%n minute(s)", "", minutes_total);
|
||||
return minutes + tr(" and ") + seconds;
|
||||
}
|
||||
|
||||
return minutes + tr(" and ") + seconds;
|
||||
case TimeSpinBox::Mode::DaysHours: {
|
||||
// "val" is number of hours.
|
||||
int hours_val = int(val);
|
||||
int days_total = hours_val / 24;
|
||||
int hours_total = hours_val - (days_total * 24);
|
||||
QString hours = tr("%n hour(s)", nullptr, hours_total);
|
||||
QString days = tr("%n day(s)", nullptr, days_total);
|
||||
|
||||
return days + tr(" and ") + hours;
|
||||
}
|
||||
|
||||
default:
|
||||
case TimeSpinBox::Mode::HoursMinutes: {
|
||||
// "val" is number of minutes.
|
||||
int minutes_total = int(val);
|
||||
int minutes_val = minutes_total % 60;
|
||||
int hours_val = (minutes_total - minutes_val) / 60;
|
||||
QString hours = tr("%n hour(s)", nullptr, hours_val);
|
||||
QString minutes = tr("%n minute(s)", nullptr, minutes_val);
|
||||
|
||||
return hours + tr(" and ") + minutes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,12 +6,13 @@
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
class TimeSpinBox : public QDoubleSpinBox {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class Mode {
|
||||
HoursMinutes,
|
||||
MinutesSeconds
|
||||
MinutesSeconds,
|
||||
DaysHours
|
||||
};
|
||||
|
||||
explicit TimeSpinBox(QWidget* parent = nullptr);
|
||||
|
@ -22,6 +22,7 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
||||
: SettingsPanel(settings, parent), m_ui(new Ui::SettingsFeedsMessages) {
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->m_spinHoursAvoid->setMode(TimeSpinBox::Mode::DaysHours);
|
||||
m_ui->m_spinAutoUpdateInterval->setMode(TimeSpinBox::Mode::MinutesSeconds);
|
||||
m_ui->m_spinStartupUpdateDelay->setMode(TimeSpinBox::Mode::MinutesSeconds);
|
||||
|
||||
@ -204,6 +205,9 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
||||
|
||||
connect(m_ui->m_gbAvoidOldArticles, &QGroupBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_dtDateTimeToAvoid, &QDateTimeEdit::dateTimeChanged, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_spinHoursAvoid, &TimeSpinBox::valueChanged, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_rbAvoidAbsolute, &QRadioButton::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_rbAvoidAbsolute, &QRadioButton::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
|
||||
m_ui->m_spinRelativeArticleTime->setValue(-1);
|
||||
}
|
||||
@ -274,10 +278,27 @@ void SettingsFeedsMessages::loadSettings() {
|
||||
->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateOnlyUnfocused)).toBool());
|
||||
m_ui->m_spinAutoUpdateInterval->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateInterval)).toInt());
|
||||
m_ui->m_spinFeedUpdateTimeout->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt());
|
||||
|
||||
m_ui->m_dtDateTimeToAvoid->setEnabled(false);
|
||||
m_ui->m_spinHoursAvoid->setEnabled(false);
|
||||
|
||||
QDateTime avoid_dt_barrier =
|
||||
settings()->value(GROUP(Messages), SETTING(Messages::DateTimeToAvoidArticle)).toDateTime();
|
||||
int avoid_hour_barrier = settings()->value(GROUP(Messages), SETTING(Messages::HoursToAvoidArticle)).toInt();
|
||||
|
||||
if (avoid_dt_barrier.isValid() && avoid_dt_barrier.toMSecsSinceEpoch() > 0) {
|
||||
m_ui->m_rbAvoidAbsolute->setChecked(true);
|
||||
m_ui->m_dtDateTimeToAvoid
|
||||
->setDateTime(settings()->value(GROUP(Messages), SETTING(Messages::DateTimeToAvoidArticle)).toDateTime());
|
||||
}
|
||||
else {
|
||||
m_ui->m_rbAvoidRelative->setChecked(true);
|
||||
m_ui->m_spinHoursAvoid->setValue(avoid_hour_barrier);
|
||||
}
|
||||
|
||||
m_ui->m_gbAvoidOldArticles
|
||||
->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::AvoidOldArticles)).toBool());
|
||||
m_ui->m_dtDateTimeToAvoid
|
||||
->setDateTime(settings()->value(GROUP(Messages), SETTING(Messages::DateTimeToAvoidArticle)).toDateTime());
|
||||
|
||||
m_ui->m_cmbFastAutoUpdate->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::FastAutoUpdate)).toBool());
|
||||
m_ui->m_checkUpdateAllFeedsOnStartup
|
||||
->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool());
|
||||
@ -386,8 +407,18 @@ void SettingsFeedsMessages::saveSettings() {
|
||||
settings()->setValue(GROUP(Feeds), Feeds::AutoUpdateOnlyUnfocused, m_ui->m_checkAutoUpdateOnlyUnfocused->isChecked());
|
||||
settings()->setValue(GROUP(Feeds), Feeds::AutoUpdateInterval, m_ui->m_spinAutoUpdateInterval->value());
|
||||
settings()->setValue(GROUP(Feeds), Feeds::UpdateTimeout, m_ui->m_spinFeedUpdateTimeout->value());
|
||||
|
||||
settings()->setValue(GROUP(Messages), Messages::AvoidOldArticles, m_ui->m_gbAvoidOldArticles->isChecked());
|
||||
settings()->setValue(GROUP(Messages), Messages::DateTimeToAvoidArticle, m_ui->m_dtDateTimeToAvoid->dateTime());
|
||||
|
||||
if (m_ui->m_rbAvoidAbsolute->isChecked()) {
|
||||
settings()->setValue(GROUP(Messages), Messages::DateTimeToAvoidArticle, m_ui->m_dtDateTimeToAvoid->dateTime());
|
||||
settings()->setValue(GROUP(Messages), Messages::HoursToAvoidArticle, 0);
|
||||
}
|
||||
else if (m_ui->m_rbAvoidRelative->isChecked()) {
|
||||
settings()->setValue(GROUP(Messages), Messages::DateTimeToAvoidArticle, QDateTime());
|
||||
settings()->setValue(GROUP(Messages), Messages::HoursToAvoidArticle, m_ui->m_spinHoursAvoid->value());
|
||||
}
|
||||
|
||||
settings()->setValue(GROUP(Feeds), Feeds::FastAutoUpdate, m_ui->m_cmbFastAutoUpdate->isChecked());
|
||||
settings()->setValue(GROUP(Feeds), Feeds::FeedsUpdateOnStartup, m_ui->m_checkUpdateAllFeedsOnStartup->isChecked());
|
||||
settings()->setValue(GROUP(Feeds), Feeds::FeedsUpdateStartupDelay, m_ui->m_spinStartupUpdateDelay->value());
|
||||
@ -395,7 +426,9 @@ void SettingsFeedsMessages::saveSettings() {
|
||||
settings()->setValue(GROUP(Feeds), Feeds::EnableTooltipsFeedsMessages, m_ui->m_checkShowTooltips->isChecked());
|
||||
settings()->setValue(GROUP(Messages), Messages::IgnoreContentsChanges, m_ui->m_cmbIgnoreContentsChanges->isChecked());
|
||||
settings()->setValue(GROUP(Messages), Messages::MultilineArticleList, m_ui->m_checkMultilineArticleList->isChecked());
|
||||
settings()->setValue(GROUP(Messages), Messages::LimitArticleImagesHeight, m_ui->m_spinHeightImageAttachments->value());
|
||||
settings()->setValue(GROUP(Messages),
|
||||
Messages::LimitArticleImagesHeight,
|
||||
m_ui->m_spinHeightImageAttachments->value());
|
||||
settings()->setValue(GROUP(Messages),
|
||||
Messages::DisplayEnclosuresInMessage,
|
||||
m_ui->m_cbShowEnclosuresDirectly->isChecked());
|
||||
|
@ -131,17 +131,57 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<item row="0" column="1">
|
||||
<widget class="QDateTimeEdit" name="m_dtDateTimeToAvoid">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumDate">
|
||||
<date>
|
||||
<year>1971</year>
|
||||
<month>1</month>
|
||||
<day>1</day>
|
||||
</date>
|
||||
</property>
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="1" column="1">
|
||||
<widget class="TimeSpinBox" name="m_spinHoursAvoid">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>10000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="m_rbAvoidAbsolute">
|
||||
<property name="text">
|
||||
<string>Absolute date/time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="m_rbAvoidRelative">
|
||||
<property name="text">
|
||||
<string>Relative time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -154,6 +194,19 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -656,17 +709,17 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>TimeSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<header>timespinbox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>HelpSpoiler</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>helpspoiler.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>TimeSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<header>timespinbox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>m_checkUpdateAllFeedsOnStartup</tabstop>
|
||||
@ -706,8 +759,40 @@
|
||||
<tabstop>m_gbFeedListFont</tabstop>
|
||||
<tabstop>m_gbArticleListFont</tabstop>
|
||||
<tabstop>m_gbAvoidOldArticles</tabstop>
|
||||
<tabstop>m_dtDateTimeToAvoid</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>m_rbAvoidAbsolute</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>m_dtDateTimeToAvoid</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>92</x>
|
||||
<y>215</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>326</x>
|
||||
<y>215</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_rbAvoidRelative</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>m_spinHoursAvoid</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>92</x>
|
||||
<y>243</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>326</x>
|
||||
<y>243</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
@ -152,6 +152,9 @@ DVALUE(bool) Messages::AvoidOldArticlesDef = false;
|
||||
DKEY Messages::DateTimeToAvoidArticle = "datetime_to_avoid_article";
|
||||
DVALUE(QDateTime) Messages::DateTimeToAvoidArticleDef = QDateTime::currentDateTime();
|
||||
|
||||
DKEY Messages::HoursToAvoidArticle = "hours_to_avoid_article";
|
||||
DVALUE(int) Messages::HoursToAvoidArticleDef = 0;
|
||||
|
||||
DKEY Messages::AlwaysDisplayItemPreview = "always_display_preview";
|
||||
DVALUE(bool) Messages::AlwaysDisplayItemPreviewDef = true;
|
||||
|
||||
|
@ -149,6 +149,9 @@ namespace Messages {
|
||||
KEY DateTimeToAvoidArticle;
|
||||
VALUE(QDateTime) DateTimeToAvoidArticleDef;
|
||||
|
||||
KEY HoursToAvoidArticle;
|
||||
VALUE(int) HoursToAvoidArticleDef;
|
||||
|
||||
KEY AlwaysDisplayItemPreview;
|
||||
VALUE(bool) AlwaysDisplayItemPreviewDef;
|
||||
|
||||
|
@ -77,5 +77,15 @@ QNetworkReply* BaseNetworkAccessManager::createRequest(QNetworkAccessManager::Op
|
||||
}
|
||||
|
||||
auto reply = QNetworkAccessManager::createRequest(op, new_request, outgoingData);
|
||||
|
||||
auto ssl_conf = reply->sslConfiguration();
|
||||
|
||||
auto aa = ssl_conf.backendConfiguration();
|
||||
|
||||
ssl_conf.setPeerVerifyMode(QSslSocket::PeerVerifyMode::VerifyNone);
|
||||
ssl_conf.setSslOption(QSsl::SslOption::SslOptionDisableLegacyRenegotiation, false);
|
||||
|
||||
reply->setSslConfiguration(ssl_conf);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ Feed::Feed(RootItem* parent)
|
||||
: RootItem(parent), m_source(QString()), m_status(Status::Normal), m_statusString(QString()),
|
||||
m_autoUpdateType(AutoUpdateType::DefaultAutoUpdate), m_autoUpdateInterval(DEFAULT_AUTO_UPDATE_INTERVAL),
|
||||
m_lastUpdated(QDateTime::currentDateTimeUtc()), m_isSwitchedOff(false), m_isQuiet(false),
|
||||
m_openArticlesDirectly(false), m_isRtl(false), m_addAnyDatetimeArticles(false),
|
||||
m_datetimeToAvoid(TextFactory::parseDateTime(0)), m_messageFilters(QList<QPointer<MessageFilter>>()) {
|
||||
m_openArticlesDirectly(false), m_isRtl(false), m_addAnyDatetimeArticles(false), m_datetimeToAvoid(QDateTime()),
|
||||
m_hoursToAvoid(0), m_messageFilters(QList<QPointer<MessageFilter>>()) {
|
||||
setKind(RootItem::Kind::Feed);
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ Feed::Feed(const Feed& other) : RootItem(other) {
|
||||
setOpenArticlesDirectly(other.openArticlesDirectly());
|
||||
setAddAnyDatetimeArticles(other.addAnyDatetimeArticles());
|
||||
setDatetimeToAvoid(other.datetimeToAvoid());
|
||||
setHoursToAvoid(other.hoursToAvoid());
|
||||
setIsRtl(other.isRtl());
|
||||
setIsSwitchedOff(other.isSwitchedOff());
|
||||
setIsQuiet(other.isQuiet());
|
||||
@ -312,6 +313,14 @@ QString Feed::getStatusDescription() const {
|
||||
}
|
||||
}
|
||||
|
||||
int Feed::hoursToAvoid() const {
|
||||
return m_hoursToAvoid;
|
||||
}
|
||||
|
||||
void Feed::setHoursToAvoid(int hours_to_avoid) {
|
||||
m_hoursToAvoid = hours_to_avoid;
|
||||
}
|
||||
|
||||
bool Feed::isQuiet() const {
|
||||
return m_isQuiet;
|
||||
}
|
||||
|
@ -97,6 +97,9 @@ class Feed : public RootItem {
|
||||
QDateTime datetimeToAvoid() const;
|
||||
void setDatetimeToAvoid(const QDateTime& dt);
|
||||
|
||||
int hoursToAvoid() const;
|
||||
void setHoursToAvoid(int hours_to_avoid);
|
||||
|
||||
public slots:
|
||||
virtual void updateCounts(bool including_total_count);
|
||||
|
||||
@ -115,9 +118,14 @@ class Feed : public RootItem {
|
||||
bool m_isQuiet;
|
||||
bool m_openArticlesDirectly;
|
||||
bool m_isRtl;
|
||||
bool m_addAnyDatetimeArticles;
|
||||
|
||||
// NOTE: These are used to filter out older articles
|
||||
// than needed. Either absolute value is given (date/time)
|
||||
// or relative value given in minutes.
|
||||
bool m_addAnyDatetimeArticles;
|
||||
QDateTime m_datetimeToAvoid;
|
||||
int m_hoursToAvoid;
|
||||
|
||||
int m_totalCount{};
|
||||
int m_unreadCount{};
|
||||
QList<QPointer<MessageFilter>> m_messageFilters;
|
||||
|
@ -60,8 +60,20 @@ void FormFeedDetails::apply() {
|
||||
}
|
||||
|
||||
if (isChangeAllowed(m_ui.m_mcbAvoidOldArticles)) {
|
||||
fd->setDatetimeToAvoid(m_ui.m_gbAvoidOldArticles->isChecked() ? m_ui.m_dtDateTimeToAvoid->dateTime()
|
||||
: TextFactory::parseDateTime(0));
|
||||
if (m_ui.m_gbAvoidOldArticles->isChecked()) {
|
||||
if (m_ui.m_rbAvoidAbsolute->isChecked()) {
|
||||
fd->setDatetimeToAvoid(m_ui.m_dtDateTimeToAvoid->dateTime());
|
||||
fd->setHoursToAvoid(0);
|
||||
}
|
||||
else {
|
||||
fd->setDatetimeToAvoid({});
|
||||
fd->setHoursToAvoid(m_ui.m_spinHoursAvoid->value());
|
||||
}
|
||||
}
|
||||
else {
|
||||
fd->setDatetimeToAvoid({});
|
||||
fd->setHoursToAvoid(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (isChangeAllowed(m_ui.m_mcbDisableFeed)) {
|
||||
@ -158,10 +170,20 @@ void FormFeedDetails::loadFeedData() {
|
||||
m_ui.m_cbOpenArticlesAutomatically->setChecked(fd->openArticlesDirectly());
|
||||
m_ui.m_cbFeedRTL->setChecked(fd->isRtl());
|
||||
m_ui.m_cbAddAnyDateArticles->setChecked(fd->addAnyDatetimeArticles());
|
||||
m_ui.m_gbAvoidOldArticles->setChecked(fd->datetimeToAvoid().toMSecsSinceEpoch() > 0);
|
||||
m_ui.m_gbAvoidOldArticles->setChecked((fd->datetimeToAvoid().isValid() &&
|
||||
fd->datetimeToAvoid().toMSecsSinceEpoch() > 0) ||
|
||||
fd->hoursToAvoid() > 0);
|
||||
m_ui.m_dtDateTimeToAvoid->setDateTime(fd->datetimeToAvoid());
|
||||
m_ui.m_spinHoursAvoid->setValue(fd->hoursToAvoid());
|
||||
m_ui.m_cbDisableFeed->setChecked(fd->isSwitchedOff());
|
||||
m_ui.m_cbSuppressFeed->setChecked(fd->isQuiet());
|
||||
|
||||
if (fd->datetimeToAvoid().isValid() && fd->datetimeToAvoid().toMSecsSinceEpoch() > 0) {
|
||||
m_ui.m_rbAvoidAbsolute->setChecked(true);
|
||||
}
|
||||
else {
|
||||
m_ui.m_rbAvoidRelative->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void FormFeedDetails::acceptIfPossible() {
|
||||
@ -183,6 +205,9 @@ void FormFeedDetails::acceptIfPossible() {
|
||||
void FormFeedDetails::initialize() {
|
||||
m_ui.setupUi(this);
|
||||
|
||||
m_ui.m_dtDateTimeToAvoid->setEnabled(false);
|
||||
m_ui.m_spinHoursAvoid->setEnabled(false);
|
||||
m_ui.m_spinHoursAvoid->setMode(TimeSpinBox::Mode::DaysHours);
|
||||
m_ui.m_dtDateTimeToAvoid
|
||||
->setDisplayFormat(qApp->localization()->loadedLocale().dateTimeFormat(QLocale::FormatType::ShortFormat));
|
||||
|
||||
|
@ -125,23 +125,60 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Avoid adding articles before this date into the database</string>
|
||||
<string>Avoid adding articles before this date/time into the database</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<item row="1" column="1">
|
||||
<widget class="QDateTimeEdit" name="m_dtDateTimeToAvoid">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumDate">
|
||||
<date>
|
||||
<year>1971</year>
|
||||
<month>1</month>
|
||||
<day>1</day>
|
||||
</date>
|
||||
</property>
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="m_rbAvoidAbsolute">
|
||||
<property name="text">
|
||||
<string>Absolute date/time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="TimeSpinBox" name="m_spinHoursAvoid">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>10000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="m_rbAvoidRelative">
|
||||
<property name="text">
|
||||
<string>Relative time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -154,6 +191,19 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -266,5 +316,37 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_rbAvoidAbsolute</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>m_dtDateTimeToAvoid</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>112</x>
|
||||
<y>487</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>233</x>
|
||||
<y>487</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_rbAvoidRelative</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>m_spinHoursAvoid</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>112</x>
|
||||
<y>515</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>233</x>
|
||||
<y>515</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
@ -493,7 +493,10 @@ QMap<QString, QVariantMap> ServiceRoot::storeCustomFeedsData() {
|
||||
feed_custom_data.insert(QSL("open_articles_directly"), feed->openArticlesDirectly());
|
||||
feed_custom_data.insert(QSL("is_rtl"), feed->isRtl());
|
||||
feed_custom_data.insert(QSL("add_any_datetime_articles"), feed->addAnyDatetimeArticles());
|
||||
feed_custom_data.insert(QSL("datetime_to_avoid"), feed->datetimeToAvoid().toMSecsSinceEpoch());
|
||||
feed_custom_data.insert(QSL("datetime_to_avoid"),
|
||||
(feed->datetimeToAvoid().isValid() && feed->datetimeToAvoid().toMSecsSinceEpoch() > 0)
|
||||
? feed->datetimeToAvoid().toMSecsSinceEpoch()
|
||||
: feed->hoursToAvoid());
|
||||
|
||||
// NOTE: This is here specifically to be able to restore custom sort order.
|
||||
// Otherwise the information is lost when list of feeds/folders is refreshed from remote
|
||||
@ -545,10 +548,15 @@ void ServiceRoot::restoreCustomFeedsData(const QMap<QString, QVariantMap>& data,
|
||||
feed->setOpenArticlesDirectly(feed_custom_data.value(QSL("open_articles_directly")).toBool());
|
||||
feed->setIsRtl(feed_custom_data.value(QSL("is_rtl")).toBool());
|
||||
feed->setAddAnyDatetimeArticles(feed_custom_data.value(QSL("add_any_datetime_articles")).toBool());
|
||||
feed->setDatetimeToAvoid(TextFactory::parseDateTime(feed_custom_data.value(QSL("datetime_to_avoid"))
|
||||
.value<qint64>()));
|
||||
|
||||
// qDebugNN << feed->datetimeToAvoid().toString();
|
||||
qint64 time_to_avoid = feed_custom_data.value(QSL("datetime_to_avoid")).value<qint64>();
|
||||
|
||||
if (time_to_avoid > 10000) {
|
||||
feed->setDatetimeToAvoid(TextFactory::parseDateTime(time_to_avoid));
|
||||
}
|
||||
else {
|
||||
feed->setHoursToAvoid(time_to_avoid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user