Merge branch 'master' of github.com:martinrotter/rssguard
This commit is contained in:
commit
508d645c82
README.md
localization
resources
src/librssguard
core
gui/dialogs
miscellaneous
network-web
services/abstract
@ -9,6 +9,8 @@ RSS Guard
|
||||
[](https://github.com/martinrotter/rssguard/issues)
|
||||
[](https://github.com/martinrotter/rssguard/blob/master/LICENSE.md)
|
||||
|
||||
### [Downloads](https://github.com/martinrotter/rssguard/releases)
|
||||
|
||||
RSS Guard is simple, light and easy-to-use RSS/ATOM feed aggregator developed using Qt framework which supports online feed synchronization with these services:
|
||||
* [Tiny Tiny RSS](https://tt-rss.org),
|
||||
* [Inoreader](https://www.inoreader.com),
|
||||
|
7119
localization/qtbase_fi.ts
Executable file
7119
localization/qtbase_fi.ts
Executable file
File diff suppressed because it is too large
Load Diff
4731
localization/rssguard_fi.ts
Executable file
4731
localization/rssguard_fi.ts
Executable file
File diff suppressed because it is too large
Load Diff
@ -2204,7 +2204,7 @@ It is highly recommended to create your own "Application ID".</source>
|
||||
</message>
|
||||
<message>
|
||||
<source>Display &documentation</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Exibir &documentação</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -198,11 +198,11 @@
|
||||
<name>ColorToolButton</name>
|
||||
<message>
|
||||
<source>Click me to change color!</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Нажмите здесь, чтобы изменить цвет!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Select new color</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Выбор нового цвета</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -312,7 +312,7 @@ This website contains %n feed(s).</source>
|
||||
</message>
|
||||
<message>
|
||||
<source>Feeds were detected, but no suitable accounts are configured.</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Каналы обнаружены, но подходящие учетные записи не настроены.</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -672,7 +672,7 @@ or this functionality is not implemented yet.</source>
|
||||
</message>
|
||||
<message>
|
||||
<source>Context menu for label</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Контекстное меню для меток</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -820,27 +820,27 @@ or this functionality is not implemented yet.</source>
|
||||
</message>
|
||||
<message>
|
||||
<source>Name for your label</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Название новой метки</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Label's name cannot be empty.</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Название метки не может быть пустым.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Perfect!</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Отлично!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Hot stuff</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Новая метка</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Create new label</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Создать новую метку</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Edit label '%1'</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Изменить метку '%1'</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -2201,11 +2201,11 @@ It is highly recommended to create your own "Application ID".</source>
|
||||
</message>
|
||||
<message>
|
||||
<source>Alternate row colors in lists</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Чередовать цвет фона строк в списках</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Display &documentation</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Показать документацию (&D)</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -3065,30 +3065,30 @@ Login tokens expiration: %2</source>
|
||||
<name>LabelsMenu</name>
|
||||
<message>
|
||||
<source>Labels</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Метки</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LabelsNode</name>
|
||||
<message>
|
||||
<source>Labels</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Метки</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You can see all your labels (tags) here.</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Вы можете увидеть все метки (теги) здесь.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>New label</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Новая метка</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>This account does not allow you to create labels.</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Эта учетная запись не позволяет создавать метки.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Not allowed</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Не допускается</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -3613,7 +3613,7 @@ version by clicking this popup notification.</source>
|
||||
</message>
|
||||
<message>
|
||||
<source>Standard online feeds (RSS/ATOM/JSON)</source>
|
||||
<translation type="unfinished"/>
|
||||
<translation>Стандартные онлайн-каналы (RSS/ATOM/JSON)</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -16,3 +16,5 @@ You can easily (de)assign label to messages in message viewer.
|
||||
<img src="images/label-assign.png" width="80%">
|
||||
|
||||
Note that (de)assignments of labels to messages are synchronized back to supported servers in regular intervals.
|
||||
|
||||
Also, [message filters](Message-filters.md) can assign or remove labels to/from messages.
|
@ -13,19 +13,55 @@ As you can see, RSS Guard processes all feeds scheduled for message downloading
|
||||
|
||||
## Writing message filter
|
||||
|
||||
Message filter consists of arbitrary JavaScript code which must provide function with prototype `function filterMessage() { }`. This function must be fast and must return integer values which belong to enumeration [`FilteringAction`](https://github.com/martinrotter/rssguard/blob/master/src/librssguard/core/message.h#L83). For example, your function must return `2` to block the message which is subsequently NOT saved into database. For easier usage, RSS Guard 3.7.1+ offers named variables for this, which are called `MSG_ACCEPT` and `MSG_IGNORE`.
|
||||
Message filter consists of arbitrary JavaScript code which must provide function with prototype
|
||||
|
||||
Each message is accessible in your script via global variable named `msg` of type [`MessageObject`](https://github.com/martinrotter/rssguard/blob/master/src/librssguard/core/message.h#L118). Some properties are writable, thus allowing you to change contents of the message before it is written to DB. You can mark message important, parse its description or perhaps change author name!!!
|
||||
```js
|
||||
function filterMessage() { }
|
||||
```
|
||||
|
||||
RSS Guard 3.8.0+ offers also read-only list of labels assigned to each message. You can therefore do actions in your filtering script based on which labels are assigned to the message. The property is called `assignedLabels` and is array of `Label` objects. Each `Label` in the array offers these properties: `title` (title of the label), `color` (color of the label) and `customId` (account-specific ID of the label).
|
||||
This function must be fast and must return values which belong to enumeration `FilteringAction` from this [file](https://github.com/martinrotter/rssguard/blob/master/src/librssguard/core/message.h). You can you either direct numerical value of each enumerant, for example `2` or you can use self-descriptive enumerant name, for example `MessageObject.Ignore`. Named enumerants are supported in RSS Guard 3.8.1+. RSS Guard 3.7.1+ also offers names `MSG_ACCEPT` and `MSG_IGNORE` as aliases for `MessageObject.Accept` and `MessageObject.Ignore`.
|
||||
|
||||
Each message is accessible in your script via global variable named `msg` of type `MessageObject`, see this [file](https://github.com/martinrotter/rssguard/blob/master/src/librssguard/core/message.h) for the declaration. Some properties are writable, allowing you to change contents of the message before it is written to DB. You can mark message important, parse its description or perhaps change author name or even assign some label to it!!!
|
||||
|
||||
RSS Guard 3.8.0+ offers also list of labels assigned to each message. You can therefore do actions in your filtering script based on which labels are assigned to the message. The property is called `assignedLabels` and is array of `Label` objects. Each `Label` in the array offers these properties: `title` (title of the label), `color` (color of the label) and `customId` (account-specific ID of the label). If you change assigned labels to the message, then the change will be eventually synchronized back to server if respective plugin supports it.
|
||||
|
||||
Passed message also offers special function
|
||||
```js
|
||||
MessageObject.isDuplicateWithAttribute(DuplicationAttributeCheck)
|
||||
```
|
||||
which allows you to perform runtime check for existence of the message in RSS Guard's database. The parameter is integer value from enumeration [`DuplicationAttributeCheck`](https://github.com/martinrotter/rssguard/blob/master/src/librssguard/core/message.h#L91) and specifies how exactly you want to determine if given message is "duplicate".
|
||||
|
||||
For example if you want to check if there is already another message with same author in database, then you call `msg.isDuplicateWithAttribute(4)`. Enumeration even supports "flags" approach, thus you can combine multiple checks via bitwise `OR` operation in single call, for example like this: `msg.isDuplicateWithAttribute(4 | 16)`.
|
||||
which allows you to perform runtime check for existence of the message in RSS Guard's database. The parameter is integer value from enumeration `DuplicationAttributeCheck` from this [file](https://github.com/martinrotter/rssguard/blob/master/src/librssguard/core/message.h) and specifies how exactly you want to determine if given message is "duplicate". Again, you can use direct integer value or enumerant name.
|
||||
|
||||
For example if you want to check if there is already another message with same author in database, then you call `msg.isDuplicateWithAttribute(MessageObject.SameAuthor)`. Enumeration even supports "flags" approach, thus you can combine multiple checks via bitwise `OR` operation in single call, for example like this: `msg.isDuplicateWithAttribute(MessageObject.SameAuthor | MessageObject.SameUrl)`.
|
||||
|
||||
## API reference
|
||||
Here is the reference of methods and properties of some types available in your filtering scipts.
|
||||
|
||||
### `MessageObject`
|
||||
|
||||
| Property/method | Description |
|
||||
|---|---|
|
||||
| `Array<Label> assignedLabels` | `READ-ONLY` List of labels assigned to the message. |
|
||||
| `Array<Label> availableLabels` | `READ-ONLY` List of labels which are currently available and can be assigned to the message. Available in RSS Guard 3.8.1+. |
|
||||
| `String feedCustomId` | `READ-ONLY` Service-specific ID of the feed which this message belongs to. |
|
||||
| `Number accountId` | `READ-ONLY` RSS Guard's ID of the account activated in the program. This property is highly advanced and you probably do not need to use it at all. |
|
||||
| `String title` | Title of the message. |
|
||||
| `String url` | URL of the message. |
|
||||
| `String author` | Author of the message. |
|
||||
| `String contents` | Contents of the message. |
|
||||
| `Date created` | Date/time of the message. |
|
||||
| `Boolean isRead` | Is message read? |
|
||||
| `Boolean isImportant` | Is message important? |
|
||||
| `Boolean isDuplicateWithAttribute(DuplicationAttributeCheck)` | Allows you to test if this particular message is already stored in RSS Guard's DB. |
|
||||
| `Boolean assignLabel(String)` | Assigns label to this message. The passed `String` value is the `customId` property of `Label` type. See its API reference for relevant info. Available in RSS Guard 3.8.1+. |
|
||||
| `Boolean deassignLabel(String)` | Removes label from this message. The passed `String` value is the `customId` property of `Label` type. See its API reference for relevant info. Available in RSS Guard 3.8.1+. |
|
||||
|
||||
### `Label`
|
||||
| Property/method | Description |
|
||||
|---|---|
|
||||
| `String title` | `READ-ONLY` Label title. |
|
||||
| `String customId` | `READ-ONLY` Service-specific ID of this label. This ID is used as unique identifier for the label and is particularly useful if you want to (de)assign label to/from message. |
|
||||
| `color color` | `READ-ONLY` Label color. Note that type `color` has its documentation [here](https://doc.qt.io/qt-5/qml-color.html). |
|
||||
|
||||
## Examples
|
||||
Accept only messages from "Bob" while also marking them important.
|
||||
@ -33,10 +69,10 @@ Accept only messages from "Bob" while also marking them important.
|
||||
function filterMessage() {
|
||||
if (msg.author == "Bob") {
|
||||
msg.isImportant = true;
|
||||
return MSG_ACCEPT;
|
||||
return MessageObject.Accept;
|
||||
}
|
||||
else {
|
||||
return MSG_IGNORE;
|
||||
return MessageObject.Ignore;
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -45,18 +81,44 @@ Replace all dogs with cats!
|
||||
```js
|
||||
function filterMessage() {
|
||||
msg.title = msg.title.replace("dogs", "cats");
|
||||
return MSG_ACCEPT;
|
||||
return MessageObject.Accept;
|
||||
}
|
||||
```
|
||||
|
||||
Write details of available labels and assign the first label to the message.
|
||||
```js
|
||||
function filterMessage() {
|
||||
console.log('Number of assigned labels ' + msg.assignedLabels.length);
|
||||
console.log('Number of available labels ' + msg.availableLabels.length);
|
||||
|
||||
var i;
|
||||
for (i = 0; i < msg.availableLabels.length; i++) {
|
||||
var lbl = msg.availableLabels[i];
|
||||
|
||||
console.log('Available label:');
|
||||
console.log(' Title: \'' + lbl.title + '\' ID: \'' + lbl.customId + '\'');
|
||||
}
|
||||
|
||||
if (msg.availableLabels.length > 0) {
|
||||
console.log('Assigning first label to message...');
|
||||
msg.assignLabel(msg.availableLabels[0].customId);
|
||||
|
||||
console.log('Number of assigned labels ' + msg.assignedLabels.length);
|
||||
}
|
||||
|
||||
console.log();
|
||||
return MessageObject.Accept;
|
||||
}
|
||||
```
|
||||
|
||||
Make sure that your receive only one message with particular URL and all other messages with same URL are subsequently ignored.
|
||||
```js
|
||||
function filterMessage() {
|
||||
if (msg.isDuplicateWithAttribute(2)) {
|
||||
return MSG_IGNORE;
|
||||
if (msg.isDuplicateWithAttribute(MessageObject.SameUrl)) {
|
||||
return MessageObject.Ignore;
|
||||
}
|
||||
else {
|
||||
return MSG_ACCEPT;
|
||||
return MessageObject.Accept;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
BIN
resources/graphics/misc/flags/fi.png
Executable file
BIN
resources/graphics/misc/flags/fi.png
Executable file
Binary file not shown.
After ![]() (image error) Size: 1.1 KiB |
@ -27,6 +27,7 @@
|
||||
<file>graphics/misc/flags/de.png</file>
|
||||
<file>graphics/misc/flags/en.png</file>
|
||||
<file>graphics/misc/flags/es.png</file>
|
||||
<file>graphics/misc/flags/fi.png</file>
|
||||
<file>graphics/misc/flags/fr.png</file>
|
||||
<file>graphics/misc/flags/gl.png</file>
|
||||
<file>graphics/misc/flags/he.png</file>
|
||||
@ -69,6 +70,7 @@
|
||||
<file>../localization/rssguard_de.qm</file>
|
||||
<file>../localization/rssguard_en.qm</file>
|
||||
<file>../localization/rssguard_es.qm</file>
|
||||
<file>../localization/rssguard_fi.qm</file>
|
||||
<file>../localization/rssguard_fr.qm</file>
|
||||
<file>../localization/rssguard_gl.qm</file>
|
||||
<file>../localization/rssguard_he.qm</file>
|
||||
@ -89,6 +91,7 @@
|
||||
<file>../localization/qtbase_da.qm</file>
|
||||
<file>../localization/qtbase_de.qm</file>
|
||||
<file>../localization/qtbase_es.qm</file>
|
||||
<file>../localization/qtbase_fi.qm</file>
|
||||
<file>../localization/qtbase_fr.qm</file>
|
||||
<file>../localization/qtbase_it.qm</file>
|
||||
<file>../localization/qtbase_ja.qm</file>
|
||||
|
@ -1,50 +1,30 @@
|
||||
# List startup folder.
|
||||
$old_pwd = $pwd.Path
|
||||
$ssl_bin = "C:\OpenSSL-v111-Win64\bin"
|
||||
$mysql_dir = "C:\Program Files\MySQL\MySQL Server 5.7"
|
||||
|
||||
ls "$ssl_bin"
|
||||
ls "$mysql_dir\lib"
|
||||
ls
|
||||
|
||||
echo "qmake args are: '$env:qmake_args'."
|
||||
|
||||
# Setup env path with qmake.
|
||||
$env:PATH = "$env:QTDIR\bin;" + $env:PATH
|
||||
|
||||
# Build MySQL Qt plugin.
|
||||
$qt_ver = "$env:QTVER"
|
||||
$qt_rev = "$env:QTREV"
|
||||
$qtbase_url = "https://download.qt.io/archive/qt/$qt_ver/$qt_ver.$qt_rev/submodules/qtbase-everywhere-src-$qt_ver.$qt_rev.zip"
|
||||
$output = "qt.zip"
|
||||
|
||||
mkdir "build-mysql"
|
||||
cd "build-mysql"
|
||||
|
||||
echo "Building MySQL Qt plugin, downloading Qt '$qt_ver.$qt_rev'."
|
||||
# Get Qt.
|
||||
$qt_version = "5.15.1"
|
||||
$qt_stub = "qt-$qt_version-dynamic-msvc2019-x86_64"
|
||||
$qt_link = "https://github.com/martinrotter/qt5-minimalistic-builds/releases/download/$qt_version/$qt_stub.7z"
|
||||
$qt_output = "qt.7z"
|
||||
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
Invoke-WebRequest -Uri $qtbase_url -OutFile $output
|
||||
Invoke-WebRequest -Uri $qt_link -OutFile $qt_output
|
||||
& ".\resources\scripts\7za\7za.exe" x $qt_output
|
||||
|
||||
& "..\resources\scripts\7za\7za.exe" x $output
|
||||
|
||||
$qt_mysql_dir = "./qtbase-everywhere-src-$qt_ver.$qt_rev/src/plugins/sqldrivers"
|
||||
$mysql_d_rev = $mysql_dir.Replace('\', '/')
|
||||
|
||||
cd "$qt_mysql_dir"
|
||||
|
||||
qmake.exe -- MYSQL_INCDIR="$mysql_d_rev/include" MYSQL_LIBDIR="$mysql_d_rev/lib"
|
||||
nmake.exe sub-mysql
|
||||
|
||||
Copy-Item -Path ".\plugins\sqldrivers\qsqlmysql.dll" -Destination "$old_pwd\build-mysql"
|
||||
$qt_path = (Resolve-Path $qt_stub).Path
|
||||
$qt_qmake = "$qt_path\bin\qmake.exe"
|
||||
|
||||
cd "$qt_stub\bin\"
|
||||
& ".\qtbinpatcher.exe"
|
||||
cd "$old_pwd"
|
||||
ls "build-mysql"
|
||||
|
||||
$env:PATH = "$qt_path\bin\;" + $env:PATH
|
||||
|
||||
# Build RSS Guard itself.
|
||||
echo "qmake args are: '$env:qmake_args'."
|
||||
|
||||
mkdir "rssguard-build"
|
||||
cd "rssguard-build"
|
||||
qmake.exe ..\build.pro "$env:qmake_args"
|
||||
& "$qt_qmake" "..\build.pro" "$env:qmake_args"
|
||||
nmake.exe
|
||||
|
||||
cd "src\rssguard"
|
||||
@ -56,12 +36,11 @@ windeployqt.exe --verbose 1 --compiler-runtime --no-translations --release rssgu
|
||||
cd ".."
|
||||
|
||||
# Copy OpenSSL.
|
||||
Copy-Item -Path "$ssl_bin\libcrypto*.dll" -Destination ".\app\"
|
||||
Copy-Item -Path "$ssl_bin\libssl*.dll" -Destination ".\app\"
|
||||
Copy-Item -Path "$qt_path\bin\libcrypto*.dll" -Destination ".\app\"
|
||||
Copy-Item -Path "$qt_path\bin\libssl*.dll" -Destination ".\app\"
|
||||
|
||||
# Copy MySQL Qt plugin.
|
||||
Copy-Item -Path "$mysql_dir\lib\libmysql.dll" -Destination ".\app\"
|
||||
Copy-Item -Path "$old_pwd\build-mysql\qsqlmysql.dll" -Destination ".\app\sqldrivers\"
|
||||
Copy-Item -Path "$qt_path\bin\libmariadb.dll" -Destination ".\app\"
|
||||
|
||||
nmake.exe windows_all
|
||||
cd "$old_pwd"
|
@ -9,7 +9,7 @@ read -p "Password: " PASSWORD
|
||||
|
||||
# Setup parameters.
|
||||
RESOURCE=../../../localization/rssguard_en.ts
|
||||
CODES="cs da de es fr gl he id it ja lt nl pl pt ru sv uk zh_CN zh_TW"
|
||||
CODES="cs da de es fi fr gl he id it ja lt nl pl pt ru sv uk zh_CN zh_TW"
|
||||
TRANSLATION='../../../localization/rssguard_$CODE.ts'
|
||||
|
||||
declare PARAMS
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "miscellaneous/application.h"
|
||||
#include "services/abstract/cacheforserviceroot.h"
|
||||
#include "services/abstract/feed.h"
|
||||
#include "services/abstract/labelsnode.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJSEngine>
|
||||
@ -112,15 +113,13 @@ void FeedDownloader::updateOneFeed(Feed* feed) {
|
||||
// Perform per-message filtering.
|
||||
QJSEngine filter_engine;
|
||||
|
||||
MessageFilter::initializeFilteringEngine(filter_engine);
|
||||
|
||||
// Create JavaScript communication wrapper for the message.
|
||||
MessageObject msg_obj(&database, feed->customId(), feed->getParentServiceRoot()->accountId());
|
||||
MessageObject msg_obj(&database,
|
||||
feed->customId(),
|
||||
feed->getParentServiceRoot()->accountId(),
|
||||
feed->getParentServiceRoot()->labelsNode()->labels());
|
||||
|
||||
// Register the wrapper.
|
||||
auto js_object = filter_engine.newQObject(&msg_obj);
|
||||
|
||||
filter_engine.globalObject().setProperty("msg", js_object);
|
||||
MessageFilter::initializeFilteringEngine(filter_engine, &msg_obj);
|
||||
|
||||
qDebugNN << LOGSEC_FEEDDOWNLOADER << "Setting up JS evaluation took " << tmr.nsecsElapsed() / 1000 << " microseconds.";
|
||||
|
||||
@ -153,18 +152,18 @@ void FeedDownloader::updateOneFeed(Feed* feed) {
|
||||
tmr.restart();
|
||||
|
||||
try {
|
||||
FilteringAction decision = msg_filter->filterMessage(&filter_engine);
|
||||
MessageObject::FilteringAction decision = msg_filter->filterMessage(&filter_engine);
|
||||
|
||||
qDebugNN << LOGSEC_FEEDDOWNLOADER
|
||||
<< "Running filter script, it took " << tmr.nsecsElapsed() / 1000 << " microseconds.";
|
||||
|
||||
switch (decision) {
|
||||
case FilteringAction::Accept:
|
||||
case MessageObject::FilteringAction::Accept:
|
||||
|
||||
// Message is normally accepted, it could be tweaked by the filter.
|
||||
continue;
|
||||
|
||||
case FilteringAction::Ignore:
|
||||
case MessageObject::FilteringAction::Ignore:
|
||||
|
||||
// Remove the message, we do not want it.
|
||||
remove_msg = true;
|
||||
@ -196,6 +195,30 @@ void FeedDownloader::updateOneFeed(Feed* feed) {
|
||||
important_msgs << *msg_orig;
|
||||
}
|
||||
|
||||
// Process changed labels.
|
||||
for (Label* lbl : msg_backup.m_assignedLabels) {
|
||||
if (!msg_orig->m_assignedLabels.contains(lbl)) {
|
||||
// Label is not there anymore, it was deassigned.
|
||||
lbl->deassignFromMessage(*msg_orig);
|
||||
|
||||
qDebugNN << "It was detected that label" << QUOTE_W_SPACE(lbl->customId())
|
||||
<< "was DEASSIGNED from message" << QUOTE_W_SPACE(msg_orig->m_customId)
|
||||
<< "by message filter(s).";
|
||||
}
|
||||
}
|
||||
|
||||
for (Label* lbl : msg_orig->m_assignedLabels) {
|
||||
if (!msg_backup.m_assignedLabels.contains(lbl)) {
|
||||
// Label is in new message, but is not in old message, it
|
||||
// was newly assigned.
|
||||
lbl->assignToMessage(*msg_orig);
|
||||
|
||||
qDebugNN << "It was detected that label" << QUOTE_W_SPACE(lbl->customId())
|
||||
<< "was ASSIGNED to message" << QUOTE_W_SPACE(msg_orig->m_customId)
|
||||
<< "by message filter(s).";
|
||||
}
|
||||
}
|
||||
|
||||
if (remove_msg) {
|
||||
msgs.removeAt(i--);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "core/message.h"
|
||||
|
||||
#include "3rd-party/boolinq/boolinq.h"
|
||||
#include "miscellaneous/textfactory.h"
|
||||
#include "services/abstract/label.h"
|
||||
|
||||
@ -158,45 +159,39 @@ uint qHash(const Message& key) {
|
||||
return (uint(key.m_accountId) * 10000) + uint(key.m_id);
|
||||
}
|
||||
|
||||
MessageObject::MessageObject(QSqlDatabase* db, const QString& feed_custom_id, int account_id, QObject* parent)
|
||||
: QObject(parent), m_db(db), m_feedCustomId(feed_custom_id), m_accountId(account_id), m_message(nullptr) {}
|
||||
MessageObject::MessageObject(QSqlDatabase* db, const QString& feed_custom_id,
|
||||
int account_id, QList<Label*> available_labels,
|
||||
QObject* parent)
|
||||
: QObject(parent), m_db(db), m_feedCustomId(feed_custom_id), m_accountId(account_id), m_message(nullptr),
|
||||
m_availableLabels(available_labels) {}
|
||||
|
||||
void MessageObject::setMessage(Message* message) {
|
||||
m_message = message;
|
||||
}
|
||||
|
||||
bool MessageObject::isDuplicateWithAttribute(int attribute_check) const {
|
||||
if (attribute_check <= 0) {
|
||||
qCriticalNN << LOGSEC_MESSAGEMODEL
|
||||
<< "Bad DuplicationAttributeCheck value '"
|
||||
<< attribute_check
|
||||
<< "' was passed from JS filter script.";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MessageObject::isDuplicateWithAttribute(MessageObject::DuplicationAttributeCheck attribute_check) const {
|
||||
// Check database according to duplication attribute_check.
|
||||
DuplicationAttributeCheck attrs = static_cast<DuplicationAttributeCheck>(attribute_check);
|
||||
QSqlQuery q(*m_db);
|
||||
QStringList where_clauses;
|
||||
QList<QPair<QString, QVariant>> bind_values;
|
||||
|
||||
// Now we construct the query according to parameter.
|
||||
if ((attrs& DuplicationAttributeCheck::SameTitle) == DuplicationAttributeCheck::SameTitle) {
|
||||
if ((attribute_check& DuplicationAttributeCheck::SameTitle) == DuplicationAttributeCheck::SameTitle) {
|
||||
where_clauses.append(QSL("title = :title"));
|
||||
bind_values.append({ ":title", title() });
|
||||
}
|
||||
|
||||
if ((attrs& DuplicationAttributeCheck::SameUrl) == DuplicationAttributeCheck::SameUrl) {
|
||||
if ((attribute_check& DuplicationAttributeCheck::SameUrl) == DuplicationAttributeCheck::SameUrl) {
|
||||
where_clauses.append(QSL("url = :url"));
|
||||
bind_values.append({ ":url", url() });
|
||||
}
|
||||
|
||||
if ((attrs& DuplicationAttributeCheck::SameAuthor) == DuplicationAttributeCheck::SameAuthor) {
|
||||
if ((attribute_check& DuplicationAttributeCheck::SameAuthor) == DuplicationAttributeCheck::SameAuthor) {
|
||||
where_clauses.append(QSL("author = :author"));
|
||||
bind_values.append({ ":author", author() });
|
||||
}
|
||||
|
||||
if ((attrs& DuplicationAttributeCheck::SameDateCreated) == DuplicationAttributeCheck::SameDateCreated) {
|
||||
if ((attribute_check& DuplicationAttributeCheck::SameDateCreated) == DuplicationAttributeCheck::SameDateCreated) {
|
||||
where_clauses.append(QSL("date_created = :date_created"));
|
||||
bind_values.append({ ":date_created", created().toMSecsSinceEpoch() });
|
||||
}
|
||||
@ -204,7 +199,7 @@ bool MessageObject::isDuplicateWithAttribute(int attribute_check) const {
|
||||
where_clauses.append(QSL("account_id = :account_id"));
|
||||
bind_values.append({ ":account_id", accountId() });
|
||||
|
||||
if ((attrs& DuplicationAttributeCheck::AllFeedsSameAccount) != DuplicationAttributeCheck::AllFeedsSameAccount) {
|
||||
if ((attribute_check& DuplicationAttributeCheck::AllFeedsSameAccount) != DuplicationAttributeCheck::AllFeedsSameAccount) {
|
||||
// Limit to current feed.
|
||||
where_clauses.append(QSL("feed = :feed"));
|
||||
bind_values.append({ ":feed", feedCustomId() });
|
||||
@ -244,6 +239,37 @@ bool MessageObject::isDuplicateWithAttribute(int attribute_check) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MessageObject::assignLabel(QString label_custom_id) const {
|
||||
Label* lbl = boolinq::from(m_availableLabels).firstOrDefault([label_custom_id](Label* lbl) {
|
||||
return lbl->customId() == label_custom_id;
|
||||
});
|
||||
|
||||
if (lbl != nullptr) {
|
||||
if (!m_message->m_assignedLabels.contains(lbl)) {
|
||||
m_message->m_assignedLabels.append(lbl);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool MessageObject::deassignLabel(QString label_custom_id) const {
|
||||
Label* lbl = boolinq::from(m_message->m_assignedLabels).firstOrDefault([label_custom_id](Label* lbl) {
|
||||
return lbl->customId() == label_custom_id;
|
||||
});
|
||||
|
||||
if (lbl != nullptr) {
|
||||
m_message->m_assignedLabels.removeAll(lbl);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString MessageObject::title() const {
|
||||
return m_message->m_title;
|
||||
}
|
||||
@ -311,3 +337,7 @@ int MessageObject::accountId() const {
|
||||
QList<Label*> MessageObject::assignedLabels() const {
|
||||
return m_message->m_assignedLabels;
|
||||
}
|
||||
|
||||
QList<Label*> MessageObject::availableLabels() const {
|
||||
return m_availableLabels;
|
||||
}
|
||||
|
@ -82,6 +82,22 @@ QDataStream& operator>>(QDataStream& in, Message& myObj);
|
||||
uint qHash(const Message& key, uint seed);
|
||||
uint qHash(const Message& key);
|
||||
|
||||
class MessageObject : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QList<Label*> assignedLabels READ assignedLabels)
|
||||
Q_PROPERTY(QList<Label*> availableLabels READ availableLabels)
|
||||
Q_PROPERTY(QString feedCustomId READ feedCustomId)
|
||||
Q_PROPERTY(int accountId READ accountId)
|
||||
Q_PROPERTY(QString title READ title WRITE setTitle)
|
||||
Q_PROPERTY(QString url READ url WRITE setUrl)
|
||||
Q_PROPERTY(QString author READ author WRITE setAuthor)
|
||||
Q_PROPERTY(QString contents READ contents WRITE setContents)
|
||||
Q_PROPERTY(QDateTime created READ created WRITE setCreated)
|
||||
Q_PROPERTY(bool isRead READ isRead WRITE setIsRead)
|
||||
Q_PROPERTY(bool isImportant READ isImportant WRITE setIsImportant)
|
||||
|
||||
public:
|
||||
enum class FilteringAction {
|
||||
// Message is normally accepted and stored in DB.
|
||||
Accept = 1,
|
||||
@ -90,6 +106,8 @@ enum class FilteringAction {
|
||||
Ignore = 2
|
||||
};
|
||||
|
||||
Q_ENUM(FilteringAction)
|
||||
|
||||
enum class DuplicationAttributeCheck {
|
||||
// Message with same title in DB.
|
||||
SameTitle = 1,
|
||||
@ -109,39 +127,30 @@ enum class DuplicationAttributeCheck {
|
||||
AllFeedsSameAccount = 16
|
||||
};
|
||||
|
||||
inline DuplicationAttributeCheck operator|(DuplicationAttributeCheck lhs, DuplicationAttributeCheck rhs) {
|
||||
return static_cast<DuplicationAttributeCheck>(int(lhs) | int(rhs));
|
||||
}
|
||||
Q_ENUM(DuplicationAttributeCheck)
|
||||
|
||||
inline DuplicationAttributeCheck operator&(DuplicationAttributeCheck lhs, DuplicationAttributeCheck rhs) {
|
||||
return static_cast<DuplicationAttributeCheck>(int(lhs) & int(rhs));
|
||||
}
|
||||
|
||||
class MessageObject : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QList<Label*> assignedLabels READ assignedLabels)
|
||||
Q_PROPERTY(QString feedCustomId READ feedCustomId)
|
||||
Q_PROPERTY(int accountId READ accountId)
|
||||
Q_PROPERTY(QString title READ title WRITE setTitle)
|
||||
Q_PROPERTY(QString url READ url WRITE setUrl)
|
||||
Q_PROPERTY(QString author READ author WRITE setAuthor)
|
||||
Q_PROPERTY(QString contents READ contents WRITE setContents)
|
||||
Q_PROPERTY(QDateTime created READ created WRITE setCreated)
|
||||
Q_PROPERTY(bool isRead READ isRead WRITE setIsRead)
|
||||
Q_PROPERTY(bool isImportant READ isImportant WRITE setIsImportant)
|
||||
|
||||
public:
|
||||
explicit MessageObject(QSqlDatabase* db, const QString& feed_custom_id, int account_id, QObject* parent = nullptr);
|
||||
explicit MessageObject(QSqlDatabase* db, const QString& feed_custom_id,
|
||||
int account_id, QList<Label*> available_labels,
|
||||
QObject* parent = nullptr);
|
||||
|
||||
void setMessage(Message* message);
|
||||
|
||||
// Check if message is duplicate with another messages in DB.
|
||||
// Parameter "attribute_check" is DuplicationAttributeCheck enum
|
||||
// value casted to int.
|
||||
Q_INVOKABLE bool isDuplicateWithAttribute(int attribute_check) const;
|
||||
Q_INVOKABLE bool isDuplicateWithAttribute(DuplicationAttributeCheck attribute_check) const;
|
||||
|
||||
// Adds given label to list of assigned labels to this message.
|
||||
// Returns true if label was assigned now or if the message already has it assigned.
|
||||
Q_INVOKABLE bool assignLabel(QString label_custom_id) const;
|
||||
|
||||
// Removes given label from list of assigned labels of this message.
|
||||
// Returns true if label was now removed or if it is not assigned to the message at all.
|
||||
Q_INVOKABLE bool deassignLabel(QString label_custom_id) const;
|
||||
|
||||
// Returns list of assigned and available messages.
|
||||
QList<Label*> assignedLabels() const;
|
||||
QList<Label*> availableLabels() const;
|
||||
|
||||
// Generic Message's properties bindings.
|
||||
QString feedCustomId() const;
|
||||
@ -173,6 +182,17 @@ class MessageObject : public QObject {
|
||||
QString m_feedCustomId;
|
||||
int m_accountId;
|
||||
Message* m_message;
|
||||
QList<Label*> m_availableLabels;
|
||||
};
|
||||
|
||||
inline MessageObject::DuplicationAttributeCheck operator|(MessageObject::DuplicationAttributeCheck lhs,
|
||||
MessageObject::DuplicationAttributeCheck rhs) {
|
||||
return static_cast<MessageObject::DuplicationAttributeCheck>(int(lhs) | int(rhs));
|
||||
}
|
||||
|
||||
inline MessageObject::DuplicationAttributeCheck operator&(MessageObject::DuplicationAttributeCheck lhs,
|
||||
MessageObject::DuplicationAttributeCheck rhs) {
|
||||
return static_cast<MessageObject::DuplicationAttributeCheck>(int(lhs) & int(rhs));
|
||||
}
|
||||
|
||||
#endif // MESSAGE_H
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
MessageFilter::MessageFilter(int id, QObject* parent) : QObject(parent), m_id(id) {}
|
||||
|
||||
FilteringAction MessageFilter::filterMessage(QJSEngine* engine) {
|
||||
MessageObject::FilteringAction MessageFilter::filterMessage(QJSEngine* engine) {
|
||||
// NOTE: Filter is represented by JavaScript code, each filter must define
|
||||
// function with "filterMessage()" prototype. There is a global "msg" object
|
||||
// representing "message" available.
|
||||
@ -56,7 +56,7 @@ FilteringAction MessageFilter::filterMessage(QJSEngine* engine) {
|
||||
throw FilteringException(error, message);
|
||||
}
|
||||
|
||||
return FilteringAction(filter_output.toInt());
|
||||
return MessageObject::FilteringAction(filter_output.toInt());
|
||||
}
|
||||
|
||||
int MessageFilter::id() const {
|
||||
@ -79,10 +79,17 @@ void MessageFilter::setScript(const QString& script) {
|
||||
m_script = script;
|
||||
}
|
||||
|
||||
void MessageFilter::initializeFilteringEngine(QJSEngine& engine) {
|
||||
void MessageFilter::initializeFilteringEngine(QJSEngine& engine, MessageObject* message_wrapper) {
|
||||
engine.installExtensions(QJSEngine::Extension::ConsoleExtension);
|
||||
engine.globalObject().setProperty("MSG_ACCEPT", int(FilteringAction::Accept));
|
||||
engine.globalObject().setProperty("MSG_IGNORE", int(FilteringAction::Ignore));
|
||||
engine.globalObject().setProperty("MSG_ACCEPT", int(MessageObject::FilteringAction::Accept));
|
||||
engine.globalObject().setProperty("MSG_IGNORE", int(MessageObject::FilteringAction::Ignore));
|
||||
|
||||
// Register the wrapper.
|
||||
auto js_object = engine.newQObject(message_wrapper);
|
||||
auto js_meta_object = engine.newQMetaObject(&message_wrapper->staticMetaObject);
|
||||
|
||||
engine.globalObject().setProperty("msg", js_object);
|
||||
engine.globalObject().setProperty(message_wrapper->staticMetaObject.className(), js_meta_object);
|
||||
}
|
||||
|
||||
void MessageFilter::setId(int id) {
|
||||
|
@ -16,7 +16,7 @@ class MessageFilter : public QObject {
|
||||
public:
|
||||
explicit MessageFilter(int id = -1, QObject* parent = nullptr);
|
||||
|
||||
FilteringAction filterMessage(QJSEngine* engine);
|
||||
MessageObject::FilteringAction filterMessage(QJSEngine* engine);
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
@ -27,7 +27,7 @@ class MessageFilter : public QObject {
|
||||
QString script() const;
|
||||
void setScript(const QString& script);
|
||||
|
||||
static void initializeFilteringEngine(QJSEngine& engine);
|
||||
static void initializeFilteringEngine(QJSEngine& engine, MessageObject* message_wrapper);
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
|
@ -147,31 +147,26 @@ void FormMessageFiltersManager::loadFilter() {
|
||||
void FormMessageFiltersManager::testFilter() {
|
||||
// Perform per-message filtering.
|
||||
QJSEngine filter_engine;
|
||||
|
||||
MessageFilter::initializeFilteringEngine(filter_engine);
|
||||
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||
|
||||
// Create JavaScript communication wrapper for the message.
|
||||
MessageObject msg_obj(&database, QString::number(NO_PARENT_CATEGORY), NO_PARENT_CATEGORY);
|
||||
|
||||
// Register the wrapper.
|
||||
auto js_object = filter_engine.newQObject(&msg_obj);
|
||||
|
||||
filter_engine.globalObject().setProperty("msg", js_object);
|
||||
|
||||
MessageObject msg_obj(&database,
|
||||
QString::number(NO_PARENT_CATEGORY),
|
||||
selectedAccount() != nullptr
|
||||
? selectedAccount()->accountId()
|
||||
: NO_PARENT_CATEGORY,
|
||||
{});
|
||||
auto* fltr = selectedFilter();
|
||||
Message msg = testingMessage();
|
||||
|
||||
MessageFilter::initializeFilteringEngine(filter_engine, &msg_obj);
|
||||
|
||||
msg_obj.setMessage(&msg);
|
||||
|
||||
auto* fltr = selectedFilter();
|
||||
|
||||
try {
|
||||
FilteringAction decision = fltr->filterMessage(&filter_engine);
|
||||
MessageObject::FilteringAction decision = fltr->filterMessage(&filter_engine);
|
||||
|
||||
m_ui.m_txtErrors->setTextColor(decision == FilteringAction::Accept ? Qt::GlobalColor::darkGreen : Qt::GlobalColor::red);
|
||||
m_ui.m_txtErrors->setTextColor(decision == MessageObject::FilteringAction::Accept ? Qt::GlobalColor::darkGreen : Qt::GlobalColor::red);
|
||||
|
||||
QString answer = tr("Message will be %1.\n\n").arg(decision == FilteringAction::Accept
|
||||
QString answer = tr("Message will be %1.\n\n").arg(decision == MessageObject::FilteringAction::Accept
|
||||
? tr("ACCEPTED")
|
||||
: tr("REJECTED"));
|
||||
|
||||
@ -351,6 +346,7 @@ void FormMessageFiltersManager::initializeTestingMessage() {
|
||||
Message FormMessageFiltersManager::testingMessage() const {
|
||||
Message msg;
|
||||
|
||||
msg.m_feedId = NO_PARENT_CATEGORY;
|
||||
msg.m_url = m_ui.m_txtSampleUrl->text();
|
||||
msg.m_title = m_ui.m_txtSampleTitle->text();
|
||||
msg.m_author = m_ui.m_txtSampleAuthor->text();
|
||||
|
@ -116,7 +116,7 @@ QString s_customLogFile = QString();
|
||||
void Application::performLogging(QtMsgType type, const QMessageLogContext& context, const QString& msg) {
|
||||
#ifndef QT_NO_DEBUG_OUTPUT
|
||||
QString console_message = qFormatLogMessage(type, context, msg);
|
||||
std::wcout << console_message.toStdWString() << std::endl;
|
||||
std::cout << console_message.toStdString() << std::endl;
|
||||
|
||||
if (!s_customLogFile.isEmpty()) {
|
||||
QFile log_file(s_customLogFile);
|
||||
@ -584,7 +584,8 @@ void Application::determineFirstRuns() {
|
||||
|
||||
void Application::parseCmdArguments() {
|
||||
QCommandLineOption log_file(QStringList() << CLI_LOG_SHORT << CLI_LOG_LONG,
|
||||
"Write application debug log to file.", "log-file");
|
||||
"Write application debug log to file. Note that logging to file may slow application down.",
|
||||
"log-file");
|
||||
QCommandLineOption custom_data_folder(QStringList() << CLI_DAT_SHORT << CLI_DAT_LONG,
|
||||
"Use custom folder for user data and disable single instance application mode.",
|
||||
"user-data-folder");
|
||||
|
@ -70,6 +70,10 @@ QString WebFactory::stripTags(QString text) {
|
||||
}
|
||||
|
||||
QString WebFactory::unescapeHtml(const QString& html) {
|
||||
if (html.isEmpty()) {
|
||||
return html;
|
||||
}
|
||||
|
||||
if (m_htmlNamedEntities.isEmpty()) {
|
||||
generateUnescapes();
|
||||
}
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>622</width>
|
||||
<height>442</height>
|
||||
<width>519</width>
|
||||
<height>352</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -15,7 +15,15 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabGeneral">
|
||||
<attribute name="title">
|
||||
<string>General</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_lblParentCategory">
|
||||
<property name="text">
|
||||
@ -77,34 +85,6 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Auto-update</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_cmbAutoUpdateType</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="m_cmbAutoUpdateType">
|
||||
<property name="toolTip">
|
||||
<string>Select the auto-update strategy for this feed. Default auto-update strategy means that the feed will be update in time intervals set in application settings.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="TimeSpinBox" name="m_spinAutoUpdateInterval">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="m_lblTitle">
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
@ -114,10 +94,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="LineEditWithStatus" name="m_txtTitle" native="true"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="m_lblDescription">
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
@ -127,10 +107,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="LineEditWithStatus" name="m_txtDescription" native="true"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>URL</string>
|
||||
@ -140,10 +120,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="LineEditWithStatus" name="m_txtUrl" native="true"/>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Fetch metadata</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_btnFetchMetadata</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnFetchMetadata">
|
||||
@ -167,7 +157,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="m_lblIcon">
|
||||
<property name="text">
|
||||
<string>Icon</string>
|
||||
@ -177,7 +167,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QToolButton" name="m_btnIcon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
@ -214,7 +204,49 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabUpdating">
|
||||
<attribute name="title">
|
||||
<string>Auto-updating</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Auto-update</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_cmbAutoUpdateType</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="m_cmbAutoUpdateType">
|
||||
<property name="toolTip">
|
||||
<string>Select the auto-update strategy for this feed. Default auto-update strategy means that the feed will be update in time intervals set in application settings.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="TimeSpinBox" name="m_spinAutoUpdateInterval">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabNetwork">
|
||||
<attribute name="title">
|
||||
<string>Network</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="m_gbAuthentication">
|
||||
<property name="toolTip">
|
||||
<string>Some feeds require authentication, including GMail feeds. BASIC, NTLM-2 and DIGEST-MD5 authentication schemes are supported.</string>
|
||||
@ -261,17 +293,9 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Fetch metadata</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_btnFetchMetadata</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||
|
@ -110,7 +110,10 @@ QIcon Label::generateIcon(const QColor& color) {
|
||||
}
|
||||
|
||||
void Label::assignToMessage(const Message& msg) {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||
bool is_main_thread = QThread::currentThread() == qApp->thread();
|
||||
QSqlDatabase database = is_main_thread ?
|
||||
qApp->database()->connection(metaObject()->className()) :
|
||||
qApp->database()->connection(QSL("feed_upd"));
|
||||
|
||||
if (getParentServiceRoot()->onBeforeLabelMessageAssignmentChanged({ this }, { msg }, true)) {
|
||||
DatabaseQueries::assignLabelToMessage(database, this, msg);
|
||||
@ -120,7 +123,10 @@ void Label::assignToMessage(const Message& msg) {
|
||||
}
|
||||
|
||||
void Label::deassignFromMessage(const Message& msg) {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||
bool is_main_thread = QThread::currentThread() == qApp->thread();
|
||||
QSqlDatabase database = is_main_thread ?
|
||||
qApp->database()->connection(metaObject()->className()) :
|
||||
qApp->database()->connection(QSL("feed_upd"));
|
||||
|
||||
if (getParentServiceRoot()->onBeforeLabelMessageAssignmentChanged({ this }, { msg }, false)) {
|
||||
DatabaseQueries::deassignLabelFromMessage(database, this, msg);
|
||||
|
@ -11,7 +11,6 @@ class RSSGUARD_DLLSPEC Label : public RootItem {
|
||||
Q_OBJECT
|
||||
|
||||
// Added for message filtering with labels.
|
||||
Q_PROPERTY(QString customId READ customId)
|
||||
Q_PROPERTY(QColor color READ color)
|
||||
|
||||
public:
|
||||
|
@ -23,6 +23,7 @@ class RSSGUARD_DLLSPEC RootItem : public QObject {
|
||||
|
||||
// Added for message filtering with labels.
|
||||
Q_PROPERTY(QString title READ title)
|
||||
Q_PROPERTY(QString customId READ customId)
|
||||
|
||||
public:
|
||||
enum class ReadStatus {
|
||||
|
Loading…
x
Reference in New Issue
Block a user