mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #1684 from csoler/v0.6-ImprovedGUI
fixed display in forum flat view
This commit is contained in:
commit
e52d563202
@ -56,7 +56,10 @@ void RsGxsForumModel::preMods()
|
|||||||
}
|
}
|
||||||
void RsGxsForumModel::postMods()
|
void RsGxsForumModel::postMods()
|
||||||
{
|
{
|
||||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(0,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsForumModel::setTreeMode(TreeMode mode)
|
void RsGxsForumModel::setTreeMode(TreeMode mode)
|
||||||
@ -65,7 +68,21 @@ void RsGxsForumModel::setTreeMode(TreeMode mode)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
mTreeMode = mode;
|
mTreeMode = mode;
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,12 +281,22 @@ void *RsGxsForumModel::getParentRef(void *ref,int& row) const
|
|||||||
{
|
{
|
||||||
ForumModelIndex ref_entry;
|
ForumModelIndex ref_entry;
|
||||||
|
|
||||||
if(mTreeMode == TREE_MODE_FLAT)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if(!convertRefPointerToTabEntry(ref,ref_entry) || ref_entry >= mPosts.size())
|
if(!convertRefPointerToTabEntry(ref,ref_entry) || ref_entry >= mPosts.size())
|
||||||
return NULL ;
|
return NULL ;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
ForumModelIndex parent_entry = mPosts[ref_entry].mParent;
|
ForumModelIndex parent_entry = mPosts[ref_entry].mParent;
|
||||||
|
|
||||||
if(parent_entry == 0) // top level index
|
if(parent_entry == 0) // top level index
|
||||||
@ -296,12 +323,22 @@ int RsGxsForumModel::getChildrenCount(void *ref) const
|
|||||||
|
|
||||||
if(mTreeMode == TREE_MODE_FLAT)
|
if(mTreeMode == TREE_MODE_FLAT)
|
||||||
if(entry == 0)
|
if(entry == 0)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_FORUMMODEL
|
||||||
|
std::cerr << "Children count (flat mode): " << mPosts.size()-1 << std::endl;
|
||||||
|
#endif
|
||||||
return ((int)mPosts.size())-1;
|
return ((int)mPosts.size())-1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_FORUMMODEL
|
||||||
|
std::cerr << "Children count (tree mode): " << mPosts[entry].mChildren.size() << std::endl;
|
||||||
|
#endif
|
||||||
return mPosts[entry].mChildren.size();
|
return mPosts[entry].mChildren.size();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const
|
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const
|
||||||
{
|
{
|
||||||
@ -699,7 +736,11 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<F
|
|||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
|
if(mTreeMode == TREE_MODE_FLAT)
|
||||||
|
beginRemoveRows(QModelIndex(),0,mPosts.size()-1);
|
||||||
|
else
|
||||||
beginRemoveRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
beginRemoveRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
||||||
|
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
|
||||||
mForumGroup = group;
|
mForumGroup = group;
|
||||||
@ -723,6 +764,9 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<F
|
|||||||
debug_dump();
|
debug_dump();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(mTreeMode == TREE_MODE_FLAT)
|
||||||
|
beginInsertRows(QModelIndex(),0,mPosts.size()-1);
|
||||||
|
else
|
||||||
beginInsertRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
beginInsertRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
postMods();
|
postMods();
|
||||||
@ -1247,17 +1291,23 @@ QModelIndex RsGxsForumModel::getIndexOfMessage(const RsGxsMessageId& mid) const
|
|||||||
|
|
||||||
// First look into msg versions, in case the msg is a version of an existing message
|
// First look into msg versions, in case the msg is a version of an existing message
|
||||||
|
|
||||||
for(auto it(mPostVersions.begin());it!=mPostVersions.end();++it)
|
for(auto it(mPostVersions.begin());it!=mPostVersions.end() && postId==mid;++it)
|
||||||
for(uint32_t i=0;i<it->second.size();++i)
|
for(uint32_t i=0;i<it->second.size();++i)
|
||||||
if(it->second[i].second == mid)
|
if(it->second[i].second == mid)
|
||||||
|
{
|
||||||
postId = it->first;
|
postId = it->first;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
for(uint32_t i=0;i<mPosts.size();++i)
|
for(uint32_t i=1;i<mPosts.size();++i)
|
||||||
if(mPosts[i].mMsgId == postId)
|
if(mPosts[i].mMsgId == postId)
|
||||||
{
|
{
|
||||||
void *ref ;
|
void *ref ;
|
||||||
convertTabEntryToRefPointer(i,ref);
|
convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab
|
||||||
|
|
||||||
|
if(mTreeMode == TREE_MODE_FLAT)
|
||||||
|
return createIndex(i-1,0,ref);
|
||||||
|
else
|
||||||
return createIndex(mPosts[i].prow,0,ref);
|
return createIndex(mPosts[i].prow,0,ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,20 +84,6 @@
|
|||||||
|
|
||||||
// We need consts for that!! Defined in multiple places.
|
// We need consts for that!! Defined in multiple places.
|
||||||
|
|
||||||
#ifdef TO_REMOVE
|
|
||||||
#define ROLE_THREAD_MSGID Qt::UserRole
|
|
||||||
#define ROLE_THREAD_STATUS Qt::UserRole + 1
|
|
||||||
#define ROLE_THREAD_MISSING Qt::UserRole + 2
|
|
||||||
#define ROLE_THREAD_AUTHOR Qt::UserRole + 3
|
|
||||||
// no need to copy, don't count in ROLE_THREAD_COUNT
|
|
||||||
#define ROLE_THREAD_READCHILDREN Qt::UserRole + 4
|
|
||||||
#define ROLE_THREAD_UNREADCHILDREN Qt::UserRole + 5
|
|
||||||
#define ROLE_THREAD_SORT Qt::UserRole + 6
|
|
||||||
#define ROLE_THREAD_PINNED Qt::UserRole + 7
|
|
||||||
|
|
||||||
#define ROLE_THREAD_COUNT 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef DEBUG_FORUMS
|
||||||
static std::ostream& operator<<(std::ostream& o,const QModelIndex& q)
|
static std::ostream& operator<<(std::ostream& o,const QModelIndex& q)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user