Added remove, copy to clipboard and resend of messages in History Browser.

Clear history in PeersDialog don't remove messages from the History Keeper.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3447 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-09-05 20:50:34 +00:00
parent c63905fefc
commit bacf1f5a80
13 changed files with 379 additions and 45 deletions

View file

@ -1385,7 +1385,6 @@ void PeersDialog::setChatInfo(QString info, QColor color)
void PeersDialog::on_actionClearChat_triggered() void PeersDialog::on_actionClearChat_triggered()
{ {
ui.msgText->clear(); ui.msgText->clear();
historyKeeper.clear();
} }
void PeersDialog::displayInfoChatMenu(const QPoint& pos) void PeersDialog::displayInfoChatMenu(const QPoint& pos)
@ -1756,6 +1755,6 @@ void PeersDialog::statusColumn()
void PeersDialog::on_actionMessageHistory_triggered() void PeersDialog::on_actionMessageHistory_triggered()
{ {
ImHistoryBrowser imBrowser(false, historyKeeper, this); ImHistoryBrowser imBrowser(false, historyKeeper, ui.lineEdit, this);
imBrowser.exec(); imBrowser.exec();
} }

View file

@ -25,12 +25,14 @@
IMHistoryItem::IMHistoryItem() IMHistoryItem::IMHistoryItem()
{ {
hiid = 0;
} }
//============================================================================ //============================================================================
IMHistoryItem::IMHistoryItem(bool incomingIn, std::string &idIn, const QString &nameIn, const QDateTime &sendTimeIn, const QString &messageTextIn) IMHistoryItem::IMHistoryItem(int hiidIn, bool incomingIn, std::string &idIn, const QString &nameIn, const QDateTime &sendTimeIn, const QString &messageTextIn)
{ {
hiid = hiidIn;
incoming = incomingIn; incoming = incomingIn;
id = idIn; id = idIn;
name = nameIn; name = nameIn;

View file

@ -30,8 +30,9 @@ class IMHistoryItem
public: public:
IMHistoryItem(); IMHistoryItem();
IMHistoryItem(bool incoming, std::string &id, const QString &name, const QDateTime &sendTime, const QString &messageText); IMHistoryItem(int hiid, bool incoming, std::string &id, const QString &name, const QDateTime &sendTime, const QString &messageText);
int hiid;
bool incoming; bool incoming;
std::string id; std::string id;
QString name; QString name;

View file

@ -44,6 +44,8 @@ IMHistoryKeeper::IMHistoryKeeper()
saveTimer->connect(saveTimer, SIGNAL(timeout()), this, SLOT(saveHistory())); saveTimer->connect(saveTimer, SIGNAL(timeout()), this, SLOT(saveHistory()));
saveTimer->setInterval(10000); saveTimer->setInterval(10000);
saveTimer->start(); saveTimer->start();
lasthiid = 0;
}; };
//============================================================================= //=============================================================================
@ -57,6 +59,8 @@ IMHistoryKeeper::~IMHistoryKeeper()
void IMHistoryKeeper::init(QString historyFileName) void IMHistoryKeeper::init(QString historyFileName)
{ {
lasthiid = 0;
hfName = historyFileName; hfName = historyFileName;
loadHistoryFile(); loadHistoryFile();
} }
@ -65,7 +69,7 @@ void IMHistoryKeeper::init(QString historyFileName)
void IMHistoryKeeper::addMessage(bool incoming, std::string &id, const QString &name, const QDateTime &sendTime, const QString &messageText) void IMHistoryKeeper::addMessage(bool incoming, std::string &id, const QString &name, const QDateTime &sendTime, const QString &messageText)
{ {
IMHistoryItem item(incoming, id, name, sendTime, messageText); IMHistoryItem item(++lasthiid, incoming, id, name, sendTime, messageText);
hitems.append(item); hitems.append(item);
@ -97,7 +101,7 @@ bool IMHistoryKeeper::loadHistoryFile()
} }
IMHistoryReader hreader; IMHistoryReader hreader;
if (!hreader.read(hitems, hfName)) { if (!hreader.read(hitems, hfName, lasthiid)) {
lastErrorMessage = hreader.errorMessage(); lastErrorMessage = hreader.errorMessage();
return false; return false;
} }
@ -145,16 +149,73 @@ bool IMHistoryKeeper::getMessages(QList<IMHistoryItem> &historyItems, const int
//============================================================================= //=============================================================================
bool IMHistoryKeeper::getMessage(int hiid, IMHistoryItem &item)
{
QList<IMHistoryItem>::iterator it;
for (it = hitems.begin(); it != hitems.end(); it++) {
if (it->hiid == hiid) {
item = *it;
return true;
}
}
return false;
}
//=============================================================================
void IMHistoryKeeper::clear() void IMHistoryKeeper::clear()
{ {
hitems.clear(); hitems.clear();
historyChanged = true; historyChanged = true;
lasthiid = 0;
emit historyClear(); emit historyClear();
} }
//============================================================================= //=============================================================================
void IMHistoryKeeper::removeMessage(int hiid)
{
QList<IMHistoryItem>::iterator it;
for (it = hitems.begin(); it != hitems.end(); it++) {
if (it->hiid == hiid) {
emit historyRemove(*it);
hitems.erase(it);
historyChanged = true;
break;
}
}
}
//=============================================================================
void IMHistoryKeeper::removeMessages(QList<int> &hiids)
{
bool changed = false;
QList<IMHistoryItem>::iterator it = hitems.begin();
while (it != hitems.end()) {
if (qFind(hiids, it->hiid) != hiids.end()) {
emit historyRemove(*it);
hitems.erase(it);
changed = true;
continue;
}
it++;
}
if (changed) {
historyChanged = true;
}
}
//=============================================================================
void IMHistoryKeeper::saveHistory() void IMHistoryKeeper::saveHistory()
{ {
if (historyChanged && hfName.isEmpty() == false) { if (historyChanged && hfName.isEmpty() == false) {

View file

@ -71,6 +71,9 @@ public:
//! Fills given list with items //! Fills given list with items
bool getMessages(QList<IMHistoryItem> &historyItems, const int messagesCount); bool getMessages(QList<IMHistoryItem> &historyItems, const int messagesCount);
//! Get message
bool getMessage(int hiid, IMHistoryItem &item);
//! Adds new message to the history //! Adds new message to the history
//! Adds new message to the history, but the message will be saved to //! Adds new message to the history, but the message will be saved to
@ -80,6 +83,12 @@ public:
//! Clear the history //! Clear the history
void clear(); void clear();
//! Remove item
void removeMessage(int hiid);
//! Remove items
void removeMessages(QList<int> &hiids);
private: private:
bool loadHistoryFile(); bool loadHistoryFile();
@ -88,12 +97,14 @@ private:
bool historyChanged; bool historyChanged;
QString lastErrorMessage; QString lastErrorMessage;
QTimer *saveTimer; QTimer *saveTimer;
int lasthiid;
private slots: private slots:
void saveHistory(); void saveHistory();
signals: signals:
void historyAdd(IMHistoryItem item) const; void historyAdd(IMHistoryItem item) const;
void historyRemove(IMHistoryItem item) const;
void historyClear() const; void historyClear() const;
}; };

View file

@ -35,12 +35,11 @@ IMHistoryReader::IMHistoryReader()
//============================================================================= //=============================================================================
bool IMHistoryReader::read(QList<IMHistoryItem>& resultList, bool IMHistoryReader::read(QList<IMHistoryItem>& resultList, const QString fileName, int &lasthiid)
const QString fileName)
{ {
errMess = "No error"; errMess = "No error";
QList<IMHistoryItem> result; resultList.clear();
//==== check for file and open it //==== check for file and open it
QFile fl(fileName); QFile fl(fileName);
@ -64,7 +63,7 @@ bool IMHistoryReader::read(QList<IMHistoryItem>& resultList,
readNext(); readNext();
if (isStartElement()) { if (isStartElement()) {
if (name() == "history_file" && attributes().value("format_version") == "1.0") { if (name() == "history_file" && attributes().value("format_version") == "1.0") {
readHistory(result); readHistory(resultList, lasthiid);
break; break;
} else { } else {
errMess = "The file is not a history file with format version 1.0"; errMess = "The file is not a history file with format version 1.0";
@ -75,13 +74,11 @@ bool IMHistoryReader::read(QList<IMHistoryItem>& resultList,
if (error()) { if (error()) {
errMess = errorString(); errMess = errorString();
} else { // } else {
resultList.clear(); // QList<IMHistoryItem>::const_iterator hii;//history items iterator
// for (hii = result.constBegin(); hii != result.constEnd(); ++hii) {
QList<IMHistoryItem>::const_iterator hii;//history items iterator // resultList << *hii;
for (hii = result.constBegin(); hii != result.constEnd(); ++hii) { // }
resultList << *hii;
}
} }
return !error(); return !error();
@ -118,13 +115,16 @@ void IMHistoryReader::readUnknownElement()
//============================================================================= //=============================================================================
void IMHistoryReader::readHistory(QList<IMHistoryItem> &historyItems) void IMHistoryReader::readHistory(QList<IMHistoryItem> &historyItems, int &lasthiid)
{ {
Q_ASSERT(isStartElement()); Q_ASSERT(isStartElement());
// qDebug()<< " " << "node with message " << name() ; // qDebug()<< " " << "node with message " << name() ;
historyItems.clear(); historyItems.clear();
lasthiid = 0;
bool recalculate = false;
while (!atEnd()) { while (!atEnd()) {
readNext(); readNext();
@ -136,13 +136,29 @@ void IMHistoryReader::readHistory(QList<IMHistoryItem> &historyItems)
if ( name() == "message") { if ( name() == "message") {
IMHistoryItem item; IMHistoryItem item;
readMessage(item); readMessage(item);
historyItems.append(item); if (item.hiid == 0) {
recalculate = true;
} else {
if (item.hiid > lasthiid) {
lasthiid = item.hiid;
} }
else { }
historyItems.append(item);
} else {
readUnknownElement(); readUnknownElement();
} }
} }
} }
if (recalculate) {
// calculate hiid
QList<IMHistoryItem>::iterator item = historyItems.begin();
for (item = historyItems.begin(); item != historyItems.end(); item++) {
if (item->hiid == 0) {
item->hiid = ++lasthiid;
}
}
}
} }
//============================================================================= //=============================================================================
@ -154,6 +170,7 @@ void IMHistoryReader::readMessage(IMHistoryItem &historyItem)
if (isStartElement() && (name() == "message")) { if (isStartElement() && (name() == "message")) {
//=== process attributes //=== process attributes
historyItem.hiid = attributes().value("hiid").toString().toInt();
historyItem.incoming = (attributes().value("incoming").toString().toInt() == 1); historyItem.incoming = (attributes().value("incoming").toString().toInt() == 1);
historyItem.id = attributes().value("id").toString().toStdString(); historyItem.id = attributes().value("id").toString().toStdString();
historyItem.name = attributes().value("name").toString(); historyItem.name = attributes().value("name").toString();
@ -180,6 +197,3 @@ void IMHistoryReader::readMessage(IMHistoryItem &historyItem)
} }
} }
//=============================================================================
//=============================================================================
//=============================================================================

View file

@ -34,14 +34,13 @@ class IMHistoryReader : public QXmlStreamReader
public: public:
IMHistoryReader(); IMHistoryReader();
bool read(QList<IMHistoryItem>& resultList, bool read(QList<IMHistoryItem>& resultList, const QString fileName, int &lasthiid);
const QString fileName );
QString errorMessage(); QString errorMessage();
private: private:
void readUnknownElement(); void readUnknownElement();
void readHistory(QList<IMHistoryItem> &historyItems); void readHistory(QList<IMHistoryItem> &historyItems, int &lasthiid);
void readMessage(IMHistoryItem &historyItem); void readMessage(IMHistoryItem &historyItem);
QString errMess; QString errMess;

View file

@ -59,6 +59,7 @@ bool IMHistoryWriter::write(QList<IMHistoryItem>& itemList, const QString fileNa
foreach(IMHistoryItem item, itemList) { foreach(IMHistoryItem item, itemList) {
writeStartElement("message"); writeStartElement("message");
writeAttribute("hiid", QString::number(item.hiid));
writeAttribute("incoming", QString::number(item.incoming ? 1 : 0)); writeAttribute("incoming", QString::number(item.incoming ? 1 : 0));
writeAttribute("id", QString::fromStdString(item.id)); writeAttribute("id", QString::fromStdString(item.id));
writeAttribute("name", item.name); writeAttribute("name", item.name);

View file

@ -24,6 +24,9 @@
#include <QMenu> #include <QMenu>
#include <QClipboard> #include <QClipboard>
#include <QTextDocument> #include <QTextDocument>
#include <QTextEdit>
#include <QClipboard>
#include <QKeyEvent>
#include "ImHistoryBrowser.h" #include "ImHistoryBrowser.h"
#include "IMHistoryItemDelegate.h" #include "IMHistoryItemDelegate.h"
@ -32,24 +35,33 @@
#include "rshare.h" #include "rshare.h"
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#define ROLE_PLAINTEXT Qt::UserRole #define ROLE_HIID Qt::UserRole
#define ROLE_PLAINTEXT Qt::UserRole + 1
/** Default constructor */ /** Default constructor */
ImHistoryBrowser::ImHistoryBrowser(bool isPrivateChatIn, IMHistoryKeeper &histKeeper, QWidget *parent, Qt::WFlags flags) ImHistoryBrowser::ImHistoryBrowser(bool isPrivateChatIn, IMHistoryKeeper &histKeeper, QTextEdit *edit, QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags), historyKeeper(histKeeper) : QDialog(parent, flags), historyKeeper(histKeeper)
{ {
/* Invoke Qt Designer generated QObject setup routine */ /* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this); ui.setupUi(this);
isPrivateChat = isPrivateChatIn; isPrivateChat = isPrivateChatIn;
textEdit = edit;
connect(&historyKeeper, SIGNAL(historyAdd(IMHistoryItem)), this, SLOT(historyAdd(IMHistoryItem))); connect(&historyKeeper, SIGNAL(historyAdd(IMHistoryItem)), this, SLOT(historyAdd(IMHistoryItem)));
connect(&historyKeeper, SIGNAL(historyRemove(IMHistoryItem)), this, SLOT(historyRemove(IMHistoryItem)));
connect(&historyKeeper, SIGNAL(historyClear()), this, SLOT(historyClear())); connect(&historyKeeper, SIGNAL(historyClear()), this, SLOT(historyClear()));
connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter())); connect(ui.clearFilterButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged())); connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
ui.clearButton->hide(); connect(ui.copyButton, SIGNAL(clicked()), SLOT(copyMessage()));
connect(ui.removeButton, SIGNAL(clicked()), SLOT(removeMessages()));
connect(ui.listWidget, SIGNAL(itemSelectionChanged()), this, SLOT(itemSelectionChanged()));
connect(ui.listWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint)));
ui.clearFilterButton->hide();
// embed smileys ? // embed smileys ?
if (isPrivateChat) { if (isPrivateChat) {
@ -73,6 +85,12 @@ ImHistoryBrowser::ImHistoryBrowser(bool isPrivateChatIn, IMHistoryKeeper &histKe
if (geometry.isEmpty() == false) { if (geometry.isEmpty() == false) {
restoreGeometry(geometry); restoreGeometry(geometry);
} }
// dummy call for set butons
itemSelectionChanged();
ui.listWidget->installEventFilter(this);
} }
ImHistoryBrowser::~ImHistoryBrowser() ImHistoryBrowser::~ImHistoryBrowser()
@ -80,6 +98,22 @@ ImHistoryBrowser::~ImHistoryBrowser()
Settings->setValueToGroup("HistorieBrowser", "Geometry", saveGeometry()); Settings->setValueToGroup("HistorieBrowser", "Geometry", saveGeometry());
} }
bool ImHistoryBrowser::eventFilter(QObject *obj, QEvent *event)
{
if (obj == ui.listWidget) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent && keyEvent->key() == Qt::Key_Delete) {
// Delete pressed
removeMessages();
return true; // eat event
}
}
}
// pass the event on to the parent class
return QDialog::eventFilter(obj, event);
}
void ImHistoryBrowser::historyAdd(IMHistoryItem item) void ImHistoryBrowser::historyAdd(IMHistoryItem item)
{ {
QListWidgetItem *itemWidget = addItem(item); QListWidgetItem *itemWidget = addItem(item);
@ -88,6 +122,18 @@ void ImHistoryBrowser::historyAdd(IMHistoryItem item)
} }
} }
void ImHistoryBrowser::historyRemove(IMHistoryItem item)
{
int count = ui.listWidget->count();
for (int i = 0; i < count; i++) {
QListWidgetItem *itemWidget = ui.listWidget->item(i);
if (itemWidget->data(ROLE_HIID).toString().toInt() == item.hiid) {
delete(ui.listWidget->takeItem(i));
break;
}
}
}
void ImHistoryBrowser::historyClear() void ImHistoryBrowser::historyClear()
{ {
ui.listWidget->clear(); ui.listWidget->clear();
@ -112,6 +158,7 @@ QListWidgetItem *ImHistoryBrowser::addItem(IMHistoryItem &item)
QListWidgetItem *itemWidget = new QListWidgetItem; QListWidgetItem *itemWidget = new QListWidgetItem;
itemWidget->setData(Qt::DisplayRole, qVariantFromValue(IMHistoryItemPainter(formatMsg))); itemWidget->setData(Qt::DisplayRole, qVariantFromValue(IMHistoryItemPainter(formatMsg)));
itemWidget->setData(ROLE_HIID, item.hiid);
/* calculate plain text */ /* calculate plain text */
QTextDocument doc; QTextDocument doc;
@ -127,9 +174,9 @@ void ImHistoryBrowser::filterRegExpChanged()
QString text = ui.filterPatternLineEdit->text(); QString text = ui.filterPatternLineEdit->text();
if (text.isEmpty()) { if (text.isEmpty()) {
ui.clearButton->hide(); ui.clearFilterButton->hide();
} else { } else {
ui.clearButton->show(); ui.clearFilterButton->show();
} }
filterItems(); filterItems();
@ -145,7 +192,6 @@ void ImHistoryBrowser::filterItems(QListWidgetItem *item)
{ {
QString text = ui.filterPatternLineEdit->text(); QString text = ui.filterPatternLineEdit->text();
QRegExp regExp(text);
if (item == NULL) { if (item == NULL) {
int count = ui.listWidget->count(); int count = ui.listWidget->count();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
@ -153,7 +199,7 @@ void ImHistoryBrowser::filterItems(QListWidgetItem *item)
if (text.isEmpty()) { if (text.isEmpty()) {
item->setHidden(false); item->setHidden(false);
} else { } else {
if (item->data(ROLE_PLAINTEXT).toString().contains(regExp)) { if (item->data(ROLE_PLAINTEXT).toString().contains(text, Qt::CaseInsensitive)) {
item->setHidden(false); item->setHidden(false);
} else { } else {
item->setHidden(true); item->setHidden(true);
@ -164,7 +210,7 @@ void ImHistoryBrowser::filterItems(QListWidgetItem *item)
if (text.isEmpty()) { if (text.isEmpty()) {
item->setHidden(false); item->setHidden(false);
} else { } else {
if (item->data(ROLE_PLAINTEXT).toString().contains(regExp)) { if (item->data(ROLE_PLAINTEXT).toString().contains(text, Qt::CaseInsensitive)) {
item->setHidden(false); item->setHidden(false);
} else { } else {
item->setHidden(true); item->setHidden(true);
@ -172,3 +218,129 @@ void ImHistoryBrowser::filterItems(QListWidgetItem *item)
} }
} }
} }
void ImHistoryBrowser::getSelectedItems(QList<int> &items)
{
QList<QListWidgetItem*> itemWidgets = ui.listWidget->selectedItems();
QList<QListWidgetItem*>::iterator it;
for (it = itemWidgets.begin(); it != itemWidgets.end(); it++) {
QListWidgetItem *item = *it;
if (item->isHidden()) {
continue;
}
items.append(item->data(ROLE_HIID).toString().toInt());
}
}
void ImHistoryBrowser::itemSelectionChanged()
{
QList<int> hiids;
getSelectedItems(hiids);
if (hiids.size()) {
// activate buttons
ui.copyButton->setEnabled(true);
ui.removeButton->setEnabled(true);
} else {
// deactivate buttons
ui.copyButton->setDisabled(true);
ui.removeButton->setDisabled(true);
}
}
void ImHistoryBrowser::customContextMenuRequested(QPoint pos)
{
QList<int> hiids;
getSelectedItems(hiids);
QListWidgetItem *currentItem = ui.listWidget->currentItem();
QMenu contextMnu(this);
QAction *selectAll = new QAction(tr("Mark all"), &contextMnu);
QAction *copyMessage = new QAction(tr("Copy"), &contextMnu);
QAction *removeMessages = new QAction(tr("Delete"), &contextMnu);
QAction *clearHistory = new QAction(tr("Clear history"), &contextMnu);
QAction *sendItem = NULL;
if (textEdit) {
sendItem = new QAction(tr("Send"), &contextMnu);
if (currentItem) {
connect(sendItem, SIGNAL(triggered()), this, SLOT(sendMessage()));
} else {
sendItem->setDisabled(true);
}
}
if (hiids.size()) {
connect(selectAll, SIGNAL(triggered()), ui.listWidget, SLOT(selectAll()));
connect(copyMessage, SIGNAL(triggered()), this, SLOT(copyMessage()));
connect(removeMessages, SIGNAL(triggered()), this, SLOT(removeMessages()));
connect(clearHistory, SIGNAL(triggered()), this, SLOT(clearHistory()));
} else {
selectAll->setDisabled(true);
copyMessage->setDisabled(true);
removeMessages->setDisabled(true);
clearHistory->setDisabled(true);
}
contextMnu.addAction(selectAll);
contextMnu.addSeparator();
contextMnu.addAction(copyMessage);
contextMnu.addAction(removeMessages);
contextMnu.addAction(clearHistory);
if (sendItem) {
contextMnu.addSeparator();
contextMnu.addAction(sendItem);
}
contextMnu.exec(QCursor::pos());
}
void ImHistoryBrowser::copyMessage()
{
QListWidgetItem *currentItem = ui.listWidget->currentItem();
if (currentItem) {
int hiid = currentItem->data(ROLE_HIID).toString().toInt();
IMHistoryItem item;
if (historyKeeper.getMessage(hiid, item)) {
QTextDocument doc;
doc.setHtml(item.messageText);
QApplication::clipboard()->setText(doc.toPlainText());
}
}
}
void ImHistoryBrowser::removeMessages()
{
QList<int> hiids;
getSelectedItems(hiids);
historyKeeper.removeMessages(hiids);
}
void ImHistoryBrowser::clearHistory()
{
historyKeeper.clear();
}
void ImHistoryBrowser::sendMessage()
{
if (textEdit) {
QListWidgetItem *currentItem = ui.listWidget->currentItem();
if (currentItem) {
int hiid = currentItem->data(ROLE_HIID).toString().toInt();
IMHistoryItem item;
if (historyKeeper.getMessage(hiid, item)) {
textEdit->clear();
textEdit->setText(item.messageText);
textEdit->setFocus();
QTextCursor cursor = textEdit->textCursor();
cursor.movePosition(QTextCursor::End);
textEdit->setTextCursor(cursor);
close();
}
}
}
}

View file

@ -30,28 +30,45 @@
#include "ui_ImHistoryBrowser.h" #include "ui_ImHistoryBrowser.h"
class QTextEdit;
class ImHistoryBrowser : public QDialog class ImHistoryBrowser : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
/** Default constructor */ /** Default constructor */
ImHistoryBrowser(bool isPrivateChat, IMHistoryKeeper &histKeeper, QWidget *parent = 0, Qt::WFlags flags = 0); ImHistoryBrowser(bool isPrivateChat, IMHistoryKeeper &histKeeper, QTextEdit *edit, QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */ /** Default destructor */
virtual ~ImHistoryBrowser(); virtual ~ImHistoryBrowser();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
private slots: private slots:
void historyAdd(IMHistoryItem item); void historyAdd(IMHistoryItem item);
void historyRemove(IMHistoryItem item);
void historyClear(); void historyClear();
void filterRegExpChanged(); void filterRegExpChanged();
void clearFilter(); void clearFilter();
void itemSelectionChanged();
void customContextMenuRequested(QPoint pos);
void copyMessage();
void removeMessages();
void clearHistory();
void sendMessage();
private: private:
QListWidgetItem *addItem(IMHistoryItem &item); QListWidgetItem *addItem(IMHistoryItem &item);
void filterItems(QListWidgetItem *item = NULL); void filterItems(QListWidgetItem *item = NULL);
void getSelectedItems(QList<int> &items);
bool isPrivateChat; bool isPrivateChat;
QTextEdit *textEdit;
bool embedSmileys; bool embedSmileys;
IMHistoryKeeper &historyKeeper; IMHistoryKeeper &historyKeeper;
ChatStyle style; ChatStyle style;

View file

@ -14,7 +14,7 @@
<string>Message History</string> <string>Message History</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../images.qrc"> <iconset>
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset> <normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property> </property>
<property name="sizeGripEnabled"> <property name="sizeGripEnabled">
@ -23,7 +23,7 @@
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<layout class="QGridLayout" name="mainLayout"> <layout class="QGridLayout" name="mainLayout">
<item row="1" column="0"> <item row="7" column="0">
<layout class="QHBoxLayout" name="bottomLine"> <layout class="QHBoxLayout" name="bottomLine">
<item> <item>
<layout class="QHBoxLayout" name="filterLayout"> <layout class="QHBoxLayout" name="filterLayout">
@ -36,7 +36,7 @@
<string/> <string/>
</property> </property>
<property name="pixmap"> <property name="pixmap">
<pixmap resource="../images.qrc">:/images/find-16.png</pixmap> <pixmap>:/images/find-16.png</pixmap>
</property> </property>
</widget> </widget>
</item> </item>
@ -44,7 +44,7 @@
<widget class="QLineEdit" name="filterPatternLineEdit"/> <widget class="QLineEdit" name="filterPatternLineEdit"/>
</item> </item>
<item> <item>
<widget class="QPushButton" name="clearButton"> <widget class="QPushButton" name="clearFilterButton">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>16</width> <width>16</width>
@ -97,16 +97,72 @@ border-image: url(:/images/closepressed.png)
</item> </item>
</layout> </layout>
</item> </item>
<item row="6" column="0">
<widget class="QListWidget" name="listWidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QListWidget" name="listWidget"/> <layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="copyButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Copy</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/images/copy.png</normaloff>:/images/copy.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="removeButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Remove</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/images/delete.png</normaloff>:/images/delete.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item> </item>
</layout> </layout>
</item> </item>
</layout> </layout>
</widget> </widget>
<resources> <resources/>
<include location="../images.qrc"/>
</resources>
<connections> <connections>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>

View file

@ -107,6 +107,7 @@
<file>images/console-small-hover.png</file> <file>images/console-small-hover.png</file>
<file>images/console-small-up.png</file> <file>images/console-small-up.png</file>
<file>images/contact_new128.png</file> <file>images/contact_new128.png</file>
<file>images/copy.png</file>
<file>images/delete.png</file> <file>images/delete.png</file>
<file>images/deleteall.png</file> <file>images/deleteall.png</file>
<file>images/deletemail-pressed.png</file> <file>images/deletemail-pressed.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B