greader now supports feed adding, modifying and deleting
This commit is contained in:
parent
4f8b4c1e6b
commit
854f6ea92e
5 changed files with 59 additions and 64 deletions
|
@ -71,7 +71,7 @@ set(APP_AUTHOR "Martin Rotter")
|
||||||
set(APP_COPYRIGHT "\\251 2011-${YEAR} ${APP_AUTHOR}")
|
set(APP_COPYRIGHT "\\251 2011-${YEAR} ${APP_AUTHOR}")
|
||||||
set(APP_REVERSE_NAME "io.github.martinrotter.rssguard")
|
set(APP_REVERSE_NAME "io.github.martinrotter.rssguard")
|
||||||
set(APP_DONATE_URL "https://github.com/sponsors/martinrotter")
|
set(APP_DONATE_URL "https://github.com/sponsors/martinrotter")
|
||||||
set(APP_VERSION "4.5.4")
|
set(APP_VERSION "4.5.5")
|
||||||
|
|
||||||
set(APP_URL "https://github.com/martinrotter/rssguard")
|
set(APP_URL "https://github.com/martinrotter/rssguard")
|
||||||
set(APP_URL_DOCUMENTATION "https://rssguard.readthedocs.io")
|
set(APP_URL_DOCUMENTATION "https://rssguard.readthedocs.io")
|
||||||
|
|
|
@ -2062,33 +2062,17 @@ QtWebEngine cache folder -> "%7"</source>
|
||||||
<context>
|
<context>
|
||||||
<name>FormGreaderFeedDetails</name>
|
<name>FormGreaderFeedDetails</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/librssguard/services/greader/gui/formgreaderfeeddetails.cpp" line="40"/>
|
<location filename="../src/librssguard/services/greader/gui/formgreaderfeeddetails.cpp" line="51"/>
|
||||||
<source>Feed NOT updated</source>
|
<source>Feed NOT updated or added</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/librssguard/services/greader/gui/formgreaderfeeddetails.cpp" line="41"/>
|
<location filename="../src/librssguard/services/greader/gui/formgreaderfeeddetails.cpp" line="52"/>
|
||||||
<location filename="../src/librssguard/services/greader/gui/formgreaderfeeddetails.cpp" line="73"/>
|
|
||||||
<source>Error: %1</source>
|
<source>Error: %1</source>
|
||||||
<translation type="unfinished">Error: %1</translation>
|
<translation type="unfinished">Error: %1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/librssguard/services/greader/gui/formgreaderfeeddetails.cpp" line="65"/>
|
<location filename="../src/librssguard/services/greader/gui/formgreaderfeeddetails.cpp" line="83"/>
|
||||||
<source>Feed added</source>
|
|
||||||
<translation type="unfinished">Feed added</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/librssguard/services/greader/gui/formgreaderfeeddetails.cpp" line="66"/>
|
|
||||||
<source>Feed was added, obtaining new tree of feeds now.</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/librssguard/services/greader/gui/formgreaderfeeddetails.cpp" line="72"/>
|
|
||||||
<source>Feed NOT added</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/librssguard/services/greader/gui/formgreaderfeeddetails.cpp" line="86"/>
|
|
||||||
<source>General</source>
|
<source>General</source>
|
||||||
<translation type="unfinished">General</translation>
|
<translation type="unfinished">General</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -81,6 +81,7 @@ bool BaseToastNotification::eventFilter(QObject* watched, QEvent* event) {
|
||||||
|
|
||||||
if (event->type() == QEvent::Type::MouseButtonPress) {
|
if (event->type() == QEvent::Type::MouseButtonPress) {
|
||||||
if (dynamic_cast<QMouseEvent*>(event)->button() == Qt::MouseButton::RightButton) {
|
if (dynamic_cast<QMouseEvent*>(event)->button() == Qt::MouseButton::RightButton) {
|
||||||
|
event->ignore();
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "services/greader/gui/formgreaderfeeddetails.h"
|
#include "services/greader/gui/formgreaderfeeddetails.h"
|
||||||
|
|
||||||
|
#include "database/databasequeries.h"
|
||||||
#include "exceptions/applicationexception.h"
|
#include "exceptions/applicationexception.h"
|
||||||
#include "miscellaneous/application.h"
|
#include "miscellaneous/application.h"
|
||||||
#include "services/greader/definitions.h"
|
#include "services/greader/definitions.h"
|
||||||
|
@ -21,60 +22,66 @@ FormGreaderFeedDetails::FormGreaderFeedDetails(ServiceRoot* service_root,
|
||||||
m_urlToProcess(url) {}
|
m_urlToProcess(url) {}
|
||||||
|
|
||||||
void FormGreaderFeedDetails::apply() {
|
void FormGreaderFeedDetails::apply() {
|
||||||
if (!m_creatingNew) {
|
|
||||||
if (!m_isBatchEdit) {
|
|
||||||
GreaderFeed* fd = feed<GreaderFeed>();
|
GreaderFeed* fd = feed<GreaderFeed>();
|
||||||
RootItem* parent = m_feedDetails->ui.m_cmbParentCategory->currentData().value<RootItem*>();
|
GreaderServiceRoot* root = qobject_cast<GreaderServiceRoot*>(m_serviceRoot);
|
||||||
const QString category_id = parent->kind() == RootItem::Kind::ServiceRoot ? QString() : parent->customId();
|
RootItem* parent =
|
||||||
|
m_feedDetails != nullptr ? m_feedDetails->ui.m_cmbParentCategory->currentData().value<RootItem*>() : nullptr;
|
||||||
|
|
||||||
|
if (m_creatingNew || !m_isBatchEdit) {
|
||||||
|
QString feed_id = m_creatingNew ? (QSL("feed/") + m_feedDetails->ui.m_txtUrl->lineEdit()->text()) : fd->customId();
|
||||||
|
QString category_to_add = parent->kind() == RootItem::Kind::ServiceRoot ? QString() : parent->customId();
|
||||||
|
QString category_to_remove =
|
||||||
|
(!m_creatingNew && fd->parent()->customId() != category_to_add) ? fd->parent()->customId() : QString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fd->serviceRoot()->network()->subscriptionEdit(QSL(GREADER_API_EDIT_SUBSCRIPTION_MODIFY),
|
// Change online
|
||||||
fd->customId(),
|
root->network()->subscriptionEdit(m_creatingNew ? QSL(GREADER_API_EDIT_SUBSCRIPTION_ADD)
|
||||||
|
: QSL(GREADER_API_EDIT_SUBSCRIPTION_MODIFY),
|
||||||
|
feed_id,
|
||||||
m_feedDetails->ui.m_txtTitle->lineEdit()->text(),
|
m_feedDetails->ui.m_txtTitle->lineEdit()->text(),
|
||||||
category_id,
|
QUrl::toPercentEncoding(category_to_add),
|
||||||
{},
|
QUrl::toPercentEncoding(category_to_remove),
|
||||||
m_serviceRoot->networkProxy());
|
|
||||||
}
|
|
||||||
catch (const ApplicationException& ex) {
|
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent,
|
|
||||||
{tr("Feed NOT updated"),
|
|
||||||
tr("Error: %1").arg(ex.message()),
|
|
||||||
QSystemTrayIcon::MessageIcon::Critical},
|
|
||||||
GuiMessageDestination(true, true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: We can only edit base properties, therefore
|
|
||||||
// base method is fine.
|
|
||||||
FormFeedDetails::apply();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
RootItem* parent = m_feedDetails->ui.m_cmbParentCategory->currentData().value<RootItem*>();
|
|
||||||
auto* root = qobject_cast<GreaderServiceRoot*>(parent->getParentServiceRoot());
|
|
||||||
const QString category_id = parent->kind() == RootItem::Kind::ServiceRoot ? QString() : parent->customId();
|
|
||||||
|
|
||||||
try {
|
|
||||||
root->network()->subscriptionEdit(QSL(GREADER_API_EDIT_SUBSCRIPTION_ADD),
|
|
||||||
QSL("feed/") + m_feedDetails->ui.m_txtUrl->lineEdit()->text(),
|
|
||||||
m_feedDetails->ui.m_txtTitle->lineEdit()->text(),
|
|
||||||
category_id,
|
|
||||||
{},
|
|
||||||
m_serviceRoot->networkProxy());
|
m_serviceRoot->networkProxy());
|
||||||
|
|
||||||
|
if (m_creatingNew) {
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent,
|
qApp->showGuiMessage(Notification::Event::GeneralEvent,
|
||||||
{tr("Feed added"),
|
{tr("Feed added"),
|
||||||
tr("Feed was added, obtaining new tree of feeds now."),
|
tr("Feed was added, refreshing feed tree..."),
|
||||||
QSystemTrayIcon::MessageIcon::Information});
|
QSystemTrayIcon::MessageIcon::Information});
|
||||||
QTimer::singleShot(300, root, &GreaderServiceRoot::syncIn);
|
QTimer::singleShot(300, root, &GreaderServiceRoot::syncIn);
|
||||||
|
|
||||||
|
// NOTE: Feed object was not used, delete.
|
||||||
|
fd->deleteLater();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fd->setTitle(m_feedDetails->ui.m_txtTitle->lineEdit()->text());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (const ApplicationException& ex) {
|
catch (const ApplicationException& ex) {
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent,
|
qApp->showGuiMessage(Notification::Event::GeneralEvent,
|
||||||
{tr("Feed NOT added"),
|
{tr("Feed NOT updated or added"),
|
||||||
tr("Error: %1").arg(ex.message()),
|
tr("Error: %1").arg(ex.message()),
|
||||||
QSystemTrayIcon::MessageIcon::Critical},
|
QSystemTrayIcon::MessageIcon::Critical},
|
||||||
GuiMessageDestination(true, true));
|
GuiMessageDestination(true, true));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FormFeedDetails::apply();
|
||||||
|
|
||||||
|
if (!m_isBatchEdit) {
|
||||||
|
try {
|
||||||
|
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
|
||||||
|
DatabaseQueries::createOverwriteFeed(database, fd, m_serviceRoot->accountId(), parent->id());
|
||||||
|
}
|
||||||
|
catch (const ApplicationException& ex) {
|
||||||
|
qFatal("Cannot save feed: '%s'.", qPrintable(ex.message()));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_serviceRoot->requestItemReassignment(fd, parent);
|
||||||
|
m_serviceRoot->itemChanged({fd});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormGreaderFeedDetails::loadFeedData() {
|
void FormGreaderFeedDetails::loadFeedData() {
|
||||||
|
@ -102,7 +109,10 @@ void FormGreaderFeedDetails::loadFeedData() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_feedDetails->ui.m_txtTitle->lineEdit()->setText(fd->title());
|
m_feedDetails->ui.m_txtTitle->lineEdit()->setText(fd->title());
|
||||||
m_feedDetails->ui.m_txtUrl->lineEdit()->setText(fd->source());
|
|
||||||
|
// NOTE: User cannot edit URL.
|
||||||
|
m_feedDetails->ui.m_lblUrl->hide();
|
||||||
|
m_feedDetails->ui.m_txtUrl->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="m_lblUrl">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>URL</string>
|
<string>URL</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
<widget class="LineEditWithStatus" name="m_txtTitle" native="true"/>
|
<widget class="LineEditWithStatus" name="m_txtTitle" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="m_lblTitle">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Title</string>
|
<string>Title</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Add table
Reference in a new issue