mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 23:36:59 -05:00
added list of files for the whole channel
This commit is contained in:
parent
591ffc2fa7
commit
944c5b3592
@ -345,6 +345,7 @@ QVariant RsGxsChannelPostFilesModel::data(const QModelIndex &index, int role) co
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole: return displayRole (fmpe,index.column()) ;
|
case Qt::DisplayRole: return displayRole (fmpe,index.column()) ;
|
||||||
case Qt::UserRole: return userRole (fmpe,index.column()) ;
|
case Qt::UserRole: return userRole (fmpe,index.column()) ;
|
||||||
|
case SortRole: return sortRole (fmpe,index.column()) ;
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
case Qt::DecorationRole: return decorationRole(fmpe,index.column()) ;
|
case Qt::DecorationRole: return decorationRole(fmpe,index.column()) ;
|
||||||
case Qt::ToolTipRole: return toolTipRole (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 ThreadPinnedRole: return pinnedRole (fmpe,index.column()) ;
|
||||||
case MissingRole: return missingRole (fmpe,index.column()) ;
|
case MissingRole: return missingRole (fmpe,index.column()) ;
|
||||||
case StatusRole: return statusRole (fmpe,index.column()) ;
|
case StatusRole: return statusRole (fmpe,index.column()) ;
|
||||||
case SortRole: return sortRole (fmpe,index.column()) ;
|
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -542,39 +542,26 @@ QVariant RsGxsChannelPostFilesModel::sizeHintRole(int col) const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TODO
|
QVariant RsGxsChannelPostFilesModel::sortRole(const RsGxsFile& fmpe,int column) const
|
||||||
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
|
|
||||||
{
|
{
|
||||||
switch(column)
|
switch(column)
|
||||||
{
|
{
|
||||||
case COLUMN_THREAD_DATE: if(mSortMode == SORT_MODE_PUBLISH_TS)
|
case COLUMN_FILES_NAME: return QVariant(QString::fromUtf8(fmpe.mName.c_str()));
|
||||||
return QVariant(QString::number(fmpe.mPublishTs)); // we should probably have leading zeroes here
|
case COLUMN_FILES_SIZE: return QVariant(qulonglong(fmpe.mSize));
|
||||||
else
|
case COLUMN_FILES_FILE:
|
||||||
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:
|
|
||||||
{
|
{
|
||||||
QString str,comment ;
|
FileInfo finfo;
|
||||||
QList<QIcon> icons;
|
if(rsFiles->FileDetails(fmpe.mHash,RS_FILE_HINTS_DOWNLOAD,finfo))
|
||||||
GxsIdDetails::MakeIdDesc(fmpe.mAuthorId, false, str, icons, comment,GxsIdDetails::ICON_TYPE_NONE);
|
return qulonglong(finfo.transfered);
|
||||||
|
|
||||||
return QVariant(str);
|
return QVariant(qulonglong(fmpe.mSize));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return displayRole(fmpe,column);
|
return displayRole(fmpe,column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
QVariant RsGxsChannelPostFilesModel::displayRole(const RsGxsFile& fmpe,int col) const
|
QVariant RsGxsChannelPostFilesModel::displayRole(const RsGxsFile& fmpe,int col) const
|
||||||
{
|
{
|
||||||
|
@ -53,15 +53,9 @@ public:
|
|||||||
COLUMN_FILES_NB_COLUMNS = 0x03
|
COLUMN_FILES_NB_COLUMNS = 0x03
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef TODO
|
|
||||||
enum Roles{ SortRole = Qt::UserRole+1,
|
enum Roles{ SortRole = Qt::UserRole+1,
|
||||||
ThreadPinnedRole = Qt::UserRole+2,
|
FilterRole = Qt::UserRole+2,
|
||||||
MissingRole = Qt::UserRole+3,
|
|
||||||
StatusRole = Qt::UserRole+4,
|
|
||||||
UnreadChildrenRole = Qt::UserRole+5,
|
|
||||||
FilterRole = Qt::UserRole+6,
|
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
enum SortMode{ SORT_MODE_PUBLISH_TS = 0x00,
|
enum SortMode{ SORT_MODE_PUBLISH_TS = 0x00,
|
||||||
@ -110,13 +104,13 @@ public:
|
|||||||
QVariant displayRole (const RsGxsFile& fmpe, int col) const;
|
QVariant displayRole (const RsGxsFile& fmpe, int col) const;
|
||||||
QVariant toolTipRole (const RsGxsFile& fmpe, int col) const;
|
QVariant toolTipRole (const RsGxsFile& fmpe, int col) const;
|
||||||
QVariant userRole (const RsGxsFile& fmpe, int col) const;
|
QVariant userRole (const RsGxsFile& fmpe, int col) const;
|
||||||
|
QVariant sortRole (const RsGxsFile& fmpe, int col) const;
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
QVariant decorationRole(const ForumModelPostEntry& fmpe, int col) const;
|
QVariant decorationRole(const ForumModelPostEntry& fmpe, int col) const;
|
||||||
QVariant pinnedRole (const ForumModelPostEntry& fmpe, int col) const;
|
QVariant pinnedRole (const ForumModelPostEntry& fmpe, int col) const;
|
||||||
QVariant missingRole (const ForumModelPostEntry& fmpe, int col) const;
|
QVariant missingRole (const ForumModelPostEntry& fmpe, int col) const;
|
||||||
QVariant statusRole (const ForumModelPostEntry& fmpe, int col) const;
|
QVariant statusRole (const ForumModelPostEntry& fmpe, int col) const;
|
||||||
QVariant authorRole (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 fontRole (const ForumModelPostEntry& fmpe, int col) const;
|
||||||
QVariant filterRole (const ForumModelPostEntry& fmpe, int col) const;
|
QVariant filterRole (const ForumModelPostEntry& fmpe, int col) const;
|
||||||
QVariant textColorRole (const ForumModelPostEntry& fmpe, int col) const;
|
QVariant textColorRole (const ForumModelPostEntry& fmpe, int col) const;
|
||||||
|
@ -71,6 +71,22 @@ void RsGxsChannelPostsModel::postMods()
|
|||||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mPosts.size(),mColumns-1,(void*)NULL));
|
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mPosts.size(),mColumns-1,(void*)NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RsGxsChannelPostsModel::getFilesList(std::list<RsGxsFile>& files)
|
||||||
|
{
|
||||||
|
// We use an intermediate map so as to remove duplicates
|
||||||
|
|
||||||
|
std::map<RsFileHash,RsGxsFile> files_map;
|
||||||
|
|
||||||
|
for(uint32_t i=1;i<mPosts.size();++i)
|
||||||
|
for(auto& file:mPosts[i].mFiles)
|
||||||
|
files_map[file.mHash] = file;
|
||||||
|
|
||||||
|
files.clear();
|
||||||
|
|
||||||
|
for(auto& it:files_map)
|
||||||
|
files.push_back(it.second);
|
||||||
|
}
|
||||||
|
|
||||||
void RsGxsChannelPostsModel::setTreeMode(TreeMode mode)
|
void RsGxsChannelPostsModel::setTreeMode(TreeMode mode)
|
||||||
{
|
{
|
||||||
if(mode == mTreeMode)
|
if(mode == mTreeMode)
|
||||||
|
@ -111,6 +111,11 @@ public:
|
|||||||
|
|
||||||
void setTreeMode(TreeMode mode) ;
|
void setTreeMode(TreeMode mode) ;
|
||||||
void setNumColumns(int n);
|
void setNumColumns(int n);
|
||||||
|
|
||||||
|
// Retrieve the full list of files for all posts.
|
||||||
|
|
||||||
|
void getFilesList(std::list<RsGxsFile>& files);
|
||||||
|
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
void setSortMode(SortMode mode) ;
|
void setSortMode(SortMode mode) ;
|
||||||
|
|
||||||
|
@ -255,8 +255,11 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
|
|||||||
ui->channelPostFiles_TV->setPlaceholderText(tr("Post files"));
|
ui->channelPostFiles_TV->setPlaceholderText(tr("Post files"));
|
||||||
|
|
||||||
ui->channelFiles_TV->setPlaceholderText(tr("All files in the channel"));
|
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(ui->postsTree->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(showPostDetails()));
|
||||||
|
connect(mChannelPostsModel,SIGNAL(channelLoaded()),this,SLOT(updateChannelFiles()));
|
||||||
|
|
||||||
QFontMetricsF fm(font());
|
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_SIZE);
|
||||||
ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_NAME);
|
ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_NAME);
|
||||||
ui->channelPostFiles_TV->setAutoSelect(true);
|
ui->channelPostFiles_TV->setAutoSelect(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxsChannelPostsWidgetWithModel::updateChannelFiles()
|
||||||
|
{
|
||||||
|
std::list<RsGxsFile> 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()
|
void GxsChannelPostsWidgetWithModel::updateGroupData()
|
||||||
|
@ -136,6 +136,7 @@ private slots:
|
|||||||
void setViewMode(int viewMode);
|
void setViewMode(int viewMode);
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
void handlePostsTreeSizeChange(QSize s);
|
void handlePostsTreeSizeChange(QSize s);
|
||||||
|
void updateChannelFiles();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void processSettings(bool load);
|
void processSettings(bool load);
|
||||||
@ -157,6 +158,7 @@ private:
|
|||||||
|
|
||||||
RsGxsChannelPostsModel *mChannelPostsModel;
|
RsGxsChannelPostsModel *mChannelPostsModel;
|
||||||
RsGxsChannelPostFilesModel *mChannelPostFilesModel;
|
RsGxsChannelPostFilesModel *mChannelPostFilesModel;
|
||||||
|
RsGxsChannelPostFilesModel *mChannelFilesModel;
|
||||||
|
|
||||||
/* UI - from Designer */
|
/* UI - from Designer */
|
||||||
Ui::GxsChannelPostsWidgetWithModel *ui;
|
Ui::GxsChannelPostsWidgetWithModel *ui;
|
||||||
|
@ -224,7 +224,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="channel_TW">
|
<widget class="QTabWidget" name="channel_TW">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_3">
|
<widget class="QWidget" name="tab_3">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -530,6 +530,11 @@ p, li { white-space: pre-wrap; }
|
|||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Comments</string>
|
<string>Comments</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="commentsDialog" native="true"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
@ -542,7 +547,14 @@ p, li { white-space: pre-wrap; }
|
|||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
<widget class="RSTreeView" name="channelFiles_TV"/>
|
<widget class="RSTreeView" name="channelFiles_TV">
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::CurrentChanged|QAbstractItemView::SelectedClicked</set>
|
||||||
|
</property>
|
||||||
|
<property name="sortingEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user