mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -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,13 +140,12 @@ void RsPostedPostsModel::initEmptyHierarchy()
|
|||||||
|
|
||||||
void RsPostedPostsModel::preMods()
|
void RsPostedPostsModel::preMods()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
emit layoutAboutToBeChanged();
|
||||||
}
|
}
|
||||||
void RsPostedPostsModel::postMods()
|
void RsPostedPostsModel::postMods()
|
||||||
{
|
{
|
||||||
endResetModel();
|
update();
|
||||||
|
emit layoutChanged();
|
||||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL));
|
|
||||||
}
|
}
|
||||||
void RsPostedPostsModel::update()
|
void RsPostedPostsModel::update()
|
||||||
{
|
{
|
||||||
@ -162,20 +161,17 @@ void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
|
|||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
beginResetModel();
|
||||||
endRemoveRows();
|
mFilteredPosts.clear();
|
||||||
|
endResetModel();
|
||||||
|
|
||||||
if(strings.empty())
|
if(strings.empty())
|
||||||
{
|
{
|
||||||
mFilteredPosts.clear();
|
|
||||||
for(int i=0;i<(int)(mPosts.size());++i)
|
for(int i=0;i<(int)(mPosts.size());++i)
|
||||||
mFilteredPosts.push_back(i);
|
mFilteredPosts.push_back(i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mFilteredPosts.clear();
|
|
||||||
//mFilteredPosts.push_back(0);
|
|
||||||
|
|
||||||
for(int i=0;i<static_cast<int>(mPosts.size());++i)
|
for(int i=0;i<static_cast<int>(mPosts.size());++i)
|
||||||
{
|
{
|
||||||
bool passes_strings = true;
|
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;
|
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
|
||||||
|
|
||||||
|
if (rowCount()>0)
|
||||||
|
{
|
||||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
}
|
}
|
||||||
@ -210,7 +209,7 @@ int RsPostedPostsModel::rowCount(const QModelIndex& parent) const
|
|||||||
if(parent.column() > 0)
|
if(parent.column() > 0)
|
||||||
return 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;
|
return 0;
|
||||||
|
|
||||||
if(!parent.isValid())
|
if(!parent.isValid())
|
||||||
@ -473,7 +472,7 @@ private:
|
|||||||
Qt::ItemFlags RsPostedPostsModel::flags(const QModelIndex& index) const
|
Qt::ItemFlags RsPostedPostsModel::flags(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
return Qt::ItemFlags();
|
||||||
|
|
||||||
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||||
}
|
}
|
||||||
@ -519,12 +518,13 @@ void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector<RsPost
|
|||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
beginResetModel();
|
||||||
endRemoveRows();
|
|
||||||
|
|
||||||
mPosts.clear();
|
mPosts.clear();
|
||||||
mPostedGroup = group;
|
mPostedGroup = group;
|
||||||
|
|
||||||
|
endResetModel();
|
||||||
|
|
||||||
createPostsArray(posts);
|
createPostsArray(posts);
|
||||||
|
|
||||||
std::sort(mPosts.begin(),mPosts.end(), PostSorter(mSortingStrategy));
|
std::sort(mPosts.begin(),mPosts.end(), PostSorter(mSortingStrategy));
|
||||||
@ -535,8 +535,11 @@ void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector<RsPost
|
|||||||
mDisplayedNbPosts = std::min((uint32_t)mFilteredPosts.size(),DEFAULT_DISPLAYED_NB_POSTS);
|
mDisplayedNbPosts = std::min((uint32_t)mFilteredPosts.size(),DEFAULT_DISPLAYED_NB_POSTS);
|
||||||
mDisplayedStartIndex = 0;
|
mDisplayedStartIndex = 0;
|
||||||
|
|
||||||
|
if (rowCount()>0)
|
||||||
|
{
|
||||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
postMods();
|
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)
|
void RsPostedPostsModel::createPostsArray(std::vector<RsPostedPost>& posts)
|
||||||
{
|
{
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
|
@ -152,13 +152,12 @@ void RsFriendListModel::setDisplayGroups(bool b)
|
|||||||
}
|
}
|
||||||
void RsFriendListModel::preMods()
|
void RsFriendListModel::preMods()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
emit layoutAboutToBeChanged();
|
||||||
}
|
}
|
||||||
void RsFriendListModel::postMods()
|
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
|
int RsFriendListModel::rowCount(const QModelIndex& parent) const
|
||||||
@ -187,7 +186,7 @@ int RsFriendListModel::rowCount(const QModelIndex& parent) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RsFriendListModel::columnCount(const QModelIndex &parent) const
|
int RsFriendListModel::columnCount(const QModelIndex &/*parent*/) const
|
||||||
{
|
{
|
||||||
return COLUMN_THREAD_NB_COLUMNS ;
|
return COLUMN_THREAD_NB_COLUMNS ;
|
||||||
}
|
}
|
||||||
@ -204,11 +203,12 @@ bool RsFriendListModel::hasChildren(const QModelIndex &parent) const
|
|||||||
return false;
|
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)
|
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();
|
return !mProfiles[mGroups[parent_index.group_index].child_profile_indices[parent_index.profile_index]].child_node_indices.empty();
|
||||||
else
|
else
|
||||||
return !mProfiles[parent_index.profile_index].child_node_indices.empty();
|
return !mProfiles[parent_index.profile_index].child_node_indices.empty();
|
||||||
|
}
|
||||||
if(parent_index.type == ENTRY_TYPE_GROUP)
|
if(parent_index.type == ENTRY_TYPE_GROUP)
|
||||||
return !mGroups[parent_index.group_index].child_profile_indices.empty();
|
return !mGroups[parent_index.group_index].child_profile_indices.empty();
|
||||||
|
|
||||||
@ -236,6 +236,8 @@ RsFriendListModel::EntryIndex RsFriendListModel::EntryIndex::parent() const
|
|||||||
case ENTRY_TYPE_NODE: i.type = ENTRY_TYPE_PROFILE;
|
case ENTRY_TYPE_NODE: i.type = ENTRY_TYPE_PROFILE;
|
||||||
i.node_index = UNDEFINED_NODE_INDEX_VALUE;
|
i.node_index = UNDEFINED_NODE_INDEX_VALUE;
|
||||||
break;
|
break;
|
||||||
|
case ENTRY_TYPE_UNKNOWN:
|
||||||
|
RS_ERR("Unknown Entry type for parent.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
@ -330,12 +332,12 @@ QModelIndex RsFriendListModel::parent(const QModelIndex& index) const
|
|||||||
Qt::ItemFlags RsFriendListModel::flags(const QModelIndex& index) const
|
Qt::ItemFlags RsFriendListModel::flags(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
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)
|
if(role == Qt::DisplayRole)
|
||||||
switch(section)
|
switch(section)
|
||||||
@ -414,12 +416,12 @@ 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);
|
return QVariant();//fmpe.mMsgStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsFriendListModel::passesFilter(const EntryIndex& e,int column) const
|
bool RsFriendListModel::passesFilter(const EntryIndex& e,int /*column*/) const
|
||||||
{
|
{
|
||||||
QString s ;
|
QString s ;
|
||||||
bool passes_strings = true ;
|
bool passes_strings = true ;
|
||||||
@ -435,6 +437,8 @@ bool RsFriendListModel::passesFilter(const EntryIndex& e,int column) const
|
|||||||
if(s.isNull())
|
if(s.isNull())
|
||||||
passes_strings = false;
|
passes_strings = false;
|
||||||
break;
|
break;
|
||||||
|
case FILTER_TYPE_NONE:
|
||||||
|
RS_ERR("None Type for Filter.");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,12 +457,9 @@ QVariant RsFriendListModel::filterRole(const EntryIndex& e,int column) const
|
|||||||
return QVariant(QString());
|
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 ;
|
return 0;
|
||||||
uint32_t count = 0;
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -479,7 +480,7 @@ void RsFriendListModel::setFilter(FilterType filter_type, const QStringList& str
|
|||||||
postMods();
|
postMods();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsFriendListModel::toolTipRole(const EntryIndex& fmpe,int column) const
|
QVariant RsFriendListModel::toolTipRole(const EntryIndex& /*fmpe*/,int /*column*/) const
|
||||||
{
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -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)
|
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);
|
if(col == COLUMN_THREAD_IP) return QVariant(most_recent_ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}// Fall-through
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -826,7 +827,6 @@ const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getNode
|
|||||||
if(e.node_index >= mProfiles[pindex].child_node_indices.size())
|
if(e.node_index >= mProfiles[pindex].child_node_indices.size())
|
||||||
return NULL ;
|
return NULL ;
|
||||||
|
|
||||||
time_t now = time(NULL);
|
|
||||||
HierarchicalNodeInformation& node(mLocations[mProfiles[pindex].child_node_indices[e.node_index]]);
|
HierarchicalNodeInformation& node(mLocations[mProfiles[pindex].child_node_indices[e.node_index]]);
|
||||||
|
|
||||||
return &node;
|
return &node;
|
||||||
@ -895,8 +895,6 @@ void RsFriendListModel::clear()
|
|||||||
emit friendListChanged();
|
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
|
void RsFriendListModel::debug_dump() const
|
||||||
{
|
{
|
||||||
std::cerr << "==== FriendListModel Debug dump ====" << std::endl;
|
std::cerr << "==== FriendListModel Debug dump ====" << std::endl;
|
||||||
@ -1084,14 +1082,14 @@ void RsFriendListModel::updateInternalData()
|
|||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
beginRemoveRows(QModelIndex(),0,mTopLevel.size()-1);
|
beginResetModel();
|
||||||
|
|
||||||
mGroups.clear();
|
mGroups.clear();
|
||||||
mProfiles.clear();
|
mProfiles.clear();
|
||||||
mLocations.clear();
|
mLocations.clear();
|
||||||
mTopLevel.clear();
|
mTopLevel.clear();
|
||||||
|
|
||||||
endRemoveRows();
|
endResetModel();
|
||||||
|
|
||||||
auto TL = mTopLevel ; // This allows to fill TL without touching mTopLevel outside of [begin/end]InsertRows().
|
auto TL = mTopLevel ; // This allows to fill TL without touching mTopLevel outside of [begin/end]InsertRows().
|
||||||
|
|
||||||
@ -1220,11 +1218,13 @@ void RsFriendListModel::updateInternalData()
|
|||||||
|
|
||||||
// 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();
|
||||||
|
|
||||||
|
@ -37,7 +37,9 @@
|
|||||||
|
|
||||||
Q_DECLARE_METATYPE(ChannelPostFileInfo)
|
Q_DECLARE_METATYPE(ChannelPostFileInfo)
|
||||||
|
|
||||||
|
#ifdef DEBUG_CHANNEL_MODEL
|
||||||
static std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere
|
static std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere
|
||||||
|
#endif
|
||||||
|
|
||||||
RsGxsChannelPostFilesModel::RsGxsChannelPostFilesModel(QObject *parent)
|
RsGxsChannelPostFilesModel::RsGxsChannelPostFilesModel(QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
@ -50,30 +52,28 @@ RsGxsChannelPostFilesModel::RsGxsChannelPostFilesModel(QObject *parent)
|
|||||||
|
|
||||||
void RsGxsChannelPostFilesModel::initEmptyHierarchy()
|
void RsGxsChannelPostFilesModel::initEmptyHierarchy()
|
||||||
{
|
{
|
||||||
preMods();
|
beginResetModel();
|
||||||
|
|
||||||
mFiles.clear();
|
mFiles.clear();
|
||||||
mFilteredFiles.clear();
|
mFilteredFiles.clear();
|
||||||
|
|
||||||
postMods();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsChannelPostFilesModel::preMods()
|
void RsGxsChannelPostFilesModel::preMods()
|
||||||
{
|
{
|
||||||
//emit layoutAboutToBeChanged(); //Generate SIGSEGV when click on button move next/prev.
|
emit layoutAboutToBeChanged();
|
||||||
|
|
||||||
beginResetModel();
|
|
||||||
}
|
}
|
||||||
void RsGxsChannelPostFilesModel::postMods()
|
void RsGxsChannelPostFilesModel::postMods()
|
||||||
{
|
{
|
||||||
endResetModel();
|
emit QAbstractItemModel::dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredFiles.size(),COLUMN_FILES_NB_COLUMNS-1,(void*)NULL));
|
||||||
|
emit layoutChanged();
|
||||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredFiles.size(),COLUMN_FILES_NB_COLUMNS-1,(void*)NULL));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsChannelPostFilesModel::update()
|
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
|
int RsGxsChannelPostFilesModel::rowCount(const QModelIndex& parent) const
|
||||||
@ -87,7 +87,7 @@ int RsGxsChannelPostFilesModel::rowCount(const QModelIndex& parent) const
|
|||||||
if(!parent.isValid())
|
if(!parent.isValid())
|
||||||
return mFilteredFiles.size(); // mFilteredPosts always has an item at 0, so size()>=1, and mColumn>=1
|
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;
|
RS_ERR(" rowCount cannot figure out the proper number of rows.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,18 +167,15 @@ QModelIndex RsGxsChannelPostFilesModel::index(int row, int column, const QModelI
|
|||||||
return createIndex(row,column,ref) ;
|
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!
|
return QModelIndex(); // there's no hierarchy here. So nothing to do!
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags RsGxsChannelPostFilesModel::flags(const QModelIndex& index) const
|
Qt::ItemFlags RsGxsChannelPostFilesModel::flags(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
return Qt::ItemFlag();
|
||||||
|
|
||||||
if(index.column() == COLUMN_FILES_FILE)
|
if(index.column() == COLUMN_FILES_FILE)
|
||||||
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||||
@ -221,15 +218,13 @@ quintptr RsGxsChannelPostFilesModel::getParentRow(quintptr ref,int& row) const
|
|||||||
|
|
||||||
int RsGxsChannelPostFilesModel::getChildrenCount(quintptr ref) const
|
int RsGxsChannelPostFilesModel::getChildrenCount(quintptr ref) const
|
||||||
{
|
{
|
||||||
uint32_t entry = 0 ;
|
|
||||||
|
|
||||||
if(ref == quintptr(0))
|
if(ref == quintptr(0))
|
||||||
return rowCount()-1;
|
return rowCount()-1;
|
||||||
|
|
||||||
return 0;
|
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)
|
if (role != Qt::DisplayRole)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -300,20 +295,15 @@ void RsGxsChannelPostFilesModel::setFilter(const QStringList& strings, uint32_t&
|
|||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
initEmptyHierarchy();
|
||||||
endRemoveRows();
|
|
||||||
|
|
||||||
if(strings.empty())
|
if(strings.empty())
|
||||||
{
|
{
|
||||||
mFilteredFiles.clear();
|
|
||||||
for(uint32_t i=0;i<mFiles.size();++i)
|
for(uint32_t i=0;i<mFiles.size();++i)
|
||||||
mFilteredFiles.push_back(i);
|
mFilteredFiles.push_back(i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mFilteredFiles.clear();
|
|
||||||
//mFilteredPosts.push_back(0);
|
|
||||||
|
|
||||||
for(uint32_t i=0;i<mFiles.size();++i)
|
for(uint32_t i=0;i<mFiles.size();++i)
|
||||||
{
|
{
|
||||||
bool passes_strings = true;
|
bool passes_strings = true;
|
||||||
@ -329,8 +319,11 @@ void RsGxsChannelPostFilesModel::setFilter(const QStringList& strings, uint32_t&
|
|||||||
|
|
||||||
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
|
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
|
||||||
|
|
||||||
|
if (rowCount()>0)
|
||||||
|
{
|
||||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
}
|
}
|
||||||
@ -372,7 +365,7 @@ void RsGxsChannelPostFilesModel::sort(int column, Qt::SortOrder order)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsGxsChannelPostFilesModel::sizeHintRole(int col) const
|
QVariant RsGxsChannelPostFilesModel::sizeHintRole(int /*col*/) const
|
||||||
{
|
{
|
||||||
float factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
|
float factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
|
||||||
|
|
||||||
@ -435,11 +428,9 @@ QVariant RsGxsChannelPostFilesModel::userRole(const ChannelPostFileInfo& fmpe,in
|
|||||||
|
|
||||||
void RsGxsChannelPostFilesModel::clear()
|
void RsGxsChannelPostFilesModel::clear()
|
||||||
{
|
{
|
||||||
preMods();
|
|
||||||
|
|
||||||
initEmptyHierarchy();
|
initEmptyHierarchy();
|
||||||
|
|
||||||
postMods();
|
|
||||||
emit channelLoaded();
|
emit channelLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,9 +438,6 @@ void RsGxsChannelPostFilesModel::setFiles(const std::list<ChannelPostFileInfo> &
|
|||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
beginRemoveRows(QModelIndex(),0,mFilteredFiles.size()-1);
|
|
||||||
endRemoveRows();
|
|
||||||
|
|
||||||
initEmptyHierarchy();
|
initEmptyHierarchy();
|
||||||
|
|
||||||
for(auto& file:files)
|
for(auto& file:files)
|
||||||
@ -462,10 +450,11 @@ void RsGxsChannelPostFilesModel::setFiles(const std::list<ChannelPostFileInfo> &
|
|||||||
// debug_dump();
|
// debug_dump();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (mFilteredFiles.size()>0)
|
||||||
|
{
|
||||||
beginInsertRows(QModelIndex(),0,mFilteredFiles.size()-1);
|
beginInsertRows(QModelIndex(),0,mFilteredFiles.size()-1);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
}
|
||||||
postMods();
|
|
||||||
|
|
||||||
emit channelLoaded();
|
emit channelLoaded();
|
||||||
|
|
||||||
@ -473,4 +462,6 @@ void RsGxsChannelPostFilesModel::setFiles(const std::list<ChannelPostFileInfo> &
|
|||||||
mTimer->start(5000);
|
mTimer->start(5000);
|
||||||
else
|
else
|
||||||
mTimer->stop();
|
mTimer->stop();
|
||||||
|
|
||||||
|
postMods();
|
||||||
}
|
}
|
||||||
|
@ -203,23 +203,22 @@ void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEve
|
|||||||
|
|
||||||
void RsGxsChannelPostsModel::initEmptyHierarchy()
|
void RsGxsChannelPostsModel::initEmptyHierarchy()
|
||||||
{
|
{
|
||||||
preMods();
|
beginResetModel();
|
||||||
|
|
||||||
mPosts.clear();
|
mPosts.clear();
|
||||||
mFilteredPosts.clear();
|
mFilteredPosts.clear();
|
||||||
|
|
||||||
postMods();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsChannelPostsModel::preMods()
|
void RsGxsChannelPostsModel::preMods()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
emit layoutAboutToBeChanged();
|
||||||
}
|
}
|
||||||
void RsGxsChannelPostsModel::postMods()
|
void RsGxsChannelPostsModel::postMods()
|
||||||
{
|
{
|
||||||
endResetModel();
|
|
||||||
|
|
||||||
triggerViewUpdate();
|
triggerViewUpdate();
|
||||||
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
void RsGxsChannelPostsModel::triggerViewUpdate()
|
void RsGxsChannelPostsModel::triggerViewUpdate()
|
||||||
{
|
{
|
||||||
@ -246,11 +245,11 @@ void RsGxsChannelPostsModel::setFilter(const QStringList& strings,bool only_unre
|
|||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
beginResetModel();
|
||||||
endRemoveRows();
|
|
||||||
|
|
||||||
mFilteredPosts.clear();
|
mFilteredPosts.clear();
|
||||||
//mFilteredPosts.push_back(0);
|
//mFilteredPosts.push_back(0);
|
||||||
|
endResetModel();
|
||||||
|
|
||||||
for(size_t i=0;i<mPosts.size();++i)
|
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();
|
count = mFilteredPosts.size();
|
||||||
|
|
||||||
|
if (rowCount()>0)
|
||||||
|
{
|
||||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
}
|
}
|
||||||
@ -374,18 +376,15 @@ QModelIndex RsGxsChannelPostsModel::index(int row, int column, const QModelIndex
|
|||||||
return createIndex(row,column,ref) ;
|
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!
|
return QModelIndex(); // there's no hierarchy here. So nothing to do!
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags RsGxsChannelPostsModel::flags(const QModelIndex& index) const
|
Qt::ItemFlags RsGxsChannelPostsModel::flags(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
return Qt::ItemFlags();
|
||||||
|
|
||||||
return QAbstractItemModel::flags(index);
|
return QAbstractItemModel::flags(index);
|
||||||
}
|
}
|
||||||
@ -402,13 +401,16 @@ bool RsGxsChannelPostsModel::setNumColumns(int n)
|
|||||||
|
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
beginResetModel();
|
||||||
endRemoveRows();
|
endResetModel();
|
||||||
|
|
||||||
mColumns = n;
|
mColumns = n;
|
||||||
|
|
||||||
|
if (rowCount()>0)
|
||||||
|
{
|
||||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
|
|
||||||
@ -551,7 +553,6 @@ void RsGxsChannelPostsModel::clear()
|
|||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
mPosts.clear();
|
|
||||||
initEmptyHierarchy();
|
initEmptyHierarchy();
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
@ -567,17 +568,13 @@ void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vecto
|
|||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
initEmptyHierarchy();
|
||||||
endRemoveRows();
|
|
||||||
|
|
||||||
mPosts.clear();
|
|
||||||
mChannelGroup = group;
|
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)
|
for(uint32_t i=0;i<mPosts.size();++i)
|
||||||
mFilteredPosts.push_back(i);
|
mFilteredPosts.push_back(i);
|
||||||
|
|
||||||
@ -585,8 +582,11 @@ void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vecto
|
|||||||
// debug_dump();
|
// debug_dump();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (rowCount()>0)
|
||||||
|
{
|
||||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
|
|
||||||
|
@ -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)) + ")" ;
|
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);
|
painter->drawText(QPoint(p.x()+0.5*font_height,y),info_text);
|
||||||
y += font_height;
|
//y += font_height;
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
@ -400,21 +400,21 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
|
|||||||
ui->channelPostFiles_TV->setItemDelegate(new ChannelPostFilesDelegate(this));
|
ui->channelPostFiles_TV->setItemDelegate(new ChannelPostFilesDelegate(this));
|
||||||
ui->channelPostFiles_TV->setPlaceholderText(tr("No files in this post, or no post selected"));
|
ui->channelPostFiles_TV->setPlaceholderText(tr("No files in this post, or no post selected"));
|
||||||
ui->channelPostFiles_TV->setSortingEnabled(true);
|
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->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->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->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->channelPostFiles_TV,SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showChannelFilesContextMenu(QPoint)));
|
||||||
connect(ui->channelFiles_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->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(showPostDetails()));
|
||||||
connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&)));
|
connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&)));
|
||||||
|
|
||||||
@ -666,7 +666,7 @@ void GxsChannelPostsWidgetWithModel::download()
|
|||||||
std::string destination;
|
std::string destination;
|
||||||
rsGxsChannels->getChannelDownloadDirectory(mGroup.mMeta.mGroupId,destination);
|
rsGxsChannels->getChannelDownloadDirectory(mGroup.mMeta.mGroupId,destination);
|
||||||
|
|
||||||
for(auto file:post.mFiles)
|
for(auto& file:post.mFiles)
|
||||||
{
|
{
|
||||||
std::list<RsPeerId> sources;
|
std::list<RsPeerId> sources;
|
||||||
std::string destination;
|
std::string destination;
|
||||||
@ -941,7 +941,8 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
|
|||||||
mChannelFilesModel->setFiles(files);
|
mChannelFilesModel->setFiles(files);
|
||||||
|
|
||||||
ui->channelFiles_TV->setAutoSelect(true);
|
ui->channelFiles_TV->setAutoSelect(true);
|
||||||
ui->channelFiles_TV->sortByColumn(3, Qt::AscendingOrder);
|
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));
|
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]" );
|
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 ;
|
break ;
|
||||||
case GXS_CIRCLE_TYPE_EXTERNAL:
|
case RsGxsCircleType::EXTERNAL:
|
||||||
{
|
{
|
||||||
RsGxsCircleDetails det ;
|
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()) ;
|
distrib_string = tr("Restricted to members of circle ")+QString::fromStdString(group.mMeta.mCircleId.toStdString()) ;
|
||||||
}
|
}
|
||||||
break ;
|
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 ;
|
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 ;
|
break ;
|
||||||
default:
|
default:
|
||||||
std::cerr << "(EE) badly initialised group distribution ID = " << group.mMeta.mCircleType << std::endl;
|
std::cerr << "(EE) badly initialised group distribution ID = " << group.mMeta.mCircleType << std::endl;
|
||||||
@ -1246,7 +1247,7 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
|
|||||||
showPostDetails();
|
showPostDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidgetWithModel::showChannelFilesContextMenu(QPoint p)
|
void GxsChannelPostsWidgetWithModel::showChannelFilesContextMenu(QPoint /*p*/)
|
||||||
{
|
{
|
||||||
QMenu contextMnu(this) ;
|
QMenu contextMnu(this) ;
|
||||||
|
|
||||||
@ -1317,7 +1318,7 @@ void GxsChannelPostsWidgetWithModel::switchOnlyUnread(bool)
|
|||||||
}
|
}
|
||||||
void GxsChannelPostsWidgetWithModel::filterChanged(QString s)
|
void GxsChannelPostsWidgetWithModel::filterChanged(QString s)
|
||||||
{
|
{
|
||||||
QStringList ql = s.split(' ',QString::SkipEmptyParts);
|
QStringList ql = s.split(' ',Qt::SkipEmptyParts);
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
mChannelPostsModel->setFilter(ql,ui->showUnread_TB->isChecked(),count);
|
mChannelPostsModel->setFilter(ql,ui->showUnread_TB->isChecked(),count);
|
||||||
mChannelFilesModel->setFilter(ql,count);
|
mChannelFilesModel->setFilter(ql,count);
|
||||||
@ -1420,7 +1421,7 @@ void GxsChannelPostsWidgetWithModel::toggleAutoDownload()
|
|||||||
class GxsChannelPostsReadData
|
class GxsChannelPostsReadData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GxsChannelPostsReadData(bool read)
|
explicit GxsChannelPostsReadData(bool read)
|
||||||
{
|
{
|
||||||
mRead = read;
|
mRead = read;
|
||||||
mLastToken = 0;
|
mLastToken = 0;
|
||||||
|
@ -50,18 +50,16 @@ RsGxsForumModel::RsGxsForumModel(QObject *parent)
|
|||||||
|
|
||||||
void RsGxsForumModel::preMods()
|
void RsGxsForumModel::preMods()
|
||||||
{
|
{
|
||||||
//emit layoutAboutToBeChanged(); //Generate SIGSEGV when click on button move next/prev.
|
emit layoutAboutToBeChanged();
|
||||||
|
|
||||||
beginResetModel();
|
|
||||||
}
|
}
|
||||||
void RsGxsForumModel::postMods()
|
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));
|
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 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)
|
void RsGxsForumModel::setTreeMode(TreeMode mode)
|
||||||
@ -71,19 +69,11 @@ void RsGxsForumModel::setTreeMode(TreeMode mode)
|
|||||||
|
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
if(mode == TREE_MODE_TREE) // means we were in FLAT mode, so the last rows are removed.
|
beginResetModel();
|
||||||
{
|
|
||||||
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.
|
endResetModel();
|
||||||
{
|
|
||||||
beginInsertRows(QModelIndex(),mPosts[0].mChildren.size(),mPosts.size()-1);
|
|
||||||
endInsertRows();
|
|
||||||
}
|
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
}
|
}
|
||||||
@ -241,7 +231,7 @@ QModelIndex RsGxsForumModel::parent(const QModelIndex& index) const
|
|||||||
Qt::ItemFlags RsGxsForumModel::flags(const QModelIndex& index) const
|
Qt::ItemFlags RsGxsForumModel::flags(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
return Qt::ItemFlags();
|
||||||
|
|
||||||
return QAbstractItemModel::flags(index);
|
return QAbstractItemModel::flags(index);
|
||||||
}
|
}
|
||||||
@ -757,12 +747,8 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<F
|
|||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
if(mTreeMode == TREE_MODE_FLAT)
|
beginResetModel();
|
||||||
beginRemoveRows(QModelIndex(),0,mPosts.size()-1);
|
endResetModel();
|
||||||
else
|
|
||||||
beginRemoveRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
|
||||||
|
|
||||||
endRemoveRows();
|
|
||||||
|
|
||||||
mForumGroup = group;
|
mForumGroup = group;
|
||||||
mPosts = posts;
|
mPosts = posts;
|
||||||
@ -785,11 +771,18 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<F
|
|||||||
debug_dump();
|
debug_dump();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
if(mTreeMode == TREE_MODE_FLAT)
|
if(mTreeMode == TREE_MODE_FLAT)
|
||||||
beginInsertRows(QModelIndex(),0,mPosts.size()-1);
|
count = mPosts.size();
|
||||||
else
|
else
|
||||||
beginInsertRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
count = mPosts[0].mChildren.size();
|
||||||
|
|
||||||
|
if(count>0)
|
||||||
|
{
|
||||||
|
beginInsertRows(QModelIndex(),0,count-1);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
emit forumLoaded();
|
emit forumLoaded();
|
||||||
}
|
}
|
||||||
@ -898,7 +891,6 @@ void RsGxsForumModel::computeReputationLevel(uint32_t forum_sign_flags,ForumMode
|
|||||||
uint32_t idflags =0;
|
uint32_t idflags =0;
|
||||||
RsReputationLevel reputation_level =
|
RsReputationLevel reputation_level =
|
||||||
rsReputations->overallReputationLevel(fentry.mAuthorId, &idflags);
|
rsReputations->overallReputationLevel(fentry.mAuthorId, &idflags);
|
||||||
bool redacted = false;
|
|
||||||
|
|
||||||
if(reputation_level == RsReputationLevel::LOCALLY_NEGATIVE)
|
if(reputation_level == RsReputationLevel::LOCALLY_NEGATIVE)
|
||||||
fentry.mPostFlags |= ForumModelPostEntry::FLAG_POST_IS_REDACTED;
|
fentry.mPostFlags |= ForumModelPostEntry::FLAG_POST_IS_REDACTED;
|
||||||
|
@ -66,6 +66,7 @@ void RsMessageModel::preMods()
|
|||||||
void RsMessageModel::postMods()
|
void RsMessageModel::postMods()
|
||||||
{
|
{
|
||||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mMessages.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
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
|
int RsMessageModel::rowCount(const QModelIndex& parent) const
|
||||||
@ -85,7 +86,7 @@ int RsMessageModel::rowCount(const QModelIndex& parent) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RsMessageModel::columnCount(const QModelIndex &parent) const
|
int RsMessageModel::columnCount(const QModelIndex &/*parent*/) const
|
||||||
{
|
{
|
||||||
return COLUMN_THREAD_NB_COLUMNS ;
|
return COLUMN_THREAD_NB_COLUMNS ;
|
||||||
}
|
}
|
||||||
@ -154,12 +155,12 @@ QModelIndex RsMessageModel::parent(const QModelIndex& index) const
|
|||||||
Qt::ItemFlags RsMessageModel::flags(const QModelIndex& index) const
|
Qt::ItemFlags RsMessageModel::flags(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
return Qt::ItemFlags();
|
||||||
|
|
||||||
return QAbstractItemModel::flags(index);
|
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)
|
if(role == Qt::DisplayRole)
|
||||||
switch(section)
|
switch(section)
|
||||||
@ -274,7 +275,7 @@ 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;
|
Rs::Msgs::MsgTagType tags;
|
||||||
rsMsgs->getMessageTagTypes(tags);
|
rsMsgs->getMessageTagTypes(tags);
|
||||||
@ -287,7 +288,7 @@ QVariant RsMessageModel::textColorRole(const Rs::Msgs::MsgInfoSummary& fmpe,int
|
|||||||
return QVariant();
|
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)
|
// if(column != COLUMN_THREAD_DATA)
|
||||||
// return QVariant();
|
// return QVariant();
|
||||||
@ -295,7 +296,7 @@ QVariant RsMessageModel::statusRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col
|
|||||||
return QVariant();//fmpe.mMsgStatus);
|
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 ;
|
QString s ;
|
||||||
bool passes_strings = true ;
|
bool passes_strings = true ;
|
||||||
@ -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)
|
for(auto it(minfo.files.begin());it!=minfo.files.end();++it)
|
||||||
s += QString::fromUtf8((*it).fname.c_str())+" ";
|
s += QString::fromUtf8((*it).fname.c_str())+" ";
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case FILTER_TYPE_NONE:
|
||||||
|
RS_ERR("None Type for Filter.");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,12 +365,9 @@ QVariant RsMessageModel::filterRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col
|
|||||||
return QVariant(QString());
|
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 ;
|
return 0;
|
||||||
uint32_t count = 0;
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -408,7 +409,7 @@ QVariant RsMessageModel::toolTipRole(const Rs::Msgs::MsgInfoSummary& fmpe,int co
|
|||||||
return QVariant();
|
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();
|
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();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -448,6 +449,7 @@ QVariant RsMessageModel::sortRole(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
|
|||||||
|
|
||||||
if(GxsIdTreeItemDelegate::computeName(RsGxsId(fmpe.srcId.toStdString()),name))
|
if(GxsIdTreeItemDelegate::computeName(RsGxsId(fmpe.srcId.toStdString()),name))
|
||||||
return name;
|
return name;
|
||||||
|
return ""; //Not Found
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return displayRole(fmpe,column);
|
return displayRole(fmpe,column);
|
||||||
@ -574,7 +576,10 @@ void RsMessageModel::clear()
|
|||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
|
beginResetModel();
|
||||||
mMessages.clear();
|
mMessages.clear();
|
||||||
|
mMessagesMap.clear();
|
||||||
|
endResetModel();
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
|
|
||||||
@ -583,13 +588,8 @@ void RsMessageModel::clear()
|
|||||||
|
|
||||||
void RsMessageModel::setMessages(const std::list<Rs::Msgs::MsgInfoSummary>& msgs)
|
void RsMessageModel::setMessages(const std::list<Rs::Msgs::MsgInfoSummary>& msgs)
|
||||||
{
|
{
|
||||||
preMods();
|
|
||||||
|
|
||||||
beginRemoveRows(QModelIndex(),0,mMessages.size()-1);
|
clear();
|
||||||
endRemoveRows();
|
|
||||||
|
|
||||||
mMessages.clear();
|
|
||||||
mMessagesMap.clear();
|
|
||||||
|
|
||||||
for(auto it(msgs.begin());it!=msgs.end();++it)
|
for(auto it(msgs.begin());it!=msgs.end();++it)
|
||||||
{
|
{
|
||||||
@ -603,9 +603,11 @@ void RsMessageModel::setMessages(const std::list<Rs::Msgs::MsgInfoSummary>& msgs
|
|||||||
debug_dump();
|
debug_dump();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (mMessages.size()>0)
|
||||||
|
{
|
||||||
beginInsertRows(QModelIndex(),0,mMessages.size()-1);
|
beginInsertRows(QModelIndex(),0,mMessages.size()-1);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
postMods();
|
}
|
||||||
|
|
||||||
emit messagesLoaded();
|
emit messagesLoaded();
|
||||||
}
|
}
|
||||||
@ -672,8 +674,6 @@ void RsMessageModel::updateMessages()
|
|||||||
emit messagesLoaded();
|
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)
|
void RsMessageModel::setMsgReadStatus(const QModelIndex& i,bool read_status)
|
||||||
{
|
{
|
||||||
if(!i.isValid())
|
if(!i.isValid())
|
||||||
|
Loading…
Reference in New Issue
Block a user