From d514b939b5a733847b483edddac7cf8372e7d564 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 27 Mar 2015 22:57:58 +0000 Subject: [PATCH] fixed completer for message composer. Still need to fix slot editingRecipientFinished() git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8088 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- .../src/gui/msgs/MessageComposer.cpp | 24 ++++++++++++++----- retroshare-gui/src/gui/msgs/MessageComposer.h | 2 ++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index be8effc9b..a5a678547 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -295,7 +295,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) ui.recipientWidget->setColumnCount(COLUMN_RECIPIENT_COUNT); QHeaderView *header = ui.recipientWidget->horizontalHeader(); - header->resizeSection(COLUMN_RECIPIENT_TYPE, 120); + header->resizeSection(COLUMN_RECIPIENT_TYPE, 60); header->resizeSection(COLUMN_RECIPIENT_ICON, 22); QHeaderView_setSectionResizeMode(header, COLUMN_RECIPIENT_TYPE, QHeaderView::Fixed); QHeaderView_setSectionResizeMode(header, COLUMN_RECIPIENT_ICON, QHeaderView::Fixed); @@ -716,15 +716,22 @@ void MessageComposer::buildCompleter() rsPeers->getFriendList(peers); std::list gxsIds; - std::list::iterator idIt; + QList gxsitems ; + + ui.friendSelectionWidget->items(gxsitems,FriendSelectionWidget::IDTYPE_GXS) ; // create completer list for friends QStringList completerList; QStringList completerGroupList; - /*for (std::list::const_iterator idIt = gxsIds.begin(); idIt != gxsIds.end(); ++idIt) { - completerList.append(*idIt); - }*/ + for (QList::const_iterator idIt = gxsitems.begin(); idIt != gxsitems.end(); ++idIt) + { + RsGxsId id ( ui.friendSelectionWidget->idFromItem( *idIt ) ); + RsIdentityDetails detail; + + if(rsIdentity->getIdDetails(id, detail)) + completerList.append( getGxsRecipientName(id,detail)) ; + } for (peerIt = peers.begin(); peerIt != peers.end(); ++peerIt) { RsPeerDetails detail; @@ -750,6 +757,7 @@ void MessageComposer::buildCompleter() m_completer = new QCompleter(completerList, this); m_completer->setCaseSensitivity(Qt::CaseInsensitive); + setNewCompleter(ui.recipientWidget, m_completer); } @@ -1489,6 +1497,10 @@ bool MessageComposer::getRecipientFromRow(int row, enumType &type, destinationTy return true; } +QString MessageComposer::getGxsRecipientName(const RsGxsId& id,const RsIdentityDetails& detail) +{ + return QString("%2 <%2@%1>").arg(QString::fromStdString(id.toStdString())).arg(QString::fromUtf8(detail.mNickname.c_str())) ; +} void MessageComposer::setRecipientToRow(int row, enumType type, destinationType dest_type, const std::string &id) { if (row + 1 > ui.recipientWidget->rowCount()) { @@ -1555,7 +1567,7 @@ void MessageComposer::setRecipientToRow(int row, enumType type, destinationType QList icons ; GxsIdDetails::getIcons(detail,icons,GxsIdDetails::ICON_TYPE_AVATAR) ; - name = tr("%2 <%2@%1>").arg(QString::fromStdString(gid.toStdString())).arg(QString::fromUtf8(detail.mNickname.c_str())) ; + name = getGxsRecipientName(gid,detail) ; if(!icons.empty()) icon = icons.front() ; diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index d9c0b6c97..046fb2d5b 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -30,6 +30,7 @@ #include "gui/msgs/MessageInterface.h" class QAction; +class RsIdentityDetails; class QComboBox; class QFontComboBox; class QTextEdit; @@ -164,6 +165,7 @@ private: void processSettings(bool bLoad); + QString getGxsRecipientName(const RsGxsId& id,const RsIdentityDetails& detail) ; void addContact(enumType type); void setTextColor(const QColor& col) ; void setupFileActions();