mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 15:39:27 -05:00
fixed a few UI glitches
This commit is contained in:
parent
d39c476131
commit
facad382cf
@ -43,6 +43,9 @@ RsGxsChannelPostFilesModel::RsGxsChannelPostFilesModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
initEmptyHierarchy(mFiles);
|
||||
|
||||
mTimer = new QTimer;
|
||||
connect(mTimer,SIGNAL(timeout()),this,SLOT(update()));
|
||||
}
|
||||
|
||||
void RsGxsChannelPostFilesModel::initEmptyHierarchy(std::vector<RsGxsFile>& files)
|
||||
@ -68,6 +71,11 @@ void RsGxsChannelPostFilesModel::postMods()
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFiles.size(),COLUMN_FILES_NB_COLUMNS-1,(void*)NULL));
|
||||
}
|
||||
|
||||
void RsGxsChannelPostFilesModel::update()
|
||||
{
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFiles.size(),COLUMN_FILES_NB_COLUMNS-1,(void*)NULL));
|
||||
}
|
||||
|
||||
#ifdef TODO
|
||||
void RsGxsChannelPostsModel::setSortMode(SortMode mode)
|
||||
{
|
||||
@ -694,34 +702,13 @@ void RsGxsChannelPostFilesModel::setFiles(const std::list<RsGxsFile>& files)
|
||||
postMods();
|
||||
|
||||
emit channelLoaded();
|
||||
|
||||
if(!files.empty())
|
||||
mTimer->start(5000);
|
||||
else
|
||||
mTimer->stop();
|
||||
}
|
||||
|
||||
//ChannelPostsModelIndex RsGxsChannelPostsModel::addEntry(std::vector<ChannelPostsModelPostEntry>& posts,const ChannelPostsModelPostEntry& entry)
|
||||
//{
|
||||
// uint32_t N = posts.size();
|
||||
// posts.push_back(entry);
|
||||
//
|
||||
//#ifdef DEBUG_FORUMMODEL
|
||||
// std::cerr << "Added new entry " << N << " children of " << parent << std::endl;
|
||||
//#endif
|
||||
// if(N == parent)
|
||||
// std::cerr << "(EE) trying to add a post as its own parent!" << std::endl;
|
||||
//
|
||||
// return ChannelPostsModelIndex(N);
|
||||
//}
|
||||
|
||||
//void RsGxsChannelPostsModel::convertMsgToPostEntry(const RsGxsChannelGroup& mChannelGroup,const RsMsgMetaData& msg, bool /*useChildTS*/, ChannelPostsModelPostEntry& fentry)
|
||||
//{
|
||||
// fentry.mTitle = msg.mMsgName;
|
||||
// fentry.mMsgId = msg.mMsgId;
|
||||
// fentry.mPublishTs = msg.mPublishTs;
|
||||
// fentry.mPostFlags = 0;
|
||||
// fentry.mMsgStatus = msg.mMsgStatus;
|
||||
//
|
||||
// // Early check for a message that should be hidden because its author
|
||||
// // is flagged with a bad reputation
|
||||
//}
|
||||
|
||||
QModelIndex RsGxsChannelPostFilesModel::getIndexOfFile(const RsFileHash& hash) const
|
||||
{
|
||||
// Brutal search. This is not so nice, so dont call that in a loop! If too costly, we'll use a map.
|
||||
|
@ -34,6 +34,8 @@
|
||||
|
||||
typedef uint32_t ChannelPostFilesModelIndex;
|
||||
|
||||
class QTimer;
|
||||
|
||||
// This class is the item model used by Qt to display the information
|
||||
|
||||
class RsGxsChannelPostFilesModel : public QAbstractItemModel
|
||||
@ -130,6 +132,9 @@ public:
|
||||
signals:
|
||||
void channelLoaded(); // emitted after the posts have been set. Can be used to updated the UI.
|
||||
|
||||
private slots:
|
||||
void update();
|
||||
|
||||
private:
|
||||
#ifdef TODO
|
||||
bool mUseChildTS;
|
||||
@ -153,4 +158,6 @@ private:
|
||||
void initEmptyHierarchy(std::vector<RsGxsFile> &files);
|
||||
|
||||
std::vector<RsGxsFile> mFiles ; // store the list of files for the post
|
||||
|
||||
QTimer *mTimer;
|
||||
};
|
||||
|
@ -156,11 +156,6 @@ void ChannelPostFilesDelegate::updateEditorGeometry(QWidget *editor, const QStyl
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
|
||||
void ChannelPostFilesDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
// nothing to do here. Is this override needed?
|
||||
}
|
||||
|
||||
void ChannelPostFilesDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
|
||||
{
|
||||
RsGxsFile file = index.data(Qt::UserRole).value<RsGxsFile>() ;
|
||||
@ -187,6 +182,12 @@ void ChannelPostFilesDelegate::paint(QPainter * painter, const QStyleOptionViewI
|
||||
painter->save();
|
||||
painter->setClipRect(option.rect);
|
||||
|
||||
painter->save();
|
||||
|
||||
painter->fillRect( option.rect, option.backgroundBrush);
|
||||
//optionFocusRect.backgroundColor = option.palette.color(colorgroup, (option.state & QStyle::State_Selected) ? QPalette::Highlight : QPalette::Background);
|
||||
painter->restore();
|
||||
|
||||
#ifdef TODO
|
||||
RsGxsFile file = index.data(Qt::UserRole).value<RsGxsFile>() ;
|
||||
QVariant value = index.data(Qt::TextColorRole);
|
||||
@ -194,25 +195,30 @@ void ChannelPostFilesDelegate::paint(QPainter * painter, const QStyleOptionViewI
|
||||
if(value.isValid() && qvariant_cast<QColor>(value).isValid())
|
||||
opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
|
||||
|
||||
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
|
||||
QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled) ? QPalette::Normal : QPalette::Disabled;
|
||||
|
||||
if(option.state & QStyle::State_Selected)
|
||||
painter->setPen(opt.palette.color(cg, QPalette::HighlightedText));
|
||||
painter->setPen(option.palette.color(cg, QPalette::HighlightedText));
|
||||
else
|
||||
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
||||
painter->setPen(option.palette.color(cg, QPalette::Text));
|
||||
#endif
|
||||
|
||||
switch(index.column())
|
||||
{
|
||||
case RsGxsChannelPostFilesModel::COLUMN_FILES_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 RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE: painter->drawText(option.rect,Qt::AlignRight | Qt::AlignVCenter,misc::friendlyUnit(qulonglong(file.mSize)));
|
||||
break;
|
||||
case RsGxsChannelPostFilesModel::COLUMN_FILES_FILE: {
|
||||
GxsChannelFilesStatusWidget w(file);
|
||||
QPixmap pixmap(w.size());
|
||||
|
||||
w.render(&pixmap);
|
||||
GxsChannelFilesStatusWidget w(file);
|
||||
|
||||
w.setFixedWidth(option.rect.width());
|
||||
|
||||
QPixmap pixmap(w.size());
|
||||
pixmap.fill(option.palette.color(QPalette::Background)); // choose the background
|
||||
w.render(&pixmap,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background
|
||||
|
||||
painter->drawPixmap(option.rect.topLeft(),pixmap);
|
||||
|
||||
#ifdef TODO
|
||||
@ -237,10 +243,10 @@ QSize ChannelPostFilesDelegate::sizeHint(const QStyleOptionViewItem& option, con
|
||||
|
||||
switch(index.column())
|
||||
{
|
||||
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());
|
||||
case RsGxsChannelPostFilesModel::COLUMN_FILES_NAME: return QSize(1.1*fm.width(QString::fromUtf8(file.mName.c_str())),fm.height());
|
||||
case RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE: return QSize(1.1*fm.width(misc::friendlyUnit(qulonglong(file.mSize))),fm.height());
|
||||
default:
|
||||
case RsGxsChannelPostFilesModel::COLUMN_FILES_FILE: return GxsChannelFilesStatusWidget(file).size();
|
||||
case RsGxsChannelPostFilesModel::COLUMN_FILES_FILE: return QSize(option.rect.width(),GxsChannelFilesStatusWidget(file).height());
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,7 +404,14 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
|
||||
// Using fixed width so that the post will not displace the text when we browse.
|
||||
|
||||
ui->postLogo_LB->setPixmap(postImage);
|
||||
ui->postName_LB->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str()));
|
||||
|
||||
ui->postLogo_LB->setFixedSize(W,postImage.height()/(float)postImage.width()*W);
|
||||
ui->postName_LB->setFixedWidth(W);
|
||||
|
||||
ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE);
|
||||
ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE);
|
||||
ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_NAME);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidgetWithModel::updateGroupData()
|
||||
|
@ -51,9 +51,6 @@ class ChannelPostFilesDelegate: public QStyledItemDelegate
|
||||
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const override;
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
class ChannelPostDelegate: public QAbstractItemDelegate
|
||||
|
@ -465,6 +465,19 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="postName_LB">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -500,6 +513,12 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="indentation">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user