tree widget converted to tree view in MessageDiwalogue and other fixes

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2300 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
nishant 2010-02-13 18:49:56 +00:00
parent a3a66e8dc5
commit 5e9e342bc9
4 changed files with 520 additions and 182 deletions

View File

@ -28,13 +28,12 @@
#include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsmsgs.h"
#include "rsiface/rsfiles.h"
#include <sstream>
#include <list>
#include <iostream>
#include <string>
#include <QtGui>
#include <QContextMenuEvent>
#include <QMenu>
#include <QCursor>
@ -45,7 +44,8 @@
#include <QPrinter>
#include <QDateTime>
#include <QHeaderView>
#include <QModelIndex>
#include <QStandardItemModel>
/* Images for context menu icons */
#define IMAGE_MESSAGE ":/images/folder-draft.png"
@ -66,9 +66,9 @@ MessagesDialog::MessagesDialog(QWidget *parent)
/* Create RshareSettings object */
_settings = new RshareSettings();
connect( ui.msgWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.messagestreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.msgList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.msgWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem *,QTreeWidgetItem * ) ), this, SLOT( updateCurrentMessage( QTreeWidgetItem *, QTreeWidgetItem *) ) );
connect( ui.messagestreeView, SIGNAL(clicked ( const QModelIndex &) ) , this, SLOT( updateCurrentMessage( const QModelIndex & ) ) );
connect( ui.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) );
connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));
@ -90,17 +90,43 @@ MessagesDialog::MessagesDialog(QWidget *parent)
connect(ui.actionTextUnderIcon, SIGNAL(triggered()), this, SLOT(buttonstextundericon()));
connect(ui.actionSave_as, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(filterRegExpChanged()));
connect(ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(filterColumnChanged()));
mCurrCertId = "";
mCurrMsgId = "";
// Set the QStandardItemModel
MessagesModel = new QStandardItemModel(0, 6);
MessagesModel->setHeaderData(0, Qt::Horizontal, tr("#"));
MessagesModel->setHeaderData(1, Qt::Horizontal, tr("Subject"));
MessagesModel->setHeaderData(2, Qt::Horizontal, tr("From"));
MessagesModel->setHeaderData(3, Qt::Horizontal, tr("Date"));
MessagesModel->setHeaderData(4, Qt::Horizontal, tr("SRCID"));
MessagesModel->setHeaderData(5, Qt::Horizontal, tr("MSGID"));
proxyModel = new QSortFilterProxyModel(this);
proxyModel->setDynamicSortFilter(true);
proxyModel->setSourceModel(MessagesModel);
ui.messagestreeView->setModel(proxyModel);
ui.messagestreeView->setSelectionBehavior(QTreeView::SelectRows);
ui.messagestreeView->setRootIsDecorated(false);
ui.messagestreeView->setSortingEnabled(true);
ui.messagestreeView->sortByColumn(3, Qt::DescendingOrder);
/* hide the Tree +/- */
ui.msgList->setRootIsDecorated( false );
ui.msgList->setSelectionMode( QAbstractItemView::ExtendedSelection );
ui.msgWidget->setRootIsDecorated( false );
/* Set header resize modes and initial section sizes */
QHeaderView * msgwheader = ui.msgWidget->header () ;
QHeaderView * msgwheader = ui.messagestreeView->header () ;
msgwheader->setResizeMode (0, QHeaderView::Custom);
msgwheader->setResizeMode (3, QHeaderView::Interactive);
@ -135,15 +161,13 @@ MessagesDialog::MessagesDialog(QWidget *parent)
viewmenu->addAction(ui.actionTextUnderIcon);
ui.viewtoolButton->setMenu(viewmenu);
ui.msgWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
ui.msgWidget->sortItems( 3, Qt::DescendingOrder );
loadToolButtonsettings();
mFont = QFont("Arial", 10, QFont::Bold);
ui.subjectText->setFont(mFont);
//sertting default filter by column as subject
proxyModel->setFilterKeyColumn(ui.filterColumnComboBox->currentIndex());
/* Hide platform specific features */
#ifdef Q_WS_WIN
@ -163,7 +187,6 @@ void MessagesDialog::keyPressEvent(QKeyEvent *e)
void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
@ -172,8 +195,20 @@ void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point )
newmsgAct = new QAction(QIcon(IMAGE_MESSAGE), tr( "New Message" ), this );
connect( newmsgAct , SIGNAL( triggered() ), this, SLOT( newmessage() ) );
int nn = ui.msgWidget->selectedItems().size() ;
//To check if the selection has more than one row.
QList<QModelIndex> selectedIndexList = ui.messagestreeView->selectionModel() -> selectedIndexes ();
QList<int> rowList;
for(QList<QModelIndex>::iterator it = selectedIndexList.begin(); it != selectedIndexList.end(); it++)
{
int row = it->row();
if (rowList.contains(row) == false)
{
rowList.append(row);
}
}
int nn = rowList.size();
if(nn > 1)
{
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Messages" ), this );
@ -528,34 +563,39 @@ void MessagesDialog::getallrecommended()
void MessagesDialog::changeBox(int)
{
insertMessages(); // show current msg list
insertMessages();
insertMsgTxtAndFiles();
}
void MessagesDialog::insertMessages()
{
std::cerr <<"MessagesDialog::insertMessages called";
fflush(0);
int c;
c = MessagesModel->rowCount();
MessagesModel->removeRows(0,c);
//ui.messagestreeView->showColumn(4);
//ui.messagestreeView->showColumn(5);
std::list<MsgInfoSummary> msgList;
std::list<MsgInfoSummary>::const_iterator it;
rsMsgs -> getMessageSummaries(msgList);
/* get a link to the table */
QTreeWidget *msgWidget = ui.msgWidget;
/* get the MsgId of the current one ... */
std::string cid;
std::string mid;
bool oldSelected = getCurrentMsg(cid, mid);
QTreeWidgetItem *newSelected = NULL;
QStandardItem *newSelected = NULL;
/* remove old items ??? */
int listrow = ui.listWidget -> currentRow();
//std::cerr << "MessagesDialog::insertMessages()" << std::endl;
//std::cerr << "Current Row: " << listrow << std::endl;
std::cerr << "MessagesDialog::insertMessages()" << std::endl;
std::cerr << "Current Row: " << listrow << std::endl;
fflush(0);
/* check the mode we are in */
unsigned int msgbox = 0;
switch(listrow)
@ -576,7 +616,7 @@ void MessagesDialog::insertMessages()
break;
}
QList<QTreeWidgetItem *> items;
//std::list<std::string>::iterator it;
for(it = msgList.begin(); it != msgList.end(); it++)
{
/* check the message flags, to decide which
@ -605,7 +645,15 @@ void MessagesDialog::insertMessages()
}
/* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
//QModelIndex index;
QStandardItem *item0 = new QStandardItem();
QStandardItem *item1 = new QStandardItem();
QStandardItem *item2 = new QStandardItem();
QStandardItem *item3 = new QStandardItem();
QStandardItem *item4 = new QStandardItem();
QStandardItem *item5 = new QStandardItem();
/* So Text should be:
* (1) Msg / Broadcast
@ -623,122 +671,165 @@ void MessagesDialog::insertMessages()
QDateTime qtime;
qtime.setTime_t(it->ts);
QString timestamp = qtime.toString("dd.MM.yyyy hh:mm:ss");
item -> setText(3, timestamp);
item3 -> setText(timestamp);
//index = MessagesModel->index(c, 3);
//MessagesModel->setData(index, timestamp);
}
// From ....
{
item -> setText(2, QString::fromStdString(rsPeers->getPeerName(it->srcId)));
item2 -> setText(QString::fromStdString(rsPeers->getPeerName(it->srcId)));
//index = MessagesModel->index(c, 2);
//MessagesModel->setData(index, QString::fromStdString(rsPeers->getPeerName(it->srcId)));
}
// Subject
item -> setText(1, QString::fromStdWString(it->title));
item1 -> setText(QString::fromStdWString(it->title));
if ((it -> msgflags & RS_MSG_NEW) == RS_MSG_NEW)
{
QFont qf = item1->font();
qf.setBold(true);
item1->setFont(qf);
}
//index = MessagesModel->index(c, 1);
//MessagesModel->setData(index, QString::fromStdWString(it->title));
// Change Message icon when Subject is Re: or Fwd:
QString text = QString::fromStdWString(it->title);
if (text.startsWith("Re:", Qt::CaseInsensitive))
{
item -> setIcon(1, (QIcon(":/images/message-mail-replied-read.png")));
item1 -> setIcon(QIcon(":/images/message-mail-replied-read.png"));
}
else if (text.startsWith("Fwd:", Qt::CaseInsensitive))
{
item -> setIcon(1, (QIcon(":/images/message-mail-forwarded-read.png")));
item1 -> setIcon(QIcon(":/images/message-mail-forwarded-read.png"));
}
else
{
item -> setIcon(1, (QIcon(":/images/message-mail-read.png")));
item1 -> setIcon(QIcon(":/images/message-mail-read.png"));
}
if (it -> msgflags & RS_MSG_NEW)
{
for(int i = 0; i < 10; i++)
{
QFont qf = item->font(i);
/*QFont qf = item->font(i);
qf.setBold(true);
item->setFont(i, qf);
item->setFont(i, qf);*/
}
QString text = QString::fromStdWString(it->title);
if (text.startsWith("Re:", Qt::CaseInsensitive))
{
item -> setIcon(1, (QIcon(":/images/message-mail-replied.png")));
}
else if (text.startsWith("Fwd:", Qt::CaseInsensitive))
{
item -> setIcon(1, (QIcon(":/images/message-mail-forwarded.png")));
}
else
{
item -> setIcon(1, (QIcon(":/images/message-mail.png")));
}
if (text.startsWith("Re:", Qt::CaseInsensitive))
{
item1 -> setIcon(QIcon(":/images/message-mail-replied.png"));
}
else if (text.startsWith("Fwd:", Qt::CaseInsensitive))
{
item1 -> setIcon(QIcon(":/images/message-mail-forwarded.png"));
}
else
{
item1 -> setIcon(QIcon(":/images/message-mail.png"));
}
}
// No of Files.
{
std::ostringstream out;
out << it -> count;
item -> setText(0, QString::fromStdString(out.str()));
item -> setTextAlignment( 0, Qt::AlignCenter );
item0 -> setText(QString::fromStdString(out.str()));
//item -> setTextAlignment( 0, Qt::AlignCenter );
}
item -> setText(4, QString::fromStdString(it->srcId));
item -> setText(5, QString::fromStdString(it->msgId));
item4 -> setText(QString::fromStdString(it->srcId));
item5 -> setText(QString::fromStdString(it->msgId));
if ((oldSelected) && (mid == it->msgId))
{
newSelected = item;
//newSelected = item;
}
/* add to the list */
items.append(item);
QList<QStandardItem *> itemList;
itemList.append(item0);
itemList.append(item1);
itemList.append(item2);
itemList.append(item3);
itemList.append(item4);
itemList.append(item5);
MessagesModel->appendRow(itemList);
}
updateMessageSummaryList();
ui.messagestreeView->hideColumn(4);
ui.messagestreeView->hideColumn(5);
}
/* add the items in! */
msgWidget->clear();
msgWidget->insertTopLevelItems(0, items);
void MessagesDialog::updateCurrentMessage(const QModelIndex &index )
{
insertMsgTxtAndFiles(index);
setMsgAsRead(index);
updateMessageSummaryList();
}
if (newSelected)
void MessagesDialog::setMsgAsRead(const QModelIndex &index)
{
QString text;
QModelIndex currentIndex = proxyModel->mapToSource(index);
if (currentIndex.isValid() == false)
{
msgWidget->setCurrentItem(newSelected);
return;
}
}
void MessagesDialog::updateCurrentMessage( QTreeWidgetItem *item , QTreeWidgetItem * )
{
insertMsgTxtAndFiles();
setMsgAsRead(item) ;
}
void MessagesDialog::setMsgAsRead(QTreeWidgetItem *item)
{
if(item == NULL)
return ;
for(int i = 0; i < 10; i++)
else
{
QFont qf = item->font(i);
qf.setBold(false);
item->setFont(i, qf);
}
for(int i = 0; i < 6; i++)
{
std::string mid(item->text(5).toStdString());
rsMsgs->MessageRead(mid);
QStandardItem* item;
item = MessagesModel->item(currentIndex.row(),i);
QFont qf = item->font();
qf.setBold(false);
item->setFont(qf);
//change the icon to read. this need to be done when user clicks to the new message
if(i == 1)
{
text = item->text();
if (text.startsWith("Re:", Qt::CaseInsensitive))
{
item -> setIcon(QIcon(":/images/message-mail-replied-read.png"));
}
else if (text.startsWith("Fwd:", Qt::CaseInsensitive))
{
item -> setIcon(QIcon(":/images/message-mail-forwarded-read.png"));
}
else
{
item -> setIcon(QIcon(":/images/message-mail-read.png"));
}
}
if(i == 5)
{
std::string mid(item->text().toStdString());
rsMsgs->MessageRead(mid);
}
}
}
}
void MessagesDialog::insertMsgTxtAndFiles()
void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index)
{
/* Locate the current Message */
QTreeWidget *msglist = ui.msgWidget;
std::cerr << "MessagesDialog::insertMsgTxtAndFiles()" << std::endl;
/* get its Ids */
std::string cid;
std::string mid;
QTreeWidgetItem *qtwi = msglist -> currentItem();
if (!qtwi)
QModelIndex currentIndex = proxyModel->mapToSource(Index);
if (currentIndex.isValid() == false)
{
/* blank it */
ui.dateText-> setText("");
@ -754,11 +845,15 @@ void MessagesDialog::insertMsgTxtAndFiles()
}
else
{
cid = qtwi -> text(4).toStdString();
mid = qtwi -> text(5).toStdString();
QStandardItem * item;
item = MessagesModel->item(currentIndex.row(),4);
cid = item->text().toStdString();
fflush(0);
item = MessagesModel->item(currentIndex.row(),5);
mid = item->text().toStdString();
}
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() mid:" << mid << std::endl;
/* Save the Data.... for later */
@ -858,38 +953,54 @@ void MessagesDialog::insertMsgTxtAndFiles()
bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid)
{
/* Locate the current Message */
QTreeWidget *msglist = ui.msgWidget;
//std::cerr << "MessagesDialog::getCurrentMsg()" << std::endl;
QModelIndex currentIndex = ui.messagestreeView->currentIndex();
currentIndex = proxyModel->mapToSource(currentIndex);
int rowSelected = -1;
/* get its Ids */
QTreeWidgetItem *qtwi = msglist -> currentItem();
if (qtwi)
if (currentIndex.isValid() == false)
{
cid = qtwi -> text(4).toStdString();
mid = qtwi -> text(5).toStdString();
return true;
//If no message is selected. assume first message is selected.
if(MessagesModel->rowCount() == 0)
{
return false;
}
else
{
rowSelected = 0;
}
}
else
{
rowSelected = currentIndex.row();
}
return false;
}
QStandardItem *item;
item = MessagesModel->item(rowSelected,4);
cid = item->text().toStdString();
item = MessagesModel->item(rowSelected,5);
mid = item->text().toStdString();
return true;
}
void MessagesDialog::removemessage()
{
QList<QTreeWidgetItem*> list(ui.msgWidget->selectedItems()) ;
QList<QModelIndex> selectedIndexList= ui.messagestreeView->selectionModel() -> selectedIndexes ();
QList<int> rowList;
for(QList<QModelIndex>::iterator it = selectedIndexList.begin(); it != selectedIndexList.end(); it++)
{
int row = it->row();
if (rowList.contains(row) == false)
{
rowList.append(row);
}
}
int maxrow = -1 ;
for(QList<QTreeWidgetItem*>::const_iterator it(list.begin());it!=list.end();++it)
maxrow = std::max(maxrow,ui.msgWidget->indexOfTopLevelItem(*it)) ;
QTreeWidgetItem *next = ui.msgWidget->topLevelItem(maxrow+1) ;
for(QList<QTreeWidgetItem*>::const_iterator it(list.begin());it!=list.end();++it)
rsMsgs->MessageDelete((*it)->text(5).toStdString());
if(next != NULL)
ui.msgWidget->setCurrentItem(next) ;
for(QList<int>::const_iterator it1(rowList.begin());it1!=rowList.end();++it1)
{
rsMsgs->MessageDelete(MessagesModel->item((*it1),5)->text().toStdString());
}
insertMessages();
return;
@ -1119,3 +1230,113 @@ void MessagesDialog::loadToolButtonsettings()
_settings->endGroup();
}
void MessagesDialog::filterRegExpChanged()
{
QRegExp regExp(ui.filterPatternLineEdit->text(), Qt::CaseInsensitive , QRegExp::FixedString);
proxyModel->setFilterRegExp(regExp);
}
void MessagesDialog::filterColumnChanged()
{
proxyModel->setFilterKeyColumn(ui.filterColumnComboBox->currentIndex());
}
void MessagesDialog::updateMessageSummaryList()
{
std::list<MsgInfoSummary> msgList;
std::list<MsgInfoSummary>::const_iterator it;
rsMsgs -> getMessageSummaries(msgList);
int newInboxCount = 0;
int newOutboxCount = 0;
int newDraftCount = 0;
/*calculating the new messages*/
for(it = msgList.begin(); it != msgList.end(); it++)
{
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_INBOX && ((it -> msgflags & RS_MSG_NEW) == RS_MSG_NEW))
{
newInboxCount ++;
}
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX && ((it -> msgflags & RS_MSG_NEW) == RS_MSG_NEW))
{
newOutboxCount ++;
}
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_DRAFTBOX )
{
newDraftCount ++;
}
}
QString textItem;
/*updating the labels in leftcolumn*/
if(newInboxCount != 0)
{
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
QListWidgetItem* item = ui.listWidget->item(0);
textItem = tr("Inbox") + "(" + QString::number(newInboxCount)+")";
item->setText(textItem);
QFont qf = item->font();
qf.setBold(true);
item->setFont(qf);
item->setIcon(QIcon(":/images/folder-inbox-new.png"));
}
else
{
QListWidgetItem* item = ui.listWidget->item(0);
textItem = tr("Inbox");
item->setText(textItem);
QFont qf = item->font();
qf.setBold(false);
item->setFont(qf);
item->setIcon(QIcon(":/images/folder-inbox.png"));
}
if(newOutboxCount != 0)
{
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
QListWidgetItem* item = ui.listWidget->item(1);
textItem = tr("Outbox") + "(" + QString::number(newOutboxCount)+")";
item->setText(textItem);
QFont qf = item->font();
qf.setBold(true);
item->setFont(qf);
}
else
{
QListWidgetItem* item = ui.listWidget->item(1);
textItem = tr("Outbox");
item->setText(textItem);
QFont qf = item->font();
qf.setBold(false);
item->setFont(qf);
}
if(newDraftCount != 0)
{
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
QListWidgetItem* item = ui.listWidget->item(2);
textItem = tr("Draft") + "(" + QString::number(newDraftCount)+")";
item->setText(textItem);
QFont qf = item->font();
qf.setBold(true);
item->setFont(qf);
}
else
{
QListWidgetItem* item = ui.listWidget->item(2);
textItem = tr("Draft");
item->setText(textItem);
QFont qf = item->font();
qf.setBold(false);
item->setFont(qf);
}
}

View File

@ -23,9 +23,14 @@
#define _MESSAGESDIALOG_H
#include "settings/rsharesettings.h"
#include <list>
#include <QFileDialog>
#include <QModelIndex>
#include <QSortFilterProxyModel>
#include <QVariant>
#include "rsiface/rsmsgs.h"
#include "mainpage.h"
#include "ui_MessagesDialog.h"
@ -37,11 +42,13 @@ public:
/** Default Constructor */
MessagesDialog(QWidget *parent = 0);
/** Default Destructor */
void insertMsgTxtAndFiles();
void insertMsgTxtAndFiles(QModelIndex index = QModelIndex());
virtual void keyPressEvent(QKeyEvent *) ;
void updateMessageSummaryList();
public slots:
void insertMessages();
private slots:
@ -50,7 +57,7 @@ private slots:
void msgfilelistWidgetCostumPopupMenu(QPoint);
void changeBox( int newrow );
void updateCurrentMessage ( QTreeWidgetItem * item, QTreeWidgetItem * item2 );
void updateCurrentMessage(const QModelIndex&);
void newmessage();
@ -79,16 +86,24 @@ private slots:
void buttonstextundericon();
void loadToolButtonsettings();
void filterRegExpChanged();
void filterColumnChanged();
private:
/** A RetroShare Settings object used for saving/loading settings */
RshareSettings *_settings;
class QStandardItemModel *MessagesModel;
QSortFilterProxyModel *proxyModel;
bool getCurrentMsg(std::string &cid, std::string &mid);
void setMsgAsRead(QTreeWidgetItem *);
void setMsgAsRead(const QModelIndex &index);
void setCurrentFileName(const QString &fileName);
std::string mCurrCertId;
std::string mCurrMsgId;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>760</width>
<height>579</height>
<width>675</width>
<height>553</height>
</rect>
</property>
<property name="sizePolicy">
@ -534,19 +534,6 @@ border: 1px solid #CCCCCC;}</string>
<property name="margin">
<number>2</number>
</property>
<item row="0" column="9">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>529</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="replymessageButton">
<property name="sizePolicy">
@ -842,6 +829,49 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="10">
<widget class="QLineEdit" name="filterPatternLineEdit"/>
</item>
<item row="0" column="11">
<widget class="QComboBox" name="filterColumnComboBox">
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Attachments</string>
</property>
</item>
<item>
<property name="text">
<string>Subject</string>
</property>
</item>
<item>
<property name="text">
<string>From</string>
</property>
</item>
<item>
<property name="text">
<string>Date</string>
</property>
</item>
</widget>
</item>
<item row="0" column="9">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
@ -933,60 +963,26 @@ p, li { white-space: pre-wrap; }
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QTreeWidget" name="msgWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>5</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="indentation">
<number>16</number>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>4</number>
</property>
<column>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/attachment.png</normaloff>:/images/attachment.png</iconset>
</property>
</column>
<column>
<property name="text">
<string>Subject</string>
</property>
</column>
<column>
<property name="text">
<string>From</string>
</property>
</column>
<column>
<property name="text">
<string>Date</string>
</property>
</column>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout">
<item>
<widget class="QTreeView" name="messagestreeView">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<property name="spacing">
@ -1277,6 +1273,9 @@ p, li { white-space: pre-wrap; }
<verstretch>10</verstretch>
</sizepolicy>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -1456,7 +1455,6 @@ p, li { white-space: pre-wrap; }
<tabstop>newmessageButton</tabstop>
<tabstop>replymessageButton</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>msgWidget</tabstop>
<tabstop>msgText</tabstop>
<tabstop>msgList</tabstop>
</tabstops>

View File

@ -771,6 +771,7 @@ void SearchDialog::insertFile(const std::string& txt,qulonglong searchId, const
//
int items = ui.searchResultWidget->topLevelItemCount();
bool found = false ;
int sources;
QString sid_hexa = QString::number(searchId,16) ;
@ -780,7 +781,100 @@ void SearchDialog::insertFile(const std::string& txt,qulonglong searchId, const
{
int s = ui.searchResultWidget->topLevelItem(i)->text(SR_ID_COL).toInt() ;
ui.searchResultWidget->topLevelItem(i)->setText(SR_ID_COL,QString::number(s+1));
QTreeWidgetItem *item = ui.searchResultWidget->topLevelItem(i);
found = true ;
sources = s+1;
if ( sources < 1)
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 19)));
}
}
else if ( sources < 2)
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 38)));
}
}
else if ( sources < 3)
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 57)));
}
}
else if ( sources < 4)
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 76)));
}
}
else if ( sources < 5)
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 96)));
}
}
else if ( sources < 6)
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 114)));
}
}
else if ( sources < 7)
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 133)));
}
}
else if ( sources < 8)
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 152)));
}
}
else if ( sources < 9)
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 171)));
}
}
else if ( sources < 10)
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 190)));
}
}
else if ( sources < 11)
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 209)));
}
}
else if ( sources < 12)
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 228)));
}
}
else
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 228)));
}
}
break ;
}
@ -805,6 +899,16 @@ void SearchDialog::insertFile(const std::string& txt,qulonglong searchId, const
item->setTextAlignment( SR_SIZE_COL, Qt::AlignRight );
item->setText(SR_ID_COL, QString::number(1));
item->setText(SR_SEARCH_ID_COL, sid_hexa);
sources = item->text(SR_ID_COL).toInt();
if ( sources == 1)
{
for(int i = 0; i < 7; i++)
{
item->setForeground(i,QBrush( QColor(0, 0, 0)));
}
}
ui.searchResultWidget->addTopLevelItem(item);
}