17#include <QApplication>
25#include <QStyleOptionViewItem>
29#include <klocalizedstring.h>
85 boost::optional<KisBaseNode::Property>
86 propForMousePos(
const QModelIndex &index,
const QPoint &mousePos,
const QStyleOptionViewItem &option);
90 : QAbstractItemDelegate(parent)
93 QApplication::instance()->installEventFilter(
this);
110 return QSize(option.rect.width(),
d->
rowHeight);
118 QStyleOptionViewItem option =
getOptions(o, index);
119 QStyle *style = option.widget ? option.widget->style() : QApplication::style();
120 style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option,
p, option.widget);
124 option.state &= ~QStyle::State_Enabled;
134 p->setFont(option.font);
155 QModelIndex
tmp = index.parent();
158 if (!
tmp.isValid())
return;
162 int rtlNum = (option.direction == Qt::RightToLeft) ? 1 : -1;
163 QPoint nodeCorner = (option.direction == Qt::RightToLeft) ? option.rect.topLeft() : option.rect.topRight();
164 int branchSpacing = rtlNum *
d->
view->indentation();
166 QPoint base = nodeCorner + 0.5 * QPoint(branchSpacing, option.rect.height()) + QPoint(0, scm.
iconSize()/4);
169 QColor bgColor = option.state & QStyle::State_Selected ?
170 qApp->palette().color(QPalette::Base) :
171 qApp->palette().color(QPalette::Text);
176 p->setPen(QPen(color, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
178 QPoint
p2 = base - QPoint(rtlNum*(qMin(
d->
view->indentation(), scm.
iconSize())/2), 0);
179 QPoint
p3 = base - QPoint(0, scm.
iconSize()/2);
180 p->drawLine(base,
p2);
181 p->drawLine(base,
p3);
184 QPoint parentBase1 = base + QPoint(branchSpacing, 0);
185 QPoint parentBase2 =
p3 + QPoint(branchSpacing, 0);
189 p->setPen(QPen(color, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
192 int levelRowIndex =
tmp.row();
195 while (
tmp.isValid()) {
196 bool moreSiblings = index.model()->rowCount(
tmp) > (levelRowIndex + 1);
198 p->drawLine(parentBase1, parentBase2);
201 parentBase1 += QPoint(branchSpacing, 0);
202 parentBase2 += QPoint(branchSpacing, 0);
204 levelRowIndex =
tmp.row();
214 if (color.alpha() <= 0)
return;
216 QColor bgColor = qApp->palette().color(QPalette::Base);
219 QRect optionRect = (option.state & QStyle::State_Selected) ?
iconsRect(option, index) : option.rect;
221 p->fillRect(optionRect, color);
228 QPen oldPen =
p->pen();
233 const QRect iconsRectR =
iconsRect(option, index);
235 const float bottomY = thumbnailRect.bottomLeft().y();
237 QPoint bottomLeftPoint;
238 QPoint bottomRightPoint;
239 if (option.direction == Qt::RightToLeft) {
240 bottomLeftPoint = iconsRectR.bottomLeft();
241 bottomRightPoint = visibilityRect.bottomRight();
243 bottomLeftPoint = visibilityRect.bottomLeft();
244 bottomRightPoint = iconsRectR.bottomRight();
248 p->drawLine(bottomLeftPoint.x(), bottomY,
249 bottomRightPoint.x(), bottomY);
269 rc.moveTop(option.rect.topLeft().y());
271 if (option.direction == Qt::RightToLeft) {
272 rc.moveRight(option.rect.right());
274 rc.moveLeft(option.rect.left());
284 const qreal devicePixelRatio =
p->device()->devicePixelRatioF();
287 const qreal oldOpacity =
p->opacity();
290 img.setDevicePixelRatio(devicePixelRatio);
291 if (!(option.state & QStyle::State_Enabled)) {
300 offset.setX((fitRect.width() - img.width()/devicePixelRatio) / 2);
301 offset.setY((fitRect.height() - img.height()/devicePixelRatio) / 2);
302 offset += fitRect.topLeft();
305 p->setBrushOrigin(offset);
306 QRect imageRectLowRes = QRect(img.rect().topLeft(), img.rect().size()/devicePixelRatio);
307 p->fillRect(imageRectLowRes.translated(offset), brush);
309 p->drawImage(offset, img);
310 p->setOpacity(oldOpacity);
312 QRect borderRect =
kisGrowRect(imageRectLowRes, 1).translated(offset);
322 const int iconsWidth =
324 (propCount + 1) * scm.
border();
328 fitRect.moveTop(option.rect.topLeft().y());
330 if (option.direction == Qt::RightToLeft) {
331 fitRect.moveLeft(option.rect.topLeft().x());
333 fitRect.moveRight(option.rect.topRight().x());
344 static int minbearing = 1337 + 666;
345 if (minbearing == 2003 || f != option.font) {
347 minbearing = option.fontMetrics.minLeftBearing() + option.fontMetrics.minRightBearing();
351 const QRect iconRect =
iconsRect(option, index);
353 QRect rc = QRect((option.direction == Qt::RightToLeft) ? iconRect.topRight() : decoRect.topRight(),
354 (option.direction == Qt::RightToLeft) ? decoRect.bottomLeft() : iconRect.bottomLeft());
355 rc.adjust(-(scm.
border()+(minbearing/2)), 0,
356 (scm.
border()+(minbearing/2)), 0);
367 QPen oldPen =
p->pen();
368 const qreal oldOpacity =
p->opacity();
370 p->setPen(option.palette.color(QPalette::Active,QPalette::Text ));
372 if (!(option.state & QStyle::State_Enabled)) {
376 const QString text = index.data(Qt::DisplayRole).toString();
377 const QString elided =
p->fontMetrics().elidedText(text, Qt::ElideRight, rc.width());
380 p->drawText(rc, Qt::AlignLeft | Qt::AlignVCenter, elided);
384 if (infoText.isEmpty()) {
385 p->drawText(rc, Qt::AlignLeft | Qt::AlignVCenter, elided);
390 const int textHeight =
p->fontMetrics().height();
391 useOneLine = rc.height() < textHeight*2;
394 const int rectCenter = rc.height()/2;
395 const int nameWidth =
p->fontMetrics().horizontalAdvance(elided);
399 p->drawText(rc.adjusted(0, 0, 0, -rectCenter), Qt::AlignLeft | Qt::AlignBottom | Qt::TextSingleLine, elided);
402 p->drawText(rc.adjusted(0, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, elided);
406 QFont layerInfoTextFont =
p->font();
407 layerInfoTextFont.setBold(
false);
408 p->setFont(layerInfoTextFont);
409 if (option.state & QStyle::State_Enabled) {
413 const QString infoTextElided =
p->fontMetrics().elidedText(infoText, Qt::ElideRight, rc.width());
414 p->drawText(rc.adjusted(0, rectCenter, 0, 0), Qt::AlignLeft | Qt::AlignTop, infoTextElided);
417 const QString infoTextElided =
p->fontMetrics().elidedText(
" "+infoText, Qt::ElideRight, rc.width()-nameWidth);
418 p->drawText(rc.adjusted(nameWidth, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, infoTextElided);
425 p->setOpacity(oldOpacity);
436 KisBaseNode::PropertyList::const_iterator it = props.constBegin();
437 KisBaseNode::PropertyList::const_iterator end = props.constEnd();
438 for (; it != end; ++it) {
439 if (!it->isMutable &&
459 if (it != list.end()) {
460 std::rotate(list.begin(), it, std::next(it));
469 QMutableListIterator<OptionalProperty> i(prependList);
471 while (i.hasPrevious()) {
474 int emptyIndex = list.lastIndexOf(
nullptr);
475 if (emptyIndex < 0)
break;
477 list[emptyIndex] = val;
482 return prependList + list;
489 return realProps.size();
494 KisBaseNode::PropertyList::iterator it = props.begin();
495 KisBaseNode::PropertyList::iterator end = props.end();
496 for (; it != end; ++it) {
497 if (it->id == refProp->
id) {
507 KisBaseNode::PropertyList::iterator it = props.begin();
508 KisBaseNode::PropertyList::iterator end = props.end();
509 for (; it != end; ++it) {
520 QModelIndex root(view->rootIndex());
526 }
else if ((modifier & Qt::ShiftModifier) == Qt::ShiftModifier && clickedProperty->
canHaveStasis) {
532 int position = shiftClickedIndexes.indexOf(index);
535 (position < 0) ? StasisOperation::Review : StasisOperation::Restore;
537 shiftClickedIndexes.clear();
538 shiftClickedIndexes.push_back(index);
541 if (modifier == (Qt::ControlModifier | Qt::ShiftModifier)) {
543 items.insert(0, index);
544 getSiblingsIndex(items, index);
546 getParentsIndex(items, index);
547 getChildrenIndex(items, index);
549 togglePropertyRecursive(root, clickedProperty, items, record, mode);
556 const bool hasPropInStasis = (shiftClickedIndexes.count() > 0 || checkImmediateStasis(root, clickedProperty));
558 shiftClickedIndexes.clear();
560 restorePropertyInStasisRecursive(root, clickedProperty);
562 shiftClickedIndexes.clear();
564 resetPropertyStateRecursive(root, clickedProperty);
576 int rowCount = view->model()->rowCount(root);
578 for (
int i = 0; i < rowCount; i++) {
579 QModelIndex idx = view->model()->index(i, 0, root);
587 if (record == StasisOperation::Record) {
588 prop->stateInStasis = prop->state.toBool();
590 if (record == StasisOperation::Review || record == StasisOperation::Record) {
591 prop->isInStasis =
true;
593 prop->state = (items.contains(idx)) ? QVariant(
true) : QVariant(
false);
595 prop->state = (!items.contains(idx))? prop->state :
596 (items.at(0) == idx)? QVariant(
true) : QVariant(
false);
599 prop->state = QVariant(prop->stateInStasis);
600 prop->isInStasis =
false;
605 togglePropertyRecursive(idx,clickedProperty, items, record, mode);
612 int rowCount = view->model()->rowCount(root);
615 for (
int i = 0; i < rowCount; i++) {
617 QModelIndex idx = view->model()->index(i, 0, root);
623 if (prop->isInStasis) {
633 result = stasisIsDirty(idx,clickedProperty, on, off);
641 int rowCount = view->model()->rowCount(root);
643 for (
int i = 0; i < rowCount; i++) {
644 QModelIndex idx = view->model()->index(i, 0, root);
650 prop->isInStasis =
false;
653 resetPropertyStateRecursive(idx,clickedProperty);
660 int rowCount = view->model()->rowCount(root);
662 for (
int i = 0; i < rowCount; i++) {
663 QModelIndex idx = view->model()->index(i, 0, root);
667 if (prop->isInStasis) {
668 prop->isInStasis =
false;
669 prop->state = QVariant(prop->stateInStasis);
674 restorePropertyInStasisRecursive(idx, clickedProperty);
682 const int rowCount = view->model()->rowCount(root);
683 for (
int i = 0; i < rowCount; i++){
684 QModelIndex idx = view->model()->index(i, 0, root);
688 if (prop->isInStasis) {
698 if (!index.isValid())
return;
700 getParentsIndex(items, index.parent());
705 qint32 childs = view->model()->rowCount(index);
708 for (quint16 i = 0; i < childs; ++i) {
709 child = view->model()->index(i, 0, index);
711 getChildrenIndex(items, child);
717 qint32 numberOfLeaves = view->model()->rowCount(index.parent());
720 for (quint16 i = 0; i < numberOfLeaves; ++i) {
721 item = view->model()->index(i, 0, index.parent());
732 const QRect rc =
iconsRect(option, index);
734 QTransform oldTransform =
p->transform();
735 QPen oldPen =
p->pen();
736 p->setTransform(QTransform::fromTranslate(rc.x(), rc.y()));
744 if (option.direction == Qt::RightToLeft) {
745 std::reverse(realProps.begin(), realProps.end());
752 bool fullColor = prop->
state.toBool() && option.state & QStyle::State_Enabled;
754 const qreal oldOpacity =
p->opacity();
764 colorRect = colorRect.marginsRemoved(QMargins(2, 1, 2, 1));
766 p->drawRect(colorRect);
768 p->drawPixmap(x, y, icon.pixmap(scm.
iconSize(), QIcon::Normal));
770 p->setOpacity(oldOpacity);
781 if (!(option.state & QStyle::State_Enabled)) {
789 p->drawRect(colorRect);
792 p->setTransform(oldTransform);
805 rc.moveCenter(option.rect.center());
807 if (option.direction == Qt::RightToLeft) {
808 rc.moveRight(option.rect.right());
810 rc.moveLeft(option.rect.left());
824 rc.moveTop(option.rect.topLeft().y());
827 if (option.direction == Qt::RightToLeft) {
848 QIcon icon = prop->state.toBool() ? prop->onIcon : prop->offIcon;
851 const qreal oldOpacity =
p->opacity();
853 if (!prop->state.toBool()) {
857 QPixmap pixmapIcon(icon.pixmap(scm.
visibilitySize(), QIcon::Active));
858 p->drawPixmap(fitRect.x(), fitRect.center().y() - scm.
visibilitySize() / 2, pixmapIcon);
860 if (prop->isInStasis) {
861 QPainter::CompositionMode prevComposition =
p->compositionMode();
862 p->setCompositionMode(QPainter::CompositionMode_HardLight);
864 QBitmap mask = pixmapIcon.mask();
865 pixmapIcon.fill(
d->
view->palette().color(QPalette::Highlight));
866 pixmapIcon.setMask(mask);
867 p->drawPixmap(fitRect.x(), fitRect.center().y() - scm.
visibilitySize() / 2, pixmapIcon);
868 p->setCompositionMode(prevComposition);
871 p->setOpacity(oldOpacity);
883 QIcon icon = index.data(Qt::DecorationRole).value<QIcon>();
885 if (!icon.isNull()) {
887 (option.state & QStyle::State_Enabled) ?
888 QIcon::Normal : QIcon::Disabled);
895 const qreal oldOpacity =
p->opacity();
897 if (!(option.state & QStyle::State_Enabled)) {
901 p->drawPixmap(rc.topLeft()-QPoint(0, 1), pixmap);
903 p->setOpacity(oldOpacity);
919 if (!(option.state & QStyle::State_Children))
return;
921 QString iconName = option.state & QStyle::State_Open ?
922 "arrow-down" : ((option.direction == Qt::RightToLeft) ?
"arrow-left" :
"arrow-right");
924 QPixmap pixmap = icon.pixmap(rc.width(),
925 (option.state & QStyle::State_Enabled) ?
926 QIcon::Normal : QIcon::Disabled);
927 p->drawPixmap(rc.bottomLeft()-QPoint(0, scm.
decorationSize()-1), pixmap);
940 if (!isAnimated)
return;
942 if ((option.state & QStyle::State_Children))
return;
944 const qreal oldOpacity =
p->opacity();
946 if (!(option.state & QStyle::State_Enabled)) {
952 QPixmap animPixmap = animatedIndicatorIcon.pixmap(decorationSize,
953 (option.state & QStyle::State_Enabled) ?
954 QIcon::Normal : QIcon::Disabled);
956 p->drawPixmap(rc.bottomLeft()-QPoint(0, scm.
decorationSize()-1), animPixmap);
958 p->setOpacity(oldOpacity);
962 const QModelIndex &index, QStyle *style)
const
964 QStyleOptionButton buttonOption;
967 QRect rect = option.rect;
973 constexpr qint32 maximumAllowedSideLength = 48;
974 const qint32 minimumSideLength = qMin(rect.width(), rect.height());
975 const qint32 sideLength = qMin(minimumSideLength, maximumAllowedSideLength);
977 QRect(rect.left() +
static_cast<qint32
>(qRound(
static_cast<qreal
>(rect.width() - sideLength) / 2.0)),
978 rect.top() +
static_cast<qint32
>(qRound(
static_cast<qreal
>(rect.height() - sideLength) / 2.0)),
979 sideLength, sideLength);
981 buttonOption.rect = rect;
985 const QColor prevBaseColor = buttonOption.palette.base().color();
986 const qint32 windowLightness = buttonOption.palette.window().color().lightness();
987 const qint32 baseLightness = prevBaseColor.lightness();
988 const QColor newBaseColor =
989 baseLightness > windowLightness ? prevBaseColor.lighter(120) : prevBaseColor.darker(120);
990 buttonOption.palette.setColor(QPalette::Window, prevBaseColor);
991 buttonOption.palette.setColor(QPalette::Base, newBaseColor);
994 buttonOption.state.setFlag((
d->
view->selectionModel()->isRowSelected(index.row(), index.parent())
996 : QStyle::State_Off));
997 style->drawPrimitive(QStyle::PE_IndicatorCheckBox, &buttonOption,
p);
1000boost::optional<KisBaseNode::Property>
1005 const QRect
iconsRect = q->iconsRect(option, index);
1007 const bool iconsClicked =
iconsRect.isValid() &&
1010 if (!iconsClicked)
return boost::none;
1014 if (option.direction == Qt::RightToLeft) {
1015 std::reverse(realProps.begin(), realProps.end());
1017 const int numProps = realProps.size();
1020 const int xPos = mousePos.x() -
iconsRect.left();
1021 const int clickedIcon = xPos / iconWidth;
1022 const int distToBorder = qMin(xPos % iconWidth, iconWidth - xPos % iconWidth);
1025 if (clickedIcon >= 0 &&
1026 clickedIcon < numProps &&
1027 realProps[clickedIcon] &&
1030 return *realProps[clickedIcon];
1039 if (event->type() == QEvent::MouseButtonRelease &&index.flags() & Qt::ItemIsEnabled) {
1041 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
1042 auto clickedProperty =
d->
propForMousePos(index, mouseEvent->pos(), option);
1043 if (!clickedProperty && mouseEvent->modifiers() == Qt::ControlModifier) {
1052 if ((event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick)
1053 && (index.flags() & Qt::ItemIsEnabled))
1055 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
1057 const bool leftButton = mouseEvent->buttons() & Qt::LeftButton;
1058 const bool altButton = mouseEvent->modifiers() & Qt::AltModifier;
1063 const bool visibilityClicked = visibilityRect.isValid() && visibilityRect.contains(mouseEvent->pos());
1064 if (leftButton && visibilityClicked) {
1067 if (!clickedProperty)
return false;
1069 d->
toggleProperty(props, clickedProperty, mouseEvent->modifiers(), index);
1075 if (leftButton && option.rect.contains(mouseEvent->pos())) {
1082 const bool thumbnailClicked = thumbnailRect.isValid() &&
1083 thumbnailRect.contains(mouseEvent->pos());
1086 const bool decorationClicked = decorationRect.isValid() &&
1087 decorationRect.contains(mouseEvent->pos());
1090 const bool filterColorClicked =
1092 filterRect.isValid() &&
1093 filterRect.contains(mouseEvent->pos());
1096 if (decorationClicked) {
1097 bool isExpandable = model->hasChildren(index);
1099 bool isExpanded =
d->
view->isExpanded(index);
1100 d->
view->setExpanded(index, !isExpanded);
1104 }
else if (thumbnailClicked) {
1105 bool hasCorrectModifier =
false;
1108 if (mouseEvent->modifiers() == Qt::ControlModifier) {
1110 hasCorrectModifier =
true;
1111 }
else if (mouseEvent->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) {
1113 hasCorrectModifier =
true;
1114 }
else if (mouseEvent->modifiers() == (Qt::ControlModifier | Qt::AltModifier)) {
1116 hasCorrectModifier =
true;
1117 }
else if (mouseEvent->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier | Qt::AltModifier)) {
1119 hasCorrectModifier =
true;
1122 if (hasCorrectModifier) {
1125 d->
view->setCurrentIndex(index);
1127 return hasCorrectModifier;
1129 }
else if (filterColorClicked) {
1134 auto clickedProperty =
d->
propForMousePos(index, mouseEvent->pos(), option);
1136 if (!clickedProperty) {
1138 d->
view->setCurrentIndex(index);
1147 d->
toggleProperty(props, &(*clickedProperty), mouseEvent->modifiers(), index);
1152 else if (event->type() == QEvent::ToolTip) {
1154 QHelpEvent *helpEvent =
static_cast<QHelpEvent*
>(event);
1156 auto hoveredProperty =
d->
propForMousePos(index, helpEvent->pos(), option);
1157 if (hoveredProperty &&
1160 QToolTip::showText(helpEvent->globalPos(), hoveredProperty->state.toString(),
d->
view);
1173 QItemSelectionModel *selectionModel =
d->
view->selectionModel();
1174 const bool wasSelected = selectionModel->isRowSelected(index.row(), index.parent());
1178 if (selectionModel->selectedIndexes().size() == 1
1179 && selectionModel->isRowSelected(index.row(), index.parent())) {
1180 selectionModel->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
1182 selectionModel->select(index, QItemSelectionModel::Toggle | QItemSelectionModel::Rows);
1185 const auto belongToSameRow = [](
const QModelIndex &a,
const QModelIndex &b) {
1186 return a.row() == b.row() && a.parent() == b.parent();
1190 if (wasSelected && belongToSameRow(selectionModel->currentIndex(), index)) {
1191 selectionModel->setCurrentIndex(selectionModel->selectedRows().last(), QItemSelectionModel::NoUpdate);
1199 const QString &text = index.data(Qt::DisplayRole).toString();
1200 d->
edit =
new QLineEdit(text, parent);
1201 d->
edit->setFocusPolicy(Qt::StrongFocus);
1208 QLineEdit *edit = qobject_cast<QLineEdit*>(widget);
1211 model->setData(index, edit->text(), Qt::DisplayRole);
1217 widget->setGeometry(option.rect);
1223 d->
toggleProperty(props, visibilityProperty, Qt::ShiftModifier, index);
1232 switch (event->type()) {
1233 case QEvent::MouseButtonPress: {
1235 QMouseEvent *me =
static_cast<QMouseEvent*
>(event);
1236 if (!QRect(
d->
edit->mapToGlobal(QPoint()),
d->
edit->size()).contains(me->globalPos())) {
1237 Q_EMIT commitData(
d->
edit);
1238 Q_EMIT closeEditor(
d->
edit);
1242 case QEvent::KeyPress: {
1243 QLineEdit *edit = qobject_cast<QLineEdit*>(
object);
1244 if (edit && edit ==
d->
edit) {
1245 QKeyEvent *ke =
static_cast<QKeyEvent*
>(event);
1246 switch (ke->key()) {
1247 case Qt::Key_Escape:
1248 Q_EMIT closeEditor(edit);
1251 Q_EMIT commitData(edit);
1252 Q_EMIT closeEditor(edit, EditNextItem);
1254 case Qt::Key_Backtab:
1255 Q_EMIT commitData(edit);
1256 Q_EMIT closeEditor(edit, EditPreviousItem);
1258 case Qt::Key_Return:
1260 Q_EMIT commitData(edit);
1261 Q_EMIT closeEditor(edit);
1267 case QEvent::ShortcutOverride : {
1268 QLineEdit *edit = qobject_cast<QLineEdit*>(
object);
1269 if (edit && edit ==
d->
edit){
1270 auto* key =
static_cast<QKeyEvent*
>(event);
1271 if (key->modifiers() == Qt::NoModifier){
1272 switch (key->key()){
1273 case Qt::Key_Escape:
1275 case Qt::Key_Backtab:
1276 case Qt::Key_Return:
1286 case QEvent::FocusOut : {
1287 QLineEdit *edit = qobject_cast<QLineEdit*>(
object);
1288 if (edit && edit ==
d->
edit) {
1289 Q_EMIT commitData(edit);
1290 Q_EMIT closeEditor(edit);
1296 return QAbstractItemDelegate::eventFilter(
object, event);
1305 QStyleOptionViewItem option = o;
1306 QVariant
v = index.data(Qt::FontRole);
1308 option.font =
v.value<QFont>();
1309 option.fontMetrics = QFontMetrics(option.font);
1311 v = index.data(Qt::TextAlignmentRole);
1313 option.displayAlignment = QFlag(
v.toInt());
1314 v = index.data(Qt::ForegroundRole);
1316 option.palette.setColor(QPalette::Text,
v.value<QColor>());
1317 v = index.data(Qt::BackgroundRole);
1319 option.palette.setColor(QPalette::Window,
v.value<QColor>());
1327 if (!
value.isNull() && (
value.toInt() >= 0 &&
value.toInt() <= 100)) {
1335 const QRect iconsRectR =
iconsRect(option, index);
1336 const int height = 5;
1337 const QRect rc = QRect(
1338 ((option.direction == Qt::RightToLeft) ?
1339 iconsRectR.bottomRight() :
1340 thumbnailRect.bottomRight()) - QPoint(0, height),
1341 ((option.direction == Qt::RightToLeft) ?
1342 thumbnailRect.bottomLeft() :
1343 iconsRectR.bottomLeft()));
1348 QStyle* style = QApplication::style();
1349 QStyleOptionProgressBar opt;
1354 opt.progress =
value.toInt();
1355 opt.textVisible =
false;
1356 opt.textAlignment = Qt::AlignHCenter;
1357 opt.text = i18n(
"%1 %", opt.progress);
1358 opt.state = option.state;
1359 style->drawControl(QStyle::CE_ProgressBar, &opt,
p, 0);
1379 if ((
d->
checkers.width() != 2 * step) ||
1385 d->
checkers = QImage(2 * step, 2 * step, QImage::Format_ARGB32);
1388 gc.fillRect(QRect(0, 0, step, step), newCheckersColor1);
1389 gc.fillRect(QRect(step, 0, step, step), newCheckersColor2);
1390 gc.fillRect(QRect(step, step, step, step), newCheckersColor1);
1391 gc.fillRect(QRect(0, step, step, step), newCheckersColor2);
1396 Q_EMIT sizeHintChanged(QModelIndex());
1408 QModelIndex root = view->rootIndex();
1409 int childs = view->model()->rowCount(root);
1411 QModelIndex firstChild = view->model()->index(0, 0, root);
1424 const QRect icons =
iconsRect(option, index);
1431 if (option.direction == Qt::RightToLeft) {
1433 rc.setRect(0, 0, icons.width() - dx, icons.height());
1436 rc.setRect(dx, 0, icons.width() - dx, icons.height());
1438 rc = rc.marginsRemoved(QMargins(8, 10, 8, 10));
1440 rc.translate(icons.x(), icons.y());
float value(const T *src, size_t ch)
KisBaseNode::Property * OptionalProperty
static KisConfigNotifier * instance()
LayerInfoTextStyle layerInfoTextStyle(bool defaultValue=false) const
QColor checkersColor2(bool defaultValue=false) const
bool useInlineLayerInfoText(bool defaultValue=false) const
QColor checkersColor1(bool defaultValue=false) const
bool hidePopups(bool defaultValue=false) const
int layerInfoTextOpacity(bool defaultValue=false) const
static const KoID layerColorSpaceMismatch
static const KoID layerError
static const KoID inheritAlpha
static const KoID alphaLocked
static const KoID colorOverlay
static const KoID visible
static KisLayerPropertiesIcons * instance()
@ FilterMaskPropertiesRole
@ LayerColorOverlayColorRole
@ LayerColorOverlayPropertiesRole
@ ProgressRole
Use to communicate a progress report to the section delegate on an action (a value of -1 or a QVarian...
@ PropertiesRole
A list of properties the part has.
QColor colorFromLabelIndex(int index) const
int thumbnailSize() const
int visibilityColumnWidth() const
int visibilitySize() const
QRect relVisibilityRect() const
QColor gridColor(const QStyleOptionViewItem &option, QTreeView *view) const
static KisNodeViewColorScheme * instance()
int decorationSize() const
int visibilityMargin() const
QRect relThumbnailRect() const
int thumbnailMargin() const
QRect relDecorationRect() const
int decorationMargin() const
QList< OptionalProperty > rightmostProperties(const KisBaseNode::PropertyList &props) const
void restorePropertyInStasisRecursive(const QModelIndex &root, const OptionalProperty &clickedProperty)
bool stasisIsDirty(const QModelIndex &root, const OptionalProperty &clickedProperty, bool on=false, bool off=false)
int numProperties(const QModelIndex &index) const
void getChildrenIndex(QList< QModelIndex > &items, const QModelIndex &index)
OptionalProperty findProperty(KisBaseNode::PropertyList &props, const OptionalProperty &refProp) const
boost::optional< KisBaseNode::Property > propForMousePos(const QModelIndex &index, const QPoint &mousePos, const QStyleOptionViewItem &option)
Private(NodeDelegate *_q, NodeView *_view)
void getSiblingsIndex(QList< QModelIndex > &items, const QModelIndex &index)
bool checkImmediateStasis(const QModelIndex &root, const OptionalProperty &clickedProperty)
void getParentsIndex(QList< QModelIndex > &items, const QModelIndex &index)
OptionalProperty findVisibilityProperty(KisBaseNode::PropertyList &props) const
void resetPropertyStateRecursive(const QModelIndex &root, const OptionalProperty &clickedProperty)
QList< QModelIndex > shiftClickedIndexes
void togglePropertyRecursive(const QModelIndex &root, const OptionalProperty &clickedProperty, const QList< QModelIndex > &items, StasisOperation record, bool mode)
void toggleProperty(KisBaseNode::PropertyList &props, const OptionalProperty clickedProperty, const Qt::KeyboardModifiers modifier, const QModelIndex &index)
void drawBranches(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const
void drawFrame(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const
void drawProgressBar(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const
void drawText(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const
QRect textRect(const QStyleOptionViewItem &option, const QModelIndex &index) const
void drawIcons(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const
void resetVisibilityStasis()
void changeSelectionAndCurrentIndex(const QModelIndex &index)
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
QRect thumbnailClickRect(const QStyleOptionViewItem &option, const QModelIndex &index) const
static QStyleOptionViewItem getOptions(const QStyleOptionViewItem &option, const QModelIndex &index)
bool eventFilter(QObject *object, QEvent *event) override
QRect decorationClickRect(const QStyleOptionViewItem &option, const QModelIndex &index) const
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
QRect filterColorClickRect(const QStyleOptionViewItem &option, const QModelIndex &index) const
void toggleSolo(const QModelIndex &index)
QRect iconsRect(const QStyleOptionViewItem &option, const QModelIndex &index) const
QRect visibilityClickRect(const QStyleOptionViewItem &option, const QModelIndex &index) const
void drawThumbnail(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
NodeDelegate(NodeView *view, QObject *parent=0)
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
void drawAnimatedDecoration(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const
void drawVisibilityIcon(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const
void drawSelectedButton(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index, QStyle *style) const
void drawColorLabel(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const
void drawDecoration(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const
void drawExpandButton(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
T kisGrowRect(const T &rect, U offset)
QIcon loadIcon(const QString &name)
QColor blendColors(const QColor &c1, const QColor &c2, qreal r1)
void renderExactRect(QPainter *p, const QRect &rc)
auto mem_equal_to(MemTypeNoRef Class::*ptr, MemType &&value)
mem_equal_to is an unary functor that compares a member of the object to a given value