mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-28 08:16:59 -05:00
inserted the model into the widget
This commit is contained in:
parent
4fce5d61cc
commit
b7c8c16e29
@ -40,6 +40,7 @@
|
|||||||
#include "msgs/MessageUserNotify.h"
|
#include "msgs/MessageUserNotify.h"
|
||||||
#include "msgs/MessageWidget.h"
|
#include "msgs/MessageWidget.h"
|
||||||
#include "msgs/TagsMenu.h"
|
#include "msgs/TagsMenu.h"
|
||||||
|
#include "msgs/MessageModel.h"
|
||||||
#include "settings/rsharesettings.h"
|
#include "settings/rsharesettings.h"
|
||||||
|
|
||||||
#include "util/DateTime.h"
|
#include "util/DateTime.h"
|
||||||
@ -99,20 +100,24 @@
|
|||||||
|
|
||||||
MessagesDialog::LockUpdate::LockUpdate (MessagesDialog *pDialog, bool bUpdate)
|
MessagesDialog::LockUpdate::LockUpdate (MessagesDialog *pDialog, bool bUpdate)
|
||||||
{
|
{
|
||||||
|
#ifdef TODO
|
||||||
m_pDialog = pDialog;
|
m_pDialog = pDialog;
|
||||||
m_bUpdate = bUpdate;
|
m_bUpdate = bUpdate;
|
||||||
|
|
||||||
++m_pDialog->lockUpdate;
|
++m_pDialog->lockUpdate;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesDialog::LockUpdate::~LockUpdate ()
|
MessagesDialog::LockUpdate::~LockUpdate ()
|
||||||
{
|
{
|
||||||
|
#ifdef TODO
|
||||||
if(--m_pDialog->lockUpdate < 0)
|
if(--m_pDialog->lockUpdate < 0)
|
||||||
m_pDialog->lockUpdate = 0;
|
m_pDialog->lockUpdate = 0;
|
||||||
|
|
||||||
if (m_bUpdate && m_pDialog->lockUpdate == 0) {
|
if (m_bUpdate && m_pDialog->lockUpdate == 0) {
|
||||||
m_pDialog->insertMessages();
|
m_pDialog->insertMessages();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesDialog::LockUpdate::setUpdate(bool bUpdate)
|
void MessagesDialog::LockUpdate::setUpdate(bool bUpdate)
|
||||||
@ -120,6 +125,25 @@ void MessagesDialog::LockUpdate::setUpdate(bool bUpdate)
|
|||||||
m_bUpdate = bUpdate;
|
m_bUpdate = bUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MessageSortFilterProxyModel: public QSortFilterProxyModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MessageSortFilterProxyModel(const QHeaderView *header,QObject *parent = NULL): QSortFilterProxyModel(parent),m_header(header) {}
|
||||||
|
|
||||||
|
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override
|
||||||
|
{
|
||||||
|
return left.data(RsMessageModel::SortRole) < right.data(RsMessageModel::SortRole) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
|
||||||
|
{
|
||||||
|
return sourceModel()->index(source_row,0,source_parent).data(RsMessageModel::FilterRole).toString() == RsMessageModel::FilterString ;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const QHeaderView *m_header ;
|
||||||
|
};
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
MessagesDialog::MessagesDialog(QWidget *parent)
|
MessagesDialog::MessagesDialog(QWidget *parent)
|
||||||
: MainPage(parent)
|
: MainPage(parent)
|
||||||
@ -165,6 +189,22 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
|||||||
|
|
||||||
mCurrMsgId = "";
|
mCurrMsgId = "";
|
||||||
|
|
||||||
|
mMessageModel = new RsMessageModel(this);
|
||||||
|
mMessageProxyModel = new MessageSortFilterProxyModel(ui.messageTreeWidget->header(),this);
|
||||||
|
mMessageProxyModel->setSourceModel(mMessageModel);
|
||||||
|
mMessageProxyModel->setSortRole(RsMessageModel::SortRole);
|
||||||
|
ui.messageTreeWidget->setModel(mMessageProxyModel);
|
||||||
|
|
||||||
|
mMessageProxyModel->setFilterRole(RsMessageModel::FilterRole);
|
||||||
|
mMessageProxyModel->setFilterRegExp(QRegExp(QString(RsMessageModel::FilterString))) ;
|
||||||
|
|
||||||
|
ui.messageTreeWidget->setSortingEnabled(true);
|
||||||
|
|
||||||
|
//ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_DISTRIBUTION,new DistributionItemDelegate()) ;
|
||||||
|
ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_AUTHOR,new GxsIdTreeItemDelegate()) ;
|
||||||
|
//ui.messageTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_READ,new ReadStatusItemDelegate()) ;
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
// Set the QStandardItemModel
|
// Set the QStandardItemModel
|
||||||
ui.messageTreeWidget->setColumnCount(COLUMN_COUNT);
|
ui.messageTreeWidget->setColumnCount(COLUMN_COUNT);
|
||||||
QTreeWidgetItem *headerItem = ui.messageTreeWidget->headerItem();
|
QTreeWidgetItem *headerItem = ui.messageTreeWidget->headerItem();
|
||||||
@ -190,6 +230,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
|||||||
headerItem->setToolTip(COLUMN_DATE, tr("Click to sort by date"));
|
headerItem->setToolTip(COLUMN_DATE, tr("Click to sort by date"));
|
||||||
headerItem->setToolTip(COLUMN_TAGS, tr("Click to sort by tags"));
|
headerItem->setToolTip(COLUMN_TAGS, tr("Click to sort by tags"));
|
||||||
headerItem->setToolTip(COLUMN_STAR, tr("Click to sort by star"));
|
headerItem->setToolTip(COLUMN_STAR, tr("Click to sort by star"));
|
||||||
|
#endif
|
||||||
|
|
||||||
mMessageCompareRole = new RSTreeWidgetItemCompareRole;
|
mMessageCompareRole = new RSTreeWidgetItemCompareRole;
|
||||||
mMessageCompareRole->setRole(COLUMN_SUBJECT, ROLE_SORT);
|
mMessageCompareRole->setRole(COLUMN_SUBJECT, ROLE_SORT);
|
||||||
@ -287,9 +328,11 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
|||||||
|
|
||||||
// create timer for navigation
|
// create timer for navigation
|
||||||
timer = new RsProtectedTimer(this);
|
timer = new RsProtectedTimer(this);
|
||||||
|
#ifdef TODO
|
||||||
timer->setInterval(300);
|
timer->setInterval(300);
|
||||||
timer->setSingleShot(true);
|
timer->setSingleShot(true);
|
||||||
connect(timer, SIGNAL(timeout()), this, SLOT(updateCurrentMessage()));
|
connect(timer, SIGNAL(timeout()), this, SLOT(updateCurrentMessage()));
|
||||||
|
#endif
|
||||||
|
|
||||||
ui.messageTreeWidget->installEventFilter(this);
|
ui.messageTreeWidget->installEventFilter(this);
|
||||||
|
|
||||||
@ -380,6 +423,7 @@ void MessagesDialog::processSettings(bool load)
|
|||||||
|
|
||||||
bool MessagesDialog::eventFilter(QObject *obj, QEvent *event)
|
bool MessagesDialog::eventFilter(QObject *obj, QEvent *event)
|
||||||
{
|
{
|
||||||
|
#ifdef TODO
|
||||||
if (obj == ui.messageTreeWidget) {
|
if (obj == ui.messageTreeWidget) {
|
||||||
if (event->type() == QEvent::KeyPress) {
|
if (event->type() == QEvent::KeyPress) {
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
||||||
@ -390,12 +434,14 @@ bool MessagesDialog::eventFilter(QObject *obj, QEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// pass the event on to the parent class
|
// pass the event on to the parent class
|
||||||
return MainPage::eventFilter(obj, event);
|
return MainPage::eventFilter(obj, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesDialog::changeEvent(QEvent *e)
|
void MessagesDialog::changeEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
|
#ifdef TODO
|
||||||
QWidget::changeEvent(e);
|
QWidget::changeEvent(e);
|
||||||
switch (e->type()) {
|
switch (e->type()) {
|
||||||
case QEvent::StyleChange:
|
case QEvent::StyleChange:
|
||||||
@ -405,6 +451,7 @@ void MessagesDialog::changeEvent(QEvent *e)
|
|||||||
// remove compiler warnings
|
// remove compiler warnings
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesDialog::fillQuickView()
|
void MessagesDialog::fillQuickView()
|
||||||
@ -486,17 +533,32 @@ void MessagesDialog::fillQuickView()
|
|||||||
// else
|
// else
|
||||||
// MainPage::keyPressEvent(e) ;
|
// MainPage::keyPressEvent(e) ;
|
||||||
//}
|
//}
|
||||||
|
int MessagesDialog::getSelectedMessages(QList<QString>& mid)
|
||||||
|
{
|
||||||
|
//To check if the selection has more than one row.
|
||||||
|
|
||||||
|
mid.clear();
|
||||||
|
QModelIndexList qmil = ui.messageTreeWidget->selectionModel()->selectedRows();
|
||||||
|
|
||||||
|
foreach(const QModelIndex& m, qmil)
|
||||||
|
mid.push_back(m.sibling(m.row(),COLUMN_DATA).data(ROLE_MSGID).toString()) ;
|
||||||
|
|
||||||
|
return mid.size();
|
||||||
|
}
|
||||||
|
|
||||||
int MessagesDialog::getSelectedMsgCount (QList<QTreeWidgetItem*> *items, QList<QTreeWidgetItem*> *itemsRead, QList<QTreeWidgetItem*> *itemsUnread, QList<QTreeWidgetItem*> *itemsStar)
|
int MessagesDialog::getSelectedMsgCount (QList<QTreeWidgetItem*> *items, QList<QTreeWidgetItem*> *itemsRead, QList<QTreeWidgetItem*> *itemsUnread, QList<QTreeWidgetItem*> *itemsStar)
|
||||||
{
|
{
|
||||||
|
#ifdef TODO
|
||||||
if (items) items->clear();
|
if (items) items->clear();
|
||||||
if (itemsRead) itemsRead->clear();
|
if (itemsRead) itemsRead->clear();
|
||||||
if (itemsUnread) itemsUnread->clear();
|
if (itemsUnread) itemsUnread->clear();
|
||||||
if (itemsStar) itemsStar->clear();
|
if (itemsStar) itemsStar->clear();
|
||||||
|
|
||||||
//To check if the selection has more than one row.
|
//To check if the selection has more than one row.
|
||||||
QList<QTreeWidgetItem*> selectedItems = ui.messageTreeWidget->selectedItems();
|
QList<QString> selectedMessages;
|
||||||
foreach (QTreeWidgetItem *item, selectedItems)
|
getSelectedMessages(selectedMessages);
|
||||||
|
|
||||||
|
foreach (const QString&, selectedMessages)
|
||||||
{
|
{
|
||||||
if (items || itemsRead || itemsUnread || itemsStar) {
|
if (items || itemsRead || itemsUnread || itemsStar) {
|
||||||
if (items) items->append(item);
|
if (items) items->append(item);
|
||||||
@ -516,6 +578,8 @@ int MessagesDialog::getSelectedMsgCount (QList<QTreeWidgetItem*> *items, QList<Q
|
|||||||
}
|
}
|
||||||
|
|
||||||
return selectedItems.size();
|
return selectedItems.size();
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessagesDialog::isMessageRead(QTreeWidgetItem *item)
|
bool MessagesDialog::isMessageRead(QTreeWidgetItem *item)
|
||||||
@ -759,7 +823,7 @@ void MessagesDialog::editmessage()
|
|||||||
/* window will destroy itself! */
|
/* window will destroy itself! */
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesDialog::changeBox(int)
|
void MessagesDialog::changeBox(int box_row)
|
||||||
{
|
{
|
||||||
if (inChange) {
|
if (inChange) {
|
||||||
// already in change method
|
// already in change method
|
||||||
@ -768,19 +832,31 @@ void MessagesDialog::changeBox(int)
|
|||||||
|
|
||||||
inChange = true;
|
inChange = true;
|
||||||
|
|
||||||
ui.messageTreeWidget->clear();
|
// ui.messageTreeWidget->clear();
|
||||||
|
|
||||||
ui.quickViewWidget->setCurrentItem(NULL);
|
ui.quickViewWidget->setCurrentItem(NULL);
|
||||||
listMode = LIST_BOX;
|
listMode = LIST_BOX;
|
||||||
|
|
||||||
insertMessages();
|
// insertMessages();
|
||||||
insertMsgTxtAndFiles(ui.messageTreeWidget->currentItem());
|
// insertMsgTxtAndFiles(ui.messageTreeWidget->currentItem());
|
||||||
|
|
||||||
|
switch(box_row)
|
||||||
|
{
|
||||||
|
case 0: mMessageModel->setCurrentBox(RsMessageModel::BOX_INBOX ); break;
|
||||||
|
case 1: mMessageModel->setCurrentBox(RsMessageModel::BOX_OUTBOX); break;
|
||||||
|
case 2: mMessageModel->setCurrentBox(RsMessageModel::BOX_DRAFTS); break;
|
||||||
|
case 3: mMessageModel->setCurrentBox(RsMessageModel::BOX_SENT ); break;
|
||||||
|
case 4: mMessageModel->setCurrentBox(RsMessageModel::BOX_TRASH ); break;
|
||||||
|
default:
|
||||||
|
mMessageModel->setCurrentBox(RsMessageModel::BOX_NONE); break;
|
||||||
|
}
|
||||||
inChange = false;
|
inChange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesDialog::changeQuickView(int newrow)
|
void MessagesDialog::changeQuickView(int newrow)
|
||||||
{
|
{
|
||||||
|
#warning Missing code here!
|
||||||
|
#ifdef TODO
|
||||||
Q_UNUSED(newrow);
|
Q_UNUSED(newrow);
|
||||||
|
|
||||||
if (inChange) {
|
if (inChange) {
|
||||||
@ -799,16 +875,20 @@ void MessagesDialog::changeQuickView(int newrow)
|
|||||||
insertMsgTxtAndFiles(ui.messageTreeWidget->currentItem());
|
insertMsgTxtAndFiles(ui.messageTreeWidget->currentItem());
|
||||||
|
|
||||||
inChange = false;
|
inChange = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesDialog::messagesTagsChanged()
|
void MessagesDialog::messagesTagsChanged()
|
||||||
{
|
{
|
||||||
|
#ifdef TODO
|
||||||
if (lockUpdate) {
|
if (lockUpdate) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fillQuickView();
|
fillQuickView();
|
||||||
insertMessages();
|
insertMessages();
|
||||||
|
#endif
|
||||||
|
#warning Missing code here!
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InitIconAndFont(QTreeWidgetItem *item)
|
static void InitIconAndFont(QTreeWidgetItem *item)
|
||||||
@ -877,6 +957,7 @@ static void InitIconAndFont(QTreeWidgetItem *item)
|
|||||||
item->setData(COLUMN_DATA, ROLE_UNREAD, isNew);
|
item->setData(COLUMN_DATA, ROLE_UNREAD, isNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
void MessagesDialog::insertMessages()
|
void MessagesDialog::insertMessages()
|
||||||
{
|
{
|
||||||
if (lockUpdate) {
|
if (lockUpdate) {
|
||||||
@ -1336,10 +1417,12 @@ void MessagesDialog::insertMessages()
|
|||||||
|
|
||||||
updateMessageSummaryList();
|
updateMessageSummaryList();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// current row in messageTreeWidget has changed
|
// current row in messageTreeWidget has changed
|
||||||
void MessagesDialog::currentItemChanged(QTreeWidgetItem *item)
|
void MessagesDialog::currentItemChanged(QTreeWidgetItem *item)
|
||||||
{
|
{
|
||||||
|
#ifdef TODO
|
||||||
timer->stop();
|
timer->stop();
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
@ -1350,6 +1433,7 @@ void MessagesDialog::currentItemChanged(QTreeWidgetItem *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateInterface();
|
updateInterface();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// click in messageTreeWidget
|
// click in messageTreeWidget
|
||||||
@ -1377,9 +1461,10 @@ void MessagesDialog::clicked(QTreeWidgetItem *item, int column)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef TODO
|
||||||
timer->stop();
|
timer->stop();
|
||||||
timerIndex = ui.messageTreeWidget->indexOfTopLevelItem(item);
|
timerIndex = ui.messageTreeWidget->indexOfTopLevelItem(item);
|
||||||
|
#endif
|
||||||
|
|
||||||
// show current message directly
|
// show current message directly
|
||||||
updateCurrentMessage();
|
updateCurrentMessage();
|
||||||
@ -1421,8 +1506,10 @@ void MessagesDialog::doubleClicked(QTreeWidgetItem *item, int column)
|
|||||||
// show current message directly
|
// show current message directly
|
||||||
void MessagesDialog::updateCurrentMessage()
|
void MessagesDialog::updateCurrentMessage()
|
||||||
{
|
{
|
||||||
|
#ifdef TODO
|
||||||
timer->stop();
|
timer->stop();
|
||||||
insertMsgTxtAndFiles(ui.messageTreeWidget->topLevelItem(timerIndex));
|
insertMsgTxtAndFiles(ui.messageTreeWidget->topLevelItem(timerIndex));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesDialog::setMsgAsReadUnread(const QList<QTreeWidgetItem*> &items, bool read)
|
void MessagesDialog::setMsgAsReadUnread(const QList<QTreeWidgetItem*> &items, bool read)
|
||||||
@ -1573,10 +1660,11 @@ void MessagesDialog::insertMsgTxtAndFiles(QTreeWidgetItem *item, bool bSetToRead
|
|||||||
|
|
||||||
bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid)
|
bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = ui.messageTreeWidget->currentItem();
|
QModelIndex indx = ui.messageTreeWidget->currentIndex();
|
||||||
|
|
||||||
|
#ifdef TODO
|
||||||
/* get its Ids */
|
/* get its Ids */
|
||||||
if (!item)
|
if (!indx.isValid())
|
||||||
{
|
{
|
||||||
//If no message is selected. assume first message is selected.
|
//If no message is selected. assume first message is selected.
|
||||||
if (ui.messageTreeWidget->topLevelItemCount() == 0)
|
if (ui.messageTreeWidget->topLevelItemCount() == 0)
|
||||||
@ -1588,8 +1676,13 @@ bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid)
|
|||||||
if (!item) {
|
if (!item) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cid = item->data(COLUMN_DATA, ROLE_SRCID).toString().toStdString();
|
#endif
|
||||||
mid = item->data(COLUMN_DATA, ROLE_MSGID).toString().toStdString();
|
if(!indx.isValid())
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
cid = indx.sibling(indx.row(),COLUMN_DATA).data(ROLE_SRCID).toString().toStdString();
|
||||||
|
mid = indx.sibling(indx.row(),COLUMN_DATA).data(ROLE_MSGID).toString().toStdString();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1597,7 +1690,8 @@ void MessagesDialog::removemessage()
|
|||||||
{
|
{
|
||||||
LockUpdate Lock (this, true);
|
LockUpdate Lock (this, true);
|
||||||
|
|
||||||
QList<QTreeWidgetItem*> selectedItems = ui.messageTreeWidget->selectedItems();
|
QList<QString> selectedMessages ;
|
||||||
|
getSelectedMessages(selectedMessages);
|
||||||
|
|
||||||
bool doDelete = false;
|
bool doDelete = false;
|
||||||
int listrow = ui.listWidget->currentRow();
|
int listrow = ui.listWidget->currentRow();
|
||||||
@ -1609,16 +1703,11 @@ void MessagesDialog::removemessage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (QTreeWidgetItem *item, selectedItems) {
|
foreach (const QString& m, selectedMessages) {
|
||||||
QString mid = item->data(COLUMN_DATA, ROLE_MSGID).toString();
|
|
||||||
|
|
||||||
// close tab showing this message
|
|
||||||
// closeTab(mid.toStdString());
|
|
||||||
|
|
||||||
if (doDelete) {
|
if (doDelete) {
|
||||||
rsMail->MessageDelete(mid.toStdString());
|
rsMail->MessageDelete(m.toStdString());
|
||||||
} else {
|
} else {
|
||||||
rsMail->MessageToTrash(mid.toStdString(), true);
|
rsMail->MessageToTrash(m.toStdString(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1658,7 +1747,9 @@ void MessagesDialog::buttonStyle()
|
|||||||
|
|
||||||
void MessagesDialog::filterChanged(const QString& text)
|
void MessagesDialog::filterChanged(const QString& text)
|
||||||
{
|
{
|
||||||
|
#ifdef TODO
|
||||||
ui.messageTreeWidget->filterItems(ui.filterLineEdit->currentFilter(), text);
|
ui.messageTreeWidget->filterItems(ui.filterLineEdit->currentFilter(), text);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesDialog::filterColumnChanged(int column)
|
void MessagesDialog::filterColumnChanged(int column)
|
||||||
@ -1669,9 +1760,11 @@ void MessagesDialog::filterColumnChanged(int column)
|
|||||||
|
|
||||||
if (column == COLUMN_CONTENT) {
|
if (column == COLUMN_CONTENT) {
|
||||||
// need content ... refill
|
// need content ... refill
|
||||||
insertMessages();
|
//insertMessages();
|
||||||
}
|
}
|
||||||
|
#ifdef TODO
|
||||||
ui.messageTreeWidget->filterItems(column, ui.filterLineEdit->text());
|
ui.messageTreeWidget->filterItems(column, ui.filterLineEdit->text());
|
||||||
|
#endif
|
||||||
|
|
||||||
// save index
|
// save index
|
||||||
Settings->setValueToGroup("MessageDialog", "filterColumn", column);
|
Settings->setValueToGroup("MessageDialog", "filterColumn", column);
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
class RSTreeWidgetItemCompareRole;
|
class RSTreeWidgetItemCompareRole;
|
||||||
class MessageWidget;
|
class MessageWidget;
|
||||||
|
class QTreeWidgetItem;
|
||||||
|
class RsMessageModel;
|
||||||
|
|
||||||
class MessagesDialog : public MainPage
|
class MessagesDialog : public MainPage
|
||||||
{
|
{
|
||||||
@ -59,9 +61,10 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *ev);
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
|
int getSelectedMessages(QList<QString>& mid);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void insertMessages();
|
//void insertMessages();
|
||||||
void messagesTagsChanged();
|
void messagesTagsChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -153,6 +156,8 @@ private:
|
|||||||
|
|
||||||
RSTreeWidgetItemCompareRole *mMessageCompareRole;
|
RSTreeWidgetItemCompareRole *mMessageCompareRole;
|
||||||
MessageWidget *msgWidget;
|
MessageWidget *msgWidget;
|
||||||
|
RsMessageModel *mMessageModel;
|
||||||
|
QSortFilterProxyModel *mMessageProxyModel;
|
||||||
|
|
||||||
/* Color definitions (for standard see qss.default) */
|
/* Color definitions (for standard see qss.default) */
|
||||||
QColor mTextColorInbox;
|
QColor mTextColorInbox;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>775</width>
|
<width>842</width>
|
||||||
<height>485</height>
|
<height>485</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -726,7 +726,7 @@
|
|||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="RSTreeWidget" name="messageTreeWidget">
|
<widget class="QTreeView" name="messageTreeWidget">
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -745,11 +745,6 @@
|
|||||||
<property name="expandsOnDoubleClick">
|
<property name="expandsOnDoubleClick">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">1</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<layout class="QGridLayout" name="msgLayout"/>
|
<layout class="QGridLayout" name="msgLayout"/>
|
||||||
@ -843,11 +838,6 @@
|
|||||||
<extends>QLineEdit</extends>
|
<extends>QLineEdit</extends>
|
||||||
<header location="global">gui/common/LineEditClear.h</header>
|
<header location="global">gui/common/LineEditClear.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>RSTreeWidget</class>
|
|
||||||
<extends>QTreeWidget</extends>
|
|
||||||
<header>gui/common/RSTreeWidget.h</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>RSTabWidget</class>
|
<class>RSTabWidget</class>
|
||||||
<extends>QTabWidget</extends>
|
<extends>QTabWidget</extends>
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#ifndef _GXS_ID_TREEWIDGETITEM_H
|
#ifndef _GXS_ID_TREEWIDGETITEM_H
|
||||||
#define _GXS_ID_TREEWIDGETITEM_H
|
#define _GXS_ID_TREEWIDGETITEM_H
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QApplication>
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
|
|
||||||
#include "gui/common/RSTreeWidgetItem.h"
|
#include "gui/common/RSTreeWidgetItem.h"
|
||||||
@ -69,4 +71,83 @@ private:
|
|||||||
RsGxsImage mAvatar;
|
RsGxsImage mAvatar;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This class is responsible of rendering authors of type RsGxsId in tree views. Used in forums, messages, etc.
|
||||||
|
|
||||||
|
class GxsIdTreeItemDelegate: public QStyledItemDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GxsIdTreeItemDelegate() {}
|
||||||
|
|
||||||
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
|
||||||
|
{
|
||||||
|
QStyleOptionViewItemV4 opt = option;
|
||||||
|
initStyleOption(&opt, index);
|
||||||
|
|
||||||
|
// disable default icon
|
||||||
|
opt.icon = QIcon();
|
||||||
|
const QRect r = option.rect;
|
||||||
|
|
||||||
|
RsGxsId id(index.data(Qt::UserRole).toString().toStdString());
|
||||||
|
QString str;
|
||||||
|
QList<QIcon> icons;
|
||||||
|
QString comment;
|
||||||
|
|
||||||
|
QFontMetricsF fm(option.font);
|
||||||
|
float f = fm.height();
|
||||||
|
|
||||||
|
QIcon icon ;
|
||||||
|
|
||||||
|
if(!GxsIdDetails::MakeIdDesc(id, true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR))
|
||||||
|
icon = GxsIdDetails::getLoadingIcon(id);
|
||||||
|
else
|
||||||
|
icon = *icons.begin();
|
||||||
|
|
||||||
|
QPixmap pix = icon.pixmap(r.size());
|
||||||
|
|
||||||
|
return QSize(1.2*(pix.width() + fm.width(str)),std::max(1.1*pix.height(),1.4*fm.height()));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex& index) const override
|
||||||
|
{
|
||||||
|
if(!index.isValid())
|
||||||
|
{
|
||||||
|
std::cerr << "(EE) attempt to draw an invalid index." << std::endl;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStyleOptionViewItemV4 opt = option;
|
||||||
|
initStyleOption(&opt, index);
|
||||||
|
|
||||||
|
// disable default icon
|
||||||
|
opt.icon = QIcon();
|
||||||
|
// draw default item
|
||||||
|
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, 0);
|
||||||
|
|
||||||
|
const QRect r = option.rect;
|
||||||
|
|
||||||
|
RsGxsId id(index.data(Qt::UserRole).toString().toStdString());
|
||||||
|
QString str;
|
||||||
|
QList<QIcon> icons;
|
||||||
|
QString comment;
|
||||||
|
|
||||||
|
QFontMetricsF fm(painter->font());
|
||||||
|
float f = fm.height();
|
||||||
|
|
||||||
|
QIcon icon ;
|
||||||
|
|
||||||
|
if(!GxsIdDetails::MakeIdDesc(id, true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR))
|
||||||
|
icon = GxsIdDetails::getLoadingIcon(id);
|
||||||
|
else
|
||||||
|
icon = *icons.begin();
|
||||||
|
|
||||||
|
QPixmap pix = icon.pixmap(r.size());
|
||||||
|
const QPoint p = QPoint(r.height()/2.0, (r.height() - pix.height())/2);
|
||||||
|
|
||||||
|
// draw pixmap at center of item
|
||||||
|
painter->drawPixmap(r.topLeft() + p, pix);
|
||||||
|
painter->drawText(r.topLeft() + QPoint(r.height()+ f/2.0 + f/2.0,f*1.0), str);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -71,6 +71,15 @@ public:
|
|||||||
explicit RsMessageModel(QObject *parent = NULL);
|
explicit RsMessageModel(QObject *parent = NULL);
|
||||||
~RsMessageModel(){}
|
~RsMessageModel(){}
|
||||||
|
|
||||||
|
enum BoxName {
|
||||||
|
BOX_NONE = 0x00,
|
||||||
|
BOX_INBOX = 0x01,
|
||||||
|
BOX_OUTBOX = 0x02,
|
||||||
|
BOX_DRAFTS = 0x03,
|
||||||
|
BOX_SENT = 0x04,
|
||||||
|
BOX_TRASH = 0x05
|
||||||
|
};
|
||||||
|
|
||||||
enum Columns {
|
enum Columns {
|
||||||
COLUMN_THREAD_STAR =0x00,
|
COLUMN_THREAD_STAR =0x00,
|
||||||
COLUMN_THREAD_ATTACHMENT =0x01,
|
COLUMN_THREAD_ATTACHMENT =0x01,
|
||||||
@ -96,6 +105,7 @@ public:
|
|||||||
|
|
||||||
// This method will asynchroneously update the data
|
// This method will asynchroneously update the data
|
||||||
|
|
||||||
|
void setCurrentBox(BoxName bn) {}
|
||||||
void updateMessages();
|
void updateMessages();
|
||||||
const RsMessageId& currentMessageId() const;
|
const RsMessageId& currentMessageId() const;
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ MessageWidget *MessageWidget::openMsg(const std::string &msgId, bool window)
|
|||||||
msgWidget->isWindow = window;
|
msgWidget->isWindow = window;
|
||||||
msgWidget->fill(msgId);
|
msgWidget->fill(msgId);
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent->addWidget(msgWidget);
|
parent->addWidget(msgWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user