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) {
|
||||
if (record.count() != MSG_DB_HAS_ENCLOSURES + 1) {
|
||||
if (record.count() != MSG_DB_LABELS + 1) {
|
||||
if (result != nullptr) {
|
||||
*result = false;
|
||||
}
|
||||
|
|
|
@ -225,40 +225,24 @@ void MessagesModel::setupHeaderData() {
|
|||
m_headerData <<
|
||||
|
||||
/*: Tooltip for ID of message.*/ tr("Id") <<
|
||||
|
||||
/*: Tooltip for "read" column in msg list.*/ tr("Read") <<
|
||||
|
||||
/*: Tooltip for "important" column in msg list.*/ tr("Important") <<
|
||||
|
||||
/*: Tooltip for "deleted" column in msg list.*/ tr("Deleted") <<
|
||||
|
||||
/*: Tooltip for "pdeleted" column in msg list.*/ tr("Permanently deleted") <<
|
||||
|
||||
/*: Tooltip for custom ID of feed of message.*/ tr("Feed ID") <<
|
||||
|
||||
/*: Tooltip for title of message.*/ tr("Title") <<
|
||||
|
||||
/*: Tooltip for url of message.*/ tr("Url") <<
|
||||
|
||||
/*: Tooltip for author of message.*/ tr("Author") <<
|
||||
|
||||
/*: Tooltip for creation date of message.*/ tr("Date") <<
|
||||
|
||||
/*: Tooltip for contents of message.*/ tr("Contents") <<
|
||||
|
||||
/*: Tooltip for attachments of message.*/ tr("Attachments") <<
|
||||
|
||||
/*: Tooltip for score of message.*/ tr("Score") <<
|
||||
|
||||
/*: Tooltip for account ID of message.*/ tr("Account ID") <<
|
||||
|
||||
/*: Tooltip for custom ID of message.*/ tr("Custom ID") <<
|
||||
|
||||
/*: Tooltip for custom hash string of message.*/ tr("Custom hash") <<
|
||||
|
||||
/*: 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?")
|
||||
<< 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("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("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 {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#include "miscellaneous/application.h"
|
||||
|
||||
MessagesModelSqlLayer::MessagesModelSqlLayer()
|
||||
: m_filter(QSL(DEFAULT_SQL_MESSAGES_FILTER)), m_fieldNames({}), m_orderByNames({}),
|
||||
m_sortColumns({}), m_numericColumns({}), m_sortOrders({}) {
|
||||
: m_filter(QSL(DEFAULT_SQL_MESSAGES_FILTER)), m_fieldNames({}), m_orderByNames({}), m_sortColumns({}),
|
||||
m_numericColumns({}), m_sortOrders({}) {
|
||||
m_db = qApp->database()->driver()->connection(QSL("MessagesModel"));
|
||||
|
||||
// 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_FEED_TITLE_INDEX] = QSL("Feeds.title");
|
||||
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
|
||||
<< MSG_DB_IMPORTANT_INDEX << MSG_DB_ACCOUNT_ID_INDEX << MSG_DB_DCREATED_INDEX
|
||||
<< MSG_DB_SCORE_INDEX;
|
||||
<< MSG_DB_IMPORTANT_INDEX << MSG_DB_ACCOUNT_ID_INDEX << MSG_DB_DCREATED_INDEX << MSG_DB_SCORE_INDEX;
|
||||
}
|
||||
|
||||
void MessagesModelSqlLayer::addSortState(int column, Qt::SortOrder order, bool ignore_multicolumn_sorting) {
|
||||
int existing = m_sortColumns.indexOf(column);
|
||||
bool is_ctrl_pressed = (QApplication::queryKeyboardModifiers() &
|
||||
Qt::KeyboardModifier::ControlModifier) == Qt::KeyboardModifier::ControlModifier;
|
||||
bool is_ctrl_pressed = (QApplication::queryKeyboardModifiers() & Qt::KeyboardModifier::ControlModifier) ==
|
||||
Qt::KeyboardModifier::ControlModifier;
|
||||
|
||||
if (existing >= 0) {
|
||||
m_sortColumns.removeAt(existing);
|
||||
|
@ -85,7 +85,8 @@ bool MessagesModelSqlLayer::isColumnNumeric(int column_id) const {
|
|||
|
||||
QString MessagesModelSqlLayer::selectStatement() const {
|
||||
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 ") +
|
||||
m_filter + orderByClause() + QL1C(';');
|
||||
}
|
||||
|
@ -99,12 +100,10 @@ QString MessagesModelSqlLayer::orderByClause() const {
|
|||
|
||||
for (int i = 0; i < m_sortColumns.size(); i++) {
|
||||
QString field_name(m_orderByNames[m_sortColumns[i]]);
|
||||
QString order_sql = isColumnNumeric(m_sortColumns[i])
|
||||
? QSL("%1")
|
||||
: QSL("LOWER(%1)");
|
||||
QString order_sql = isColumnNumeric(m_sortColumns[i]) ? QSL("%1") : QSL("LOWER(%1)");
|
||||
|
||||
//sorts.append(QSL("LENGTH(%1)").arg(order_sql.arg(field_name)) +
|
||||
// (m_sortOrders[i] == Qt::SortOrder::AscendingOrder ? QSL(" ASC") : QSL(" DESC")));
|
||||
// sorts.append(QSL("LENGTH(%1)").arg(order_sql.arg(field_name)) +
|
||||
// (m_sortOrders[i] == Qt::SortOrder::AscendingOrder ? QSL(" ASC") : QSL(" DESC")));
|
||||
|
||||
sorts.append(order_sql.arg(field_name) +
|
||||
(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) {
|
||||
const QStringList statements = prepareScript(APP_SQL_PATH,
|
||||
QSL(APP_DB_UPDATE_FILE_PATTERN).arg(ddlFilePrefix(),
|
||||
QString::number(source_db_schema_version),
|
||||
QString::number(source_db_schema_version + 1)),
|
||||
QSL(APP_DB_UPDATE_FILE_PATTERN)
|
||||
.arg(ddlFilePrefix(),
|
||||
QString::number(source_db_schema_version),
|
||||
QString::number(source_db_schema_version + 1)),
|
||||
database_name);
|
||||
|
||||
for (const QString& statement : statements) {
|
||||
|
@ -32,10 +33,7 @@ void DatabaseDriver::updateDatabaseSchema(QSqlQuery& query,
|
|||
}
|
||||
|
||||
// Increment the version.
|
||||
qDebugNN << LOGSEC_DB
|
||||
<< "Updating database schema "
|
||||
<< QUOTE_W_SPACE(source_db_schema_version)
|
||||
<< "->"
|
||||
qDebugNN << LOGSEC_DB << "Updating database schema " << QUOTE_W_SPACE(source_db_schema_version) << "->"
|
||||
<< QUOTE_W_SPACE_DOT(source_db_schema_version + 1);
|
||||
|
||||
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) {
|
||||
if (!query.prepare(empty_table
|
||||
? QSL("INSERT INTO Information VALUES ('schema_version', :schema_version);")
|
||||
: QSL("UPDATE Information SET inf_value = :schema_version WHERE inf_key = 'schema_version';"))) {
|
||||
? QSL("INSERT INTO Information VALUES ('schema_version', :schema_version);")
|
||||
: QSL("UPDATE Information SET inf_value = :schema_version WHERE inf_key = 'schema_version';"))) {
|
||||
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++) {
|
||||
if (new_statements.at(i).startsWith(QSL(APP_DB_INCLUDE_PLACEHOLDER))) {
|
||||
// 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_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_FEED_TITLE_INDEX 16
|
||||
#define MSG_DB_HAS_ENCLOSURES 17
|
||||
#define MSG_DB_LABELS 18
|
||||
|
||||
// Indexes of columns as they are DEFINED IN THE TABLE for CATEGORIES.
|
||||
#define CAT_DB_ID_INDEX 0
|
||||
|
|
|
@ -826,6 +826,7 @@ void MessagesView::adjustColumns() {
|
|||
hideColumn(MSG_DB_FEED_CUSTOM_ID_INDEX);
|
||||
hideColumn(MSG_DB_FEED_TITLE_INDEX);
|
||||
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) {
|
||||
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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue