mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
@ -162,20 +161,17 @@ 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;
|
||||
|
||||
if (rowCount()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
postMods();
|
||||
}
|
||||
@ -210,7 +209,7 @@ 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())
|
||||
@ -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;
|
||||
}
|
||||
@ -519,12 +518,13 @@ void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector<RsPost
|
||||
{
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
||||
endRemoveRows();
|
||||
beginResetModel();
|
||||
|
||||
mPosts.clear();
|
||||
mPostedGroup = group;
|
||||
|
||||
endResetModel();
|
||||
|
||||
createPostsArray(posts);
|
||||
|
||||
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);
|
||||
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,13 +152,12 @@ 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 layoutChanged();
|
||||
}
|
||||
|
||||
int RsFriendListModel::rowCount(const QModelIndex& parent) const
|
||||
@ -187,7 +186,7 @@ int RsFriendListModel::rowCount(const QModelIndex& parent) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RsFriendListModel::columnCount(const QModelIndex &parent) const
|
||||
int RsFriendListModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return COLUMN_THREAD_NB_COLUMNS ;
|
||||
}
|
||||
@ -204,11 +203,12 @@ bool RsFriendListModel::hasChildren(const QModelIndex &parent) const
|
||||
return false;
|
||||
|
||||
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();
|
||||
|
||||
@ -236,6 +236,8 @@ RsFriendListModel::EntryIndex RsFriendListModel::EntryIndex::parent() const
|
||||
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;
|
||||
@ -330,12 +332,12 @@ QModelIndex RsFriendListModel::parent(const QModelIndex& index) const
|
||||
Qt::ItemFlags RsFriendListModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
return Qt::ItemFlags();
|
||||
|
||||
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,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);
|
||||
}
|
||||
|
||||
bool RsFriendListModel::passesFilter(const EntryIndex& e,int column) const
|
||||
bool RsFriendListModel::passesFilter(const EntryIndex& e,int /*column*/) const
|
||||
{
|
||||
QString s ;
|
||||
bool passes_strings = true ;
|
||||
@ -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.");
|
||||
};
|
||||
}
|
||||
|
||||
@ -453,12 +457,9 @@ QVariant RsFriendListModel::filterRole(const EntryIndex& e,int column) const
|
||||
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();
|
||||
}
|
||||
@ -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().
|
||||
|
||||
@ -1220,11 +1218,13 @@ void RsFriendListModel::updateInternalData()
|
||||
|
||||
// finally, tell the model client that layout has changed.
|
||||
|
||||
beginInsertRows(QModelIndex(),0,TL.size()-1);
|
||||
|
||||
mTopLevel = TL;
|
||||
|
||||
if (TL.size()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,TL.size()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
postMods();
|
||||
|
||||
|
@ -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,30 +52,28 @@ RsGxsChannelPostFilesModel::RsGxsChannelPostFilesModel(QObject *parent)
|
||||
|
||||
void RsGxsChannelPostFilesModel::initEmptyHierarchy()
|
||||
{
|
||||
preMods();
|
||||
beginResetModel();
|
||||
|
||||
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
|
||||
@ -87,7 +87,7 @@ int RsGxsChannelPostFilesModel::rowCount(const QModelIndex& parent) const
|
||||
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;
|
||||
RS_ERR(" rowCount cannot figure out the proper number of rows.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -167,18 +167,15 @@ 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;
|
||||
return Qt::ItemFlag();
|
||||
|
||||
if(index.column() == COLUMN_FILES_FILE)
|
||||
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||
@ -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;
|
||||
|
||||
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();
|
||||
@ -300,20 +295,15 @@ void RsGxsChannelPostFilesModel::setFilter(const QStringList& strings, uint32_t&
|
||||
{
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
mFilteredFiles.clear();
|
||||
//mFilteredPosts.push_back(0);
|
||||
|
||||
for(uint32_t i=0;i<mFiles.size();++i)
|
||||
{
|
||||
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;
|
||||
|
||||
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,11 +428,9 @@ QVariant RsGxsChannelPostFilesModel::userRole(const ChannelPostFileInfo& fmpe,in
|
||||
|
||||
void RsGxsChannelPostFilesModel::clear()
|
||||
{
|
||||
preMods();
|
||||
|
||||
initEmptyHierarchy();
|
||||
|
||||
postMods();
|
||||
emit channelLoaded();
|
||||
}
|
||||
|
||||
@ -447,9 +438,6 @@ void RsGxsChannelPostFilesModel::setFiles(const std::list<ChannelPostFileInfo> &
|
||||
{
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,mFilteredFiles.size()-1);
|
||||
endRemoveRows();
|
||||
|
||||
initEmptyHierarchy();
|
||||
|
||||
for(auto& file:files)
|
||||
@ -462,10 +450,11 @@ void RsGxsChannelPostFilesModel::setFiles(const std::list<ChannelPostFileInfo> &
|
||||
// debug_dump();
|
||||
#endif
|
||||
|
||||
if (mFilteredFiles.size()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,mFilteredFiles.size()-1);
|
||||
endInsertRows();
|
||||
|
||||
postMods();
|
||||
}
|
||||
|
||||
emit channelLoaded();
|
||||
|
||||
@ -473,4 +462,6 @@ void RsGxsChannelPostFilesModel::setFiles(const std::list<ChannelPostFileInfo> &
|
||||
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();
|
||||
|
||||
postMods();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void RsGxsChannelPostsModel::preMods()
|
||||
{
|
||||
beginResetModel();
|
||||
emit layoutAboutToBeChanged();
|
||||
}
|
||||
void RsGxsChannelPostsModel::postMods()
|
||||
{
|
||||
endResetModel();
|
||||
|
||||
triggerViewUpdate();
|
||||
emit layoutChanged();
|
||||
}
|
||||
void RsGxsChannelPostsModel::triggerViewUpdate()
|
||||
{
|
||||
@ -246,11 +245,11 @@ void RsGxsChannelPostsModel::setFilter(const QStringList& strings,bool only_unre
|
||||
{
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
||||
endRemoveRows();
|
||||
beginResetModel();
|
||||
|
||||
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();
|
||||
|
||||
if (rowCount()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
postMods();
|
||||
}
|
||||
@ -374,18 +376,15 @@ 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);
|
||||
}
|
||||
@ -402,13 +401,16 @@ bool RsGxsChannelPostsModel::setNumColumns(int n)
|
||||
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
||||
endRemoveRows();
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
|
||||
mColumns = n;
|
||||
|
||||
if (rowCount()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
postMods();
|
||||
|
||||
@ -551,7 +553,6 @@ void RsGxsChannelPostsModel::clear()
|
||||
{
|
||||
preMods();
|
||||
|
||||
mPosts.clear();
|
||||
initEmptyHierarchy();
|
||||
|
||||
postMods();
|
||||
@ -567,17 +568,13 @@ void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vecto
|
||||
{
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
||||
endRemoveRows();
|
||||
|
||||
mPosts.clear();
|
||||
initEmptyHierarchy();
|
||||
mChannelGroup = group;
|
||||
|
||||
createPostsArray(posts);
|
||||
|
||||
std::sort(mPosts.begin(),mPosts.end());
|
||||
|
||||
mFilteredPosts.clear();
|
||||
for(uint32_t i=0;i<mPosts.size();++i)
|
||||
mFilteredPosts.push_back(i);
|
||||
|
||||
@ -585,8 +582,11 @@ void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vecto
|
||||
// debug_dump();
|
||||
#endif
|
||||
|
||||
if (rowCount()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
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)) + ")" ;
|
||||
|
||||
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;
|
||||
@ -941,7 +941,8 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
|
||||
mChannelFilesModel->setFiles(files);
|
||||
|
||||
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));
|
||||
|
||||
@ -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,18 +50,16 @@ 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)
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mPosts.size(),COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
else
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mPosts[0].mChildren.size(),COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
void RsGxsForumModel::setTreeMode(TreeMode mode)
|
||||
@ -71,19 +69,11 @@ void RsGxsForumModel::setTreeMode(TreeMode mode)
|
||||
|
||||
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();
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
@ -757,12 +747,8 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<F
|
||||
{
|
||||
preMods();
|
||||
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
beginRemoveRows(QModelIndex(),0,mPosts.size()-1);
|
||||
else
|
||||
beginRemoveRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
||||
|
||||
endRemoveRows();
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
|
||||
mForumGroup = group;
|
||||
mPosts = posts;
|
||||
@ -785,11 +771,18 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<F
|
||||
debug_dump();
|
||||
#endif
|
||||
|
||||
int count = 0;
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
beginInsertRows(QModelIndex(),0,mPosts.size()-1);
|
||||
count = mPosts.size();
|
||||
else
|
||||
beginInsertRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
||||
count = mPosts[0].mChildren.size();
|
||||
|
||||
if(count>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,count-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
postMods();
|
||||
emit forumLoaded();
|
||||
}
|
||||
@ -898,7 +891,6 @@ void RsGxsForumModel::computeReputationLevel(uint32_t forum_sign_flags,ForumMode
|
||||
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;
|
||||
|
@ -66,6 +66,7 @@ void RsMessageModel::preMods()
|
||||
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
|
||||
@ -85,7 +86,7 @@ int RsMessageModel::rowCount(const QModelIndex& parent) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RsMessageModel::columnCount(const QModelIndex &parent) const
|
||||
int RsMessageModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return COLUMN_THREAD_NB_COLUMNS ;
|
||||
}
|
||||
@ -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,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;
|
||||
rsMsgs->getMessageTagTypes(tags);
|
||||
@ -287,7 +288,7 @@ QVariant RsMessageModel::textColorRole(const Rs::Msgs::MsgInfoSummary& fmpe,int
|
||||
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,7 +296,7 @@ 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 ;
|
||||
@ -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.");
|
||||
};
|
||||
}
|
||||
|
||||
@ -361,12 +365,9 @@ QVariant RsMessageModel::filterRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col
|
||||
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();
|
||||
}
|
||||
@ -448,6 +449,7 @@ QVariant RsMessageModel::sortRole(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
|
||||
|
||||
if(GxsIdTreeItemDelegate::computeName(RsGxsId(fmpe.srcId.toStdString()),name))
|
||||
return name;
|
||||
return ""; //Not Found
|
||||
}
|
||||
default:
|
||||
return displayRole(fmpe,column);
|
||||
@ -574,7 +576,10 @@ void RsMessageModel::clear()
|
||||
{
|
||||
preMods();
|
||||
|
||||
beginResetModel();
|
||||
mMessages.clear();
|
||||
mMessagesMap.clear();
|
||||
endResetModel();
|
||||
|
||||
postMods();
|
||||
|
||||
@ -583,13 +588,8 @@ void RsMessageModel::clear()
|
||||
|
||||
void RsMessageModel::setMessages(const std::list<Rs::Msgs::MsgInfoSummary>& msgs)
|
||||
{
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,mMessages.size()-1);
|
||||
endRemoveRows();
|
||||
|
||||
mMessages.clear();
|
||||
mMessagesMap.clear();
|
||||
clear();
|
||||
|
||||
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();
|
||||
#endif
|
||||
|
||||
if (mMessages.size()>0)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),0,mMessages.size()-1);
|
||||
endInsertRows();
|
||||
postMods();
|
||||
}
|
||||
|
||||
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())
|
||||
|
Loading…
Reference in New Issue
Block a user