fixed sorting

This commit is contained in:
csoler 2019-03-26 11:21:31 +01:00
parent 90995f16ce
commit 5820364b0d
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 24 additions and 7 deletions

View File

@ -134,13 +134,13 @@ MessagesDialog::MessagesDialog(QWidget *parent)
mMessageProxyModel->setSortRole(RsMessageModel::SortRole);
mMessageProxyModel->setDynamicSortFilter(false);
mMessageProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
mMessageProxyModel->setFilterRole(RsMessageModel::FilterRole);
mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString));
ui.messageTreeWidget->setModel(mMessageProxyModel);
changeBox(0); // set to inbox
mMessageProxyModel->setFilterRole(RsMessageModel::FilterRole);
ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_AUTHOR,new GxsIdTreeItemDelegate()) ;
RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this);
@ -1042,6 +1042,8 @@ void MessagesDialog::buttonStyle()
setToolbarButtonStyle((Qt::ToolButtonStyle) dynamic_cast<QAction*>(sender())->data().toInt());
}
void MessagesDialog::filterChanged(const QString& text)
{
QStringList items = text.split(' ',QString::SkipEmptyParts);
@ -1051,15 +1053,18 @@ void MessagesDialog::filterChanged(const QString& text)
switch(ui.filterLineEdit->currentFilter())
{
case RsMessageModel::COLUMN_THREAD_SUBJECT: f = RsMessageModel::FILTER_TYPE_SUBJECT ; break;
case RsMessageModel::COLUMN_THREAD_AUTHOR: f = RsMessageModel::FILTER_TYPE_FROM ; break;
case RsMessageModel::COLUMN_THREAD_AUTHOR: f = RsMessageModel::FILTER_TYPE_FROM ; break;
case RsMessageModel::COLUMN_THREAD_DATE: f = RsMessageModel::FILTER_TYPE_DATE ; break;
case RsMessageModel::COLUMN_THREAD_CONTENT: f = RsMessageModel::FILTER_TYPE_CONTENT ; break;
case RsMessageModel::COLUMN_THREAD_TAGS: f = RsMessageModel::FILTER_TYPE_TAGS ; break;
case RsMessageModel::COLUMN_THREAD_ATTACHMENT: f = RsMessageModel::FILTER_TYPE_ATTACHMENTS ; break;
case RsMessageModel::COLUMN_THREAD_ATTACHMENT: f = RsMessageModel::FILTER_TYPE_ATTACHMENTS ; break;
default:break;
}
mMessageModel->setFilter(f,items);
mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString));
QCoreApplication::processEvents();
}
void MessagesDialog::filterColumnChanged(int column)
@ -1072,19 +1077,22 @@ void MessagesDialog::filterColumnChanged(int column)
switch(column)
{
case RsMessageModel::COLUMN_THREAD_SUBJECT: f = RsMessageModel::FILTER_TYPE_SUBJECT ; break;
case RsMessageModel::COLUMN_THREAD_AUTHOR: f = RsMessageModel::FILTER_TYPE_FROM ; break;
case RsMessageModel::COLUMN_THREAD_AUTHOR: f = RsMessageModel::FILTER_TYPE_FROM ; break;
case RsMessageModel::COLUMN_THREAD_DATE: f = RsMessageModel::FILTER_TYPE_DATE ; break;
case RsMessageModel::COLUMN_THREAD_CONTENT: f = RsMessageModel::FILTER_TYPE_CONTENT ; break;
case RsMessageModel::COLUMN_THREAD_TAGS: f = RsMessageModel::FILTER_TYPE_TAGS ; break;
case RsMessageModel::COLUMN_THREAD_ATTACHMENT: f = RsMessageModel::FILTER_TYPE_ATTACHMENTS ; break;
case RsMessageModel::COLUMN_THREAD_ATTACHMENT: f = RsMessageModel::FILTER_TYPE_ATTACHMENTS ; break;
default:break;
}
QStringList items = ui.filterLineEdit->text().split(' ',QString::SkipEmptyParts);
mMessageModel->setFilter(f,items);
mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString));
// save index
Settings->setValueToGroup("MessageDialog", "filterColumn", column);
QCoreApplication::processEvents();
}
void MessagesDialog::updateMessageSummaryList()

View File

@ -301,7 +301,9 @@ bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
case FILTER_TYPE_SUBJECT: s = displayRole(fmpe,COLUMN_THREAD_SUBJECT).toString();
break;
case FILTER_TYPE_FROM: s = sortRole(fmpe.COLUMN_THREAD_AUTHOR).toString();
case FILTER_TYPE_FROM: s = sortRole(fmpe,COLUMN_THREAD_AUTHOR).toString();
if(s.isNull())
passes_strings = false;
break;
case FILTER_TYPE_DATE: s = displayRole(fmpe,COLUMN_THREAD_DATE).toString();
break;
@ -335,6 +337,8 @@ bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
|| (mQuickViewFilter==QUICK_VIEW_STARRED && (fmpe.msgflags & RS_MSG_STAR))
|| (mQuickViewFilter==QUICK_VIEW_SYSTEM && (fmpe.msgflags & RS_MSG_SYSTEM));
std::cerr << "Passes filter: type=" << mFilterType << " s=\"" << s.toStdString() << "\" strings:" << passes_strings << " quick_view:" << passes_quick_view << std::endl;
return passes_quick_view && passes_strings;
}
@ -357,6 +361,11 @@ uint32_t RsMessageModel::updateFilterStatus(ForumModelIndex i,int column,const Q
void RsMessageModel::setFilter(FilterType filter_type, const QStringList& strings)
{
std::cerr << "Setting filter to filter_type=" << int(filter_type) << " and strings to " ;
foreach(const QString& str,strings)
std::cerr << "\"" << str.toStdString() << "\" " ;
std::cerr << std::endl;
preMods();
mFilterType = filter_type;