kdeui: format and indent

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-05 11:51:29 +03:00
parent 1a0f259d1b
commit ccd772f4f4
2 changed files with 34 additions and 42 deletions

View file

@ -31,20 +31,19 @@
class KColorComboDelegate : public QAbstractItemDelegate
{
public:
enum ItemRoles {
ColorRole = Qt::UserRole + 1
};
public:
enum ItemRoles {
ColorRole = Qt::UserRole + 1
};
enum LayoutMetrics {
FrameMargin = 3
};
enum LayoutMetrics {
FrameMargin = 3
};
KColorComboDelegate(QObject *parent = 0);
virtual ~KColorComboDelegate();
KColorComboDelegate(QObject *parent = 0);
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const final;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const final;
};
static QBrush k_colorcombodelegate_brush(const QModelIndex &index, int role)
@ -64,10 +63,6 @@ KColorComboDelegate::KColorComboDelegate(QObject *parent)
{
}
KColorComboDelegate::~KColorComboDelegate()
{
}
void KColorComboDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
// background
@ -129,7 +124,6 @@ void KColorComboDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
QSize KColorComboDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(index)
// the width does not matter, as the view will always use the maximum width available
return QSize(100, option.fontMetrics.height() + 2 * FrameMargin);
}
@ -175,20 +169,20 @@ static inline QColor standardColor(int i)
class KColorComboPrivate
{
public:
KColorComboPrivate(KColorCombo *qq);
public:
KColorComboPrivate(KColorCombo *qq);
void addColors();
void setCustomColor(const QColor &color, bool lookupInPresets = true);
void addColors();
void setCustomColor(const QColor &color, bool lookupInPresets = true);
// slots
void _k_slotActivated(int index);
void _k_slotHighlighted(int index);
// slots
void _k_slotActivated(int index);
void _k_slotHighlighted(int index);
KColorCombo *q;
QList<QColor> colorList;
QColor customColor;
QColor internalcolor;
KColorCombo *q;
QList<QColor> colorList;
QColor customColor;
QColor internalcolor;
};
KColorComboPrivate::KColorComboPrivate(KColorCombo *qq)
@ -244,7 +238,7 @@ KColorCombo::KColorCombo( QWidget *parent )
KColorCombo::~KColorCombo()
{
delete d;
delete d;
}
void KColorCombo::setColors( const QList<QColor> &colors )
@ -260,11 +254,10 @@ QList<QColor> KColorCombo::colors() const
QList<QColor> list;
for (int i = 0; i < STANDARD_PALETTE_SIZE; ++i) {
list += standardColor(i);
}
}
return list;
} else {
return d->colorList;
}
return d->colorList;
}
/**
@ -275,11 +268,9 @@ void KColorCombo::setColor( const QColor &col )
if (!col.isValid()) {
return;
}
if (count() == 0) {
d->addColors();
}
d->setCustomColor(col, true);
}
@ -287,8 +278,9 @@ void KColorCombo::setColor( const QColor &col )
/**
Returns the currently selected color
*/
QColor KColorCombo::color() const {
return d->internalcolor;
QColor KColorCombo::color() const
{
return d->internalcolor;
}
bool KColorCombo::isCustomColor() const

View file

@ -44,20 +44,20 @@ class KColorComboPrivate;
class KDEUI_EXPORT KColorCombo : public QComboBox
{
Q_OBJECT
Q_PROPERTY( QColor color READ color WRITE setColor NOTIFY activated USER true )
Q_PROPERTY( QList<QColor> colors READ colors WRITE setColors )
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY activated USER true)
Q_PROPERTY(QList<QColor> colors READ colors WRITE setColors)
public:
/**
* Constructs a color combo box.
*/
explicit KColorCombo(QWidget *parent = 0);
explicit KColorCombo(QWidget *parent = nullptr);
~KColorCombo();
/**
* Selects the color @p col.
*/
void setColor( const QColor &col );
void setColor(const QColor &col);
/**
* Returns the currently selected color.
**/
@ -75,7 +75,7 @@ public:
* @param cols list of colors. If empty, the selection list reverts to
* the standard list.
**/
void setColors(const QList<QColor> &colors );
void setColors(const QList<QColor> &colors);
/**
* Return the list of colors available for selection.
@ -92,11 +92,11 @@ Q_SIGNALS:
/**
* Emitted when a new color box has been selected.
*/
void activated( const QColor &col );
void activated(const QColor &col);
/**
* Emitted when a new item has been highlighted.
*/
void highlighted( const QColor &col );
void highlighted(const QColor &col);
protected:
virtual void paintEvent(QPaintEvent *event);