merge
This commit is contained in:
commit
04ae1c54dd
8 changed files with 296 additions and 285 deletions
|
@ -110,7 +110,7 @@ void Message::sanitize(const Feed* feed, bool fix_future_datetimes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Message Message::fromSqlRecord(const QSqlRecord& record, bool* result) {
|
Message Message::fromSqlRecord(const QSqlRecord& record, bool* result) {
|
||||||
if (record.count() != MSG_DB_HAS_ENCLOSURES + 1) {
|
if (record.count() != MSG_DB_LABELS + 1) {
|
||||||
if (result != nullptr) {
|
if (result != nullptr) {
|
||||||
*result = false;
|
*result = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,40 +225,24 @@ void MessagesModel::setupHeaderData() {
|
||||||
m_headerData <<
|
m_headerData <<
|
||||||
|
|
||||||
/*: Tooltip for ID of message.*/ tr("Id") <<
|
/*: Tooltip for ID of message.*/ tr("Id") <<
|
||||||
|
|
||||||
/*: Tooltip for "read" column in msg list.*/ tr("Read") <<
|
/*: Tooltip for "read" column in msg list.*/ tr("Read") <<
|
||||||
|
|
||||||
/*: Tooltip for "important" column in msg list.*/ tr("Important") <<
|
/*: Tooltip for "important" column in msg list.*/ tr("Important") <<
|
||||||
|
|
||||||
/*: Tooltip for "deleted" column in msg list.*/ tr("Deleted") <<
|
/*: Tooltip for "deleted" column in msg list.*/ tr("Deleted") <<
|
||||||
|
|
||||||
/*: Tooltip for "pdeleted" column in msg list.*/ tr("Permanently deleted") <<
|
/*: Tooltip for "pdeleted" column in msg list.*/ tr("Permanently deleted") <<
|
||||||
|
|
||||||
/*: Tooltip for custom ID of feed of message.*/ tr("Feed ID") <<
|
/*: Tooltip for custom ID of feed of message.*/ tr("Feed ID") <<
|
||||||
|
|
||||||
/*: Tooltip for title of message.*/ tr("Title") <<
|
/*: Tooltip for title of message.*/ tr("Title") <<
|
||||||
|
|
||||||
/*: Tooltip for url of message.*/ tr("Url") <<
|
/*: Tooltip for url of message.*/ tr("Url") <<
|
||||||
|
|
||||||
/*: Tooltip for author of message.*/ tr("Author") <<
|
/*: Tooltip for author of message.*/ tr("Author") <<
|
||||||
|
|
||||||
/*: Tooltip for creation date of message.*/ tr("Date") <<
|
/*: Tooltip for creation date of message.*/ tr("Date") <<
|
||||||
|
|
||||||
/*: Tooltip for contents of message.*/ tr("Contents") <<
|
/*: Tooltip for contents of message.*/ tr("Contents") <<
|
||||||
|
|
||||||
/*: Tooltip for attachments of message.*/ tr("Attachments") <<
|
/*: Tooltip for attachments of message.*/ tr("Attachments") <<
|
||||||
|
|
||||||
/*: Tooltip for score of message.*/ tr("Score") <<
|
/*: Tooltip for score of message.*/ tr("Score") <<
|
||||||
|
|
||||||
/*: Tooltip for account ID of message.*/ tr("Account ID") <<
|
/*: Tooltip for account ID of message.*/ tr("Account ID") <<
|
||||||
|
|
||||||
/*: Tooltip for custom ID of message.*/ tr("Custom ID") <<
|
/*: Tooltip for custom ID of message.*/ tr("Custom ID") <<
|
||||||
|
|
||||||
/*: Tooltip for custom hash string of message.*/ tr("Custom hash") <<
|
/*: Tooltip for custom hash string of message.*/ tr("Custom hash") <<
|
||||||
|
|
||||||
/*: Tooltip for name of feed for message.*/ tr("Feed") <<
|
/*: Tooltip for name of feed for message.*/ tr("Feed") <<
|
||||||
|
/*: Tooltip for indication of presence of enclosures.*/ tr("Has enclosures") <<
|
||||||
/*: Tooltip for indication of presence of enclosures.*/ tr("Has enclosures");
|
/*: Tooltip for indication of labels of message.*/ tr("Assigned labels");
|
||||||
|
|
||||||
m_tooltipData << tr("ID of the article.") << tr("Is article read?") << tr("Is article important?")
|
m_tooltipData << tr("ID of the article.") << tr("Is article read?") << tr("Is article important?")
|
||||||
<< tr("Is article deleted?") << tr("Is article permanently deleted from recycle bin?")
|
<< tr("Is article deleted?") << tr("Is article permanently deleted from recycle bin?")
|
||||||
|
@ -267,7 +251,7 @@ void MessagesModel::setupHeaderData() {
|
||||||
<< tr("Contents of the article.") << tr("List of attachments.") << tr("Score of the article.")
|
<< tr("Contents of the article.") << tr("List of attachments.") << tr("Score of the article.")
|
||||||
<< tr("Account ID of the article.") << tr("Custom ID of the article.")
|
<< tr("Account ID of the article.") << tr("Custom ID of the article.")
|
||||||
<< tr("Custom hash of the article.") << tr("Name of feed of the article.")
|
<< tr("Custom hash of the article.") << tr("Name of feed of the article.")
|
||||||
<< tr("Indication of enclosures presence within the article.");
|
<< tr("Indication of enclosures presence within the article.") << tr("Labels assigned to the article.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags MessagesModel::flags(const QModelIndex& index) const {
|
Qt::ItemFlags MessagesModel::flags(const QModelIndex& index) const {
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#include "miscellaneous/application.h"
|
#include "miscellaneous/application.h"
|
||||||
|
|
||||||
MessagesModelSqlLayer::MessagesModelSqlLayer()
|
MessagesModelSqlLayer::MessagesModelSqlLayer()
|
||||||
: m_filter(QSL(DEFAULT_SQL_MESSAGES_FILTER)), m_fieldNames({}), m_orderByNames({}),
|
: m_filter(QSL(DEFAULT_SQL_MESSAGES_FILTER)), m_fieldNames({}), m_orderByNames({}), m_sortColumns({}),
|
||||||
m_sortColumns({}), m_numericColumns({}), m_sortOrders({}) {
|
m_numericColumns({}), m_sortOrders({}) {
|
||||||
m_db = qApp->database()->driver()->connection(QSL("MessagesModel"));
|
m_db = qApp->database()->driver()->connection(QSL("MessagesModel"));
|
||||||
|
|
||||||
// Used in <x>: SELECT <x1>, <x2> FROM ....;
|
// Used in <x>: SELECT <x1>, <x2> FROM ....;
|
||||||
|
@ -33,16 +33,16 @@ MessagesModelSqlLayer::MessagesModelSqlLayer()
|
||||||
m_orderByNames[MSG_DB_CUSTOM_HASH_INDEX] = QSL("Messages.custom_hash");
|
m_orderByNames[MSG_DB_CUSTOM_HASH_INDEX] = QSL("Messages.custom_hash");
|
||||||
m_orderByNames[MSG_DB_FEED_TITLE_INDEX] = QSL("Feeds.title");
|
m_orderByNames[MSG_DB_FEED_TITLE_INDEX] = QSL("Feeds.title");
|
||||||
m_orderByNames[MSG_DB_HAS_ENCLOSURES] = QSL("has_enclosures");
|
m_orderByNames[MSG_DB_HAS_ENCLOSURES] = QSL("has_enclosures");
|
||||||
|
m_orderByNames[MSG_DB_LABELS] = QSL("msg_labels");
|
||||||
|
|
||||||
m_numericColumns << MSG_DB_ID_INDEX << MSG_DB_READ_INDEX << MSG_DB_DELETED_INDEX << MSG_DB_PDELETED_INDEX
|
m_numericColumns << MSG_DB_ID_INDEX << MSG_DB_READ_INDEX << MSG_DB_DELETED_INDEX << MSG_DB_PDELETED_INDEX
|
||||||
<< MSG_DB_IMPORTANT_INDEX << MSG_DB_ACCOUNT_ID_INDEX << MSG_DB_DCREATED_INDEX
|
<< MSG_DB_IMPORTANT_INDEX << MSG_DB_ACCOUNT_ID_INDEX << MSG_DB_DCREATED_INDEX << MSG_DB_SCORE_INDEX;
|
||||||
<< MSG_DB_SCORE_INDEX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesModelSqlLayer::addSortState(int column, Qt::SortOrder order, bool ignore_multicolumn_sorting) {
|
void MessagesModelSqlLayer::addSortState(int column, Qt::SortOrder order, bool ignore_multicolumn_sorting) {
|
||||||
int existing = m_sortColumns.indexOf(column);
|
int existing = m_sortColumns.indexOf(column);
|
||||||
bool is_ctrl_pressed = (QApplication::queryKeyboardModifiers() &
|
bool is_ctrl_pressed = (QApplication::queryKeyboardModifiers() & Qt::KeyboardModifier::ControlModifier) ==
|
||||||
Qt::KeyboardModifier::ControlModifier) == Qt::KeyboardModifier::ControlModifier;
|
Qt::KeyboardModifier::ControlModifier;
|
||||||
|
|
||||||
if (existing >= 0) {
|
if (existing >= 0) {
|
||||||
m_sortColumns.removeAt(existing);
|
m_sortColumns.removeAt(existing);
|
||||||
|
@ -85,7 +85,8 @@ bool MessagesModelSqlLayer::isColumnNumeric(int column_id) const {
|
||||||
|
|
||||||
QString MessagesModelSqlLayer::selectStatement() const {
|
QString MessagesModelSqlLayer::selectStatement() const {
|
||||||
return QL1S("SELECT ") + formatFields() + QL1C(' ') +
|
return QL1S("SELECT ") + formatFields() + QL1C(' ') +
|
||||||
QL1S("FROM Messages LEFT JOIN Feeds ON Messages.feed = Feeds.custom_id AND Messages.account_id = Feeds.account_id "
|
QL1S("FROM Messages LEFT JOIN Feeds ON Messages.feed = Feeds.custom_id AND Messages.account_id = "
|
||||||
|
"Feeds.account_id "
|
||||||
"WHERE ") +
|
"WHERE ") +
|
||||||
m_filter + orderByClause() + QL1C(';');
|
m_filter + orderByClause() + QL1C(';');
|
||||||
}
|
}
|
||||||
|
@ -99,12 +100,10 @@ QString MessagesModelSqlLayer::orderByClause() const {
|
||||||
|
|
||||||
for (int i = 0; i < m_sortColumns.size(); i++) {
|
for (int i = 0; i < m_sortColumns.size(); i++) {
|
||||||
QString field_name(m_orderByNames[m_sortColumns[i]]);
|
QString field_name(m_orderByNames[m_sortColumns[i]]);
|
||||||
QString order_sql = isColumnNumeric(m_sortColumns[i])
|
QString order_sql = isColumnNumeric(m_sortColumns[i]) ? QSL("%1") : QSL("LOWER(%1)");
|
||||||
? QSL("%1")
|
|
||||||
: QSL("LOWER(%1)");
|
|
||||||
|
|
||||||
//sorts.append(QSL("LENGTH(%1)").arg(order_sql.arg(field_name)) +
|
// sorts.append(QSL("LENGTH(%1)").arg(order_sql.arg(field_name)) +
|
||||||
// (m_sortOrders[i] == Qt::SortOrder::AscendingOrder ? QSL(" ASC") : QSL(" DESC")));
|
// (m_sortOrders[i] == Qt::SortOrder::AscendingOrder ? QSL(" ASC") : QSL(" DESC")));
|
||||||
|
|
||||||
sorts.append(order_sql.arg(field_name) +
|
sorts.append(order_sql.arg(field_name) +
|
||||||
(m_sortOrders[i] == Qt::SortOrder::AscendingOrder ? QSL(" ASC") : QSL(" DESC")));
|
(m_sortOrders[i] == Qt::SortOrder::AscendingOrder ? QSL(" ASC") : QSL(" DESC")));
|
||||||
|
|
|
@ -20,9 +20,10 @@ void DatabaseDriver::updateDatabaseSchema(QSqlQuery& query,
|
||||||
|
|
||||||
while (source_db_schema_version != current_version) {
|
while (source_db_schema_version != current_version) {
|
||||||
const QStringList statements = prepareScript(APP_SQL_PATH,
|
const QStringList statements = prepareScript(APP_SQL_PATH,
|
||||||
QSL(APP_DB_UPDATE_FILE_PATTERN).arg(ddlFilePrefix(),
|
QSL(APP_DB_UPDATE_FILE_PATTERN)
|
||||||
QString::number(source_db_schema_version),
|
.arg(ddlFilePrefix(),
|
||||||
QString::number(source_db_schema_version + 1)),
|
QString::number(source_db_schema_version),
|
||||||
|
QString::number(source_db_schema_version + 1)),
|
||||||
database_name);
|
database_name);
|
||||||
|
|
||||||
for (const QString& statement : statements) {
|
for (const QString& statement : statements) {
|
||||||
|
@ -32,10 +33,7 @@ void DatabaseDriver::updateDatabaseSchema(QSqlQuery& query,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increment the version.
|
// Increment the version.
|
||||||
qDebugNN << LOGSEC_DB
|
qDebugNN << LOGSEC_DB << "Updating database schema " << QUOTE_W_SPACE(source_db_schema_version) << "->"
|
||||||
<< "Updating database schema "
|
|
||||||
<< QUOTE_W_SPACE(source_db_schema_version)
|
|
||||||
<< "->"
|
|
||||||
<< QUOTE_W_SPACE_DOT(source_db_schema_version + 1);
|
<< QUOTE_W_SPACE_DOT(source_db_schema_version + 1);
|
||||||
|
|
||||||
source_db_schema_version++;
|
source_db_schema_version++;
|
||||||
|
@ -46,8 +44,8 @@ void DatabaseDriver::updateDatabaseSchema(QSqlQuery& query,
|
||||||
|
|
||||||
void DatabaseDriver::setSchemaVersion(QSqlQuery& query, int new_schema_version, bool empty_table) {
|
void DatabaseDriver::setSchemaVersion(QSqlQuery& query, int new_schema_version, bool empty_table) {
|
||||||
if (!query.prepare(empty_table
|
if (!query.prepare(empty_table
|
||||||
? QSL("INSERT INTO Information VALUES ('schema_version', :schema_version);")
|
? QSL("INSERT INTO Information VALUES ('schema_version', :schema_version);")
|
||||||
: QSL("UPDATE Information SET inf_value = :schema_version WHERE inf_key = 'schema_version';"))) {
|
: QSL("UPDATE Information SET inf_value = :schema_version WHERE inf_key = 'schema_version';"))) {
|
||||||
throw ApplicationException(query.lastError().text());
|
throw ApplicationException(query.lastError().text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +71,7 @@ QStringList DatabaseDriver::prepareScript(const QString& base_sql_folder,
|
||||||
for (int i = 0; i < new_statements.size(); i++) {
|
for (int i = 0; i < new_statements.size(); i++) {
|
||||||
if (new_statements.at(i).startsWith(QSL(APP_DB_INCLUDE_PLACEHOLDER))) {
|
if (new_statements.at(i).startsWith(QSL(APP_DB_INCLUDE_PLACEHOLDER))) {
|
||||||
// We include another file.
|
// We include another file.
|
||||||
QString included_file_name = new_statements.at(i).mid(QSL(APP_DB_INCLUDE_PLACEHOLDER).size() + 1);
|
QString included_file_name = new_statements.at(i).mid(QSL(APP_DB_INCLUDE_PLACEHOLDER).size() + 1).simplified();
|
||||||
|
|
||||||
QString included_file = base_sql_folder + QDir::separator() + included_file_name;
|
QString included_file = base_sql_folder + QDir::separator() + included_file_name;
|
||||||
QString included_sql_script = QString::fromUtf8(IOFactory::readFile(included_file));
|
QString included_sql_script = QString::fromUtf8(IOFactory::readFile(included_file));
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -255,6 +255,7 @@
|
||||||
#define MSG_DB_CUSTOM_HASH_INDEX 15
|
#define MSG_DB_CUSTOM_HASH_INDEX 15
|
||||||
#define MSG_DB_FEED_TITLE_INDEX 16
|
#define MSG_DB_FEED_TITLE_INDEX 16
|
||||||
#define MSG_DB_HAS_ENCLOSURES 17
|
#define MSG_DB_HAS_ENCLOSURES 17
|
||||||
|
#define MSG_DB_LABELS 18
|
||||||
|
|
||||||
// Indexes of columns as they are DEFINED IN THE TABLE for CATEGORIES.
|
// Indexes of columns as they are DEFINED IN THE TABLE for CATEGORIES.
|
||||||
#define CAT_DB_ID_INDEX 0
|
#define CAT_DB_ID_INDEX 0
|
||||||
|
|
|
@ -826,6 +826,7 @@ void MessagesView::adjustColumns() {
|
||||||
hideColumn(MSG_DB_FEED_CUSTOM_ID_INDEX);
|
hideColumn(MSG_DB_FEED_CUSTOM_ID_INDEX);
|
||||||
hideColumn(MSG_DB_FEED_TITLE_INDEX);
|
hideColumn(MSG_DB_FEED_TITLE_INDEX);
|
||||||
hideColumn(MSG_DB_HAS_ENCLOSURES);
|
hideColumn(MSG_DB_HAS_ENCLOSURES);
|
||||||
|
hideColumn(MSG_DB_LABELS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,8 @@ int TextFactory::stringWidth(const QString& string, const QFontMetrics& metrics)
|
||||||
bool TextFactory::couldBeHtml(const QString& string) {
|
bool TextFactory::couldBeHtml(const QString& string) {
|
||||||
const QString sstring = string.simplified();
|
const QString sstring = string.simplified();
|
||||||
|
|
||||||
return sstring.startsWith(QL1S("<!")) || sstring.startsWith(QL1S("<figure")) || Qt::mightBeRichText(sstring);
|
return sstring.startsWith(QL1S("<!")) || sstring.startsWith(QL1S("<html")) || sstring.startsWith(QL1S("<figure")) ||
|
||||||
|
Qt::mightBeRichText(sstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime TextFactory::parseDateTime(const QString& date_time) {
|
QDateTime TextFactory::parseDateTime(const QString& date_time) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue