2018-11-14 15:14:40 -05:00
/*******************************************************************************
* retroshare - gui / src / gui / gxs / GxsGroupFrameDialog . h *
* *
* Copyright 2012 - 2013 by Robert Fernie < 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/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2014-05-04 18:59:06 -04:00
# ifndef _GXSGROUPFRAMEDIALOG_H
# define _GXSGROUPFRAMEDIALOG_H
# include "gui/gxs/RsGxsUpdateBroadcastPage.h"
# include "RsAutoUpdatePage.h"
2014-05-27 17:14:05 -04:00
# include "gui/RetroShareLink.h"
2014-07-24 10:54:23 -04:00
# include "gui/settings/rsharesettings.h"
2014-09-11 18:07:06 -04:00
# include "util/RsUserdata.h"
2014-05-04 18:59:06 -04:00
# include <inttypes.h>
# include "GxsIdTreeWidgetItem.h"
# include "GxsGroupDialog.h"
namespace Ui {
class GxsGroupFrameDialog ;
}
class GroupTreeWidget ;
class GroupItemInfo ;
class GxsMessageFrameWidget ;
2014-05-07 17:04:54 -04:00
class UIStateHelper ;
2019-02-14 17:45:08 -05:00
struct RsGxsCommentService ;
2014-05-07 20:00:21 -04:00
class GxsCommentDialog ;
2014-05-04 18:59:06 -04:00
2020-03-22 16:47:14 -04:00
class GxsGroupFrameDialog : public MainPage
2014-05-04 18:59:06 -04:00
{
Q_OBJECT
public :
enum TextType {
TEXT_NAME ,
TEXT_NEW ,
TEXT_TODO ,
TEXT_YOUR_GROUP ,
TEXT_SUBSCRIBED_GROUP ,
TEXT_POPULAR_GROUP ,
TEXT_OTHER_GROUP
} ;
enum IconType {
ICON_NAME ,
ICON_NEW ,
ICON_YOUR_GROUP ,
ICON_SUBSCRIBED_GROUP ,
ICON_POPULAR_GROUP ,
ICON_OTHER_GROUP ,
2018-06-20 16:30:44 -04:00
ICON_SEARCH ,
2014-05-04 18:59:06 -04:00
ICON_DEFAULT
} ;
public :
2018-07-05 08:00:04 -04:00
GxsGroupFrameDialog ( RsGxsIfaceHelper * ifaceImpl , QWidget * parent = 0 , bool allow_dist_sync = false ) ;
2014-09-10 17:38:43 -04:00
virtual ~ GxsGroupFrameDialog ( ) ;
2014-05-04 18:59:06 -04:00
2014-10-25 11:50:00 -04:00
bool navigate ( const RsGxsGroupId & groupId , const RsGxsMessageId & msgId ) ;
2014-05-04 18:59:06 -04:00
2014-09-10 17:38:43 -04:00
virtual QString getHelpString ( ) const = 0 ;
2018-07-05 04:11:12 -04:00
virtual void getGroupList ( std : : map < RsGxsGroupId , RsGroupMetaData > & groups ) ;
2017-10-21 15:23:40 -04:00
2020-04-08 15:11:53 -04:00
void getServiceStatistics ( GxsServiceStatistic & stats ) const ;
2014-05-04 18:59:06 -04:00
protected :
2020-04-06 15:55:07 -04:00
virtual void showEvent ( QShowEvent * event ) override ;
virtual void paintEvent ( QPaintEvent * pe ) override ;
2014-05-04 18:59:06 -04:00
virtual void updateDisplay ( bool complete ) ;
2015-03-13 15:33:37 -04:00
const RsGxsGroupId & groupId ( ) { return mGroupId ; }
2014-05-04 18:59:06 -04:00
void setSingleTab ( bool singleTab ) ;
2014-07-14 17:29:51 -04:00
void setHideTabBarWithOneTab ( bool hideTabBarWithOneTab ) ;
2014-07-24 10:54:23 -04:00
bool getCurrentGroupName ( QString & name ) ;
virtual RetroShareLink : : enumType getLinkType ( ) = 0 ;
virtual GroupFrameSettings : : Type groupFrameSettingsType ( ) { return GroupFrameSettings : : Nothing ; }
2020-03-21 10:25:34 -04:00
virtual void groupInfoToGroupItemInfo ( const RsGxsGenericGroupData * groupInfo , GroupItemInfo & groupItemInfo ) ;
2018-07-04 17:54:26 -04:00
virtual void checkRequestGroup ( const RsGxsGroupId & /* grpId */ ) { } // overload this one in order to retrieve full group data when the group is browsed
2014-05-04 18:59:06 -04:00
2020-01-26 17:19:20 -05:00
void updateMessageSummaryList ( RsGxsGroupId groupId ) ;
2020-03-22 16:47:14 -04:00
void updateGroupStatistics ( const RsGxsGroupId & groupId ) ;
2020-01-26 17:19:20 -05:00
2020-02-06 13:57:23 -05:00
virtual const std : : set < TurtleRequestId > getSearchRequests ( ) const { return std : : set < TurtleRequestId > ( ) ; } // overload this for subclasses that provide distant search
2020-03-21 10:25:34 -04:00
2020-03-22 16:47:14 -04:00
// These two need to be overloaded by subsclasses, possibly calling the blocking API, since they are used asynchroneously.
2020-03-21 10:25:34 -04:00
virtual bool getGroupData ( std : : list < RsGxsGenericGroupData * > & groupInfo ) = 0 ;
2020-03-22 16:47:14 -04:00
virtual bool getGroupStatistics ( const RsGxsGroupId & groupId , GxsGroupStatistic & stat ) = 0 ;
2020-04-11 14:52:35 -04:00
void updateGroupStatisticsReal ( const RsGxsGroupId & groupId ) ;
void updateMessageSummaryListReal ( RsGxsGroupId groupId ) ;
2014-05-04 18:59:06 -04:00
private slots :
void todo ( ) ;
/** Create the context popup menu and it's submenus */
void groupTreeCustomPopupMenu ( QPoint point ) ;
2014-07-24 10:54:23 -04:00
void settingsChanged ( ) ;
2016-12-05 16:14:48 -05:00
void setSyncPostsDelay ( ) ;
void setStorePostsDelay ( ) ;
2014-05-04 18:59:06 -04:00
void restoreGroupKeys ( ) ;
void newGroup ( ) ;
2018-07-05 05:43:55 -04:00
void distantRequestGroupData ( ) ;
2014-05-04 18:59:06 -04:00
2018-06-21 03:26:03 -04:00
void changedCurrentGroup ( const QString & groupId ) ;
2014-05-04 18:59:06 -04:00
void groupTreeMiddleButtonClicked ( QTreeWidgetItem * item ) ;
void openInNewTab ( ) ;
void messageTabCloseRequested ( int index ) ;
void messageTabChanged ( int index ) ;
void messageTabInfoChanged ( QWidget * widget ) ;
2015-03-14 17:13:28 -04:00
void messageTabWaitingChanged ( QWidget * widget ) ;
2014-05-04 18:59:06 -04:00
void copyGroupLink ( ) ;
void subscribeGroup ( ) ;
void unsubscribeGroup ( ) ;
void showGroupDetails ( ) ;
void editGroupDetails ( ) ;
void markMsgAsRead ( ) ;
void markMsgAsUnread ( ) ;
2016-06-16 22:23:27 -04:00
void sharePublishKey ( ) ;
2014-05-04 18:59:06 -04:00
2017-05-18 16:31:52 -04:00
void loadComment ( const RsGxsGroupId & grpId , const QVector < RsGxsMessageId > & msg_versions , const RsGxsMessageId & most_recent_msgId , const QString & title ) ;
2018-06-20 17:26:37 -04:00
2018-06-20 16:30:44 -04:00
void searchNetwork ( const QString & search_string ) ;
2018-06-20 17:26:37 -04:00
void removeAllSearches ( ) ;
void removeCurrentSearch ( ) ;
2014-05-07 20:00:21 -04:00
2014-05-04 18:59:06 -04:00
private :
virtual QString text ( TextType type ) = 0 ;
virtual QString icon ( IconType type ) = 0 ;
virtual QString settingsGroupName ( ) = 0 ;
2018-06-20 16:30:44 -04:00
virtual TurtleRequestId distantSearch ( const QString & search_string ) ;
2014-05-27 17:14:05 -04:00
2020-03-22 16:47:14 -04:00
virtual GxsGroupDialog * createNewGroupDialog ( ) = 0 ;
virtual GxsGroupDialog * createGroupDialog ( GxsGroupDialog : : Mode mode , RsGxsGroupId groupId ) = 0 ;
2014-05-04 18:59:06 -04:00
virtual int shareKeyType ( ) = 0 ;
virtual GxsMessageFrameWidget * createMessageFrameWidget ( const RsGxsGroupId & groupId ) = 0 ;
virtual void groupTreeCustomActions ( RsGxsGroupId /*grpId*/ , int /*subscribeFlags*/ , QList < QAction * > & /*actions*/ ) { }
2014-05-07 20:00:21 -04:00
virtual RsGxsCommentService * getCommentService ( ) { return NULL ; }
virtual QWidget * createCommentHeaderWidget ( const RsGxsGroupId & /*grpId*/ , const RsGxsMessageId & /*msgId*/ ) { return NULL ; }
2020-06-16 15:13:55 -04:00
virtual bool getDistantSearchResults ( TurtleRequestId /* id */ , std : : map < RsGxsGroupId , RsGxsGroupSearchResults > & /* group_infos */ ) { return false ; }
2014-05-04 18:59:06 -04:00
void initUi ( ) ;
void openGroupInNewTab ( const RsGxsGroupId & groupId ) ;
void groupSubscribe ( bool subscribe ) ;
void processSettings ( bool load ) ;
// New Request/Response Loading Functions.
2020-03-21 10:25:34 -04:00
void insertGroupsData ( const std : : list < RsGxsGenericGroupData * > & groupList ) ;
//void requestGroupSummary();
void updateGroupSummary ( ) ;
void loadGroupSummary ( const std : : list < RsGxsGenericGroupData * > & groupInfo ) ;
2014-05-04 18:59:06 -04:00
2014-09-11 18:07:06 -04:00
virtual uint32_t requestGroupSummaryType ( ) { return GXS_REQUEST_TYPE_GROUP_META ; } // request only meta data
2014-05-04 18:59:06 -04:00
// subscribe/unsubscribe ack.
2020-06-23 15:37:36 -04:00
GxsMessageFrameWidget * messageWidget ( const RsGxsGroupId & groupId ) ;
2014-05-04 18:59:06 -04:00
GxsMessageFrameWidget * createMessageWidget ( const RsGxsGroupId & groupId ) ;
2014-05-07 20:00:21 -04:00
GxsCommentDialog * commentWidget ( const RsGxsMessageId & msgId ) ;
2014-09-24 19:57:47 -04:00
protected :
2020-06-16 15:13:55 -04:00
void updateSearchResults ( const TurtleRequestId & sid ) ;
void updateSearchResults ( ) ; // update all searches
2020-02-03 15:39:05 -05:00
2014-09-24 19:57:47 -04:00
bool mCountChildMsgs ; // Count unread child messages?
2014-05-04 18:59:06 -04:00
private :
2020-06-23 14:24:14 -04:00
GxsMessageFrameWidget * currentWidget ( ) const ;
2020-06-23 15:37:36 -04:00
bool useTabs ( ) ;
2020-06-23 14:24:14 -04:00
2014-05-04 18:59:06 -04:00
bool mInitialized ;
2015-08-26 08:51:34 -04:00
bool mInFill ;
2018-07-05 08:00:04 -04:00
bool mDistSyncAllowed ;
2014-05-04 18:59:06 -04:00
QString mSettingsName ;
RsGxsGroupId mGroupId ;
RsGxsIfaceHelper * mInterface ;
QTreeWidgetItem * mYourGroups ;
QTreeWidgetItem * mSubscribedGroups ;
QTreeWidgetItem * mPopularGroups ;
QTreeWidgetItem * mOtherGroups ;
2014-10-25 11:50:00 -04:00
RsGxsGroupId mNavigatePendingGroupId ;
RsGxsMessageId mNavigatePendingMsgId ;
2020-04-11 14:52:35 -04:00
// Message summary list update
2020-04-06 15:55:07 -04:00
bool mShouldUpdateMessageSummaryList ; // whether we should update the counting for groups. This takes some CPU so we only do it when needed.
std : : set < RsGxsGroupId > mGroupIdsSummaryToUpdate ;
2020-04-11 14:52:35 -04:00
// GroupStatistics update
bool mShouldUpdateGroupStatistics ;
rstime_t mLastGroupStatisticsUpdateTs ;
std : : set < RsGxsGroupId > mGroupStatisticsToUpdate ;
2014-05-07 17:04:54 -04:00
UIStateHelper * mStateHelper ;
2014-05-04 18:59:06 -04:00
/** Qt Designer generated object */
Ui : : GxsGroupFrameDialog * ui ;
2017-10-21 15:23:40 -04:00
2018-07-05 04:11:12 -04:00
std : : map < RsGxsGroupId , RsGroupMetaData > mCachedGroupMetas ;
2020-04-08 15:11:53 -04:00
std : : map < RsGxsGroupId , GxsGroupStatistic > mCachedGroupStats ;
2018-06-20 16:30:44 -04:00
2018-06-24 17:15:22 -04:00
std : : map < uint32_t , QTreeWidgetItem * > mSearchGroupsItems ;
std : : map < uint32_t , std : : set < RsGxsGroupId > > mKnownGroups ;
2014-05-04 18:59:06 -04:00
} ;
# endif