fixed filter/sort by author name

This commit is contained in:
csoler 2019-03-26 10:25:54 +01:00
parent d38ad97911
commit 90995f16ce
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
3 changed files with 49 additions and 25 deletions

View File

@ -121,9 +121,6 @@ MessagesDialog::MessagesDialog(QWidget *parent)
ui.actionIconOnly->setData(Qt::ToolButtonIconOnly); ui.actionIconOnly->setData(Qt::ToolButtonIconOnly);
ui.actionTextUnderIcon->setData(Qt::ToolButtonTextUnderIcon); ui.actionTextUnderIcon->setData(Qt::ToolButtonTextUnderIcon);
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
connect(ui.filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int)));
msgWidget = new MessageWidget(true, this); msgWidget = new MessageWidget(true, this);
ui.msgLayout->addWidget(msgWidget); ui.msgLayout->addWidget(msgWidget);
@ -145,15 +142,11 @@ MessagesDialog::MessagesDialog(QWidget *parent)
mMessageProxyModel->setFilterRole(RsMessageModel::FilterRole); mMessageProxyModel->setFilterRole(RsMessageModel::FilterRole);
ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_AUTHOR,new GxsIdTreeItemDelegate()) ; ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_AUTHOR,new GxsIdTreeItemDelegate()) ;
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_CONTENT,true);
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_MSGID,true);
RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this);
itemDelegate->setSpacing(QSize(0, 2)); itemDelegate->setSpacing(QSize(0, 2));
ui.messageTreeWidget->setItemDelegate(itemDelegate); ui.messageTreeWidget->setItemDelegate(itemDelegate);
//ui.messageTreeWidget->sortByColumn(COLUMN_DATA, Qt::DescendingOrder);
// workaround for Qt bug, should be solved in next Qt release 4.7.0 // workaround for Qt bug, should be solved in next Qt release 4.7.0
// http://bugreports.qt.nokia.com/browse/QTBUG-8270 // http://bugreports.qt.nokia.com/browse/QTBUG-8270
QShortcut *Shortcut = new QShortcut(QKeySequence (Qt::Key_Delete), ui.messageTreeWidget, 0, 0, Qt::WidgetShortcut); QShortcut *Shortcut = new QShortcut(QKeySequence (Qt::Key_Delete), ui.messageTreeWidget, 0, 0, Qt::WidgetShortcut);
@ -208,6 +201,9 @@ MessagesDialog::MessagesDialog(QWidget *parent)
// Post "load settings" actions (which makes sure they are not affected by settings) // // Post "load settings" actions (which makes sure they are not affected by settings) //
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_CONTENT,true);
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_MSGID,true);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_STAR, fm.width('0')*1.5); msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_STAR, fm.width('0')*1.5);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_ATTACHMENT, fm.width('0')*1.5); msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_ATTACHMENT, fm.width('0')*1.5);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_READ, fm.width('0')*1.5); msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_READ, fm.width('0')*1.5);
@ -259,6 +255,9 @@ MessagesDialog::MessagesDialog(QWidget *parent)
connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), mMessageModel, SLOT(updateMessages())); connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), mMessageModel, SLOT(updateMessages()));
connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged())); connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged()));
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
connect(ui.filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int)));
connect(mMessageModel,SIGNAL(messagesAboutToLoad()),this,SLOT(preModelUpdate())); connect(mMessageModel,SIGNAL(messagesAboutToLoad()),this,SLOT(preModelUpdate()));
connect(mMessageModel,SIGNAL(messagesLoaded()),this,SLOT(postModelUpdate())); connect(mMessageModel,SIGNAL(messagesLoaded()),this,SLOT(postModelUpdate()));

View File

@ -138,33 +138,23 @@ public:
RsGxsId id(index.data(Qt::UserRole).toString().toStdString()); RsGxsId id(index.data(Qt::UserRole).toString().toStdString());
QString str; QString str;
QList<QIcon> icons;
QString comment; QString comment;
QFontMetricsF fm(painter->font()); QFontMetricsF fm(painter->font());
float f = fm.height(); float f = fm.height();
QIcon icon ; QIcon icon ;
if(! computeNameIconAndComment(id,str,icon,comment))
if(rsPeers->isFriend(RsPeerId(id))) // horrible trick because some widgets still use locations as IDs (e.g. messages)
{
str = QString::fromUtf8(rsPeers->getPeerName(RsPeerId(id)).c_str()) ;
}
else if(!GxsIdDetails::MakeIdDesc(id, true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR))
{
if(mReloadPeriod > 3) if(mReloadPeriod > 3)
{ {
str = tr("[Unknown]"); str = tr("[Unknown]");
icon = QIcon(); icon = QIcon();
} }
else else
{ {
icon = GxsIdDetails::getLoadingIcon(id); icon = GxsIdDetails::getLoadingIcon(id);
launchAsyncLoading(); launchAsyncLoading();
} }
}
else
icon = *icons.begin();
QPixmap pix = icon.pixmap(r.size()); QPixmap pix = icon.pixmap(r.size());
const QPoint p = QPoint(r.height()/2.0, (r.height() - pix.height())/2); const QPoint p = QPoint(r.height()/2.0, (r.height() - pix.height())/2);
@ -185,6 +175,33 @@ public:
QTimer::singleShot(1000,this,SLOT(reload())); QTimer::singleShot(1000,this,SLOT(reload()));
} }
static bool computeName(const RsGxsId& id,QString& name)
{
QList<QIcon> icons;
QString comment;
if(rsPeers->isFriend(RsPeerId(id))) // horrible trick because some widgets still use locations as IDs (e.g. messages)
name = QString::fromUtf8(rsPeers->getPeerName(RsPeerId(id)).c_str()) ;
else if(!GxsIdDetails::MakeIdDesc(id, false, name, icons, comment,GxsIdDetails::ICON_TYPE_NONE))
return false;
return true;
}
static bool computeNameIconAndComment(const RsGxsId& id,QString& name,QIcon& icon,QString& comment)
{
QList<QIcon> icons;
if(rsPeers->isFriend(RsPeerId(id))) // horrible trick because some widgets still use locations as IDs (e.g. messages)
name = QString::fromUtf8(rsPeers->getPeerName(RsPeerId(id)).c_str()) ;
else if(!GxsIdDetails::MakeIdDesc(id, true, name, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR))
return false;
else
icon = *icons.begin();
return true;
}
private slots: private slots:
void reload() { mLoading=false; emit commitData(NULL) ; } void reload() { mLoading=false; emit commitData(NULL) ; }

View File

@ -30,6 +30,7 @@
#include "util/HandleRichText.h" #include "util/HandleRichText.h"
#include "util/DateTime.h" #include "util/DateTime.h"
#include "gui/gxs/GxsIdDetails.h" #include "gui/gxs/GxsIdDetails.h"
#include "gui/gxs/GxsIdTreeWidgetItem.h"
#include "MessageModel.h" #include "MessageModel.h"
#include "retroshare/rsexpr.h" #include "retroshare/rsexpr.h"
#include "retroshare/rsmsgs.h" #include "retroshare/rsmsgs.h"
@ -300,7 +301,8 @@ bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
case FILTER_TYPE_SUBJECT: s = displayRole(fmpe,COLUMN_THREAD_SUBJECT).toString(); case FILTER_TYPE_SUBJECT: s = displayRole(fmpe,COLUMN_THREAD_SUBJECT).toString();
break; break;
case FILTER_TYPE_FROM: case FILTER_TYPE_FROM: s = sortRole(fmpe.COLUMN_THREAD_AUTHOR).toString();
break;
case FILTER_TYPE_DATE: s = displayRole(fmpe,COLUMN_THREAD_DATE).toString(); case FILTER_TYPE_DATE: s = displayRole(fmpe,COLUMN_THREAD_DATE).toString();
break; break;
case FILTER_TYPE_CONTENT: { case FILTER_TYPE_CONTENT: {
@ -419,6 +421,12 @@ QVariant RsMessageModel::sortRole(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
case COLUMN_THREAD_STAR: return QVariant((fmpe.msgflags & RS_MSG_STAR)? 1:0); case COLUMN_THREAD_STAR: return QVariant((fmpe.msgflags & RS_MSG_STAR)? 1:0);
case COLUMN_THREAD_AUTHOR:{
QString name;
if(GxsIdTreeItemDelegate::computeName(RsGxsId(fmpe.srcId.toStdString()),name))
return name;
}
default: default:
return displayRole(fmpe,column); return displayRole(fmpe,column);
} }