change: change code style to Linux style except indent.

This commit is contained in:
Mike Solar
2025-08-03 03:09:40 +08:00
parent 65ab76edc8
commit 74f73ab3be
789 changed files with 77113 additions and 68888 deletions
@@ -22,62 +22,69 @@
#include <QPainter>
namespace olive {
ProjectExplorerListViewItemDelegate::ProjectExplorerListViewItemDelegate(QObject *parent) :
QStyledItemDelegate(parent)
namespace olive
{
}
QSize ProjectExplorerListViewItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &) const
ProjectExplorerListViewItemDelegate::ProjectExplorerListViewItemDelegate(
QObject *parent)
: QStyledItemDelegate(parent)
{
return QSize(option.decorationSize.height(), option.decorationSize.height());
}
void ProjectExplorerListViewItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
QSize ProjectExplorerListViewItemDelegate::sizeHint(
const QStyleOptionViewItem &option, const QModelIndex &) const
{
QFontMetrics fm = painter->fontMetrics();
QRect img_rect = option.rect;
return QSize(option.decorationSize.height(),
option.decorationSize.height());
}
if (option.state & QStyle::State_Selected) {
painter->fillRect(option.rect, option.palette.highlight());
}
void ProjectExplorerListViewItemDelegate::paint(
QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QFontMetrics fm = painter->fontMetrics();
QRect img_rect = option.rect;
img_rect.setWidth(qMin(img_rect.width(), img_rect.height()));
if (option.state & QStyle::State_Selected) {
painter->fillRect(option.rect, option.palette.highlight());
}
QIcon ico = index.data(Qt::DecorationRole).value<QIcon>();
QSize icon_size = ico.actualSize(img_rect.size());
img_rect = QRect(img_rect.x() + (img_rect.width() / 2 - icon_size.width() / 2),
img_rect.y() + (img_rect.height() / 2 - icon_size.height() / 2),
icon_size.width(),
icon_size.height());
painter->drawPixmap(img_rect, ico.pixmap(icon_size));
img_rect.setWidth(qMin(img_rect.width(), img_rect.height()));
QRect text_rect = option.rect;
text_rect.setLeft(text_rect.left() + option.rect.height());
QIcon ico = index.data(Qt::DecorationRole).value<QIcon>();
QSize icon_size = ico.actualSize(img_rect.size());
img_rect =
QRect(img_rect.x() + (img_rect.width() / 2 - icon_size.width() / 2),
img_rect.y() + (img_rect.height() / 2 - icon_size.height() / 2),
icon_size.width(), icon_size.height());
painter->drawPixmap(img_rect, ico.pixmap(icon_size));
int maximum_line_count = qMax(1, option.rect.height() / fm.height() - 1);
QString text;
if (maximum_line_count == 1) {
text = index.data(Qt::DisplayRole).toString();
} else {
text = index.data(Qt::ToolTipRole).toString();
if (text.isEmpty()) {
text = index.data(Qt::DisplayRole).toString();
} else {
QStringList strings = text.split("\n");
while (strings.size() > maximum_line_count) {
strings.removeLast();
}
text = strings.join("\n");
}
}
QRect text_rect = option.rect;
text_rect.setLeft(text_rect.left() + option.rect.height());
painter->setPen(option.state & QStyle::State_Selected ?
option.palette.highlightedText().color() : option.palette.text().color());
int maximum_line_count = qMax(1, option.rect.height() / fm.height() - 1);
QString text;
if (maximum_line_count == 1) {
text = index.data(Qt::DisplayRole).toString();
} else {
text = index.data(Qt::ToolTipRole).toString();
if (text.isEmpty()) {
text = index.data(Qt::DisplayRole).toString();
} else {
QStringList strings = text.split("\n");
while (strings.size() > maximum_line_count) {
strings.removeLast();
}
text = strings.join("\n");
}
}
painter->drawText(text_rect, static_cast<int>(Qt::AlignLeft | Qt::AlignVCenter), text);
painter->setPen(option.state & QStyle::State_Selected ?
option.palette.highlightedText().color() :
option.palette.text().color());
painter->drawText(text_rect,
static_cast<int>(Qt::AlignLeft | Qt::AlignVCenter), text);
}
}