diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index 7f6220b4e..40c828449 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -121,9 +121,6 @@ MessagesDialog::MessagesDialog(QWidget *parent) ui.actionIconOnly->setData(Qt::ToolButtonIconOnly); 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); ui.msgLayout->addWidget(msgWidget); @@ -145,15 +142,11 @@ MessagesDialog::MessagesDialog(QWidget *parent) mMessageProxyModel->setFilterRole(RsMessageModel::FilterRole); 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); itemDelegate->setSpacing(QSize(0, 2)); 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 // http://bugreports.qt.nokia.com/browse/QTBUG-8270 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) // /////////////////////////////////////////////////////////////////////////////////////// + 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_ATTACHMENT, 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(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(messagesLoaded()),this,SLOT(postModelUpdate())); diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h index 8a8452a34..02eff1d32 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h @@ -138,33 +138,23 @@ public: RsGxsId id(index.data(Qt::UserRole).toString().toStdString()); QString str; - QList icons; QString comment; QFontMetricsF fm(painter->font()); float f = fm.height(); QIcon icon ; - - 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(! computeNameIconAndComment(id,str,icon,comment)) if(mReloadPeriod > 3) - { + { str = tr("[Unknown]"); - icon = QIcon(); - } - else - { + icon = QIcon(); + } + else + { icon = GxsIdDetails::getLoadingIcon(id); launchAsyncLoading(); - } - } - else - icon = *icons.begin(); + } QPixmap pix = icon.pixmap(r.size()); const QPoint p = QPoint(r.height()/2.0, (r.height() - pix.height())/2); @@ -185,6 +175,33 @@ public: QTimer::singleShot(1000,this,SLOT(reload())); } + static bool computeName(const RsGxsId& id,QString& name) + { + QList 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 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: void reload() { mLoading=false; emit commitData(NULL) ; } diff --git a/retroshare-gui/src/gui/msgs/MessageModel.cpp b/retroshare-gui/src/gui/msgs/MessageModel.cpp index 839b5689d..2ee805ea8 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.cpp +++ b/retroshare-gui/src/gui/msgs/MessageModel.cpp @@ -30,6 +30,7 @@ #include "util/HandleRichText.h" #include "util/DateTime.h" #include "gui/gxs/GxsIdDetails.h" +#include "gui/gxs/GxsIdTreeWidgetItem.h" #include "MessageModel.h" #include "retroshare/rsexpr.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(); 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(); break; 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_AUTHOR:{ + QString name; + + if(GxsIdTreeItemDelegate::computeName(RsGxsId(fmpe.srcId.toStdString()),name)) + return name; + } default: return displayRole(fmpe,column); }