2007-11-14 22:18:48 -05:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006, crypton
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-05-23 13:21:30 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2007-11-14 22:18:48 -05:00
|
|
|
* Boston, MA 02110-1301, USA.
|
2008-09-04 15:28:35 -04:00
|
|
|
****************************************************************/
|
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
#include <QItemDelegate>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QPaintEvent>
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
#include <QShortcut>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QPrinter>
|
|
|
|
#include <QPrintDialog>
|
|
|
|
#include <QTextStream>
|
|
|
|
#include <QTextCodec>
|
2009-11-28 09:34:15 -05:00
|
|
|
|
2008-09-04 15:28:35 -04:00
|
|
|
#include "MessagesDialog.h"
|
2010-05-23 15:13:41 -04:00
|
|
|
#include "msgs/MessageComposer.h"
|
2010-03-10 16:38:26 -05:00
|
|
|
#include "gui/RetroShareLink.h"
|
2008-03-26 10:22:51 -04:00
|
|
|
#include "util/printpreview.h"
|
2010-07-23 14:52:58 -04:00
|
|
|
#include "settings/rsharesettings.h"
|
2009-07-10 19:48:20 -04:00
|
|
|
#include "util/misc.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rsinit.h>
|
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
#include <retroshare/rsfiles.h>
|
2009-02-11 13:43:37 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-09-04 15:28:35 -04:00
|
|
|
/* Images for context menu icons */
|
2008-11-25 20:19:09 -05:00
|
|
|
#define IMAGE_MESSAGE ":/images/folder-draft.png"
|
|
|
|
#define IMAGE_MESSAGEREPLY ":/images/mail_reply.png"
|
2009-02-09 08:24:05 -05:00
|
|
|
#define IMAGE_MESSAGEREPLYALL ":/images/mail_replyall.png"
|
2008-11-25 20:19:09 -05:00
|
|
|
#define IMAGE_MESSAGEFORWARD ":/images/mail_forward.png"
|
|
|
|
#define IMAGE_MESSAGEREMOVE ":/images/message-mail-imapdelete.png"
|
|
|
|
#define IMAGE_DOWNLOAD ":/images/start.png"
|
|
|
|
#define IMAGE_DOWNLOADALL ":/images/startall.png"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-06-25 08:17:46 -04:00
|
|
|
#define COLUMN_COUNT 7
|
2010-05-18 18:37:18 -04:00
|
|
|
#define COLUMN_ATTACHEMENTS 0
|
|
|
|
#define COLUMN_SUBJECT 1
|
2010-08-08 18:58:10 -04:00
|
|
|
#define COLUMN_UNREAD 2
|
2010-05-23 13:21:30 -04:00
|
|
|
#define COLUMN_FROM 3
|
|
|
|
#define COLUMN_DATE 4
|
2010-06-25 08:17:46 -04:00
|
|
|
#define COLUMN_CONTENT 5
|
|
|
|
#define COLUMN_TAGS 6
|
|
|
|
|
|
|
|
#define COLUMN_DATA 0 // column for storing the userdata like msgid and srcid
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
#define ROLE_SORT Qt::UserRole
|
|
|
|
#define ROLE_MSGID Qt::UserRole + 1
|
|
|
|
#define ROLE_SRCID Qt::UserRole + 2
|
|
|
|
#define ROLE_UNREAD Qt::UserRole + 3
|
2010-05-27 15:48:52 -04:00
|
|
|
|
2010-05-28 10:42:54 -04:00
|
|
|
#define ROW_INBOX 0
|
|
|
|
#define ROW_OUTBOX 1
|
|
|
|
#define ROW_DRAFTBOX 2
|
|
|
|
#define ROW_SENTBOX 3
|
|
|
|
#define ROW_TRASHBOX 4
|
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
#define ACTION_TAGSINDEX_SIZE 3
|
|
|
|
#define ACTION_TAGSINDEX_TYPE "Type"
|
|
|
|
#define ACTION_TAGSINDEX_ID "ID"
|
|
|
|
#define ACTION_TAGSINDEX_COLOR "Color"
|
|
|
|
|
|
|
|
#define ACTION_TAGS_REMOVEALL 0
|
|
|
|
#define ACTION_TAGS_TAG 1
|
|
|
|
#define ACTION_TAGS_NEWTAG 2
|
|
|
|
|
|
|
|
#define CONFIG_FILE (RsInit::RsProfileConfigDirectory() + "/msg_locale.cfg")
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
#define CONFIG_SECTION_UNREAD "Unread"
|
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
#define CONFIG_SECTION_TAGS "Tags"
|
|
|
|
#define CONFIG_KEY_TEXT "Text"
|
|
|
|
#define CONFIG_KEY_COLOR "Color"
|
|
|
|
|
|
|
|
#define CONFIG_SECTION_TAG "Tag"
|
|
|
|
#define CONFIG_KEY_TAG "Tag"
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
class MessagesItemDelegate : public QItemDelegate
|
2010-05-23 13:21:30 -04:00
|
|
|
{
|
|
|
|
public:
|
2010-08-08 18:58:10 -04:00
|
|
|
MessagesItemDelegate(QObject *parent = 0) : QItemDelegate(parent)
|
2010-05-23 13:21:30 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
|
|
{
|
|
|
|
QStyleOptionViewItem ownOption (option);
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
if (index.column() == COLUMN_UNREAD) {
|
2010-05-23 13:21:30 -04:00
|
|
|
ownOption.state &= ~QStyle::State_HasFocus; // don't show text and focus rectangle
|
|
|
|
}
|
|
|
|
|
|
|
|
QItemDelegate::paint (painter, ownOption, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
|
|
{
|
|
|
|
QStyleOptionViewItem ownOption (option);
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
if (index.column() == COLUMN_UNREAD) {
|
2010-05-23 13:21:30 -04:00
|
|
|
ownOption.state &= ~QStyle::State_HasFocus; // don't show text and focus rectangle
|
|
|
|
}
|
|
|
|
|
|
|
|
return QItemDelegate::sizeHint(ownOption, index);
|
|
|
|
}
|
|
|
|
};
|
2010-05-18 18:37:18 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
class MessagesMenu : public QMenu
|
2010-05-27 15:48:52 -04:00
|
|
|
{
|
|
|
|
public:
|
2010-08-08 18:58:10 -04:00
|
|
|
MessagesMenu(const QString &title, QWidget *parent) : QMenu (title, parent)
|
2010-05-27 15:48:52 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void paintEvent(QPaintEvent *e)
|
|
|
|
{
|
|
|
|
QMenu::paintEvent(e);
|
|
|
|
|
|
|
|
QPainter p(this);
|
|
|
|
QRegion emptyArea = QRegion(rect());
|
|
|
|
|
|
|
|
//draw the items with color
|
|
|
|
foreach (QAction *pAction, actions()) {
|
|
|
|
QRect adjustedActionRect = actionGeometry(pAction);
|
|
|
|
if (!e->rect().intersects(adjustedActionRect))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const QMap<QString, QVariant> &Values = pAction->data().toMap();
|
|
|
|
if (Values.size () != ACTION_TAGSINDEX_SIZE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (Values [ACTION_TAGSINDEX_TYPE] != ACTION_TAGS_TAG) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//set the clip region to be extra safe (and adjust for the scrollers)
|
|
|
|
QRegion adjustedActionReg(adjustedActionRect);
|
|
|
|
emptyArea -= adjustedActionReg;
|
|
|
|
p.setClipRegion(adjustedActionReg);
|
|
|
|
|
|
|
|
QStyleOptionMenuItem opt;
|
|
|
|
initStyleOption(&opt, pAction);
|
|
|
|
|
|
|
|
opt.palette.setColor(QPalette::ButtonText, QColor(Values [ACTION_TAGSINDEX_COLOR].toInt()));
|
2010-05-29 20:00:15 -04:00
|
|
|
// needed for Cleanlooks
|
|
|
|
opt.palette.setColor(QPalette::Text, QColor(Values [ACTION_TAGSINDEX_COLOR].toInt()));
|
2010-05-27 15:48:52 -04:00
|
|
|
|
|
|
|
opt.rect = adjustedActionRect;
|
|
|
|
style()->drawControl(QStyle::CE_MenuItem, &opt, &p, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-06-03 18:12:07 -04:00
|
|
|
MessagesDialog::LockUpdate::LockUpdate (MessagesDialog *pDialog, bool bUpdate)
|
|
|
|
{
|
|
|
|
m_pDialog = pDialog;
|
|
|
|
m_bUpdate = bUpdate;
|
|
|
|
|
|
|
|
m_pDialog->m_nLockUpdate++;
|
|
|
|
}
|
|
|
|
|
|
|
|
MessagesDialog::LockUpdate::~LockUpdate ()
|
|
|
|
{
|
2010-07-08 21:10:27 -04:00
|
|
|
if(--m_pDialog->m_nLockUpdate < 0)
|
|
|
|
m_pDialog->m_nLockUpdate = 0;
|
2010-06-03 18:12:07 -04:00
|
|
|
|
|
|
|
if (m_bUpdate && m_pDialog->m_nLockUpdate == 0) {
|
|
|
|
m_pDialog->insertMessages();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-18 18:37:18 -04:00
|
|
|
static int FilterColumnFromComboBox(int nIndex)
|
|
|
|
{
|
|
|
|
switch (nIndex) {
|
|
|
|
case 0:
|
|
|
|
return COLUMN_ATTACHEMENTS;
|
|
|
|
case 1:
|
|
|
|
return COLUMN_SUBJECT;
|
|
|
|
case 2:
|
|
|
|
return COLUMN_FROM;
|
|
|
|
case 3:
|
|
|
|
return COLUMN_DATE;
|
|
|
|
case 4:
|
|
|
|
return COLUMN_CONTENT;
|
2010-05-27 15:48:52 -04:00
|
|
|
case 5:
|
|
|
|
return COLUMN_TAGS;
|
2010-05-18 18:37:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return COLUMN_SUBJECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int FilterColumnToComboBox(int nIndex)
|
|
|
|
{
|
|
|
|
switch (nIndex) {
|
|
|
|
case COLUMN_ATTACHEMENTS:
|
|
|
|
return 0;
|
|
|
|
case COLUMN_SUBJECT:
|
|
|
|
return 1;
|
|
|
|
case COLUMN_FROM:
|
|
|
|
return 2;
|
|
|
|
case COLUMN_DATE:
|
|
|
|
return 3;
|
|
|
|
case COLUMN_CONTENT:
|
|
|
|
return 4;
|
2010-05-27 15:48:52 -04:00
|
|
|
case COLUMN_TAGS:
|
|
|
|
return 5;
|
2010-05-18 18:37:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return FilterColumnToComboBox(COLUMN_SUBJECT);
|
|
|
|
}
|
2010-05-10 15:55:59 -04:00
|
|
|
|
2008-09-04 15:28:35 -04:00
|
|
|
/** Constructor */
|
|
|
|
MessagesDialog::MessagesDialog(QWidget *parent)
|
|
|
|
: MainPage(parent)
|
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
m_bProcessSettings = false;
|
2010-06-01 18:14:52 -04:00
|
|
|
m_bInChange = false;
|
2010-06-03 18:12:07 -04:00
|
|
|
m_nLockUpdate = 0;
|
2010-05-27 15:48:52 -04:00
|
|
|
m_pConfig = new RSettings (CONFIG_FILE);
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
connect( ui.messagestreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) );
|
|
|
|
connect( ui.msgList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( QPoint ) ) );
|
|
|
|
connect( ui.messagestreeView, SIGNAL(clicked ( const QModelIndex &) ) , this, SLOT( clicked( const QModelIndex & ) ) );
|
2010-05-25 05:32:14 -04:00
|
|
|
connect( ui.messagestreeView, SIGNAL(doubleClicked ( const QModelIndex& ) ) , this, SLOT( doubleClicked( const QModelIndex & ) ) );
|
2010-05-23 13:21:30 -04:00
|
|
|
connect( ui.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) );
|
2010-06-01 18:14:52 -04:00
|
|
|
connect( ui.tagWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeTag ( int) ) );
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));
|
|
|
|
connect(ui.removemessageButton, SIGNAL(clicked()), this, SLOT(removemessage()));
|
|
|
|
connect(ui.replymessageButton, SIGNAL(clicked()), this, SLOT(replytomessage()));
|
|
|
|
connect(ui.replyallmessageButton, SIGNAL(clicked()), this, SLOT(replyallmessage()));
|
|
|
|
connect(ui.forwardmessageButton, SIGNAL(clicked()), this, SLOT(forwardmessage()));
|
|
|
|
|
|
|
|
connect(ui.actionPrint, SIGNAL(triggered()), this, SLOT(print()));
|
|
|
|
ui.actionPrint->setDisabled(true);
|
|
|
|
connect(ui.actionPrintPreview, SIGNAL(triggered()), this, SLOT(printpreview()));
|
|
|
|
ui.actionPrintPreview->setDisabled(true);
|
|
|
|
connect(ui.printbutton, SIGNAL(clicked()), this, SLOT(print()));
|
|
|
|
|
|
|
|
connect(ui.expandFilesButton, SIGNAL(clicked()), this, SLOT(togglefileview()));
|
|
|
|
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getcurrentrecommended()));
|
|
|
|
|
|
|
|
connect( ui.msgText, SIGNAL( anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
|
|
|
|
|
|
|
|
connect(ui.actionTextBesideIcon, SIGNAL(triggered()), this, SLOT(buttonstextbesideicon()));
|
|
|
|
connect(ui.actionIconOnly, SIGNAL(triggered()), this, SLOT(buttonsicononly()));
|
|
|
|
connect(ui.actionTextUnderIcon, SIGNAL(triggered()), this, SLOT(buttonstextundericon()));
|
|
|
|
|
|
|
|
connect(ui.actionSave_as, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
|
|
|
|
ui.actionSave_as->setDisabled(true);
|
|
|
|
|
|
|
|
connect( ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
|
|
|
connect( ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
|
|
|
|
|
|
|
connect(ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged()));
|
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
ui.msgText->setOpenLinks(false);
|
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
m_eListMode = LIST_NOTHING;
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
mCurrCertId = "";
|
|
|
|
mCurrMsgId = "";
|
|
|
|
|
|
|
|
// Set the QStandardItemModel
|
2010-05-10 15:55:59 -04:00
|
|
|
MessagesModel = new QStandardItemModel(0, COLUMN_COUNT);
|
2010-05-23 14:17:08 -04:00
|
|
|
MessagesModel->setHeaderData(COLUMN_ATTACHEMENTS, Qt::Horizontal, QIcon(":/images/attachment.png"), Qt::DecorationRole);
|
2010-05-18 18:37:18 -04:00
|
|
|
MessagesModel->setHeaderData(COLUMN_SUBJECT, Qt::Horizontal, tr("Subject"));
|
2010-08-08 18:58:10 -04:00
|
|
|
MessagesModel->setHeaderData(COLUMN_UNREAD, Qt::Horizontal, QIcon(":/images/message-state-header.png"), Qt::DecorationRole);
|
2010-05-18 18:37:18 -04:00
|
|
|
MessagesModel->setHeaderData(COLUMN_FROM, Qt::Horizontal, tr("From"));
|
|
|
|
MessagesModel->setHeaderData(COLUMN_DATE, Qt::Horizontal, tr("Date"));
|
2010-05-27 15:48:52 -04:00
|
|
|
MessagesModel->setHeaderData(COLUMN_TAGS, Qt::Horizontal, tr("Tags"));
|
2010-05-18 18:37:18 -04:00
|
|
|
MessagesModel->setHeaderData(COLUMN_CONTENT, Qt::Horizontal, tr("Content"));
|
|
|
|
|
2010-02-13 13:49:56 -05:00
|
|
|
proxyModel = new QSortFilterProxyModel(this);
|
|
|
|
proxyModel->setDynamicSortFilter(true);
|
|
|
|
proxyModel->setSourceModel(MessagesModel);
|
2010-06-25 08:17:46 -04:00
|
|
|
proxyModel->setSortRole(ROLE_SORT);
|
2010-05-10 15:55:59 -04:00
|
|
|
proxyModel->sort (COLUMN_DATE, Qt::DescendingOrder);
|
2010-02-13 13:49:56 -05:00
|
|
|
ui.messagestreeView->setModel(proxyModel);
|
|
|
|
ui.messagestreeView->setSelectionBehavior(QTreeView::SelectRows);
|
2010-05-23 13:21:30 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
QItemDelegate *pDelegate = new MessagesItemDelegate(this);
|
2010-05-23 13:21:30 -04:00
|
|
|
ui.messagestreeView->setItemDelegate(pDelegate);
|
|
|
|
|
2010-02-13 13:49:56 -05:00
|
|
|
ui.messagestreeView->setRootIsDecorated(false);
|
2010-05-23 13:21:30 -04:00
|
|
|
ui.messagestreeView->setSortingEnabled(true);
|
2010-05-10 15:55:59 -04:00
|
|
|
ui.messagestreeView->sortByColumn(COLUMN_DATE, Qt::DescendingOrder);
|
2010-04-27 17:46:28 -04:00
|
|
|
|
|
|
|
// connect after setting model
|
|
|
|
connect( ui.messagestreeView->selectionModel(), SIGNAL(currentChanged ( QModelIndex, QModelIndex ) ) , this, SLOT( currentChanged( const QModelIndex & ) ) );
|
|
|
|
|
2010-05-06 10:39:50 -04:00
|
|
|
// workaround for Qt bug, should be solved in next Qt release 4.7.0
|
|
|
|
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
|
|
|
|
QShortcut *Shortcut = new QShortcut(QKeySequence (Qt::Key_Delete), ui.messagestreeView, 0, 0, Qt::WidgetShortcut);
|
|
|
|
connect(Shortcut, SIGNAL(activated()), this, SLOT( removemessage ()));
|
2010-05-28 10:42:54 -04:00
|
|
|
Shortcut = new QShortcut(QKeySequence (Qt::SHIFT | Qt::Key_Delete), ui.messagestreeView, 0, 0, Qt::WidgetShortcut);
|
|
|
|
connect(Shortcut, SIGNAL(activated()), this, SLOT( removemessage ()));
|
2010-05-06 10:39:50 -04:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
/* hide the Tree +/- */
|
|
|
|
ui.msgList->setRootIsDecorated( false );
|
|
|
|
ui.msgList->setSelectionMode( QAbstractItemView::ExtendedSelection );
|
|
|
|
|
|
|
|
/* Set header initial section sizes */
|
|
|
|
QHeaderView * msgwheader = ui.messagestreeView->header () ;
|
|
|
|
msgwheader->resizeSection (COLUMN_ATTACHEMENTS, 24);
|
|
|
|
msgwheader->resizeSection (COLUMN_SUBJECT, 250);
|
2010-08-08 18:58:10 -04:00
|
|
|
msgwheader->resizeSection (COLUMN_UNREAD, 16);
|
2010-05-23 13:21:30 -04:00
|
|
|
msgwheader->resizeSection (COLUMN_FROM, 140);
|
|
|
|
msgwheader->resizeSection (COLUMN_DATE, 140);
|
|
|
|
|
2007-11-18 18:35:53 -05:00
|
|
|
/* Set header resize modes and initial section sizes */
|
2010-05-23 13:21:30 -04:00
|
|
|
QHeaderView * msglheader = ui.msgList->header () ;
|
|
|
|
msglheader->setResizeMode (0, QHeaderView::Interactive);
|
|
|
|
msglheader->setResizeMode (1, QHeaderView::Interactive);
|
|
|
|
msglheader->setResizeMode (2, QHeaderView::Interactive);
|
|
|
|
msglheader->setResizeMode (3, QHeaderView::Interactive);
|
|
|
|
|
|
|
|
msglheader->resizeSection (0, 200);
|
|
|
|
msglheader->resizeSection (1, 100);
|
|
|
|
msglheader->resizeSection (2, 100);
|
|
|
|
msglheader->resizeSection (3, 200);
|
|
|
|
|
|
|
|
ui.forwardmessageButton->setToolTip(tr("Forward selected Message"));
|
|
|
|
ui.replyallmessageButton->setToolTip(tr("Reply to All"));
|
2008-11-25 20:19:09 -05:00
|
|
|
|
2008-09-04 15:28:35 -04:00
|
|
|
QMenu * printmenu = new QMenu();
|
|
|
|
printmenu->addAction(ui.actionPrint);
|
|
|
|
printmenu->addAction(ui.actionPrintPreview);
|
2008-03-26 10:22:51 -04:00
|
|
|
ui.printbutton->setMenu(printmenu);
|
2010-05-23 13:21:30 -04:00
|
|
|
|
2010-01-21 20:05:45 -05:00
|
|
|
QMenu * viewmenu = new QMenu();
|
|
|
|
viewmenu->addAction(ui.actionTextBesideIcon);
|
|
|
|
viewmenu->addAction(ui.actionIconOnly);
|
2010-03-24 06:52:52 -04:00
|
|
|
//viewmenu->addAction(ui.actionTextUnderIcon);
|
2010-01-21 20:05:45 -05:00
|
|
|
ui.viewtoolButton->setMenu(viewmenu);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
loadToolButtonsettings();
|
|
|
|
|
|
|
|
mFont = QFont("Arial", 10, QFont::Bold);
|
|
|
|
ui.subjectText->setFont(mFont);
|
2008-09-04 15:28:35 -04:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
//setting default filter by column as subject
|
2010-05-18 18:37:18 -04:00
|
|
|
proxyModel->setFilterKeyColumn(FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex()));
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
ui.clearButton->hide();
|
2010-02-14 07:29:50 -05:00
|
|
|
|
2010-05-18 18:37:18 -04:00
|
|
|
// load settings
|
|
|
|
processSettings(true);
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
/* Set header sizes for the fixed columns and resize modes, must be set after processSettings */
|
2010-05-23 14:17:08 -04:00
|
|
|
msgwheader->setResizeMode (COLUMN_ATTACHEMENTS, QHeaderView::Fixed);
|
2010-05-23 13:21:30 -04:00
|
|
|
msgwheader->setResizeMode (COLUMN_DATE, QHeaderView::Interactive);
|
2010-08-08 18:58:10 -04:00
|
|
|
msgwheader->setResizeMode (COLUMN_UNREAD, QHeaderView::Fixed);
|
|
|
|
msgwheader->resizeSection (COLUMN_UNREAD, 24);
|
2010-05-23 13:21:30 -04:00
|
|
|
|
2010-05-18 18:37:18 -04:00
|
|
|
// fill folder list
|
|
|
|
updateMessageSummaryList();
|
2010-05-28 10:42:54 -04:00
|
|
|
ui.listWidget->setCurrentRow(ROW_INBOX);
|
2010-05-18 18:37:18 -04:00
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
// create tag menu
|
2010-06-01 18:14:52 -04:00
|
|
|
fillTags();
|
2010-05-27 15:48:52 -04:00
|
|
|
|
2010-04-27 17:46:28 -04:00
|
|
|
// create timer for navigation
|
|
|
|
timer = new QTimer(this);
|
|
|
|
timer->setInterval(300);
|
|
|
|
timer->setSingleShot(true);
|
|
|
|
connect(timer, SIGNAL(timeout()), this, SLOT(updateCurrentMessage()));
|
|
|
|
|
2008-09-04 15:28:35 -04:00
|
|
|
/* Hide platform specific features */
|
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-04-27 17:46:28 -04:00
|
|
|
MessagesDialog::~MessagesDialog()
|
|
|
|
{
|
|
|
|
// stop and delete timer
|
|
|
|
timer->stop();
|
|
|
|
delete(timer);
|
2010-05-18 18:37:18 -04:00
|
|
|
|
|
|
|
// save settings
|
|
|
|
processSettings(false);
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
delete (m_pConfig);
|
2010-05-18 18:37:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MessagesDialog::processSettings(bool bLoad)
|
|
|
|
{
|
2010-05-20 17:53:27 -04:00
|
|
|
m_bProcessSettings = true;
|
|
|
|
|
2010-05-18 18:37:18 -04:00
|
|
|
QHeaderView *msgwheader = ui.messagestreeView->header () ;
|
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->beginGroup(QString("MessageDialog"));
|
2010-05-18 18:37:18 -04:00
|
|
|
|
|
|
|
if (bLoad) {
|
|
|
|
// load settings
|
|
|
|
|
|
|
|
// expandFiles
|
2010-05-20 17:53:27 -04:00
|
|
|
bool bValue = Settings->value("expandFiles", true).toBool();
|
2010-05-18 18:37:18 -04:00
|
|
|
ui.expandFilesButton->setChecked(bValue);
|
|
|
|
ui.msgList->setVisible(bValue);
|
|
|
|
togglefileview_internal();
|
|
|
|
|
|
|
|
// filterColumn
|
2010-05-20 17:53:27 -04:00
|
|
|
int nValue = FilterColumnToComboBox(Settings->value("filterColumn", true).toInt());
|
2010-05-18 18:37:18 -04:00
|
|
|
ui.filterColumnComboBox->setCurrentIndex(nValue);
|
|
|
|
|
|
|
|
// state of message tree
|
2010-05-20 17:53:27 -04:00
|
|
|
msgwheader->restoreState(Settings->value("MessageTree").toByteArray());
|
2010-05-18 18:37:18 -04:00
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
// state of tag list
|
|
|
|
bValue = Settings->value("tagList", true).toBool();
|
|
|
|
ui.Tags_Button->setChecked(bValue);
|
|
|
|
|
2010-05-18 18:37:18 -04:00
|
|
|
// state of splitter
|
2010-05-20 17:53:27 -04:00
|
|
|
ui.msgSplitter->restoreState(Settings->value("Splitter").toByteArray());
|
|
|
|
ui.msgSplitter_2->restoreState(Settings->value("Splitter2").toByteArray());
|
2010-06-19 13:46:19 -04:00
|
|
|
ui.listSplitter->restoreState(Settings->value("Splitter3").toByteArray());
|
2010-05-18 18:37:18 -04:00
|
|
|
} else {
|
|
|
|
// save settings
|
|
|
|
|
|
|
|
// state of message tree
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setValue("MessageTree", msgwheader->saveState());
|
2010-05-18 18:37:18 -04:00
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
// state of tag list
|
|
|
|
Settings->setValue("tagList", ui.Tags_Button->isChecked());
|
|
|
|
|
2010-05-18 18:37:18 -04:00
|
|
|
// state of splitter
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setValue("Splitter", ui.msgSplitter->saveState());
|
|
|
|
Settings->setValue("Splitter2", ui.msgSplitter_2->saveState());
|
2010-06-19 13:46:19 -04:00
|
|
|
Settings->setValue("Splitter3", ui.listSplitter->saveState());
|
2010-05-18 18:37:18 -04:00
|
|
|
}
|
2010-05-20 17:53:27 -04:00
|
|
|
|
|
|
|
Settings->endGroup();
|
|
|
|
|
|
|
|
m_bProcessSettings = false;
|
2010-04-27 17:46:28 -04:00
|
|
|
}
|
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
static void getMessageTags (RSettings *pConfig, QString msgId, QList<int> &tagIds)
|
2010-05-27 15:48:52 -04:00
|
|
|
{
|
|
|
|
pConfig->beginGroup(CONFIG_SECTION_TAG);
|
|
|
|
|
|
|
|
int nSize = pConfig->beginReadArray(msgId);
|
|
|
|
|
|
|
|
for (int i = 0; i < nSize; i++) {
|
|
|
|
pConfig->setArrayIndex(i);
|
|
|
|
int nTagId = pConfig->value(CONFIG_KEY_TAG).toInt();
|
|
|
|
tagIds.push_back(nTagId);
|
|
|
|
}
|
|
|
|
pConfig->endArray();
|
|
|
|
|
|
|
|
pConfig->endGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setMessageTags (RSettings *pConfig, QString &msgId, QList<int> &tagIds)
|
|
|
|
{
|
|
|
|
pConfig->beginGroup(CONFIG_SECTION_TAG);
|
|
|
|
|
|
|
|
pConfig->remove(msgId);
|
|
|
|
|
|
|
|
if (tagIds.size()) {
|
|
|
|
pConfig->beginWriteArray(msgId, tagIds.size());
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
for (QList<int>::iterator tagId = tagIds.begin(); tagId != tagIds.end(); tagId++) {
|
|
|
|
pConfig->setArrayIndex(i++);
|
|
|
|
pConfig->setValue(CONFIG_KEY_TAG, *tagId);
|
|
|
|
}
|
|
|
|
pConfig->endArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
pConfig->endGroup();
|
|
|
|
}
|
|
|
|
|
2010-06-02 08:11:09 -04:00
|
|
|
/*static*/ void MessagesDialog::initStandardTagItems(std::map<int, TagItem> &Items)
|
|
|
|
{
|
|
|
|
// create standard enties ... id = sort, maybe later own member
|
|
|
|
Items [-5].text = tr("Important");
|
|
|
|
Items [-5].color = QColor(255, 0, 0).rgb();
|
|
|
|
|
|
|
|
Items [-4].text = tr("Work");
|
|
|
|
Items [-4].color = QColor(255, 153, 0).rgb();
|
|
|
|
|
|
|
|
Items [-3].text = tr("Personal");
|
|
|
|
Items [-3].color = QColor(0, 153, 0).rgb();
|
|
|
|
|
|
|
|
Items [-2].text = tr("Todo");
|
|
|
|
Items [-2].color = QColor(51, 51, 255).rgb();
|
|
|
|
|
|
|
|
Items [-1].text = tr("Later");
|
|
|
|
Items [-1].color = QColor(153, 51, 153).rgb();
|
|
|
|
}
|
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
void MessagesDialog::getTagItems(std::map<int, TagItem> &Items)
|
|
|
|
{
|
2010-06-02 08:11:09 -04:00
|
|
|
initStandardTagItems (Items);
|
2010-05-27 15:48:52 -04:00
|
|
|
|
2010-06-02 08:11:09 -04:00
|
|
|
// create standard enties
|
|
|
|
initStandardTagItems(Items);
|
2010-05-27 15:48:52 -04:00
|
|
|
|
|
|
|
// load user tags and colors
|
|
|
|
m_pConfig->beginGroup(CONFIG_SECTION_TAGS);
|
|
|
|
|
|
|
|
QStringList ids = m_pConfig->childGroups();
|
|
|
|
for (QStringList::iterator id = ids.begin(); id != ids.end(); id++) {
|
|
|
|
int nId = 0;
|
|
|
|
std::istringstream instream((*id).toStdString());
|
|
|
|
instream >> nId;
|
|
|
|
|
|
|
|
m_pConfig->beginGroup(*id);
|
|
|
|
|
2010-06-02 08:11:09 -04:00
|
|
|
TagItem Item;
|
2010-05-27 15:48:52 -04:00
|
|
|
if (nId < 0) {
|
|
|
|
// standard tag
|
|
|
|
Item = Items[nId];
|
|
|
|
} else {
|
|
|
|
Item.text = m_pConfig->value(CONFIG_KEY_TEXT).toString();
|
|
|
|
}
|
|
|
|
Item.color = m_pConfig->value(CONFIG_KEY_COLOR, Item.color).toUInt();
|
|
|
|
|
|
|
|
m_pConfig->endGroup();
|
|
|
|
|
|
|
|
Items [nId] = Item;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pConfig->endGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessagesDialog::setTagItems(std::map<int, TagItem> &Items)
|
|
|
|
{
|
|
|
|
// process deleted tags
|
|
|
|
QList<int> tagIdsToDelete;
|
|
|
|
std::map<int, TagItem>::iterator Item;
|
|
|
|
for (Item = Items.begin(); Item != Items.end(); Item++) {
|
|
|
|
if (Item->second._delete) {
|
|
|
|
tagIdsToDelete.push_back(Item->first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tagIdsToDelete.size()) {
|
|
|
|
// iterate all saved tags on messages and remove the id's
|
|
|
|
|
|
|
|
// get all msgIds with tags
|
|
|
|
m_pConfig->beginGroup(CONFIG_SECTION_TAG);
|
|
|
|
QStringList msgIds = m_pConfig->childGroups();
|
|
|
|
m_pConfig->endGroup();
|
|
|
|
|
|
|
|
for (QStringList::iterator msgId = msgIds.begin(); msgId != msgIds.end(); msgId++) {
|
|
|
|
QList<int> tagIds;
|
|
|
|
getMessageTags (m_pConfig, *msgId, tagIds);
|
|
|
|
|
|
|
|
bool bSave = false;
|
|
|
|
|
|
|
|
for (QList<int>::iterator tagIdToDelete = tagIdsToDelete.begin(); tagIdToDelete != tagIdsToDelete.end(); tagIdToDelete++) {
|
|
|
|
QList<int>::iterator tagId = qFind(tagIds.begin(), tagIds.end(), *tagIdToDelete);
|
|
|
|
if (tagId != tagIds.end()) {
|
|
|
|
tagIds.erase(tagId);
|
|
|
|
bSave = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bSave) {
|
|
|
|
setMessageTags (m_pConfig, *msgId, tagIds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// save tags
|
|
|
|
m_pConfig->remove(CONFIG_SECTION_TAGS);
|
|
|
|
|
|
|
|
m_pConfig->beginGroup(CONFIG_SECTION_TAGS);
|
|
|
|
|
|
|
|
for (Item = Items.begin(); Item != Items.end(); Item++) {
|
|
|
|
if (Item->second._delete) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString sId;
|
|
|
|
sId.sprintf("%d", Item->first);
|
|
|
|
m_pConfig->beginGroup(sId);
|
|
|
|
|
|
|
|
if (Item->first > 0) {
|
|
|
|
m_pConfig->setValue(CONFIG_KEY_TEXT, Item->second.text);
|
|
|
|
}
|
|
|
|
m_pConfig->setValue(CONFIG_KEY_COLOR, Item->second.color);
|
|
|
|
|
|
|
|
m_pConfig->endGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pConfig->endGroup();
|
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
fillTags();
|
2010-05-27 15:48:52 -04:00
|
|
|
insertMessages();
|
|
|
|
}
|
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
void MessagesDialog::fillTags()
|
2010-05-27 15:48:52 -04:00
|
|
|
{
|
2010-06-01 18:14:52 -04:00
|
|
|
std::map<int, TagItem> TagItems;
|
|
|
|
std::map<int, TagItem>::iterator Item;
|
|
|
|
getTagItems(TagItems);
|
|
|
|
|
|
|
|
// create tag menu
|
2010-08-08 18:58:10 -04:00
|
|
|
QMenu *pMenu = new MessagesMenu (tr("Tag"), this);
|
2010-05-27 15:48:52 -04:00
|
|
|
connect(pMenu, SIGNAL(triggered (QAction*)), this, SLOT(tagTriggered(QAction*)));
|
|
|
|
connect(pMenu, SIGNAL(aboutToShow()), this, SLOT(tagAboutToShow()));
|
|
|
|
|
|
|
|
bool bUser = false;
|
|
|
|
|
|
|
|
QAction *pAction;
|
|
|
|
QMap<QString, QVariant> Values;
|
|
|
|
|
|
|
|
if (TagItems.size()) {
|
|
|
|
pAction = new QAction(tr("Remove All Tags"), pMenu);
|
|
|
|
Values [ACTION_TAGSINDEX_TYPE] = ACTION_TAGS_REMOVEALL;
|
|
|
|
Values [ACTION_TAGSINDEX_ID] = 0;
|
|
|
|
Values [ACTION_TAGSINDEX_COLOR] = 0;
|
|
|
|
pAction->setData (Values);
|
|
|
|
pMenu->addAction(pAction);
|
|
|
|
|
|
|
|
pMenu->addSeparator();
|
|
|
|
|
|
|
|
for (Item = TagItems.begin(); Item != TagItems.end(); Item++) {
|
|
|
|
pAction = new QAction(Item->second.text, pMenu);
|
|
|
|
Values [ACTION_TAGSINDEX_TYPE] = ACTION_TAGS_TAG;
|
|
|
|
Values [ACTION_TAGSINDEX_ID] = Item->first;
|
|
|
|
Values [ACTION_TAGSINDEX_COLOR] = Item->second.color;
|
|
|
|
pAction->setData (Values);
|
|
|
|
pAction->setCheckable(true);
|
|
|
|
|
|
|
|
if (Item->first > 0 && bUser == false) {
|
|
|
|
bUser = true;
|
|
|
|
pMenu->addSeparator();
|
|
|
|
}
|
|
|
|
|
|
|
|
pMenu->addAction(pAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
pMenu->addSeparator();
|
|
|
|
}
|
|
|
|
|
|
|
|
pAction = new QAction(tr("New tag ..."), pMenu);
|
|
|
|
Values [ACTION_TAGSINDEX_TYPE] = ACTION_TAGS_NEWTAG;
|
|
|
|
Values [ACTION_TAGSINDEX_ID] = 0;
|
|
|
|
Values [ACTION_TAGSINDEX_COLOR] = 0;
|
|
|
|
pAction->setData (Values);
|
|
|
|
pMenu->addAction(pAction);
|
|
|
|
|
|
|
|
ui.tagButton->setMenu(pMenu);
|
2010-06-01 18:14:52 -04:00
|
|
|
|
|
|
|
// fill tags
|
|
|
|
m_bInChange = true;
|
|
|
|
|
|
|
|
// save current selection
|
|
|
|
QListWidgetItem *pItem = ui.tagWidget->currentItem();
|
|
|
|
int nSelectecTagId = 0;
|
|
|
|
if (pItem) {
|
|
|
|
nSelectecTagId = pItem->data(Qt::UserRole).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
QListWidgetItem *pItemToSelect = NULL;
|
|
|
|
|
|
|
|
ui.tagWidget->clear();
|
|
|
|
for (Item = TagItems.begin(); Item != TagItems.end(); Item++) {
|
|
|
|
pItem = new QListWidgetItem (Item->second.text, ui.tagWidget);
|
|
|
|
pItem->setForeground(QBrush(QColor(Item->second.color)));
|
2010-06-01 19:27:34 -04:00
|
|
|
pItem->setIcon(QIcon(":/images/foldermail.png"));
|
2010-06-01 18:14:52 -04:00
|
|
|
pItem->setData(Qt::UserRole, Item->first);
|
|
|
|
pItem->setData(Qt::UserRole + 1, Item->second.text); // for updateMessageSummaryList
|
|
|
|
|
|
|
|
if (Item->first == nSelectecTagId) {
|
|
|
|
pItemToSelect = pItem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pItemToSelect) {
|
|
|
|
ui.tagWidget->setCurrentItem(pItemToSelect);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_bInChange = false;
|
|
|
|
|
|
|
|
updateMessageSummaryList();
|
2010-05-27 15:48:52 -04:00
|
|
|
}
|
|
|
|
|
2010-05-06 10:39:50 -04:00
|
|
|
// replaced by shortcut
|
|
|
|
//void MessagesDialog::keyPressEvent(QKeyEvent *e)
|
|
|
|
//{
|
|
|
|
// if(e->key() == Qt::Key_Delete)
|
|
|
|
// {
|
|
|
|
// removemessage() ;
|
|
|
|
// e->accept() ;
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// MainPage::keyPressEvent(e) ;
|
|
|
|
//}
|
2008-09-04 15:28:35 -04:00
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
int MessagesDialog::getSelectedMsgCount (QList<int> *pRows, QList<int> *pRowsRead, QList<int> *pRowsUnread)
|
2010-05-07 18:23:38 -04:00
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
if (pRowsRead) pRowsRead->clear();
|
|
|
|
if (pRowsUnread) pRowsUnread->clear();
|
|
|
|
|
2010-05-07 18:23:38 -04:00
|
|
|
//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);
|
2010-05-23 13:21:30 -04:00
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
if (pRows || pRowsRead || pRowsUnread) {
|
2010-05-23 13:21:30 -04:00
|
|
|
int mappedRow = proxyModel->mapToSource(*it).row();
|
2010-05-27 15:48:52 -04:00
|
|
|
|
|
|
|
if (pRows) pRows->append(mappedRow);
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
if (MessagesModel->item(mappedRow, COLUMN_DATA)->data(ROLE_UNREAD).toBool()) {
|
2010-05-23 13:21:30 -04:00
|
|
|
if (pRowsUnread) pRowsUnread->append(mappedRow);
|
|
|
|
} else {
|
|
|
|
if (pRowsRead) pRowsRead->append(mappedRow);
|
|
|
|
}
|
|
|
|
}
|
2010-05-07 18:23:38 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rowList.size();
|
|
|
|
}
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
bool MessagesDialog::isMessageRead(int nRow)
|
|
|
|
{
|
|
|
|
QStandardItem *item;
|
2010-08-08 18:58:10 -04:00
|
|
|
item = MessagesModel->item(nRow,COLUMN_DATA);
|
|
|
|
return !item->data(ROLE_UNREAD).toBool();
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
|
2008-09-04 15:28:35 -04:00
|
|
|
void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point )
|
|
|
|
{
|
2010-05-07 18:23:38 -04:00
|
|
|
QMenu contextMnu( this );
|
2008-09-04 15:28:35 -04:00
|
|
|
|
2010-05-07 18:23:38 -04:00
|
|
|
/** Defines the actions for the context menu */
|
2010-05-27 15:48:52 -04:00
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *replytomsgAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply to Message" ), &contextMnu );
|
2010-05-07 18:23:38 -04:00
|
|
|
connect( replytomsgAct , SIGNAL( triggered() ), this, SLOT( replytomessage() ) );
|
|
|
|
contextMnu.addAction( replytomsgAct);
|
2009-02-09 08:24:05 -05:00
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *replyallmsgAct = new QAction(QIcon(IMAGE_MESSAGEREPLYALL), tr( "Reply to All" ), &contextMnu );
|
2010-05-07 18:23:38 -04:00
|
|
|
connect( replyallmsgAct , SIGNAL( triggered() ), this, SLOT( replyallmessage() ) );
|
|
|
|
contextMnu.addAction( replyallmsgAct);
|
2008-11-25 20:19:09 -05:00
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *forwardmsgAct = new QAction(QIcon(IMAGE_MESSAGEFORWARD), tr( "Forward Message" ), &contextMnu );
|
2010-05-07 18:23:38 -04:00
|
|
|
connect( forwardmsgAct , SIGNAL( triggered() ), this, SLOT( forwardmessage() ) );
|
|
|
|
contextMnu.addAction( forwardmsgAct);
|
2008-11-25 20:19:09 -05:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
QList<int> RowsRead;
|
|
|
|
QList<int> RowsUnread;
|
2010-05-27 15:48:52 -04:00
|
|
|
int nCount = getSelectedMsgCount (NULL, &RowsRead, &RowsUnread);
|
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *editAct = new QAction(tr( "Edit..." ), &contextMnu );
|
2010-06-14 14:16:32 -04:00
|
|
|
connect(editAct, SIGNAL(triggered()), this, SLOT(editmessage()));
|
|
|
|
contextMnu.addAction(editAct);
|
|
|
|
|
|
|
|
if (nCount == 1) {
|
|
|
|
editAct->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
editAct->setDisabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *markAsRead = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Mark as read" ), &contextMnu);
|
2010-05-23 13:21:30 -04:00
|
|
|
connect(markAsRead , SIGNAL(triggered()), this, SLOT(markAsRead()));
|
|
|
|
contextMnu.addAction(markAsRead);
|
|
|
|
if (RowsUnread.size() == 0) {
|
|
|
|
markAsRead->setDisabled(true);
|
|
|
|
}
|
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *markAsUnread = new QAction(QIcon(":/images/message-mail.png"), tr( "Mark as unread" ), &contextMnu);
|
2010-05-23 13:21:30 -04:00
|
|
|
connect(markAsUnread , SIGNAL(triggered()), this, SLOT(markAsUnread()));
|
|
|
|
contextMnu.addAction(markAsUnread);
|
|
|
|
if (RowsRead.size() == 0) {
|
|
|
|
markAsUnread->setDisabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
contextMnu.addSeparator();
|
2010-05-27 15:48:52 -04:00
|
|
|
|
|
|
|
// add tags
|
|
|
|
contextMnu.addMenu(ui.tagButton->menu());
|
|
|
|
contextMnu.addSeparator();
|
2010-05-23 13:21:30 -04:00
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
QAction *removemsgAct;
|
2010-06-14 14:16:32 -04:00
|
|
|
if (nCount > 1) {
|
2010-07-15 07:25:34 -04:00
|
|
|
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Messages" ), &contextMnu );
|
2010-05-26 11:20:31 -04:00
|
|
|
} else {
|
2010-07-15 07:25:34 -04:00
|
|
|
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Message" ), &contextMnu );
|
2010-05-26 11:20:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
connect( removemsgAct , SIGNAL( triggered() ), this, SLOT( removemessage() ) );
|
|
|
|
contextMnu.addAction( removemsgAct);
|
|
|
|
|
2010-05-28 10:42:54 -04:00
|
|
|
int listrow = ui.listWidget -> currentRow();
|
|
|
|
if (listrow == ROW_TRASHBOX) {
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *undeleteAct = new QAction(tr( "Undelete" ), &contextMnu );
|
2010-05-28 10:42:54 -04:00
|
|
|
connect(undeleteAct, SIGNAL(triggered()), this, SLOT(undeletemessage()));
|
|
|
|
contextMnu.addAction(undeleteAct);
|
|
|
|
|
|
|
|
if (nCount) {
|
|
|
|
undeleteAct->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
undeleteAct->setDisabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-26 11:20:31 -04:00
|
|
|
contextMnu.addAction( ui.actionSave_as);
|
|
|
|
contextMnu.addAction( ui.actionPrintPreview);
|
|
|
|
contextMnu.addAction( ui.actionPrint);
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *newmsgAct = new QAction(QIcon(IMAGE_MESSAGE), tr( "New Message" ), &contextMnu );
|
2010-05-07 18:23:38 -04:00
|
|
|
connect( newmsgAct , SIGNAL( triggered() ), this, SLOT( newmessage() ) );
|
|
|
|
contextMnu.addAction( newmsgAct);
|
|
|
|
|
|
|
|
if (nCount != 1) {
|
|
|
|
replytomsgAct->setDisabled(true);
|
|
|
|
replyallmsgAct->setDisabled(true);
|
|
|
|
forwardmsgAct->setDisabled(true);
|
|
|
|
}
|
|
|
|
if (nCount == 0) {
|
|
|
|
removemsgAct->setDisabled(true);
|
|
|
|
}
|
|
|
|
|
2010-05-14 16:55:44 -04:00
|
|
|
contextMnu.exec(QCursor::pos());
|
2008-09-04 15:28:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MessagesDialog::msgfilelistWidgetCostumPopupMenu( QPoint point )
|
|
|
|
{
|
2010-05-07 18:23:38 -04:00
|
|
|
QMenu contextMnu( this );
|
2008-09-04 15:28:35 -04:00
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction* getRecAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), &contextMnu );
|
2010-05-07 18:23:38 -04:00
|
|
|
connect( getRecAct , SIGNAL( triggered() ), this, SLOT( getcurrentrecommended() ) );
|
2010-05-23 13:21:30 -04:00
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
// QAction* getAllRecAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Download" ), &contextMnu );
|
2010-05-07 18:23:38 -04:00
|
|
|
// connect( getAllRecAct , SIGNAL( triggered() ), this, SLOT( getallrecommended() ) );
|
2008-09-04 15:28:35 -04:00
|
|
|
|
2010-05-07 18:23:38 -04:00
|
|
|
contextMnu.addAction( getRecAct);
|
|
|
|
// contextMnu.addAction( getAllRecAct);
|
2010-05-14 16:55:44 -04:00
|
|
|
contextMnu.exec(QCursor::pos());
|
2008-09-04 15:28:35 -04:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
void MessagesDialog::newmessage()
|
|
|
|
{
|
2010-05-25 05:32:14 -04:00
|
|
|
MessageComposer *nMsgDialog = new MessageComposer();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* fill it in */
|
|
|
|
//std::cerr << "MessagesDialog::newmessage()" << std::endl;
|
|
|
|
nMsgDialog->newMsg();
|
|
|
|
nMsgDialog->show();
|
2007-11-18 18:35:53 -05:00
|
|
|
nMsgDialog->activateWindow();
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* window will destroy itself! */
|
|
|
|
}
|
|
|
|
|
2010-06-14 14:16:32 -04:00
|
|
|
void MessagesDialog::editmessage()
|
|
|
|
{
|
|
|
|
std::string cid;
|
|
|
|
std::string mid;
|
|
|
|
|
|
|
|
if(!getCurrentMsg(cid, mid))
|
|
|
|
return ;
|
|
|
|
|
|
|
|
MessageInfo msgInfo;
|
|
|
|
if (!rsMsgs->getMessage(mid, msgInfo)) {
|
|
|
|
std::cerr << "MessagesDialog::editmessage() Couldn't find Msg" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageComposer *pMsgDialog = new MessageComposer();
|
|
|
|
/* fill it in */
|
|
|
|
pMsgDialog->newMsg(msgInfo.msgId);
|
|
|
|
|
|
|
|
pMsgDialog->show();
|
|
|
|
pMsgDialog->activateWindow();
|
|
|
|
|
|
|
|
/* window will destroy itself! */
|
|
|
|
}
|
|
|
|
|
2008-09-04 15:28:35 -04:00
|
|
|
void MessagesDialog::replytomessage()
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
/* put msg on msgBoard, and switch to it. */
|
|
|
|
|
|
|
|
std::string cid;
|
|
|
|
std::string mid;
|
|
|
|
|
|
|
|
if(!getCurrentMsg(cid, mid))
|
|
|
|
return ;
|
|
|
|
|
|
|
|
mCurrCertId = cid;
|
|
|
|
mCurrMsgId = mid;
|
|
|
|
|
|
|
|
MessageInfo msgInfo;
|
|
|
|
if (!rsMsgs -> getMessage(mid, msgInfo))
|
|
|
|
return ;
|
|
|
|
|
2010-05-25 05:32:14 -04:00
|
|
|
MessageComposer *nMsgDialog = new MessageComposer();
|
2010-05-23 13:21:30 -04:00
|
|
|
/* fill it in */
|
|
|
|
//std::cerr << "MessagesDialog::newmessage()" << std::endl;
|
|
|
|
nMsgDialog->newMsg();
|
|
|
|
|
|
|
|
QString text = QString::fromStdWString(msgInfo.title);
|
|
|
|
|
|
|
|
if (text.startsWith("Re:", Qt::CaseInsensitive))
|
|
|
|
{
|
2010-01-15 21:42:11 -05:00
|
|
|
nMsgDialog->insertTitleText( QString::fromStdWString(msgInfo.title).toStdString()) ;
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-09-03 08:56:37 -04:00
|
|
|
nMsgDialog->insertTitleText( (QString("Re: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
2008-11-25 20:19:09 -05:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
nMsgDialog->setWindowTitle( tr ("Compose: ") + tr("Re: ") + QString::fromStdWString(msgInfo.title) ) ;
|
2008-09-03 08:56:37 -04:00
|
|
|
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
QTextDocument doc ;
|
|
|
|
doc.setHtml(QString::fromStdWString(msgInfo.msg)) ;
|
|
|
|
std::string cited_text(doc.toPlainText().toStdString()) ;
|
2010-05-02 20:09:55 -04:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
nMsgDialog->insertPastedText(cited_text) ;
|
|
|
|
nMsgDialog->addRecipient( msgInfo.srcId ) ;
|
|
|
|
nMsgDialog->show();
|
|
|
|
nMsgDialog->activateWindow();
|
|
|
|
|
|
|
|
/* window will destroy itself! */
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2009-02-09 08:24:05 -05:00
|
|
|
void MessagesDialog::replyallmessage()
|
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
/* put msg on msgBoard, and switch to it. */
|
|
|
|
|
|
|
|
std::string cid;
|
|
|
|
std::string mid;
|
|
|
|
|
|
|
|
if(!getCurrentMsg(cid, mid))
|
|
|
|
return ;
|
|
|
|
|
|
|
|
mCurrCertId = cid;
|
|
|
|
mCurrMsgId = mid;
|
|
|
|
|
|
|
|
MessageInfo msgInfo;
|
|
|
|
if (!rsMsgs -> getMessage(mid, msgInfo))
|
|
|
|
return ;
|
|
|
|
|
2010-05-25 05:32:14 -04:00
|
|
|
MessageComposer *nMsgDialog = new MessageComposer();
|
2010-05-23 13:21:30 -04:00
|
|
|
/* fill it in */
|
|
|
|
//std::cerr << "MessagesDialog::newmessage()" << std::endl;
|
|
|
|
nMsgDialog->newMsg();
|
|
|
|
|
|
|
|
QString text = QString::fromStdWString(msgInfo.title);
|
|
|
|
|
|
|
|
if (text.startsWith("Re:", Qt::CaseInsensitive))
|
|
|
|
{
|
2010-01-15 21:42:11 -05:00
|
|
|
nMsgDialog->insertTitleText( QString::fromStdWString(msgInfo.title).toStdString()) ;
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-09 08:24:05 -05:00
|
|
|
nMsgDialog->insertTitleText( (QString("Re: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
nMsgDialog->setWindowTitle( tr ("Compose: ") + tr("Re: ") + QString::fromStdWString(msgInfo.title) ) ;
|
2009-02-09 08:24:05 -05:00
|
|
|
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
QTextDocument doc ;
|
|
|
|
doc.setHtml(QString::fromStdWString(msgInfo.msg)) ;
|
|
|
|
std::string cited_text(doc.toPlainText().toStdString()) ;
|
|
|
|
|
|
|
|
nMsgDialog->insertPastedText(cited_text) ;
|
|
|
|
nMsgDialog->addRecipient( msgInfo.srcId ) ;
|
2009-02-09 08:24:05 -05:00
|
|
|
|
2009-02-11 13:43:37 -05:00
|
|
|
std::list<std::string> tl ( msgInfo.msgto );
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
for ( std::list<std::string>::iterator tli = tl.begin(); tli!= tl.end(); tli++ )
|
2009-02-11 13:43:37 -05:00
|
|
|
{
|
|
|
|
nMsgDialog->addRecipient( *tli ) ;
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
2010-05-02 20:09:55 -04:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
nMsgDialog->show();
|
|
|
|
nMsgDialog->activateWindow();
|
|
|
|
|
|
|
|
/* window will destroy itself! */
|
2009-02-09 08:24:05 -05:00
|
|
|
}
|
|
|
|
|
2008-11-25 20:19:09 -05:00
|
|
|
void MessagesDialog::forwardmessage()
|
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
/* put msg on msgBoard, and switch to it. */
|
|
|
|
|
|
|
|
std::string cid;
|
|
|
|
std::string mid;
|
|
|
|
|
|
|
|
if(!getCurrentMsg(cid, mid))
|
|
|
|
return ;
|
|
|
|
|
|
|
|
mCurrCertId = cid;
|
|
|
|
mCurrMsgId = mid;
|
|
|
|
|
|
|
|
MessageInfo msgInfo;
|
|
|
|
if (!rsMsgs -> getMessage(mid, msgInfo))
|
|
|
|
return ;
|
|
|
|
|
2010-05-25 05:32:14 -04:00
|
|
|
MessageComposer *nMsgDialog = new MessageComposer();
|
2010-05-23 13:21:30 -04:00
|
|
|
/* fill it in */
|
|
|
|
//std::cerr << "MessagesDialog::newmessage()" << std::endl;
|
|
|
|
nMsgDialog->newMsg();
|
|
|
|
|
|
|
|
QString text = QString::fromStdWString(msgInfo.title);
|
|
|
|
|
|
|
|
if (text.startsWith("Fwd:", Qt::CaseInsensitive))
|
|
|
|
{
|
2010-01-15 21:42:11 -05:00
|
|
|
nMsgDialog->insertTitleText( QString::fromStdWString(msgInfo.title).toStdString()) ;
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-25 20:19:09 -05:00
|
|
|
nMsgDialog->insertTitleText( (QString("Fwd: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
2008-11-25 20:19:09 -05:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
nMsgDialog->setWindowTitle( tr ("Compose: ") + tr("Fwd: ") + QString::fromStdWString(msgInfo.title) ) ;
|
2008-11-25 20:19:09 -05:00
|
|
|
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
QTextDocument doc ;
|
|
|
|
doc.setHtml(QString::fromStdWString(msgInfo.msg)) ;
|
|
|
|
std::string cited_text(doc.toPlainText().toStdString()) ;
|
2010-04-26 17:11:19 -04:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
nMsgDialog->insertForwardPastedText(cited_text) ;
|
2010-04-26 17:11:19 -04:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
std::list<FileInfo>& files_info = msgInfo.files;
|
2010-04-26 17:11:19 -04:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
/* enable all files for sending */
|
|
|
|
std::list<FileInfo>::iterator it;
|
|
|
|
for(it = files_info.begin(); it != files_info.end(); it++)
|
|
|
|
{
|
|
|
|
it->inRecommend = true;
|
|
|
|
}
|
2010-05-02 20:09:55 -04:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
nMsgDialog->insertFileList(files_info);
|
|
|
|
//nMsgDialog->addRecipient( msgInfo.srcId ) ;
|
|
|
|
nMsgDialog->show();
|
|
|
|
nMsgDialog->activateWindow();
|
|
|
|
|
|
|
|
/* window will destroy itself! */
|
2008-11-25 20:19:09 -05:00
|
|
|
}
|
|
|
|
|
2010-05-18 18:37:18 -04:00
|
|
|
void MessagesDialog::togglefileview_internal()
|
2008-01-26 08:08:28 -05:00
|
|
|
{
|
2010-05-18 18:37:18 -04:00
|
|
|
/* if msg header visible -> change icon and tooltip
|
|
|
|
* three widgets...
|
|
|
|
*/
|
2008-01-26 08:08:28 -05:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
if (ui.expandFilesButton->isChecked()) {
|
2010-05-18 18:37:18 -04:00
|
|
|
ui.expandFilesButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
|
|
|
|
ui.expandFilesButton->setToolTip(tr("Hide"));
|
2010-05-23 13:21:30 -04:00
|
|
|
} else {
|
2010-05-18 18:37:18 -04:00
|
|
|
ui.expandFilesButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
|
|
|
|
ui.expandFilesButton->setToolTip(tr("Expand"));
|
|
|
|
}
|
|
|
|
}
|
2008-01-26 08:08:28 -05:00
|
|
|
|
2010-05-18 18:37:18 -04:00
|
|
|
void MessagesDialog::togglefileview()
|
|
|
|
{
|
|
|
|
// save state of files view
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setValueToGroup("MessageDialog", "expandFiles", ui.expandFilesButton->isChecked());
|
2010-05-18 18:37:18 -04:00
|
|
|
|
|
|
|
togglefileview_internal();
|
2008-01-26 08:08:28 -05:00
|
|
|
}
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* download the recommendations... */
|
|
|
|
void MessagesDialog::getcurrentrecommended()
|
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
MessageInfo msgInfo;
|
|
|
|
if (!rsMsgs -> getMessage(mCurrMsgId, msgInfo))
|
|
|
|
return;
|
|
|
|
|
|
|
|
std::list<std::string> srcIds;
|
|
|
|
srcIds.push_back(msgInfo.srcId);
|
|
|
|
|
|
|
|
QModelIndexList list = ui.msgList->selectionModel()->selectedIndexes();
|
|
|
|
|
|
|
|
std::map<int,FileInfo> files ;
|
|
|
|
|
|
|
|
for(QModelIndexList::const_iterator it(list.begin());it!=list.end();++it)
|
|
|
|
{
|
|
|
|
FileInfo& f(files[it->row()]) ;
|
|
|
|
|
|
|
|
switch(it->column())
|
|
|
|
{
|
|
|
|
case 0: f.fname = it->data().toString().toStdString() ;
|
|
|
|
break ;
|
|
|
|
case 1: f.size = it->data().toULongLong() ;
|
|
|
|
break ;
|
|
|
|
case 3: f.hash = it->data().toString().toStdString() ;
|
|
|
|
break ;
|
|
|
|
default: ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(std::map<int,FileInfo>::const_iterator it(files.begin());it!=files.end();++it)
|
|
|
|
{
|
|
|
|
const FileInfo& f(it->second) ;
|
|
|
|
std::cout << "Requesting file " << f.fname << ", size=" << f.size << ", hash=" << f.hash << std::endl ;
|
|
|
|
rsFiles -> FileRequest(it->second.fname,it->second.hash,it->second.size, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds);
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
#if 0
|
2007-11-14 22:18:48 -05:00
|
|
|
void MessagesDialog::getallrecommended()
|
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
/* get Message */
|
|
|
|
MessageInfo msgInfo;
|
|
|
|
if (!rsMsgs -> getMessage(mCurrMsgId, msgInfo))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::list<FileInfo> &recList = msgInfo.files;
|
|
|
|
std::list<FileInfo>::const_iterator it;
|
|
|
|
|
|
|
|
std::list<std::string> fnames;
|
|
|
|
std::list<std::string> hashes;
|
|
|
|
std::list<int> sizes;
|
|
|
|
|
|
|
|
for(it = recList.begin(); it != recList.end(); it++)
|
|
|
|
{
|
|
|
|
fnames.push_back(it->fname);
|
|
|
|
hashes.push_back(it->hash);
|
|
|
|
sizes.push_back(it->size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now do requests */
|
|
|
|
std::list<std::string>::const_iterator fit;
|
|
|
|
std::list<std::string>::const_iterator hit;
|
|
|
|
std::list<int>::const_iterator sit;
|
|
|
|
|
|
|
|
for(fit = fnames.begin(), hit = hashes.begin(), sit = sizes.begin(); fit != fnames.end(); fit++, hit++, sit++)
|
|
|
|
{
|
|
|
|
std::cerr << "MessagesDialog::getallrecommended() Calling File Request";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
std::list<std::string> srcIds;
|
|
|
|
srcIds.push_back(msgInfo.srcId);
|
|
|
|
rsFiles -> FileRequest(*fit, *hit, *sit, "", 0, srcIds);
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
2009-05-17 15:38:42 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-22 12:36:39 -05:00
|
|
|
void MessagesDialog::changeBox(int)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2010-06-01 18:14:52 -04:00
|
|
|
if (m_bInChange) {
|
|
|
|
// already in change method
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_bInChange = true;
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
MessagesModel->removeRows (0, MessagesModel->rowCount());
|
2010-05-07 18:23:38 -04:00
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
ui.tagWidget->setCurrentItem(NULL);
|
|
|
|
m_eListMode = LIST_BOX;
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
insertMessages();
|
|
|
|
insertMsgTxtAndFiles();
|
2010-06-01 18:14:52 -04:00
|
|
|
|
|
|
|
m_bInChange = false;
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
void MessagesDialog::changeTag(int)
|
|
|
|
{
|
|
|
|
if (m_bInChange) {
|
|
|
|
// already in change method
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_bInChange = true;
|
|
|
|
|
|
|
|
MessagesModel->removeRows (0, MessagesModel->rowCount());
|
|
|
|
|
|
|
|
ui.listWidget->setCurrentItem(NULL);
|
|
|
|
m_eListMode = LIST_TAG;
|
|
|
|
|
|
|
|
insertMessages();
|
|
|
|
insertMsgTxtAndFiles();
|
|
|
|
|
|
|
|
m_bInChange = false;
|
|
|
|
}
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
static void InitIconAndFont(RSettings *pConfig, QStandardItem *pItem [COLUMN_COUNT], int nFlag)
|
|
|
|
{
|
|
|
|
QString sText = pItem [COLUMN_SUBJECT]->text();
|
2010-06-25 08:17:46 -04:00
|
|
|
QString mid = pItem [COLUMN_DATA]->data(ROLE_MSGID).toString();
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
bool bNew = (nFlag & RS_MSG_NEW);
|
|
|
|
|
|
|
|
// show the real "New" state
|
|
|
|
if (bNew) {
|
|
|
|
if (sText.startsWith("Re:", Qt::CaseInsensitive)) {
|
|
|
|
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-replied.png"));
|
|
|
|
} else if (sText.startsWith("Fwd:", Qt::CaseInsensitive)) {
|
|
|
|
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-forwarded.png"));
|
|
|
|
} else {
|
|
|
|
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail.png"));
|
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-state-new.png"));
|
2010-05-23 13:21:30 -04:00
|
|
|
} else {
|
|
|
|
// Change Message icon when Subject is Re: or Fwd:
|
|
|
|
if (sText.startsWith("Re:", Qt::CaseInsensitive)) {
|
|
|
|
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-replied-read.png"));
|
|
|
|
} else if (sText.startsWith("Fwd:", Qt::CaseInsensitive)) {
|
|
|
|
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-forwarded-read.png"));
|
|
|
|
} else {
|
|
|
|
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-read.png"));
|
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
pItem[COLUMN_SUBJECT]->setIcon(QIcon());
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// show the locale "New" state
|
|
|
|
if (bNew == false) {
|
|
|
|
// check locale config
|
|
|
|
pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
|
|
|
bNew = pConfig->value(mid, false).toBool();
|
|
|
|
pConfig->endGroup();
|
|
|
|
}
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
// set icon
|
2010-05-23 13:21:30 -04:00
|
|
|
if (bNew) {
|
2010-08-08 18:58:10 -04:00
|
|
|
pItem[COLUMN_UNREAD]->setIcon(QIcon(":/images/message-state-unread.png"));
|
2010-05-23 13:21:30 -04:00
|
|
|
} else {
|
2010-08-08 18:58:10 -04:00
|
|
|
pItem[COLUMN_UNREAD]->setIcon(QIcon(":/images/message-state-read.png"));
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// set font
|
|
|
|
for (int i = 0; i < COLUMN_COUNT; i++) {
|
|
|
|
QFont qf = pItem[i]->font();
|
|
|
|
qf.setBold(bNew);
|
|
|
|
pItem[i]->setFont(qf);
|
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
|
|
|
|
pItem[COLUMN_DATA]->setData(bNew, ROLE_UNREAD);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MessagesDialog::insertMessages()
|
|
|
|
{
|
2010-06-03 18:12:07 -04:00
|
|
|
if (m_nLockUpdate) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
std::cerr <<"MessagesDialog::insertMessages called";
|
|
|
|
fflush(0);
|
|
|
|
|
|
|
|
std::list<MsgInfoSummary> msgList;
|
|
|
|
std::list<MsgInfoSummary>::const_iterator it;
|
|
|
|
MessageInfo msgInfo;
|
|
|
|
bool bGotInfo;
|
|
|
|
QString text;
|
|
|
|
|
|
|
|
rsMsgs -> getMessageSummaries(msgList);
|
|
|
|
|
|
|
|
std::cerr << "MessagesDialog::insertMessages()" << std::endl;
|
|
|
|
fflush(0);
|
|
|
|
|
|
|
|
int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
|
|
|
|
|
|
|
|
/* check the mode we are in */
|
|
|
|
unsigned int msgbox = 0;
|
2010-05-28 10:42:54 -04:00
|
|
|
bool bTrash = false;
|
2010-05-23 13:21:30 -04:00
|
|
|
bool bFill = true;
|
2010-06-01 18:14:52 -04:00
|
|
|
int nTagId = 0;
|
|
|
|
|
|
|
|
switch (m_eListMode) {
|
|
|
|
case LIST_NOTHING:
|
|
|
|
bFill = false;
|
2010-05-23 13:21:30 -04:00
|
|
|
break;
|
2010-06-01 18:14:52 -04:00
|
|
|
|
|
|
|
case LIST_BOX:
|
|
|
|
{
|
|
|
|
int listrow = ui.listWidget->currentRow();
|
|
|
|
|
|
|
|
switch (listrow) {
|
|
|
|
case ROW_INBOX:
|
|
|
|
msgbox = RS_MSG_INBOX;
|
2010-06-03 19:41:46 -04:00
|
|
|
ui.tabWidget->setTabIcon ( 0, QIcon(":/images/folder-inbox.png") );
|
|
|
|
ui.tabWidget->setTabText ( 0, tr ("Inbox") );
|
2010-06-01 18:14:52 -04:00
|
|
|
break;
|
|
|
|
case ROW_OUTBOX:
|
|
|
|
msgbox = RS_MSG_OUTBOX;
|
2010-06-03 19:41:46 -04:00
|
|
|
ui.tabWidget->setTabIcon ( 0, QIcon(":/images/folder-outbox.png") );
|
|
|
|
ui.tabWidget->setTabText ( 0, tr ("Outbox") );
|
2010-06-01 18:14:52 -04:00
|
|
|
break;
|
|
|
|
case ROW_DRAFTBOX:
|
|
|
|
msgbox = RS_MSG_DRAFTBOX;
|
2010-06-03 19:41:46 -04:00
|
|
|
ui.tabWidget->setTabIcon ( 0, QIcon(":/images/folder-draft.png") );
|
|
|
|
ui.tabWidget->setTabText ( 0, tr ("Drafts") );
|
2010-06-01 18:14:52 -04:00
|
|
|
break;
|
|
|
|
case ROW_SENTBOX:
|
|
|
|
msgbox = RS_MSG_SENTBOX;
|
2010-06-03 19:41:46 -04:00
|
|
|
ui.tabWidget->setTabIcon ( 0, QIcon(":/images/folder-sent.png") );
|
|
|
|
ui.tabWidget->setTabText ( 0, tr ("Sent") );
|
2010-06-01 18:14:52 -04:00
|
|
|
break;
|
|
|
|
case ROW_TRASHBOX:
|
|
|
|
bTrash = true;
|
2010-06-03 19:41:46 -04:00
|
|
|
ui.tabWidget->setTabIcon ( 0, QIcon(":/images/folder-trash.png") );
|
|
|
|
ui.tabWidget->setTabText ( 0, tr ("Trash") );
|
2010-06-01 18:14:52 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
bFill = false;
|
|
|
|
}
|
|
|
|
}
|
2010-05-23 13:21:30 -04:00
|
|
|
break;
|
2010-06-01 18:14:52 -04:00
|
|
|
|
|
|
|
case LIST_TAG:
|
|
|
|
{
|
|
|
|
QListWidgetItem *pItem = ui.tagWidget->currentItem();
|
|
|
|
if (pItem) {
|
|
|
|
nTagId = pItem->data (Qt::UserRole).toInt();
|
|
|
|
} else {
|
|
|
|
bFill = false;
|
|
|
|
}
|
|
|
|
}
|
2010-05-23 13:21:30 -04:00
|
|
|
break;
|
2010-06-01 18:14:52 -04:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
default:
|
|
|
|
bFill = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msgbox == RS_MSG_INBOX) {
|
|
|
|
MessagesModel->setHeaderData(COLUMN_FROM, Qt::Horizontal, tr("From"));
|
|
|
|
} else {
|
|
|
|
MessagesModel->setHeaderData(COLUMN_FROM, Qt::Horizontal, tr("To"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bFill) {
|
2010-05-27 15:48:52 -04:00
|
|
|
std::map<int, TagItem> TagItems;
|
|
|
|
getTagItems(TagItems);
|
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
/* search messages */
|
|
|
|
std::list<MsgInfoSummary> msgToShow;
|
|
|
|
for(it = msgList.begin(); it != msgList.end(); it++) {
|
|
|
|
if (m_eListMode == LIST_BOX) {
|
2010-05-28 10:42:54 -04:00
|
|
|
if (bTrash) {
|
|
|
|
if ((it->msgflags & RS_MSG_TRASH) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (it->msgflags & RS_MSG_TRASH) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((it->msgflags & RS_MSG_BOXMASK) != msgbox) {
|
|
|
|
continue;
|
|
|
|
}
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
2010-06-01 18:14:52 -04:00
|
|
|
} else if (m_eListMode == LIST_TAG) {
|
|
|
|
QList<int> tagIds;
|
|
|
|
getMessageTags (m_pConfig, QString::fromStdString(it->msgId), tagIds);
|
|
|
|
if (qFind(tagIds.begin(), tagIds.end(), nTagId) == tagIds.end()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
2010-05-23 13:21:30 -04:00
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
msgToShow.push_back(*it);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove old items */
|
|
|
|
int nRowCount = MessagesModel->rowCount();
|
|
|
|
int nRow = 0;
|
|
|
|
for (nRow = 0; nRow < nRowCount; ) {
|
2010-06-25 08:17:46 -04:00
|
|
|
std::string msgIdFromRow = MessagesModel->item(nRow, COLUMN_DATA)->data(ROLE_MSGID).toString().toStdString();
|
2010-06-01 18:14:52 -04:00
|
|
|
for(it = msgToShow.begin(); it != msgToShow.end(); it++) {
|
|
|
|
if (it->msgId == msgIdFromRow) {
|
2010-05-23 13:21:30 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
if (it == msgToShow.end ()) {
|
2010-05-23 13:21:30 -04:00
|
|
|
MessagesModel->removeRow (nRow);
|
|
|
|
nRowCount = MessagesModel->rowCount();
|
|
|
|
} else {
|
|
|
|
nRow++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
for(it = msgToShow.begin(); it != msgToShow.end(); it++)
|
2010-05-23 13:21:30 -04:00
|
|
|
{
|
|
|
|
/* check the message flags, to decide which
|
|
|
|
* group it should go in...
|
|
|
|
*
|
|
|
|
* InBox
|
|
|
|
* OutBox
|
|
|
|
* Drafts
|
|
|
|
* Sent
|
|
|
|
*
|
|
|
|
* FLAGS = OUTGOING.
|
|
|
|
* -> Outbox/Drafts/Sent
|
|
|
|
* + SENT -> Sent
|
|
|
|
* + IN_PROGRESS -> Draft.
|
|
|
|
* + nuffing -> Outbox.
|
|
|
|
* FLAGS = INCOMING = (!OUTGOING)
|
|
|
|
* -> + NEW -> Bold.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
bGotInfo = false;
|
|
|
|
msgInfo = MessageInfo(); // clear
|
|
|
|
|
|
|
|
// search exisisting items
|
|
|
|
nRowCount = MessagesModel->rowCount();
|
|
|
|
for (nRow = 0; nRow < nRowCount; nRow++) {
|
2010-06-25 08:17:46 -04:00
|
|
|
if (it->msgId == MessagesModel->item(nRow, COLUMN_DATA)->data(ROLE_MSGID).toString().toStdString()) {
|
2010-05-23 13:21:30 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make a widget per friend */
|
|
|
|
|
|
|
|
QStandardItem *item [COLUMN_COUNT];
|
|
|
|
|
|
|
|
bool bInsert = false;
|
|
|
|
|
|
|
|
if (nRow < nRowCount) {
|
2010-05-27 15:48:52 -04:00
|
|
|
for (int i = 0; i < COLUMN_COUNT; i++) {
|
2010-05-23 13:21:30 -04:00
|
|
|
item[i] = MessagesModel->item(nRow, i);
|
|
|
|
}
|
|
|
|
} else {
|
2010-05-27 15:48:52 -04:00
|
|
|
for (int i = 0; i < COLUMN_COUNT; i++) {
|
2010-05-23 13:21:30 -04:00
|
|
|
item[i] = new QStandardItem();
|
|
|
|
}
|
|
|
|
bInsert = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//set this false if you want to expand on double click
|
2010-05-27 15:48:52 -04:00
|
|
|
for (int i = 0; i < COLUMN_COUNT; i++) {
|
2010-05-23 13:21:30 -04:00
|
|
|
item[i]->setEditable(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* So Text should be:
|
|
|
|
* (1) Msg / Broadcast
|
|
|
|
* (1b) Person / Channel Name
|
|
|
|
* (2) Rank
|
|
|
|
* (3) Date
|
|
|
|
* (4) Title
|
|
|
|
* (5) Msg
|
|
|
|
* (6) File Count
|
|
|
|
* (7) File Total
|
|
|
|
*/
|
|
|
|
|
|
|
|
QString dateString;
|
|
|
|
// Date First.... (for sorting)
|
|
|
|
{
|
|
|
|
QDateTime qdatetime;
|
|
|
|
qdatetime.setTime_t(it->ts);
|
|
|
|
|
|
|
|
// add string to all data
|
|
|
|
dateString = qdatetime.toString("_yyyyMMdd_hhmmss");
|
|
|
|
|
|
|
|
//if the mail is on same date show only time.
|
|
|
|
if (qdatetime.daysTo(QDateTime::currentDateTime()) == 0)
|
|
|
|
{
|
|
|
|
QTime qtime = qdatetime.time();
|
|
|
|
QVariant varTime(qtime);
|
|
|
|
item[COLUMN_DATE]->setData(varTime, Qt::DisplayRole);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QVariant varDateTime(qdatetime);
|
|
|
|
item[COLUMN_DATE]->setData(varDateTime, Qt::DisplayRole);
|
|
|
|
}
|
|
|
|
// for sorting
|
2010-06-25 08:17:46 -04:00
|
|
|
item[COLUMN_DATE]->setData(qdatetime, ROLE_SORT);
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// From ....
|
|
|
|
{
|
2010-05-25 05:32:14 -04:00
|
|
|
if (msgbox == RS_MSG_INBOX || msgbox == RS_MSG_OUTBOX) {
|
2010-05-23 13:21:30 -04:00
|
|
|
text = QString::fromStdString(rsPeers->getPeerName(it->srcId));
|
|
|
|
} else {
|
|
|
|
if (bGotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) {
|
|
|
|
bGotInfo = true;
|
|
|
|
|
|
|
|
text.clear();
|
|
|
|
|
|
|
|
std::list<std::string>::const_iterator pit;
|
|
|
|
for (pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++)
|
|
|
|
{
|
|
|
|
if (text.isEmpty() == false) {
|
2010-05-23 14:31:40 -04:00
|
|
|
text += ", ";
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
QString sPeer = QString::fromStdString(rsPeers->getPeerName(*pit));
|
|
|
|
if (sPeer.isEmpty()) {
|
|
|
|
text += tr("Anonymous") + "@" + QString::fromStdString(*pit);
|
|
|
|
} else {
|
|
|
|
text += sPeer;
|
|
|
|
}
|
2010-05-07 18:23:38 -04:00
|
|
|
}
|
2010-05-23 13:21:30 -04:00
|
|
|
} else {
|
|
|
|
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
item[COLUMN_FROM]->setText(text);
|
2010-06-25 08:17:46 -04:00
|
|
|
item[COLUMN_FROM]->setData(text + dateString, ROLE_SORT);
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Subject
|
|
|
|
text = QString::fromStdWString(it->title);
|
|
|
|
item[COLUMN_SUBJECT]->setText(text);
|
2010-06-25 08:17:46 -04:00
|
|
|
item[COLUMN_SUBJECT]->setData(text + dateString, ROLE_SORT);
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
// internal data
|
2010-05-27 15:48:52 -04:00
|
|
|
QString msgId = QString::fromStdString(it->msgId);
|
2010-06-25 08:17:46 -04:00
|
|
|
item[COLUMN_DATA]->setData(QString::fromStdString(it->srcId), ROLE_SRCID);
|
|
|
|
item[COLUMN_DATA]->setData(msgId, ROLE_MSGID);
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
// Init icon and font
|
|
|
|
InitIconAndFont(m_pConfig, item, it->msgflags);
|
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
// Tags
|
|
|
|
QList<int> tagIds;
|
|
|
|
getMessageTags (m_pConfig, msgId, tagIds);
|
|
|
|
qSort(tagIds.begin(), tagIds.end());
|
|
|
|
|
|
|
|
text.clear();
|
|
|
|
|
|
|
|
for (QList<int>::iterator tagId = tagIds.begin(); tagId != tagIds.end(); tagId++) {
|
|
|
|
if (text.isEmpty() == false) {
|
|
|
|
text += ",";
|
|
|
|
}
|
|
|
|
text += TagItems[*tagId].text;
|
|
|
|
}
|
|
|
|
item[COLUMN_TAGS]->setText(text);
|
|
|
|
|
|
|
|
// set color
|
|
|
|
QBrush Brush; // standard
|
|
|
|
if (tagIds.size()) {
|
|
|
|
Brush = QBrush(TagItems [tagIds [0]].color);
|
|
|
|
}
|
|
|
|
for (int i = 0; i < COLUMN_COUNT; i++) {
|
|
|
|
item[i]->setForeground(Brush);
|
|
|
|
}
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
// No of Files.
|
|
|
|
{
|
|
|
|
std::ostringstream out;
|
|
|
|
out << it -> count;
|
|
|
|
item[COLUMN_ATTACHEMENTS] -> setText(QString::fromStdString(out.str()));
|
2010-06-25 08:17:46 -04:00
|
|
|
item[COLUMN_ATTACHEMENTS] -> setData(item[COLUMN_ATTACHEMENTS]->text() + dateString, ROLE_SORT);
|
2010-06-19 14:06:04 -04:00
|
|
|
item[COLUMN_ATTACHEMENTS] -> setTextAlignment(Qt::AlignHCenter);
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nFilterColumn == COLUMN_CONTENT) {
|
|
|
|
// need content for filter
|
|
|
|
if (bGotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) {
|
|
|
|
bGotInfo = true;
|
|
|
|
QTextDocument doc;
|
|
|
|
doc.setHtml(QString::fromStdWString(msgInfo.msg));
|
|
|
|
item[COLUMN_CONTENT]->setText(doc.toPlainText().replace(QString("\n"), QString(" ")));
|
|
|
|
} else {
|
|
|
|
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl;
|
|
|
|
item[COLUMN_CONTENT]->setText("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bInsert) {
|
|
|
|
/* add to the list */
|
|
|
|
QList<QStandardItem *> itemList;
|
2010-05-27 15:48:52 -04:00
|
|
|
for (int i = 0; i < COLUMN_COUNT; i++) {
|
2010-05-23 13:21:30 -04:00
|
|
|
itemList.append(item[i]);
|
|
|
|
}
|
|
|
|
MessagesModel->appendRow(itemList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
MessagesModel->removeRows (0, MessagesModel->rowCount());
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
ui.messagestreeView->showColumn(COLUMN_ATTACHEMENTS);
|
|
|
|
ui.messagestreeView->showColumn(COLUMN_SUBJECT);
|
2010-08-08 18:58:10 -04:00
|
|
|
ui.messagestreeView->showColumn(COLUMN_UNREAD);
|
2010-05-23 13:21:30 -04:00
|
|
|
ui.messagestreeView->showColumn(COLUMN_FROM);
|
|
|
|
ui.messagestreeView->showColumn(COLUMN_DATE);
|
2010-05-27 15:48:52 -04:00
|
|
|
ui.messagestreeView->showColumn(COLUMN_TAGS);
|
2010-05-23 13:21:30 -04:00
|
|
|
ui.messagestreeView->hideColumn(COLUMN_CONTENT);
|
2010-06-01 18:14:52 -04:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
updateMessageSummaryList();
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2010-04-27 17:46:28 -04:00
|
|
|
// current row in messagestreeView has changed
|
|
|
|
void MessagesDialog::currentChanged(const QModelIndex &index )
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2010-04-27 17:46:28 -04:00
|
|
|
timer->stop();
|
|
|
|
timerIndex = index;
|
|
|
|
timer->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
// click in messagestreeView
|
|
|
|
void MessagesDialog::clicked(const QModelIndex &index )
|
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
if (index.isValid() == false) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
if (index.column() == COLUMN_UNREAD) {
|
2010-05-23 13:21:30 -04:00
|
|
|
int mappedRow = proxyModel->mapToSource(index).row();
|
|
|
|
|
|
|
|
QList<int> Rows;
|
|
|
|
Rows.append(mappedRow);
|
|
|
|
setMsgAsReadUnread(Rows, !isMessageRead(mappedRow));
|
|
|
|
insertMsgTxtAndFiles(index, false);
|
|
|
|
updateMessageSummaryList();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-27 17:46:28 -04:00
|
|
|
timer->stop();
|
|
|
|
timerIndex = index;
|
|
|
|
// show current message directly
|
|
|
|
updateCurrentMessage();
|
|
|
|
}
|
|
|
|
|
2010-05-25 05:32:14 -04:00
|
|
|
// double click in messagestreeView
|
|
|
|
void MessagesDialog::doubleClicked(const QModelIndex &index)
|
|
|
|
{
|
2010-06-14 14:16:32 -04:00
|
|
|
/* activate row */
|
|
|
|
clicked (index);
|
2010-05-25 05:32:14 -04:00
|
|
|
|
2010-06-14 14:16:32 -04:00
|
|
|
/* edit message */
|
|
|
|
editmessage();
|
2010-05-25 05:32:14 -04:00
|
|
|
}
|
|
|
|
|
2010-04-27 17:46:28 -04:00
|
|
|
// show current message directly
|
|
|
|
void MessagesDialog::updateCurrentMessage()
|
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
timer->stop();
|
|
|
|
insertMsgTxtAndFiles(timerIndex);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
void MessagesDialog::setMsgAsReadUnread(const QList<int> &Rows, bool bRead)
|
2009-02-22 12:36:39 -05:00
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
for (int nRow = 0; nRow < Rows.size(); nRow++) {
|
|
|
|
QStandardItem* item[COLUMN_COUNT];
|
|
|
|
for(int nCol = 0; nCol < COLUMN_COUNT; nCol++)
|
|
|
|
{
|
|
|
|
item[nCol] = MessagesModel->item(Rows [nRow], nCol);
|
|
|
|
}
|
|
|
|
|
2010-06-25 08:17:46 -04:00
|
|
|
QString mid = item[COLUMN_DATA]->data(ROLE_MSGID).toString();
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
m_pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
|
|
|
if (bRead) {
|
|
|
|
// set as read in config
|
|
|
|
m_pConfig->setValue(mid, false);
|
|
|
|
// set message to read
|
|
|
|
rsMsgs->MessageRead(mid.toStdString());
|
|
|
|
} else {
|
|
|
|
// set as unread in config
|
|
|
|
m_pConfig->setValue(mid, true);
|
|
|
|
}
|
|
|
|
m_pConfig->endGroup();
|
|
|
|
|
|
|
|
InitIconAndFont(m_pConfig, item, 0);
|
|
|
|
}
|
2009-02-22 12:36:39 -05:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
void MessagesDialog::markAsRead()
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
QList<int> RowsUnread;
|
2010-05-27 15:48:52 -04:00
|
|
|
getSelectedMsgCount (NULL, NULL, &RowsUnread);
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
setMsgAsReadUnread (RowsUnread, true);
|
|
|
|
updateMessageSummaryList();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessagesDialog::markAsUnread()
|
|
|
|
{
|
|
|
|
QList<int> RowsRead;
|
2010-05-27 15:48:52 -04:00
|
|
|
getSelectedMsgCount (NULL, &RowsRead, NULL);
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
setMsgAsReadUnread (RowsRead, false);
|
|
|
|
updateMessageSummaryList();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
|
|
|
|
{
|
|
|
|
std::cerr << "MessagesDialog::insertMsgTxtAndFiles()" << std::endl;
|
|
|
|
|
|
|
|
/* get its Ids */
|
|
|
|
std::string cid;
|
|
|
|
std::string mid;
|
|
|
|
|
|
|
|
QModelIndex currentIndex = proxyModel->mapToSource(Index);
|
|
|
|
if (currentIndex.isValid() == false)
|
|
|
|
{
|
|
|
|
/* blank it */
|
|
|
|
ui.dateText-> setText("");
|
|
|
|
ui.toText->setText("");
|
|
|
|
ui.fromText->setText("");
|
|
|
|
ui.filesText->setText("");
|
|
|
|
|
|
|
|
ui.subjectText->setText("");
|
|
|
|
ui.msgList->clear();
|
|
|
|
ui.msgText->clear();
|
|
|
|
|
|
|
|
ui.actionSave_as->setDisabled(true);
|
|
|
|
ui.actionPrintPreview->setDisabled(true);
|
|
|
|
ui.actionPrint->setDisabled(true);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-25 08:17:46 -04:00
|
|
|
QStandardItem *item;
|
|
|
|
item = MessagesModel->item(currentIndex.row(),COLUMN_DATA);
|
|
|
|
if (item == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cid = item->data(ROLE_SRCID).toString().toStdString();
|
|
|
|
mid = item->data(ROLE_MSGID).toString().toStdString();
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
int nCount = getSelectedMsgCount (NULL, NULL, NULL);
|
2010-05-23 13:21:30 -04:00
|
|
|
if (nCount == 1) {
|
|
|
|
ui.actionSave_as->setEnabled(true);
|
|
|
|
ui.actionPrintPreview->setEnabled(true);
|
|
|
|
ui.actionPrint->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
ui.actionSave_as->setDisabled(true);
|
|
|
|
ui.actionPrintPreview->setDisabled(true);
|
|
|
|
ui.actionPrint->setDisabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mCurrMsgId == mid) {
|
|
|
|
// message doesn't changed
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the Data.... for later */
|
|
|
|
|
|
|
|
mCurrCertId = cid;
|
|
|
|
mCurrMsgId = mid;
|
|
|
|
|
|
|
|
MessageInfo msgInfo;
|
|
|
|
if (!rsMsgs -> getMessage(mid, msgInfo))
|
|
|
|
{
|
|
|
|
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<int> Rows;
|
|
|
|
Rows.append(currentIndex.row());
|
|
|
|
|
|
|
|
bool bSetToReadOnActive = Settings->getMsgSetToReadOnActivate();
|
|
|
|
|
|
|
|
if (msgInfo.msgflags & RS_MSG_NEW) {
|
|
|
|
// set to read
|
|
|
|
setMsgAsReadUnread(Rows, true);
|
|
|
|
if (bSetToReadOnActive == false || bSetToRead == false) {
|
|
|
|
// set locally to unread
|
|
|
|
setMsgAsReadUnread(Rows, false);
|
|
|
|
}
|
|
|
|
updateMessageSummaryList();
|
|
|
|
} else {
|
|
|
|
if (bSetToRead && bSetToReadOnActive) {
|
|
|
|
// set to read
|
|
|
|
setMsgAsReadUnread(Rows, true);
|
|
|
|
updateMessageSummaryList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::list<FileInfo> &recList = msgInfo.files;
|
|
|
|
std::list<FileInfo>::const_iterator it;
|
|
|
|
|
|
|
|
/* get a link to the table */
|
|
|
|
QTreeWidget *tree = ui.msgList;
|
|
|
|
|
|
|
|
/* get the MessageInfo */
|
|
|
|
|
|
|
|
tree->clear();
|
2010-06-23 10:09:29 -04:00
|
|
|
tree->setColumnCount(4);
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
QList<QTreeWidgetItem *> items;
|
|
|
|
for(it = recList.begin(); it != recList.end(); it++)
|
|
|
|
{
|
|
|
|
/* make a widget per person */
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
|
|
|
/* (0) Filename */
|
|
|
|
item -> setText(0, QString::fromStdString(it->fname));
|
|
|
|
//std::cerr << "Msg FileItem(" << it->fname.length() << ") :" << it->fname << std::endl;
|
|
|
|
|
|
|
|
item -> setText(1, QString::number(it->size)); /* (1) Size */
|
|
|
|
item -> setText(2, QString::number(0)); /* (2) Rank */ // what is this ???
|
|
|
|
item -> setText(3, QString::fromStdString(it->hash));
|
|
|
|
|
|
|
|
/* add to the list */
|
|
|
|
items.append(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add the items in! */
|
|
|
|
tree->insertTopLevelItems(0, items);
|
|
|
|
|
|
|
|
/* iterate through the sources */
|
|
|
|
std::list<std::string>::const_iterator pit;
|
|
|
|
|
|
|
|
QString msgTxt;
|
|
|
|
for(pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++)
|
|
|
|
{
|
|
|
|
QString sPeer = QString::fromStdString(rsPeers->getPeerName(*pit));
|
|
|
|
if (sPeer.isEmpty())
|
|
|
|
{
|
|
|
|
msgTxt += "<a style='color: black;'href='" + tr("Anonymous") + "@" + QString::fromStdString(*pit) + "'> " + tr("Anonymous") + "</a>" + " ";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
msgTxt += "<a style='color: black;'href='" + sPeer + "@" + QString::fromStdString(*pit) + "'> " + sPeer + "</a>" + " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msgInfo.msgcc.size() > 0)
|
|
|
|
msgTxt += "\nCc: ";
|
|
|
|
for(pit = msgInfo.msgcc.begin(); pit != msgInfo.msgcc.end(); pit++)
|
|
|
|
{
|
|
|
|
QString sPeer = QString::fromStdString(rsPeers->getPeerName(*pit));
|
|
|
|
if (sPeer.isEmpty())
|
|
|
|
{
|
|
|
|
msgTxt += "<a style='color: black;'href='" + tr("Anonymous") + "@" + QString::fromStdString(*pit) + "'> " + tr("Anonymous") + "</a>" + " ";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
msgTxt += "<a style='color: black;'href='" + sPeer + "@" + QString::fromStdString(*pit) + "'> " + sPeer + "</a>" + " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msgInfo.msgbcc.size() > 0)
|
|
|
|
msgTxt += "\nBcc: ";
|
|
|
|
for(pit = msgInfo.msgbcc.begin(); pit != msgInfo.msgbcc.end(); pit++)
|
|
|
|
{
|
|
|
|
QString sPeer = QString::fromStdString(rsPeers->getPeerName(*pit));
|
|
|
|
if (sPeer.isEmpty())
|
|
|
|
{
|
|
|
|
msgTxt += "<a style='color: black;'href='" + tr("Anonymous") + "@" + QString::fromStdString(*pit) + "'> " + tr("Anonymous") + "</a>" + " ";
|
2010-05-07 18:23:38 -04:00
|
|
|
}
|
2010-05-23 13:21:30 -04:00
|
|
|
else
|
|
|
|
msgTxt += "<a style='color: black;'href='" + sPeer + "@" + QString::fromStdString(*pit) + "'> " + sPeer + "</a>" + " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
QDateTime qtime;
|
|
|
|
qtime.setTime_t(msgInfo.ts);
|
|
|
|
QString timestamp = qtime.toString("dd.MM.yyyy hh:mm:ss");
|
|
|
|
ui.dateText-> setText(timestamp);
|
|
|
|
}
|
|
|
|
ui.toText->setText(msgTxt);
|
2010-05-25 05:32:14 -04:00
|
|
|
|
|
|
|
std::string sSrcId;
|
|
|
|
if ((msgInfo.msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX) {
|
|
|
|
// outgoing message are from me
|
|
|
|
sSrcId = rsPeers->getOwnId();
|
|
|
|
} else {
|
|
|
|
sSrcId = msgInfo.srcId;
|
|
|
|
}
|
|
|
|
ui.fromText->setText("<a style='color: blue;' href='" + QString::fromStdString(rsPeers->getPeerName(sSrcId)) + "@" + QString::fromStdString(sSrcId) + "'> " + QString::fromStdString(rsPeers->getPeerName(sSrcId)) +"</a>");
|
|
|
|
ui.fromText->setToolTip(QString::fromStdString(rsPeers->getPeerName(sSrcId)) + "@" + QString::fromStdString(sSrcId));
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
ui.subjectText->setText(QString::fromStdWString(msgInfo.title));
|
|
|
|
ui.msgText->setHtml(QString::fromStdWString(msgInfo.msg));
|
2008-02-04 12:55:59 -05:00
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
{
|
|
|
|
std::ostringstream out;
|
|
|
|
out << "(" << msgInfo.count << " Files)";
|
|
|
|
ui.filesText->setText(QString::fromStdString(out.str()));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Msg Displayed OK!" << std::endl;
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid)
|
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
QModelIndex currentIndex = ui.messagestreeView->currentIndex();
|
|
|
|
currentIndex = proxyModel->mapToSource(currentIndex);
|
|
|
|
int rowSelected = -1;
|
|
|
|
|
|
|
|
/* get its Ids */
|
|
|
|
if (currentIndex.isValid() == false)
|
|
|
|
{
|
|
|
|
//If no message is selected. assume first message is selected.
|
|
|
|
if(MessagesModel->rowCount() == 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rowSelected = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rowSelected = currentIndex.row();
|
|
|
|
}
|
|
|
|
|
2010-06-25 08:17:46 -04:00
|
|
|
QStandardItem *item = MessagesModel->item(rowSelected,COLUMN_DATA);
|
|
|
|
if (item == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
cid = item->data(ROLE_SRCID).toString().toStdString();
|
|
|
|
mid = item->data(ROLE_MSGID).toString().toStdString();
|
2010-05-23 13:21:30 -04:00
|
|
|
return true;
|
2010-02-13 13:49:56 -05:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
void MessagesDialog::removemessage()
|
|
|
|
{
|
2010-06-03 18:12:07 -04:00
|
|
|
LockUpdate Lock (this, true);
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
QList<QModelIndex> selectedIndexList= ui.messagestreeView->selectionModel() -> selectedIndexes ();
|
|
|
|
QList<int> rowList;
|
|
|
|
QModelIndex selectedIndex;
|
|
|
|
|
|
|
|
for(QList<QModelIndex>::iterator it = selectedIndexList.begin(); it != selectedIndexList.end(); it++) {
|
|
|
|
selectedIndex = proxyModel->mapToSource(*it);
|
|
|
|
int row = selectedIndex.row();
|
|
|
|
if (rowList.contains(row) == false)
|
|
|
|
{
|
|
|
|
rowList.append(row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-28 10:42:54 -04:00
|
|
|
bool bDelete = false;
|
2010-06-03 18:12:07 -04:00
|
|
|
int listrow = ui.listWidget->currentRow();
|
2010-05-28 10:42:54 -04:00
|
|
|
if (listrow == ROW_TRASHBOX) {
|
|
|
|
bDelete = true;
|
|
|
|
} else {
|
|
|
|
if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
|
|
|
|
bDelete = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-03 18:12:07 -04:00
|
|
|
for(QList<int>::const_iterator it1 = rowList.begin(); it1 != rowList.end(); it1++) {
|
2010-06-25 08:17:46 -04:00
|
|
|
QStandardItem *pItem = MessagesModel->item((*it1), COLUMN_DATA);
|
2010-06-03 18:12:07 -04:00
|
|
|
if (pItem) {
|
2010-06-25 08:17:46 -04:00
|
|
|
QString mid = pItem->data(ROLE_MSGID).toString();
|
2010-06-03 18:12:07 -04:00
|
|
|
if (bDelete) {
|
|
|
|
rsMsgs->MessageDelete(mid.toStdString());
|
2010-05-28 10:42:54 -04:00
|
|
|
|
2010-06-03 18:12:07 -04:00
|
|
|
// clean locale config
|
|
|
|
m_pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
|
|
|
m_pConfig->remove (mid);
|
|
|
|
m_pConfig->endGroup();
|
2010-05-28 10:42:54 -04:00
|
|
|
|
2010-06-03 18:12:07 -04:00
|
|
|
// remove tag
|
|
|
|
m_pConfig->beginGroup(CONFIG_SECTION_TAG);
|
|
|
|
m_pConfig->remove (mid);
|
|
|
|
m_pConfig->endGroup();
|
|
|
|
} else {
|
|
|
|
rsMsgs->MessageToTrash(mid.toStdString(), true);
|
|
|
|
}
|
2010-05-28 10:42:54 -04:00
|
|
|
}
|
|
|
|
}
|
2010-05-23 13:21:30 -04:00
|
|
|
|
2010-06-03 18:12:07 -04:00
|
|
|
// LockUpdate -> insertMessages();
|
2010-05-28 10:42:54 -04:00
|
|
|
}
|
2010-05-27 15:48:52 -04:00
|
|
|
|
2010-05-28 10:42:54 -04:00
|
|
|
void MessagesDialog::undeletemessage()
|
|
|
|
{
|
2010-06-03 18:12:07 -04:00
|
|
|
LockUpdate (this, true);
|
|
|
|
|
2010-05-28 10:42:54 -04:00
|
|
|
QList<int> Rows;
|
|
|
|
getSelectedMsgCount (&Rows, NULL, NULL);
|
|
|
|
for (int nRow = 0; nRow < Rows.size(); nRow++) {
|
2010-06-25 08:17:46 -04:00
|
|
|
QString mid = MessagesModel->item (Rows [nRow], COLUMN_DATA)->data(ROLE_MSGID).toString();
|
2010-05-28 10:42:54 -04:00
|
|
|
rsMsgs->MessageToTrash(mid.toStdString(), false);
|
2010-05-23 13:21:30 -04:00
|
|
|
}
|
|
|
|
|
2010-06-03 18:12:07 -04:00
|
|
|
// LockUpdate -> insertMessages();
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2008-09-04 15:28:35 -04:00
|
|
|
void MessagesDialog::print()
|
|
|
|
{
|
|
|
|
#ifndef QT_NO_PRINTER
|
|
|
|
QPrinter printer(QPrinter::HighResolution);
|
|
|
|
printer.setFullPage(true);
|
|
|
|
QPrintDialog *dlg = new QPrintDialog(&printer, this);
|
|
|
|
if (ui.msgText->textCursor().hasSelection())
|
|
|
|
dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection);
|
|
|
|
dlg->setWindowTitle(tr("Print Document"));
|
|
|
|
if (dlg->exec() == QDialog::Accepted) {
|
|
|
|
ui.msgText->print(&printer);
|
|
|
|
}
|
|
|
|
delete dlg;
|
|
|
|
#endif
|
2008-03-26 10:22:51 -04:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-09-04 15:28:35 -04:00
|
|
|
void MessagesDialog::printpreview()
|
|
|
|
{
|
|
|
|
PrintPreview *preview = new PrintPreview(ui.msgText->document(), this);
|
|
|
|
preview->setWindowModality(Qt::WindowModal);
|
|
|
|
preview->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
preview->show();
|
2008-03-27 19:40:37 -04:00
|
|
|
}
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
void MessagesDialog::anchorClicked (const QUrl& link )
|
2010-01-16 13:03:35 -05:00
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
std::cerr << "MessagesDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl;
|
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
RetroShareLink::processUrl(link, NULL, RSLINK_PROCESS_NOTIFY_ALL);
|
2010-01-21 20:05:45 -05:00
|
|
|
}
|
|
|
|
|
2010-01-22 14:23:12 -05:00
|
|
|
bool MessagesDialog::fileSave()
|
|
|
|
{
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
return fileSaveAs();
|
|
|
|
|
|
|
|
QFile file(fileName);
|
|
|
|
if (!file.open(QFile::WriteOnly))
|
|
|
|
return false;
|
|
|
|
QTextStream ts(&file);
|
|
|
|
ts.setCodec(QTextCodec::codecForName("UTF-8"));
|
|
|
|
ts << ui.msgText->document()->toHtml("UTF-8");
|
|
|
|
ui.msgText->document()->setModified(false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MessagesDialog::fileSaveAs()
|
|
|
|
{
|
|
|
|
QString fn = QFileDialog::getSaveFileName(this, tr("Save as..."),
|
|
|
|
QString(), tr("HTML-Files (*.htm *.html);;All Files (*)"));
|
|
|
|
if (fn.isEmpty())
|
|
|
|
return false;
|
|
|
|
setCurrentFileName(fn);
|
|
|
|
return fileSave();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessagesDialog::setCurrentFileName(const QString &fileName)
|
|
|
|
{
|
|
|
|
this->fileName = fileName;
|
|
|
|
ui.msgText->document()->setModified(false);
|
|
|
|
|
|
|
|
setWindowModified(false);
|
|
|
|
}
|
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
void MessagesDialog::setToolbarButtonStyle(Qt::ToolButtonStyle style)
|
2010-01-21 20:05:45 -05:00
|
|
|
{
|
2010-05-27 15:48:52 -04:00
|
|
|
ui.newmessageButton->setToolButtonStyle(style);
|
|
|
|
ui.removemessageButton->setToolButtonStyle(style);
|
|
|
|
ui.replymessageButton->setToolButtonStyle(style);
|
|
|
|
ui.replyallmessageButton->setToolButtonStyle(style);
|
|
|
|
ui.forwardmessageButton->setToolButtonStyle(style);
|
|
|
|
ui.tagButton->setToolButtonStyle(style);
|
|
|
|
ui.printbutton->setToolButtonStyle(style);
|
|
|
|
ui.viewtoolButton->setToolButtonStyle(style);
|
|
|
|
}
|
2010-05-20 17:53:27 -04:00
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
void MessagesDialog::buttonsicononly()
|
|
|
|
{
|
|
|
|
setToolbarButtonStyle(Qt::ToolButtonIconOnly);
|
2010-05-18 18:37:18 -04:00
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
Settings->setValueToGroup("MessageDialog", "ToolButon_Stlye", Qt::ToolButtonIconOnly);
|
2010-01-21 20:05:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MessagesDialog::buttonstextbesideicon()
|
|
|
|
{
|
2010-05-27 15:48:52 -04:00
|
|
|
setToolbarButtonStyle(Qt::ToolButtonTextBesideIcon);
|
2010-05-18 18:37:18 -04:00
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
Settings->setValueToGroup("MessageDialog", "ToolButon_Stlye", Qt::ToolButtonTextBesideIcon);
|
2010-01-21 20:05:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MessagesDialog::buttonstextundericon()
|
|
|
|
{
|
2010-05-27 15:48:52 -04:00
|
|
|
setToolbarButtonStyle(Qt::ToolButtonTextUnderIcon);
|
2010-01-25 07:44:12 -05:00
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
Settings->setValueToGroup("MessageDialog", "ToolButon_Stlye", Qt::ToolButtonTextUnderIcon);
|
2010-01-25 07:44:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MessagesDialog::loadToolButtonsettings()
|
|
|
|
{
|
2010-05-27 15:48:52 -04:00
|
|
|
Qt::ToolButtonStyle style = (Qt::ToolButtonStyle) Settings->valueFromGroup("MessageDialog", "ToolButon_Stlye", Qt::ToolButtonIconOnly).toInt();
|
|
|
|
setToolbarButtonStyle(style);
|
2010-01-25 07:44:12 -05:00
|
|
|
}
|
2010-02-13 13:49:56 -05:00
|
|
|
|
|
|
|
void MessagesDialog::filterRegExpChanged()
|
|
|
|
{
|
|
|
|
QRegExp regExp(ui.filterPatternLineEdit->text(), Qt::CaseInsensitive , QRegExp::FixedString);
|
|
|
|
proxyModel->setFilterRegExp(regExp);
|
2010-05-19 15:44:06 -04:00
|
|
|
|
|
|
|
QString text = ui.filterPatternLineEdit->text();
|
|
|
|
|
|
|
|
if (text.isEmpty())
|
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
ui.clearButton->hide();
|
2010-05-19 15:44:06 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
ui.clearButton->show();
|
2010-05-19 15:44:06 -04:00
|
|
|
}
|
2010-02-13 13:49:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MessagesDialog::filterColumnChanged()
|
|
|
|
{
|
2010-05-20 17:53:27 -04:00
|
|
|
if (m_bProcessSettings) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-05-18 18:37:18 -04:00
|
|
|
int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
|
|
|
|
if (nFilterColumn == COLUMN_CONTENT) {
|
|
|
|
// need content ... refill
|
|
|
|
insertMessages();
|
|
|
|
}
|
|
|
|
proxyModel->setFilterKeyColumn(nFilterColumn);
|
|
|
|
|
|
|
|
// save index
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setValueToGroup("MessageDialog", "filterColumn", nFilterColumn);
|
2010-02-13 13:49:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MessagesDialog::updateMessageSummaryList()
|
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
unsigned int newInboxCount = 0;
|
|
|
|
unsigned int newOutboxCount = 0;
|
|
|
|
unsigned int newDraftCount = 0;
|
|
|
|
unsigned int newSentboxCount = 0;
|
|
|
|
unsigned int inboxCount = 0;
|
2010-05-28 10:42:54 -04:00
|
|
|
unsigned int trashboxCount = 0;
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
/* calculating the new messages */
|
|
|
|
// rsMsgs->getMessageCount (&inboxCount, &newInboxCount, &newOutboxCount, &newDraftCount, &newSentboxCount);
|
|
|
|
|
|
|
|
std::list<MsgInfoSummary> msgList;
|
|
|
|
std::list<MsgInfoSummary>::const_iterator it;
|
|
|
|
|
|
|
|
rsMsgs->getMessageSummaries(msgList);
|
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
QMap<int, int> tagCount;
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
/*calculating the new messages*/
|
|
|
|
for (it = msgList.begin(); it != msgList.end(); it++) {
|
2010-06-01 18:14:52 -04:00
|
|
|
/* calcluate tag count */
|
|
|
|
QList<int> tagIds;
|
|
|
|
getMessageTags (m_pConfig, QString::fromStdString(it->msgId), tagIds);
|
|
|
|
for (QList<int>::iterator tagId = tagIds.begin(); tagId != tagIds.end(); tagId++) {
|
|
|
|
int nCount = tagCount [*tagId];
|
|
|
|
nCount++;
|
|
|
|
tagCount [*tagId] = nCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* calculate box */
|
2010-05-28 10:42:54 -04:00
|
|
|
if (it->msgflags & RS_MSG_TRASH) {
|
|
|
|
trashboxCount++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
switch (it->msgflags & RS_MSG_BOXMASK) {
|
|
|
|
case RS_MSG_INBOX:
|
|
|
|
inboxCount++;
|
|
|
|
if ((it->msgflags & RS_MSG_NEW) == RS_MSG_NEW) {
|
|
|
|
newInboxCount++;
|
|
|
|
} else {
|
|
|
|
// check locale config
|
|
|
|
m_pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
|
|
|
if (m_pConfig->value(QString::fromStdString(it->msgId), false).toBool()) {
|
|
|
|
newInboxCount++;
|
|
|
|
}
|
|
|
|
m_pConfig->endGroup();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RS_MSG_OUTBOX:
|
|
|
|
newOutboxCount++;
|
|
|
|
break;
|
|
|
|
case RS_MSG_DRAFTBOX:
|
|
|
|
newDraftCount++;
|
|
|
|
break;
|
|
|
|
case RS_MSG_SENTBOX:
|
|
|
|
newSentboxCount++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-06-12 11:11:42 -04:00
|
|
|
|
|
|
|
|
|
|
|
int listrow = ui.listWidget->currentRow();
|
|
|
|
QString textTotal;
|
|
|
|
|
|
|
|
switch (listrow)
|
|
|
|
{
|
|
|
|
case ROW_INBOX:
|
|
|
|
textTotal = tr("Total:") + " " + QString::number(inboxCount);
|
|
|
|
ui.total_label->setText(textTotal);
|
|
|
|
break;
|
|
|
|
case ROW_OUTBOX:
|
|
|
|
textTotal = tr("Total:") + " " + QString::number(newOutboxCount);
|
|
|
|
ui.total_label->setText(textTotal);
|
|
|
|
break;
|
|
|
|
case ROW_DRAFTBOX:
|
|
|
|
textTotal = tr("Total:") + " " + QString::number(newDraftCount);
|
|
|
|
ui.total_label->setText(textTotal);
|
|
|
|
break;
|
|
|
|
case ROW_SENTBOX:
|
|
|
|
textTotal = tr("Total:") + " " + QString::number(newSentboxCount);
|
|
|
|
ui.total_label->setText(textTotal);
|
|
|
|
break;
|
|
|
|
case ROW_TRASHBOX:
|
|
|
|
textTotal = tr("Total:") + " " + QString::number(trashboxCount);
|
|
|
|
ui.total_label->setText(textTotal);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-05-23 13:21:30 -04:00
|
|
|
|
|
|
|
QString textItem;
|
|
|
|
/*updating the labels in leftcolumn*/
|
|
|
|
|
|
|
|
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
|
2010-05-28 10:42:54 -04:00
|
|
|
QListWidgetItem* item = ui.listWidget->item(ROW_INBOX);
|
2010-05-23 13:21:30 -04:00
|
|
|
if (newInboxCount != 0)
|
|
|
|
{
|
2010-06-01 18:14:52 -04:00
|
|
|
textItem = tr("Inbox") + " (" + QString::number(newInboxCount)+")";
|
2010-05-23 13:21:30 -04:00
|
|
|
item->setText(textItem);
|
|
|
|
QFont qf = item->font();
|
|
|
|
qf.setBold(true);
|
|
|
|
item->setFont(qf);
|
|
|
|
item->setIcon(QIcon(":/images/folder-inbox-new.png"));
|
|
|
|
item->setForeground(QBrush(QColor(49, 106, 197)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
textItem = tr("Inbox");
|
|
|
|
item->setText(textItem);
|
|
|
|
QFont qf = item->font();
|
|
|
|
qf.setBold(false);
|
|
|
|
item->setFont(qf);
|
|
|
|
item->setIcon(QIcon(":/images/folder-inbox.png"));
|
|
|
|
item->setForeground(QBrush(QColor(0, 0, 0)));
|
|
|
|
}
|
|
|
|
|
|
|
|
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
|
2010-05-28 10:42:54 -04:00
|
|
|
item = ui.listWidget->item(ROW_OUTBOX);
|
2010-05-23 13:21:30 -04:00
|
|
|
if (newOutboxCount != 0)
|
|
|
|
{
|
2010-06-01 18:14:52 -04:00
|
|
|
textItem = tr("Outbox") + " (" + QString::number(newOutboxCount)+")";
|
2010-05-23 13:21:30 -04:00
|
|
|
item->setText(textItem);
|
|
|
|
QFont qf = item->font();
|
|
|
|
qf.setBold(true);
|
|
|
|
item->setFont(qf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
textItem = tr("Outbox");
|
|
|
|
item->setText(textItem);
|
|
|
|
QFont qf = item->font();
|
|
|
|
qf.setBold(false);
|
|
|
|
item->setFont(qf);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
|
2010-05-28 10:42:54 -04:00
|
|
|
item = ui.listWidget->item(ROW_DRAFTBOX);
|
2010-05-23 13:21:30 -04:00
|
|
|
if (newDraftCount != 0)
|
|
|
|
{
|
2010-06-01 18:14:52 -04:00
|
|
|
textItem = tr("Drafts") + " (" + QString::number(newDraftCount)+")";
|
2010-05-23 13:21:30 -04:00
|
|
|
item->setText(textItem);
|
|
|
|
QFont qf = item->font();
|
|
|
|
qf.setBold(true);
|
|
|
|
item->setFont(qf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-28 13:29:21 -04:00
|
|
|
textItem = tr("Drafts");
|
2010-05-23 13:21:30 -04:00
|
|
|
item->setText(textItem);
|
|
|
|
QFont qf = item->font();
|
|
|
|
qf.setBold(false);
|
|
|
|
item->setFont(qf);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-28 10:42:54 -04:00
|
|
|
item = ui.listWidget->item(ROW_TRASHBOX);
|
|
|
|
if (trashboxCount != 0)
|
|
|
|
{
|
2010-06-01 18:14:52 -04:00
|
|
|
textItem = tr("Trash") + " (" + QString::number(trashboxCount)+")";
|
2010-05-28 10:42:54 -04:00
|
|
|
item->setText(textItem);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
textItem = tr("Trash");
|
|
|
|
item->setText(textItem);
|
|
|
|
}
|
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
|
|
|
|
/* set tag counts */
|
|
|
|
int nRowCount = ui.tagWidget->count();
|
|
|
|
for (int nRow = 0; nRow < nRowCount; nRow++) {
|
|
|
|
QListWidgetItem *pItem = ui.tagWidget->item(nRow);
|
|
|
|
int nCount = tagCount[pItem->data(Qt::UserRole).toInt()];
|
|
|
|
|
|
|
|
QString sText = pItem->data(Qt::UserRole + 1).toString();
|
|
|
|
if (nCount) {
|
|
|
|
sText += " (" + QString::number(nCount) + ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
pItem->setText(sText);
|
|
|
|
}
|
2010-02-13 13:49:56 -05:00
|
|
|
}
|
2010-02-14 07:29:50 -05:00
|
|
|
|
|
|
|
/** clear Filter **/
|
|
|
|
void MessagesDialog::clearFilter()
|
|
|
|
{
|
2010-05-23 13:21:30 -04:00
|
|
|
ui.filterPatternLineEdit->clear();
|
|
|
|
ui.filterPatternLineEdit->setFocus();
|
2010-02-14 07:29:50 -05:00
|
|
|
}
|
2010-05-27 15:48:52 -04:00
|
|
|
|
|
|
|
void MessagesDialog::tagAboutToShow()
|
|
|
|
{
|
|
|
|
// activate actions from the first selected row
|
|
|
|
QList<int> tagIds;
|
|
|
|
|
|
|
|
QList<int> Rows;
|
|
|
|
getSelectedMsgCount (&Rows, NULL, NULL);
|
|
|
|
|
|
|
|
if (Rows.size()) {
|
2010-06-25 08:17:46 -04:00
|
|
|
QStandardItem* pItem = MessagesModel->item(Rows [0], COLUMN_DATA);
|
|
|
|
QString msgId = pItem->data(ROLE_MSGID).toString();
|
2010-05-27 15:48:52 -04:00
|
|
|
|
|
|
|
getMessageTags(m_pConfig, msgId, tagIds);
|
|
|
|
}
|
|
|
|
|
|
|
|
QMenu *pMenu = ui.tagButton->menu();
|
|
|
|
|
|
|
|
foreach(QObject *pObject, pMenu->children()) {
|
|
|
|
QAction *pAction = qobject_cast<QAction*> (pObject);
|
|
|
|
if (pAction == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QMap<QString, QVariant> &Values = pAction->data().toMap();
|
|
|
|
if (Values.size () != ACTION_TAGSINDEX_SIZE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (Values [ACTION_TAGSINDEX_TYPE] != ACTION_TAGS_TAG) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<int>::iterator tagId = qFind(tagIds.begin(), tagIds.end(), Values [ACTION_TAGSINDEX_ID]);
|
|
|
|
pAction->setChecked(tagId != tagIds.end());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessagesDialog::tagTriggered(QAction *pAction)
|
|
|
|
{
|
|
|
|
if (pAction == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QMap<QString, QVariant> &Values = pAction->data().toMap();
|
|
|
|
if (Values.size () != ACTION_TAGSINDEX_SIZE) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool bRemoveAll = false;
|
|
|
|
int nId = 0;
|
|
|
|
bool bSet = false;
|
|
|
|
|
|
|
|
if (Values [ACTION_TAGSINDEX_TYPE] == ACTION_TAGS_REMOVEALL) {
|
|
|
|
// remove all tags
|
|
|
|
bRemoveAll = true;
|
|
|
|
} else if (Values [ACTION_TAGSINDEX_TYPE] == ACTION_TAGS_NEWTAG) {
|
|
|
|
// new tag
|
|
|
|
std::map<int, TagItem> TagItems;
|
|
|
|
getTagItems(TagItems);
|
|
|
|
|
|
|
|
NewTag Tag(TagItems);
|
|
|
|
if (Tag.exec() == QDialog::Accepted && Tag.m_nId) {
|
|
|
|
// Tag.m_nId
|
|
|
|
setTagItems (TagItems);
|
|
|
|
nId = Tag.m_nId;
|
|
|
|
bSet = true;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (Values [ACTION_TAGSINDEX_TYPE].toInt() == ACTION_TAGS_TAG) {
|
|
|
|
nId = Values [ACTION_TAGSINDEX_ID].toInt();
|
|
|
|
if (nId == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bSet = pAction->isChecked();
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<int> Rows;
|
|
|
|
getSelectedMsgCount (&Rows, NULL, NULL);
|
|
|
|
for (int nRow = 0; nRow < Rows.size(); nRow++) {
|
2010-06-25 08:17:46 -04:00
|
|
|
QStandardItem* pItem = MessagesModel->item(Rows [nRow], COLUMN_DATA);
|
|
|
|
QString msgId = pItem->data(ROLE_MSGID).toString();
|
2010-05-27 15:48:52 -04:00
|
|
|
|
|
|
|
if (bRemoveAll) {
|
|
|
|
// remove all
|
|
|
|
m_pConfig->beginGroup(CONFIG_SECTION_TAG);
|
|
|
|
m_pConfig->remove (msgId);
|
|
|
|
m_pConfig->endGroup();
|
|
|
|
|
|
|
|
insertMessages();
|
|
|
|
} else {
|
|
|
|
// set or unset tag
|
|
|
|
QList<int> tagIds;
|
|
|
|
getMessageTags(m_pConfig, msgId, tagIds);
|
|
|
|
|
2010-06-01 18:14:52 -04:00
|
|
|
QList<int>::iterator tagId = qFind(tagIds.begin(), tagIds.end(), nId);
|
2010-05-27 15:48:52 -04:00
|
|
|
|
|
|
|
bool bSaveAndRefresh = false;
|
|
|
|
if (bSet) {
|
|
|
|
if (tagId == tagIds.end()) {
|
|
|
|
// not found
|
|
|
|
tagIds.push_back(nId);
|
|
|
|
bSaveAndRefresh = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (tagId != tagIds.end()) {
|
|
|
|
// found
|
|
|
|
tagIds.erase(tagId);
|
|
|
|
bSaveAndRefresh = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bSaveAndRefresh) {
|
|
|
|
setMessageTags(m_pConfig, msgId, tagIds);
|
|
|
|
insertMessages();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|