Probably partially fixed #172.
This commit is contained in:
parent
9b6982ee19
commit
a6479b2603
@ -13,6 +13,7 @@ Added:
|
||||
|
||||
Fixed:
|
||||
|
||||
▪ Ordering of messages is now done on SQL server (stands for both MySQL and SQLite). (bug #172)
|
||||
▪ Now title of the RSS/ATOM message is taken into account when deciding message "uniqueness". (bug #171)
|
||||
▪ MySQL scripts improved. (bug #170)
|
||||
▪ Fixed little problem with feed list hiding. (bug #163)
|
||||
|
@ -74,14 +74,10 @@ bool MessagesProxyModel::lessThan(const QModelIndex &left, const QModelIndex &ri
|
||||
// V případě, že do messagelistu budu zobrazovat řekněme
|
||||
// více než 4 000 zpráv, tak tady vracet automaticky false,
|
||||
// neprovádět skutečně porovnávání.
|
||||
Q_UNUSED(left)
|
||||
Q_UNUSED(right)
|
||||
|
||||
if (left.column() == MSG_DB_TITLE_INDEX && right.column() == MSG_DB_TITLE_INDEX) {
|
||||
return QString::localeAwareCompare(m_sourceModel->data(left, Qt::EditRole).toString(),
|
||||
m_sourceModel->data(right, Qt::EditRole).toString()) < 0;
|
||||
}
|
||||
else {
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QModelIndexList MessagesProxyModel::mapListFromSource(const QModelIndexList &indexes, bool deep) const {
|
||||
@ -184,6 +180,12 @@ QModelIndexList MessagesProxyModel::match(const QModelIndex &start, int role,
|
||||
return result;
|
||||
}
|
||||
|
||||
void MessagesProxyModel::sort(int column, Qt::SortOrder order) {
|
||||
// NOTE: Ignore here, sort is done elsewhere.
|
||||
Q_UNUSED(column)
|
||||
Q_UNUSED(order)
|
||||
}
|
||||
|
||||
QModelIndexList MessagesProxyModel::mapListToSource(const QModelIndexList &indexes) const {
|
||||
QModelIndexList source_indexes;
|
||||
|
||||
|
@ -45,6 +45,8 @@ class MessagesProxyModel : public QSortFilterProxyModel {
|
||||
// Fix for matching indexes with respect to specifics of the message model.
|
||||
QModelIndexList match(const QModelIndex &start, int role, const QVariant &entered_value, int hits, Qt::MatchFlags flags) const;
|
||||
|
||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
||||
|
||||
private:
|
||||
QModelIndex getNextUnreadItemIndex(int default_row, int max_row) const;
|
||||
|
||||
|
@ -51,9 +51,9 @@ MessagesView::~MessagesView() {
|
||||
}
|
||||
|
||||
void MessagesView::setSortingEnabled(bool enable) {
|
||||
disconnect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
|
||||
disconnect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(onSortIndicatorChanged(int,Qt::SortOrder)));
|
||||
QTreeView::setSortingEnabled(enable);
|
||||
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
|
||||
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(onSortIndicatorChanged(int,Qt::SortOrder)));
|
||||
}
|
||||
|
||||
void MessagesView::createConnections() {
|
||||
@ -61,7 +61,7 @@ void MessagesView::createConnections() {
|
||||
|
||||
// Adjust columns when layout gets changed.
|
||||
connect(header(), SIGNAL(geometriesChanged()), this, SLOT(adjustColumns()));
|
||||
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
|
||||
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(onSortIndicatorChanged(int,Qt::SortOrder)));
|
||||
}
|
||||
|
||||
void MessagesView::keyboardSearch(const QString &search) {
|
||||
@ -79,8 +79,7 @@ void MessagesView::reloadSelections(bool mark_current_index_read) {
|
||||
const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
|
||||
|
||||
// Reload the model now.
|
||||
m_sourceModel->fetchAllData();
|
||||
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
|
||||
m_sourceModel->sort(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
|
||||
|
||||
selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true);
|
||||
current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(), mapped_current_index.column()));
|
||||
@ -228,12 +227,11 @@ void MessagesView::selectionChanged(const QItemSelection &selected, const QItemS
|
||||
}
|
||||
|
||||
void MessagesView::loadItem(RootItem *item) {
|
||||
m_sourceModel->loadMessages(item);
|
||||
|
||||
const int col = qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortColumnMessages)).toInt();
|
||||
const Qt::SortOrder ord = static_cast<Qt::SortOrder>(qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortOrderMessages)).toInt());
|
||||
|
||||
sortByColumn(col, ord);
|
||||
m_sourceModel->setSort(col, ord);
|
||||
m_sourceModel->loadMessages(item);
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
// Messages are loaded, make sure that previously
|
||||
@ -244,18 +242,6 @@ void MessagesView::loadItem(RootItem *item) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void MessagesView::sortByColumn(int column, Qt::SortOrder order) {
|
||||
const int old_column = header()->sortIndicatorSection();
|
||||
const Qt::SortOrder old_order = header()->sortIndicatorOrder();
|
||||
|
||||
if (column == old_column && order == old_order) {
|
||||
m_proxyModel->sort(column, order);
|
||||
}
|
||||
else {
|
||||
QTreeView::sortByColumn(column, order);
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesView::openSelectedSourceMessagesExternally() {
|
||||
foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
|
||||
const QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()).m_url;
|
||||
@ -350,7 +336,6 @@ void MessagesView::setSelectedMessagesReadStatus(RootItem::ReadStatus read) {
|
||||
const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
|
||||
|
||||
m_sourceModel->setBatchMessagesRead(mapped_indexes, read);
|
||||
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
|
||||
|
||||
selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true);
|
||||
current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(), mapped_current_index.column()));
|
||||
@ -378,9 +363,8 @@ void MessagesView::deleteSelectedMessages() {
|
||||
const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
|
||||
|
||||
m_sourceModel->setBatchMessagesDeleted(mapped_indexes);
|
||||
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
|
||||
|
||||
const int row_count = m_sourceModel->rowCount();
|
||||
const int row_count = m_proxyModel->rowCount();
|
||||
|
||||
if (row_count > 0) {
|
||||
const QModelIndex last_item = current_index.row() < row_count ?
|
||||
@ -407,9 +391,8 @@ void MessagesView::restoreSelectedMessages() {
|
||||
const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
|
||||
|
||||
m_sourceModel->setBatchMessagesRestored(mapped_indexes);
|
||||
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
|
||||
|
||||
int row_count = m_sourceModel->rowCount();
|
||||
const int row_count = m_sourceModel->rowCount();
|
||||
|
||||
if (row_count > 0) {
|
||||
const QModelIndex last_item = current_index.row() < row_count ?
|
||||
@ -437,7 +420,6 @@ void MessagesView::switchSelectedMessagesImportance() {
|
||||
const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
|
||||
|
||||
m_sourceModel->switchBatchMessageImportance(mapped_indexes);
|
||||
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
|
||||
|
||||
selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true);
|
||||
current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(),
|
||||
@ -570,8 +552,13 @@ void MessagesView::adjustColumns() {
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesView::saveSortState(int column, Qt::SortOrder order) {
|
||||
void MessagesView::onSortIndicatorChanged(int column, Qt::SortOrder order) {
|
||||
// Save current setup.
|
||||
qApp->settings()->setValue(GROUP(GUI), GUI::DefaultSortColumnMessages, column);
|
||||
qApp->settings()->setValue(GROUP(GUI), GUI::DefaultSortOrderMessages, order);
|
||||
qApp->settings()->sync();
|
||||
|
||||
// Repopulate the shit.
|
||||
m_sourceModel->sort(column, order);
|
||||
emit currentMessagesRemoved();
|
||||
}
|
||||
|
@ -59,8 +59,6 @@ class MessagesView : public QTreeView {
|
||||
// Loads un-deleted messages from selected feeds.
|
||||
void loadItem(RootItem *item);
|
||||
|
||||
void sortByColumn(int column, Qt::SortOrder order);
|
||||
|
||||
// Message manipulators.
|
||||
void openSelectedSourceMessagesExternally();
|
||||
void openSelectedSourceMessagesInternally();
|
||||
@ -92,7 +90,7 @@ class MessagesView : public QTreeView {
|
||||
void adjustColumns();
|
||||
|
||||
// Saves current sort state.
|
||||
void saveSortState(int column, Qt::SortOrder order);
|
||||
void onSortIndicatorChanged(int column, Qt::SortOrder order);
|
||||
|
||||
signals:
|
||||
// Link/message openers.
|
||||
|
Loading…
x
Reference in New Issue
Block a user