even better implementation of RTL which now works even when parent node is selected and RTL is automatically correctly decided for each individual article
This commit is contained in:
parent
8133fce9e8
commit
388c9297ac
@ -322,9 +322,11 @@ bool FeedsProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right
|
||||
bool FeedsProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const {
|
||||
bool should_show = filterAcceptsRowInternal(source_row, source_parent);
|
||||
|
||||
/*
|
||||
qDebugNN << LOGSEC_CORE << "Filter accepts row"
|
||||
<< QUOTE_W_SPACE(m_sourceModel->itemForIndex(m_sourceModel->index(source_row, 0, source_parent))->title())
|
||||
<< "and filter result is:" << QUOTE_W_SPACE_DOT(should_show);
|
||||
*/
|
||||
|
||||
/*
|
||||
if (should_show && (!filterRegularExpression().pattern().isEmpty() ||
|
||||
|
@ -68,7 +68,7 @@ Message::Message() {
|
||||
m_categories = QList<MessageCategory>();
|
||||
m_accountId = m_id = 0;
|
||||
m_score = 0.0;
|
||||
m_isRead = m_isImportant = m_isDeleted = false;
|
||||
m_isRead = m_isImportant = m_isDeleted = m_isRtl = false;
|
||||
m_assignedLabels = QList<Label*>();
|
||||
m_assignedLabelsByFilter = QList<Label*>();
|
||||
m_deassignedLabelsByFilter = QList<Label*>();
|
||||
@ -140,6 +140,7 @@ Message Message::fromSqlRecord(const QSqlRecord& record, bool* result) {
|
||||
message.m_contents = record.value(MSG_DB_CONTENTS_INDEX).toString();
|
||||
message.m_enclosures = Enclosures::decodeEnclosuresFromString(record.value(MSG_DB_ENCLOSURES_INDEX).toString());
|
||||
message.m_score = record.value(MSG_DB_SCORE_INDEX).toDouble();
|
||||
message.m_isRtl = record.value(MSG_DB_FEED_IS_RTL_INDEX).toBool();
|
||||
message.m_accountId = record.value(MSG_DB_ACCOUNT_ID_INDEX).toInt();
|
||||
message.m_customId = record.value(MSG_DB_CUSTOM_ID_INDEX).toString();
|
||||
message.m_customHash = record.value(MSG_DB_CUSTOM_HASH_INDEX).toString();
|
||||
@ -179,7 +180,7 @@ QString Message::generateRawAtomContents(const Message& msg) {
|
||||
|
||||
QDataStream& operator<<(QDataStream& out, const Message& my_obj) {
|
||||
out << my_obj.m_accountId << my_obj.m_customHash << my_obj.m_customId << my_obj.m_feedId << my_obj.m_id
|
||||
<< my_obj.m_isImportant << my_obj.m_isRead << my_obj.m_isDeleted << my_obj.m_score;
|
||||
<< my_obj.m_isImportant << my_obj.m_isRead << my_obj.m_isDeleted << my_obj.m_score << my_obj.m_isRtl;
|
||||
|
||||
return out;
|
||||
}
|
||||
@ -193,9 +194,11 @@ QDataStream& operator>>(QDataStream& in, Message& my_obj) {
|
||||
bool is_important;
|
||||
bool is_read;
|
||||
bool is_deleted;
|
||||
bool is_rtl;
|
||||
double score;
|
||||
|
||||
in >> account_id >> custom_hash >> custom_id >> feed_id >> id >> is_important >> is_read >> is_deleted >> score;
|
||||
in >> account_id >> custom_hash >> custom_id >> feed_id >> id >> is_important >> is_read >> is_deleted >> score >>
|
||||
is_rtl;
|
||||
|
||||
my_obj.m_accountId = account_id;
|
||||
my_obj.m_customHash = custom_hash;
|
||||
@ -206,6 +209,7 @@ QDataStream& operator>>(QDataStream& in, Message& my_obj) {
|
||||
my_obj.m_isRead = is_read;
|
||||
my_obj.m_isDeleted = is_deleted;
|
||||
my_obj.m_score = score;
|
||||
my_obj.m_isRtl = is_rtl;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ class RSSGUARD_DLLSPEC Message {
|
||||
bool m_isImportant;
|
||||
bool m_isDeleted;
|
||||
double m_score;
|
||||
bool m_isRtl;
|
||||
QList<Enclosure> m_enclosures;
|
||||
|
||||
// List of assigned labels.
|
||||
|
@ -294,6 +294,7 @@ void MessagesModel::setupHeaderData() {
|
||||
/*: 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 whether article is RTL or not.*/ tr("RTL") <<
|
||||
/*: Tooltip for indication of presence of enclosures.*/ tr("Has enclosures") <<
|
||||
/*: Tooltip for indication of labels of message.*/ tr("Assigned labels") <<
|
||||
/*: Tooltip for indication of label IDs of message.*/ tr("Assigned label IDs");
|
||||
@ -305,8 +306,8 @@ 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("Labels assigned to the article.")
|
||||
<< tr("Label IDs assigned to the article.");
|
||||
<< tr("Layout direction of the article") << tr("Indication of enclosures presence within the article.")
|
||||
<< tr("Labels assigned to the article.") << tr("Label IDs assigned to the article.");
|
||||
}
|
||||
|
||||
Qt::ItemFlags MessagesModel::flags(const QModelIndex& index) const {
|
||||
@ -409,6 +410,23 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
|
||||
}
|
||||
}
|
||||
|
||||
case TEXT_DIRECTION_ROLE: {
|
||||
int index_column = idx.column();
|
||||
|
||||
if (index_column != MSG_DB_TITLE_INDEX && index_column != MSG_DB_FEED_TITLE_INDEX &&
|
||||
index_column != MSG_DB_AUTHOR_INDEX) {
|
||||
return Qt::LayoutDirection::LayoutDirectionAuto;
|
||||
}
|
||||
else {
|
||||
return (m_cache->containsData(idx.row())
|
||||
? m_cache->data(index(idx.row(), MSG_DB_FEED_IS_RTL_INDEX))
|
||||
: QSqlQueryModel::data(index(idx.row(), MSG_DB_FEED_IS_RTL_INDEX), Qt::ItemDataRole::EditRole))
|
||||
.toInt() == 0
|
||||
? Qt::LayoutDirection::LayoutDirectionAuto
|
||||
: Qt::LayoutDirection::RightToLeft;
|
||||
}
|
||||
}
|
||||
|
||||
case LOWER_TITLE_ROLE:
|
||||
return m_cache->containsData(idx.row())
|
||||
? m_cache->data(idx).toString().toLower()
|
||||
|
@ -32,12 +32,14 @@ MessagesModelSqlLayer::MessagesModelSqlLayer()
|
||||
m_orderByNames[MSG_DB_CUSTOM_ID_INDEX] = QSL("Messages.custom_id");
|
||||
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_IS_RTL_INDEX] = QSL("Feeds.is_rtl");
|
||||
m_orderByNames[MSG_DB_HAS_ENCLOSURES] = QSL("has_enclosures");
|
||||
m_orderByNames[MSG_DB_LABELS] = QSL("msg_labels");
|
||||
m_orderByNames[MSG_DB_LABELS_IDS] = QSL("Messages.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
|
||||
<< MSG_DB_FEED_IS_RTL_INDEX;
|
||||
}
|
||||
|
||||
void MessagesModelSqlLayer::addSortState(int column, Qt::SortOrder order, bool ignore_multicolumn_sorting) {
|
||||
|
@ -33,7 +33,8 @@ QMap<int, QString> DatabaseQueries::messageTableAttributes(bool only_msg_table,
|
||||
field_names[MSG_DB_CUSTOM_ID_INDEX] = QSL("Messages.custom_id");
|
||||
field_names[MSG_DB_CUSTOM_HASH_INDEX] = QSL("Messages.custom_hash");
|
||||
field_names[MSG_DB_FEED_TITLE_INDEX] = only_msg_table ? QSL("Messages.feed") : QSL("Feeds.title");
|
||||
field_names[MSG_DB_HAS_ENCLOSURES] = QSL("CASE WHEN length(Messages.enclosures) > 10 "
|
||||
field_names[MSG_DB_FEED_IS_RTL_INDEX] = QSL("Feeds.is_rtl");
|
||||
field_names[MSG_DB_HAS_ENCLOSURES] = QSL("CASE WHEN LENGTH(Messages.enclosures) > 10 "
|
||||
"THEN 'true' "
|
||||
"ELSE 'false' "
|
||||
"END AS has_enclosures");
|
||||
|
@ -268,9 +268,10 @@
|
||||
#define MSG_DB_CUSTOM_ID_INDEX 14
|
||||
#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
|
||||
#define MSG_DB_LABELS_IDS 19
|
||||
#define MSG_DB_FEED_IS_RTL_INDEX 17
|
||||
#define MSG_DB_HAS_ENCLOSURES 18
|
||||
#define MSG_DB_LABELS 19
|
||||
#define MSG_DB_LABELS_IDS 20
|
||||
|
||||
// Indexes of columns as they are DEFINED IN THE TABLE for CATEGORIES.
|
||||
#define CAT_DB_ID_INDEX 0
|
||||
|
@ -516,6 +516,7 @@ void MessagesView::loadItem(RootItem* item) {
|
||||
sort(col, ord, false, true, false, true);
|
||||
m_sourceModel->loadMessages(item);
|
||||
|
||||
/*
|
||||
if (item->kind() == RootItem::Kind::Feed) {
|
||||
if (item->toFeed()->isRtl()) {
|
||||
setLayoutDirection(Qt::LayoutDirection::RightToLeft);
|
||||
@ -527,6 +528,7 @@ void MessagesView::loadItem(RootItem* item) {
|
||||
else {
|
||||
setLayoutDirection(Qt::LayoutDirection::LeftToRight);
|
||||
}
|
||||
*/
|
||||
|
||||
// Messages are loaded, make sure that previously
|
||||
// active message is not shown in browser.
|
||||
@ -838,6 +840,7 @@ void MessagesView::adjustColumns() {
|
||||
hideColumn(MSG_DB_CUSTOM_HASH_INDEX);
|
||||
hideColumn(MSG_DB_FEED_CUSTOM_ID_INDEX);
|
||||
hideColumn(MSG_DB_FEED_TITLE_INDEX);
|
||||
hideColumn(MSG_DB_FEED_IS_RTL_INDEX);
|
||||
hideColumn(MSG_DB_HAS_ENCLOSURES);
|
||||
hideColumn(MSG_DB_LABELS);
|
||||
|
||||
|
@ -303,10 +303,19 @@ void TextBrowserViewer::loadMessages(const QList<Message>& messages, RootItem* r
|
||||
|
||||
setHtml(html_messages.m_html, html_messages.m_baseUrl);
|
||||
|
||||
bool is_rtl_feed = root != nullptr && root->kind() == RootItem::Kind::Feed && qobject_cast<Feed*>(root)->isRtl();
|
||||
/*
|
||||
auto* feed = root != nullptr
|
||||
? root->getParentServiceRoot()
|
||||
->getItemFromSubTree([messages](const RootItem* it) {
|
||||
return it->kind() == RootItem::Kind::Feed && it->customId() == messages.at(0).m_feedId;
|
||||
})
|
||||
->toFeed()
|
||||
: nullptr;
|
||||
bool is_rtl_feed = feed != nullptr && feed->isRtl();
|
||||
*/
|
||||
|
||||
QTextOption op;
|
||||
op.setTextDirection(is_rtl_feed ? Qt::LayoutDirection::RightToLeft : Qt::LayoutDirection::LeftToRight);
|
||||
op.setTextDirection(messages.at(0).m_isRtl ? Qt::LayoutDirection::RightToLeft : Qt::LayoutDirection::LeftToRight);
|
||||
document()->setDefaultTextOption(op);
|
||||
|
||||
emit loadingFinished(true);
|
||||
|
@ -238,7 +238,9 @@ PreparedHtml SkinFactory::generateHtmlOfArticles(const QList<Message>& messages,
|
||||
})
|
||||
->toFeed()
|
||||
: nullptr;
|
||||
/*
|
||||
bool is_rtl_feed = feed != nullptr && feed->isRtl();
|
||||
*/
|
||||
|
||||
for (const Message& message : messages) {
|
||||
QString enclosures;
|
||||
@ -284,7 +286,7 @@ PreparedHtml SkinFactory::generateHtmlOfArticles(const QList<Message>& messages,
|
||||
enclosures,
|
||||
enclosure_images,
|
||||
QString::number(message.m_id),
|
||||
is_rtl_feed ? QSL("rtl") : QSL("ltr")));
|
||||
message.m_isRtl ? QSL("rtl") : QSL("ltr")));
|
||||
}
|
||||
|
||||
QString msg_contents =
|
||||
|
@ -49,8 +49,6 @@ void EmailPreviewer::clear() {
|
||||
}
|
||||
|
||||
void EmailPreviewer::loadMessage(const Message& msg, RootItem* selected_item) {
|
||||
Q_UNUSED(selected_item)
|
||||
|
||||
m_message = msg;
|
||||
m_webView->loadMessages({msg}, selected_item);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user