fix #1045
This commit is contained in:
parent
a9e40ae242
commit
1831d961b9
4 changed files with 42 additions and 6 deletions
|
@ -288,6 +288,23 @@ bool DatabaseQueries::createLabel(const QSqlDatabase& db, Label* label, int acco
|
|||
return q.exec() && res;
|
||||
}
|
||||
|
||||
void DatabaseQueries::updateProbe(const QSqlDatabase& db, Search* probe) {
|
||||
QSqlQuery q(db);
|
||||
|
||||
q.setForwardOnly(true);
|
||||
q.prepare(QSL("UPDATE Probes SET name = :name, fltr = :fltr, color = :color "
|
||||
"WHERE id = :id AND account_id = :account_id;"));
|
||||
q.bindValue(QSL(":name"), probe->title());
|
||||
q.bindValue(QSL(":fltr"), probe->filter());
|
||||
q.bindValue(QSL(":color"), probe->color().name());
|
||||
q.bindValue(QSL(":id"), probe->id());
|
||||
q.bindValue(QSL(":account_id"), probe->getParentServiceRoot()->accountId());
|
||||
|
||||
if (!q.exec()) {
|
||||
throw ApplicationException(q.lastError().text());
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseQueries::createProbe(const QSqlDatabase& db, Search* probe, int account_id) {
|
||||
QSqlQuery q(db);
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ class DatabaseQueries {
|
|||
static void createProbe(const QSqlDatabase& db, Search* probe, int account_id);
|
||||
static QList<Search*> getProbesForAccount(const QSqlDatabase& db, int account_id);
|
||||
static void deleteProbe(const QSqlDatabase& db, Search* probe);
|
||||
static void updateProbe(const QSqlDatabase& db, Search* probe);
|
||||
|
||||
// Message operators.
|
||||
static bool markLabelledMessagesReadUnread(const QSqlDatabase& db, Label* label, RootItem::ReadStatus read);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "services/abstract/feed.h"
|
||||
|
||||
#include "3rd-party/boolinq/boolinq.h"
|
||||
#include "database/databasequeries.h"
|
||||
#include "definitions/definitions.h"
|
||||
#include "miscellaneous/application.h"
|
||||
|
@ -371,12 +372,25 @@ QString Feed::additionalTooltip() const {
|
|||
stat += QSL(" (%1)").arg(m_statusString);
|
||||
}
|
||||
|
||||
auto std_fltrs = boolinq::from(m_messageFilters)
|
||||
.select([](const QPointer<MessageFilter>& pn) {
|
||||
return pn->name();
|
||||
})
|
||||
.toStdList();
|
||||
QStringList fltrs = FROM_STD_LIST(QStringList, std_fltrs);
|
||||
|
||||
return tr("Auto-update status: %1\n"
|
||||
"Active message filters: %2\n"
|
||||
"Status: %3\n"
|
||||
"Source: <a href=\"%4\">%4</a>\n"
|
||||
"Item ID: %5")
|
||||
.arg(getAutoUpdateStatusDescription(), QString::number(m_messageFilters.size()), stat, m_source, customId());
|
||||
.arg(getAutoUpdateStatusDescription(),
|
||||
m_messageFilters.size() > 0
|
||||
? QSL("%1 (%2)").arg(QString::number(m_messageFilters.size()), fltrs.join(QSL(", ")))
|
||||
: QString::number(m_messageFilters.size()),
|
||||
stat,
|
||||
m_source,
|
||||
customId());
|
||||
}
|
||||
|
||||
Qt::ItemFlags Feed::additionalFlags() const {
|
||||
|
|
|
@ -51,14 +51,18 @@ bool Search::editViaGui() {
|
|||
if (form.execForEdit(this)) {
|
||||
QSqlDatabase db = qApp->database()->driver()->connection(metaObject()->className());
|
||||
|
||||
try {
|
||||
DatabaseQueries::updateProbe(db, this);
|
||||
return true;
|
||||
// return DatabaseQueries::updateLabel(db, this);
|
||||
}
|
||||
catch (const ApplicationException& ex) {
|
||||
qCriticalNN << LOGSEC_CORE << "Failed to edit probe:" << QUOTE_W_SPACE_DOT(ex.message());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Search::canBeDeleted() const {
|
||||
|
|
Loading…
Add table
Reference in a new issue