2018-12-02 16:45:16 +01:00
/*******************************************************************************
* retroshare - gui / src / gui / gxsforums / GxsForumModel . cpp *
* *
* Copyright 2018 by Cyril Soler < csoler @ users . sourceforge . net > *
* *
* 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/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2018-11-17 22:36:07 +01:00
# include <QApplication>
# include <QFontMetrics>
# include <QModelIndex>
2018-11-24 22:06:34 +01:00
# include <QIcon>
2018-11-17 22:36:07 +01:00
2020-04-19 17:41:13 +02:00
# include "gui/common/FilesDefs.h"
2018-11-21 23:18:08 +01:00
# include "util/qtthreadsutils.h"
2018-11-25 21:12:26 +01:00
# include "util/HandleRichText.h"
2018-11-22 09:28:07 +01:00
# include "util/DateTime.h"
2018-11-25 21:12:26 +01:00
# include "gui/gxs/GxsIdDetails.h"
2020-05-03 20:31:32 +02:00
# include "gui/gxs/GxsIdTreeWidgetItem.h"
2018-11-17 22:36:07 +01:00
# include "GxsForumModel.h"
2018-11-24 16:11:40 +01:00
# include "retroshare/rsgxsflags.h"
2018-11-21 23:18:08 +01:00
# include "retroshare/rsgxsforums.h"
2018-12-01 16:09:35 +01:00
# include "retroshare/rsexpr.h"
2018-11-17 22:36:07 +01:00
2018-11-22 10:44:06 +01:00
//#define DEBUG_FORUMMODEL
2018-11-17 22:36:07 +01:00
Q_DECLARE_METATYPE ( RsMsgMetaData ) ;
2018-11-18 21:36:13 +01:00
std : : ostream & operator < < ( std : : ostream & o , const QModelIndex & i ) ; // defined elsewhere
2018-11-17 22:36:07 +01:00
2018-12-01 16:09:35 +01:00
const QString RsGxsForumModel : : FilterString ( " filtered " ) ;
2018-11-17 22:36:07 +01:00
RsGxsForumModel : : RsGxsForumModel ( QObject * parent )
2020-04-26 13:07:39 +02:00
: QAbstractItemModel ( parent ) , mUseChildTS ( false ) , mFilteringEnabled ( false ) , mTreeMode ( TREE_MODE_TREE )
2018-11-17 22:36:07 +01:00
{
2018-11-22 10:44:06 +01:00
initEmptyHierarchy ( mPosts ) ;
2018-11-17 22:36:07 +01:00
}
2018-12-04 09:36:06 +01:00
void RsGxsForumModel : : preMods ( )
{
2020-04-19 19:11:34 +02:00
//emit layoutAboutToBeChanged(); //Generate SIGSEGV when click on button move next/prev.
2020-04-15 11:31:26 +02:00
beginResetModel ( ) ;
2018-12-04 09:36:06 +01:00
}
void RsGxsForumModel : : postMods ( )
{
2020-04-15 11:31:26 +02:00
endResetModel ( ) ;
2019-10-14 20:27:53 +02:00
if ( mTreeMode = = TREE_MODE_FLAT )
emit dataChanged ( createIndex ( 0 , 0 , ( void * ) NULL ) , createIndex ( mPosts . size ( ) , COLUMN_THREAD_NB_COLUMNS - 1 , ( void * ) NULL ) ) ;
else
emit dataChanged ( createIndex ( 0 , 0 , ( void * ) NULL ) , createIndex ( mPosts [ 0 ] . mChildren . size ( ) , COLUMN_THREAD_NB_COLUMNS - 1 , ( void * ) NULL ) ) ;
2018-12-04 09:36:06 +01:00
}
2018-12-02 12:02:25 +01:00
void RsGxsForumModel : : setTreeMode ( TreeMode mode )
{
if ( mode = = mTreeMode )
return ;
2018-12-04 09:36:06 +01:00
preMods ( ) ;
2019-10-14 20:27:53 +02:00
if ( mode = = TREE_MODE_TREE ) // means we were in FLAT mode, so the last rows are removed.
{
beginRemoveRows ( QModelIndex ( ) , mPosts [ 0 ] . mChildren . size ( ) , mPosts . size ( ) - 1 ) ;
endRemoveRows ( ) ;
}
2018-12-02 12:02:25 +01:00
mTreeMode = mode ;
2019-10-14 20:27:53 +02:00
if ( mode = = TREE_MODE_FLAT ) // means we were in tree mode, so the last rows are added.
{
beginInsertRows ( QModelIndex ( ) , mPosts [ 0 ] . mChildren . size ( ) , mPosts . size ( ) - 1 ) ;
endInsertRows ( ) ;
}
2018-12-04 09:36:06 +01:00
postMods ( ) ;
2018-12-02 12:02:25 +01:00
}
2018-12-02 16:34:43 +01:00
void RsGxsForumModel : : setSortMode ( SortMode mode )
{
2018-12-04 09:36:06 +01:00
preMods ( ) ;
2018-12-02 16:34:43 +01:00
mSortMode = mode ;
2018-12-04 09:36:06 +01:00
postMods ( ) ;
2018-12-02 16:34:43 +01:00
}
2018-11-22 10:44:06 +01:00
void RsGxsForumModel : : initEmptyHierarchy ( std : : vector < ForumModelPostEntry > & posts )
{
2018-12-04 09:36:06 +01:00
preMods ( ) ;
2018-12-02 12:02:25 +01:00
2018-11-22 10:44:06 +01:00
posts . resize ( 1 ) ; // adds a sentinel item
posts [ 0 ] . mTitle = " Root sentinel post " ;
posts [ 0 ] . mParent = 0 ;
2018-12-02 12:02:25 +01:00
2018-12-04 09:36:06 +01:00
postMods ( ) ;
2018-11-22 10:44:06 +01:00
}
2018-11-17 22:36:07 +01:00
int RsGxsForumModel : : rowCount ( const QModelIndex & parent ) const
{
2018-11-19 21:45:42 +01:00
if ( parent . column ( ) > 0 )
return 0 ;
2018-11-17 22:36:07 +01:00
if ( mPosts . empty ( ) ) // security. Should never happen.
return 0 ;
2018-11-19 21:45:42 +01:00
if ( ! parent . isValid ( ) )
return getChildrenCount ( NULL ) ;
else
return getChildrenCount ( parent . internalPointer ( ) ) ;
2018-11-17 22:36:07 +01:00
}
2018-11-27 19:21:49 +01:00
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
int RsGxsForumModel : : columnCount ( const QModelIndex & /*parent*/ ) const
2018-11-17 22:36:07 +01:00
{
2018-11-22 22:52:27 +01:00
return COLUMN_THREAD_NB_COLUMNS ;
2018-11-17 22:36:07 +01:00
}
2018-11-27 19:21:49 +01:00
std : : vector < std : : pair < time_t , RsGxsMessageId > > RsGxsForumModel : : getPostVersions ( const RsGxsMessageId & mid ) const
{
auto it = mPostVersions . find ( mid ) ;
if ( it ! = mPostVersions . end ( ) )
return it - > second ;
else
return std : : vector < std : : pair < time_t , RsGxsMessageId > > ( ) ;
}
2018-11-24 17:57:19 +01:00
bool RsGxsForumModel : : getPostData ( const QModelIndex & i , ForumModelPostEntry & fmpe ) const
{
if ( ! i . isValid ( ) )
return true ;
void * ref = i . internalPointer ( ) ;
uint32_t entry = 0 ;
if ( ! convertRefPointerToTabEntry ( ref , entry ) | | entry > = mPosts . size ( ) )
return false ;
fmpe = mPosts [ entry ] ;
return true ;
}
2018-11-17 22:36:07 +01:00
bool RsGxsForumModel : : hasChildren ( const QModelIndex & parent ) const
{
2018-11-19 21:45:42 +01:00
if ( ! parent . isValid ( ) )
return true ;
2018-12-02 12:02:25 +01:00
if ( mTreeMode = = TREE_MODE_FLAT )
return false ;
2018-11-19 21:45:42 +01:00
void * ref = parent . internalPointer ( ) ;
2018-11-17 22:36:07 +01:00
uint32_t entry = 0 ;
if ( ! convertRefPointerToTabEntry ( ref , entry ) | | entry > = mPosts . size ( ) )
{
# ifdef DEBUG_FORUMMODEL
std : : cerr < < " hasChildren-2( " < < parent < < " ) : " < < false < < std : : endl ;
# endif
return false ;
}
2018-11-19 21:45:42 +01:00
# ifdef DEBUG_FORUMMODEL
2018-11-21 23:18:08 +01:00
std : : cerr < < " hasChildren-3( " < < parent < < " ) : " < < ! mPosts [ entry ] . mChildren . empty ( ) < < std : : endl ;
2018-11-17 22:36:07 +01:00
# endif
2018-11-21 23:18:08 +01:00
return ! mPosts [ entry ] . mChildren . empty ( ) ;
2018-11-17 22:36:07 +01:00
}
bool RsGxsForumModel : : convertTabEntryToRefPointer ( uint32_t entry , void * & ref )
{
// the pointer is formed the following way:
//
// [ 32 bits ]
//
// This means that the whole software has the following build-in limitation:
// * 4 B simultaenous posts. Should be enough !
ref = reinterpret_cast < void * > ( ( intptr_t ) entry ) ;
return true ;
}
bool RsGxsForumModel : : convertRefPointerToTabEntry ( void * ref , uint32_t & entry )
{
intptr_t val = ( intptr_t ) ref ;
2018-12-08 21:43:14 +01:00
if ( val > ( 1 < < 30 ) ) // make sure the pointer is an int that fits in 32bits and not too big which would look suspicious
2018-11-17 22:36:07 +01:00
{
2018-11-19 21:45:42 +01:00
std : : cerr < < " (EE) trying to make a ForumModelIndex out of a number that is larger than 2^32-1 ! " < < std : : endl ;
2018-11-17 22:36:07 +01:00
return false ;
}
entry = uint32_t ( val ) ;
return true ;
}
QModelIndex RsGxsForumModel : : index ( int row , int column , const QModelIndex & parent ) const
{
2018-11-22 22:52:27 +01:00
if ( row < 0 | | column < 0 | | column > = COLUMN_THREAD_NB_COLUMNS )
2018-11-17 22:36:07 +01:00
return QModelIndex ( ) ;
2018-11-19 21:45:42 +01:00
void * ref = getChildRef ( parent . internalPointer ( ) , row ) ;
2018-11-17 22:36:07 +01:00
# ifdef DEBUG_FORUMMODEL
2018-11-19 21:45:42 +01:00
std : : cerr < < " index-3( " < < row < < " , " < < column < < " parent= " < < parent < < " ) : " < < createIndex ( row , column , ref ) < < std : : endl ;
2018-11-17 22:36:07 +01:00
# endif
2018-11-19 21:45:42 +01:00
return createIndex ( row , column , ref ) ;
}
2018-11-17 22:36:07 +01:00
2018-11-19 21:45:42 +01:00
QModelIndex RsGxsForumModel : : parent ( const QModelIndex & index ) const
{
if ( ! index . isValid ( ) )
return QModelIndex ( ) ;
2018-11-17 22:36:07 +01:00
2018-12-02 12:02:25 +01:00
if ( mTreeMode = = TREE_MODE_FLAT )
return QModelIndex ( ) ;
2018-11-19 21:45:42 +01:00
void * child_ref = index . internalPointer ( ) ;
int row = 0 ;
2018-11-17 22:36:07 +01:00
2018-11-19 21:45:42 +01:00
void * parent_ref = getParentRef ( child_ref , row ) ;
if ( parent_ref = = NULL ) // root
return QModelIndex ( ) ;
return createIndex ( row , 0 , parent_ref ) ;
2018-11-17 22:36:07 +01:00
}
2018-11-19 21:45:42 +01:00
Qt : : ItemFlags RsGxsForumModel : : flags ( const QModelIndex & index ) const
2018-11-17 22:36:07 +01:00
{
2018-11-19 21:45:42 +01:00
if ( ! index . isValid ( ) )
return 0 ;
2018-11-17 22:36:07 +01:00
2018-11-19 21:45:42 +01:00
return QAbstractItemModel : : flags ( index ) ;
}
void * RsGxsForumModel : : getChildRef ( void * ref , int row ) const
{
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
if ( row < 0 )
return nullptr ;
2018-11-19 21:45:42 +01:00
ForumModelIndex entry ;
2018-11-17 22:36:07 +01:00
2018-11-19 21:45:42 +01:00
if ( ! convertRefPointerToTabEntry ( ref , entry ) | | entry > = mPosts . size ( ) )
return NULL ;
2018-11-18 21:36:13 +01:00
2018-11-19 21:45:42 +01:00
void * new_ref ;
2018-12-02 12:02:25 +01:00
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
if ( mTreeMode = = TREE_MODE_FLAT )
{
if ( entry = = 0 )
{
2018-12-02 12:02:25 +01:00
convertTabEntryToRefPointer ( row + 1 , new_ref ) ;
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
return new_ref ;
}
2018-12-02 12:02:25 +01:00
else
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
{
return NULL ;
}
}
2018-12-02 12:02:25 +01:00
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
if ( static_cast < size_t > ( row ) > = mPosts [ entry ] . mChildren . size ( ) )
2018-11-19 21:45:42 +01:00
return NULL ;
2018-11-17 22:36:07 +01:00
2018-11-21 23:18:08 +01:00
convertTabEntryToRefPointer ( mPosts [ entry ] . mChildren [ row ] , new_ref ) ;
2018-11-19 21:45:42 +01:00
return new_ref ;
}
void * RsGxsForumModel : : getParentRef ( void * ref , int & row ) const
{
ForumModelIndex ref_entry ;
if ( ! convertRefPointerToTabEntry ( ref , ref_entry ) | | ref_entry > = mPosts . size ( ) )
return NULL ;
2019-10-14 22:24:36 +02:00
if ( mTreeMode = = TREE_MODE_FLAT )
{
if ( ref_entry = = 0 )
{
RsErr ( ) < < " getParentRef() shouldn't be asked for the parent of NULL " < < std : : endl ;
row = 0 ;
}
else
row = ref_entry - 1 ;
return NULL ;
}
2018-11-21 23:18:08 +01:00
ForumModelIndex parent_entry = mPosts [ ref_entry ] . mParent ;
2018-11-17 22:36:07 +01:00
2018-11-18 21:36:13 +01:00
if ( parent_entry = = 0 ) // top level index
2018-11-19 21:45:42 +01:00
{
row = 0 ;
return NULL ;
}
2018-11-18 21:36:13 +01:00
else
{
2018-11-19 21:45:42 +01:00
void * parent_ref ;
convertTabEntryToRefPointer ( parent_entry , parent_ref ) ;
row = mPosts [ parent_entry ] . prow ;
2018-11-17 22:36:07 +01:00
2018-11-19 21:45:42 +01:00
return parent_ref ;
2018-11-18 21:36:13 +01:00
}
2018-11-17 22:36:07 +01:00
}
2018-11-19 21:45:42 +01:00
int RsGxsForumModel : : getChildrenCount ( void * ref ) const
{
uint32_t entry = 0 ;
if ( ! convertRefPointerToTabEntry ( ref , entry ) | | entry > = mPosts . size ( ) )
return 0 ;
2018-12-02 12:02:25 +01:00
if ( mTreeMode = = TREE_MODE_FLAT )
if ( entry = = 0 )
2019-10-14 20:27:53 +02:00
{
# ifdef DEBUG_FORUMMODEL
std : : cerr < < " Children count (flat mode): " < < mPosts . size ( ) - 1 < < std : : endl ;
# endif
2018-12-02 12:02:25 +01:00
return ( ( int ) mPosts . size ( ) ) - 1 ;
2019-10-14 20:27:53 +02:00
}
2018-12-02 12:02:25 +01:00
else
return 0 ;
else
2019-10-14 20:27:53 +02:00
{
# ifdef DEBUG_FORUMMODEL
std : : cerr < < " Children count (tree mode): " < < mPosts [ entry ] . mChildren . size ( ) < < std : : endl ;
# endif
2018-12-02 12:02:25 +01:00
return mPosts [ entry ] . mChildren . size ( ) ;
2019-10-14 20:27:53 +02:00
}
2018-11-19 21:45:42 +01:00
}
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
QVariant RsGxsForumModel : : headerData ( int section , Qt : : Orientation /*orientation*/ , int role ) const
2018-11-17 22:36:07 +01:00
{
2018-11-24 22:06:34 +01:00
if ( role = = Qt : : DisplayRole )
switch ( section )
{
case COLUMN_THREAD_TITLE : return tr ( " Title " ) ;
case COLUMN_THREAD_DATE : return tr ( " Date " ) ;
case COLUMN_THREAD_AUTHOR : return tr ( " Author " ) ;
default :
return QVariant ( ) ;
}
2018-11-17 22:36:07 +01:00
2018-11-24 22:06:34 +01:00
if ( role = = Qt : : DecorationRole )
switch ( section )
{
2020-04-19 17:41:13 +02:00
case COLUMN_THREAD_DISTRIBUTION : return FilesDefs : : getIconFromQtResourcePath ( " :/icons/flag-green.png " ) ;
case COLUMN_THREAD_READ : return FilesDefs : : getIconFromQtResourcePath ( " :/images/message-state-read.png " ) ;
2018-11-24 22:06:34 +01:00
default :
return QVariant ( ) ;
}
return QVariant ( ) ;
2018-11-17 22:36:07 +01:00
}
QVariant RsGxsForumModel : : data ( const QModelIndex & index , int role ) const
{
2018-11-19 21:45:42 +01:00
# ifdef DEBUG_FORUMMODEL
std : : cerr < < " calling data( " < < index < < " ) role= " < < role < < std : : endl ;
# endif
2018-11-17 22:36:07 +01:00
if ( ! index . isValid ( ) )
return QVariant ( ) ;
switch ( role )
{
2018-11-24 20:50:09 +01:00
case Qt : : SizeHintRole : return sizeHintRole ( index . column ( ) ) ;
case Qt : : StatusTipRole : return QVariant ( ) ;
2018-11-19 21:45:42 +01:00
default : break ;
2018-11-17 22:36:07 +01:00
}
void * ref = ( index . isValid ( ) ) ? index . internalPointer ( ) : NULL ;
uint32_t entry = 0 ;
# ifdef DEBUG_FORUMMODEL
std : : cerr < < " data( " < < index < < " ) " ;
# endif
if ( ! ref )
{
# ifdef DEBUG_FORUMMODEL
std : : cerr < < " [empty] " < < std : : endl ;
# endif
return QVariant ( ) ;
}
if ( ! convertRefPointerToTabEntry ( ref , entry ) | | entry > = mPosts . size ( ) )
{
# ifdef DEBUG_FORUMMODEL
std : : cerr < < " Bad pointer: " < < ( void * ) ref < < std : : endl ;
# endif
return QVariant ( ) ;
}
2018-11-21 23:18:08 +01:00
const ForumModelPostEntry & fmpe ( mPosts [ entry ] ) ;
2018-11-17 22:36:07 +01:00
2018-11-24 16:11:40 +01:00
if ( role = = Qt : : FontRole )
{
QFont font ;
2018-11-30 18:01:51 +01:00
font . setBold ( ( fmpe . mPostFlags & ( ForumModelPostEntry : : FLAG_POST_HAS_UNREAD_CHILDREN | ForumModelPostEntry : : FLAG_POST_IS_PINNED ) ) | | IS_MSG_UNREAD ( fmpe . mMsgStatus ) ) ;
2018-11-24 16:11:40 +01:00
return QVariant ( font ) ;
}
2018-11-26 22:48:47 +01:00
if ( role = = UnreadChildrenRole )
return bool ( fmpe . mPostFlags & ForumModelPostEntry : : FLAG_POST_HAS_UNREAD_CHILDREN ) ;
2018-11-18 21:36:13 +01:00
# ifdef DEBUG_FORUMMODEL
2018-11-17 22:36:07 +01:00
std : : cerr < < " [ok] " < < std : : endl ;
# endif
switch ( role )
{
2018-11-21 23:18:08 +01:00
case Qt : : DisplayRole : return displayRole ( fmpe , index . column ( ) ) ;
case Qt : : DecorationRole : return decorationRole ( fmpe , index . column ( ) ) ;
case Qt : : ToolTipRole : return toolTipRole ( fmpe , index . column ( ) ) ;
2018-11-24 16:11:40 +01:00
case Qt : : UserRole : return userRole ( fmpe , index . column ( ) ) ;
2018-11-24 20:50:09 +01:00
case Qt : : TextColorRole : return textColorRole ( fmpe , index . column ( ) ) ;
2018-11-27 15:15:54 +01:00
case Qt : : BackgroundRole : return backgroundRole ( fmpe , index . column ( ) ) ;
2018-11-21 23:18:08 +01:00
2018-12-01 16:09:35 +01:00
case FilterRole : return filterRole ( fmpe , index . column ( ) ) ;
2018-11-21 23:18:08 +01:00
case ThreadPinnedRole : return pinnedRole ( fmpe , index . column ( ) ) ;
case MissingRole : return missingRole ( fmpe , index . column ( ) ) ;
case StatusRole : return statusRole ( fmpe , index . column ( ) ) ;
2018-11-30 17:24:43 +01:00
case SortRole : return sortRole ( fmpe , index . column ( ) ) ;
2018-11-17 22:36:07 +01:00
default :
return QVariant ( ) ;
}
}
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
QVariant RsGxsForumModel : : textColorRole ( const ForumModelPostEntry & fmpe , int /*column*/ ) const
2018-11-24 20:50:09 +01:00
{
2018-11-24 22:25:23 +01:00
if ( ( fmpe . mPostFlags & ForumModelPostEntry : : FLAG_POST_IS_MISSING ) )
return QVariant ( mTextColorMissing ) ;
2020-07-01 17:12:34 +09:00
if ( IS_MSG_UNREAD ( fmpe . mMsgStatus ) )
2018-11-24 22:25:23 +01:00
return QVariant ( mTextColorUnread ) ;
else
2020-07-01 17:12:34 +09:00
if ( fmpe . mPostFlags & ForumModelPostEntry : : FLAG_POST_IS_PINNED )
return QVariant ( mTextColorPinned ) ;
else
return QVariant ( mTextColorRead ) ;
2018-11-24 20:50:09 +01:00
return QVariant ( ) ;
}
2018-11-21 23:18:08 +01:00
QVariant RsGxsForumModel : : statusRole ( const ForumModelPostEntry & fmpe , int column ) const
2018-11-20 23:28:07 +01:00
{
if ( column ! = COLUMN_THREAD_DATA )
return QVariant ( ) ;
2018-11-24 16:11:40 +01:00
return QVariant ( fmpe . mMsgStatus ) ;
2018-11-20 23:28:07 +01:00
}
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
QVariant RsGxsForumModel : : filterRole ( const ForumModelPostEntry & fmpe , int /*column*/ ) const
2018-12-01 16:09:35 +01:00
{
2018-12-01 23:14:08 +01:00
if ( ! mFilteringEnabled | | ( fmpe . mPostFlags & ForumModelPostEntry : : FLAG_POST_CHILDREN_PASSES_FILTER ) )
return QVariant ( FilterString ) ;
2018-12-01 16:09:35 +01:00
2018-12-01 23:14:08 +01:00
return QVariant ( QString ( ) ) ;
}
2018-12-01 16:09:35 +01:00
2018-12-01 23:14:08 +01:00
uint32_t RsGxsForumModel : : recursUpdateFilterStatus ( ForumModelIndex i , int column , const QStringList & strings )
{
QString s ;
uint32_t count = 0 ;
2018-12-01 16:09:35 +01:00
2018-12-01 23:14:08 +01:00
switch ( column )
{
default :
case COLUMN_THREAD_DATE :
case COLUMN_THREAD_TITLE : s = displayRole ( mPosts [ i ] , column ) . toString ( ) ;
break ;
case COLUMN_THREAD_AUTHOR :
{
QString comment ;
QList < QIcon > icons ;
GxsIdDetails : : MakeIdDesc ( mPosts [ i ] . mAuthorId , false , s , icons , comment , GxsIdDetails : : ICON_TYPE_NONE ) ;
}
break ;
}
if ( ! strings . empty ( ) )
{
mPosts [ i ] . mPostFlags & = ~ ( ForumModelPostEntry : : FLAG_POST_PASSES_FILTER | ForumModelPostEntry : : FLAG_POST_CHILDREN_PASSES_FILTER ) ;
for ( auto iter ( strings . begin ( ) ) ; iter ! = strings . end ( ) ; + + iter )
if ( s . contains ( * iter , Qt : : CaseInsensitive ) )
{
mPosts [ i ] . mPostFlags | = ForumModelPostEntry : : FLAG_POST_PASSES_FILTER | ForumModelPostEntry : : FLAG_POST_CHILDREN_PASSES_FILTER ;
count + + ;
break ;
}
}
else
{
mPosts [ i ] . mPostFlags | = ForumModelPostEntry : : FLAG_POST_PASSES_FILTER | ForumModelPostEntry : : FLAG_POST_CHILDREN_PASSES_FILTER ;
count + + ;
}
for ( uint32_t j = 0 ; j < mPosts [ i ] . mChildren . size ( ) ; + + j )
{
uint32_t tmp = recursUpdateFilterStatus ( mPosts [ i ] . mChildren [ j ] , column , strings ) ;
count + = tmp ;
if ( tmp > 0 )
mPosts [ i ] . mPostFlags | = ForumModelPostEntry : : FLAG_POST_CHILDREN_PASSES_FILTER ;
}
return count ;
2018-12-01 16:09:35 +01:00
}
2018-12-01 23:14:08 +01:00
void RsGxsForumModel : : setFilter ( int column , const QStringList & strings , uint32_t & count )
2018-12-01 16:09:35 +01:00
{
2018-12-04 09:36:06 +01:00
preMods ( ) ;
2018-12-01 16:09:35 +01:00
2018-12-01 23:14:08 +01:00
if ( ! strings . empty ( ) )
{
count = recursUpdateFilterStatus ( ForumModelIndex ( 0 ) , column , strings ) ;
mFilteringEnabled = true ;
}
else
2018-12-04 22:14:54 +01:00
{
count = 0 ;
2018-12-01 23:14:08 +01:00
mFilteringEnabled = false ;
2018-12-04 22:14:54 +01:00
}
2018-12-01 23:14:08 +01:00
2018-12-04 09:36:06 +01:00
postMods ( ) ;
2018-12-01 16:09:35 +01:00
}
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
QVariant RsGxsForumModel : : missingRole ( const ForumModelPostEntry & fmpe , int /*column*/ ) const
2018-11-20 23:28:07 +01:00
{
2018-11-21 23:18:08 +01:00
if ( fmpe . mPostFlags & ForumModelPostEntry : : FLAG_POST_IS_MISSING )
2018-11-20 23:28:07 +01:00
return QVariant ( true ) ;
else
return QVariant ( false ) ;
}
2018-11-21 23:18:08 +01:00
QVariant RsGxsForumModel : : toolTipRole ( const ForumModelPostEntry & fmpe , int column ) const
2018-11-20 23:28:07 +01:00
{
2018-11-25 21:12:26 +01:00
if ( column = = COLUMN_THREAD_DISTRIBUTION )
switch ( fmpe . mReputationWarningLevel )
{
case 3 : return QVariant ( tr ( " Information for this identity is currently missing. " ) ) ;
case 2 : return QVariant ( tr ( " You have banned this ID. The message will not be \n displayed nor forwarded to your friends. " ) ) ;
case 1 : return QVariant ( tr ( " You have not set an opinion for this person, \n and your friends do not vote positively: Spam regulation \n prevents the message to be forwarded to your friends. " ) ) ;
case 0 : return QVariant ( tr ( " Message will be forwarded to your friends. " ) ) ;
default :
return QVariant ( " [ERROR: missing reputation level information - contact the developers] " ) ;
}
2018-11-20 23:28:07 +01:00
2018-11-25 21:12:26 +01:00
if ( column = = COLUMN_THREAD_AUTHOR )
{
QString str , comment ;
QList < QIcon > icons ;
if ( ! GxsIdDetails : : MakeIdDesc ( fmpe . mAuthorId , true , str , icons , comment , GxsIdDetails : : ICON_TYPE_AVATAR ) )
return QVariant ( ) ;
int S = QFontMetricsF ( QApplication : : font ( ) ) . height ( ) ;
QImage pix ( ( * icons . begin ( ) ) . pixmap ( QSize ( 4 * S , 4 * S ) ) . toImage ( ) ) ;
QString embeddedImage ;
if ( RsHtml : : makeEmbeddedImage ( pix . scaled ( QSize ( 4 * S , 4 * S ) , Qt : : KeepAspectRatio , Qt : : SmoothTransformation ) , embeddedImage , 8 * S * 8 * S ) )
comment = " <table><tr><td> " + embeddedImage + " </td><td> " + comment + " </td></table> " ;
return comment ;
}
return QVariant ( ) ;
2018-11-20 23:28:07 +01:00
}
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
QVariant RsGxsForumModel : : pinnedRole ( const ForumModelPostEntry & fmpe , int /*column*/ ) const
2018-11-20 23:28:07 +01:00
{
2018-11-21 23:18:08 +01:00
if ( fmpe . mPostFlags & ForumModelPostEntry : : FLAG_POST_IS_PINNED )
2018-11-20 23:28:07 +01:00
return QVariant ( true ) ;
else
return QVariant ( false ) ;
}
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
QVariant RsGxsForumModel : : backgroundRole ( const ForumModelPostEntry & fmpe , int /*column*/ ) const
2018-11-27 15:15:54 +01:00
{
if ( fmpe . mPostFlags & ForumModelPostEntry : : FLAG_POST_IS_PINNED )
return QVariant ( QBrush ( QColor ( 255 , 200 , 180 ) ) ) ;
2018-12-01 23:14:08 +01:00
if ( mFilteringEnabled & & ( fmpe . mPostFlags & ForumModelPostEntry : : FLAG_POST_PASSES_FILTER ) )
return QVariant ( QBrush ( QColor ( 255 , 240 , 210 ) ) ) ;
2018-11-27 15:15:54 +01:00
return QVariant ( ) ;
}
2018-11-20 23:28:07 +01:00
2018-11-17 22:36:07 +01:00
QVariant RsGxsForumModel : : sizeHintRole ( int col ) const
{
float factor = QFontMetricsF ( QApplication : : font ( ) ) . height ( ) / 14.0f ;
switch ( col )
{
default :
2018-11-21 23:18:08 +01:00
case COLUMN_THREAD_TITLE : return QVariant ( QSize ( factor * 170 , factor * 14 ) ) ;
case COLUMN_THREAD_DATE : return QVariant ( QSize ( factor * 75 , factor * 14 ) ) ;
case COLUMN_THREAD_AUTHOR : return QVariant ( QSize ( factor * 75 , factor * 14 ) ) ;
2018-11-27 15:15:54 +01:00
case COLUMN_THREAD_DISTRIBUTION : return QVariant ( QSize ( factor * 15 , factor * 14 ) ) ;
2018-11-17 22:36:07 +01:00
}
}
2018-11-21 23:18:08 +01:00
QVariant RsGxsForumModel : : authorRole ( const ForumModelPostEntry & fmpe , int column ) const
2018-11-20 23:28:07 +01:00
{
if ( column = = COLUMN_THREAD_DATA )
2018-11-22 09:28:07 +01:00
return QVariant ( QString : : fromStdString ( fmpe . mAuthorId . toStdString ( ) ) ) ;
2018-11-20 23:28:07 +01:00
return QVariant ( ) ;
}
2018-11-21 23:18:08 +01:00
QVariant RsGxsForumModel : : sortRole ( const ForumModelPostEntry & fmpe , int column ) const
2018-11-20 23:28:07 +01:00
{
2018-11-30 17:24:43 +01:00
switch ( column )
{
2018-12-02 16:34:43 +01:00
case COLUMN_THREAD_DATE : if ( mSortMode = = SORT_MODE_PUBLISH_TS )
return QVariant ( QString : : number ( fmpe . mPublishTs ) ) ; // we should probably have leading zeroes here
else
return QVariant ( QString : : number ( fmpe . mMostRecentTsInThread ) ) ; // we should probably have leading zeroes here
2018-11-30 17:24:43 +01:00
case COLUMN_THREAD_READ : return QVariant ( ( bool ) IS_MSG_UNREAD ( fmpe . mMsgStatus ) ) ;
case COLUMN_THREAD_DISTRIBUTION : return decorationRole ( fmpe , column ) ;
case COLUMN_THREAD_AUTHOR :
{
QString str , comment ;
QList < QIcon > icons ;
GxsIdDetails : : MakeIdDesc ( fmpe . mAuthorId , false , str , icons , comment , GxsIdDetails : : ICON_TYPE_NONE ) ;
2018-11-20 23:28:07 +01:00
2018-11-30 17:24:43 +01:00
return QVariant ( str ) ;
}
default :
return displayRole ( fmpe , column ) ;
}
2018-11-20 23:28:07 +01:00
}
2018-11-21 23:18:08 +01:00
QVariant RsGxsForumModel : : displayRole ( const ForumModelPostEntry & fmpe , int col ) const
2018-11-17 22:36:07 +01:00
{
switch ( col )
{
2018-11-21 23:18:08 +01:00
case COLUMN_THREAD_TITLE : if ( fmpe . mPostFlags & ForumModelPostEntry : : FLAG_POST_IS_REDACTED )
2018-11-20 23:28:07 +01:00
return QVariant ( tr ( " [ ... Redacted message ... ] " ) ) ;
else if ( fmpe . mPostFlags & ForumModelPostEntry : : FLAG_POST_IS_PINNED )
2018-11-21 23:18:08 +01:00
return QVariant ( tr ( " [PINNED] " ) + QString : : fromUtf8 ( fmpe . mTitle . c_str ( ) ) ) ;
2018-11-20 23:28:07 +01:00
else
2018-11-21 23:18:08 +01:00
return QVariant ( QString : : fromUtf8 ( fmpe . mTitle . c_str ( ) ) ) ;
2018-11-20 23:28:07 +01:00
2018-11-24 16:11:40 +01:00
case COLUMN_THREAD_READ : return QVariant ( ) ;
2018-12-01 16:09:35 +01:00
case COLUMN_THREAD_DATE : {
if ( fmpe . mPostFlags & ForumModelPostEntry : : FLAG_POST_IS_MISSING )
return QVariant ( QString ( ) ) ;
2018-11-20 23:28:07 +01:00
QDateTime qtime ;
2018-11-21 23:18:08 +01:00
qtime . setTime_t ( fmpe . mPublishTs ) ;
2018-11-20 23:28:07 +01:00
2018-11-22 09:28:07 +01:00
return QVariant ( DateTime : : formatDateTime ( qtime ) ) ;
2018-11-20 23:28:07 +01:00
}
2018-11-17 22:36:07 +01:00
2018-11-24 16:11:40 +01:00
case COLUMN_THREAD_DISTRIBUTION :
2020-05-03 20:31:32 +02:00
case COLUMN_THREAD_AUTHOR : {
QString name ;
RsGxsId id = RsGxsId ( fmpe . mAuthorId . toStdString ( ) ) ;
if ( id . isNull ( ) )
return QVariant ( tr ( " [Notification] " ) ) ;
if ( GxsIdTreeItemDelegate : : computeName ( id , name ) )
return name ;
return QVariant ( tr ( " [Unknown] " ) ) ;
}
2018-11-24 16:11:40 +01:00
case COLUMN_THREAD_MSGID : return QVariant ( ) ;
2018-11-20 23:28:07 +01:00
# ifdef TODO
if ( filterColumn = = COLUMN_THREAD_CONTENT ) {
// need content for filter
QTextDocument doc ;
doc . setHtml ( QString : : fromUtf8 ( msg . mMsg . c_str ( ) ) ) ;
item - > setText ( COLUMN_THREAD_CONTENT , doc . toPlainText ( ) . replace ( QString ( " \n " ) , QString ( " " ) ) ) ;
}
# endif
2018-11-17 22:36:07 +01:00
default :
return QVariant ( " [ TODO ] " ) ;
}
return QVariant ( " [ERROR] " ) ;
}
2018-11-24 16:11:40 +01:00
QVariant RsGxsForumModel : : userRole ( const ForumModelPostEntry & fmpe , int col ) const
{
switch ( col )
{
case COLUMN_THREAD_AUTHOR : return QVariant ( QString : : fromStdString ( fmpe . mAuthorId . toStdString ( ) ) ) ;
case COLUMN_THREAD_MSGID : return QVariant ( QString : : fromStdString ( fmpe . mMsgId . toStdString ( ) ) ) ;
default :
return QVariant ( ) ;
}
}
2018-11-21 23:18:08 +01:00
QVariant RsGxsForumModel : : decorationRole ( const ForumModelPostEntry & fmpe , int col ) const
2018-11-17 22:36:07 +01:00
{
2020-05-03 20:31:32 +02:00
bool exist = false ;
switch ( col )
{
case COLUMN_THREAD_DISTRIBUTION :
return QVariant ( fmpe . mReputationWarningLevel ) ;
case COLUMN_THREAD_READ :
return QVariant ( fmpe . mMsgStatus ) ;
case COLUMN_THREAD_AUTHOR : //Return icon as place holder.
return FilesDefs : : getIconFromGxsIdCache ( RsGxsId ( fmpe . mAuthorId . toStdString ( ) ) , QIcon ( ) , exist ) ;
}
return QVariant ( ) ;
2018-11-21 23:18:08 +01:00
}
2018-12-14 22:09:02 +01:00
const RsGxsGroupId & RsGxsForumModel : : currentGroupId ( ) const
{
return mForumGroup . mMeta . mGroupId ;
}
2018-12-06 23:04:53 +01:00
void RsGxsForumModel : : updateForum ( const RsGxsGroupId & forum_group_id )
2018-11-21 23:18:08 +01:00
{
2018-12-03 21:56:11 +01:00
if ( forum_group_id . isNull ( ) )
return ;
2018-11-22 09:28:07 +01:00
update_posts ( forum_group_id ) ;
}
2018-12-03 17:30:46 +01:00
void RsGxsForumModel : : clear ( )
{
2018-12-04 09:36:06 +01:00
preMods ( ) ;
2018-12-03 17:30:46 +01:00
mPosts . clear ( ) ;
mPostVersions . clear ( ) ;
2018-12-04 09:36:06 +01:00
postMods ( ) ;
2018-12-03 17:30:46 +01:00
emit forumLoaded ( ) ;
}
2018-11-27 19:21:49 +01:00
void RsGxsForumModel : : setPosts ( const RsGxsForumGroup & group , const std : : vector < ForumModelPostEntry > & posts , const std : : map < RsGxsMessageId , std : : vector < std : : pair < time_t , RsGxsMessageId > > > & post_versions )
2018-11-22 09:28:07 +01:00
{
2018-12-04 09:36:06 +01:00
preMods ( ) ;
2018-11-25 17:40:48 +01:00
2019-10-14 22:24:36 +02:00
if ( mTreeMode = = TREE_MODE_FLAT )
beginRemoveRows ( QModelIndex ( ) , 0 , mPosts . size ( ) - 1 ) ;
else
beginRemoveRows ( QModelIndex ( ) , 0 , mPosts [ 0 ] . mChildren . size ( ) - 1 ) ;
2018-12-04 23:10:24 +01:00
endRemoveRows ( ) ;
2018-11-22 09:28:07 +01:00
mForumGroup = group ;
mPosts = posts ;
2018-11-27 19:21:49 +01:00
mPostVersions = post_versions ;
2018-11-21 23:18:08 +01:00
2018-11-22 10:44:06 +01:00
// now update prow for all posts
for ( uint32_t i = 0 ; i < mPosts . size ( ) ; + + i )
for ( uint32_t j = 0 ; j < mPosts [ i ] . mChildren . size ( ) ; + + j )
mPosts [ mPosts [ i ] . mChildren [ j ] ] . prow = j ;
mPosts [ 0 ] . prow = 0 ;
2018-11-24 20:50:09 +01:00
bool has_unread_below , has_read_below ;
2018-12-02 16:34:43 +01:00
recursUpdateReadStatusAndTimes ( 0 , has_unread_below , has_read_below ) ;
2018-12-01 23:14:08 +01:00
recursUpdateFilterStatus ( 0 , 0 , QStringList ( ) ) ;
2018-12-02 16:34:43 +01:00
2018-12-02 16:45:16 +01:00
# ifdef DEBUG_FORUMMODEL
2018-11-22 10:44:06 +01:00
debug_dump ( ) ;
2018-11-25 21:12:26 +01:00
# endif
2018-11-22 10:44:06 +01:00
2019-10-14 22:24:36 +02:00
if ( mTreeMode = = TREE_MODE_FLAT )
beginInsertRows ( QModelIndex ( ) , 0 , mPosts . size ( ) - 1 ) ;
else
beginInsertRows ( QModelIndex ( ) , 0 , mPosts [ 0 ] . mChildren . size ( ) - 1 ) ;
2018-12-04 23:10:24 +01:00
endInsertRows ( ) ;
2018-12-04 09:36:06 +01:00
postMods ( ) ;
2018-11-27 10:13:03 +01:00
emit forumLoaded ( ) ;
2018-11-21 23:18:08 +01:00
}
void RsGxsForumModel : : update_posts ( const RsGxsGroupId & group_id )
{
2018-12-03 17:30:46 +01:00
if ( group_id . isNull ( ) )
return ;
2018-11-21 23:18:08 +01:00
RsThread : : async ( [ this , group_id ] ( )
{
// 1 - get message data from p3GxsForums
std : : list < RsGxsGroupId > forumIds ;
2018-12-12 11:33:38 +01:00
std : : vector < RsMsgMetaData > msg_metas ;
2018-11-21 23:18:08 +01:00
std : : vector < RsGxsForumGroup > groups ;
forumIds . push_back ( group_id ) ;
2019-10-06 00:12:28 +02:00
if ( ! rsGxsForums - > getForumsInfo ( forumIds , groups ) | | groups . size ( ) ! = 1 )
2018-11-17 22:36:07 +01:00
{
2018-11-21 23:18:08 +01:00
std : : cerr < < __PRETTY_FUNCTION__ < < " failed to retrieve forum group info for forum " < < group_id < < std : : endl ;
return ;
}
2018-11-17 22:36:07 +01:00
2018-12-12 11:33:38 +01:00
if ( ! rsGxsForums - > getForumMsgMetaData ( group_id , msg_metas ) )
2018-11-21 23:18:08 +01:00
{
std : : cerr < < __PRETTY_FUNCTION__ < < " failed to retrieve forum message info for forum " < < group_id < < std : : endl ;
return ;
2018-11-17 22:36:07 +01:00
}
2018-11-21 23:18:08 +01:00
// 2 - sort the messages into a proper hierarchy
2018-11-17 22:36:07 +01:00
2018-11-27 19:21:49 +01:00
auto post_versions = new std : : map < RsGxsMessageId , std : : vector < std : : pair < time_t , RsGxsMessageId > > > ( ) ;
2018-11-21 23:18:08 +01:00
std : : vector < ForumModelPostEntry > * vect = new std : : vector < ForumModelPostEntry > ( ) ;
2018-11-22 09:28:07 +01:00
RsGxsForumGroup group = groups [ 0 ] ;
2018-11-17 22:36:07 +01:00
2018-12-12 11:33:38 +01:00
computeMessagesHierarchy ( group , msg_metas , * vect , * post_versions ) ;
2018-11-21 23:18:08 +01:00
// 3 - update the model in the UI thread.
2018-11-27 19:21:49 +01:00
RsQThreadUtils : : postToObject ( [ group , vect , post_versions , this ] ( )
2018-11-21 23:18:08 +01:00
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread , for example to update the data model with new information
* after a blocking call to RetroShare API complete , note that
* Qt : : QueuedConnection is important !
*/
2018-11-17 22:36:07 +01:00
2018-11-27 19:21:49 +01:00
setPosts ( group , * vect , * post_versions ) ;
2018-11-21 23:18:08 +01:00
delete vect ;
2018-11-27 19:21:49 +01:00
delete post_versions ;
2018-11-21 23:18:08 +01:00
} , this ) ;
} ) ;
2018-11-17 22:36:07 +01:00
}
2018-11-21 23:18:08 +01:00
ForumModelIndex RsGxsForumModel : : addEntry ( std : : vector < ForumModelPostEntry > & posts , const ForumModelPostEntry & entry , ForumModelIndex parent )
2018-11-17 22:36:07 +01:00
{
2018-11-21 23:18:08 +01:00
uint32_t N = posts . size ( ) ;
posts . push_back ( entry ) ;
posts [ N ] . mParent = parent ;
posts [ parent ] . mChildren . push_back ( N ) ;
2018-12-02 16:49:14 +01:00
# ifdef DEBUG_FORUMMODEL
2018-11-22 10:44:06 +01:00
std : : cerr < < " Added new entry " < < N < < " children of " < < parent < < std : : endl ;
2018-12-02 16:49:14 +01:00
# endif
2018-11-22 10:44:06 +01:00
if ( N = = parent )
std : : cerr < < " (EE) trying to add a post as its own parent! " < < std : : endl ;
2018-11-21 23:18:08 +01:00
return ForumModelIndex ( N ) ;
2018-11-17 22:36:07 +01:00
}
2018-11-21 23:18:08 +01:00
void RsGxsForumModel : : generateMissingItem ( const RsGxsMessageId & msgId , ForumModelPostEntry & entry )
2018-11-17 22:36:07 +01:00
{
2018-11-21 23:18:08 +01:00
entry . mPostFlags = ForumModelPostEntry : : FLAG_POST_IS_MISSING ;
entry . mTitle = std : : string ( tr ( " [ ... Missing Message ... ] " ) . toUtf8 ( ) ) ;
entry . mMsgId = msgId ;
entry . mAuthorId . clear ( ) ;
entry . mPublishTs = 0 ;
entry . mReputationWarningLevel = 3 ;
}
2018-11-17 22:36:07 +01:00
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
void RsGxsForumModel : : convertMsgToPostEntry ( const RsGxsForumGroup & mForumGroup , const RsMsgMetaData & msg , bool /*useChildTS*/ , ForumModelPostEntry & fentry )
2018-11-21 23:18:08 +01:00
{
2018-12-12 11:33:38 +01:00
fentry . mTitle = msg . mMsgName ;
fentry . mAuthorId = msg . mAuthorId ;
fentry . mMsgId = msg . mMsgId ;
fentry . mPublishTs = msg . mPublishTs ;
2018-11-22 10:44:06 +01:00
fentry . mPostFlags = 0 ;
2018-12-12 11:33:38 +01:00
fentry . mMsgStatus = msg . mMsgStatus ;
2018-11-21 23:18:08 +01:00
2018-12-12 11:33:38 +01:00
if ( mForumGroup . mPinnedPosts . ids . find ( msg . mMsgId ) ! = mForumGroup . mPinnedPosts . ids . end ( ) )
2018-11-21 23:18:08 +01:00
fentry . mPostFlags | = ForumModelPostEntry : : FLAG_POST_IS_PINNED ;
// Early check for a message that should be hidden because its author
// is flagged with a bad reputation
2018-12-06 23:04:53 +01:00
computeReputationLevel ( mForumGroup . mMeta . mSignFlags , fentry ) ;
}
void RsGxsForumModel : : computeReputationLevel ( uint32_t forum_sign_flags , ForumModelPostEntry & fentry )
{
2018-11-21 23:18:08 +01:00
uint32_t idflags = 0 ;
2019-02-16 11:42:22 -03:00
RsReputationLevel reputation_level =
rsReputations - > overallReputationLevel ( fentry . mAuthorId , & idflags ) ;
2018-11-21 23:18:08 +01:00
bool redacted = false ;
2019-02-16 11:42:22 -03:00
if ( reputation_level = = RsReputationLevel : : LOCALLY_NEGATIVE )
2018-12-06 23:04:53 +01:00
fentry . mPostFlags | = ForumModelPostEntry : : FLAG_POST_IS_REDACTED ;
else
fentry . mPostFlags & = ~ ForumModelPostEntry : : FLAG_POST_IS_REDACTED ;
2018-11-17 22:36:07 +01:00
2018-11-21 23:18:08 +01:00
// We use a specific item model for forums in order to handle the post pinning.
2018-11-17 22:36:07 +01:00
2019-02-16 11:42:22 -03:00
if ( reputation_level = = RsReputationLevel : : UNKNOWN )
2018-11-21 23:18:08 +01:00
fentry . mReputationWarningLevel = 3 ;
2019-02-16 11:42:22 -03:00
else if ( reputation_level = = RsReputationLevel : : LOCALLY_NEGATIVE )
2018-11-21 23:18:08 +01:00
fentry . mReputationWarningLevel = 2 ;
2018-12-06 23:04:53 +01:00
else if ( reputation_level < rsGxsForums - > minReputationForForwardingMessages ( forum_sign_flags , idflags ) )
2018-11-21 23:18:08 +01:00
fentry . mReputationWarningLevel = 1 ;
else
fentry . mReputationWarningLevel = 0 ;
}
2018-11-27 19:21:49 +01:00
static bool decreasing_time_comp ( const std : : pair < time_t , RsGxsMessageId > & e1 , const std : : pair < time_t , RsGxsMessageId > & e2 ) { return e2 . first < e1 . first ; }
2018-11-21 23:18:08 +01:00
2018-11-22 09:28:07 +01:00
void RsGxsForumModel : : computeMessagesHierarchy ( const RsGxsForumGroup & forum_group ,
2018-12-12 11:33:38 +01:00
const std : : vector < RsMsgMetaData > & msgs_metas_array ,
2018-11-27 19:21:49 +01:00
std : : vector < ForumModelPostEntry > & posts ,
std : : map < RsGxsMessageId , std : : vector < std : : pair < time_t , RsGxsMessageId > > > & mPostVersions
)
2018-11-21 23:18:08 +01:00
{
2018-12-12 11:33:38 +01:00
std : : cerr < < " updating messages data with " < < msgs_metas_array . size ( ) < < " messages " < < std : : endl ;
2018-11-21 23:18:08 +01:00
2018-12-02 16:49:14 +01:00
# ifdef DEBUG_FORUMS
2018-11-21 23:18:08 +01:00
std : : cerr < < " Retrieved group data: " < < std : : endl ;
std : : cerr < < " Group ID: " < < forum_group . mMeta . mGroupId < < std : : endl ;
std : : cerr < < " Admin lst: " < < forum_group . mAdminList . ids . size ( ) < < " elements. " < < std : : endl ;
for ( auto it ( forum_group . mAdminList . ids . begin ( ) ) ; it ! = forum_group . mAdminList . ids . end ( ) ; + + it )
std : : cerr < < " " < < * it < < std : : endl ;
std : : cerr < < " Pinned Post: " < < forum_group . mPinnedPosts . ids . size ( ) < < " messages. " < < std : : endl ;
for ( auto it ( forum_group . mPinnedPosts . ids . begin ( ) ) ; it ! = forum_group . mPinnedPosts . ids . end ( ) ; + + it )
std : : cerr < < " " < < * it < < std : : endl ;
2018-12-02 16:49:14 +01:00
# endif
2018-11-21 23:18:08 +01:00
/* get messages */
2018-12-12 11:33:38 +01:00
std : : map < RsGxsMessageId , RsMsgMetaData > msgs ;
2018-11-21 23:18:08 +01:00
2018-12-12 11:33:38 +01:00
for ( uint32_t i = 0 ; i < msgs_metas_array . size ( ) ; + + i )
2018-11-17 22:36:07 +01:00
{
2018-11-21 23:18:08 +01:00
# ifdef DEBUG_FORUMS
2018-12-12 11:33:38 +01:00
std : : cerr < < " Adding message " < < msgs_metas_array [ i ] . mMeta . mMsgId < < " with parent " < < msgs_metas_array [ i ] . mMeta . mParentId < < " to message map " < < std : : endl ;
2018-11-21 23:18:08 +01:00
# endif
2018-12-12 11:33:38 +01:00
msgs [ msgs_metas_array [ i ] . mMsgId ] = msgs_metas_array [ i ] ;
2018-11-17 22:36:07 +01:00
}
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
# ifdef DEBUG_FORUMS
size_t count = msgs . size ( ) ;
# endif
// int pos = 0;
2018-11-21 23:18:08 +01:00
// int steps = count / PROGRESSBAR_MAX;
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
// int step = 0;
2018-11-17 22:36:07 +01:00
2018-11-22 10:44:06 +01:00
initEmptyHierarchy ( posts ) ;
2018-11-21 23:18:08 +01:00
// ThreadList contains the list of parent threads. The algorithm below iterates through all messages
// and tries to establish parenthood relationships between them, given that we only know the
// immediate parent of a message and now its children. Some messages have a missing parent and for them
// a fake top level parent is generated.
2018-11-17 22:36:07 +01:00
2018-11-21 23:18:08 +01:00
// In order to be efficient, we first create a structure that lists the children of every mesage ID in the list.
// Then the hierarchy of message is build by attaching the kids to every message until all of them have been processed.
// The messages with missing parents will be the last ones remaining in the list.
2018-11-17 22:36:07 +01:00
2018-11-21 23:18:08 +01:00
std : : list < std : : pair < RsGxsMessageId , ForumModelIndex > > threadStack ;
std : : map < RsGxsMessageId , std : : list < RsGxsMessageId > > kids_array ;
std : : set < RsGxsMessageId > missing_parents ;
2018-11-17 22:36:07 +01:00
2018-11-21 23:18:08 +01:00
// First of all, remove all older versions of posts. This is done by first adding all posts into a hierarchy structure
// and then removing all posts which have a new versions available. The older versions are kept appart.
# ifdef DEBUG_FORUMS
std : : cerr < < " GxsForumsFillThread::run() Collecting post versions " < < std : : endl ;
# endif
mPostVersions . clear ( ) ;
std : : list < RsGxsMessageId > msg_stack ;
2018-12-12 11:33:38 +01:00
for ( auto msgIt = msgs . begin ( ) ; msgIt ! = msgs . end ( ) ; + + msgIt )
2018-11-21 23:18:08 +01:00
{
2018-12-12 11:33:38 +01:00
if ( ! msgIt - > second . mOrigMsgId . isNull ( ) & & msgIt - > second . mOrigMsgId ! = msgIt - > second . mMsgId )
2018-11-17 22:36:07 +01:00
{
2018-11-21 23:18:08 +01:00
# ifdef DEBUG_FORUMS
std : : cerr < < " Post " < < msgIt - > second . mMeta . mMsgId < < " is a new version of " < < msgIt - > second . mMeta . mOrigMsgId < < std : : endl ;
2018-11-17 22:36:07 +01:00
# endif
2018-12-12 11:33:38 +01:00
auto msgIt2 = msgs . find ( msgIt - > second . mOrigMsgId ) ;
2018-11-21 23:18:08 +01:00
// Ensuring that the post exists allows to only collect the existing data.
if ( msgIt2 = = msgs . end ( ) )
continue ;
// Make sure that the author is the same than the original message, or is a moderator. This should always happen when messages are constructed using
// the UI but nothing can prevent a nasty user to craft a new version of a message with his own signature.
2018-12-12 11:33:38 +01:00
if ( msgIt2 - > second . mAuthorId ! = msgIt - > second . mAuthorId )
2018-11-21 23:18:08 +01:00
{
2018-12-12 11:33:38 +01:00
if ( ! IS_FORUM_MSG_MODERATION ( msgIt - > second . mMsgFlags ) ) // if authors are different the moderation flag needs to be set on the editing msg
2018-11-21 23:18:08 +01:00
continue ;
2018-12-24 11:44:57 +01:00
if ( ! forum_group . canEditPosts ( msgIt - > second . mAuthorId ) ) // if author is not a moderator, continue
2018-11-21 23:18:08 +01:00
continue ;
}
// always add the post a self version
2018-12-12 11:33:38 +01:00
if ( mPostVersions [ msgIt - > second . mOrigMsgId ] . empty ( ) )
mPostVersions [ msgIt - > second . mOrigMsgId ] . push_back ( std : : make_pair ( msgIt2 - > second . mPublishTs , msgIt2 - > second . mMsgId ) ) ;
2018-11-21 23:18:08 +01:00
2018-12-12 11:33:38 +01:00
mPostVersions [ msgIt - > second . mOrigMsgId ] . push_back ( std : : make_pair ( msgIt - > second . mPublishTs , msgIt - > second . mMsgId ) ) ;
2018-11-17 22:36:07 +01:00
}
2018-11-21 23:18:08 +01:00
}
// The following code assembles all new versions of a given post into the same array, indexed by the oldest version of the post.
2018-11-27 19:21:49 +01:00
for ( auto it ( mPostVersions . begin ( ) ) ; it ! = mPostVersions . end ( ) ; + + it )
2018-11-21 23:18:08 +01:00
{
2018-11-27 19:21:49 +01:00
auto & v ( it - > second ) ;
2018-11-21 23:18:08 +01:00
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
for ( size_t i = 0 ; i < v . size ( ) ; + + i )
{
2018-11-27 19:21:49 +01:00
if ( v [ i ] . second ! = it - > first )
2018-11-21 23:18:08 +01:00
{
RsGxsMessageId sub_msg_id = v [ i ] . second ;
2018-11-27 19:21:49 +01:00
auto it2 = mPostVersions . find ( sub_msg_id ) ;
2018-11-21 23:18:08 +01:00
if ( it2 ! = mPostVersions . end ( ) )
{
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
for ( size_t j = 0 ; j < it2 - > second . size ( ) ; + + j )
2018-11-27 19:21:49 +01:00
if ( it2 - > second [ j ] . second ! = sub_msg_id ) // dont copy it, since it is already present at slot i
v . push_back ( it2 - > second [ j ] ) ;
2018-11-21 23:18:08 +01:00
mPostVersions . erase ( it2 ) ; // it2 is never equal to it
}
}
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
}
2018-11-21 23:18:08 +01:00
}
// Now remove from msg ids, all posts except the most recent one. And make the mPostVersion be indexed by the most recent version of the post,
// which corresponds to the item in the tree widget.
# ifdef DEBUG_FORUMS
std : : cerr < < " Final post versions: " < < std : : endl ;
# endif
2018-11-27 19:21:49 +01:00
std : : map < RsGxsMessageId , std : : vector < std : : pair < time_t , RsGxsMessageId > > > mTmp ;
2018-11-21 23:18:08 +01:00
std : : map < RsGxsMessageId , RsGxsMessageId > most_recent_versions ;
2018-11-27 19:21:49 +01:00
for ( auto it ( mPostVersions . begin ( ) ) ; it ! = mPostVersions . end ( ) ; + + it )
2018-11-21 23:18:08 +01:00
{
# ifdef DEBUG_FORUMS
std : : cerr < < " Original post: " < < it . key ( ) < < std : : endl ;
# endif
// Finally, sort the posts from newer to older
2018-11-27 19:21:49 +01:00
std : : sort ( it - > second . begin ( ) , it - > second . end ( ) , decreasing_time_comp ) ;
2018-11-21 23:18:08 +01:00
# ifdef DEBUG_FORUMS
std : : cerr < < " most recent version " < < ( * it ) [ 0 ] . first < < " " < < ( * it ) [ 0 ] . second < < std : : endl ;
# endif
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
for ( size_t i = 1 ; i < it - > second . size ( ) ; + + i )
{
2018-11-27 19:21:49 +01:00
msgs . erase ( it - > second [ i ] . second ) ;
2018-11-21 23:18:08 +01:00
# ifdef DEBUG_FORUMS
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
std : : cerr < < " older version " < < ( * it ) [ i ] . first < < " " < < ( * it ) [ i ] . second < < std : : endl ;
2018-11-21 23:18:08 +01:00
# endif
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
}
2018-11-21 23:18:08 +01:00
2018-11-27 19:21:49 +01:00
mTmp [ it - > second [ 0 ] . second ] = it - > second ; // index the versions map by the ID of the most recent post.
2018-11-21 23:18:08 +01:00
// Now make sure that message parents are consistent. Indeed, an old post may have the old version of a post as parent. So we need to change that parent
// to the newest version. So we create a map of which is the most recent version of each message, so that parent messages can be searched in it.
Fix clang warnings for
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
106:53: warning: unused parameter 'parent' [-Wunused-parameter]
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3:
warning: add explicit braces to avoid dangling else [-Wdangling-else]
else
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
248:12: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
if(row >= mPosts[entry].mChildren.size())
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
299:67: warning: unused parameter 'orientation' [-Wunused-parameter]
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation
orientation, int role) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
398:77: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
419:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
498:75: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
540:74: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int
column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
548:78: warning: unused parameter 'column' [-Wunused-parameter]
QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry&
fmpe,int column) const
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter]
void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup&
mForumGroup,const RsMsgMetaData& msg, bool useChildTS,
ForumModelPostEntry& fentry)
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7:
warning: unused variable 'redacted' [-Wunused-variable]
bool redacted = false;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6:
warning: unused variable 'pos' [-Wunused-variable]
int pos = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6:
warning: unused variable 'count' [-Wunused-variable]
int count = msgs.size();
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6:
warning: unused variable 'step' [-Wunused-variable]
int step = 0;
^
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
949:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=0;i<v.size();++i)
~^~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
959:23: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t j=0;j<it2-
>second.size();++j)
~^~~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
991:26: warning: comparison of integers of different signs: 'int32_t'
(aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-
compare]
for(int32_t i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:
1005:22: warning: comparison of integers of different signs: 'int' and
'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int i=1;i<it->second.size();++i)
~^~~~~~~~~~~~~~~~~~
../../../trunk/retroshare-gui/src/gui/gxsforums/
GxsForumThreadWidget.cpp:1038:13: warning: unused function
'cleanupItems' [-Wunused-function]
static void cleanupItems (QList<QTreeWidgetItem *> &items)
^
2019-02-23 19:28:45 +01:00
for ( size_t i = 1 ; i < it - > second . size ( ) ; + + i )
most_recent_versions [ it - > second [ i ] . second ] = it - > second [ 0 ] . second ;
}
2018-11-21 23:18:08 +01:00
mPostVersions = mTmp ;
// The next step is to find the top level thread messages. These are defined as the messages without
// any parent message ID.
// this trick is needed because while we remove messages, the parents a given msg may already have been removed
// and wrongly understand as a missing parent.
2018-12-12 11:33:38 +01:00
std : : map < RsGxsMessageId , RsMsgMetaData > kept_msgs ;
2018-11-21 23:18:08 +01:00
2018-12-12 11:33:38 +01:00
for ( auto msgIt = msgs . begin ( ) ; msgIt ! = msgs . end ( ) ; + + msgIt )
2018-11-21 23:18:08 +01:00
{
2018-12-12 11:33:38 +01:00
if ( msgIt - > second . mParentId . isNull ( ) )
2018-11-17 22:36:07 +01:00
{
2018-11-21 23:18:08 +01:00
/* add all threads */
2018-12-12 11:33:38 +01:00
const RsMsgMetaData & msg = msgIt - > second ;
2018-11-21 23:18:08 +01:00
# ifdef DEBUG_FORUMS
2018-12-12 11:33:38 +01:00
std : : cerr < < " GxsForumsFillThread::run() Adding TopLevel Thread: mId: " < < msg . mMsgId < < std : : endl ;
2018-11-17 22:36:07 +01:00
# endif
2018-11-21 23:18:08 +01:00
ForumModelPostEntry entry ;
2018-12-01 23:14:08 +01:00
convertMsgToPostEntry ( forum_group , msg , mUseChildTS , entry ) ;
2018-11-21 23:18:08 +01:00
ForumModelIndex entry_index = addEntry ( posts , entry , 0 ) ;
2018-12-02 12:02:25 +01:00
//if (!mFlatView)
2018-12-12 11:33:38 +01:00
threadStack . push_back ( std : : make_pair ( msg . mMsgId , entry_index ) ) ;
2018-11-21 23:18:08 +01:00
//calculateExpand(msg, item);
//mItems.append(entry_index);
2018-11-17 22:36:07 +01:00
}
2018-11-21 23:18:08 +01:00
else
{
# ifdef DEBUG_FORUMS
2018-12-12 11:33:38 +01:00
std : : cerr < < " GxsForumsFillThread::run() Storing kid " < < msgIt - > first < < " of message " < < msgIt - > second . mParentId < < std : : endl ;
2018-11-21 23:18:08 +01:00
# endif
// The same missing parent may appear multiple times, so we first store them into a unique container.
2018-11-17 22:36:07 +01:00
2018-12-12 11:33:38 +01:00
RsGxsMessageId parent_msg = msgIt - > second . mParentId ;
2018-11-17 22:36:07 +01:00
2018-11-21 23:18:08 +01:00
if ( msgs . find ( parent_msg ) = = msgs . end ( ) )
{
// also check that the message is not versionned
2018-11-17 22:36:07 +01:00
2018-11-21 23:18:08 +01:00
std : : map < RsGxsMessageId , RsGxsMessageId > : : const_iterator mrit = most_recent_versions . find ( parent_msg ) ;
if ( mrit ! = most_recent_versions . end ( ) )
parent_msg = mrit - > second ;
else
missing_parents . insert ( parent_msg ) ;
}
kids_array [ parent_msg ] . push_back ( msgIt - > first ) ;
kept_msgs . insert ( * msgIt ) ;
}
}
msgs = kept_msgs ;
// Also create a list of posts by time, when they are new versions of existing posts. Only the last one will have an item created.
// Add a fake toplevel item for the parent IDs that we dont actually have.
for ( std : : set < RsGxsMessageId > : : const_iterator it ( missing_parents . begin ( ) ) ; it ! = missing_parents . end ( ) ; + + it )
{
// add dummy parent item
ForumModelPostEntry e ;
2018-11-22 09:28:07 +01:00
generateMissingItem ( * it , e ) ;
2018-11-21 23:18:08 +01:00
ForumModelIndex e_index = addEntry ( posts , e , 0 ) ; // no parent -> parent is level 0
//mItems.append( e_index );
threadStack . push_back ( std : : make_pair ( * it , e_index ) ) ;
}
# ifdef DEBUG_FORUMS
std : : cerr < < " GxsForumsFillThread::run() Processing stack: " < < std : : endl ;
# endif
// Now use a stack to go down the hierarchy
while ( ! threadStack . empty ( ) )
{
std : : pair < RsGxsMessageId , uint32_t > threadPair = threadStack . front ( ) ;
threadStack . pop_front ( ) ;
std : : map < RsGxsMessageId , std : : list < RsGxsMessageId > > : : iterator it = kids_array . find ( threadPair . first ) ;
# ifdef DEBUG_FORUMS
std : : cerr < < " GxsForumsFillThread::run() Node: " < < threadPair . first < < std : : endl ;
# endif
if ( it = = kids_array . end ( ) )
continue ;
for ( std : : list < RsGxsMessageId > : : const_iterator it2 ( it - > second . begin ( ) ) ; it2 ! = it - > second . end ( ) ; + + it2 )
{
// We iterate through the top level thread items, and look for which message has the current item as parent.
// When found, the item is put in the thread list itself, as a potential new parent.
2018-12-12 11:33:38 +01:00
auto mit = msgs . find ( * it2 ) ;
2018-11-21 23:18:08 +01:00
if ( mit = = msgs . end ( ) )
{
std : : cerr < < " GxsForumsFillThread::run() Cannot find submessage " < < * it2 < < " !!! " < < std : : endl ;
continue ;
}
2018-12-12 11:33:38 +01:00
const RsMsgMetaData & msg ( mit - > second ) ;
2018-11-21 23:18:08 +01:00
# ifdef DEBUG_FORUMS
2018-12-12 11:33:38 +01:00
std : : cerr < < " GxsForumsFillThread::run() adding sub_item " < < msg . mMsgId < < std : : endl ;
2018-11-21 23:18:08 +01:00
# endif
ForumModelPostEntry e ;
2018-12-01 23:14:08 +01:00
convertMsgToPostEntry ( forum_group , msg , mUseChildTS , e ) ;
2018-11-21 23:18:08 +01:00
ForumModelIndex e_index = addEntry ( posts , e , threadPair . second ) ;
//calculateExpand(msg, item);
/* add item to process list */
2018-12-12 11:33:38 +01:00
threadStack . push_back ( std : : make_pair ( msg . mMsgId , e_index ) ) ;
2018-11-21 23:18:08 +01:00
msgs . erase ( mit ) ;
2018-11-17 22:36:07 +01:00
}
2018-11-21 23:18:08 +01:00
# ifdef DEBUG_FORUMS
std : : cerr < < " GxsForumsFillThread::run() Erasing entry " < < it - > first < < " from kids tab. " < < std : : endl ;
# endif
kids_array . erase ( it ) ; // This is not strictly needed, but it improves performance by reducing the search space.
2018-11-17 22:36:07 +01:00
}
2018-11-21 23:18:08 +01:00
# ifdef DEBUG_FORUMS
std : : cerr < < " Kids array now has " < < kids_array . size ( ) < < " elements " < < std : : endl ;
for ( std : : map < RsGxsMessageId , std : : list < RsGxsMessageId > > : : const_iterator it ( kids_array . begin ( ) ) ; it ! = kids_array . end ( ) ; + + it )
{
std : : cerr < < " Node " < < it - > first < < std : : endl ;
for ( std : : list < RsGxsMessageId > : : const_iterator it2 ( it - > second . begin ( ) ) ; it2 ! = it - > second . end ( ) ; + + it2 )
std : : cerr < < " " < < * it2 < < std : : endl ;
}
std : : cerr < < " GxsForumsFillThread::run() stopped: " < < ( wasStopped ( ) ? " yes " : " no " ) < < std : : endl ;
2018-11-17 22:36:07 +01:00
# endif
2018-11-24 20:50:09 +01:00
}
2018-11-24 17:57:19 +01:00
2018-11-24 20:50:09 +01:00
void RsGxsForumModel : : setMsgReadStatus ( const QModelIndex & i , bool read_status , bool with_children )
{
if ( ! i . isValid ( ) )
return ;
2018-11-24 17:57:19 +01:00
2020-05-21 19:07:03 +02:00
// no need to call preMods()/postMods() here because we'renot changing the model
2018-12-03 21:56:11 +01:00
2018-11-24 20:50:09 +01:00
void * ref = i . internalPointer ( ) ;
uint32_t entry = 0 ;
if ( ! convertRefPointerToTabEntry ( ref , entry ) | | entry > = mPosts . size ( ) )
return ;
2020-05-21 19:07:03 +02:00
bool has_unread_below , has_read_below ;
recursSetMsgReadStatus ( entry , read_status , with_children ) ;
2018-12-02 16:34:43 +01:00
recursUpdateReadStatusAndTimes ( 0 , has_unread_below , has_read_below ) ;
2018-11-24 22:06:34 +01:00
2018-11-24 20:50:09 +01:00
}
2019-01-13 15:19:07 +01:00
2018-11-24 20:50:09 +01:00
void RsGxsForumModel : : recursSetMsgReadStatus ( ForumModelIndex i , bool read_status , bool with_children )
{
2020-04-14 14:32:53 +02:00
int newStatus = ( read_status ? mPosts [ i ] . mMsgStatus & ~ static_cast < int > ( GXS_SERV : : GXS_MSG_STATUS_GUI_UNREAD )
: mPosts [ i ] . mMsgStatus | static_cast < int > ( GXS_SERV : : GXS_MSG_STATUS_GUI_UNREAD ) ) ;
bool bChanged = ( mPosts [ i ] . mMsgStatus ! = newStatus ) ;
mPosts [ i ] . mMsgStatus = newStatus ;
//Remove Unprocessed and New flags
mPosts [ i ] . mMsgStatus & = ~ ( GXS_SERV : : GXS_MSG_STATUS_UNPROCESSED | GXS_SERV : : GXS_MSG_STATUS_GUI_NEW ) ;
if ( bChanged )
{
//Don't recurs post versions as this should be done before, if no change.
uint32_t token ;
auto s = getPostVersions ( mPosts [ i ] . mMsgId ) ;
2019-01-13 15:19:07 +01:00
2020-04-14 14:32:53 +02:00
if ( ! s . empty ( ) )
for ( auto it ( s . begin ( ) ) ; it ! = s . end ( ) ; + + it )
{
rsGxsForums - > setMessageReadStatus ( token , std : : make_pair ( mForumGroup . mMeta . mGroupId , it - > second ) , read_status ) ;
std : : cerr < < " Setting version " < < it - > second < < " of post " < < mPosts [ i ] . mMsgId < < " as read. " < < std : : endl ;
}
else
rsGxsForums - > setMessageReadStatus ( token , std : : make_pair ( mForumGroup . mMeta . mGroupId , mPosts [ i ] . mMsgId ) , read_status ) ;
2020-05-21 19:07:03 +02:00
QModelIndex itemIndex = createIndex ( i - 1 , 0 , & mPosts [ i ] ) ;
emit dataChanged ( itemIndex , itemIndex ) ;
2020-04-14 14:32:53 +02:00
}
2018-11-24 20:50:09 +01:00
2020-04-14 14:32:53 +02:00
if ( ! with_children )
return ;
2018-11-24 20:50:09 +01:00
2020-04-14 14:32:53 +02:00
for ( uint32_t j = 0 ; j < mPosts [ i ] . mChildren . size ( ) ; + + j )
recursSetMsgReadStatus ( mPosts [ i ] . mChildren [ j ] , read_status , with_children ) ;
2018-11-24 17:57:19 +01:00
}
2018-12-02 16:34:43 +01:00
void RsGxsForumModel : : recursUpdateReadStatusAndTimes ( ForumModelIndex i , bool & has_unread_below , bool & has_read_below )
2018-11-24 17:57:19 +01:00
{
2018-11-24 20:50:09 +01:00
has_unread_below = IS_MSG_UNREAD ( mPosts [ i ] . mMsgStatus ) ;
has_read_below = ! IS_MSG_UNREAD ( mPosts [ i ] . mMsgStatus ) ;
2018-11-24 17:57:19 +01:00
2018-12-02 16:34:43 +01:00
mPosts [ i ] . mMostRecentTsInThread = mPosts [ i ] . mPublishTs ;
2018-11-24 17:57:19 +01:00
for ( uint32_t j = 0 ; j < mPosts [ i ] . mChildren . size ( ) ; + + j )
{
bool ub , rb ;
2018-12-02 16:34:43 +01:00
recursUpdateReadStatusAndTimes ( mPosts [ i ] . mChildren [ j ] , ub , rb ) ;
2018-11-24 17:57:19 +01:00
has_unread_below = has_unread_below | | ub ;
2018-11-24 20:50:09 +01:00
has_read_below = has_read_below | | rb ;
2018-11-24 17:57:19 +01:00
2018-12-02 16:34:43 +01:00
if ( mPosts [ i ] . mMostRecentTsInThread < mPosts [ mPosts [ i ] . mChildren [ j ] ] . mMostRecentTsInThread )
mPosts [ i ] . mMostRecentTsInThread = mPosts [ mPosts [ i ] . mChildren [ j ] ] . mMostRecentTsInThread ;
2018-11-24 17:57:19 +01:00
}
if ( has_unread_below )
2018-11-24 20:50:09 +01:00
mPosts [ i ] . mPostFlags | = ForumModelPostEntry : : FLAG_POST_HAS_UNREAD_CHILDREN ;
2018-11-24 17:57:19 +01:00
else
mPosts [ i ] . mPostFlags & = ~ ForumModelPostEntry : : FLAG_POST_HAS_UNREAD_CHILDREN ;
if ( has_read_below )
2018-11-24 20:50:09 +01:00
mPosts [ i ] . mPostFlags | = ForumModelPostEntry : : FLAG_POST_HAS_READ_CHILDREN ;
2018-11-24 17:57:19 +01:00
else
mPosts [ i ] . mPostFlags & = ~ ForumModelPostEntry : : FLAG_POST_HAS_READ_CHILDREN ;
2018-11-17 22:36:07 +01:00
}
2018-11-21 23:18:08 +01:00
2018-11-25 22:07:59 +01:00
QModelIndex RsGxsForumModel : : getIndexOfMessage ( const RsGxsMessageId & mid ) const
{
2018-12-09 17:35:31 +01:00
// Brutal search. This is not so nice, so dont call that in a loop! If too costly, we'll use a map.
RsGxsMessageId postId = mid ;
// First look into msg versions, in case the msg is a version of an existing message
2019-10-14 22:24:36 +02:00
for ( auto it ( mPostVersions . begin ( ) ) ; it ! = mPostVersions . end ( ) & & postId = = mid ; + + it )
2018-12-09 17:35:31 +01:00
for ( uint32_t i = 0 ; i < it - > second . size ( ) ; + + i )
if ( it - > second [ i ] . second = = mid )
2019-10-14 22:24:36 +02:00
{
2018-12-09 17:35:31 +01:00
postId = it - > first ;
2019-10-14 22:24:36 +02:00
break ;
}
2018-11-25 22:07:59 +01:00
2019-10-14 22:24:36 +02:00
for ( uint32_t i = 1 ; i < mPosts . size ( ) ; + + i )
2018-12-09 17:35:31 +01:00
if ( mPosts [ i ] . mMsgId = = postId )
2018-11-25 22:07:59 +01:00
{
void * ref ;
2019-10-14 22:24:36 +02:00
convertTabEntryToRefPointer ( i , ref ) ; // we dont use i+1 here because i is not a row, but an index in the mPosts tab
2018-11-25 22:07:59 +01:00
2019-10-14 22:24:36 +02:00
if ( mTreeMode = = TREE_MODE_FLAT )
return createIndex ( i - 1 , 0 , ref ) ;
else
return createIndex ( mPosts [ i ] . prow , 0 , ref ) ;
2018-11-25 22:07:59 +01:00
}
return QModelIndex ( ) ;
}
2019-02-24 00:37:42 +01:00
# ifdef DEBUG_FORUMMODEL
2018-11-26 22:07:10 +01:00
static void recursPrintModel ( const std : : vector < ForumModelPostEntry > & entries , ForumModelIndex index , int depth )
{
const ForumModelPostEntry & e ( entries [ index ] ) ;
2018-11-29 22:15:12 +01:00
QDateTime qtime ;
qtime . setTime_t ( e . mPublishTs ) ;
2018-11-26 22:07:10 +01:00
std : : cerr < < std : : string ( depth * 2 , ' ' ) < < index < < " : " < < e . mAuthorId . toStdString ( ) < < " "
< < QString ( " %1 " ) . arg ( ( uint32_t ) e . mPostFlags , 8 , 16 , QChar ( ' 0 ' ) ) . toStdString ( ) < < " "
< < QString ( " %1 " ) . arg ( ( uint32_t ) e . mMsgStatus , 8 , 16 , QChar ( ' 0 ' ) ) . toStdString ( ) < < " "
2018-11-29 22:15:12 +01:00
< < qtime . toString ( ) . toStdString ( ) < < " \" " < < e . mTitle < < " \" " < < std : : endl ;
2018-11-26 22:07:10 +01:00
for ( uint32_t i = 0 ; i < e . mChildren . size ( ) ; + + i )
recursPrintModel ( entries , e . mChildren [ i ] , depth + 1 ) ;
}
2018-11-22 10:44:06 +01:00
void RsGxsForumModel : : debug_dump ( )
{
std : : cerr < < " Model data dump: " < < std : : endl ;
std : : cerr < < " Entries: " < < mPosts . size ( ) < < std : : endl ;
// non recursive print
for ( uint32_t i = 0 ; i < mPosts . size ( ) ; + + i )
{
const ForumModelPostEntry & e ( mPosts [ i ] ) ;
2018-11-24 20:50:09 +01:00
std : : cerr < < " " < < i < < " : " < < e . mMsgId < < " (from " < < e . mAuthorId . toStdString ( ) < < " ) "
< < QString ( " %1 " ) . arg ( ( uint32_t ) e . mPostFlags , 8 , 16 , QChar ( ' 0 ' ) ) . toStdString ( ) < < " "
< < QString ( " %1 " ) . arg ( ( uint32_t ) e . mMsgStatus , 8 , 16 , QChar ( ' 0 ' ) ) . toStdString ( ) < < " " ;
2018-11-22 10:44:06 +01:00
for ( uint32_t i = 0 ; i < e . mChildren . size ( ) ; + + i )
std : : cerr < < " " < < e . mChildren [ i ] ;
2018-11-29 22:15:12 +01:00
QDateTime qtime ;
qtime . setTime_t ( e . mPublishTs ) ;
2018-11-22 10:44:06 +01:00
std : : cerr < < " ( " < < e . mParent < < " ) " ;
2018-11-29 22:15:12 +01:00
std : : cerr < < " " < < qtime . toString ( ) . toStdString ( ) < < " \" " < < e . mTitle < < " \" " < < std : : endl ;
2018-11-22 10:44:06 +01:00
}
// recursive print
recursPrintModel ( mPosts , ForumModelIndex ( 0 ) , 0 ) ;
}
2018-12-02 16:45:16 +01:00
# endif
2018-11-21 23:18:08 +01:00
2019-02-16 11:42:22 -03:00
void RsGxsForumModel : : setAuthorOpinion ( const QModelIndex & indx , RsOpinion op )
2018-12-06 23:04:53 +01:00
{
if ( ! indx . isValid ( ) )
return ;
2018-11-21 23:18:08 +01:00
2018-12-06 23:04:53 +01:00
void * ref = indx . internalPointer ( ) ;
uint32_t entry = 0 ;
if ( ! convertRefPointerToTabEntry ( ref , entry ) | | entry > = mPosts . size ( ) )
return ;
2019-02-16 11:42:22 -03:00
std : : cerr < < " Setting own opinion for author " < < mPosts [ entry ] . mAuthorId
< < " to " < < static_cast < uint32_t > ( op ) < < std : : endl ;
2018-12-06 23:04:53 +01:00
RsGxsId author_id = mPosts [ entry ] . mAuthorId ;
rsReputations - > setOwnOpinion ( author_id , op ) ;
// update opinions and distribution flags. No need to re-load all posts.
for ( uint32_t i = 0 ; i < mPosts . size ( ) ; + + i )
if ( mPosts [ i ] . mAuthorId = = author_id )
{
computeReputationLevel ( mForumGroup . mMeta . mSignFlags , mPosts [ i ] ) ;
// notify the widgets that the data has changed.
emit dataChanged ( createIndex ( 0 , 0 , ( void * ) NULL ) , createIndex ( 0 , COLUMN_THREAD_NB_COLUMNS - 1 , ( void * ) NULL ) ) ;
}
}