mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 15:39:27 -05:00
fixed entering editing event.
This commit is contained in:
parent
b9c41b31d4
commit
d39c476131
@ -65,7 +65,7 @@ void RsGxsChannelPostFilesModel::postMods()
|
||||
{
|
||||
endResetModel();
|
||||
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFiles.size(),COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFiles.size(),COLUMN_FILES_NB_COLUMNS-1,(void*)NULL));
|
||||
}
|
||||
|
||||
#ifdef TODO
|
||||
@ -107,7 +107,7 @@ int RsGxsChannelPostFilesModel::rowCount(const QModelIndex& parent) const
|
||||
|
||||
int RsGxsChannelPostFilesModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return COLUMN_THREAD_NB_COLUMNS ;
|
||||
return COLUMN_FILES_NB_COLUMNS ;
|
||||
}
|
||||
|
||||
// std::vector<std::pair<time_t,RsGxsMessageId> > RsGxsChannelPostsModel::getPostVersions(const RsGxsMessageId& mid) const
|
||||
@ -175,7 +175,7 @@ bool RsGxsChannelPostFilesModel::convertRefPointerToTabEntry(quintptr ref, uint3
|
||||
|
||||
QModelIndex RsGxsChannelPostFilesModel::index(int row, int column, const QModelIndex & parent) const
|
||||
{
|
||||
if(row < 0 || column < 0 || column >= COLUMN_THREAD_NB_COLUMNS)
|
||||
if(row < 0 || column < 0 || column >= COLUMN_FILES_NB_COLUMNS)
|
||||
return QModelIndex();
|
||||
|
||||
quintptr ref = getChildRef(parent.internalId(),row);
|
||||
@ -199,6 +199,9 @@ Qt::ItemFlags RsGxsChannelPostFilesModel::flags(const QModelIndex& index) const
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
|
||||
if(index.column() == COLUMN_FILES_FILE)
|
||||
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||
else
|
||||
return QAbstractItemModel::flags(index);
|
||||
}
|
||||
|
||||
@ -258,6 +261,21 @@ int RsGxsChannelPostFilesModel::getChildrenCount(quintptr ref) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
QVariant RsGxsChannelPostFilesModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
switch(section)
|
||||
{
|
||||
case COLUMN_FILES_FILE: return QString("Status");
|
||||
case COLUMN_FILES_SIZE: return QString("Size");
|
||||
case COLUMN_FILES_NAME: return QString("File");
|
||||
default:
|
||||
return QString("[No data]");
|
||||
}
|
||||
}
|
||||
|
||||
QVariant RsGxsChannelPostFilesModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL_MODEL
|
||||
|
@ -44,20 +44,14 @@ public:
|
||||
explicit RsGxsChannelPostFilesModel(QObject *parent = NULL);
|
||||
~RsGxsChannelPostFilesModel(){}
|
||||
|
||||
static const int COLUMN_THREAD_NB_COLUMNS = 0x03; // columns for name, size, percentage completion
|
||||
|
||||
#ifdef TODO
|
||||
enum Columns {
|
||||
COLUMN_THREAD_TITLE =0x00,
|
||||
COLUMN_THREAD_READ =0x01,
|
||||
COLUMN_THREAD_DATE =0x02,
|
||||
COLUMN_THREAD_DISTRIBUTION =0x03,
|
||||
COLUMN_THREAD_AUTHOR =0x04,
|
||||
COLUMN_THREAD_CONTENT =0x05,
|
||||
COLUMN_THREAD_MSGID =0x06,
|
||||
COLUMN_THREAD_DATA =0x07,
|
||||
COLUMN_FILES_NAME = 0x00,
|
||||
COLUMN_FILES_SIZE = 0x01,
|
||||
COLUMN_FILES_FILE = 0x02,
|
||||
COLUMN_FILES_NB_COLUMNS = 0x03
|
||||
};
|
||||
|
||||
#ifdef TODO
|
||||
enum Roles{ SortRole = Qt::UserRole+1,
|
||||
ThreadPinnedRole = Qt::UserRole+2,
|
||||
MissingRole = Qt::UserRole+3,
|
||||
@ -106,6 +100,7 @@ public:
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
|
||||
// Custom item roles
|
||||
|
||||
|
@ -62,10 +62,6 @@ static const int CHANNEL_TABS_POSTS = 1;
|
||||
#define VIEW_MODE_FEEDS 1
|
||||
#define VIEW_MODE_FILES 2
|
||||
|
||||
#define CHANNEL_FILES_COLUMN_NAME 0
|
||||
#define CHANNEL_FILES_COLUMN_SIZE 1
|
||||
#define CHANNEL_FILES_COLUMN_FILE 2
|
||||
|
||||
Q_DECLARE_METATYPE(RsGxsFile)
|
||||
|
||||
void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
|
||||
@ -150,7 +146,7 @@ QWidget *ChannelPostFilesDelegate::createEditor(QWidget *parent, const QStyleOpt
|
||||
{
|
||||
RsGxsFile file = index.data(Qt::UserRole).value<RsGxsFile>() ;
|
||||
|
||||
if(index.column() == CHANNEL_FILES_COLUMN_FILE)
|
||||
if(index.column() == RsGxsChannelPostFilesModel::COLUMN_FILES_FILE)
|
||||
return new GxsChannelFilesStatusWidget(file,parent);
|
||||
else
|
||||
return NULL;
|
||||
@ -208,11 +204,11 @@ void ChannelPostFilesDelegate::paint(QPainter * painter, const QStyleOptionViewI
|
||||
|
||||
switch(index.column())
|
||||
{
|
||||
case CHANNEL_FILES_COLUMN_NAME: painter->drawText(option.rect,Qt::AlignLeft | Qt::AlignVCenter,QString::fromUtf8(file.mName.c_str()));
|
||||
case RsGxsChannelPostFilesModel::COLUMN_FILES_NAME: painter->drawText(option.rect,Qt::AlignLeft | Qt::AlignVCenter,QString::fromUtf8(file.mName.c_str()));
|
||||
break;
|
||||
case CHANNEL_FILES_COLUMN_SIZE: painter->drawText(option.rect,Qt::AlignLeft | Qt::AlignVCenter,misc::friendlyUnit(qulonglong(file.mSize)));
|
||||
case RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE: painter->drawText(option.rect,Qt::AlignRight | Qt::AlignVCenter,misc::friendlyUnit(qulonglong(file.mSize)));
|
||||
break;
|
||||
case CHANNEL_FILES_COLUMN_FILE: {
|
||||
case RsGxsChannelPostFilesModel::COLUMN_FILES_FILE: {
|
||||
GxsChannelFilesStatusWidget w(file);
|
||||
QPixmap pixmap(w.size());
|
||||
|
||||
@ -241,10 +237,10 @@ QSize ChannelPostFilesDelegate::sizeHint(const QStyleOptionViewItem& option, con
|
||||
|
||||
switch(index.column())
|
||||
{
|
||||
case CHANNEL_FILES_COLUMN_NAME: return QSize(fm.width(QString::fromUtf8(file.mName.c_str())),fm.height());
|
||||
case CHANNEL_FILES_COLUMN_SIZE: return QSize(fm.width(misc::friendlyUnit(qulonglong(file.mSize))),fm.height());
|
||||
case RsGxsChannelPostFilesModel::COLUMN_FILES_NAME: return QSize(fm.width(QString::fromUtf8(file.mName.c_str())),fm.height());
|
||||
case RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE: return QSize(fm.width(misc::friendlyUnit(qulonglong(file.mSize))),fm.height());
|
||||
default:
|
||||
case CHANNEL_FILES_COLUMN_FILE: return GxsChannelFilesStatusWidget(file).size();
|
||||
case RsGxsChannelPostFilesModel::COLUMN_FILES_FILE: return GxsChannelFilesStatusWidget(file).size();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -495,20 +495,13 @@ p, li { white-space: pre-wrap; }
|
||||
<item>
|
||||
<widget class="QTreeView" name="channelPostFiles_TV">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::CurrentChanged</set>
|
||||
<set>QAbstractItemView::CurrentChanged|QAbstractItemView::SelectedClicked</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="channelPostFilesDL_PB">
|
||||
<property name="text">
|
||||
<string>Download selected files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
|
Loading…
Reference in New Issue
Block a user