mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 16:39:29 -05:00
Merge pull request #2221 from PhenomRetroShare/Fix_ForSelfBuiltQtQAssert
Fix for running with Self-Built Qt
This commit is contained in:
commit
41727210cd
@ -140,42 +140,38 @@ void RsPostedPostsModel::initEmptyHierarchy()
|
||||
|
||||
void RsPostedPostsModel::preMods()
|
||||
{
|
||||
beginResetModel();
|
||||
emit layoutAboutToBeChanged();
|
||||
}
|
||||
void RsPostedPostsModel::postMods()
|
||||
{
|
||||
endResetModel();
|
||||
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL));
|
||||
update();
|
||||
emit layoutChanged();
|
||||
}
|
||||
void RsPostedPostsModel::update()
|
||||
{
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL));
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL));
|
||||
}
|
||||
void RsPostedPostsModel::triggerRedraw()
|
||||
{
|
||||
preMods();
|
||||
postMods();
|
||||
preMods();
|
||||
postMods();
|
||||
}
|
||||
|
||||
void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
|
||||
{
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
||||
endRemoveRows();
|
||||
beginResetModel();
|
||||
mFilteredPosts.clear();
|
||||
endResetModel();
|
||||
|
||||
if(strings.empty())
|
||||
{
|
||||
mFilteredPosts.clear();
|
||||
for(int i=0;i<(int)(mPosts.size());++i)
|
||||
mFilteredPosts.push_back(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
mFilteredPosts.clear();
|
||||
//mFilteredPosts.push_back(0);
|
||||
|
||||
for(int i=0;i<static_cast<int>(mPosts.size());++i)
|
||||
{
|
||||
bool passes_strings = true;
|
||||
@ -199,8 +195,11 @@ void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
|
||||
|
||||
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
|
||||
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
if (rowCount()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
postMods();
|
||||
}
|
||||
@ -210,11 +209,11 @@ int RsPostedPostsModel::rowCount(const QModelIndex& parent) const
|
||||
if(parent.column() > 0)
|
||||
return 0;
|
||||
|
||||
if(mFilteredPosts.empty()) // security. Should never happen.
|
||||
if(mFilteredPosts.empty()) // rowCount is called by internal Qt so maybe before posts are populated.
|
||||
return 0;
|
||||
|
||||
if(!parent.isValid())
|
||||
return mDisplayedNbPosts;
|
||||
return mDisplayedNbPosts;
|
||||
|
||||
RsErr() << __PRETTY_FUNCTION__ << " rowCount cannot figure out the porper number of rows." << std::endl;
|
||||
return 0;
|
||||
@ -473,7 +472,7 @@ private:
|
||||
Qt::ItemFlags RsPostedPostsModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
return Qt::ItemFlags();
|
||||
|
||||
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||
}
|
||||
@ -495,16 +494,16 @@ void RsPostedPostsModel::setPostsInterval(int start,int nb_posts)
|
||||
|
||||
preMods();
|
||||
|
||||
uint32_t old_nb_rows = rowCount() ;
|
||||
uint32_t old_nb_rows = rowCount() ;
|
||||
|
||||
mDisplayedNbPosts = (uint32_t)std::min(nb_posts,(int)mFilteredPosts.size() - (start+1));
|
||||
mDisplayedStartIndex = start;
|
||||
mDisplayedNbPosts = (uint32_t)std::min(nb_posts,(int)mFilteredPosts.size() - (start+1));
|
||||
mDisplayedStartIndex = start;
|
||||
|
||||
beginRemoveRows(QModelIndex(),mDisplayedNbPosts,old_nb_rows);
|
||||
endRemoveRows();
|
||||
endRemoveRows();
|
||||
|
||||
beginInsertRows(QModelIndex(),old_nb_rows,mDisplayedNbPosts);
|
||||
endInsertRows();
|
||||
endInsertRows();
|
||||
|
||||
postMods();
|
||||
}
|
||||
@ -517,26 +516,30 @@ void RsPostedPostsModel::deepUpdate()
|
||||
|
||||
void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector<RsPostedPost>& posts)
|
||||
{
|
||||
preMods();
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
||||
endRemoveRows();
|
||||
beginResetModel();
|
||||
|
||||
mPosts.clear();
|
||||
mPostedGroup = group;
|
||||
mPosts.clear();
|
||||
mPostedGroup = group;
|
||||
|
||||
createPostsArray(posts);
|
||||
endResetModel();
|
||||
|
||||
std::sort(mPosts.begin(),mPosts.end(), PostSorter(mSortingStrategy));
|
||||
createPostsArray(posts);
|
||||
|
||||
uint32_t tmpval;
|
||||
setFilter(QStringList(),tmpval);
|
||||
std::sort(mPosts.begin(),mPosts.end(), PostSorter(mSortingStrategy));
|
||||
|
||||
mDisplayedNbPosts = std::min((uint32_t)mFilteredPosts.size(),DEFAULT_DISPLAYED_NB_POSTS);
|
||||
mDisplayedStartIndex = 0;
|
||||
uint32_t tmpval;
|
||||
setFilter(QStringList(),tmpval);
|
||||
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
mDisplayedNbPosts = std::min((uint32_t)mFilteredPosts.size(),DEFAULT_DISPLAYED_NB_POSTS);
|
||||
mDisplayedStartIndex = 0;
|
||||
|
||||
if (rowCount()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
postMods();
|
||||
|
||||
@ -599,8 +602,6 @@ void RsPostedPostsModel::update_posts(const RsGxsGroupId& group_id)
|
||||
});
|
||||
}
|
||||
|
||||
//static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
|
||||
|
||||
void RsPostedPostsModel::createPostsArray(std::vector<RsPostedPost>& posts)
|
||||
{
|
||||
#ifdef TODO
|
||||
|
@ -152,93 +152,95 @@ void RsFriendListModel::setDisplayGroups(bool b)
|
||||
}
|
||||
void RsFriendListModel::preMods()
|
||||
{
|
||||
beginResetModel();
|
||||
emit layoutAboutToBeChanged();
|
||||
}
|
||||
void RsFriendListModel::postMods()
|
||||
{
|
||||
endResetModel();
|
||||
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,columnCount()-1,(void*)NULL));
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,columnCount()-1,(void*)NULL));
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
int RsFriendListModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
if(parent.column() >= COLUMN_THREAD_NB_COLUMNS)
|
||||
return 0;
|
||||
if(parent.column() >= COLUMN_THREAD_NB_COLUMNS)
|
||||
return 0;
|
||||
|
||||
if(parent.internalId() == 0)
|
||||
return mTopLevel.size();
|
||||
|
||||
EntryIndex index;
|
||||
if(!convertInternalIdToIndex<sizeof(uintptr_t)>(parent.internalId(),index))
|
||||
return 0;
|
||||
EntryIndex index;
|
||||
if(!convertInternalIdToIndex<sizeof(uintptr_t)>(parent.internalId(),index))
|
||||
return 0;
|
||||
|
||||
if(index.type == ENTRY_TYPE_GROUP)
|
||||
return mGroups[index.group_index].child_profile_indices.size();
|
||||
if(index.type == ENTRY_TYPE_GROUP)
|
||||
return mGroups[index.group_index].child_profile_indices.size();
|
||||
|
||||
if(index.type == ENTRY_TYPE_PROFILE)
|
||||
if(index.type == ENTRY_TYPE_PROFILE)
|
||||
{
|
||||
if(index.group_index < UNDEFINED_GROUP_INDEX_VALUE)
|
||||
return mProfiles[mGroups[index.group_index].child_profile_indices[index.profile_index]].child_node_indices.size();
|
||||
else
|
||||
return mProfiles[index.profile_index].child_node_indices.size();
|
||||
else
|
||||
return mProfiles[index.profile_index].child_node_indices.size();
|
||||
}
|
||||
else //if(index.type == ENTRY_TYPE_NODE)
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RsFriendListModel::columnCount(const QModelIndex &parent) const
|
||||
int RsFriendListModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return COLUMN_THREAD_NB_COLUMNS ;
|
||||
}
|
||||
|
||||
bool RsFriendListModel::hasChildren(const QModelIndex &parent) const
|
||||
{
|
||||
if(!parent.isValid())
|
||||
return true;
|
||||
if(!parent.isValid())
|
||||
return true;
|
||||
|
||||
EntryIndex parent_index ;
|
||||
convertInternalIdToIndex<sizeof(uintptr_t)>(parent.internalId(),parent_index);
|
||||
convertInternalIdToIndex<sizeof(uintptr_t)>(parent.internalId(),parent_index);
|
||||
|
||||
if(parent_index.type == ENTRY_TYPE_NODE)
|
||||
return false;
|
||||
if(parent_index.type == ENTRY_TYPE_NODE)
|
||||
return false;
|
||||
|
||||
if(parent_index.type == ENTRY_TYPE_PROFILE)
|
||||
if(parent_index.type == ENTRY_TYPE_PROFILE)
|
||||
{
|
||||
if(parent_index.group_index < UNDEFINED_GROUP_INDEX_VALUE)
|
||||
return !mProfiles[mGroups[parent_index.group_index].child_profile_indices[parent_index.profile_index]].child_node_indices.empty();
|
||||
else
|
||||
return !mProfiles[parent_index.profile_index].child_node_indices.empty();
|
||||
|
||||
if(parent_index.type == ENTRY_TYPE_GROUP)
|
||||
return !mGroups[parent_index.group_index].child_profile_indices.empty();
|
||||
else
|
||||
return !mProfiles[parent_index.profile_index].child_node_indices.empty();
|
||||
}
|
||||
if(parent_index.type == ENTRY_TYPE_GROUP)
|
||||
return !mGroups[parent_index.group_index].child_profile_indices.empty();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
RsFriendListModel::EntryIndex RsFriendListModel::EntryIndex::parent() const
|
||||
{
|
||||
EntryIndex i(*this);
|
||||
EntryIndex i(*this);
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case ENTRY_TYPE_GROUP: return EntryIndex();
|
||||
switch(type)
|
||||
{
|
||||
case ENTRY_TYPE_GROUP: return EntryIndex();
|
||||
|
||||
case ENTRY_TYPE_PROFILE:
|
||||
if(i.group_index==UNDEFINED_GROUP_INDEX_VALUE)
|
||||
return EntryIndex();
|
||||
else
|
||||
{
|
||||
i.type = ENTRY_TYPE_GROUP;
|
||||
i.profile_index = UNDEFINED_PROFILE_INDEX_VALUE;
|
||||
}
|
||||
break;
|
||||
case ENTRY_TYPE_PROFILE:
|
||||
if(i.group_index==UNDEFINED_GROUP_INDEX_VALUE)
|
||||
return EntryIndex();
|
||||
else
|
||||
{
|
||||
i.type = ENTRY_TYPE_GROUP;
|
||||
i.profile_index = UNDEFINED_PROFILE_INDEX_VALUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case ENTRY_TYPE_NODE: i.type = ENTRY_TYPE_PROFILE;
|
||||
i.node_index = UNDEFINED_NODE_INDEX_VALUE;
|
||||
break;
|
||||
}
|
||||
case ENTRY_TYPE_NODE: i.type = ENTRY_TYPE_PROFILE;
|
||||
i.node_index = UNDEFINED_NODE_INDEX_VALUE;
|
||||
break;
|
||||
case ENTRY_TYPE_UNKNOWN:
|
||||
RS_ERR("Unknown Entry type for parent.");
|
||||
}
|
||||
|
||||
return i;
|
||||
return i;
|
||||
}
|
||||
|
||||
RsFriendListModel::EntryIndex RsFriendListModel::EntryIndex::child(int row,const std::vector<EntryIndex>& top_level) const
|
||||
@ -310,32 +312,32 @@ QModelIndex RsFriendListModel::index(int row, int column, const QModelIndex& par
|
||||
|
||||
QModelIndex RsFriendListModel::parent(const QModelIndex& index) const
|
||||
{
|
||||
if(!index.isValid())
|
||||
return QModelIndex();
|
||||
if(!index.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
EntryIndex I ;
|
||||
convertInternalIdToIndex<sizeof(uintptr_t)>(index.internalId(),I);
|
||||
convertInternalIdToIndex<sizeof(uintptr_t)>(index.internalId(),I);
|
||||
|
||||
EntryIndex p = I.parent();
|
||||
EntryIndex p = I.parent();
|
||||
|
||||
if(p.type == ENTRY_TYPE_UNKNOWN)
|
||||
return QModelIndex();
|
||||
if(p.type == ENTRY_TYPE_UNKNOWN)
|
||||
return QModelIndex();
|
||||
|
||||
quintptr i;
|
||||
convertIndexToInternalId<sizeof(uintptr_t)>(p,i);
|
||||
quintptr i;
|
||||
convertIndexToInternalId<sizeof(uintptr_t)>(p,i);
|
||||
|
||||
return createIndex(I.parentRow(mGroups.size()),0,i);
|
||||
}
|
||||
|
||||
Qt::ItemFlags RsFriendListModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
if (!index.isValid())
|
||||
return Qt::ItemFlags();
|
||||
|
||||
return QAbstractItemModel::flags(index);
|
||||
return QAbstractItemModel::flags(index);
|
||||
}
|
||||
|
||||
QVariant RsFriendListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
QVariant RsFriendListModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const
|
||||
{
|
||||
if(role == Qt::DisplayRole)
|
||||
switch(section)
|
||||
@ -414,17 +416,17 @@ QVariant RsFriendListModel::textColorRole(const EntryIndex& fmpe,int column) con
|
||||
}
|
||||
}
|
||||
|
||||
QVariant RsFriendListModel::statusRole(const EntryIndex& fmpe,int column) const
|
||||
QVariant RsFriendListModel::statusRole(const EntryIndex& /*fmpe*/,int /*column*/) const
|
||||
{
|
||||
return QVariant();//fmpe.mMsgStatus);
|
||||
}
|
||||
|
||||
bool RsFriendListModel::passesFilter(const EntryIndex& e,int column) const
|
||||
bool RsFriendListModel::passesFilter(const EntryIndex& e,int /*column*/) const
|
||||
{
|
||||
QString s ;
|
||||
bool passes_strings = true ;
|
||||
|
||||
if(e.type == ENTRY_TYPE_PROFILE && !mFilterStrings.empty())
|
||||
if(e.type == ENTRY_TYPE_PROFILE && !mFilterStrings.empty())
|
||||
{
|
||||
switch(mFilterType)
|
||||
{
|
||||
@ -435,6 +437,8 @@ bool RsFriendListModel::passesFilter(const EntryIndex& e,int column) const
|
||||
if(s.isNull())
|
||||
passes_strings = false;
|
||||
break;
|
||||
case FILTER_TYPE_NONE:
|
||||
RS_ERR("None Type for Filter.");
|
||||
};
|
||||
}
|
||||
|
||||
@ -447,18 +451,15 @@ bool RsFriendListModel::passesFilter(const EntryIndex& e,int column) const
|
||||
|
||||
QVariant RsFriendListModel::filterRole(const EntryIndex& e,int column) const
|
||||
{
|
||||
if(passesFilter(e,column))
|
||||
return QVariant(FilterString);
|
||||
if(passesFilter(e,column))
|
||||
return QVariant(FilterString);
|
||||
|
||||
return QVariant(QString());
|
||||
}
|
||||
|
||||
uint32_t RsFriendListModel::updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings)
|
||||
uint32_t RsFriendListModel::updateFilterStatus(ForumModelIndex /*i*/,int /*column*/,const QStringList& /*strings*/)
|
||||
{
|
||||
QString s ;
|
||||
uint32_t count = 0;
|
||||
|
||||
return count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -479,7 +480,7 @@ void RsFriendListModel::setFilter(FilterType filter_type, const QStringList& str
|
||||
postMods();
|
||||
}
|
||||
|
||||
QVariant RsFriendListModel::toolTipRole(const EntryIndex& fmpe,int column) const
|
||||
QVariant RsFriendListModel::toolTipRole(const EntryIndex& /*fmpe*/,int /*column*/) const
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
@ -489,14 +490,14 @@ QVariant RsFriendListModel::sizeHintRole(const EntryIndex& e,int col) const
|
||||
float x_factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
|
||||
float y_factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
|
||||
|
||||
if(e.type == ENTRY_TYPE_NODE)
|
||||
y_factor *= 3.0;
|
||||
if(e.type == ENTRY_TYPE_NODE)
|
||||
y_factor *= 3.0;
|
||||
|
||||
if((e.type == ENTRY_TYPE_PROFILE) && !isProfileExpanded(e))
|
||||
y_factor *= 3.0;
|
||||
if((e.type == ENTRY_TYPE_PROFILE) && !isProfileExpanded(e))
|
||||
y_factor *= 3.0;
|
||||
|
||||
if(e.type == ENTRY_TYPE_GROUP)
|
||||
y_factor = std::max(y_factor, 24.0f / 14.0f ); // allows to fit the 24 pixels icon for groups in the line
|
||||
if(e.type == ENTRY_TYPE_GROUP)
|
||||
y_factor = std::max(y_factor, 24.0f / 14.0f ); // allows to fit the 24 pixels icon for groups in the line
|
||||
|
||||
switch(col)
|
||||
{
|
||||
@ -542,7 +543,7 @@ QVariant RsFriendListModel::sortRole(const EntryIndex& entry,int column) const
|
||||
}
|
||||
}
|
||||
|
||||
QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int col) const
|
||||
QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const
|
||||
{
|
||||
switch(e.type)
|
||||
{
|
||||
@ -698,7 +699,7 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
|
||||
if(col == COLUMN_THREAD_IP) return QVariant(most_recent_ip);
|
||||
}
|
||||
|
||||
}
|
||||
}// Fall-through
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -826,7 +827,6 @@ const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getNode
|
||||
if(e.node_index >= mProfiles[pindex].child_node_indices.size())
|
||||
return NULL ;
|
||||
|
||||
time_t now = time(NULL);
|
||||
HierarchicalNodeInformation& node(mLocations[mProfiles[pindex].child_node_indices[e.node_index]]);
|
||||
|
||||
return &node;
|
||||
@ -895,8 +895,6 @@ void RsFriendListModel::clear()
|
||||
emit friendListChanged();
|
||||
}
|
||||
|
||||
static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
|
||||
|
||||
void RsFriendListModel::debug_dump() const
|
||||
{
|
||||
std::cerr << "==== FriendListModel Debug dump ====" << std::endl;
|
||||
@ -1084,14 +1082,14 @@ void RsFriendListModel::updateInternalData()
|
||||
{
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,mTopLevel.size()-1);
|
||||
beginResetModel();
|
||||
|
||||
mGroups.clear();
|
||||
mProfiles.clear();
|
||||
mLocations.clear();
|
||||
mTopLevel.clear();
|
||||
|
||||
endRemoveRows();
|
||||
endResetModel();
|
||||
|
||||
auto TL = mTopLevel ; // This allows to fill TL without touching mTopLevel outside of [begin/end]InsertRows().
|
||||
|
||||
@ -1218,17 +1216,19 @@ void RsFriendListModel::updateInternalData()
|
||||
TL.push_back(e);
|
||||
}
|
||||
|
||||
// finally, tell the model client that layout has changed.
|
||||
// finally, tell the model client that layout has changed.
|
||||
|
||||
beginInsertRows(QModelIndex(),0,TL.size()-1);
|
||||
mTopLevel = TL;
|
||||
|
||||
mTopLevel = TL;
|
||||
if (TL.size()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,TL.size()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
endInsertRows();
|
||||
postMods();
|
||||
|
||||
postMods();
|
||||
|
||||
mLastInternalDataUpdate = time(NULL);
|
||||
mLastInternalDataUpdate = time(NULL);
|
||||
}
|
||||
|
||||
QModelIndex RsFriendListModel::getIndexOfGroup(const RsNodeGroupId& mid) const
|
||||
@ -1251,7 +1251,7 @@ void RsFriendListModel::collapseItem(const QModelIndex& index)
|
||||
if(!convertInternalIdToIndex<sizeof(uintptr_t)>(index.internalId(),entry))
|
||||
return;
|
||||
|
||||
const HierarchicalProfileInformation *hp = getProfileInfo(entry);
|
||||
const HierarchicalProfileInformation *hp = getProfileInfo(entry);
|
||||
const HierarchicalGroupInformation *hg = getGroupInfo(entry);
|
||||
|
||||
std::string s ;
|
||||
@ -1276,7 +1276,7 @@ void RsFriendListModel::expandItem(const QModelIndex& index)
|
||||
if(!convertInternalIdToIndex<sizeof(uintptr_t)>(index.internalId(),entry))
|
||||
return;
|
||||
|
||||
const HierarchicalProfileInformation *hp = getProfileInfo(entry);
|
||||
const HierarchicalProfileInformation *hp = getProfileInfo(entry);
|
||||
const HierarchicalGroupInformation *hg = getGroupInfo(entry);
|
||||
|
||||
std::string s ;
|
||||
|
@ -37,7 +37,9 @@
|
||||
|
||||
Q_DECLARE_METATYPE(ChannelPostFileInfo)
|
||||
|
||||
#ifdef DEBUG_CHANNEL_MODEL
|
||||
static std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere
|
||||
#endif
|
||||
|
||||
RsGxsChannelPostFilesModel::RsGxsChannelPostFilesModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
@ -50,45 +52,43 @@ RsGxsChannelPostFilesModel::RsGxsChannelPostFilesModel(QObject *parent)
|
||||
|
||||
void RsGxsChannelPostFilesModel::initEmptyHierarchy()
|
||||
{
|
||||
preMods();
|
||||
beginResetModel();
|
||||
|
||||
mFiles.clear();
|
||||
mFilteredFiles.clear();
|
||||
mFiles.clear();
|
||||
mFilteredFiles.clear();
|
||||
|
||||
postMods();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void RsGxsChannelPostFilesModel::preMods()
|
||||
{
|
||||
//emit layoutAboutToBeChanged(); //Generate SIGSEGV when click on button move next/prev.
|
||||
|
||||
beginResetModel();
|
||||
emit layoutAboutToBeChanged();
|
||||
}
|
||||
void RsGxsChannelPostFilesModel::postMods()
|
||||
{
|
||||
endResetModel();
|
||||
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredFiles.size(),COLUMN_FILES_NB_COLUMNS-1,(void*)NULL));
|
||||
emit QAbstractItemModel::dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredFiles.size(),COLUMN_FILES_NB_COLUMNS-1,(void*)NULL));
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
void RsGxsChannelPostFilesModel::update()
|
||||
{
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredFiles.size(),COLUMN_FILES_NB_COLUMNS-1,(void*)NULL));
|
||||
preMods();
|
||||
postMods();
|
||||
}
|
||||
|
||||
int RsGxsChannelPostFilesModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
if(parent.column() > 0)
|
||||
return 0;
|
||||
if(parent.column() > 0)
|
||||
return 0;
|
||||
|
||||
if(mFilteredFiles.empty()) // security. Should never happen.
|
||||
return 0;
|
||||
if(mFilteredFiles.empty()) // security. Should never happen.
|
||||
return 0;
|
||||
|
||||
if(!parent.isValid())
|
||||
if(!parent.isValid())
|
||||
return mFilteredFiles.size(); // mFilteredPosts always has an item at 0, so size()>=1, and mColumn>=1
|
||||
|
||||
RsErr() << __PRETTY_FUNCTION__ << " rowCount cannot figure out the porper number of rows." << std::endl;
|
||||
return 0;
|
||||
RS_ERR(" rowCount cannot figure out the proper number of rows.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RsGxsChannelPostFilesModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
@ -99,15 +99,15 @@ int RsGxsChannelPostFilesModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
bool RsGxsChannelPostFilesModel::getFileData(const QModelIndex& i,ChannelPostFileInfo& fmpe) const
|
||||
{
|
||||
if(!i.isValid())
|
||||
return true;
|
||||
return true;
|
||||
|
||||
quintptr ref = i.internalId();
|
||||
quintptr ref = i.internalId();
|
||||
uint32_t entry = 0;
|
||||
|
||||
if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFiles.size())
|
||||
return false ;
|
||||
|
||||
fmpe = mFiles[mFilteredFiles[entry]];
|
||||
fmpe = mFiles[mFilteredFiles[entry]];
|
||||
|
||||
return true;
|
||||
|
||||
@ -115,8 +115,8 @@ bool RsGxsChannelPostFilesModel::getFileData(const QModelIndex& i,ChannelPostFil
|
||||
|
||||
bool RsGxsChannelPostFilesModel::hasChildren(const QModelIndex &parent) const
|
||||
{
|
||||
if(!parent.isValid())
|
||||
return true;
|
||||
if(!parent.isValid())
|
||||
return true;
|
||||
|
||||
return false; // by default, no channel post has children
|
||||
}
|
||||
@ -167,22 +167,19 @@ QModelIndex RsGxsChannelPostFilesModel::index(int row, int column, const QModelI
|
||||
return createIndex(row,column,ref) ;
|
||||
}
|
||||
|
||||
QModelIndex RsGxsChannelPostFilesModel::parent(const QModelIndex& index) const
|
||||
QModelIndex RsGxsChannelPostFilesModel::parent(const QModelIndex& /*index*/) const
|
||||
{
|
||||
if(!index.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
return QModelIndex(); // there's no hierarchy here. So nothing to do!
|
||||
}
|
||||
|
||||
Qt::ItemFlags RsGxsChannelPostFilesModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
if (!index.isValid())
|
||||
return Qt::ItemFlag();
|
||||
|
||||
if(index.column() == COLUMN_FILES_FILE)
|
||||
if(index.column() == COLUMN_FILES_FILE)
|
||||
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||
else
|
||||
else
|
||||
return QAbstractItemModel::flags(index);
|
||||
}
|
||||
|
||||
@ -191,7 +188,7 @@ quintptr RsGxsChannelPostFilesModel::getChildRef(quintptr ref,int index) const
|
||||
if (index < 0)
|
||||
return 0;
|
||||
|
||||
if(ref == quintptr(0))
|
||||
if(ref == quintptr(0))
|
||||
{
|
||||
quintptr new_ref;
|
||||
convertTabEntryToRefPointer(index,new_ref);
|
||||
@ -221,15 +218,13 @@ quintptr RsGxsChannelPostFilesModel::getParentRow(quintptr ref,int& row) const
|
||||
|
||||
int RsGxsChannelPostFilesModel::getChildrenCount(quintptr ref) const
|
||||
{
|
||||
uint32_t entry = 0 ;
|
||||
|
||||
if(ref == quintptr(0))
|
||||
return rowCount()-1;
|
||||
if(ref == quintptr(0))
|
||||
return rowCount()-1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
QVariant RsGxsChannelPostFilesModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
QVariant RsGxsChannelPostFilesModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
@ -298,39 +293,37 @@ QVariant RsGxsChannelPostFilesModel::data(const QModelIndex &index, int role) co
|
||||
|
||||
void RsGxsChannelPostFilesModel::setFilter(const QStringList& strings, uint32_t& count)
|
||||
{
|
||||
preMods();
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
||||
endRemoveRows();
|
||||
initEmptyHierarchy();
|
||||
|
||||
if(strings.empty())
|
||||
{
|
||||
mFilteredFiles.clear();
|
||||
for(uint32_t i=0;i<mFiles.size();++i)
|
||||
mFilteredFiles.push_back(i);
|
||||
}
|
||||
{
|
||||
for(uint32_t i=0;i<mFiles.size();++i)
|
||||
mFilteredFiles.push_back(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
mFilteredFiles.clear();
|
||||
//mFilteredPosts.push_back(0);
|
||||
|
||||
for(uint32_t i=0;i<mFiles.size();++i)
|
||||
{
|
||||
bool passes_strings = true;
|
||||
{
|
||||
for(uint32_t i=0;i<mFiles.size();++i)
|
||||
{
|
||||
bool passes_strings = true;
|
||||
|
||||
for(auto& s:strings)
|
||||
passes_strings = passes_strings && QString::fromStdString(mFiles[i].mName).contains(s,Qt::CaseInsensitive);
|
||||
|
||||
if(passes_strings)
|
||||
mFilteredFiles.push_back(i);
|
||||
}
|
||||
}
|
||||
count = mFilteredFiles.size();
|
||||
if(passes_strings)
|
||||
mFilteredFiles.push_back(i);
|
||||
}
|
||||
}
|
||||
count = mFilteredFiles.size();
|
||||
|
||||
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
|
||||
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
|
||||
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
if (rowCount()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
postMods();
|
||||
}
|
||||
@ -372,7 +365,7 @@ void RsGxsChannelPostFilesModel::sort(int column, Qt::SortOrder order)
|
||||
update();
|
||||
}
|
||||
|
||||
QVariant RsGxsChannelPostFilesModel::sizeHintRole(int col) const
|
||||
QVariant RsGxsChannelPostFilesModel::sizeHintRole(int /*col*/) const
|
||||
{
|
||||
float factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
|
||||
|
||||
@ -435,42 +428,40 @@ QVariant RsGxsChannelPostFilesModel::userRole(const ChannelPostFileInfo& fmpe,in
|
||||
|
||||
void RsGxsChannelPostFilesModel::clear()
|
||||
{
|
||||
preMods();
|
||||
|
||||
initEmptyHierarchy();
|
||||
initEmptyHierarchy();
|
||||
|
||||
postMods();
|
||||
emit channelLoaded();
|
||||
}
|
||||
|
||||
void RsGxsChannelPostFilesModel::setFiles(const std::list<ChannelPostFileInfo> &files)
|
||||
{
|
||||
preMods();
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,mFilteredFiles.size()-1);
|
||||
endRemoveRows();
|
||||
initEmptyHierarchy();
|
||||
|
||||
initEmptyHierarchy();
|
||||
for(auto& file:files)
|
||||
mFiles.push_back(file);
|
||||
|
||||
for(auto& file:files)
|
||||
mFiles.push_back(file);
|
||||
|
||||
for(uint32_t i=0;i<mFiles.size();++i)
|
||||
mFilteredFiles.push_back(i);
|
||||
for(uint32_t i=0;i<mFiles.size();++i)
|
||||
mFilteredFiles.push_back(i);
|
||||
|
||||
#ifdef DEBUG_CHANNEL_MODEL
|
||||
// debug_dump();
|
||||
// debug_dump();
|
||||
#endif
|
||||
|
||||
beginInsertRows(QModelIndex(),0,mFilteredFiles.size()-1);
|
||||
endInsertRows();
|
||||
|
||||
postMods();
|
||||
if (mFilteredFiles.size()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,mFilteredFiles.size()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
emit channelLoaded();
|
||||
|
||||
if(!files.empty())
|
||||
mTimer->start(5000);
|
||||
else
|
||||
mTimer->stop();
|
||||
if(!files.empty())
|
||||
mTimer->start(5000);
|
||||
else
|
||||
mTimer->stop();
|
||||
|
||||
postMods();
|
||||
}
|
||||
|
@ -203,23 +203,22 @@ void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEve
|
||||
|
||||
void RsGxsChannelPostsModel::initEmptyHierarchy()
|
||||
{
|
||||
preMods();
|
||||
beginResetModel();
|
||||
|
||||
mPosts.clear();
|
||||
mFilteredPosts.clear();
|
||||
mPosts.clear();
|
||||
mFilteredPosts.clear();
|
||||
|
||||
postMods();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void RsGxsChannelPostsModel::preMods()
|
||||
{
|
||||
beginResetModel();
|
||||
emit layoutAboutToBeChanged();
|
||||
}
|
||||
void RsGxsChannelPostsModel::postMods()
|
||||
{
|
||||
endResetModel();
|
||||
|
||||
triggerViewUpdate();
|
||||
triggerViewUpdate();
|
||||
emit layoutChanged();
|
||||
}
|
||||
void RsGxsChannelPostsModel::triggerViewUpdate()
|
||||
{
|
||||
@ -244,13 +243,13 @@ void RsGxsChannelPostsModel::getFilesList(std::list<ChannelPostFileInfo>& files)
|
||||
|
||||
void RsGxsChannelPostsModel::setFilter(const QStringList& strings,bool only_unread, uint32_t& count)
|
||||
{
|
||||
preMods();
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
||||
endRemoveRows();
|
||||
beginResetModel();
|
||||
|
||||
mFilteredPosts.clear();
|
||||
//mFilteredPosts.push_back(0);
|
||||
mFilteredPosts.clear();
|
||||
//mFilteredPosts.push_back(0);
|
||||
endResetModel();
|
||||
|
||||
for(size_t i=0;i<mPosts.size();++i)
|
||||
{
|
||||
@ -268,8 +267,11 @@ void RsGxsChannelPostsModel::setFilter(const QStringList& strings,bool only_unre
|
||||
|
||||
count = mFilteredPosts.size();
|
||||
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
if (rowCount()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
postMods();
|
||||
}
|
||||
@ -321,8 +323,8 @@ bool RsGxsChannelPostsModel::getPostData(const QModelIndex& i,RsGxsChannelPost&
|
||||
|
||||
bool RsGxsChannelPostsModel::hasChildren(const QModelIndex &parent) const
|
||||
{
|
||||
if(!parent.isValid())
|
||||
return true;
|
||||
if(!parent.isValid())
|
||||
return true;
|
||||
|
||||
return false; // by default, no channel post has children
|
||||
}
|
||||
@ -374,45 +376,45 @@ QModelIndex RsGxsChannelPostsModel::index(int row, int column, const QModelIndex
|
||||
return createIndex(row,column,ref) ;
|
||||
}
|
||||
|
||||
QModelIndex RsGxsChannelPostsModel::parent(const QModelIndex& index) const
|
||||
QModelIndex RsGxsChannelPostsModel::parent(const QModelIndex& /*index*/) const
|
||||
{
|
||||
if(!index.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
return QModelIndex(); // there's no hierarchy here. So nothing to do!
|
||||
}
|
||||
|
||||
Qt::ItemFlags RsGxsChannelPostsModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
return Qt::ItemFlags();
|
||||
|
||||
return QAbstractItemModel::flags(index);
|
||||
}
|
||||
|
||||
bool RsGxsChannelPostsModel::setNumColumns(int n)
|
||||
{
|
||||
if(n < 1)
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " Attempt to set a number of column of 0. This is wrong." << std::endl;
|
||||
return false;
|
||||
}
|
||||
if((int)mColumns == n)
|
||||
return false;
|
||||
if(n < 1)
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " Attempt to set a number of column of 0. This is wrong." << std::endl;
|
||||
return false;
|
||||
}
|
||||
if((int)mColumns == n)
|
||||
return false;
|
||||
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
||||
endRemoveRows();
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
|
||||
mColumns = n;
|
||||
mColumns = n;
|
||||
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
if (rowCount()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
postMods();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
quintptr RsGxsChannelPostsModel::getChildRef(quintptr ref,int index) const
|
||||
@ -450,8 +452,8 @@ quintptr RsGxsChannelPostsModel::getParentRow(quintptr ref,int& row) const
|
||||
|
||||
int RsGxsChannelPostsModel::getChildrenCount(quintptr ref) const
|
||||
{
|
||||
if(ref == quintptr(0))
|
||||
return rowCount()-1;
|
||||
if(ref == quintptr(0))
|
||||
return rowCount()-1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -549,10 +551,9 @@ void RsGxsChannelPostsModel::updateChannel(const RsGxsGroupId& channel_group_id)
|
||||
|
||||
void RsGxsChannelPostsModel::clear()
|
||||
{
|
||||
preMods();
|
||||
preMods();
|
||||
|
||||
mPosts.clear();
|
||||
initEmptyHierarchy();
|
||||
initEmptyHierarchy();
|
||||
|
||||
postMods();
|
||||
emit channelPostsLoaded();
|
||||
@ -565,28 +566,27 @@ bool operator<(const RsGxsChannelPost& p1,const RsGxsChannelPost& p2)
|
||||
|
||||
void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vector<RsGxsChannelPost>& posts)
|
||||
{
|
||||
preMods();
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
||||
endRemoveRows();
|
||||
initEmptyHierarchy();
|
||||
mChannelGroup = group;
|
||||
|
||||
mPosts.clear();
|
||||
mChannelGroup = group;
|
||||
createPostsArray(posts);
|
||||
|
||||
createPostsArray(posts);
|
||||
std::sort(mPosts.begin(),mPosts.end());
|
||||
|
||||
std::sort(mPosts.begin(),mPosts.end());
|
||||
|
||||
mFilteredPosts.clear();
|
||||
for(uint32_t i=0;i<mPosts.size();++i)
|
||||
mFilteredPosts.push_back(i);
|
||||
for(uint32_t i=0;i<mPosts.size();++i)
|
||||
mFilteredPosts.push_back(i);
|
||||
|
||||
#ifdef DEBUG_CHANNEL_MODEL
|
||||
// debug_dump();
|
||||
// debug_dump();
|
||||
#endif
|
||||
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
if (rowCount()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
postMods();
|
||||
|
||||
@ -595,8 +595,8 @@ void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vecto
|
||||
|
||||
void RsGxsChannelPostsModel::update_posts(const RsGxsGroupId& group_id)
|
||||
{
|
||||
if(group_id.isNull())
|
||||
return;
|
||||
if(group_id.isNull())
|
||||
return;
|
||||
|
||||
RsThread::async([this, group_id]()
|
||||
{
|
||||
|
@ -238,7 +238,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
||||
info_text += ", " + QString::number(post.mAttachmentCount)+ " " +((post.mAttachmentCount>1)?tr("files"):tr("file")) + " (" + misc::friendlyUnit(qulonglong(post.mSize)) + ")" ;
|
||||
|
||||
painter->drawText(QPoint(p.x()+0.5*font_height,y),info_text);
|
||||
y += font_height;
|
||||
//y += font_height;
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
@ -400,21 +400,21 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
|
||||
ui->channelPostFiles_TV->setItemDelegate(new ChannelPostFilesDelegate(this));
|
||||
ui->channelPostFiles_TV->setPlaceholderText(tr("No files in this post, or no post selected"));
|
||||
ui->channelPostFiles_TV->setSortingEnabled(true);
|
||||
ui->channelPostFiles_TV->sortByColumn(3, Qt::AscendingOrder); // sort by time
|
||||
ui->channelPostFiles_TV->sortByColumn(RsGxsChannelPostFilesModel::COLUMN_FILES_DATE, Qt::DescendingOrder); // sort by time
|
||||
ui->channelPostFiles_TV->setAlternatingRowColors(false);
|
||||
|
||||
ui->channelFiles_TV->setModel(mChannelFilesModel = new RsGxsChannelPostFilesModel());
|
||||
ui->channelFiles_TV->setItemDelegate(mFilesDelegate = new ChannelPostFilesDelegate(this));
|
||||
ui->channelFiles_TV->setPlaceholderText(tr("No files in the channel, or no channel selected"));
|
||||
ui->channelFiles_TV->setSortingEnabled(true);
|
||||
ui->channelFiles_TV->sortByColumn(RsGxsChannelPostFilesModel::COLUMN_FILES_DATE, Qt::DescendingOrder); // sort by time
|
||||
|
||||
connect(ui->channelPostFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnPostFiles(int,Qt::SortOrder)));
|
||||
connect(ui->channelFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnFiles(int,Qt::SortOrder)));
|
||||
|
||||
connect(ui->channelPostFiles_TV,SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showChannelFilesContextMenu(QPoint)));
|
||||
connect(ui->channelFiles_TV,SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showChannelFilesContextMenu(QPoint)));
|
||||
|
||||
ui->channelFiles_TV->setModel(mChannelFilesModel = new RsGxsChannelPostFilesModel());
|
||||
ui->channelFiles_TV->setItemDelegate(mFilesDelegate = new ChannelPostFilesDelegate(this));
|
||||
ui->channelFiles_TV->setPlaceholderText(tr("No files in the channel, or no channel selected"));
|
||||
ui->channelFiles_TV->setSortingEnabled(true);
|
||||
ui->channelFiles_TV->sortByColumn(3, Qt::AscendingOrder); // sort by time
|
||||
|
||||
connect(ui->postsTree->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(showPostDetails()));
|
||||
connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&)));
|
||||
|
||||
@ -666,7 +666,7 @@ void GxsChannelPostsWidgetWithModel::download()
|
||||
std::string destination;
|
||||
rsGxsChannels->getChannelDownloadDirectory(mGroup.mMeta.mGroupId,destination);
|
||||
|
||||
for(auto file:post.mFiles)
|
||||
for(auto& file:post.mFiles)
|
||||
{
|
||||
std::list<RsPeerId> sources;
|
||||
std::string destination;
|
||||
@ -940,8 +940,9 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
|
||||
mChannelPostsModel->getFilesList(files);
|
||||
mChannelFilesModel->setFiles(files);
|
||||
|
||||
ui->channelFiles_TV->setAutoSelect(true);
|
||||
ui->channelFiles_TV->sortByColumn(3, Qt::AscendingOrder);
|
||||
ui->channelFiles_TV->setAutoSelect(true);
|
||||
ui->channelFiles_TV->sortByColumn(ui->channelFiles_TV->header()->sortIndicatorSection()
|
||||
,ui->channelFiles_TV->header()->sortIndicatorOrder());
|
||||
|
||||
ui->infoPosts->setText(QString::number(mChannelPostsModel->getNumberOfPosts()) + " / " + QString::number(mGroup.mMeta.mVisibleMsgCount));
|
||||
|
||||
@ -1207,11 +1208,11 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
|
||||
|
||||
QString distrib_string ( "[unknown]" );
|
||||
|
||||
switch(group.mMeta.mCircleType)
|
||||
switch((RsGxsCircleType)group.mMeta.mCircleType)
|
||||
{
|
||||
case GXS_CIRCLE_TYPE_PUBLIC: distrib_string = tr("Public") ;
|
||||
case RsGxsCircleType::PUBLIC: distrib_string = tr("Public") ;
|
||||
break ;
|
||||
case GXS_CIRCLE_TYPE_EXTERNAL:
|
||||
case RsGxsCircleType::EXTERNAL:
|
||||
{
|
||||
RsGxsCircleDetails det ;
|
||||
|
||||
@ -1223,9 +1224,9 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
|
||||
distrib_string = tr("Restricted to members of circle ")+QString::fromStdString(group.mMeta.mCircleId.toStdString()) ;
|
||||
}
|
||||
break ;
|
||||
case GXS_CIRCLE_TYPE_YOUR_EYES_ONLY: distrib_string = tr("Your eyes only");
|
||||
case RsGxsCircleType::YOUR_EYES_ONLY: distrib_string = tr("Your eyes only");
|
||||
break ;
|
||||
case GXS_CIRCLE_TYPE_LOCAL: distrib_string = tr("You and your friend nodes");
|
||||
case RsGxsCircleType::LOCAL: distrib_string = tr("You and your friend nodes");
|
||||
break ;
|
||||
default:
|
||||
std::cerr << "(EE) badly initialised group distribution ID = " << group.mMeta.mCircleType << std::endl;
|
||||
@ -1246,7 +1247,7 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
|
||||
showPostDetails();
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidgetWithModel::showChannelFilesContextMenu(QPoint p)
|
||||
void GxsChannelPostsWidgetWithModel::showChannelFilesContextMenu(QPoint /*p*/)
|
||||
{
|
||||
QMenu contextMnu(this) ;
|
||||
|
||||
@ -1317,7 +1318,7 @@ void GxsChannelPostsWidgetWithModel::switchOnlyUnread(bool)
|
||||
}
|
||||
void GxsChannelPostsWidgetWithModel::filterChanged(QString s)
|
||||
{
|
||||
QStringList ql = s.split(' ',QString::SkipEmptyParts);
|
||||
QStringList ql = s.split(' ',Qt::SkipEmptyParts);
|
||||
uint32_t count;
|
||||
mChannelPostsModel->setFilter(ql,ui->showUnread_TB->isChecked(),count);
|
||||
mChannelFilesModel->setFilter(ql,count);
|
||||
@ -1420,7 +1421,7 @@ void GxsChannelPostsWidgetWithModel::toggleAutoDownload()
|
||||
class GxsChannelPostsReadData
|
||||
{
|
||||
public:
|
||||
GxsChannelPostsReadData(bool read)
|
||||
explicit GxsChannelPostsReadData(bool read)
|
||||
{
|
||||
mRead = read;
|
||||
mLastToken = 0;
|
||||
|
@ -50,42 +50,32 @@ RsGxsForumModel::RsGxsForumModel(QObject *parent)
|
||||
|
||||
void RsGxsForumModel::preMods()
|
||||
{
|
||||
//emit layoutAboutToBeChanged(); //Generate SIGSEGV when click on button move next/prev.
|
||||
|
||||
beginResetModel();
|
||||
emit layoutAboutToBeChanged();
|
||||
}
|
||||
void RsGxsForumModel::postMods()
|
||||
{
|
||||
endResetModel();
|
||||
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mPosts.size(),COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
else
|
||||
else
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mPosts[0].mChildren.size(),COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
void RsGxsForumModel::setTreeMode(TreeMode mode)
|
||||
{
|
||||
if(mode == mTreeMode)
|
||||
return;
|
||||
if(mode == mTreeMode)
|
||||
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();
|
||||
}
|
||||
beginResetModel();
|
||||
|
||||
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();
|
||||
}
|
||||
endResetModel();
|
||||
|
||||
postMods();
|
||||
postMods();
|
||||
}
|
||||
|
||||
void RsGxsForumModel::setSortMode(SortMode mode)
|
||||
@ -241,7 +231,7 @@ QModelIndex RsGxsForumModel::parent(const QModelIndex& index) const
|
||||
Qt::ItemFlags RsGxsForumModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
return Qt::ItemFlags();
|
||||
|
||||
return QAbstractItemModel::flags(index);
|
||||
}
|
||||
@ -466,8 +456,8 @@ QVariant RsGxsForumModel::statusRole(const ForumModelPostEntry& fmpe,int column)
|
||||
|
||||
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int /*column*/) const
|
||||
{
|
||||
if(!mFilteringEnabled || (fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_CHILDREN_PASSES_FILTER))
|
||||
return QVariant(FilterString);
|
||||
if(!mFilteringEnabled || (fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_CHILDREN_PASSES_FILTER))
|
||||
return QVariant(FilterString);
|
||||
|
||||
return QVariant(QString());
|
||||
}
|
||||
@ -755,65 +745,68 @@ void RsGxsForumModel::clear()
|
||||
|
||||
void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<ForumModelPostEntry>& posts,const std::map<RsGxsMessageId,std::vector<std::pair<time_t,RsGxsMessageId> > >& post_versions)
|
||||
{
|
||||
preMods();
|
||||
preMods();
|
||||
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
beginRemoveRows(QModelIndex(),0,mPosts.size()-1);
|
||||
else
|
||||
beginRemoveRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
|
||||
endRemoveRows();
|
||||
mForumGroup = group;
|
||||
mPosts = posts;
|
||||
mPostVersions = post_versions;
|
||||
|
||||
mForumGroup = group;
|
||||
mPosts = posts;
|
||||
mPostVersions = post_versions;
|
||||
// now update prow for all posts
|
||||
|
||||
// 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;
|
||||
|
||||
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;
|
||||
|
||||
mPosts[0].prow = 0;
|
||||
bool has_unread_below,has_read_below ;
|
||||
|
||||
bool has_unread_below,has_read_below ;
|
||||
|
||||
recursUpdateReadStatusAndTimes(0,has_unread_below,has_read_below) ;
|
||||
recursUpdateFilterStatus(0,0,QStringList());
|
||||
recursUpdateReadStatusAndTimes(0,has_unread_below,has_read_below) ;
|
||||
recursUpdateFilterStatus(0,0,QStringList());
|
||||
|
||||
#ifdef DEBUG_FORUMMODEL
|
||||
debug_dump();
|
||||
debug_dump();
|
||||
#endif
|
||||
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
beginInsertRows(QModelIndex(),0,mPosts.size()-1);
|
||||
else
|
||||
beginInsertRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
||||
endInsertRows();
|
||||
int count = 0;
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
count = mPosts.size();
|
||||
else
|
||||
count = mPosts[0].mChildren.size();
|
||||
|
||||
if(count>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,count-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
postMods();
|
||||
emit forumLoaded();
|
||||
}
|
||||
|
||||
void RsGxsForumModel::update_posts(const RsGxsGroupId& group_id)
|
||||
{
|
||||
if(group_id.isNull())
|
||||
return;
|
||||
if(group_id.isNull())
|
||||
return;
|
||||
|
||||
RsThread::async([this, group_id]()
|
||||
{
|
||||
// 1 - get message data from p3GxsForums
|
||||
// 1 - get message data from p3GxsForums
|
||||
|
||||
std::list<RsGxsGroupId> forumIds;
|
||||
std::list<RsGxsGroupId> forumIds;
|
||||
std::vector<RsMsgMetaData> msg_metas;
|
||||
std::vector<RsGxsForumGroup> groups;
|
||||
|
||||
forumIds.push_back(group_id);
|
||||
forumIds.push_back(group_id);
|
||||
|
||||
if(!rsGxsForums->getForumsInfo(forumIds,groups) || groups.size() != 1)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve forum group info for forum " << group_id << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!rsGxsForums->getForumMsgMetaData(group_id,msg_metas))
|
||||
{
|
||||
@ -821,17 +814,17 @@ void RsGxsForumModel::update_posts(const RsGxsGroupId& group_id)
|
||||
return;
|
||||
}
|
||||
|
||||
// 2 - sort the messages into a proper hierarchy
|
||||
// 2 - sort the messages into a proper hierarchy
|
||||
|
||||
auto post_versions = new std::map<RsGxsMessageId,std::vector<std::pair<time_t, RsGxsMessageId> > >() ;
|
||||
std::vector<ForumModelPostEntry> *vect = new std::vector<ForumModelPostEntry>();
|
||||
RsGxsForumGroup group = groups[0];
|
||||
auto post_versions = new std::map<RsGxsMessageId,std::vector<std::pair<time_t, RsGxsMessageId> > >() ;
|
||||
std::vector<ForumModelPostEntry> *vect = new std::vector<ForumModelPostEntry>();
|
||||
RsGxsForumGroup group = groups[0];
|
||||
|
||||
computeMessagesHierarchy(group,msg_metas,*vect,*post_versions);
|
||||
computeMessagesHierarchy(group,msg_metas,*vect,*post_versions);
|
||||
|
||||
// 3 - update the model in the UI thread.
|
||||
// 3 - update the model in the UI thread.
|
||||
|
||||
RsQThreadUtils::postToObject( [group,vect,post_versions,this]()
|
||||
RsQThreadUtils::postToObject( [group,vect,post_versions,this]()
|
||||
{
|
||||
/* 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
|
||||
@ -839,15 +832,15 @@ void RsGxsForumModel::update_posts(const RsGxsGroupId& group_id)
|
||||
* Qt::QueuedConnection is important!
|
||||
*/
|
||||
|
||||
setPosts(group,*vect,*post_versions) ;
|
||||
setPosts(group,*vect,*post_versions) ;
|
||||
|
||||
delete vect;
|
||||
delete post_versions;
|
||||
delete vect;
|
||||
delete post_versions;
|
||||
|
||||
|
||||
}, this );
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ForumModelIndex RsGxsForumModel::addEntry(std::vector<ForumModelPostEntry>& posts,const ForumModelPostEntry& entry,ForumModelIndex parent)
|
||||
@ -895,26 +888,25 @@ void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup& mForumGroup,c
|
||||
|
||||
void RsGxsForumModel::computeReputationLevel(uint32_t forum_sign_flags,ForumModelPostEntry& fentry)
|
||||
{
|
||||
uint32_t idflags =0;
|
||||
uint32_t idflags =0;
|
||||
RsReputationLevel reputation_level =
|
||||
rsReputations->overallReputationLevel(fentry.mAuthorId, &idflags);
|
||||
bool redacted = false;
|
||||
|
||||
if(reputation_level == RsReputationLevel::LOCALLY_NEGATIVE)
|
||||
fentry.mPostFlags |= ForumModelPostEntry::FLAG_POST_IS_REDACTED;
|
||||
else
|
||||
fentry.mPostFlags &= ~ForumModelPostEntry::FLAG_POST_IS_REDACTED;
|
||||
fentry.mPostFlags |= ForumModelPostEntry::FLAG_POST_IS_REDACTED;
|
||||
else
|
||||
fentry.mPostFlags &= ~ForumModelPostEntry::FLAG_POST_IS_REDACTED;
|
||||
|
||||
// We use a specific item model for forums in order to handle the post pinning.
|
||||
// We use a specific item model for forums in order to handle the post pinning.
|
||||
|
||||
if(reputation_level == RsReputationLevel::UNKNOWN)
|
||||
fentry.mReputationWarningLevel = 3 ;
|
||||
fentry.mReputationWarningLevel = 3 ;
|
||||
else if(reputation_level == RsReputationLevel::LOCALLY_NEGATIVE)
|
||||
fentry.mReputationWarningLevel = 2 ;
|
||||
else if(reputation_level < rsGxsForums->minReputationForForwardingMessages(forum_sign_flags,idflags))
|
||||
fentry.mReputationWarningLevel = 1 ;
|
||||
else
|
||||
fentry.mReputationWarningLevel = 0 ;
|
||||
fentry.mReputationWarningLevel = 2 ;
|
||||
else if(reputation_level < rsGxsForums->minReputationForForwardingMessages(forum_sign_flags,idflags))
|
||||
fentry.mReputationWarningLevel = 1 ;
|
||||
else
|
||||
fentry.mReputationWarningLevel = 0 ;
|
||||
}
|
||||
|
||||
static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
|
||||
|
@ -61,31 +61,32 @@ RsMessageModel::RsMessageModel(QObject *parent)
|
||||
|
||||
void RsMessageModel::preMods()
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
emit layoutAboutToBeChanged();
|
||||
}
|
||||
void RsMessageModel::postMods()
|
||||
{
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mMessages.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
int RsMessageModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
if(!parent.isValid())
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
if(parent.column() > 0)
|
||||
return 0;
|
||||
if(parent.column() > 0)
|
||||
return 0;
|
||||
|
||||
if(mMessages.empty()) // security. Should never happen.
|
||||
return 0;
|
||||
if(mMessages.empty()) // security. Should never happen.
|
||||
return 0;
|
||||
|
||||
if(parent.internalPointer() == NULL)
|
||||
return mMessages.size();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RsMessageModel::columnCount(const QModelIndex &parent) const
|
||||
int RsMessageModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return COLUMN_THREAD_NB_COLUMNS ;
|
||||
}
|
||||
@ -145,8 +146,8 @@ QModelIndex RsMessageModel::index(int row, int column, const QModelIndex & paren
|
||||
|
||||
QModelIndex RsMessageModel::parent(const QModelIndex& index) const
|
||||
{
|
||||
if(!index.isValid())
|
||||
return QModelIndex();
|
||||
if(!index.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
@ -154,12 +155,12 @@ QModelIndex RsMessageModel::parent(const QModelIndex& index) const
|
||||
Qt::ItemFlags RsMessageModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
return Qt::ItemFlags();
|
||||
|
||||
return QAbstractItemModel::flags(index);
|
||||
}
|
||||
|
||||
QVariant RsMessageModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
QVariant RsMessageModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const
|
||||
{
|
||||
if(role == Qt::DisplayRole)
|
||||
switch(section)
|
||||
@ -274,20 +275,20 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
QVariant RsMessageModel::textColorRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
|
||||
QVariant RsMessageModel::textColorRole(const Rs::Msgs::MsgInfoSummary& fmpe,int /*column*/) const
|
||||
{
|
||||
Rs::Msgs::MsgTagType tags;
|
||||
rsMsgs->getMessageTagTypes(tags);
|
||||
|
||||
for(auto it(fmpe.msgtags.begin());it!=fmpe.msgtags.end();++it)
|
||||
for(auto it2(tags.types.begin());it2!=tags.types.end();++it2)
|
||||
if(it2->first == *it)
|
||||
return QColor(it2->second.second);
|
||||
for(auto it(fmpe.msgtags.begin());it!=fmpe.msgtags.end();++it)
|
||||
for(auto it2(tags.types.begin());it2!=tags.types.end();++it2)
|
||||
if(it2->first == *it)
|
||||
return QColor(it2->second.second);
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant RsMessageModel::statusRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
|
||||
QVariant RsMessageModel::statusRole(const Rs::Msgs::MsgInfoSummary& /*fmpe*/,int /*column*/) const
|
||||
{
|
||||
// if(column != COLUMN_THREAD_DATA)
|
||||
// return QVariant();
|
||||
@ -295,12 +296,12 @@ QVariant RsMessageModel::statusRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col
|
||||
return QVariant();//fmpe.mMsgStatus);
|
||||
}
|
||||
|
||||
bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
|
||||
bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int /*column*/) const
|
||||
{
|
||||
QString s ;
|
||||
bool passes_strings = true ;
|
||||
QString s ;
|
||||
bool passes_strings = true ;
|
||||
|
||||
if(!mFilterStrings.empty())
|
||||
if(!mFilterStrings.empty())
|
||||
{
|
||||
switch(mFilterType)
|
||||
{
|
||||
@ -308,9 +309,9 @@ bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
|
||||
break;
|
||||
|
||||
case FILTER_TYPE_FROM: s = sortRole(fmpe,COLUMN_THREAD_AUTHOR).toString();
|
||||
if(s.isNull())
|
||||
passes_strings = false;
|
||||
break;
|
||||
if(s.isNull())
|
||||
passes_strings = false;
|
||||
break;
|
||||
case FILTER_TYPE_DATE: s = displayRole(fmpe,COLUMN_THREAD_DATE).toString();
|
||||
break;
|
||||
case FILTER_TYPE_CONTENT: {
|
||||
@ -330,6 +331,9 @@ bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
|
||||
for(auto it(minfo.files.begin());it!=minfo.files.end();++it)
|
||||
s += QString::fromUtf8((*it).fname.c_str())+" ";
|
||||
}
|
||||
break;
|
||||
case FILTER_TYPE_NONE:
|
||||
RS_ERR("None Type for Filter.");
|
||||
};
|
||||
}
|
||||
|
||||
@ -355,18 +359,15 @@ bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
|
||||
|
||||
QVariant RsMessageModel::filterRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
|
||||
{
|
||||
if(passesFilter(fmpe,column))
|
||||
return QVariant(FilterString);
|
||||
if(passesFilter(fmpe,column))
|
||||
return QVariant(FilterString);
|
||||
|
||||
return QVariant(QString());
|
||||
}
|
||||
|
||||
uint32_t RsMessageModel::updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings)
|
||||
uint32_t RsMessageModel::updateFilterStatus(ForumModelIndex /*i*/,int /*column*/,const QStringList& /*strings*/)
|
||||
{
|
||||
QString s ;
|
||||
uint32_t count = 0;
|
||||
|
||||
return count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -408,7 +409,7 @@ QVariant RsMessageModel::toolTipRole(const Rs::Msgs::MsgInfoSummary& fmpe,int co
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant RsMessageModel::backgroundRole(const Rs::Msgs::MsgInfoSummary &fmpe, int column) const
|
||||
QVariant RsMessageModel::backgroundRole(const Rs::Msgs::MsgInfoSummary &/*fmpe*/, int /*column*/) const
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
@ -426,7 +427,7 @@ QVariant RsMessageModel::sizeHintRole(int col) const
|
||||
}
|
||||
}
|
||||
|
||||
QVariant RsMessageModel::authorRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
|
||||
QVariant RsMessageModel::authorRole(const Rs::Msgs::MsgInfoSummary& /*fmpe*/,int /*column*/) const
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
@ -443,15 +444,16 @@ QVariant RsMessageModel::sortRole(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
|
||||
|
||||
case COLUMN_THREAD_SPAM: return QVariant((fmpe.msgflags & RS_MSG_SPAM)? 1:0);
|
||||
|
||||
case COLUMN_THREAD_AUTHOR:{
|
||||
QString name;
|
||||
case COLUMN_THREAD_AUTHOR:{
|
||||
QString name;
|
||||
|
||||
if(GxsIdTreeItemDelegate::computeName(RsGxsId(fmpe.srcId.toStdString()),name))
|
||||
return name;
|
||||
}
|
||||
default:
|
||||
return displayRole(fmpe,column);
|
||||
}
|
||||
if(GxsIdTreeItemDelegate::computeName(RsGxsId(fmpe.srcId.toStdString()),name))
|
||||
return name;
|
||||
return ""; //Not Found
|
||||
}
|
||||
default:
|
||||
return displayRole(fmpe,column);
|
||||
}
|
||||
}
|
||||
|
||||
QVariant RsMessageModel::displayRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col) const
|
||||
@ -572,9 +574,12 @@ QVariant RsMessageModel::decorationRole(const Rs::Msgs::MsgInfoSummary& fmpe,int
|
||||
|
||||
void RsMessageModel::clear()
|
||||
{
|
||||
preMods();
|
||||
preMods();
|
||||
|
||||
mMessages.clear();
|
||||
beginResetModel();
|
||||
mMessages.clear();
|
||||
mMessagesMap.clear();
|
||||
endResetModel();
|
||||
|
||||
postMods();
|
||||
|
||||
@ -583,29 +588,26 @@ void RsMessageModel::clear()
|
||||
|
||||
void RsMessageModel::setMessages(const std::list<Rs::Msgs::MsgInfoSummary>& msgs)
|
||||
{
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,mMessages.size()-1);
|
||||
endRemoveRows();
|
||||
clear();
|
||||
|
||||
mMessages.clear();
|
||||
mMessagesMap.clear();
|
||||
for(auto it(msgs.begin());it!=msgs.end();++it)
|
||||
{
|
||||
mMessagesMap[(*it).msgId] = mMessages.size();
|
||||
mMessages.push_back(*it);
|
||||
}
|
||||
|
||||
for(auto it(msgs.begin());it!=msgs.end();++it)
|
||||
{
|
||||
mMessagesMap[(*it).msgId] = mMessages.size();
|
||||
mMessages.push_back(*it);
|
||||
}
|
||||
|
||||
// now update prow for all posts
|
||||
// now update prow for all posts
|
||||
|
||||
#ifdef DEBUG_MESSAGE_MODEL
|
||||
debug_dump();
|
||||
debug_dump();
|
||||
#endif
|
||||
|
||||
beginInsertRows(QModelIndex(),0,mMessages.size()-1);
|
||||
endInsertRows();
|
||||
postMods();
|
||||
if (mMessages.size()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,mMessages.size()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
emit messagesLoaded();
|
||||
}
|
||||
@ -672,8 +674,6 @@ void RsMessageModel::updateMessages()
|
||||
emit messagesLoaded();
|
||||
}
|
||||
|
||||
static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
|
||||
|
||||
void RsMessageModel::setMsgReadStatus(const QModelIndex& i,bool read_status)
|
||||
{
|
||||
if(!i.isValid())
|
||||
@ -704,12 +704,12 @@ void RsMessageModel::setMsgJunk(const QModelIndex& i,bool junk)
|
||||
|
||||
QModelIndex RsMessageModel::getIndexOfMessage(const std::string& mid) const
|
||||
{
|
||||
// Brutal search. This is not so nice, so dont call that in a loop! If too costly, we'll use a map.
|
||||
// Brutal search. This is not so nice, so dont call that in a loop! If too costly, we'll use a map.
|
||||
|
||||
auto it = mMessagesMap.find(mid);
|
||||
auto it = mMessagesMap.find(mid);
|
||||
|
||||
if(it == mMessagesMap.end() || it->second >= mMessages.size())
|
||||
return QModelIndex();
|
||||
if(it == mMessagesMap.end() || it->second >= mMessages.size())
|
||||
return QModelIndex();
|
||||
|
||||
quintptr ref ;
|
||||
convertMsgIndexToInternalId(it->second,ref);
|
||||
|
Loading…
Reference in New Issue
Block a user