Changeset View
Changeset View
Standalone View
Standalone View
plugins/dockers/layerdocker/NodeDelegate.cpp
Context not available. | |||||
60 | QColor checkersColor1; | 60 | QColor checkersColor1; | ||
---|---|---|---|---|---|
61 | QColor checkersColor2; | 61 | QColor checkersColor2; | ||
62 | 62 | | |||
63 | QHash<QModelIndex, QVariant> m_visible; | ||||
64 | bool m_recoverVisible = {false}; | ||||
65 | | ||||
63 | QList<OptionalProperty> rightmostProperties(const KisBaseNode::PropertyList &props) const; | 66 | QList<OptionalProperty> rightmostProperties(const KisBaseNode::PropertyList &props) const; | ||
64 | int numProperties(const QModelIndex &index) const; | 67 | int numProperties(const QModelIndex &index) const; | ||
65 | OptionalProperty findProperty(KisBaseNode::PropertyList &props, const OptionalProperty &refProp) const; | 68 | OptionalProperty findProperty(KisBaseNode::PropertyList &props, const OptionalProperty &refProp) const; | ||
66 | OptionalProperty findVisibilityProperty(KisBaseNode::PropertyList &props) const; | 69 | OptionalProperty findVisibilityProperty(KisBaseNode::PropertyList &props) const; | ||
67 | 70 | | |||
68 | void toggleProperty(KisBaseNode::PropertyList &props, OptionalProperty prop, bool controlPressed, const QModelIndex &index); | 71 | void toggleProperty(KisBaseNode::PropertyList &props, OptionalProperty prop, bool controlPressed, const QModelIndex &index); | ||
72 | void recordVisibilityStateRecursive(const QModelIndex &root, OptionalProperty clickedProperty, QModelIndex index); | ||||
73 | void recoverVisibilityStateRecursive(const QModelIndex &root, OptionalProperty clickedProperty, QModelIndex index); | ||||
69 | }; | 74 | }; | ||
70 | 75 | | |||
71 | NodeDelegate::NodeDelegate(NodeView *view, QObject *parent) | 76 | NodeDelegate::NodeDelegate(NodeView *view, QObject *parent) | ||
Context not available. | |||||
780 | KisBaseNode::PropertyList props = index.data(KisNodeModel::PropertiesRole).value<KisBaseNode::PropertyList>(); | 785 | KisBaseNode::PropertyList props = index.data(KisNodeModel::PropertiesRole).value<KisBaseNode::PropertyList>(); | ||
781 | OptionalProperty clickedProperty = d->findVisibilityProperty(props); | 786 | OptionalProperty clickedProperty = d->findVisibilityProperty(props); | ||
782 | if (!clickedProperty) return false; | 787 | if (!clickedProperty) return false; | ||
783 | d->toggleProperty(props, clickedProperty, mouseEvent->modifiers() == Qt::ControlModifier, index); | 788 | | ||
789 | if(mouseEvent->modifiers() == Qt::ShiftModifier) { | ||||
790 | if(d->m_recoverVisible) { | ||||
791 | d->recoverVisibilityStateRecursive(d->view->rootIndex(), clickedProperty, index); | ||||
792 | d->m_recoverVisible = false; | ||||
793 | } else { | ||||
794 | d->recordVisibilityStateRecursive(d->view->rootIndex(), clickedProperty, index); | ||||
795 | d->m_recoverVisible = true; | ||||
796 | } | ||||
797 | } else { | ||||
798 | d->toggleProperty(props, clickedProperty, mouseEvent->modifiers() == Qt::ControlModifier, index); | ||||
799 | } | ||||
784 | return true; | 800 | return true; | ||
785 | } else if (leftButton && decorationClicked) { | 801 | } else if (leftButton && decorationClicked) { | ||
786 | bool isExpandable = model->hasChildren(index); | 802 | bool isExpandable = model->hasChildren(index); | ||
Context not available. | |||||
1013 | { | 1029 | { | ||
1014 | KisLayerPropertiesIcons::instance()->updateIcons(); | 1030 | KisLayerPropertiesIcons::instance()->updateIcons(); | ||
1015 | } | 1031 | } | ||
1032 | | ||||
1033 | void NodeDelegate::Private::recordVisibilityStateRecursive(const QModelIndex &root, OptionalProperty clickedProperty, QModelIndex index) | ||||
1034 | { | ||||
1035 | int rowCount = view->model()->rowCount(root); | ||||
1036 | QModelIndex parent = index.parent(); | ||||
1037 | | ||||
1038 | for (int i = 0; i < rowCount; i++) { | ||||
1039 | QModelIndex idx = view->model()->index(i, 0, root); | ||||
1040 | if(idx != parent){ | ||||
1041 | KisBaseNode::PropertyList props = idx.data(KisNodeModel::PropertiesRole).value<KisBaseNode::PropertyList>(); | ||||
1042 | OptionalProperty prop = findVisibilityProperty(props); | ||||
1043 | m_visible.insert(idx,prop->state); | ||||
1044 | | ||||
1045 | // The entire property list has to be altered because model->setData cannot set individual properties | ||||
1046 | prop = findProperty(props, clickedProperty); | ||||
1047 | if (!prop) continue; | ||||
1048 | prop->state = (idx == index)? QVariant(true) : QVariant(false); // always show clicked index | ||||
1049 | view->model()->setData(idx, QVariant::fromValue(props), KisNodeModel::PropertiesRole); | ||||
1050 | } | ||||
1051 | | ||||
1052 | recordVisibilityStateRecursive(idx,clickedProperty, index); | ||||
1053 | } | ||||
1054 | } | ||||
1055 | | ||||
1056 | void NodeDelegate::Private::recoverVisibilityStateRecursive(const QModelIndex &root, OptionalProperty clickedProperty, QModelIndex index) | ||||
1057 | { | ||||
1058 | int rowCount = view->model()->rowCount(root); | ||||
1059 | QModelIndex parent = index.parent(); | ||||
1060 | | ||||
1061 | for (int i = 0; i < rowCount; i++) { | ||||
1062 | QModelIndex idx = view->model()->index(i, 0, root); | ||||
1063 | if(idx != parent){ | ||||
1064 | KisBaseNode::PropertyList props = idx.data(KisNodeModel::PropertiesRole).value<KisBaseNode::PropertyList>(); | ||||
1065 | OptionalProperty prop = findVisibilityProperty(props); | ||||
1066 | // get state from hash | ||||
1067 | | ||||
1068 | // The entire property list has to be altered because model->setData cannot set individual properties | ||||
1069 | prop = findProperty(props, clickedProperty); | ||||
1070 | if (!prop) continue; | ||||
1071 | prop->state = m_visible.take(idx); | ||||
1072 | view->model()->setData(idx, QVariant::fromValue(props), KisNodeModel::PropertiesRole); | ||||
1073 | } | ||||
1074 | recoverVisibilityStateRecursive(idx,clickedProperty, index); | ||||
1075 | } | ||||
1076 | } | ||||
Context not available. |