mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-25 23:06:10 -05:00
Merge pull request #2099 from PhenomRetroShare/Add_IMHistoryNoModal
Change Chat History Dialog to no modal.
This commit is contained in:
commit
608a754f92
@ -416,7 +416,7 @@ bool p3HistoryMgr::loadList(std::list<RsItem*>& load)
|
||||
}
|
||||
|
||||
// have to convert to virtual peer id, to be able to use existing serialiser and file format
|
||||
bool p3HistoryMgr::chatIdToVirtualPeerId(ChatId chat_id, RsPeerId &peer_id)
|
||||
bool p3HistoryMgr::chatIdToVirtualPeerId(const ChatId& chat_id, RsPeerId &peer_id)
|
||||
{
|
||||
if (chat_id.isBroadcast()) {
|
||||
peer_id = RsPeerId();
|
||||
|
@ -68,9 +68,9 @@ public:
|
||||
virtual void saveDone();
|
||||
virtual bool loadList(std::list<RsItem*>& load);
|
||||
|
||||
private:
|
||||
static bool chatIdToVirtualPeerId(ChatId chat_id, RsPeerId& peer_id);
|
||||
static bool chatIdToVirtualPeerId(const ChatId& chat_id, RsPeerId& peer_id);
|
||||
|
||||
private:
|
||||
uint32_t nextMsgId;
|
||||
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> > mMessages;
|
||||
|
||||
|
@ -1876,7 +1876,9 @@ bool p3PeerMgrIMPL::getExtAddressReportedByFriends(sockaddr_storage &addr, uint8
|
||||
static bool cleanIpList(std::list<pqiIpAddress>& lst,const RsPeerId& pid,p3LinkMgr *link_mgr)
|
||||
{
|
||||
bool changed = false ;
|
||||
#ifdef PEER_DEBUG
|
||||
rstime_t now = time(NULL) ;
|
||||
#endif
|
||||
|
||||
for(std::list<pqiIpAddress>::iterator it2(lst.begin());it2 != lst.end();)
|
||||
{
|
||||
|
@ -70,15 +70,17 @@ public:
|
||||
class RsHistory
|
||||
{
|
||||
public:
|
||||
virtual bool getMessages(const ChatId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
|
||||
virtual bool chatIdToVirtualPeerId(const ChatId &chat_id, RsPeerId &peer_id) = 0;
|
||||
virtual bool getMessages(const ChatId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
|
||||
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg) = 0;
|
||||
virtual void removeMessages(const std::list<uint32_t> &msgIds) = 0;
|
||||
virtual void clear(const ChatId &chatPeerId) = 0;
|
||||
virtual void clear(const ChatId &chatPeerId) = 0;
|
||||
|
||||
virtual bool getEnable(uint32_t chat_type) = 0;
|
||||
virtual void setEnable(uint32_t chat_type, bool enable) = 0;
|
||||
virtual uint32_t getMaxStorageDuration() = 0 ;
|
||||
virtual void setMaxStorageDuration(uint32_t seconds) = 0 ;
|
||||
|
||||
virtual uint32_t getMaxStorageDuration() = 0;
|
||||
virtual void setMaxStorageDuration(uint32_t seconds) = 0;
|
||||
|
||||
// 0 = no limit, >0 count of saved messages
|
||||
virtual uint32_t getSaveCount(uint32_t chat_type) = 0;
|
||||
|
@ -31,6 +31,11 @@ p3History::~p3History()
|
||||
{
|
||||
}
|
||||
|
||||
bool p3History::chatIdToVirtualPeerId(const ChatId &chat_id, RsPeerId &peer_id)
|
||||
{
|
||||
return mHistoryMgr->chatIdToVirtualPeerId(chat_id, peer_id);
|
||||
}
|
||||
|
||||
void p3History::setMaxStorageDuration(uint32_t seconds)
|
||||
{
|
||||
mHistoryMgr->setMaxStorageDuration(seconds) ;
|
||||
|
@ -37,16 +37,21 @@ public:
|
||||
p3History(p3HistoryMgr* historyMgr);
|
||||
virtual ~p3History();
|
||||
|
||||
virtual bool getMessages(const ChatId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount);
|
||||
virtual bool chatIdToVirtualPeerId(const ChatId &chat_id, RsPeerId &peer_id);
|
||||
virtual bool getMessages(const ChatId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount);
|
||||
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg);
|
||||
virtual void removeMessages(const std::list<uint32_t> &msgIds);
|
||||
virtual void clear(const ChatId &chatPeerId);
|
||||
virtual void clear(const ChatId &chatPeerId);
|
||||
|
||||
virtual bool getEnable(uint32_t chat_type);
|
||||
virtual void setEnable(uint32_t chat_type, bool enable);
|
||||
|
||||
virtual uint32_t getMaxStorageDuration();
|
||||
virtual void setMaxStorageDuration(uint32_t seconds);
|
||||
|
||||
// 0 = no limit, >0 count of saved messages
|
||||
virtual uint32_t getSaveCount(uint32_t chat_type);
|
||||
virtual void setSaveCount(uint32_t chat_type, uint32_t count);
|
||||
virtual void setMaxStorageDuration(uint32_t seconds) ;
|
||||
virtual uint32_t getMaxStorageDuration() ;
|
||||
virtual void setSaveCount(uint32_t chat_type, uint32_t count);
|
||||
|
||||
private:
|
||||
p3HistoryMgr* mHistoryMgr;
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/settings/rsettingswin.h"
|
||||
#include "gui/settings/RsharePeerSettings.h"
|
||||
#include "gui/im_history/ImHistoryBrowser.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
#include "gui/common/FilesDefs.h"
|
||||
#include "gui/common/Emoticons.h"
|
||||
@ -78,7 +77,7 @@ ChatWidget::ChatWidget(QWidget *parent)
|
||||
, lastStatusSendTime(0)
|
||||
, firstShow(true), inChatCharFormatChanged(false), firstSearch(true)
|
||||
, lastUpdateCursorPos(0), lastUpdateCursorEnd(0)
|
||||
, completer(NULL), notify(NULL)
|
||||
, completer(NULL), imBrowser(NULL), notify(NULL)
|
||||
, ui(new Ui::ChatWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -87,8 +86,8 @@ ChatWidget::ChatWidget(QWidget *parent)
|
||||
double fmm = iconHeight > FMM_THRESHOLD ? FMM : FMM_SMALLER;
|
||||
iconHeight *= fmm;
|
||||
QSize iconSize = QSize(iconHeight, iconHeight);
|
||||
int butt_size(iconSize.height() + fmm);
|
||||
QSize buttonSize = QSize(butt_size, butt_size);
|
||||
//int butt_size(iconSize.height() + fmm);
|
||||
//QSize buttonSize = QSize(butt_size, butt_size);
|
||||
|
||||
lastMsgDate = QDate::currentDate();
|
||||
|
||||
@ -1607,8 +1606,9 @@ void ChatWidget::deleteChatHistory()
|
||||
|
||||
void ChatWidget::messageHistory()
|
||||
{
|
||||
ImHistoryBrowser imBrowser(chatId, ui->chatTextEdit, window());
|
||||
imBrowser.exec();
|
||||
if (!imBrowser)
|
||||
imBrowser = new ImHistoryBrowser(chatId, ui->chatTextEdit, this->title, window());
|
||||
imBrowser->show();
|
||||
}
|
||||
|
||||
void ChatWidget::addExtraFile()
|
||||
|
@ -23,20 +23,22 @@
|
||||
#ifndef CHATWIDGET_H
|
||||
#define CHATWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QCompleter>
|
||||
#include <QTextCursor>
|
||||
#include <QTextCharFormat>
|
||||
#include <QToolButton>
|
||||
#include "ChatLobbyUserNotify.h"
|
||||
#include "ChatStyle.h"
|
||||
#include "gui/common/HashBox.h"
|
||||
#include "gui/common/RsButtonOnText.h"
|
||||
#include "ChatStyle.h"
|
||||
#include "gui/im_history/ImHistoryBrowser.h"
|
||||
#include "gui/style/RSStyle.h"
|
||||
#include "ChatLobbyUserNotify.h"
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
|
||||
#include <QCompleter>
|
||||
#include <QTextCharFormat>
|
||||
#include <QTextCursor>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
|
||||
//For PersonId anchor.
|
||||
#define PERSONID "PersonId:"
|
||||
|
||||
@ -258,7 +260,8 @@ private:
|
||||
TransferRequestFlags mDefaultExtraFileFlags ; // flags for extra files shared in this chat. Will be 0 by default, but might be ANONYMOUS for chat lobbies.
|
||||
QDate lastMsgDate ;
|
||||
|
||||
QCompleter *completer;
|
||||
QCompleter *completer;
|
||||
ImHistoryBrowser* imBrowser;
|
||||
|
||||
QList<ChatWidgetHolder*> mChatWidgetHolder;
|
||||
ChatLobbyUserNotify* notify;
|
||||
|
@ -91,14 +91,15 @@ void ImHistoryBrowserCreateItemsThread::run()
|
||||
}
|
||||
|
||||
/** Default constructor */
|
||||
ImHistoryBrowser::ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit, QWidget *parent)
|
||||
ImHistoryBrowser::ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit,const QString &chatTitle, QWidget *parent)
|
||||
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
|
||||
{
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
setWindowTitle(tr("%1 's Message History").arg(chatTitle));
|
||||
ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/user/agt_forum64.png"));
|
||||
ui.headerFrame->setHeaderText(tr("Message History"));
|
||||
ui.headerFrame->setHeaderText(windowTitle());
|
||||
|
||||
m_chatId = chatId;
|
||||
textEdit = edit;
|
||||
@ -225,36 +226,43 @@ void ImHistoryBrowser::historyAdd(HistoryMsg& msg)
|
||||
|
||||
void ImHistoryBrowser::historyChanged(uint msgId, int type)
|
||||
{
|
||||
if (type == NOTIFY_TYPE_ADD) {
|
||||
/* history message added */
|
||||
HistoryMsg msg;
|
||||
if (rsHistory->getMessage(msgId, msg) == false) {
|
||||
return;
|
||||
}
|
||||
if (type == NOTIFY_TYPE_ADD) {
|
||||
/* history message added */
|
||||
HistoryMsg msg;
|
||||
if (rsHistory->getMessage(msgId, msg) == false) {
|
||||
return;
|
||||
}
|
||||
RsPeerId virtChatId;
|
||||
if ( rsHistory->chatIdToVirtualPeerId(m_chatId ,virtChatId)
|
||||
&& virtChatId == msg.chatPeerId)
|
||||
historyAdd(msg);
|
||||
|
||||
historyAdd(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (type == NOTIFY_TYPE_DEL) {
|
||||
/* history message removed */
|
||||
int count = ui.listWidget->count();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
QListWidgetItem *itemWidget = ui.listWidget->item(i);
|
||||
if (itemWidget->data(ROLE_MSGID).toString().toUInt() == msgId) {
|
||||
delete(ui.listWidget->takeItem(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == NOTIFY_TYPE_DEL) {
|
||||
/* history message removed */
|
||||
int count = ui.listWidget->count();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
QListWidgetItem *itemWidget = ui.listWidget->item(i);
|
||||
if (itemWidget->data(ROLE_MSGID).toString().toUInt() == msgId) {
|
||||
delete(ui.listWidget->takeItem(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == NOTIFY_TYPE_MOD) {
|
||||
/* clear history */
|
||||
ui.listWidget->clear();
|
||||
return;
|
||||
}
|
||||
if (type == NOTIFY_TYPE_MOD) {
|
||||
/* clear history */
|
||||
// As no ChatId nor msgId are send via Notify,
|
||||
// only check if history of this chat is empty before clear our list.
|
||||
std::list<HistoryMsg> historyMsgs;
|
||||
rsHistory->getMessages(m_chatId, historyMsgs, 1);
|
||||
if (historyMsgs.empty())
|
||||
ui.listWidget->clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ImHistoryBrowser::fillItem(QListWidgetItem *itemWidget, HistoryMsg& msg)
|
||||
|
@ -41,7 +41,7 @@ class ImHistoryBrowser : public QDialog
|
||||
|
||||
public:
|
||||
/** Default constructor */
|
||||
ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit, QWidget *parent = 0);
|
||||
ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit,const QString &chatTitle, QWidget *parent = 0);
|
||||
/** Default destructor */
|
||||
virtual ~ImHistoryBrowser();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user