mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05:00
first version of item model for new friend list
This commit is contained in:
parent
081a3a7023
commit
a4f6d89575
@ -43,6 +43,7 @@
|
|||||||
#include "FriendsDialog.h"
|
#include "FriendsDialog.h"
|
||||||
#include "NetworkView.h"
|
#include "NetworkView.h"
|
||||||
#include "NetworkDialog.h"
|
#include "NetworkDialog.h"
|
||||||
|
#include "gui/common/NewFriendList.h"
|
||||||
#include "gui/Identity/IdDialog.h"
|
#include "gui/Identity/IdDialog.h"
|
||||||
#ifdef RS_USE_CIRCLES
|
#ifdef RS_USE_CIRCLES
|
||||||
#include "gui/Circles/CirclesDialog.h"
|
#include "gui/Circles/CirclesDialog.h"
|
||||||
@ -77,10 +78,8 @@ FriendsDialog::FriendsDialog(QWidget *parent)
|
|||||||
ui.chatWidget->setWelcomeMessage(msg);
|
ui.chatWidget->setWelcomeMessage(msg);
|
||||||
ui.chatWidget->init(ChatId::makeBroadcastId(), tr("Broadcast"));
|
ui.chatWidget->init(ChatId::makeBroadcastId(), tr("Broadcast"));
|
||||||
|
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(chatMessageReceived(ChatMessage)),
|
connect(NotifyQt::getInstance(), SIGNAL(chatMessageReceived(ChatMessage)), this, SLOT(chatMessageReceived(ChatMessage)));
|
||||||
this, SLOT(chatMessageReceived(ChatMessage)));
|
connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusReceived(ChatId,QString)));
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)),
|
|
||||||
this, SLOT(chatStatusReceived(ChatId,QString)));
|
|
||||||
#else // def RS_DIRECT_CHAT
|
#else // def RS_DIRECT_CHAT
|
||||||
ui.tabWidget->removeTab(ui.tabWidget->indexOf(ui.groupChatTab));
|
ui.tabWidget->removeTab(ui.tabWidget->indexOf(ui.groupChatTab));
|
||||||
#endif // def RS_DIRECT_CHAT
|
#endif // def RS_DIRECT_CHAT
|
||||||
@ -97,47 +96,15 @@ FriendsDialog::FriendsDialog(QWidget *parent)
|
|||||||
ui.tabWidget->addTab(networkView = new NetworkView(),QIcon(IMAGE_NETWORK2), tr("Network graph"));
|
ui.tabWidget->addTab(networkView = new NetworkView(),QIcon(IMAGE_NETWORK2), tr("Network graph"));
|
||||||
ui.tabWidget->addTab(networkDialog = new NetworkDialog(),QIcon(IMAGE_PEERS), tr("Keyring"));
|
ui.tabWidget->addTab(networkDialog = new NetworkDialog(),QIcon(IMAGE_PEERS), tr("Keyring"));
|
||||||
|
|
||||||
//ui.tabWidget->addTab(new ProfileWidget(), tr("Profile"));
|
|
||||||
//newsFeed = new NewsFeed();
|
|
||||||
//int newsFeedTabIndex = ui.tabWidget->insertTab(0, newsFeed, tr("News Feed"));
|
|
||||||
//ui.tabWidget->setCurrentIndex(newsFeedTabIndex);
|
|
||||||
|
|
||||||
ui.tabWidget->hideCloseButton(0);
|
ui.tabWidget->hideCloseButton(0);
|
||||||
ui.tabWidget->hideCloseButton(1);
|
ui.tabWidget->hideCloseButton(1);
|
||||||
ui.tabWidget->hideCloseButton(2);
|
ui.tabWidget->hideCloseButton(2);
|
||||||
ui.tabWidget->hideCloseButton(3);
|
ui.tabWidget->hideCloseButton(3);
|
||||||
ui.tabWidget->hideCloseButton(4);
|
ui.tabWidget->hideCloseButton(4);
|
||||||
|
|
||||||
/* get the current text and text color of the tab bar */
|
|
||||||
//newsFeedTabColor = ui.tabWidget->tabBar()->tabTextColor(newsFeedTabIndex);
|
|
||||||
//newsFeedText = ui.tabWidget->tabBar()->tabText(newsFeedTabIndex);
|
|
||||||
|
|
||||||
//connect(newsFeed, SIGNAL(newsFeedChanged(int)), this, SLOT(newsFeedChanged(int)));
|
|
||||||
|
|
||||||
// menu = new QMenu();
|
|
||||||
// menu->addAction(ui.actionAdd_Friend);
|
|
||||||
// menu->addAction(ui.actionAdd_Group);
|
|
||||||
// menu->addAction(ui.actionCreate_new_Chat_lobby);
|
|
||||||
//
|
|
||||||
// menu->addSeparator();
|
|
||||||
// menu->addAction(ui.actionSet_your_Avatar);
|
|
||||||
// menu->addAction(ui.actionSet_your_Personal_Message);
|
|
||||||
//
|
|
||||||
// ui.menutoolButton->setMenu(menu);
|
|
||||||
|
|
||||||
/*QToolButton *addFriendButton = new QToolButton(this);
|
|
||||||
addFriendButton->setIcon(QIcon(":/images/user/add_user24.png"));
|
|
||||||
addFriendButton->setToolTip(tr("Add friend node"));
|
|
||||||
connect(addFriendButton, SIGNAL(clicked()), this, SLOT(addFriend()));
|
|
||||||
ui.friendList->addToolButton(addFriendButton);*/
|
|
||||||
|
|
||||||
/* Set initial size the splitter */
|
/* Set initial size the splitter */
|
||||||
ui.splitter->setStretchFactor(0, 0);
|
ui.splitter->setStretchFactor(0, 0);
|
||||||
ui.splitter->setStretchFactor(1, 1);
|
ui.splitter->setStretchFactor(1, 1);
|
||||||
/*remove
|
|
||||||
QList<int> sizes;
|
|
||||||
sizes << height() << 100; // Qt calculates the right sizes
|
|
||||||
ui.splitter_2->setSizes(sizes);*/
|
|
||||||
|
|
||||||
loadmypersonalstatus();
|
loadmypersonalstatus();
|
||||||
|
|
||||||
@ -145,9 +112,9 @@ QList<int> sizes;
|
|||||||
|
|
||||||
// load settings
|
// load settings
|
||||||
RsAutoUpdatePage::lockAllEvents();
|
RsAutoUpdatePage::lockAllEvents();
|
||||||
ui.friendList->setColumnVisible(FriendList::COLUMN_LAST_CONTACT, false);
|
ui.friendList->setColumnVisible(NewFriendList::COLUMN_LAST_CONTACT, false);
|
||||||
ui.friendList->setColumnVisible(FriendList::COLUMN_IP, false);
|
ui.friendList->setColumnVisible(NewFriendList::COLUMN_IP, false);
|
||||||
ui.friendList->setColumnVisible(FriendList::COLUMN_ID, false);
|
ui.friendList->setColumnVisible(NewFriendList::COLUMN_ID, false);
|
||||||
ui.friendList->setShowGroups(true);
|
ui.friendList->setShowGroups(true);
|
||||||
processSettings(true);
|
processSettings(true);
|
||||||
RsAutoUpdatePage::unlockAllEvents();
|
RsAutoUpdatePage::unlockAllEvents();
|
||||||
|
@ -384,7 +384,7 @@
|
|||||||
<customwidget>
|
<customwidget>
|
||||||
<class>NewFriendList</class>
|
<class>NewFriendList</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>NewFriendList.h</header>
|
<header>gui/common/NewFriendList.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* retroshare-gui/src/gui/msgs/RsMessageModel.cpp *
|
* retroshare-gui/src/gui/msgs/RsFriendListModel.cpp *
|
||||||
* *
|
* *
|
||||||
* Copyright 2019 by Cyril Soler <csoler@users.sourceforge.net> *
|
* Copyright 2019 by Cyril Soler <csoler@users.sourceforge.net> *
|
||||||
* *
|
* *
|
||||||
@ -26,12 +26,12 @@
|
|||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
#include "gui/common/TagDefs.h"
|
#include "gui/common/StatusDefs.h"
|
||||||
#include "util/HandleRichText.h"
|
#include "util/HandleRichText.h"
|
||||||
#include "util/DateTime.h"
|
#include "util/DateTime.h"
|
||||||
|
#include "gui/common/FriendListModel.h"
|
||||||
#include "gui/gxs/GxsIdDetails.h"
|
#include "gui/gxs/GxsIdDetails.h"
|
||||||
#include "gui/gxs/GxsIdTreeWidgetItem.h"
|
#include "gui/gxs/GxsIdTreeWidgetItem.h"
|
||||||
#include "MessageModel.h"
|
|
||||||
#include "retroshare/rsexpr.h"
|
#include "retroshare/rsexpr.h"
|
||||||
#include "retroshare/rsmsgs.h"
|
#include "retroshare/rsmsgs.h"
|
||||||
|
|
||||||
@ -44,27 +44,28 @@
|
|||||||
|
|
||||||
std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere
|
std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere
|
||||||
|
|
||||||
const QString RsMessageModel::FilterString("filtered");
|
const QString RsFriendListModel::FilterString("filtered");
|
||||||
|
|
||||||
RsMessageModel::RsMessageModel(QObject *parent)
|
RsFriendListModel::RsFriendListModel(QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
{
|
{
|
||||||
mCurrentBox = BOX_NONE;
|
mDisplayGroups = false;
|
||||||
mQuickViewFilter = QUICK_VIEW_ALL;
|
|
||||||
mFilterType = FILTER_TYPE_NONE;
|
|
||||||
mFilterStrings.clear();
|
mFilterStrings.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsMessageModel::preMods()
|
void RsFriendListModel::preMods()
|
||||||
{
|
{
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
}
|
}
|
||||||
void RsMessageModel::postMods()
|
void RsFriendListModel::postMods()
|
||||||
{
|
{
|
||||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mMessages.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
if(mDisplayGroups)
|
||||||
|
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mGroups.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||||
|
else
|
||||||
|
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mProfiles.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
int RsMessageModel::rowCount(const QModelIndex& parent) const
|
int RsFriendListModel::rowCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
if(!parent.isValid())
|
if(!parent.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
@ -72,35 +73,46 @@ int RsMessageModel::rowCount(const QModelIndex& parent) const
|
|||||||
if(parent.column() > 0)
|
if(parent.column() > 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(mMessages.empty()) // security. Should never happen.
|
if(mDisplayGroups)
|
||||||
return 0;
|
{
|
||||||
|
if(mGroups.empty()) // security. Should never happen.
|
||||||
|
return 0;
|
||||||
|
|
||||||
if(parent.internalPointer() == NULL)
|
if(parent.internalPointer() == NULL)
|
||||||
return mMessages.size();
|
return mGroups.size();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(mProfiles.empty()) // security. Should never happen.
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(parent.internalPointer() == NULL)
|
||||||
|
return mProfiles.size();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RsMessageModel::columnCount(const QModelIndex &parent) const
|
int RsFriendListModel::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return COLUMN_THREAD_NB_COLUMNS ;
|
return COLUMN_THREAD_NB_COLUMNS ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsMessageModel::getMessageData(const QModelIndex& i,Rs::Msgs::MessageInfo& fmpe) const
|
// bool RsFriendListModel::getProfileData(const QModelIndex& i,Rs::Msgs::MessageInfo& fmpe) const
|
||||||
{
|
// {
|
||||||
if(!i.isValid())
|
// if(!i.isValid())
|
||||||
return true;
|
// return true;
|
||||||
|
//
|
||||||
|
// quintptr ref = i.internalId();
|
||||||
|
// uint32_t index = 0;
|
||||||
|
//
|
||||||
|
// if(!convertInternalIdToMsgIndex(ref,index) || index >= mMessages.size())
|
||||||
|
// return false ;
|
||||||
|
//
|
||||||
|
// return rsMsgs->getMessage(mMessages[index].msgId,fmpe);
|
||||||
|
// }
|
||||||
|
|
||||||
quintptr ref = i.internalId();
|
bool RsFriendListModel::hasChildren(const QModelIndex &parent) const
|
||||||
uint32_t index = 0;
|
|
||||||
|
|
||||||
if(!convertInternalIdToMsgIndex(ref,index) || index >= mMessages.size())
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
return rsMsgs->getMessage(mMessages[index].msgId,fmpe);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RsMessageModel::hasChildren(const QModelIndex &parent) const
|
|
||||||
{
|
{
|
||||||
if(!parent.isValid())
|
if(!parent.isValid())
|
||||||
return true;
|
return true;
|
||||||
@ -108,38 +120,84 @@ bool RsMessageModel::hasChildren(const QModelIndex &parent) const
|
|||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsMessageModel::convertMsgIndexToInternalId(uint32_t index,quintptr& id)
|
bool RsFriendListModel::convertIndexToInternalId(const EntryIndex& e,quintptr& id)
|
||||||
{
|
{
|
||||||
// the internal id is set to the place in the table of items. We simply shift to allow 0 to mean something special.
|
// the internal id is set to the place in the table of items. We simply shift to allow 0 to mean something special.
|
||||||
|
|
||||||
id = index + 1 ;
|
if(e.ind > 0x0fffffff)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(e.type == ENTRY_TYPE_GROUP)
|
||||||
|
id = e.ind + 0x10000000 ;
|
||||||
|
else if(e.type == ENTRY_TYPE_PROFILE)
|
||||||
|
id = e.ind + 0x20000000 ;
|
||||||
|
else if(e.type == ENTRY_TYPE_NODE)
|
||||||
|
id = e.ind + 0x30000000 ;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsMessageModel::convertInternalIdToMsgIndex(quintptr ref,uint32_t& index)
|
bool RsFriendListModel::convertInternalIdToIndex(quintptr ref,EntryIndex& e)
|
||||||
{
|
{
|
||||||
if(ref == 0)
|
if(ref == 0)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
index = ref - 1;
|
e.ind = ref & 0x0fffffff;
|
||||||
|
|
||||||
|
int t = (ref >> 28)&0xf;
|
||||||
|
|
||||||
|
if(t == 0x1)
|
||||||
|
e.type = ENTRY_TYPE_GROUP ;
|
||||||
|
else if(t==0x2)
|
||||||
|
e.type = ENTRY_TYPE_PROFILE ;
|
||||||
|
else if(t==0x3)
|
||||||
|
e.type = ENTRY_TYPE_NODE ;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex RsMessageModel::index(int row, int column, const QModelIndex & parent) const
|
QModelIndex RsFriendListModel::index(int row, int column, const QModelIndex & parent) const
|
||||||
{
|
{
|
||||||
if(row < 0 || column < 0 || column >= COLUMN_THREAD_NB_COLUMNS)
|
if(row < 0 || column < 0 || column >= COLUMN_THREAD_NB_COLUMNS)
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
quintptr ref ;
|
if(parent.internalId() == 0)
|
||||||
|
{
|
||||||
|
quintptr ref ;
|
||||||
|
|
||||||
|
if(mDisplayGroups)
|
||||||
|
convertIndexToInternalId(EntryIndex(ENTRY_TYPE_GROUP,row),ref);
|
||||||
|
else
|
||||||
|
convertIndexToInternalId(EntryIndex(ENTRY_TYPE_PROFILE,row),ref);
|
||||||
|
|
||||||
if(parent.internalId() == 0 && convertMsgIndexToInternalId(row,ref))
|
|
||||||
return createIndex(row,column,ref) ;
|
return createIndex(row,column,ref) ;
|
||||||
|
}
|
||||||
|
|
||||||
return QModelIndex();
|
EntryIndex parent_index ;
|
||||||
|
EntryIndex new_index;
|
||||||
|
|
||||||
|
convertInternalIdToIndex(parent.internalId(),parent_index);
|
||||||
|
|
||||||
|
new_index.ind = row;
|
||||||
|
|
||||||
|
switch(parent_index.type)
|
||||||
|
{
|
||||||
|
case ENTRY_TYPE_GROUP: new_index.type = ENTRY_TYPE_PROFILE;
|
||||||
|
case ENTRY_TYPE_PROFILE: new_index.type = ENTRY_TYPE_NODE;
|
||||||
|
default:
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
quintptr ref ;
|
||||||
|
convertIndexToInternalId(new_index,ref);
|
||||||
|
|
||||||
|
return createIndex(row,column,ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex RsMessageModel::parent(const QModelIndex& index) const
|
QModelIndex RsFriendListModel::parent(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
if(!index.isValid())
|
if(!index.isValid())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
@ -147,7 +205,7 @@ QModelIndex RsMessageModel::parent(const QModelIndex& index) const
|
|||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags RsMessageModel::flags(const QModelIndex& index) const
|
Qt::ItemFlags RsFriendListModel::flags(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
@ -155,46 +213,23 @@ Qt::ItemFlags RsMessageModel::flags(const QModelIndex& index) const
|
|||||||
return QAbstractItemModel::flags(index);
|
return QAbstractItemModel::flags(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsMessageModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant RsFriendListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if(role == Qt::DisplayRole)
|
if(role == Qt::DisplayRole)
|
||||||
switch(section)
|
switch(section)
|
||||||
{
|
{
|
||||||
case COLUMN_THREAD_DATE: return tr("Date");
|
case COLUMN_THREAD_NAME: return tr("Name");
|
||||||
case COLUMN_THREAD_AUTHOR: return tr("From");
|
case COLUMN_THREAD_ID: return tr("Id");
|
||||||
case COLUMN_THREAD_SUBJECT: return tr("Subject");
|
case COLUMN_THREAD_LAST_CONTACT: return tr("Last contact");
|
||||||
case COLUMN_THREAD_TAGS: return tr("Tags");
|
case COLUMN_THREAD_IP: return tr("IP");
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(role == Qt::DecorationRole)
|
|
||||||
switch(section)
|
|
||||||
{
|
|
||||||
case COLUMN_THREAD_STAR: return QIcon(IMAGE_STAR_ON);
|
|
||||||
case COLUMN_THREAD_READ: return QIcon(":/images/message-state-header.png");
|
|
||||||
case COLUMN_THREAD_ATTACHMENT: return QIcon(":/images/attachment.png");
|
|
||||||
default:
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(role == Qt::ToolTipRole)
|
|
||||||
switch(section)
|
|
||||||
{
|
|
||||||
case COLUMN_THREAD_ATTACHMENT: return tr("Click to sort by attachments");
|
|
||||||
case COLUMN_THREAD_SUBJECT: return tr("Click to sort by subject");
|
|
||||||
case COLUMN_THREAD_READ: return tr("Click to sort by read");
|
|
||||||
case COLUMN_THREAD_AUTHOR: return tr("Click to sort by from");
|
|
||||||
case COLUMN_THREAD_DATE: return tr("Click to sort by date");
|
|
||||||
case COLUMN_THREAD_TAGS: return tr("Click to sort by tags");
|
|
||||||
case COLUMN_THREAD_STAR: return tr("Click to sort by star");
|
|
||||||
default:
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsMessageModel::data(const QModelIndex &index, int role) const
|
QVariant RsFriendListModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_MESSAGE_MODEL
|
#ifdef DEBUG_MESSAGE_MODEL
|
||||||
std::cerr << "calling data(" << index << ") role=" << role << std::endl;
|
std::cerr << "calling data(" << index << ") role=" << role << std::endl;
|
||||||
@ -211,7 +246,6 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
quintptr ref = (index.isValid())?index.internalId():0 ;
|
quintptr ref = (index.isValid())?index.internalId():0 ;
|
||||||
uint32_t entry = 0;
|
|
||||||
|
|
||||||
#ifdef DEBUG_MESSAGE_MODEL
|
#ifdef DEBUG_MESSAGE_MODEL
|
||||||
std::cerr << "data(" << index << ")" ;
|
std::cerr << "data(" << index << ")" ;
|
||||||
@ -225,7 +259,9 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant() ;
|
return QVariant() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!convertInternalIdToMsgIndex(ref,entry) || entry >= mMessages.size())
|
EntryIndex entry;
|
||||||
|
|
||||||
|
if(!convertInternalIdToIndex(ref,entry))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_MESSAGE_MODEL
|
#ifdef DEBUG_MESSAGE_MODEL
|
||||||
std::cerr << "Bad pointer: " << (void*)ref << std::endl;
|
std::cerr << "Bad pointer: " << (void*)ref << std::endl;
|
||||||
@ -233,55 +269,42 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant() ;
|
return QVariant() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Rs::Msgs::MsgInfoSummary& fmpe(mMessages[entry]);
|
|
||||||
|
|
||||||
if(role == Qt::FontRole)
|
|
||||||
{
|
|
||||||
QFont font ;
|
|
||||||
font.setBold(fmpe.msgflags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER));
|
|
||||||
|
|
||||||
return QVariant(font);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_MESSAGE_MODEL
|
|
||||||
std::cerr << " [ok]" << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch(role)
|
switch(role)
|
||||||
{
|
{
|
||||||
case Qt::DisplayRole: return displayRole (fmpe,index.column()) ;
|
case Qt::DisplayRole: return displayRole(entry,index.column()) ;
|
||||||
case Qt::DecorationRole: return decorationRole(fmpe,index.column()) ;
|
|
||||||
case Qt::ToolTipRole: return toolTipRole (fmpe,index.column()) ;
|
|
||||||
case Qt::UserRole: return userRole (fmpe,index.column()) ;
|
|
||||||
case Qt::TextColorRole: return textColorRole (fmpe,index.column()) ;
|
|
||||||
case Qt::BackgroundRole: return backgroundRole(fmpe,index.column()) ;
|
|
||||||
|
|
||||||
case FilterRole: return filterRole (fmpe,index.column()) ;
|
|
||||||
case StatusRole: return statusRole (fmpe,index.column()) ;
|
|
||||||
case SortRole: return sortRole (fmpe,index.column()) ;
|
|
||||||
case MsgFlagsRole: return fmpe.msgflags ;
|
|
||||||
case UnreadRole: return fmpe.msgflags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER);
|
|
||||||
case MsgIdRole: return QString::fromStdString(fmpe.msgId) ;
|
|
||||||
case SrcIdRole: return QString::fromStdString(fmpe.srcId.toStdString()) ;
|
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if(role == Qt::FontRole)
|
||||||
|
// {
|
||||||
|
// QFont font ;
|
||||||
|
// font.setBold(fmpe.msgflags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER));
|
||||||
|
//
|
||||||
|
// return QVariant(font);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// case Qt::DecorationRole: return decorationRole(fmpe,index.column()) ;
|
||||||
|
// case Qt::ToolTipRole: return toolTipRole (fmpe,index.column()) ;
|
||||||
|
// case Qt::UserRole: return userRole (fmpe,index.column()) ;
|
||||||
|
// case Qt::TextColorRole: return textColorRole (fmpe,index.column()) ;
|
||||||
|
// case Qt::BackgroundRole: return backgroundRole(fmpe,index.column()) ;
|
||||||
|
//
|
||||||
|
// case FilterRole: return filterRole (fmpe,index.column()) ;
|
||||||
|
// case StatusRole: return statusRole (fmpe,index.column()) ;
|
||||||
|
// case SortRole: return sortRole (fmpe,index.column()) ;
|
||||||
|
// case MsgFlagsRole: return fmpe.msgflags ;
|
||||||
|
// case UnreadRole: return fmpe.msgflags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER);
|
||||||
|
// case MsgIdRole: return QString::fromStdString(fmpe.msgId) ;
|
||||||
|
// case SrcIdRole: return QString::fromStdString(fmpe.srcId.toStdString()) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsMessageModel::textColorRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
|
QVariant RsFriendListModel::textColorRole(const EntryIndex& fmpe,int column) const
|
||||||
{
|
{
|
||||||
Rs::Msgs::MsgTagType tags;
|
|
||||||
rsMsgs->getMessageTagTypes(tags);
|
|
||||||
|
|
||||||
for(auto it(fmpe.msgtags.begin());it!=fmpe.msgtags.end();++it)
|
|
||||||
for(auto it2(tags.types.begin());it2!=tags.types.end();++it2)
|
|
||||||
if(it2->first == *it)
|
|
||||||
return QColor(it2->second.second);
|
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsMessageModel::statusRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
|
QVariant RsFriendListModel::statusRole(const EntryIndex& fmpe,int column) const
|
||||||
{
|
{
|
||||||
// if(column != COLUMN_THREAD_DATA)
|
// if(column != COLUMN_THREAD_DATA)
|
||||||
// return QVariant();
|
// return QVariant();
|
||||||
@ -289,71 +312,52 @@ QVariant RsMessageModel::statusRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col
|
|||||||
return QVariant();//fmpe.mMsgStatus);
|
return QVariant();//fmpe.mMsgStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
|
bool RsFriendListModel::passesFilter(const EntryIndex& e,int column) const
|
||||||
{
|
{
|
||||||
QString s ;
|
// QString s ;
|
||||||
bool passes_strings = true ;
|
// bool passes_strings = true ;
|
||||||
|
//
|
||||||
if(!mFilterStrings.empty())
|
// if(!mFilterStrings.empty())
|
||||||
{
|
// {
|
||||||
switch(mFilterType)
|
// switch(mFilterType)
|
||||||
{
|
// {
|
||||||
case FILTER_TYPE_SUBJECT: s = displayRole(fmpe,COLUMN_THREAD_SUBJECT).toString();
|
// case FILTER_TYPE_ID: s = displayRole(fmpe,COLUMN_THREAD_SUBJECT).toString();
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case FILTER_TYPE_FROM: s = sortRole(fmpe,COLUMN_THREAD_AUTHOR).toString();
|
// case FILTER_TYPE_NAME: s = sortRole(fmpe,COLUMN_THREAD_AUTHOR).toString();
|
||||||
if(s.isNull())
|
// if(s.isNull())
|
||||||
passes_strings = false;
|
// passes_strings = false;
|
||||||
break;
|
// break;
|
||||||
case FILTER_TYPE_DATE: s = displayRole(fmpe,COLUMN_THREAD_DATE).toString();
|
// };
|
||||||
break;
|
// }
|
||||||
case FILTER_TYPE_CONTENT: {
|
//
|
||||||
Rs::Msgs::MessageInfo minfo;
|
// if(!s.isNull())
|
||||||
rsMsgs->getMessage(fmpe.msgId,minfo);
|
// for(auto iter(mFilterStrings.begin()); iter != mFilterStrings.end(); ++iter)
|
||||||
s = QTextDocument(QString::fromUtf8(minfo.msg.c_str())).toPlainText();
|
// passes_strings = passes_strings && s.contains(*iter,Qt::CaseInsensitive);
|
||||||
}
|
//
|
||||||
break;
|
// bool passes_quick_view =
|
||||||
case FILTER_TYPE_TAGS: s = displayRole(fmpe,COLUMN_THREAD_TAGS).toString();
|
// (mQuickViewFilter==QUICK_VIEW_ALL)
|
||||||
break;
|
// || (std::find(fmpe.msgtags.begin(),fmpe.msgtags.end(),mQuickViewFilter) != fmpe.msgtags.end())
|
||||||
|
// || (mQuickViewFilter==QUICK_VIEW_STARRED && (fmpe.msgflags & RS_MSG_STAR))
|
||||||
case FILTER_TYPE_ATTACHMENTS:
|
// || (mQuickViewFilter==QUICK_VIEW_SYSTEM && (fmpe.msgflags & RS_MSG_SYSTEM));
|
||||||
{
|
// #ifdef DEBUG_MESSAGE_MODEL
|
||||||
Rs::Msgs::MessageInfo minfo;
|
// std::cerr << "Passes filter: type=" << mFilterType << " s=\"" << s.toStdString() << "MsgFlags=" << fmpe.msgflags << " msgtags=" ;
|
||||||
rsMsgs->getMessage(fmpe.msgId,minfo);
|
// foreach(uint32_t i,fmpe.msgtags) std::cerr << i << " " ;
|
||||||
|
// std::cerr << "\" strings:" << passes_strings << " quick_view:" << passes_quick_view << std::endl;
|
||||||
for(auto it(minfo.files.begin());it!=minfo.files.end();++it)
|
// #endif
|
||||||
s += QString::fromUtf8((*it).fname.c_str())+" ";
|
//
|
||||||
}
|
// return passes_quick_view && passes_strings;
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!s.isNull())
|
|
||||||
for(auto iter(mFilterStrings.begin()); iter != mFilterStrings.end(); ++iter)
|
|
||||||
passes_strings = passes_strings && s.contains(*iter,Qt::CaseInsensitive);
|
|
||||||
|
|
||||||
bool passes_quick_view =
|
|
||||||
(mQuickViewFilter==QUICK_VIEW_ALL)
|
|
||||||
|| (std::find(fmpe.msgtags.begin(),fmpe.msgtags.end(),mQuickViewFilter) != fmpe.msgtags.end())
|
|
||||||
|| (mQuickViewFilter==QUICK_VIEW_STARRED && (fmpe.msgflags & RS_MSG_STAR))
|
|
||||||
|| (mQuickViewFilter==QUICK_VIEW_SYSTEM && (fmpe.msgflags & RS_MSG_SYSTEM));
|
|
||||||
#ifdef DEBUG_MESSAGE_MODEL
|
|
||||||
std::cerr << "Passes filter: type=" << mFilterType << " s=\"" << s.toStdString() << "MsgFlags=" << fmpe.msgflags << " msgtags=" ;
|
|
||||||
foreach(uint32_t i,fmpe.msgtags) std::cerr << i << " " ;
|
|
||||||
std::cerr << "\" strings:" << passes_strings << " quick_view:" << passes_quick_view << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return passes_quick_view && passes_strings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsMessageModel::filterRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
|
QVariant RsFriendListModel::filterRole(const EntryIndex& e,int column) const
|
||||||
{
|
{
|
||||||
if(passesFilter(fmpe,column))
|
if(passesFilter(e,column))
|
||||||
return QVariant(FilterString);
|
return QVariant(FilterString);
|
||||||
|
|
||||||
return QVariant(QString());
|
return QVariant(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t RsMessageModel::updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings)
|
uint32_t RsFriendListModel::updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings)
|
||||||
{
|
{
|
||||||
QString s ;
|
QString s ;
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
@ -362,7 +366,7 @@ uint32_t RsMessageModel::updateFilterStatus(ForumModelIndex i,int column,const Q
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RsMessageModel::setFilter(FilterType filter_type, const QStringList& strings)
|
void RsFriendListModel::setFilter(FilterType filter_type, const QStringList& strings)
|
||||||
{
|
{
|
||||||
std::cerr << "Setting filter to filter_type=" << int(filter_type) << " and strings to " ;
|
std::cerr << "Setting filter to filter_type=" << int(filter_type) << " and strings to " ;
|
||||||
foreach(const QString& str,strings)
|
foreach(const QString& str,strings)
|
||||||
@ -377,317 +381,225 @@ void RsMessageModel::setFilter(FilterType filter_type, const QStringList& string
|
|||||||
postMods();
|
postMods();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsMessageModel::toolTipRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
|
QVariant RsFriendListModel::toolTipRole(const EntryIndex& fmpe,int column) const
|
||||||
{
|
{
|
||||||
if(column == COLUMN_THREAD_AUTHOR)
|
// if(column == COLUMN_THREAD_AUTHOR)
|
||||||
{
|
// {
|
||||||
QString str,comment ;
|
// QString str,comment ;
|
||||||
QList<QIcon> icons;
|
// QList<QIcon> icons;
|
||||||
|
//
|
||||||
if(!GxsIdDetails::MakeIdDesc(RsGxsId(fmpe.srcId.toStdString()), true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR))
|
// if(!GxsIdDetails::MakeIdDesc(RsGxsId(fmpe.srcId.toStdString()), true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR))
|
||||||
return QVariant();
|
// return QVariant();
|
||||||
|
//
|
||||||
int S = QFontMetricsF(QApplication::font()).height();
|
// int S = QFontMetricsF(QApplication::font()).height();
|
||||||
QImage pix( (*icons.begin()).pixmap(QSize(4*S,4*S)).toImage());
|
// QImage pix( (*icons.begin()).pixmap(QSize(4*S,4*S)).toImage());
|
||||||
|
//
|
||||||
QString embeddedImage;
|
// QString embeddedImage;
|
||||||
if(RsHtml::makeEmbeddedImage(pix.scaled(QSize(4*S,4*S), Qt::KeepAspectRatio, Qt::SmoothTransformation), embeddedImage, 8*S * 8*S))
|
// if(RsHtml::makeEmbeddedImage(pix.scaled(QSize(4*S,4*S), Qt::KeepAspectRatio, Qt::SmoothTransformation), embeddedImage, 8*S * 8*S))
|
||||||
comment = "<table><tr><td>" + embeddedImage + "</td><td>" + comment + "</td></table>";
|
// comment = "<table><tr><td>" + embeddedImage + "</td><td>" + comment + "</td></table>";
|
||||||
|
//
|
||||||
return comment;
|
// return comment;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsMessageModel::backgroundRole(const Rs::Msgs::MsgInfoSummary &fmpe, int column) const
|
QVariant RsFriendListModel::sizeHintRole(int col) const
|
||||||
{
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant RsMessageModel::sizeHintRole(int col) const
|
|
||||||
{
|
{
|
||||||
float factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
|
float factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
|
||||||
|
|
||||||
switch(col)
|
switch(col)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case COLUMN_THREAD_SUBJECT: return QVariant( QSize(factor * 170, factor*14 ));
|
case COLUMN_THREAD_NAME: return QVariant( QSize(factor * 170, factor*14 ));
|
||||||
case COLUMN_THREAD_DATE: return QVariant( QSize(factor * 75 , factor*14 ));
|
case COLUMN_THREAD_IP: return QVariant( QSize(factor * 75 , factor*14 ));
|
||||||
case COLUMN_THREAD_AUTHOR: return QVariant( QSize(factor * 75 , factor*14 ));
|
case COLUMN_THREAD_ID: return QVariant( QSize(factor * 75 , factor*14 ));
|
||||||
|
case COLUMN_THREAD_LAST_CONTACT: return QVariant( QSize(factor * 75 , factor*14 ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsMessageModel::authorRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
|
QVariant RsFriendListModel::sortRole(const EntryIndex& fmpe,int column) const
|
||||||
{
|
{
|
||||||
|
// switch(column)
|
||||||
|
// {
|
||||||
|
// case COLUMN_THREAD_DATE: return QVariant(QString::number(fmpe.ts)); // we should probably have leading zeroes here
|
||||||
|
//
|
||||||
|
// case COLUMN_THREAD_READ: return QVariant((bool)IS_MESSAGE_UNREAD(fmpe.msgflags));
|
||||||
|
//
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsMessageModel::sortRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
|
QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
|
||||||
{
|
{
|
||||||
switch(column)
|
switch(e.type)
|
||||||
{
|
|
||||||
case COLUMN_THREAD_DATE: return QVariant(QString::number(fmpe.ts)); // we should probably have leading zeroes here
|
|
||||||
|
|
||||||
case COLUMN_THREAD_READ: return QVariant((bool)IS_MESSAGE_UNREAD(fmpe.msgflags));
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant RsMessageModel::displayRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col) const
|
|
||||||
{
|
|
||||||
switch(col)
|
|
||||||
{
|
{
|
||||||
case COLUMN_THREAD_SUBJECT: return QVariant(QString::fromUtf8(fmpe.title.c_str()));
|
case ENTRY_TYPE_GROUP:
|
||||||
case COLUMN_THREAD_ATTACHMENT:return QVariant(QString::number(fmpe.count));
|
if(e.ind >= mGroups.size())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
case COLUMN_THREAD_STAR:
|
switch(col)
|
||||||
case COLUMN_THREAD_READ:return QVariant();
|
{
|
||||||
case COLUMN_THREAD_DATE:{
|
case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(mGroups[e.ind].name.c_str()));
|
||||||
QDateTime qtime;
|
|
||||||
qtime.setTime_t(fmpe.ts);
|
|
||||||
|
|
||||||
return QVariant(DateTime::formatDateTime(qtime));
|
default:
|
||||||
|
return QVariant();
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case ENTRY_TYPE_PROFILE:
|
||||||
|
if(e.ind >= mProfiles.size())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
switch(col)
|
||||||
|
{
|
||||||
|
case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(mProfiles[e.ind].name.c_str()));
|
||||||
|
case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(mProfiles[e.ind].gpg_id.toStdString()) );
|
||||||
|
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case ENTRY_TYPE_NODE:
|
||||||
|
if(e.ind >= mLocations.size())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
switch(col)
|
||||||
|
{
|
||||||
|
case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(mLocations[e.ind].location.c_str()));
|
||||||
|
case COLUMN_THREAD_LAST_CONTACT: return QVariant(QDateTime::fromTime_t(mLocations[e.ind].lastConnect).toString());
|
||||||
|
case COLUMN_THREAD_IP: return QVariant( (mLocations[e.ind].state & RS_PEER_STATE_CONNECTED) ? StatusDefs::connectStateIpString(mLocations[e.ind]) : QString("---"));
|
||||||
|
case COLUMN_THREAD_ID: return QVariant( QString::fromStdString(mLocations[e.ind].id.toStdString()) );
|
||||||
|
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
} break;
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
case COLUMN_THREAD_TAGS:{
|
|
||||||
// Tags
|
|
||||||
Rs::Msgs::MsgTagInfo tagInfo;
|
|
||||||
rsMsgs->getMessageTag(fmpe.msgId, tagInfo);
|
|
||||||
|
|
||||||
Rs::Msgs::MsgTagType Tags;
|
|
||||||
rsMsgs->getMessageTagTypes(Tags);
|
|
||||||
|
|
||||||
QString text;
|
|
||||||
|
|
||||||
// build tag names
|
|
||||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
|
|
||||||
for (auto tagit = tagInfo.tagIds.begin(); tagit != tagInfo.tagIds.end(); ++tagit)
|
|
||||||
{
|
|
||||||
if (!text.isNull())
|
|
||||||
text += ",";
|
|
||||||
|
|
||||||
auto Tag = Tags.types.find(*tagit);
|
|
||||||
|
|
||||||
if (Tag != Tags.types.end())
|
|
||||||
text += TagDefs::name(Tag->first, Tag->second.first);
|
|
||||||
else
|
|
||||||
std::cerr << "(WW) unknown tag " << (int)Tag->first << " in message " << fmpe.msgId << std::endl;
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
case COLUMN_THREAD_AUTHOR: return QVariant();
|
|
||||||
|
|
||||||
default:
|
|
||||||
return QVariant("[ TODO ]");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return QVariant("[ERROR]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsMessageModel::userRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col) const
|
QVariant RsFriendListModel::userRole(const EntryIndex& fmpe,int col) const
|
||||||
{
|
{
|
||||||
switch(col)
|
// switch(col)
|
||||||
{
|
// {
|
||||||
case COLUMN_THREAD_AUTHOR: return QVariant(QString::fromStdString(fmpe.srcId.toStdString()));
|
// case COLUMN_THREAD_AUTHOR: return QVariant(QString::fromStdString(fmpe.srcId.toStdString()));
|
||||||
case COLUMN_THREAD_MSGID: return QVariant(QString::fromStdString(fmpe.msgId));
|
// case COLUMN_THREAD_MSGID: return QVariant(QString::fromStdString(fmpe.msgId));
|
||||||
default:
|
// default:
|
||||||
return QVariant();
|
// return QVariant();
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsMessageModel::decorationRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col) const
|
QVariant RsFriendListModel::decorationRole(const EntryIndex& fmpe,int col) const
|
||||||
{
|
{
|
||||||
if(col == COLUMN_THREAD_READ)
|
// if(col == COLUMN_THREAD_READ)
|
||||||
if(fmpe.msgflags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER))
|
// if(fmpe.msgflags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER))
|
||||||
return QIcon(":/images/message-state-unread.png");
|
// return QIcon(":/images/message-state-unread.png");
|
||||||
else
|
// else
|
||||||
return QIcon(":/images/message-state-read.png");
|
// return QIcon(":/images/message-state-read.png");
|
||||||
|
//
|
||||||
if(col == COLUMN_THREAD_SUBJECT)
|
// if(col == COLUMN_THREAD_SUBJECT)
|
||||||
{
|
// {
|
||||||
if(fmpe.msgflags & RS_MSG_NEW ) return QIcon(":/images/message-state-new.png");
|
// if(fmpe.msgflags & RS_MSG_NEW ) return QIcon(":/images/message-state-new.png");
|
||||||
if(fmpe.msgflags & RS_MSG_USER_REQUEST) return QIcon(":/images/user/user_request16.png");
|
// if(fmpe.msgflags & RS_MSG_USER_REQUEST) return QIcon(":/images/user/user_request16.png");
|
||||||
if(fmpe.msgflags & RS_MSG_FRIEND_RECOMMENDATION) return QIcon(":/images/user/friend_suggestion16.png");
|
// if(fmpe.msgflags & RS_MSG_FRIEND_RECOMMENDATION) return QIcon(":/images/user/friend_suggestion16.png");
|
||||||
if(fmpe.msgflags & RS_MSG_PUBLISH_KEY) return QIcon(":/images/share-icon-16.png");
|
// if(fmpe.msgflags & RS_MSG_PUBLISH_KEY) return QIcon(":/images/share-icon-16.png");
|
||||||
|
//
|
||||||
if(fmpe.msgflags & RS_MSG_UNREAD_BY_USER)
|
// if(fmpe.msgflags & RS_MSG_UNREAD_BY_USER)
|
||||||
{
|
// {
|
||||||
if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_REPLIED) return QIcon(":/images/message-mail-replied.png");
|
// if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_REPLIED) return QIcon(":/images/message-mail-replied.png");
|
||||||
if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_FORWARDED) return QIcon(":/images/message-mail-forwarded.png");
|
// if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_FORWARDED) return QIcon(":/images/message-mail-forwarded.png");
|
||||||
if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == (RS_MSG_REPLIED | RS_MSG_FORWARDED)) return QIcon(":/images/message-mail-replied-forw.png");
|
// if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == (RS_MSG_REPLIED | RS_MSG_FORWARDED)) return QIcon(":/images/message-mail-replied-forw.png");
|
||||||
|
//
|
||||||
return QIcon(":/images/message-mail.png");
|
// return QIcon(":/images/message-mail.png");
|
||||||
}
|
// }
|
||||||
if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_REPLIED) return QIcon(":/images/message-mail-replied-read.png");
|
// if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_REPLIED) return QIcon(":/images/message-mail-replied-read.png");
|
||||||
if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_FORWARDED) return QIcon(":/images/message-mail-forwarded-read.png");
|
// if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_FORWARDED) return QIcon(":/images/message-mail-forwarded-read.png");
|
||||||
if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == (RS_MSG_REPLIED | RS_MSG_FORWARDED)) return QIcon(":/images/message-mail-replied-forw-read.png");
|
// if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == (RS_MSG_REPLIED | RS_MSG_FORWARDED)) return QIcon(":/images/message-mail-replied-forw-read.png");
|
||||||
|
//
|
||||||
return QIcon(":/images/message-mail-read.png");
|
// return QIcon(":/images/message-mail-read.png");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(col == COLUMN_THREAD_STAR)
|
// if(col == COLUMN_THREAD_STAR)
|
||||||
return QIcon((fmpe.msgflags & RS_MSG_STAR) ? (IMAGE_STAR_ON ): (IMAGE_STAR_OFF));
|
// return QIcon((fmpe.msgflags & RS_MSG_STAR) ? (IMAGE_STAR_ON ): (IMAGE_STAR_OFF));
|
||||||
|
//
|
||||||
bool isNew = fmpe.msgflags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER);
|
// bool isNew = fmpe.msgflags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER);
|
||||||
|
//
|
||||||
if(col == COLUMN_THREAD_READ)
|
// if(col == COLUMN_THREAD_READ)
|
||||||
return QIcon(isNew ? ":/images/message-state-unread.png": ":/images/message-state-read.png");
|
// return QIcon(isNew ? ":/images/message-state-unread.png": ":/images/message-state-read.png");
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsMessageModel::clear()
|
void RsFriendListModel::clear()
|
||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
mMessages.clear();
|
mGroups.clear();
|
||||||
|
mProfiles.clear();
|
||||||
|
mLocations.clear();
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
|
|
||||||
emit messagesLoaded();
|
emit friendListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsMessageModel::setMessages(const std::list<Rs::Msgs::MsgInfoSummary>& msgs)
|
// void RsFriendListModel::setMessages(const std::list<Rs::Msgs::MsgInfoSummary>& msgs)
|
||||||
{
|
// {
|
||||||
preMods();
|
// preMods();
|
||||||
|
//
|
||||||
beginRemoveRows(QModelIndex(),0,mMessages.size()-1);
|
// beginRemoveRows(QModelIndex(),0,mMessages.size()-1);
|
||||||
endRemoveRows();
|
// endRemoveRows();
|
||||||
|
//
|
||||||
mMessages.clear();
|
// mMessages.clear();
|
||||||
mMessagesMap.clear();
|
// mMessagesMap.clear();
|
||||||
|
//
|
||||||
for(auto it(msgs.begin());it!=msgs.end();++it)
|
// for(auto it(msgs.begin());it!=msgs.end();++it)
|
||||||
{
|
// {
|
||||||
mMessagesMap[(*it).msgId] = mMessages.size();
|
// mMessagesMap[(*it).msgId] = mMessages.size();
|
||||||
mMessages.push_back(*it);
|
// mMessages.push_back(*it);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// now update prow for all posts
|
// // now update prow for all posts
|
||||||
|
//
|
||||||
#ifdef DEBUG_MESSAGE_MODEL
|
// #ifdef DEBUG_MESSAGE_MODEL
|
||||||
debug_dump();
|
// debug_dump();
|
||||||
#endif
|
// #endif
|
||||||
|
//
|
||||||
beginInsertRows(QModelIndex(),0,mMessages.size()-1);
|
// beginInsertRows(QModelIndex(),0,mMessages.size()-1);
|
||||||
endInsertRows();
|
// endInsertRows();
|
||||||
postMods();
|
// postMods();
|
||||||
|
//
|
||||||
emit messagesLoaded();
|
// emit messagesLoaded();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
void RsMessageModel::setCurrentBox(BoxName bn)
|
// void RsFriendListModel::updateMessages()
|
||||||
{
|
// {
|
||||||
if(mCurrentBox != bn)
|
// emit messagesAboutToLoad();
|
||||||
{
|
//
|
||||||
mCurrentBox = bn;
|
// std::list<Rs::Msgs::MsgInfoSummary> msgs;
|
||||||
updateMessages();
|
//
|
||||||
}
|
// getMessageSummaries(mCurrentBox,msgs);
|
||||||
}
|
// setMessages(msgs);
|
||||||
|
//
|
||||||
void RsMessageModel::setQuickViewFilter(QuickViewFilter fn)
|
// emit messagesLoaded();
|
||||||
{
|
// }
|
||||||
if(fn != mQuickViewFilter)
|
|
||||||
{
|
|
||||||
std::cerr << "Changing new quickview filter to " << fn << std::endl;
|
|
||||||
|
|
||||||
preMods();
|
|
||||||
mQuickViewFilter = fn ;
|
|
||||||
postMods();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RsMessageModel::getMessageSummaries(BoxName box,std::list<Rs::Msgs::MsgInfoSummary>& msgs)
|
|
||||||
{
|
|
||||||
rsMsgs->getMessageSummaries(msgs);
|
|
||||||
|
|
||||||
// filter out messages that are not in the right box.
|
|
||||||
|
|
||||||
for(auto it(msgs.begin());it!=msgs.end();)
|
|
||||||
{
|
|
||||||
bool ok = false;
|
|
||||||
|
|
||||||
switch(box)
|
|
||||||
{
|
|
||||||
case BOX_INBOX : ok = (it->msgflags & RS_MSG_BOXMASK) == RS_MSG_INBOX && !(it->msgflags & RS_MSG_TRASH); break ;
|
|
||||||
case BOX_SENT : ok = (it->msgflags & RS_MSG_BOXMASK) == RS_MSG_SENTBOX && !(it->msgflags & RS_MSG_TRASH); break ;
|
|
||||||
case BOX_OUTBOX : ok = (it->msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX && !(it->msgflags & RS_MSG_TRASH); break ;
|
|
||||||
case BOX_DRAFTS : ok = (it->msgflags & RS_MSG_BOXMASK) == RS_MSG_DRAFTBOX && !(it->msgflags & RS_MSG_TRASH); break ;
|
|
||||||
case BOX_TRASH : ok = (it->msgflags & RS_MSG_TRASH) ; break ;
|
|
||||||
default:
|
|
||||||
++it;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ok)
|
|
||||||
++it;
|
|
||||||
else
|
|
||||||
it = msgs.erase(it) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RsMessageModel::updateMessages()
|
|
||||||
{
|
|
||||||
emit messagesAboutToLoad();
|
|
||||||
|
|
||||||
std::list<Rs::Msgs::MsgInfoSummary> msgs;
|
|
||||||
|
|
||||||
getMessageSummaries(mCurrentBox,msgs);
|
|
||||||
setMessages(msgs);
|
|
||||||
|
|
||||||
emit messagesLoaded();
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
|
static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
|
||||||
|
|
||||||
void RsMessageModel::setMsgReadStatus(const QModelIndex& i,bool read_status)
|
void RsFriendListModel::debug_dump() const
|
||||||
{
|
{
|
||||||
if(!i.isValid())
|
for(auto it(mGroups.begin());it!=mGroups.end();++it)
|
||||||
return ;
|
std::cerr << "Group: " << *it << std::endl;
|
||||||
|
|
||||||
preMods();
|
|
||||||
rsMsgs->MessageRead(i.data(MsgIdRole).toString().toStdString(),!read_status);
|
|
||||||
|
|
||||||
emit dataChanged(i.sibling(i.row(),0),i.sibling(i.row(),COLUMN_THREAD_NB_COLUMNS-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
void RsMessageModel::setMsgStar(const QModelIndex& i,bool star)
|
|
||||||
{
|
|
||||||
preMods();
|
|
||||||
rsMsgs->MessageStar(i.data(MsgIdRole).toString().toStdString(),star);
|
|
||||||
|
|
||||||
emit dataChanged(i.sibling(i.row(),0),i.sibling(i.row(),COLUMN_THREAD_NB_COLUMNS-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndex RsMessageModel::getIndexOfMessage(const std::string& mid) const
|
|
||||||
{
|
|
||||||
// Brutal search. This is not so nice, so dont call that in a loop! If too costly, we'll use a map.
|
|
||||||
|
|
||||||
auto it = mMessagesMap.find(mid);
|
|
||||||
|
|
||||||
if(it == mMessagesMap.end() || it->second >= mMessages.size())
|
|
||||||
return QModelIndex();
|
|
||||||
|
|
||||||
quintptr ref ;
|
|
||||||
convertMsgIndexToInternalId(it->second,ref);
|
|
||||||
|
|
||||||
return createIndex(it->second,0,ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RsMessageModel::debug_dump() const
|
|
||||||
{
|
|
||||||
for(auto it(mMessages.begin());it!=mMessages.end();++it)
|
|
||||||
std::cerr << "Id: " << it->msgId << ": from " << it->srcId << ": flags=" << it->msgflags << ": title=\"" << it->title << "\"" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
#include "retroshare/rsmsgs.h"
|
#include "retroshare/rsmsgs.h"
|
||||||
|
#include "retroshare/rspeers.h"
|
||||||
|
|
||||||
// This class holds the actual hierarchy of posts, represented by identifiers
|
// This class holds the actual hierarchy of posts, represented by identifiers
|
||||||
// It is responsible for auto-updating when necessary and holds a mutex to allow the Model to
|
// It is responsible for auto-updating when necessary and holds a mutex to allow the Model to
|
||||||
@ -43,17 +44,15 @@ public:
|
|||||||
explicit RsFriendListModel(QObject *parent = NULL);
|
explicit RsFriendListModel(QObject *parent = NULL);
|
||||||
~RsFriendListModel(){}
|
~RsFriendListModel(){}
|
||||||
|
|
||||||
|
class RsNodeDetails: public RsPeerDetails {};// in the near future, there will be a specific class for Profile/Node details in replacement of RsPeerDetails
|
||||||
|
class RsProfileDetails: public RsPeerDetails {};
|
||||||
|
|
||||||
enum Columns {
|
enum Columns {
|
||||||
COLUMN_THREAD_STAR = 0x00,
|
COLUMN_THREAD_NAME = 0x00,
|
||||||
COLUMN_THREAD_ATTACHMENT = 0x01,
|
COLUMN_THREAD_LAST_CONTACT = 0x01,
|
||||||
COLUMN_THREAD_SUBJECT = 0x02,
|
COLUMN_THREAD_IP = 0x02,
|
||||||
COLUMN_THREAD_READ = 0x03,
|
COLUMN_THREAD_ID = 0x03,
|
||||||
COLUMN_THREAD_AUTHOR = 0x04,
|
COLUMN_THREAD_NB_COLUMNS = 0x04
|
||||||
COLUMN_THREAD_DATE = 0x05,
|
|
||||||
COLUMN_THREAD_TAGS = 0x06,
|
|
||||||
COLUMN_THREAD_MSGID = 0x07,
|
|
||||||
COLUMN_THREAD_NB_COLUMNS = 0x08,
|
|
||||||
COLUMN_THREAD_CONTENT = 0x08,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Roles{ SortRole = Qt::UserRole+1,
|
enum Roles{ SortRole = Qt::UserRole+1,
|
||||||
@ -65,14 +64,36 @@ public:
|
|||||||
SrcIdRole = Qt::UserRole+7,
|
SrcIdRole = Qt::UserRole+7,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum FilterType{ FILTER_TYPE_NONE = 0x00,
|
||||||
|
FILTER_TYPE_ID = 0x01,
|
||||||
|
FILTER_TYPE_NAME = 0x02
|
||||||
|
};
|
||||||
|
|
||||||
|
enum EntryType{ ENTRY_TYPE_UNKNOWN = 0x00,
|
||||||
|
ENTRY_TYPE_GROUP = 0x01,
|
||||||
|
ENTRY_TYPE_PROFILE = 0x02,
|
||||||
|
ENTRY_TYPE_NODE = 0x03
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EntryIndex
|
||||||
|
{
|
||||||
|
EntryIndex(EntryType t,uint32_t i) : type(t),ind(i) {}
|
||||||
|
EntryIndex() : type(ENTRY_TYPE_UNKNOWN),ind(0) {}
|
||||||
|
|
||||||
|
EntryType type;
|
||||||
|
uint32_t ind;
|
||||||
|
};
|
||||||
|
|
||||||
QModelIndex root() const{ return createIndex(0,0,(void*)NULL) ;}
|
QModelIndex root() const{ return createIndex(0,0,(void*)NULL) ;}
|
||||||
QModelIndex getIndexOfMessage(const std::string &mid) const;
|
|
||||||
|
QModelIndex getIndexOfGroup(const RsNodeGroupId& mid) const;
|
||||||
|
|
||||||
static const QString FilterString ;
|
static const QString FilterString ;
|
||||||
|
|
||||||
// This method will asynchroneously update the data
|
// This method will asynchroneously update the data
|
||||||
|
|
||||||
const RsMessageId& currentMessageId() const;
|
EntryType currentItemData(RsGroupInfo&,RsProfileDetails&,RsNodeDetails&) const;
|
||||||
|
|
||||||
void setFilter(FilterType filter_type, const QStringList& strings) ;
|
void setFilter(FilterType filter_type, const QStringList& strings) ;
|
||||||
|
|
||||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||||
@ -90,15 +111,17 @@ public:
|
|||||||
|
|
||||||
QVariant sizeHintRole (int col) const;
|
QVariant sizeHintRole (int col) const;
|
||||||
|
|
||||||
QVariant displayRole (const Rs::Msgs::MsgInfoSummary& fmpe, int col) const;
|
QVariant displayRole (const EntryIndex &e, int col) const;
|
||||||
QVariant decorationRole(const Rs::Msgs::MsgInfoSummary& fmpe, int col) const;
|
|
||||||
QVariant toolTipRole (const Rs::Msgs::MsgInfoSummary& fmpe, int col) const;
|
QVariant decorationRole(const EntryIndex& fmpe, int col) const;
|
||||||
QVariant userRole (const Rs::Msgs::MsgInfoSummary& fmpe, int col) const;
|
QVariant toolTipRole (const EntryIndex &fmpe, int col) const;
|
||||||
QVariant statusRole (const Rs::Msgs::MsgInfoSummary& fmpe, int col) const;
|
QVariant userRole (const EntryIndex& fmpe, int col) const;
|
||||||
QVariant sortRole (const Rs::Msgs::MsgInfoSummary& fmpe, int col) const;
|
QVariant statusRole (const EntryIndex& fmpe, int col) const;
|
||||||
QVariant fontRole (const Rs::Msgs::MsgInfoSummary& fmpe, int col) const;
|
QVariant sortRole (const EntryIndex& fmpe, int col) const;
|
||||||
QVariant filterRole (const Rs::Msgs::MsgInfoSummary& fmpe, int col) const;
|
QVariant fontRole (const EntryIndex& fmpe, int col) const;
|
||||||
QVariant textColorRole (const Rs::Msgs::MsgInfoSummary& fmpe, int col) const;
|
QVariant textColorRole (const EntryIndex& fmpe, int col) const;
|
||||||
|
|
||||||
|
QVariant filterRole (const EntryIndex& e, int col) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief debug_dump
|
* \brief debug_dump
|
||||||
@ -111,10 +134,11 @@ public slots:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataLoaded(); // emitted after the messages have been set. Can be used to updated the UI.
|
void dataLoaded(); // emitted after the messages have been set. Can be used to updated the UI.
|
||||||
|
void friendListChanged(); // emitted after the messages have been set. Can be used to updated the UI.
|
||||||
void dataAboutToLoad();
|
void dataAboutToLoad();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const;
|
bool passesFilter(const EntryIndex &e, int column) const;
|
||||||
|
|
||||||
void preMods() ;
|
void preMods() ;
|
||||||
void postMods() ;
|
void postMods() ;
|
||||||
@ -123,15 +147,17 @@ private:
|
|||||||
void *getChildRef(void *ref,int row) const;
|
void *getChildRef(void *ref,int row) const;
|
||||||
int getChildrenCount(void *ref) const;
|
int getChildrenCount(void *ref) const;
|
||||||
|
|
||||||
static bool convertMsgIndexToInternalId(uint32_t entry,quintptr& ref);
|
static bool convertIndexToInternalId(const EntryIndex& e,quintptr& ref);
|
||||||
static bool convertInternalIdToMsgIndex(quintptr ref,uint32_t& index);
|
static bool convertInternalIdToIndex(quintptr ref, EntryIndex& e);
|
||||||
|
|
||||||
uint32_t updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings);
|
uint32_t updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings);
|
||||||
|
|
||||||
QStringList mFilterStrings;
|
QStringList mFilterStrings;
|
||||||
FilterType mFilterType;
|
FilterType mFilterType;
|
||||||
|
|
||||||
|
bool mDisplayGroups ;
|
||||||
|
|
||||||
std::vector<RsGroupInfo> mGroups;
|
std::vector<RsGroupInfo> mGroups;
|
||||||
std::vector<RsPeerDetails> mProfiles; // normally here we should have a specific class rather than RsPeerDetails
|
std::vector<RsProfileDetails> mProfiles;
|
||||||
std::vector<RsPeerDetails> mLocations;// normally here we should have a specific class rather than RsPeerDetails
|
std::vector<RsNodeDetails> mLocations;
|
||||||
};
|
};
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
#include "gui/connect/ConnectProgressDialog.h"
|
#include "gui/connect/ConnectProgressDialog.h"
|
||||||
#include "gui/common/ElidedLabel.h"
|
#include "gui/common/ElidedLabel.h"
|
||||||
|
|
||||||
#include "FriendList.h"
|
#include "NewFriendList.h"
|
||||||
#include "ui_FriendList.h"
|
#include "ui_FriendList.h"
|
||||||
|
|
||||||
/* Images for context menu icons */
|
/* Images for context menu icons */
|
||||||
@ -109,34 +109,34 @@
|
|||||||
Q_DECLARE_METATYPE(ElidedLabel*)
|
Q_DECLARE_METATYPE(ElidedLabel*)
|
||||||
|
|
||||||
NewFriendList::NewFriendList(QWidget *parent) :
|
NewFriendList::NewFriendList(QWidget *parent) :
|
||||||
QAbstractItemView(parent),
|
QTreeView(parent),
|
||||||
mCompareRole(new RSTreeWidgetItemCompareRole),
|
// mCompareRole(new RSTreeWidgetItemCompareRole),
|
||||||
mShowGroups(true),
|
mShowGroups(true),
|
||||||
mShowState(false),
|
mShowState(false),
|
||||||
mHideUnconnected(false),
|
mHideUnconnected(false),
|
||||||
groupsHasChanged(false)
|
groupsHasChanged(false)
|
||||||
{
|
{
|
||||||
connect(ui->peerTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(peerTreeWidgetCustomPopupMenu()));
|
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(peerTreeWidgetCustomPopupMenu()));
|
||||||
connect(ui->peerTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem *)), this, SLOT(expandItem(QTreeWidgetItem *)));
|
connect(this, SIGNAL(itemExpanded(QTreeWidgetItem *)), this, SLOT(expandItem(QTreeWidgetItem *)));
|
||||||
connect(ui->peerTreeWidget, SIGNAL(itemCollapsed(QTreeWidgetItem *)), this, SLOT(collapseItem(QTreeWidgetItem *)));
|
connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem *)), this, SLOT(collapseItem(QTreeWidgetItem *)));
|
||||||
connect(ui->peerTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(expandItem(QTreeWidgetItem *)) );
|
connect(this, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(expandItem(QTreeWidgetItem *)) );
|
||||||
|
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged()));
|
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged()));
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(insertPeers()));
|
connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(insertPeers()));
|
||||||
|
|
||||||
connect(ui->actionHideOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setHideUnconnected(bool)));
|
// connect(ui->actionHideOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setHideUnconnected(bool)));
|
||||||
connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool)));
|
// connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool)));
|
||||||
connect(ui->actionShowGroups, SIGNAL(triggered(bool)), this, SLOT(setShowGroups(bool)));
|
// connect(ui->actionShowGroups, SIGNAL(triggered(bool)), this, SLOT(setShowGroups(bool)));
|
||||||
connect(ui->actionExportFriendlist, SIGNAL(triggered()), this, SLOT(exportFriendlistClicked()));
|
// connect(ui->actionExportFriendlist, SIGNAL(triggered()), this, SLOT(exportFriendlistClicked()));
|
||||||
connect(ui->actionImportFriendlist, SIGNAL(triggered()), this, SLOT(importFriendlistClicked()));
|
// connect(ui->actionImportFriendlist, SIGNAL(triggered()), this, SLOT(importFriendlistClicked()));
|
||||||
|
|
||||||
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
|
||||||
|
|
||||||
ui->filterLineEdit->setPlaceholderText(tr("Search")) ;
|
|
||||||
ui->filterLineEdit->showFilterIcon();
|
|
||||||
|
|
||||||
|
// connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
||||||
|
//
|
||||||
|
// ui->filterLineEdit->setPlaceholderText(tr("Search")) ;
|
||||||
|
// ui->filterLineEdit->showFilterIcon();
|
||||||
|
//
|
||||||
/* Add filter actions */
|
/* Add filter actions */
|
||||||
QTreeWidgetItem *headerItem = ui->peerTreeWidget->headerItem();
|
QTreeWidgetItem *headerItem = headerItem();
|
||||||
QString headerText = headerItem->text(COLUMN_NAME);
|
QString headerText = headerItem->text(COLUMN_NAME);
|
||||||
ui->filterLineEdit->addFilter(QIcon(), headerText, COLUMN_NAME, QString("%1 %2").arg(tr("Search"), headerText));
|
ui->filterLineEdit->addFilter(QIcon(), headerText, COLUMN_NAME, QString("%1 %2").arg(tr("Search"), headerText));
|
||||||
ui->filterLineEdit->addFilter(QIcon(), tr("ID"), COLUMN_ID, tr("Search ID"));
|
ui->filterLineEdit->addFilter(QIcon(), tr("ID"), COLUMN_ID, tr("Search ID"));
|
||||||
|
@ -18,12 +18,12 @@
|
|||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#ifndef FRIENDLIST_H
|
#pragma once
|
||||||
#define FRIENDLIST_H
|
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
#include "retroshare/rsstatus.h"
|
#include "retroshare/rsstatus.h"
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ class RSTreeWidgetItemCompareRole;
|
|||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
|
|
||||||
class NewFriendList : public QAbstractItemView
|
class NewFriendList : public QTreeView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -159,5 +159,3 @@ private slots:
|
|||||||
void exportFriendlistClicked();
|
void exportFriendlistClicked();
|
||||||
void importFriendlistClicked();
|
void importFriendlistClicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FRIENDLIST_H
|
|
||||||
|
@ -243,7 +243,7 @@ QString StatusDefs::connectStateWithoutTransportTypeString(RsPeerDetails &detail
|
|||||||
return stateString;
|
return stateString;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString StatusDefs::connectStateIpString(RsPeerDetails &details)
|
QString StatusDefs::connectStateIpString(const RsPeerDetails &details)
|
||||||
{
|
{
|
||||||
QString stateString = QString("");
|
QString stateString = QString("");
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
static QString peerStateString(int peerState);
|
static QString peerStateString(int peerState);
|
||||||
static QString connectStateString(RsPeerDetails &details);
|
static QString connectStateString(RsPeerDetails &details);
|
||||||
static QString connectStateWithoutTransportTypeString(RsPeerDetails &details);
|
static QString connectStateWithoutTransportTypeString(RsPeerDetails &details);
|
||||||
static QString connectStateIpString(RsPeerDetails &details);
|
static QString connectStateIpString(const RsPeerDetails &details);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user