Commit d1d4b7c2 authored by hjk's avatar hjk Committed by Thomas Hartmann
Browse files

QmlDesigner: Several compile fixes



Change-Id: I6edff8970e5d20a381c165fc57384611cdf43913
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 9a774254
......@@ -33,6 +33,10 @@
#include "componentcore_constants.h"
#include "selectioncontext.h"
QT_BEGIN_NAMESPACE
class QAction;
QT_END_NAMESPACE
namespace QmlDesigner {
class AbstractDesignerAction
......
......@@ -30,6 +30,8 @@
#ifndef COMPONENTCORE_CONSTANTS_H
#define COMPONENTCORE_CONSTANTS_H
#include <QtGlobal>
namespace QmlDesigner {
namespace ComponentCoreConstants {
......
......@@ -235,17 +235,17 @@ public:
{}
virtual void updateContext()
{
m_action->setSelectionContext(m_selectionContext);
if (m_selectionContext.isValid()) {
m_action->setEnabled(isEnabled(m_selectionContext));
m_action->setVisible(isVisible(m_selectionContext));
this->m_action->setSelectionContext(this->m_selectionContext);
if (this->m_selectionContext.isValid()) {
this->m_action->setEnabled(this->isEnabled(this->m_selectionContext));
this->m_action->setVisible(this->isVisible(this->m_selectionContext));
m_action->setCheckable(true);
QmlItemNode itemNode = QmlItemNode(m_selectionContext.currentSingleSelectedNode());
this->m_action->setCheckable(true);
QmlItemNode itemNode = QmlItemNode(this->m_selectionContext.currentSingleSelectedNode());
if (itemNode.isValid())
m_action->setChecked(itemNode.instanceValue("visible").toBool());
this->m_action->setChecked(itemNode.instanceValue("visible").toBool());
else
m_action->setEnabled(false);
this->m_action->setEnabled(false);
}
}
};
......
......@@ -32,10 +32,113 @@
#include "modelnodecontextmenu.h"
#include "designeractionmanager.h"
#include <QAction>
#include <QMenu>
namespace QmlDesigner {
namespace SelectionContextFunctors {
struct Always {
bool operator() (const SelectionContext &) {
return true;
}
};
struct InBaseState {
bool operator() (const SelectionContext &selectionState) {
return selectionState.isInBaseState();
}
};
struct SingleSelection {
bool operator() (const SelectionContext &selectionState) {
return selectionState.singleSelected();
}
};
struct SelectionEnabled {
bool operator() (const SelectionContext &selectionState) {
return selectionState.showSelectionTools();
}
};
struct SelectionNotEmpty {
bool operator() (const SelectionContext &selectionState) {
return !selectionState.selectedModelNodes().isEmpty();
}
};
struct SingleSelectionNotRoot {
bool operator() (const SelectionContext &selectionState) {
return selectionState.singleSelected()
&& !selectionState.currentSingleSelectedNode().isRootNode();
}
};
template <class T1, class T2>
struct And {
bool operator() (const SelectionContext &selectionState) {
T1 t1;
T2 t2;
return t1(selectionState) && t2(selectionState);
}
};
template <class T1, class T2>
struct Or {
bool operator() (const SelectionContext &selectionState) {
T1 t1;
T2 t2;
return t1(selectionState) || t2(selectionState);
}
};
template <class T1>
struct Not {
bool operator() (const SelectionContext &selectionState) {
T1 t1;
return !t1(selectionState);
}
};
template <char* PROPERTYNAME>
struct SelectionHasProperty {
bool operator() (const SelectionContext &selectionState) {
foreach (const ModelNode &modelNode, selectionState.selectedModelNodes())
if (modelNode.hasProperty(QLatin1String(PROPERTYNAME)))
return true;
return false;
}
};
struct SelectionHasSameParent {
bool operator() (const SelectionContext &selectionState);
};
struct SelectionIsComponent {
bool operator() (const SelectionContext &selectionState);
};
struct SingleSelectionItemIsAnchored {
bool operator() (const SelectionContext &selectionState);
};
struct SingleSelectionItemNotAnchored {
bool operator() (const SelectionContext &selectionState);
};
struct SingleSelectedItem {
bool operator() (const SelectionContext &selectionState) {
QmlItemNode itemNode(selectionState.currentSingleSelectedNode());
return itemNode.isValid();
}
};
} //SelectionStateFunctors
class ComponentUtils {
public:
static void goIntoComponent(const ModelNode &modelNode);
......@@ -240,105 +343,6 @@ private:
const int m_priority;
};
namespace SelectionContextFunctors {
struct Always {
bool operator() (const SelectionContext &) {
return true;
}
};
struct InBaseState {
bool operator() (const SelectionContext &selectionState) {
return selectionState.isInBaseState();
}
};
struct SingleSelection {
bool operator() (const SelectionContext &selectionState) {
return selectionState.singleSelected();
}
};
struct SelectionEnabled {
bool operator() (const SelectionContext &selectionState) {
return selectionState.showSelectionTools();
}
};
struct SelectionNotEmpty {
bool operator() (const SelectionContext &selectionState) {
return !selectionState.selectedModelNodes().isEmpty();
}
};
struct SingleSelectionNotRoot {
bool operator() (const SelectionContext &selectionState) {
return selectionState.singleSelected()
&& !selectionState.currentSingleSelectedNode().isRootNode();
}
};
template <class T1, class T2>
struct And {
bool operator() (const SelectionContext &selectionState) {
T1 t1;
T2 t2;
return t1(selectionState) && t2(selectionState);
}
};
template <class T1, class T2>
struct Or {
bool operator() (const SelectionContext &selectionState) {
T1 t1;
T2 t2;
return t1(selectionState) || t2(selectionState);
}
};
template <class T1>
struct Not {
bool operator() (const SelectionContext &selectionState) {
T1 t1;
return !t1(selectionState);
}
};
template <char* PROPERTYNAME>
struct SelectionHasProperty {
bool operator() (const SelectionContext &selectionState) {
foreach (const ModelNode &modelNode, selectionState.selectedModelNodes())
if (modelNode.hasProperty(QLatin1String(PROPERTYNAME)))
return true;
return false;
}
};
struct SelectionHasSameParent {
bool operator() (const SelectionContext &selectionState);
};
struct SelectionIsComponent {
bool operator() (const SelectionContext &selectionState);
};
struct SingleSelectionItemIsAnchored {
bool operator() (const SelectionContext &selectionState);
};
struct SingleSelectionItemNotAnchored {
bool operator() (const SelectionContext &selectionState);
};
struct SingleSelectedItem {
bool operator() (const SelectionContext &selectionState) {
QmlItemNode itemNode(selectionState.currentSingleSelectedNode());
return itemNode.isValid();
}
};
} //SelectionStateFunctors
} //QmlDesigner
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment