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)
95 QApplication::instance()->installEventFilter(
this);
112 return QSize(option.rect.width(),
d->
rowHeight);
120 QStyleOptionViewItem option =
getOptions(o, index);
121 QStyle *style = option.widget ? option.widget->style() : QApplication::style();
122 style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option,
p, option.widget);
126 option.state &= ~QStyle::State_Enabled;
136 p->setFont(option.font);
157 QModelIndex
tmp = index.parent();
160 if (!
tmp.isValid())
return;
164 int rtlNum = (option.direction == Qt::RightToLeft) ? 1 : -1;
165 QPoint nodeCorner = (option.direction == Qt::RightToLeft) ? option.rect.topLeft() : option.rect.topRight();
166 int branchSpacing = rtlNum *
d->
view->indentation();
168 QPoint base = nodeCorner + 0.5 * QPoint(branchSpacing, option.rect.height()) + QPoint(0, scm.
iconSize()/4);
171 QColor bgColor = option.state & QStyle::State_Selected ?
172 qApp->palette().color(QPalette::Base) :
173 qApp->palette().color(QPalette::Text);
178 p->setPen(QPen(color, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
180 QPoint
p2 = base - QPoint(rtlNum*(qMin(
d->
view->indentation(), scm.
iconSize())/2), 0);
181 QPoint
p3 = base - QPoint(0, scm.
iconSize()/2);
182 p->drawLine(base,
p2);
183 p->drawLine(base,
p3);
186 QPoint parentBase1 = base + QPoint(branchSpacing, 0);
187 QPoint parentBase2 =
p3 + QPoint(branchSpacing, 0);
191 p->setPen(QPen(color, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
194 int levelRowIndex =
tmp.row();
197 while (
tmp.isValid()) {
198 bool moreSiblings = index.model()->rowCount(
tmp) > (levelRowIndex + 1);
200 p->drawLine(parentBase1, parentBase2);
203 parentBase1 += QPoint(branchSpacing, 0);
204 parentBase2 += QPoint(branchSpacing, 0);
206 levelRowIndex =
tmp.row();
216 if (color.alpha() <= 0)
return;
218 QColor bgColor = qApp->palette().color(QPalette::Base);
221 QRect optionRect = (option.state & QStyle::State_Selected) ?
iconsRect(option, index) : option.rect;
223 p->fillRect(optionRect, color);
230 QPen oldPen =
p->pen();
235 const QRect iconsRectR =
iconsRect(option, index);
237 const float bottomY = thumbnailRect.bottomLeft().y();
239 QPoint bottomLeftPoint;
240 QPoint bottomRightPoint;
241 if (option.direction == Qt::RightToLeft) {
242 bottomLeftPoint = iconsRectR.bottomLeft();
243 bottomRightPoint = visibilityRect.bottomRight();
245 bottomLeftPoint = visibilityRect.bottomLeft();
246 bottomRightPoint = iconsRectR.bottomRight();
250 p->drawLine(bottomLeftPoint.x(), bottomY,
251 bottomRightPoint.x(), bottomY);
271 rc.moveTop(option.rect.topLeft().y());
273 if (option.direction == Qt::RightToLeft) {
274 rc.moveRight(option.rect.right());
276 rc.moveLeft(option.rect.left());
286 const qreal devicePixelRatio =
p->device()->devicePixelRatioF();
289 const qreal oldOpacity =
p->opacity();
292 img.setDevicePixelRatio(devicePixelRatio);
293 if (!(option.state & QStyle::State_Enabled)) {
302 offset.setX((fitRect.width() - img.width()/devicePixelRatio) / 2);
303 offset.setY((fitRect.height() - img.height()/devicePixelRatio) / 2);
304 offset += fitRect.topLeft();
307 p->setBrushOrigin(offset);
308 QRect imageRectLowRes = QRect(img.rect().topLeft(), img.rect().size()/devicePixelRatio);
309 p->fillRect(imageRectLowRes.translated(offset), brush);
311 p->drawImage(offset, img);
312 p->setOpacity(oldOpacity);
314 QRect borderRect =
kisGrowRect(imageRectLowRes, 1).translated(offset);
324 const int iconsWidth =
326 (propCount + 1) * scm.
border();
330 fitRect.moveTop(option.rect.topLeft().y());
332 if (option.direction == Qt::RightToLeft) {
333 fitRect.moveLeft(option.rect.topLeft().x());
335 fitRect.moveRight(option.rect.topRight().x());
346 static int minbearing = 1337 + 666;
347 if (minbearing == 2003 || f != option.font) {
349 minbearing = option.fontMetrics.minLeftBearing() + option.fontMetrics.minRightBearing();
353 const QRect iconRect =
iconsRect(option, index);
355 QRect rc = QRect((option.direction == Qt::RightToLeft) ? iconRect.topRight() : decoRect.topRight(),
356 (option.direction == Qt::RightToLeft) ? decoRect.bottomLeft() : iconRect.bottomLeft());
357 rc.adjust(-(scm.
border()+(minbearing/2)), 0,
358 (scm.
border()+(minbearing/2)), 0);
369 QPen oldPen =
p->pen();
370 const qreal oldOpacity =
p->opacity();
372 p->setPen(option.palette.color(QPalette::Active,QPalette::Text ));
374 if (!(option.state & QStyle::State_Enabled)) {
378 const QString text = index.data(Qt::DisplayRole).toString();
379 const QString elided =
p->fontMetrics().elidedText(text, Qt::ElideRight, rc.width());
382 p->drawText(rc, Qt::AlignLeft | Qt::AlignVCenter, elided);
386 if (infoText.isEmpty()) {
387 p->drawText(rc, Qt::AlignLeft | Qt::AlignVCenter, elided);
392 const int textHeight =
p->fontMetrics().height();
393 useOneLine = rc.height() < textHeight*2;
396 const int rectCenter = rc.height()/2;
397 const int nameWidth =
p->fontMetrics().horizontalAdvance(elided);
401 p->drawText(rc.adjusted(0, 0, 0, -rectCenter), Qt::AlignLeft | Qt::AlignBottom | Qt::TextSingleLine, elided);
404 p->drawText(rc.adjusted(0, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, elided);
408 QFont layerInfoTextFont =
p->font();
409 layerInfoTextFont.setBold(
false);
410 p->setFont(layerInfoTextFont);
411 if (option.state & QStyle::State_Enabled) {
415 const QString infoTextElided =
p->fontMetrics().elidedText(infoText, Qt::ElideRight, rc.width());
416 p->drawText(rc.adjusted(0, rectCenter, 0, 0), Qt::AlignLeft | Qt::AlignTop, infoTextElided);
419 const QString infoTextElided =
p->fontMetrics().elidedText(
" "+infoText, Qt::ElideRight, rc.width()-nameWidth);
420 p->drawText(rc.adjusted(nameWidth, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, infoTextElided);
427 p->setOpacity(oldOpacity);
438 KisBaseNode::PropertyList::const_iterator it = props.constBegin();
439 KisBaseNode::PropertyList::const_iterator end = props.constEnd();
440 for (; it != end; ++it) {
441 if (!it->isMutable &&
461 if (it != list.end()) {
462 std::rotate(list.begin(), it, std::next(it));
471 QMutableListIterator<OptionalProperty> i(prependList);
473 while (i.hasPrevious()) {
476 int emptyIndex = list.lastIndexOf(
nullptr);
477 if (emptyIndex < 0)
break;
479 list[emptyIndex] = val;
484 return prependList + list;
491 return realProps.size();
496 KisBaseNode::PropertyList::iterator it = props.begin();
497 KisBaseNode::PropertyList::iterator end = props.end();
498 for (; it != end; ++it) {
499 if (it->id == refProp->
id) {
509 KisBaseNode::PropertyList::iterator it = props.begin();
510 KisBaseNode::PropertyList::iterator end = props.end();
511 for (; it != end; ++it) {
522 QModelIndex root(view->rootIndex());
528 }
else if ((modifier & Qt::ShiftModifier) == Qt::ShiftModifier && clickedProperty->
canHaveStasis) {
534 int position = shiftClickedIndexes.indexOf(index);
537 (position < 0) ? StasisOperation::Review : StasisOperation::Restore;
539 shiftClickedIndexes.clear();
540 shiftClickedIndexes.push_back(index);
543 if (modifier == (Qt::ControlModifier | Qt::ShiftModifier)) {
545 items.insert(0, index);
546 getSiblingsIndex(items, index);
548 getParentsIndex(items, index);
549 getChildrenIndex(items, index);
551 togglePropertyRecursive(root, clickedProperty, items, record, mode);
558 const bool hasPropInStasis = (shiftClickedIndexes.count() > 0 || checkImmediateStasis(root, clickedProperty));
560 shiftClickedIndexes.clear();
562 restorePropertyInStasisRecursive(root, clickedProperty);
564 shiftClickedIndexes.clear();
566 resetPropertyStateRecursive(root, clickedProperty);
578 int rowCount = view->model()->rowCount(root);
580 for (
int i = 0; i < rowCount; i++) {
581 QModelIndex idx = view->model()->index(i, 0, root);
589 if (record == StasisOperation::Record) {
590 prop->stateInStasis = prop->state.toBool();
592 if (record == StasisOperation::Review || record == StasisOperation::Record) {
593 prop->isInStasis =
true;
595 prop->state = (items.contains(idx)) ? QVariant(
true) : QVariant(
false);
597 prop->state = (!items.contains(idx))? prop->state :
598 (items.at(0) == idx)? QVariant(
true) : QVariant(
false);
601 prop->state = QVariant(prop->stateInStasis);
602 prop->isInStasis =
false;
607 togglePropertyRecursive(idx,clickedProperty, items, record, mode);
614 int rowCount = view->model()->rowCount(root);
617 for (
int i = 0; i < rowCount; i++) {
619 QModelIndex idx = view->model()->index(i, 0, root);
625 if (prop->isInStasis) {
635 result = stasisIsDirty(idx,clickedProperty, on, off);
643 int rowCount = view->model()->rowCount(root);
645 for (
int i = 0; i < rowCount; i++) {
646 QModelIndex idx = view->model()->index(i, 0, root);
652 prop->isInStasis =
false;
655 resetPropertyStateRecursive(idx,clickedProperty);
662 int rowCount = view->model()->rowCount(root);
664 for (
int i = 0; i < rowCount; i++) {
665 QModelIndex idx = view->model()->index(i, 0, root);
669 if (prop->isInStasis) {
670 prop->isInStasis =
false;
671 prop->state = QVariant(prop->stateInStasis);
676 restorePropertyInStasisRecursive(idx, clickedProperty);
684 const int rowCount = view->model()->rowCount(root);
685 for (
int i = 0; i < rowCount; i++){
686 QModelIndex idx = view->model()->index(i, 0, root);
690 if (prop->isInStasis) {
700 if (!index.isValid())
return;
702 getParentsIndex(items, index.parent());
707 qint32 childs = view->model()->rowCount(index);
710 for (quint16 i = 0; i < childs; ++i) {
711 child = view->model()->index(i, 0, index);
713 getChildrenIndex(items, child);
719 qint32 numberOfLeaves = view->model()->rowCount(index.parent());
722 for (quint16 i = 0; i < numberOfLeaves; ++i) {
723 item = view->model()->index(i, 0, index.parent());
734 const QRect rc =
iconsRect(option, index);
736 QTransform oldTransform =
p->transform();
737 QPen oldPen =
p->pen();
738 p->setTransform(QTransform::fromTranslate(rc.x(), rc.y()));
746 if (option.direction == Qt::RightToLeft) {
747 std::reverse(realProps.begin(), realProps.end());
754 bool fullColor = prop->
state.toBool() && option.state & QStyle::State_Enabled;
756 const qreal oldOpacity =
p->opacity();
766 colorRect = colorRect.marginsRemoved(QMargins(2, 1, 2, 1));
768 p->drawRect(colorRect);
770 p->drawPixmap(x, y, icon.pixmap(scm.
iconSize(), QIcon::Normal));
772 p->setOpacity(oldOpacity);
783 if (!(option.state & QStyle::State_Enabled)) {
791 p->drawRect(colorRect);
794 p->setTransform(oldTransform);
807 rc.moveCenter(option.rect.center());
809 if (option.direction == Qt::RightToLeft) {
810 rc.moveRight(option.rect.right());
812 rc.moveLeft(option.rect.left());
826 rc.moveTop(option.rect.topLeft().y());
829 if (option.direction == Qt::RightToLeft) {
850 QIcon icon = prop->state.toBool() ? prop->onIcon : prop->offIcon;
853 const qreal oldOpacity =
p->opacity();
855 if (!prop->state.toBool()) {
859 QPixmap pixmapIcon(icon.pixmap(scm.
visibilitySize(), QIcon::Active));
860 p->drawPixmap(fitRect.x(), fitRect.center().y() - scm.
visibilitySize() / 2, pixmapIcon);
862 if (prop->isInStasis) {
863 QPainter::CompositionMode prevComposition =
p->compositionMode();
864 p->setCompositionMode(QPainter::CompositionMode_HardLight);
866 QBitmap mask = pixmapIcon.mask();
867 pixmapIcon.fill(
d->
view->palette().color(QPalette::Highlight));
868 pixmapIcon.setMask(mask);
869 p->drawPixmap(fitRect.x(), fitRect.center().y() - scm.
visibilitySize() / 2, pixmapIcon);
870 p->setCompositionMode(prevComposition);
873 p->setOpacity(oldOpacity);
885 QIcon icon = index.data(Qt::DecorationRole).value<QIcon>();
887 if (!icon.isNull()) {
889 (option.state & QStyle::State_Enabled) ?
890 QIcon::Normal : QIcon::Disabled);
897 const qreal oldOpacity =
p->opacity();
899 if (!(option.state & QStyle::State_Enabled)) {
903 p->drawPixmap(rc.topLeft()-QPoint(0, 1), pixmap);
905 p->setOpacity(oldOpacity);
921 if (!(option.state & QStyle::State_Children))
return;
923 QString iconName = option.state & QStyle::State_Open ?
924 "arrow-down" : ((option.direction == Qt::RightToLeft) ?
"arrow-left" :
"arrow-right");
926 QPixmap pixmap = icon.pixmap(rc.width(),
927 (option.state & QStyle::State_Enabled) ?
928 QIcon::Normal : QIcon::Disabled);
929 p->drawPixmap(rc.bottomLeft()-QPoint(0, scm.
decorationSize()-1), pixmap);
942 if (!isAnimated)
return;
944 if ((option.state & QStyle::State_Children))
return;
946 const qreal oldOpacity =
p->opacity();
948 if (!(option.state & QStyle::State_Enabled)) {
954 QPixmap animPixmap = animatedIndicatorIcon.pixmap(decorationSize,
955 (option.state & QStyle::State_Enabled) ?
956 QIcon::Normal : QIcon::Disabled);
958 p->drawPixmap(rc.bottomLeft()-QPoint(0, scm.
decorationSize()-1), animPixmap);
960 p->setOpacity(oldOpacity);
964 const QModelIndex &index, QStyle *style)
const
966 QStyleOptionButton buttonOption;
969 QRect
rect = option.rect;
975 constexpr qint32 maximumAllowedSideLength = 48;
976 const qint32 minimumSideLength = qMin(
rect.width(),
rect.height());
977 const qint32 sideLength = qMin(minimumSideLength, maximumAllowedSideLength);
979 QRect(
rect.left() +
static_cast<qint32
>(qRound(
static_cast<qreal
>(
rect.width() - sideLength) / 2.0)),
980 rect.top() +
static_cast<qint32
>(qRound(
static_cast<qreal
>(
rect.height() - sideLength) / 2.0)),
981 sideLength, sideLength);
983 buttonOption.rect =
rect;
987 const QColor prevBaseColor = buttonOption.palette.base().color();
988 const qint32 windowLightness = buttonOption.palette.window().color().lightness();
989 const qint32 baseLightness = prevBaseColor.lightness();
990 const QColor newBaseColor =
991 baseLightness > windowLightness ? prevBaseColor.lighter(120) : prevBaseColor.darker(120);
992 buttonOption.palette.setColor(QPalette::Window, prevBaseColor);
993 buttonOption.palette.setColor(QPalette::Base, newBaseColor);
996 buttonOption.state.setFlag((
d->
view->selectionModel()->isRowSelected(index.row(), index.parent())
998 : QStyle::State_Off));
999 style->drawPrimitive(QStyle::PE_IndicatorCheckBox, &buttonOption,
p);
1002boost::optional<KisBaseNode::Property>
1007 const QRect
iconsRect = q->iconsRect(option, index);
1009 const bool iconsClicked =
iconsRect.isValid() &&
1012 if (!iconsClicked)
return boost::none;
1016 if (option.direction == Qt::RightToLeft) {
1017 std::reverse(realProps.begin(), realProps.end());
1019 const int numProps = realProps.size();
1022 const int xPos = mousePos.x() -
iconsRect.left();
1023 const int clickedIcon = xPos / iconWidth;
1024 const int distToBorder = qMin(xPos % iconWidth, iconWidth - xPos % iconWidth);
1027 if (clickedIcon >= 0 &&
1028 clickedIcon < numProps &&
1029 realProps[clickedIcon] &&
1032 return *realProps[clickedIcon];
1040 if ((event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick)
1041 && (index.flags() & Qt::ItemIsEnabled))
1043 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
1045 const bool leftButton = mouseEvent->buttons() & Qt::LeftButton;
1046 const bool altButton = mouseEvent->modifiers() & Qt::AltModifier;
1051 const bool visibilityClicked = visibilityRect.isValid() && visibilityRect.contains(mouseEvent->pos());
1052 if (leftButton && visibilityClicked) {
1055 if (!clickedProperty)
return false;
1057 d->
toggleProperty(props, clickedProperty, mouseEvent->modifiers(), index);
1063 if (leftButton && option.rect.contains(mouseEvent->pos())) {
1070 const bool thumbnailClicked = thumbnailRect.isValid() &&
1071 thumbnailRect.contains(mouseEvent->pos());
1074 const bool decorationClicked = decorationRect.isValid() &&
1075 decorationRect.contains(mouseEvent->pos());
1078 const bool filterColorClicked =
1080 filterRect.isValid() &&
1081 filterRect.contains(mouseEvent->pos());
1084 if (decorationClicked) {
1085 bool isExpandable = model->hasChildren(index);
1087 bool isExpanded =
d->
view->isExpanded(index);
1088 d->
view->setExpanded(index, !isExpanded);
1092 }
else if (thumbnailClicked) {
1093 bool hasCorrectModifier =
false;
1096 if (mouseEvent->modifiers() == Qt::ControlModifier) {
1098 hasCorrectModifier =
true;
1099 }
else if (mouseEvent->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) {
1101 hasCorrectModifier =
true;
1102 }
else if (mouseEvent->modifiers() == (Qt::ControlModifier | Qt::AltModifier)) {
1104 hasCorrectModifier =
true;
1105 }
else if (mouseEvent->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier | Qt::AltModifier)) {
1107 hasCorrectModifier =
true;
1110 if (hasCorrectModifier) {
1113 d->
view->setCurrentIndex(index);
1115 return hasCorrectModifier;
1117 }
else if (filterColorClicked) {
1122 auto clickedProperty =
d->
propForMousePos(index, mouseEvent->pos(), option);
1124 if (!clickedProperty) {
1126 d->
view->setCurrentIndex(index);
1130 }
else if (mouseEvent->modifiers() == Qt::ControlModifier) {
1140 d->
toggleProperty(props, &(*clickedProperty), mouseEvent->modifiers(), index);
1145 else if (event->type() == QEvent::ToolTip) {
1147 QHelpEvent *helpEvent =
static_cast<QHelpEvent*
>(event);
1149 auto hoveredProperty =
d->
propForMousePos(index, helpEvent->pos(), option);
1150 if (hoveredProperty &&
1153 QToolTip::showText(helpEvent->globalPos(), hoveredProperty->state.toString(),
d->
view);
1159 }
else if (event->type() == QEvent::Leave) {
1168 QItemSelectionModel *selectionModel =
d->
view->selectionModel();
1169 const bool wasSelected = selectionModel->isRowSelected(index.row(), index.parent());
1173 if (selectionModel->selectedIndexes().size() == 1
1174 && selectionModel->isRowSelected(index.row(), index.parent())) {
1175 selectionModel->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
1177 selectionModel->select(index, QItemSelectionModel::Toggle | QItemSelectionModel::Rows);
1180 const auto belongToSameRow = [](
const QModelIndex &a,
const QModelIndex &b) {
1181 return a.row() == b.row() && a.parent() == b.parent();
1185 if (wasSelected && belongToSameRow(selectionModel->currentIndex(), index)) {
1186 selectionModel->setCurrentIndex(selectionModel->selectedRows().last(), QItemSelectionModel::NoUpdate);
1194 const QString &text = index.data(Qt::DisplayRole).toString();
1195 d->
edit =
new QLineEdit(text, parent);
1196 d->
edit->setFocusPolicy(Qt::StrongFocus);
1203 QLineEdit *edit = qobject_cast<QLineEdit*>(widget);
1206 model->setData(index, edit->text(), Qt::DisplayRole);
1212 widget->setGeometry(option.rect);
1218 d->
toggleProperty(props, visibilityProperty, Qt::ShiftModifier, index);
1227 switch (event->type()) {
1228 case QEvent::MouseButtonPress: {
1230 QMouseEvent *me =
static_cast<QMouseEvent*
>(event);
1231 if (!QRect(
d->
edit->mapToGlobal(QPoint()),
d->
edit->size()).contains(me->globalPos())) {
1232 Q_EMIT commitData(
d->
edit);
1233 Q_EMIT closeEditor(
d->
edit);
1237 case QEvent::KeyPress: {
1238 QLineEdit *edit = qobject_cast<QLineEdit*>(
object);
1239 if (edit && edit ==
d->
edit) {
1240 QKeyEvent *ke =
static_cast<QKeyEvent*
>(event);
1241 switch (ke->key()) {
1242 case Qt::Key_Escape:
1243 Q_EMIT closeEditor(edit);
1246 Q_EMIT commitData(edit);
1247 Q_EMIT closeEditor(edit, EditNextItem);
1249 case Qt::Key_Backtab:
1250 Q_EMIT commitData(edit);
1251 Q_EMIT closeEditor(edit, EditPreviousItem);
1253 case Qt::Key_Return:
1255 Q_EMIT commitData(edit);
1256 Q_EMIT closeEditor(edit);
1262 case QEvent::ShortcutOverride : {
1263 QLineEdit *edit = qobject_cast<QLineEdit*>(
object);
1264 if (edit && edit ==
d->
edit){
1265 auto* key =
static_cast<QKeyEvent*
>(event);
1266 if (key->modifiers() == Qt::NoModifier){
1267 switch (key->key()){
1268 case Qt::Key_Escape:
1270 case Qt::Key_Backtab:
1271 case Qt::Key_Return:
1281 case QEvent::FocusOut : {
1282 QLineEdit *edit = qobject_cast<QLineEdit*>(
object);
1283 if (edit && edit ==
d->
edit) {
1284 Q_EMIT commitData(edit);
1285 Q_EMIT closeEditor(edit);
1291 return QAbstractItemDelegate::eventFilter(
object, event);
1300 QStyleOptionViewItem option = o;
1301 QVariant
v = index.data(Qt::FontRole);
1303 option.font =
v.value<QFont>();
1304 option.fontMetrics = QFontMetrics(option.font);
1306 v = index.data(Qt::TextAlignmentRole);
1308 option.displayAlignment = QFlag(
v.toInt());
1309 v = index.data(Qt::ForegroundRole);
1311 option.palette.setColor(QPalette::Text,
v.value<QColor>());
1312 v = index.data(Qt::BackgroundRole);
1314 option.palette.setColor(QPalette::Window,
v.value<QColor>());
1322 if (!
value.isNull() && (
value.toInt() >= 0 &&
value.toInt() <= 100)) {
1330 const QRect iconsRectR =
iconsRect(option, index);
1331 const int height = 5;
1332 const QRect rc = QRect(
1333 ((option.direction == Qt::RightToLeft) ?
1334 iconsRectR.bottomRight() :
1335 thumbnailRect.bottomRight()) - QPoint(0, height),
1336 ((option.direction == Qt::RightToLeft) ?
1337 thumbnailRect.bottomLeft() :
1338 iconsRectR.bottomLeft()));
1343 QStyle* style = QApplication::style();
1344 QStyleOptionProgressBar opt;
1349 opt.progress =
value.toInt();
1350 opt.textVisible =
false;
1351 opt.textAlignment = Qt::AlignHCenter;
1352 opt.text = i18n(
"%1 %", opt.progress);
1353 opt.state = option.state;
1354 style->drawControl(QStyle::CE_ProgressBar, &opt,
p, 0);
1374 if ((
d->
checkers.width() != 2 * step) ||
1380 d->
checkers = QImage(2 * step, 2 * step, QImage::Format_ARGB32);
1383 gc.fillRect(QRect(0, 0, step, step), newCheckersColor1);
1384 gc.fillRect(QRect(step, 0, step, step), newCheckersColor2);
1385 gc.fillRect(QRect(step, step, step, step), newCheckersColor1);
1386 gc.fillRect(QRect(0, step, step, step), newCheckersColor2);
1391 Q_EMIT sizeHintChanged(QModelIndex());
1403 QModelIndex root = view->rootIndex();
1404 int childs = view->model()->rowCount(root);
1406 QModelIndex firstChild = view->model()->index(0, 0, root);
1419 const QRect icons =
iconsRect(option, index);
1426 if (option.direction == Qt::RightToLeft) {
1428 rc.setRect(0, 0, icons.width() - dx, icons.height());
1431 rc.setRect(dx, 0, icons.width() - dx, icons.height());
1433 rc = rc.marginsRemoved(QMargins(8, 10, 8, 10));
1435 rc.translate(icons.x(), icons.y());
float value(const T *src, size_t ch)
KisBaseNode::Property * OptionalProperty
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
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)
Private(NodeDelegate *_q)
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)
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