diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp index 06ba27a0f..b1b7eddbd 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp @@ -345,6 +345,7 @@ QVariant RsGxsChannelPostFilesModel::data(const QModelIndex &index, int role) co { case Qt::DisplayRole: return displayRole (fmpe,index.column()) ; case Qt::UserRole: return userRole (fmpe,index.column()) ; + case SortRole: return sortRole (fmpe,index.column()) ; #ifdef TODO case Qt::DecorationRole: return decorationRole(fmpe,index.column()) ; case Qt::ToolTipRole: return toolTipRole (fmpe,index.column()) ; @@ -355,7 +356,6 @@ QVariant RsGxsChannelPostFilesModel::data(const QModelIndex &index, int role) co case ThreadPinnedRole: return pinnedRole (fmpe,index.column()) ; case MissingRole: return missingRole (fmpe,index.column()) ; case StatusRole: return statusRole (fmpe,index.column()) ; - case SortRole: return sortRole (fmpe,index.column()) ; #endif default: return QVariant(); @@ -542,39 +542,26 @@ QVariant RsGxsChannelPostFilesModel::sizeHintRole(int col) const #endif } -#ifdef TODO -QVariant RsGxsForumModel::authorRole(const ForumModelPostEntry& fmpe,int column) const -{ - if(column == COLUMN_THREAD_DATA) - return QVariant(QString::fromStdString(fmpe.mAuthorId.toStdString())); - - return QVariant(); -} - -QVariant RsGxsForumModel::sortRole(const ForumModelPostEntry& fmpe,int column) const +QVariant RsGxsChannelPostFilesModel::sortRole(const RsGxsFile& fmpe,int column) const { switch(column) { - case COLUMN_THREAD_DATE: if(mSortMode == SORT_MODE_PUBLISH_TS) - return QVariant(QString::number(fmpe.mPublishTs)); // we should probably have leading zeroes here - else - return QVariant(QString::number(fmpe.mMostRecentTsInThread)); // we should probably have leading zeroes here - - case COLUMN_THREAD_READ: return QVariant((bool)IS_MSG_UNREAD(fmpe.mMsgStatus)); - case COLUMN_THREAD_DISTRIBUTION: return decorationRole(fmpe,column); - case COLUMN_THREAD_AUTHOR: + case COLUMN_FILES_NAME: return QVariant(QString::fromUtf8(fmpe.mName.c_str())); + case COLUMN_FILES_SIZE: return QVariant(qulonglong(fmpe.mSize)); + case COLUMN_FILES_FILE: { - QString str,comment ; - QList icons; - GxsIdDetails::MakeIdDesc(fmpe.mAuthorId, false, str, icons, comment,GxsIdDetails::ICON_TYPE_NONE); + FileInfo finfo; + if(rsFiles->FileDetails(fmpe.mHash,RS_FILE_HINTS_DOWNLOAD,finfo)) + return qulonglong(finfo.transfered); - return QVariant(str); + return QVariant(qulonglong(fmpe.mSize)); } + break; + default: return displayRole(fmpe,column); } } -#endif QVariant RsGxsChannelPostFilesModel::displayRole(const RsGxsFile& fmpe,int col) const { diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.h index 873f179e8..eb214516a 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.h @@ -53,15 +53,9 @@ public: COLUMN_FILES_NB_COLUMNS = 0x03 }; -#ifdef TODO enum Roles{ SortRole = Qt::UserRole+1, - ThreadPinnedRole = Qt::UserRole+2, - MissingRole = Qt::UserRole+3, - StatusRole = Qt::UserRole+4, - UnreadChildrenRole = Qt::UserRole+5, - FilterRole = Qt::UserRole+6, + FilterRole = Qt::UserRole+2, }; -#endif #ifdef TODO enum SortMode{ SORT_MODE_PUBLISH_TS = 0x00, @@ -110,13 +104,13 @@ public: QVariant displayRole (const RsGxsFile& fmpe, int col) const; QVariant toolTipRole (const RsGxsFile& fmpe, int col) const; QVariant userRole (const RsGxsFile& fmpe, int col) const; + QVariant sortRole (const RsGxsFile& fmpe, int col) const; #ifdef TODO QVariant decorationRole(const ForumModelPostEntry& fmpe, int col) const; QVariant pinnedRole (const ForumModelPostEntry& fmpe, int col) const; QVariant missingRole (const ForumModelPostEntry& fmpe, int col) const; QVariant statusRole (const ForumModelPostEntry& fmpe, int col) const; QVariant authorRole (const ForumModelPostEntry& fmpe, int col) const; - QVariant sortRole (const ForumModelPostEntry& fmpe, int col) const; QVariant fontRole (const ForumModelPostEntry& fmpe, int col) const; QVariant filterRole (const ForumModelPostEntry& fmpe, int col) const; QVariant textColorRole (const ForumModelPostEntry& fmpe, int col) const; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 6fc4325a5..87cd08ca8 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -71,6 +71,22 @@ void RsGxsChannelPostsModel::postMods() emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mPosts.size(),mColumns-1,(void*)NULL)); } +void RsGxsChannelPostsModel::getFilesList(std::list& files) +{ + // We use an intermediate map so as to remove duplicates + + std::map files_map; + + for(uint32_t i=1;i& files); + #ifdef TODO void setSortMode(SortMode mode) ; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 4a64024a1..550e97d39 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -255,8 +255,11 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI ui->channelPostFiles_TV->setPlaceholderText(tr("Post files")); ui->channelFiles_TV->setPlaceholderText(tr("All files in the channel")); + ui->channelFiles_TV->setModel(mChannelFilesModel = new RsGxsChannelPostFilesModel()); + ui->channelFiles_TV->setItemDelegate(new ChannelPostFilesDelegate()); connect(ui->postsTree->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(showPostDetails())); + connect(mChannelPostsModel,SIGNAL(channelLoaded()),this,SLOT(updateChannelFiles())); QFontMetricsF fm(font()); @@ -416,6 +419,20 @@ void GxsChannelPostsWidgetWithModel::showPostDetails() ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE); ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_NAME); ui->channelPostFiles_TV->setAutoSelect(true); + +} + +void GxsChannelPostsWidgetWithModel::updateChannelFiles() +{ + std::list files; + + mChannelPostsModel->getFilesList(files); + mChannelFilesModel->setFiles(files); + + ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE); + ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE); + ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_NAME); + ui->channelFiles_TV->setAutoSelect(true); } void GxsChannelPostsWidgetWithModel::updateGroupData() diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 48caeaf49..c679a732d 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -136,6 +136,7 @@ private slots: void setViewMode(int viewMode); void settingsChanged(); void handlePostsTreeSizeChange(QSize s); + void updateChannelFiles(); private: void processSettings(bool load); @@ -157,6 +158,7 @@ private: RsGxsChannelPostsModel *mChannelPostsModel; RsGxsChannelPostFilesModel *mChannelPostFilesModel; + RsGxsChannelPostFilesModel *mChannelFilesModel; /* UI - from Designer */ Ui::GxsChannelPostsWidgetWithModel *ui; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index e6795a63b..5cc94fbbc 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -224,7 +224,7 @@ - 1 + 2 @@ -530,6 +530,11 @@ p, li { white-space: pre-wrap; } Comments + + + + + @@ -542,7 +547,14 @@ p, li { white-space: pre-wrap; } - + + + QAbstractItemView::CurrentChanged|QAbstractItemView::SelectedClicked + + + true + +