mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-28 00:07:09 -05:00
removed dead code form GxsForumThreadWidget.cpp
This commit is contained in:
parent
61083ff77a
commit
d1b26c9d36
@ -271,14 +271,9 @@ void GxsIdTreeItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
|||||||
|
|
||||||
// draw pixmap at center of item
|
// draw pixmap at center of item
|
||||||
painter->drawPixmap(r.topLeft() + p, pix);
|
painter->drawPixmap(r.topLeft() + p, pix);
|
||||||
//painter->drawText(r.topLeft() + QPoint(r.height()+ f/2.0 + f/2.0,f*1.0), str);
|
|
||||||
|
|
||||||
//cr.adjust(margin(), margin(), -margin(), -margin());
|
|
||||||
|
|
||||||
QRect mRectElision;
|
QRect mRectElision;
|
||||||
|
|
||||||
r.adjust(pix.height()+f,(r.height()-f)/2.0,0,0);
|
r.adjust(pix.height()+f,(r.height()-f)/2.0,0,0);
|
||||||
|
|
||||||
bool didElide = ElidedLabel::paintElidedLine(*painter,str,r,Qt::AlignLeft,false,false,mRectElision);
|
bool didElide = ElidedLabel::paintElidedLine(*painter,str,r,Qt::AlignLeft,false,false,mRectElision);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -184,95 +184,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class AuthorItemDelegate: public QStyledItemDelegate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AuthorItemDelegate() {}
|
|
||||||
|
|
||||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
|
|
||||||
{
|
|
||||||
QStyleOptionViewItemV4 opt = option;
|
|
||||||
initStyleOption(&opt, index);
|
|
||||||
|
|
||||||
// disable default icon
|
|
||||||
opt.icon = QIcon();
|
|
||||||
const QRect r = option.rect;
|
|
||||||
|
|
||||||
RsGxsId id(index.data(Qt::UserRole).toString().toStdString());
|
|
||||||
QString str;
|
|
||||||
QList<QIcon> icons;
|
|
||||||
QString comment;
|
|
||||||
|
|
||||||
QFontMetricsF fm(option.font);
|
|
||||||
float f = fm.height();
|
|
||||||
|
|
||||||
QIcon icon ;
|
|
||||||
|
|
||||||
if(!GxsIdDetails::MakeIdDesc(id, true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR))
|
|
||||||
icon = GxsIdDetails::getLoadingIcon(id);
|
|
||||||
else
|
|
||||||
icon = *icons.begin();
|
|
||||||
|
|
||||||
QPixmap pix = icon.pixmap(r.size());
|
|
||||||
|
|
||||||
return QSize(1.2*(pix.width() + fm.width(str)),std::max(1.1*pix.height(),1.4*fm.height()));
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex& index) const override
|
|
||||||
{
|
|
||||||
if(!index.isValid())
|
|
||||||
{
|
|
||||||
std::cerr << "(EE) attempt to draw an invalid index." << std::endl;
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStyleOptionViewItemV4 opt = option;
|
|
||||||
initStyleOption(&opt, index);
|
|
||||||
|
|
||||||
// disable default icon
|
|
||||||
opt.icon = QIcon();
|
|
||||||
// draw default item
|
|
||||||
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, 0);
|
|
||||||
|
|
||||||
const QRect r = option.rect;
|
|
||||||
|
|
||||||
RsGxsId id(index.data(Qt::UserRole).toString().toStdString());
|
|
||||||
QString str;
|
|
||||||
QList<QIcon> icons;
|
|
||||||
QString comment;
|
|
||||||
|
|
||||||
QFontMetricsF fm(painter->font());
|
|
||||||
float f = fm.height();
|
|
||||||
|
|
||||||
QIcon icon ;
|
|
||||||
|
|
||||||
if(!GxsIdDetails::MakeIdDesc(id, true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR))
|
|
||||||
icon = GxsIdDetails::getLoadingIcon(id);
|
|
||||||
else
|
|
||||||
icon = *icons.begin();
|
|
||||||
|
|
||||||
unsigned int warning_level = qvariant_cast<unsigned int>(index.sibling(index.row(),RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION).data(Qt::DecorationRole));
|
|
||||||
|
|
||||||
if(warning_level == 2)
|
|
||||||
{
|
|
||||||
str = tr("[Banned]");
|
|
||||||
icon = QIcon(IMAGE_BIOHAZARD);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(index.data(RsGxsForumModel::MissingRole).toBool())
|
|
||||||
painter->drawText(r.topLeft() + QPoint(f/2.0,f*1.0), tr("[None]"));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QPixmap pix = icon.pixmap(r.size());
|
|
||||||
const QPoint p = QPoint(r.height()/2.0, (r.height() - pix.height())/2);
|
|
||||||
|
|
||||||
// draw pixmap at center of item
|
|
||||||
painter->drawPixmap(r.topLeft() + p, pix);
|
|
||||||
painter->drawText(r.topLeft() + QPoint(r.height()+ f/2.0 + f/2.0,f*1.0), str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class ForumPostSortFilterProxyModel: public QSortFilterProxyModel
|
class ForumPostSortFilterProxyModel: public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -331,7 +242,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
|||||||
ui->threadTreeWidget->setSortingEnabled(true);
|
ui->threadTreeWidget->setSortingEnabled(true);
|
||||||
|
|
||||||
ui->threadTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION,new DistributionItemDelegate()) ;
|
ui->threadTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION,new DistributionItemDelegate()) ;
|
||||||
ui->threadTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_AUTHOR,new AuthorItemDelegate()) ;
|
ui->threadTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_AUTHOR,new GxsIdTreeItemDelegate()) ;
|
||||||
ui->threadTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_READ,new ReadStatusItemDelegate()) ;
|
ui->threadTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_READ,new ReadStatusItemDelegate()) ;
|
||||||
|
|
||||||
ui->threadTreeWidget->header()->setSortIndicatorShown(true);
|
ui->threadTreeWidget->header()->setSortIndicatorShown(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user