2018-11-15 21:49:12 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* retroshare-gui/src/gui/gxsforums/GxsForumsThreadWidget.h *
|
|
|
|
* *
|
|
|
|
* Copyright 2012 Retroshare Team <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
|
|
|
|
2012-11-27 23:21:20 +00:00
|
|
|
#ifndef GXSFORUMTHREADWIDGET_H
|
|
|
|
#define GXSFORUMTHREADWIDGET_H
|
|
|
|
|
2017-02-09 14:49:43 +01:00
|
|
|
#include <QMap>
|
|
|
|
|
2014-05-04 22:59:06 +00:00
|
|
|
#include "gui/gxs/GxsMessageFrameWidget.h"
|
2015-05-02 18:50:34 +00:00
|
|
|
#include <retroshare/rsgxsforums.h>
|
2015-05-03 12:28:08 +00:00
|
|
|
#include "gui/gxs/GxsIdDetails.h"
|
2012-11-27 23:21:20 +00:00
|
|
|
|
2018-11-27 15:15:54 +01:00
|
|
|
class QSortFilterProxyModel;
|
2012-11-27 23:21:20 +00:00
|
|
|
class QTreeWidgetItem;
|
|
|
|
class RSTreeWidgetItemCompareRole;
|
2012-12-09 02:32:47 +00:00
|
|
|
class GxsForumsFillThread;
|
2018-12-03 21:28:00 +01:00
|
|
|
class QItemSelection;
|
2019-02-14 23:15:54 +01:00
|
|
|
struct RsGxsForumGroup;
|
2018-11-22 09:47:58 +01:00
|
|
|
class RsGxsForumModel;
|
2019-02-15 00:02:12 +01:00
|
|
|
struct RsGxsForumMsg;
|
2019-02-15 00:04:00 +01:00
|
|
|
struct ForumModelPostEntry;
|
2012-11-27 23:21:20 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class GxsForumThreadWidget;
|
|
|
|
}
|
|
|
|
|
2015-03-13 19:33:37 +00:00
|
|
|
class GxsForumThreadWidget : public GxsMessageFrameWidget
|
2012-11-27 23:21:20 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2018-11-25 17:11:08 +01:00
|
|
|
typedef void (GxsForumThreadWidget::*MsgMethod)(const RsGxsForumMsg&) ;
|
|
|
|
|
2012-11-27 23:21:20 +00:00
|
|
|
Q_PROPERTY(QColor textColorRead READ textColorRead WRITE setTextColorRead)
|
|
|
|
Q_PROPERTY(QColor textColorUnread READ textColorUnread WRITE setTextColorUnread)
|
|
|
|
Q_PROPERTY(QColor textColorUnreadChildren READ textColorUnreadChildren WRITE setTextColorUnreadChildren)
|
|
|
|
Q_PROPERTY(QColor textColorNotSubscribed READ textColorNotSubscribed WRITE setTextColorNotSubscribed)
|
|
|
|
Q_PROPERTY(QColor textColorMissing READ textColorMissing WRITE setTextColorMissing)
|
2020-07-01 17:12:34 +09:00
|
|
|
Q_PROPERTY(QColor textColorPinned READ textColorPinned WRITE setTextColorPinned)
|
2012-11-27 23:21:20 +00:00
|
|
|
|
2020-07-06 13:18:45 +09:00
|
|
|
Q_PROPERTY(QColor backgroundColorPinned READ backgroundColorPinned WRITE setBackgroundColorPinned)
|
|
|
|
Q_PROPERTY(QColor backgroundColorFiltered READ backgroundColorFiltered WRITE setBackgroundColorFiltered)
|
|
|
|
|
2012-11-27 23:21:20 +00:00
|
|
|
public:
|
2014-03-17 20:56:06 +00:00
|
|
|
explicit GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget *parent = NULL);
|
2012-11-27 23:21:20 +00:00
|
|
|
~GxsForumThreadWidget();
|
2012-12-04 16:06:21 +00:00
|
|
|
|
|
|
|
QColor textColorRead() const { return mTextColorRead; }
|
|
|
|
QColor textColorUnread() const { return mTextColorUnread; }
|
|
|
|
QColor textColorUnreadChildren() const { return mTextColorUnreadChildren; }
|
|
|
|
QColor textColorNotSubscribed() const { return mTextColorNotSubscribed; }
|
|
|
|
QColor textColorMissing() const { return mTextColorMissing; }
|
2020-07-01 17:12:34 +09:00
|
|
|
QColor textColorPinned() const { return mTextColorPinned; }
|
2012-11-27 23:21:20 +00:00
|
|
|
|
2020-07-06 13:18:45 +09:00
|
|
|
QColor backgroundColorPinned() const { return mBackgroundColorPinned; }
|
|
|
|
QColor backgroundColorFiltered() const { return mBackgroundColorFiltered; }
|
|
|
|
|
2018-11-24 20:50:09 +01:00
|
|
|
void setTextColorRead (QColor color) ;
|
|
|
|
void setTextColorUnread (QColor color) ;
|
|
|
|
void setTextColorUnreadChildren(QColor color) ;
|
|
|
|
void setTextColorNotSubscribed (QColor color) ;
|
|
|
|
void setTextColorMissing (QColor color) ;
|
2020-07-01 17:12:34 +09:00
|
|
|
void setTextColorPinned (QColor color) ;
|
2012-11-27 23:21:20 +00:00
|
|
|
|
2020-07-06 13:18:45 +09:00
|
|
|
void setBackgroundColorPinned (QColor color);
|
|
|
|
void setBackgroundColorFiltered (QColor color);
|
|
|
|
|
2014-10-25 23:52:33 +00:00
|
|
|
/* GxsMessageFrameWidget */
|
2015-03-13 19:33:37 +00:00
|
|
|
virtual void groupIdChanged();
|
2014-05-04 22:59:06 +00:00
|
|
|
virtual QString groupName(bool withUnreadCount);
|
|
|
|
virtual QIcon groupIcon();
|
2014-10-25 23:52:33 +00:00
|
|
|
virtual bool navigate(const RsGxsMessageId& msgId);
|
|
|
|
|
2012-12-09 02:32:47 +00:00
|
|
|
unsigned int newCount() { return mNewCount; }
|
|
|
|
unsigned int unreadCount() { return mUnreadCount; }
|
|
|
|
|
2014-03-17 20:56:06 +00:00
|
|
|
QTreeWidgetItem *generateMissingItem(const RsGxsMessageId &msgId);
|
2012-12-09 02:32:47 +00:00
|
|
|
|
2018-06-25 23:08:10 +02:00
|
|
|
virtual void blank();
|
2012-11-27 23:21:20 +00:00
|
|
|
|
|
|
|
protected:
|
2018-12-06 23:04:53 +01:00
|
|
|
//bool eventFilter(QObject *obj, QEvent *ev);
|
|
|
|
//void changeEvent(QEvent *e);
|
2015-03-14 21:13:28 +00:00
|
|
|
|
|
|
|
/* RsGxsUpdateBroadcastWidget */
|
2013-07-19 09:48:51 +00:00
|
|
|
virtual void updateDisplay(bool complete);
|
2012-11-27 23:21:20 +00:00
|
|
|
|
2015-03-14 21:13:28 +00:00
|
|
|
/* GxsMessageFrameWidget */
|
|
|
|
virtual void setAllMessagesReadDo(bool read, uint32_t &token);
|
2015-10-10 18:27:15 -04:00
|
|
|
|
2020-03-26 23:19:34 +01:00
|
|
|
void setMessageLoadingError(const QString& error);
|
2012-11-27 23:21:20 +00:00
|
|
|
private slots:
|
|
|
|
/** Create the context popup menu and it's submenus */
|
|
|
|
void threadListCustomPopupMenu(QPoint point);
|
2015-12-06 23:01:23 +01:00
|
|
|
void contextMenuTextBrowser(QPoint point);
|
2020-07-01 16:42:35 +09:00
|
|
|
void headerContextMenuRequested(const QPoint& pos);
|
2012-11-27 23:21:20 +00:00
|
|
|
|
2018-12-03 21:28:00 +01:00
|
|
|
void changedSelection(const QModelIndex &, const QModelIndex &);
|
2018-11-22 22:52:27 +01:00
|
|
|
void changedThread(QModelIndex index);
|
2017-02-09 21:49:24 +01:00
|
|
|
void changedVersion();
|
2020-04-28 19:39:07 +02:00
|
|
|
void clickedThread (QModelIndex index);
|
|
|
|
void postForumLoading();
|
|
|
|
|
2017-02-03 12:48:51 +01:00
|
|
|
void reply_with_private_message();
|
2015-11-19 12:05:52 +01:00
|
|
|
void replytoforummessage();
|
2017-02-03 12:48:51 +01:00
|
|
|
void editforummessage();
|
2015-11-19 12:05:52 +01:00
|
|
|
|
2012-11-27 23:21:20 +00:00
|
|
|
void replyMessageData(const RsGxsForumMsg &msg);
|
2017-02-03 12:48:51 +01:00
|
|
|
void editForumMessageData(const RsGxsForumMsg &msg);
|
2015-11-19 12:05:52 +01:00
|
|
|
void replyForumMessageData(const RsGxsForumMsg &msg);
|
2016-12-27 20:42:47 +01:00
|
|
|
void showAuthorInPeople(const RsGxsForumMsg& msg);
|
|
|
|
|
2018-11-25 17:11:08 +01:00
|
|
|
// This method is used to perform an asynchroneous action on the message data. Any of the methods above can be used as parameter.
|
|
|
|
void async_msg_action(const MsgMethod& method);
|
|
|
|
|
2015-12-06 23:01:23 +01:00
|
|
|
void saveImage();
|
2015-11-19 12:05:52 +01:00
|
|
|
|
2012-11-27 23:21:20 +00:00
|
|
|
void markMsgAsRead();
|
|
|
|
void markMsgAsReadChildren();
|
|
|
|
void markMsgAsUnread();
|
|
|
|
void markMsgAsUnreadChildren();
|
|
|
|
|
|
|
|
void copyMessageLink();
|
2016-12-27 20:42:47 +01:00
|
|
|
void showInPeopleTab();
|
2012-11-27 23:21:20 +00:00
|
|
|
|
|
|
|
/* handle splitter */
|
|
|
|
void togglethreadview();
|
|
|
|
|
2014-07-07 11:18:20 +00:00
|
|
|
void subscribeGroup(bool subscribe);
|
2012-11-27 23:21:20 +00:00
|
|
|
void createthread();
|
2018-08-30 11:48:37 +02:00
|
|
|
void togglePinUpPost();
|
2012-11-27 23:21:20 +00:00
|
|
|
void createmessage();
|
|
|
|
|
|
|
|
void previousMessage();
|
|
|
|
void nextMessage();
|
|
|
|
void nextUnreadMessage();
|
|
|
|
void downloadAllFiles();
|
|
|
|
|
|
|
|
void changedViewBox();
|
2016-12-24 17:29:53 +01:00
|
|
|
void flagperson();
|
2012-11-27 23:21:20 +00:00
|
|
|
|
|
|
|
void filterColumnChanged(int column);
|
|
|
|
void filterItems(const QString &text);
|
2020-07-01 04:23:20 +09:00
|
|
|
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
|
|
|
void expandSubtree();
|
|
|
|
#endif
|
2020-07-01 16:42:35 +09:00
|
|
|
void changeHeaderColumnVisibility(bool visibility);
|
2020-07-02 03:20:09 +09:00
|
|
|
void showBannedText(bool display);
|
2012-11-27 23:21:20 +00:00
|
|
|
private:
|
2014-11-27 22:45:34 +00:00
|
|
|
void insertMessageData(const RsGxsForumMsg &msg);
|
2018-11-24 17:57:19 +01:00
|
|
|
bool getCurrentPost(ForumModelPostEntry& fmpe) const ;
|
2018-11-24 20:50:09 +01:00
|
|
|
QModelIndex getCurrentIndex() const;
|
2012-11-27 23:21:20 +00:00
|
|
|
|
2014-11-27 22:45:34 +00:00
|
|
|
void insertMessage();
|
2018-11-22 22:07:58 +01:00
|
|
|
void insertGroupData();
|
2012-11-27 23:21:20 +00:00
|
|
|
|
2018-12-05 20:28:58 +01:00
|
|
|
void recursRestoreExpandedItems(const QModelIndex& index, const QList<RsGxsMessageId>& expanded_items);
|
|
|
|
void recursSaveExpandedItems(const QModelIndex& index, QList<RsGxsMessageId>& expanded_items) const;
|
|
|
|
void saveExpandedItems(QList<RsGxsMessageId>& expanded_items) const;
|
|
|
|
|
2012-11-27 23:21:20 +00:00
|
|
|
int getSelectedMsgCount(QList<QTreeWidgetItem*> *pRows, QList<QTreeWidgetItem*> *pRowsRead, QList<QTreeWidgetItem*> *pRowsUnread);
|
2020-04-28 19:39:07 +02:00
|
|
|
void setMsgReadStatus(QList<QTreeWidgetItem*> &rows, bool read);
|
|
|
|
void markMsgAsReadUnread(bool read, bool children, bool forum, RsGxsMessageId msgId = RsGxsMessageId());
|
|
|
|
void calculateUnreadCount();
|
2012-11-27 23:21:20 +00:00
|
|
|
|
|
|
|
void togglethreadview_internal();
|
|
|
|
|
2018-12-05 20:28:58 +01:00
|
|
|
//bool filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn);
|
2012-11-27 23:21:20 +00:00
|
|
|
|
|
|
|
void processSettings(bool bLoad);
|
|
|
|
|
2018-11-22 22:07:58 +01:00
|
|
|
void updateGroupData();
|
2015-05-03 12:28:08 +00:00
|
|
|
static void loadAuthorIdCallback(GxsIdDetailsType type, const RsIdentityDetails &details, QObject *object, const QVariant &/*data*/);
|
|
|
|
|
2018-11-22 22:07:58 +01:00
|
|
|
void updateMessageData(const RsGxsMessageId& msgId);
|
2020-03-26 17:10:29 +01:00
|
|
|
void updateForumDescription(bool success);
|
2018-11-22 22:07:58 +01:00
|
|
|
|
2019-12-16 23:52:09 +01:00
|
|
|
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
|
|
|
|
2014-11-27 22:45:34 +00:00
|
|
|
private:
|
2020-03-26 17:10:29 +01:00
|
|
|
void setForumDescriptionLoading();
|
|
|
|
void clearForumDescription();
|
2020-04-28 19:39:07 +02:00
|
|
|
void blankPost();
|
2020-03-26 17:10:29 +01:00
|
|
|
|
2014-03-17 20:56:06 +00:00
|
|
|
RsGxsGroupId mLastForumID;
|
|
|
|
RsGxsMessageId mThreadId;
|
2017-02-09 18:45:55 +01:00
|
|
|
RsGxsMessageId mOrigThreadId;
|
2015-05-02 18:50:34 +00:00
|
|
|
RsGxsForumGroup mForumGroup;
|
2018-12-09 23:25:59 +01:00
|
|
|
//bool mUpdating;
|
2012-11-27 23:21:20 +00:00
|
|
|
bool mInProcessSettings;
|
|
|
|
bool mInMsgAsReadUnread;
|
|
|
|
int mLastViewType;
|
|
|
|
RSTreeWidgetItemCompareRole *mThreadCompareRole;
|
2012-12-09 02:32:47 +00:00
|
|
|
GxsForumsFillThread *mFillThread;
|
|
|
|
unsigned int mUnreadCount;
|
|
|
|
unsigned int mNewCount;
|
2020-07-02 03:20:09 +09:00
|
|
|
bool mDisplayBannedText;
|
2012-11-27 23:21:20 +00:00
|
|
|
|
|
|
|
/* Color definitions (for standard see qss.default) */
|
|
|
|
QColor mTextColorRead;
|
|
|
|
QColor mTextColorUnread;
|
|
|
|
QColor mTextColorUnreadChildren;
|
|
|
|
QColor mTextColorNotSubscribed;
|
|
|
|
QColor mTextColorMissing;
|
2020-07-01 17:12:34 +09:00
|
|
|
QColor mTextColorPinned;
|
2012-11-27 23:21:20 +00:00
|
|
|
|
2020-07-06 13:18:45 +09:00
|
|
|
QColor mBackgroundColorPinned;
|
|
|
|
QColor mBackgroundColorFiltered;
|
|
|
|
|
2020-11-25 19:56:07 +01:00
|
|
|
std::map<RsGxsGroupId,RsGxsMessageId> mLastSelectedPosts;
|
2014-10-25 23:52:33 +00:00
|
|
|
RsGxsMessageId mNavigatePendingMsgId;
|
2014-11-27 22:45:34 +00:00
|
|
|
QList<RsGxsMessageId> mIgnoredMsgId;
|
2014-10-25 23:52:33 +00:00
|
|
|
|
2018-11-22 09:47:58 +01:00
|
|
|
RsGxsForumModel *mThreadModel;
|
2018-11-27 15:15:54 +01:00
|
|
|
QSortFilterProxyModel *mThreadProxyModel;
|
2018-12-05 20:28:58 +01:00
|
|
|
QList<RsGxsMessageId> mSavedExpandedMessages;
|
2018-11-22 09:47:58 +01:00
|
|
|
|
2015-10-09 18:51:16 -04:00
|
|
|
Ui::GxsForumThreadWidget *ui;
|
2019-12-16 23:52:09 +01:00
|
|
|
RsEventsHandlerId_t mEventHandlerId;
|
2012-11-27 23:21:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GXSFORUMTHREADWIDGET_H
|