Improve coding style
This commit is contained in:
parent
d0e81c6a4a
commit
7472ddc5af
|
@ -184,8 +184,10 @@ use_cpp_utilities()
|
||||||
# include modules to apply configuration
|
# include modules to apply configuration
|
||||||
include(BasicConfig)
|
include(BasicConfig)
|
||||||
include(QtGuiConfig)
|
include(QtGuiConfig)
|
||||||
# apply Qt utilities specific configuration
|
|
||||||
|
# add further Qt modules (which are not automatically detected)
|
||||||
set(META_PUBLIC_QT_MODULES Core ${ADDITIONAL_QT_MODULES})
|
set(META_PUBLIC_QT_MODULES Core ${ADDITIONAL_QT_MODULES})
|
||||||
|
|
||||||
# include further modules to apply configuration
|
# include further modules to apply configuration
|
||||||
include(QtConfig)
|
include(QtConfig)
|
||||||
include(WindowsResources)
|
include(WindowsResources)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "recentmenumanager.h"
|
#include "./recentmenumanager.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
|
@ -417,7 +417,7 @@ RoleEditor::RoleEditor(QWidget *parent)
|
||||||
// textMargin in QItemDelegate
|
// textMargin in QItemDelegate
|
||||||
setFocusProxy(m_label);
|
setFocusProxy(m_label);
|
||||||
|
|
||||||
QToolButton *button = new QToolButton(this);
|
auto *const button = new QToolButton(this);
|
||||||
button->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
button->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
||||||
button->setIcon(QIcon(QStringLiteral(":/qtutilities/icons/hicolor/48x48/actions/edit-clear.png")));
|
button->setIcon(QIcon(QStringLiteral(":/qtutilities/icons/hicolor/48x48/actions/edit-clear.png")));
|
||||||
button->setIconSize(QSize(8, 8));
|
button->setIconSize(QSize(8, 8));
|
||||||
|
@ -460,36 +460,32 @@ ColorDelegate::ColorDelegate(QObject *parent)
|
||||||
|
|
||||||
QWidget *ColorDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const
|
QWidget *ColorDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QWidget *ed = nullptr;
|
|
||||||
if (index.column() == 0) {
|
if (index.column() == 0) {
|
||||||
RoleEditor *editor = new RoleEditor(parent);
|
auto *const editor = new RoleEditor(parent);
|
||||||
connect(editor, &RoleEditor::changed, this, &ColorDelegate::commitData);
|
connect(editor, &RoleEditor::changed, this, &ColorDelegate::commitData);
|
||||||
// editor->setFocusPolicy(Qt::NoFocus);
|
return editor;
|
||||||
// editor->installEventFilter(const_cast<ColorDelegate *>(this));
|
|
||||||
ed = editor;
|
|
||||||
} else {
|
|
||||||
typedef void (BrushEditor::*BrushEditorWidgetSignal)(QWidget *);
|
|
||||||
|
|
||||||
BrushEditor *editor = new BrushEditor(parent);
|
|
||||||
connect(editor, static_cast<BrushEditorWidgetSignal>(&BrushEditor::changed), this, &ColorDelegate::commitData);
|
|
||||||
editor->setFocusPolicy(Qt::NoFocus);
|
|
||||||
editor->installEventFilter(const_cast<ColorDelegate *>(this));
|
|
||||||
ed = editor;
|
|
||||||
}
|
}
|
||||||
return ed;
|
|
||||||
|
using BrushEditorWidgetSignal = void (BrushEditor::*)(QWidget *);
|
||||||
|
|
||||||
|
auto *const editor = new BrushEditor(parent);
|
||||||
|
connect(editor, static_cast<BrushEditorWidgetSignal>(&BrushEditor::changed), this, &ColorDelegate::commitData);
|
||||||
|
editor->setFocusPolicy(Qt::NoFocus);
|
||||||
|
editor->installEventFilter(const_cast<ColorDelegate *>(this));
|
||||||
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorDelegate::setEditorData(QWidget *ed, const QModelIndex &index) const
|
void ColorDelegate::setEditorData(QWidget *ed, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.column() == 0) {
|
if (index.column() == 0) {
|
||||||
const bool mask = qvariant_cast<bool>(index.model()->data(index, Qt::EditRole));
|
const auto mask = qvariant_cast<bool>(index.model()->data(index, Qt::EditRole));
|
||||||
RoleEditor *editor = static_cast<RoleEditor *>(ed);
|
auto *const editor = static_cast<RoleEditor *>(ed);
|
||||||
editor->setEdited(mask);
|
editor->setEdited(mask);
|
||||||
const QString colorName = qvariant_cast<QString>(index.model()->data(index, Qt::DisplayRole));
|
const auto colorName = qvariant_cast<QString>(index.model()->data(index, Qt::DisplayRole));
|
||||||
editor->setLabel(colorName);
|
editor->setLabel(colorName);
|
||||||
} else {
|
} else {
|
||||||
const QBrush br = qvariant_cast<QBrush>(index.model()->data(index, BrushRole));
|
const auto br = qvariant_cast<QBrush>(index.model()->data(index, BrushRole));
|
||||||
BrushEditor *editor = static_cast<BrushEditor *>(ed);
|
auto *const editor = static_cast<BrushEditor *>(ed);
|
||||||
editor->setBrush(br);
|
editor->setBrush(br);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -497,11 +493,11 @@ void ColorDelegate::setEditorData(QWidget *ed, const QModelIndex &index) const
|
||||||
void ColorDelegate::setModelData(QWidget *ed, QAbstractItemModel *model, const QModelIndex &index) const
|
void ColorDelegate::setModelData(QWidget *ed, QAbstractItemModel *model, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.column() == 0) {
|
if (index.column() == 0) {
|
||||||
RoleEditor *editor = static_cast<RoleEditor *>(ed);
|
const auto *const editor = static_cast<RoleEditor *>(ed);
|
||||||
const bool mask = editor->edited();
|
const auto mask = editor->edited();
|
||||||
model->setData(index, mask, Qt::EditRole);
|
model->setData(index, mask, Qt::EditRole);
|
||||||
} else {
|
} else {
|
||||||
BrushEditor *editor = static_cast<BrushEditor *>(ed);
|
const auto *const editor = static_cast<BrushEditor *>(ed);
|
||||||
if (editor->changed()) {
|
if (editor->changed()) {
|
||||||
QBrush br = editor->brush();
|
QBrush br = editor->brush();
|
||||||
model->setData(index, br, BrushRole);
|
model->setData(index, br, BrushRole);
|
||||||
|
@ -518,11 +514,11 @@ void ColorDelegate::updateEditorGeometry(QWidget *ed, const QStyleOptionViewItem
|
||||||
void ColorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &index) const
|
void ColorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QStyleOptionViewItem option = opt;
|
QStyleOptionViewItem option = opt;
|
||||||
const bool mask = qvariant_cast<bool>(index.model()->data(index, Qt::EditRole));
|
const auto mask = qvariant_cast<bool>(index.model()->data(index, Qt::EditRole));
|
||||||
if (index.column() == 0 && mask) {
|
if (index.column() == 0 && mask) {
|
||||||
option.font.setBold(true);
|
option.font.setBold(true);
|
||||||
}
|
}
|
||||||
QBrush br = qvariant_cast<QBrush>(index.model()->data(index, BrushRole));
|
auto br = qvariant_cast<QBrush>(index.model()->data(index, BrushRole));
|
||||||
if (br.style() == Qt::LinearGradientPattern || br.style() == Qt::RadialGradientPattern || br.style() == Qt::ConicalGradientPattern) {
|
if (br.style() == Qt::LinearGradientPattern || br.style() == Qt::RadialGradientPattern || br.style() == Qt::ConicalGradientPattern) {
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->translate(option.rect.x(), option.rect.y());
|
painter->translate(option.rect.x(), option.rect.y());
|
||||||
|
|
Loading…
Reference in New Issue