mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-05 01:25:39 -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
|
// 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()) {
|
if (chat_id.isBroadcast()) {
|
||||||
peer_id = RsPeerId();
|
peer_id = RsPeerId();
|
||||||
|
@ -68,9 +68,9 @@ public:
|
|||||||
virtual void saveDone();
|
virtual void saveDone();
|
||||||
virtual bool loadList(std::list<RsItem*>& load);
|
virtual bool loadList(std::list<RsItem*>& load);
|
||||||
|
|
||||||
private:
|
static bool chatIdToVirtualPeerId(const ChatId& chat_id, RsPeerId& peer_id);
|
||||||
static bool chatIdToVirtualPeerId(ChatId chat_id, RsPeerId& peer_id);
|
|
||||||
|
|
||||||
|
private:
|
||||||
uint32_t nextMsgId;
|
uint32_t nextMsgId;
|
||||||
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> > mMessages;
|
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)
|
static bool cleanIpList(std::list<pqiIpAddress>& lst,const RsPeerId& pid,p3LinkMgr *link_mgr)
|
||||||
{
|
{
|
||||||
bool changed = false ;
|
bool changed = false ;
|
||||||
|
#ifdef PEER_DEBUG
|
||||||
rstime_t now = time(NULL) ;
|
rstime_t now = time(NULL) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
for(std::list<pqiIpAddress>::iterator it2(lst.begin());it2 != lst.end();)
|
for(std::list<pqiIpAddress>::iterator it2(lst.begin());it2 != lst.end();)
|
||||||
{
|
{
|
||||||
|
@ -70,6 +70,7 @@ public:
|
|||||||
class RsHistory
|
class RsHistory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
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 getMessages(const ChatId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
|
||||||
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg) = 0;
|
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg) = 0;
|
||||||
virtual void removeMessages(const std::list<uint32_t> &msgIds) = 0;
|
virtual void removeMessages(const std::list<uint32_t> &msgIds) = 0;
|
||||||
@ -77,8 +78,9 @@ public:
|
|||||||
|
|
||||||
virtual bool getEnable(uint32_t chat_type) = 0;
|
virtual bool getEnable(uint32_t chat_type) = 0;
|
||||||
virtual void setEnable(uint32_t chat_type, bool enable) = 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
|
// 0 = no limit, >0 count of saved messages
|
||||||
virtual uint32_t getSaveCount(uint32_t chat_type) = 0;
|
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)
|
void p3History::setMaxStorageDuration(uint32_t seconds)
|
||||||
{
|
{
|
||||||
mHistoryMgr->setMaxStorageDuration(seconds) ;
|
mHistoryMgr->setMaxStorageDuration(seconds) ;
|
||||||
|
@ -37,16 +37,21 @@ public:
|
|||||||
p3History(p3HistoryMgr* historyMgr);
|
p3History(p3HistoryMgr* historyMgr);
|
||||||
virtual ~p3History();
|
virtual ~p3History();
|
||||||
|
|
||||||
|
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 getMessages(const ChatId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount);
|
||||||
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg);
|
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg);
|
||||||
virtual void removeMessages(const std::list<uint32_t> &msgIds);
|
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 bool getEnable(uint32_t chat_type);
|
||||||
virtual void setEnable(uint32_t chat_type, bool enable);
|
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 uint32_t getSaveCount(uint32_t chat_type);
|
||||||
virtual void setSaveCount(uint32_t chat_type, uint32_t count);
|
virtual void setSaveCount(uint32_t chat_type, uint32_t count);
|
||||||
virtual void setMaxStorageDuration(uint32_t seconds) ;
|
|
||||||
virtual uint32_t getMaxStorageDuration() ;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
p3HistoryMgr* mHistoryMgr;
|
p3HistoryMgr* mHistoryMgr;
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
#include "gui/settings/rsettingswin.h"
|
#include "gui/settings/rsettingswin.h"
|
||||||
#include "gui/settings/RsharePeerSettings.h"
|
#include "gui/settings/RsharePeerSettings.h"
|
||||||
#include "gui/im_history/ImHistoryBrowser.h"
|
|
||||||
#include "gui/common/StatusDefs.h"
|
#include "gui/common/StatusDefs.h"
|
||||||
#include "gui/common/FilesDefs.h"
|
#include "gui/common/FilesDefs.h"
|
||||||
#include "gui/common/Emoticons.h"
|
#include "gui/common/Emoticons.h"
|
||||||
@ -78,7 +77,7 @@ ChatWidget::ChatWidget(QWidget *parent)
|
|||||||
, lastStatusSendTime(0)
|
, lastStatusSendTime(0)
|
||||||
, firstShow(true), inChatCharFormatChanged(false), firstSearch(true)
|
, firstShow(true), inChatCharFormatChanged(false), firstSearch(true)
|
||||||
, lastUpdateCursorPos(0), lastUpdateCursorEnd(0)
|
, lastUpdateCursorPos(0), lastUpdateCursorEnd(0)
|
||||||
, completer(NULL), notify(NULL)
|
, completer(NULL), imBrowser(NULL), notify(NULL)
|
||||||
, ui(new Ui::ChatWidget)
|
, ui(new Ui::ChatWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -87,8 +86,8 @@ ChatWidget::ChatWidget(QWidget *parent)
|
|||||||
double fmm = iconHeight > FMM_THRESHOLD ? FMM : FMM_SMALLER;
|
double fmm = iconHeight > FMM_THRESHOLD ? FMM : FMM_SMALLER;
|
||||||
iconHeight *= fmm;
|
iconHeight *= fmm;
|
||||||
QSize iconSize = QSize(iconHeight, iconHeight);
|
QSize iconSize = QSize(iconHeight, iconHeight);
|
||||||
int butt_size(iconSize.height() + fmm);
|
//int butt_size(iconSize.height() + fmm);
|
||||||
QSize buttonSize = QSize(butt_size, butt_size);
|
//QSize buttonSize = QSize(butt_size, butt_size);
|
||||||
|
|
||||||
lastMsgDate = QDate::currentDate();
|
lastMsgDate = QDate::currentDate();
|
||||||
|
|
||||||
@ -1607,8 +1606,9 @@ void ChatWidget::deleteChatHistory()
|
|||||||
|
|
||||||
void ChatWidget::messageHistory()
|
void ChatWidget::messageHistory()
|
||||||
{
|
{
|
||||||
ImHistoryBrowser imBrowser(chatId, ui->chatTextEdit, window());
|
if (!imBrowser)
|
||||||
imBrowser.exec();
|
imBrowser = new ImHistoryBrowser(chatId, ui->chatTextEdit, this->title, window());
|
||||||
|
imBrowser->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatWidget::addExtraFile()
|
void ChatWidget::addExtraFile()
|
||||||
|
@ -23,20 +23,22 @@
|
|||||||
#ifndef CHATWIDGET_H
|
#ifndef CHATWIDGET_H
|
||||||
#define CHATWIDGET_H
|
#define CHATWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include "ChatLobbyUserNotify.h"
|
||||||
#include <QCompleter>
|
#include "ChatStyle.h"
|
||||||
#include <QTextCursor>
|
|
||||||
#include <QTextCharFormat>
|
|
||||||
#include <QToolButton>
|
|
||||||
#include "gui/common/HashBox.h"
|
#include "gui/common/HashBox.h"
|
||||||
#include "gui/common/RsButtonOnText.h"
|
#include "gui/common/RsButtonOnText.h"
|
||||||
#include "ChatStyle.h"
|
#include "gui/im_history/ImHistoryBrowser.h"
|
||||||
#include "gui/style/RSStyle.h"
|
#include "gui/style/RSStyle.h"
|
||||||
#include "ChatLobbyUserNotify.h"
|
|
||||||
|
|
||||||
#include <retroshare/rsmsgs.h>
|
#include <retroshare/rsmsgs.h>
|
||||||
#include <retroshare/rsfiles.h>
|
#include <retroshare/rsfiles.h>
|
||||||
|
|
||||||
|
#include <QCompleter>
|
||||||
|
#include <QTextCharFormat>
|
||||||
|
#include <QTextCursor>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
//For PersonId anchor.
|
//For PersonId anchor.
|
||||||
#define PERSONID "PersonId:"
|
#define PERSONID "PersonId:"
|
||||||
|
|
||||||
@ -259,6 +261,7 @@ private:
|
|||||||
QDate lastMsgDate ;
|
QDate lastMsgDate ;
|
||||||
|
|
||||||
QCompleter *completer;
|
QCompleter *completer;
|
||||||
|
ImHistoryBrowser* imBrowser;
|
||||||
|
|
||||||
QList<ChatWidgetHolder*> mChatWidgetHolder;
|
QList<ChatWidgetHolder*> mChatWidgetHolder;
|
||||||
ChatLobbyUserNotify* notify;
|
ChatLobbyUserNotify* notify;
|
||||||
|
@ -91,14 +91,15 @@ void ImHistoryBrowserCreateItemsThread::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Default constructor */
|
/** 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)
|
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
|
||||||
{
|
{
|
||||||
/* Invoke Qt Designer generated QObject setup routine */
|
/* Invoke Qt Designer generated QObject setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
setWindowTitle(tr("%1 's Message History").arg(chatTitle));
|
||||||
ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/user/agt_forum64.png"));
|
ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/user/agt_forum64.png"));
|
||||||
ui.headerFrame->setHeaderText(tr("Message History"));
|
ui.headerFrame->setHeaderText(windowTitle());
|
||||||
|
|
||||||
m_chatId = chatId;
|
m_chatId = chatId;
|
||||||
textEdit = edit;
|
textEdit = edit;
|
||||||
@ -231,7 +232,9 @@ void ImHistoryBrowser::historyChanged(uint msgId, int type)
|
|||||||
if (rsHistory->getMessage(msgId, msg) == false) {
|
if (rsHistory->getMessage(msgId, msg) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
RsPeerId virtChatId;
|
||||||
|
if ( rsHistory->chatIdToVirtualPeerId(m_chatId ,virtChatId)
|
||||||
|
&& virtChatId == msg.chatPeerId)
|
||||||
historyAdd(msg);
|
historyAdd(msg);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -252,6 +255,11 @@ void ImHistoryBrowser::historyChanged(uint msgId, int type)
|
|||||||
|
|
||||||
if (type == NOTIFY_TYPE_MOD) {
|
if (type == NOTIFY_TYPE_MOD) {
|
||||||
/* clear history */
|
/* 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();
|
ui.listWidget->clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class ImHistoryBrowser : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/** Default constructor */
|
/** 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 */
|
/** Default destructor */
|
||||||
virtual ~ImHistoryBrowser();
|
virtual ~ImHistoryBrowser();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user