Vera++.
--HG-- branch : develop
This commit is contained in:
parent
9a735b29bf
commit
1d4f0a6a55
|
@ -190,7 +190,7 @@ void Calculator::InitVariables(const VContainer *data, const QMap<int, QString>
|
||||||
|
|
||||||
if (found == false)
|
if (found == false)
|
||||||
{
|
{
|
||||||
throw qmu::QmuParserError (ecUNASSIGNABLE_TOKEN , i.value(), formula, i.key());
|
throw qmu::QmuParserError (ecUNASSIGNABLE_TOKEN, i.value(), formula, i.key());
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -437,7 +437,7 @@ const QMap<QString, QSharedPointer<T> > VContainer::DataVar(const VarType &type)
|
||||||
QHash<QString, QSharedPointer<VInternalVariable> >::const_iterator i;
|
QHash<QString, QSharedPointer<VInternalVariable> >::const_iterator i;
|
||||||
for (i = d->variables.constBegin(); i != d->variables.constEnd(); ++i)
|
for (i = d->variables.constBegin(); i != d->variables.constEnd(); ++i)
|
||||||
{
|
{
|
||||||
if(i.value()->GetType() == type)
|
if (i.value()->GetType() == type)
|
||||||
{
|
{
|
||||||
QSharedPointer<T> var = GetVariable<T>(i.key());
|
QSharedPointer<T> var = GetVariable<T>(i.key());
|
||||||
map.insert(qApp->VarToUser(i.key()), var);
|
map.insert(qApp->VarToUser(i.key()), var);
|
||||||
|
|
|
@ -175,9 +175,9 @@ public:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void AddVariable(const QString& name, T *var)
|
void AddVariable(const QString& name, T *var)
|
||||||
{
|
{
|
||||||
if(d->variables.contains(name))
|
if (d->variables.contains(name))
|
||||||
{
|
{
|
||||||
if(d->variables.value(name)->GetType() == var->GetType())
|
if (d->variables.value(name)->GetType() == var->GetType())
|
||||||
{
|
{
|
||||||
d->variables[name].clear();
|
d->variables[name].clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ VFormula::VFormula()
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VFormula::VFormula(const QString &formula, const VContainer *container)
|
VFormula::VFormula(const QString &formula, const VContainer *container)
|
||||||
:formula(qApp->FormulaToUser(formula)), value(QString(tr("Error"))), checkZero(true), data(container), toolId(NULL_ID),
|
:formula(qApp->FormulaToUser(formula)), value(QString(tr("Error"))), checkZero(true), data(container),
|
||||||
postfix(QStringLiteral("")), _error(true), dValue(0)
|
toolId(NULL_ID), postfix(QStringLiteral("")), _error(true), dValue(0)
|
||||||
{
|
{
|
||||||
this->formula.replace("\n", " ");// Replace line return with spaces for calc if exist
|
this->formula.replace("\n", " ");// Replace line return with spaces for calc if exist
|
||||||
Eval();
|
Eval();
|
||||||
|
|
|
@ -48,7 +48,8 @@
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent)
|
DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent)
|
||||||
:DialogTool(data, NULL_ID, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0), m(nullptr)
|
:DialogTool(data, NULL_ID, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0),
|
||||||
|
m(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,7 @@ int main(int argc, char *argv[])
|
||||||
//Before we load pattern show window.
|
//Before we load pattern show window.
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
for(int i=0;i<args.size();++i)
|
for (int i=0;i<args.size();++i)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -767,7 +767,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MainWindow::customEvent(QEvent *event)
|
void MainWindow::customEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
if(event->type() == UNDO_EVENT)
|
if (event->type() == UNDO_EVENT)
|
||||||
{
|
{
|
||||||
qApp->getUndoStack()->undo();
|
qApp->getUndoStack()->undo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ private:
|
||||||
QString CheckPathToMeasurements(const QString &path, const MeasurementsType &patternType);
|
QString CheckPathToMeasurements(const QString &path, const MeasurementsType &patternType);
|
||||||
void OpenPattern(const QString &filePath);
|
void OpenPattern(const QString &filePath);
|
||||||
QComboBox *SetGradationList(const QString &label, const QStringList &list);
|
QComboBox *SetGradationList(const QString &label, const QStringList &list);
|
||||||
void ChangePP(int index , bool zoomBestFit = true);
|
void ChangePP(int index, bool zoomBestFit = true);
|
||||||
/**
|
/**
|
||||||
* @brief EndVisualization try show dialog after and working with tool visualization.
|
* @brief EndVisualization try show dialog after and working with tool visualization.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -393,4 +393,3 @@ void VToolBisector::setFirstPointId(const quint32 &value)
|
||||||
SaveOption(obj);
|
SaveOption(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -338,4 +338,3 @@ void VToolHeight::setP1LineId(const quint32 &value)
|
||||||
SaveOption(obj);
|
SaveOption(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -397,4 +397,3 @@ void VToolLineIntersect::setP1Line1(const quint32 &value)
|
||||||
SaveOption(obj);
|
SaveOption(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,4 +353,3 @@ void VToolNormal::ShowVisualization(bool show)
|
||||||
vis = nullptr;
|
vis = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -397,4 +397,3 @@ void VToolShoulderPoint::setP2Line(const quint32 &value)
|
||||||
SaveOption(obj);
|
SaveOption(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -354,7 +354,7 @@ void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||||
void VToolSpline::RefreshGeometry()
|
void VToolSpline::RefreshGeometry()
|
||||||
{
|
{
|
||||||
//this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
|
//this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
|
||||||
if(isHovered)
|
if (isHovered)
|
||||||
{
|
{
|
||||||
this->setPath(ToolPath(PathDirection::Show));
|
this->setPath(ToolPath(PathDirection::Show));
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,7 +417,7 @@ void VToolSplinePath::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &ob
|
||||||
*/
|
*/
|
||||||
void VToolSplinePath::RefreshGeometry()
|
void VToolSplinePath::RefreshGeometry()
|
||||||
{
|
{
|
||||||
if(isHovered)
|
if (isHovered)
|
||||||
{
|
{
|
||||||
this->setPath(ToolPath(PathDirection::Show));
|
this->setPath(ToolPath(PathDirection::Show));
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ qreal VisLine::CorrectAngle(const qreal &angle) const
|
||||||
ang = angle - 360 * qFloor(angle/360);
|
ang = angle - 360 * qFloor(angle/360);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(qFloor((qAbs(ang)+22.5)/45))
|
switch (qFloor((qAbs(ang)+22.5)/45))
|
||||||
{
|
{
|
||||||
case 0: // <22.5
|
case 0: // <22.5
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -86,7 +86,7 @@ qreal VisLine::CorrectAngle(const qreal &angle) const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const
|
QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const
|
||||||
{
|
{
|
||||||
if(this->scene() == nullptr)
|
if (this->scene() == nullptr)
|
||||||
{
|
{
|
||||||
QLineF line = QLineF(firstPoint, Visualization::scenePos);
|
QLineF line = QLineF(firstPoint, Visualization::scenePos);
|
||||||
line.setAngle(angle);
|
line.setAngle(angle);
|
||||||
|
|
|
@ -112,8 +112,3 @@ void VisToolSpline::setKCurve(const qreal &value)
|
||||||
{
|
{
|
||||||
kCurve = value;
|
kCurve = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ void VisToolTriangle::DrawAimedAxis(QGraphicsPathItem *item, const QLineF &line,
|
||||||
axis.setLength(arrow_step);
|
axis.setLength(arrow_step);
|
||||||
|
|
||||||
int steps = qFloor(line.length()/arrow_step);
|
int steps = qFloor(line.length()/arrow_step);
|
||||||
for(int i=0; i<steps; ++i)
|
for (int i=0; i<steps; ++i)
|
||||||
{
|
{
|
||||||
DrawArrow(axis, path, arrow_size);
|
DrawArrow(axis, path, arrow_size);
|
||||||
axis.setLength(axis.length()+arrow_step);
|
axis.setLength(axis.length()+arrow_step);
|
||||||
|
|
|
@ -2075,13 +2075,13 @@ void VApplication::restoreOverrideCursor(const QString &pixmapPath, int hotX, in
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QStringList VApplication::LabelLanguages()
|
QStringList VApplication::LabelLanguages()
|
||||||
{
|
{
|
||||||
QStringList list{"de" , // German
|
QStringList list{"de", // German
|
||||||
"en" , // English
|
"en", // English
|
||||||
"fr" , // French
|
"fr", // French
|
||||||
"ru" , // Russian
|
"ru", // Russian
|
||||||
"uk" , // Ukrainian
|
"uk", // Ukrainian
|
||||||
"hr" , // Croatian
|
"hr", // Croatian
|
||||||
"sr" , // Serbian
|
"sr", // Serbian
|
||||||
"bs" // Bosnian
|
"bs" // Bosnian
|
||||||
};
|
};
|
||||||
return list;
|
return list;
|
||||||
|
|
|
@ -62,18 +62,26 @@ VFormulaProperty::VFormulaProperty(const QString &name) :
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
QVariant VFormulaProperty::data (int column, int role) const
|
QVariant VFormulaProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
||||||
|
{
|
||||||
return getValue();
|
return getValue();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags VFormulaProperty::flags(int column) const
|
Qt::ItemFlags VFormulaProperty::flags(int column) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Name || column == DPC_Data)
|
if (column == DPC_Name || column == DPC_Data)
|
||||||
|
{
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -97,7 +105,7 @@ QWidget* VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewI
|
||||||
bool VFormulaProperty::setEditorData(QWidget* editor)
|
bool VFormulaProperty::setEditorData(QWidget* editor)
|
||||||
{
|
{
|
||||||
VFormulaPropertyEditor* tmpWidget = qobject_cast<VFormulaPropertyEditor*>(editor);
|
VFormulaPropertyEditor* tmpWidget = qobject_cast<VFormulaPropertyEditor*>(editor);
|
||||||
if(tmpWidget)
|
if (tmpWidget)
|
||||||
{
|
{
|
||||||
VFormula formula = VProperty::d_ptr->VariantValue.value<VFormula>();
|
VFormula formula = VProperty::d_ptr->VariantValue.value<VFormula>();
|
||||||
tmpWidget->setFormula(formula);
|
tmpWidget->setFormula(formula);
|
||||||
|
@ -113,7 +121,7 @@ bool VFormulaProperty::setEditorData(QWidget* editor)
|
||||||
QVariant VFormulaProperty::getEditorData(QWidget* editor) const
|
QVariant VFormulaProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
VFormulaPropertyEditor* tmpWidget = qobject_cast<VFormulaPropertyEditor*>(editor);
|
VFormulaPropertyEditor* tmpWidget = qobject_cast<VFormulaPropertyEditor*>(editor);
|
||||||
if(tmpWidget)
|
if (tmpWidget)
|
||||||
{
|
{
|
||||||
QVariant value;
|
QVariant value;
|
||||||
value.setValue(tmpWidget->getFormula());
|
value.setValue(tmpWidget->getFormula());
|
||||||
|
@ -132,19 +140,22 @@ QString VFormulaProperty::type() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VProperty *VFormulaProperty::clone(bool include_children, VProperty *container) const
|
VProperty *VFormulaProperty::clone(bool include_children, VProperty *container) const
|
||||||
{
|
{
|
||||||
if(!container) {
|
if (!container)
|
||||||
|
{
|
||||||
container = new VFormulaProperty(getName());
|
container = new VFormulaProperty(getName());
|
||||||
|
|
||||||
if(!include_children) {
|
if (!include_children)
|
||||||
|
{
|
||||||
QList<VProperty*> tmpChildren = container->getChildren();
|
QList<VProperty*> tmpChildren = container->getChildren();
|
||||||
foreach(VProperty* tmpChild, tmpChildren) {
|
foreach (VProperty* tmpChild, tmpChildren)
|
||||||
|
{
|
||||||
container->removeChild(tmpChild);
|
container->removeChild(tmpChild);
|
||||||
delete tmpChild;
|
delete tmpChild;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return VProperty::clone(false, container); // Child
|
return VProperty::clone(false, container); // Child
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,8 +184,10 @@ VFormula VFormulaProperty::getFormula() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VFormulaProperty::setFormula(const VFormula &formula)
|
void VFormulaProperty::setFormula(const VFormula &formula)
|
||||||
{
|
{
|
||||||
if(d_ptr->Children.count() < 2)
|
if (d_ptr->Children.count() < 2)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant value;
|
QVariant value;
|
||||||
value.setValue(formula);
|
value.setValue(formula);
|
||||||
|
|
|
@ -33,9 +33,7 @@
|
||||||
|
|
||||||
class VFormula;
|
class VFormula;
|
||||||
|
|
||||||
using namespace VPE;
|
class VFormulaProperty : public VPE::VProperty
|
||||||
|
|
||||||
class VFormulaProperty : public VProperty
|
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -50,8 +48,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
||||||
virtual bool setEditorData(QWidget* editor);
|
virtual bool setEditorData(QWidget* editor);
|
||||||
|
@ -64,7 +64,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent) :
|
||||||
ToolButton->setText(tr("..."));
|
ToolButton->setText(tr("..."));
|
||||||
ToolButton->setFixedWidth(20);
|
ToolButton->setFixedWidth(20);
|
||||||
ToolButton->installEventFilter(this);
|
ToolButton->installEventFilter(this);
|
||||||
setFocusProxy(ToolButton); // Make the ToolButton the focus proxy
|
setFocusProxy(ToolButton); // Make the ToolButton the focus proxy
|
||||||
setFocusPolicy(ToolButton->focusPolicy());
|
setFocusPolicy(ToolButton->focusPolicy());
|
||||||
connect(ToolButton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked()));
|
connect(ToolButton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked()));
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void VFormulaPropertyEditor::onToolButtonClicked()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool VFormulaPropertyEditor::eventFilter(QObject *obj, QEvent *ev)
|
bool VFormulaPropertyEditor::eventFilter(QObject *obj, QEvent *ev)
|
||||||
{
|
{
|
||||||
if(obj == ToolButton && (ev->type() == QEvent::KeyPress || ev->type() == QEvent::KeyPress))
|
if (obj == ToolButton && (ev->type() == QEvent::KeyPress || ev->type() == QEvent::KeyPress))
|
||||||
{
|
{
|
||||||
// Ignore the event, so that eventually the delegate gets the event.
|
// Ignore the event, so that eventually the delegate gets the event.
|
||||||
ev->ignore();
|
ev->ignore();
|
||||||
|
|
|
@ -267,4 +267,3 @@ void VMainGraphicsView::setShowToolOptions(bool value)
|
||||||
{
|
{
|
||||||
showToolOptions = value;
|
showToolOptions = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,6 @@ class QGraphicsItem;
|
||||||
class QScrollArea;
|
class QScrollArea;
|
||||||
class VFormula;
|
class VFormula;
|
||||||
|
|
||||||
using namespace VPE;
|
|
||||||
|
|
||||||
class VToolOptionsPropertyBrowser : public QObject
|
class VToolOptionsPropertyBrowser : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -50,19 +48,19 @@ public:
|
||||||
VToolOptionsPropertyBrowser(QDockWidget *parent);
|
VToolOptionsPropertyBrowser(QDockWidget *parent);
|
||||||
public slots:
|
public slots:
|
||||||
void itemClicked(QGraphicsItem *item);
|
void itemClicked(QGraphicsItem *item);
|
||||||
void userChangedData(VProperty* property);
|
void userChangedData(VPE::VProperty* property);
|
||||||
void UpdateOptions();
|
void UpdateOptions();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolOptionsPropertyBrowser)
|
Q_DISABLE_COPY(VToolOptionsPropertyBrowser)
|
||||||
|
|
||||||
VPropertyModel* PropertyModel;
|
VPE::VPropertyModel* PropertyModel;
|
||||||
VPropertyFormView* formView;
|
VPE::VPropertyFormView* formView;
|
||||||
|
|
||||||
QGraphicsItem *currentItem;
|
QGraphicsItem *currentItem;
|
||||||
QMap<VProperty *, QString> propertyToId;
|
QMap<VPE::VProperty *, QString> propertyToId;
|
||||||
QMap<QString, VProperty *> idToProperty;
|
QMap<QString, VPE::VProperty *> idToProperty;
|
||||||
|
|
||||||
void AddProperty(VProperty *property, const QString &id);
|
void AddProperty(VPE::VProperty *property, const QString &id);
|
||||||
void ShowItemOptions(QGraphicsItem *item);
|
void ShowItemOptions(QGraphicsItem *item);
|
||||||
|
|
||||||
template<class Tool>
|
template<class Tool>
|
||||||
|
@ -78,24 +76,24 @@ private:
|
||||||
|
|
||||||
QStringList PropertiesList() const;
|
QStringList PropertiesList() const;
|
||||||
|
|
||||||
void ChangeDataToolSinglePoint(VProperty *property);
|
void ChangeDataToolSinglePoint(VPE::VProperty *property);
|
||||||
void ChangeDataToolEndLine(VProperty *property);
|
void ChangeDataToolEndLine(VPE::VProperty *property);
|
||||||
void ChangeDataToolAlongLine(VProperty *property);
|
void ChangeDataToolAlongLine(VPE::VProperty *property);
|
||||||
void ChangeDataToolArc(VProperty *property);
|
void ChangeDataToolArc(VPE::VProperty *property);
|
||||||
void ChangeDataToolBisector(VProperty *property);
|
void ChangeDataToolBisector(VPE::VProperty *property);
|
||||||
void ChangeDataToolCutArc(VProperty *property);
|
void ChangeDataToolCutArc(VPE::VProperty *property);
|
||||||
void ChangeDataToolCutSpline(VProperty *property);
|
void ChangeDataToolCutSpline(VPE::VProperty *property);
|
||||||
void ChangeDataToolCutSplinePath(VProperty *property);
|
void ChangeDataToolCutSplinePath(VPE::VProperty *property);
|
||||||
void ChangeDataToolHeight(VProperty *property);
|
void ChangeDataToolHeight(VPE::VProperty *property);
|
||||||
void ChangeDataToolLine(VProperty *property);
|
void ChangeDataToolLine(VPE::VProperty *property);
|
||||||
void ChangeDataToolLineIntersect(VProperty *property);
|
void ChangeDataToolLineIntersect(VPE::VProperty *property);
|
||||||
void ChangeDataToolNormal(VProperty *property);
|
void ChangeDataToolNormal(VPE::VProperty *property);
|
||||||
void ChangeDataToolPointOfContact(VProperty *property);
|
void ChangeDataToolPointOfContact(VPE::VProperty *property);
|
||||||
void ChangeDataToolPointOfIntersection(VProperty *property);
|
void ChangeDataToolPointOfIntersection(VPE::VProperty *property);
|
||||||
void ChangeDataToolShoulderPoint(VProperty *property);
|
void ChangeDataToolShoulderPoint(VPE::VProperty *property);
|
||||||
void ChangeDataToolSpline(VProperty *property);
|
void ChangeDataToolSpline(VPE::VProperty *property);
|
||||||
void ChangeDataToolSplinePath(VProperty *property);
|
void ChangeDataToolSplinePath(VPE::VProperty *property);
|
||||||
void ChangeDataToolTriangle(VProperty *property);
|
void ChangeDataToolTriangle(VPE::VProperty *property);
|
||||||
|
|
||||||
void ShowOptionsToolSinglePoint(QGraphicsItem *item);
|
void ShowOptionsToolSinglePoint(QGraphicsItem *item);
|
||||||
void ShowOptionsToolEndLine(QGraphicsItem *item);
|
void ShowOptionsToolEndLine(QGraphicsItem *item);
|
||||||
|
|
|
@ -201,7 +201,7 @@ qreal VAbstractMeasurements::UnitConvertor(qreal value, const Unit &from, const
|
||||||
switch (from)
|
switch (from)
|
||||||
{
|
{
|
||||||
case Unit::Mm:
|
case Unit::Mm:
|
||||||
switch(to)
|
switch (to)
|
||||||
{
|
{
|
||||||
case Unit::Mm:
|
case Unit::Mm:
|
||||||
return value;
|
return value;
|
||||||
|
@ -214,7 +214,7 @@ qreal VAbstractMeasurements::UnitConvertor(qreal value, const Unit &from, const
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Unit::Cm:
|
case Unit::Cm:
|
||||||
switch(to)
|
switch (to)
|
||||||
{
|
{
|
||||||
case Unit::Mm:
|
case Unit::Mm:
|
||||||
return value * 10.0;
|
return value * 10.0;
|
||||||
|
@ -227,7 +227,7 @@ qreal VAbstractMeasurements::UnitConvertor(qreal value, const Unit &from, const
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Unit::Inch:
|
case Unit::Inch:
|
||||||
switch(to)
|
switch (to)
|
||||||
{
|
{
|
||||||
case Unit::Mm:
|
case Unit::Mm:
|
||||||
return value * 25.4;
|
return value * 25.4;
|
||||||
|
|
|
@ -723,7 +723,7 @@ void VPattern::LiteParseTree(const Document &parse)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
emit SetEnabledGUI(true);
|
emit SetEnabledGUI(true);
|
||||||
switch(parse)
|
switch (parse)
|
||||||
{
|
{
|
||||||
case Document::LitePPParse:
|
case Document::LitePPParse:
|
||||||
ParseCurrentPP();
|
ParseCurrentPP();
|
||||||
|
@ -832,7 +832,7 @@ void VPattern::ClearScene()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPattern::customEvent(QEvent *event)
|
void VPattern::customEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
if(event->type() == UNDO_EVENT)
|
if (event->type() == UNDO_EVENT)
|
||||||
{
|
{
|
||||||
qApp->getUndoStack()->undo();
|
qApp->getUndoStack()->undo();
|
||||||
}
|
}
|
||||||
|
@ -1629,7 +1629,7 @@ QString VPattern::GetLabelBase(unsigned int index) const
|
||||||
QStringList list = VApplication::LabelLanguages();
|
QStringList list = VApplication::LabelLanguages();
|
||||||
|
|
||||||
QStringList alphabet;
|
QStringList alphabet;
|
||||||
switch(list.indexOf(checkedLocale))
|
switch (list.indexOf(checkedLocale))
|
||||||
{
|
{
|
||||||
case 0: // de
|
case 0: // de
|
||||||
{
|
{
|
||||||
|
@ -2369,7 +2369,7 @@ QString VPattern::GenerateLabel(const LabelType &type) const
|
||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
name = GetLabelBase(drawList.size() + i);
|
name = GetLabelBase(drawList.size() + i);
|
||||||
if (data->IsUnique(name))
|
if (data->IsUnique(name))
|
||||||
|
|
|
@ -27,7 +27,7 @@ using namespace VPE;
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
QVector3DProperty::QVector3DProperty(const QString& name)
|
QVector3DProperty::QVector3DProperty(const QString& name)
|
||||||
: VProperty(name, QVariant::String) // todo: QVariant::Vector3D??
|
: VProperty(name, QVariant::String) // todo: QVariant::Vector3D??
|
||||||
{
|
{
|
||||||
QVariant tmpFloat(0); tmpFloat.convert(QVariant::Double);
|
QVariant tmpFloat(0); tmpFloat.convert(QVariant::Double);
|
||||||
VDoubleProperty* tmpX = new VDoubleProperty("X"); addChild(tmpX); tmpX->setUpdateBehaviour(true, false);
|
VDoubleProperty* tmpX = new VDoubleProperty("X"); addChild(tmpX); tmpX->setUpdateBehaviour(true, false);
|
||||||
|
@ -40,7 +40,7 @@ QVector3DProperty::QVector3DProperty(const QString& name)
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
QVariant QVector3DProperty::data (int column, int role) const
|
QVariant QVector3DProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Data && Qt::DisplayRole == role)
|
if (column == DPC_Data && Qt::DisplayRole == role)
|
||||||
{
|
{
|
||||||
Vector3D tmpVect = getVector();
|
Vector3D tmpVect = getVector();
|
||||||
return QString("(%1, %2, %3)").arg(QString::number(tmpVect.X),
|
return QString("(%1, %2, %3)").arg(QString::number(tmpVect.X),
|
||||||
|
@ -54,8 +54,10 @@ QVariant QVector3DProperty::data (int column, int role) const
|
||||||
//! Returns item flags
|
//! Returns item flags
|
||||||
Qt::ItemFlags QVector3DProperty::flags(int column) const
|
Qt::ItemFlags QVector3DProperty::flags(int column) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Name || column == DPC_Data)
|
if (column == DPC_Name || column == DPC_Data)
|
||||||
|
{
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
}
|
}
|
||||||
|
@ -66,8 +68,10 @@ Vector3D QVector3DProperty::getVector() const
|
||||||
{
|
{
|
||||||
Vector3D tmpVect;
|
Vector3D tmpVect;
|
||||||
|
|
||||||
if(d_ptr->Children.count() < 3)
|
if (d_ptr->Children.count() < 3)
|
||||||
|
{
|
||||||
return tmpVect;
|
return tmpVect;
|
||||||
|
}
|
||||||
|
|
||||||
tmpVect.X = d_ptr->Children.at(0)->getValue().toFloat();
|
tmpVect.X = d_ptr->Children.at(0)->getValue().toFloat();
|
||||||
tmpVect.Y = d_ptr->Children.at(1)->getValue().toFloat();
|
tmpVect.Y = d_ptr->Children.at(1)->getValue().toFloat();
|
||||||
|
@ -84,8 +88,10 @@ void QVector3DProperty::setVector(const Vector3D &vect)
|
||||||
|
|
||||||
void QVector3DProperty::setVector(float x, float y, float z)
|
void QVector3DProperty::setVector(float x, float y, float z)
|
||||||
{
|
{
|
||||||
if(d_ptr->Children.count() < 3)
|
if (d_ptr->Children.count() < 3)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant tmpX(x); tmpX.convert(QVariant::Double);
|
QVariant tmpX(x); tmpX.convert(QVariant::Double);
|
||||||
QVariant tmpY(y); tmpY.convert(QVariant::Double);
|
QVariant tmpY(y); tmpY.convert(QVariant::Double);
|
||||||
|
@ -102,25 +108,29 @@ QString QVector3DProperty::type() const
|
||||||
|
|
||||||
VProperty* QVector3DProperty::clone(bool include_children, VProperty* container) const
|
VProperty* QVector3DProperty::clone(bool include_children, VProperty* container) const
|
||||||
{
|
{
|
||||||
if(!container) {
|
if (!container)
|
||||||
|
{
|
||||||
container = new QVector3DProperty(getName());
|
container = new QVector3DProperty(getName());
|
||||||
|
|
||||||
if(!include_children) {
|
if (!include_children)
|
||||||
|
{
|
||||||
QList<VProperty*> tmpChildren = container->getChildren();
|
QList<VProperty*> tmpChildren = container->getChildren();
|
||||||
foreach(VProperty* tmpChild, tmpChildren) {
|
foreach (VProperty* tmpChild, tmpChildren)
|
||||||
|
{
|
||||||
container->removeChild(tmpChild);
|
container->removeChild(tmpChild);
|
||||||
delete tmpChild;
|
delete tmpChild;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return VProperty::clone(false, container); // Child
|
return VProperty::clone(false, container); // Child
|
||||||
}
|
}
|
||||||
|
|
||||||
void QVector3DProperty::setValue(const QVariant &value)
|
void QVector3DProperty::setValue(const QVariant &value)
|
||||||
{
|
{
|
||||||
QStringList tmpStrings = value.toString().split(",");
|
QStringList tmpStrings = value.toString().split(",");
|
||||||
if(tmpStrings.count() == 3) {
|
if (tmpStrings.count() == 3)
|
||||||
|
{
|
||||||
setVector(tmpStrings[0].toDouble(), tmpStrings[1].toDouble(), tmpStrings[2].toDouble());
|
setVector(tmpStrings[0].toDouble(), tmpStrings[1].toDouble(), tmpStrings[2].toDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
struct VPROPERTYEXPLORERSHARED_EXPORT Vector3D
|
struct VPROPERTYEXPLORERSHARED_EXPORT Vector3D
|
||||||
{
|
{
|
||||||
|
@ -80,7 +81,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -41,27 +41,38 @@ VBoolProperty::VBoolProperty(const QString& name) :
|
||||||
d_ptr->VariantValue.convert(QVariant::Bool);
|
d_ptr->VariantValue.convert(QVariant::Bool);
|
||||||
|
|
||||||
// I'm not sure, how Qt handles the translations...
|
// I'm not sure, how Qt handles the translations...
|
||||||
if(TrueText.isNull()) TrueText = QObject::tr("True");
|
if (TrueText.isNull())
|
||||||
if(TrueText.isNull()) FalseText = QObject::tr("False");
|
{
|
||||||
|
TrueText = QObject::tr("True");
|
||||||
|
}
|
||||||
|
if (TrueText.isNull())
|
||||||
|
{
|
||||||
|
FalseText = QObject::tr("False");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
QVariant VBoolProperty::data (int column, int role) const
|
QVariant VBoolProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
||||||
|
{
|
||||||
return d_ptr->VariantValue.toBool() ? TrueText : FalseText;
|
return d_ptr->VariantValue.toBool() ? TrueText : FalseText;
|
||||||
if(column == DPC_Data && Qt::CheckStateRole == role)
|
}
|
||||||
|
if (column == DPC_Data && Qt::CheckStateRole == role)
|
||||||
|
{
|
||||||
return d_ptr->VariantValue.toBool() ? Qt::Checked : Qt::Unchecked;
|
return d_ptr->VariantValue.toBool() ? Qt::Checked : Qt::Unchecked;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VBoolProperty::setData(const QVariant &data, int role)
|
bool VBoolProperty::setData(const QVariant &data, int role)
|
||||||
{
|
{
|
||||||
if(Qt::CheckStateRole == role)
|
if (Qt::CheckStateRole == role)
|
||||||
{
|
{
|
||||||
d_ptr->VariantValue = (Qt::Checked == static_cast<Qt::CheckState>(data.toInt())); return true;
|
d_ptr->VariantValue = (Qt::Checked == static_cast<Qt::CheckState>(data.toInt()));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -70,8 +81,10 @@ bool VBoolProperty::setData(const QVariant &data, int role)
|
||||||
//! Returns item flags
|
//! Returns item flags
|
||||||
Qt::ItemFlags VBoolProperty::flags(int column) const
|
Qt::ItemFlags VBoolProperty::flags(int column) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Data)
|
if (column == DPC_Data)
|
||||||
|
{
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::flags(column);
|
return VProperty::flags(column);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
//! The VBoolProperty can take two states: True or False.
|
//! The VBoolProperty can take two states: True or False.
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VBoolProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VBoolProperty : public VProperty
|
||||||
|
@ -52,7 +53,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -34,18 +34,25 @@ VColorProperty::VColorProperty(const QString &name) :
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
QVariant VColorProperty::data (int column, int role) const
|
QVariant VColorProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Data && (Qt::DisplayRole == role))
|
if (column == DPC_Data && (Qt::DisplayRole == role))
|
||||||
|
{
|
||||||
return VColorPropertyEditor::getColorString(d_ptr->VariantValue.value<QColor>());
|
return VColorPropertyEditor::getColorString(d_ptr->VariantValue.value<QColor>());
|
||||||
else if(Qt::EditRole == role)
|
}
|
||||||
|
else if (Qt::EditRole == role)
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
else if(column == DPC_Data && (Qt::DecorationRole == role))
|
}
|
||||||
|
else if (column == DPC_Data && (Qt::DecorationRole == role))
|
||||||
|
{
|
||||||
return VColorPropertyEditor::getColorPixmap(d_ptr->VariantValue.value<QColor>());
|
return VColorPropertyEditor::getColorPixmap(d_ptr->VariantValue.value<QColor>());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
QWidget* VColorProperty::createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VColorProperty::createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
Q_UNUSED(delegate);
|
Q_UNUSED(delegate);
|
||||||
|
@ -59,8 +66,10 @@ QWidget* VColorProperty::createEditor(QWidget* parent, const QStyleOptionViewIte
|
||||||
bool VColorProperty::setEditorData(QWidget* editor)
|
bool VColorProperty::setEditorData(QWidget* editor)
|
||||||
{
|
{
|
||||||
VColorPropertyEditor* tmpWidget = qobject_cast<VColorPropertyEditor*>(editor);
|
VColorPropertyEditor* tmpWidget = qobject_cast<VColorPropertyEditor*>(editor);
|
||||||
if(tmpWidget)
|
if (tmpWidget)
|
||||||
|
{
|
||||||
tmpWidget->setColor(d_ptr->VariantValue.value<QColor>());
|
tmpWidget->setColor(d_ptr->VariantValue.value<QColor>());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -71,8 +80,10 @@ bool VColorProperty::setEditorData(QWidget* editor)
|
||||||
QVariant VColorProperty::getEditorData(QWidget* editor) const
|
QVariant VColorProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
VColorPropertyEditor* tmpWidget = qobject_cast<VColorPropertyEditor*>(editor);
|
VColorPropertyEditor* tmpWidget = qobject_cast<VColorPropertyEditor*>(editor);
|
||||||
if(tmpWidget)
|
if (tmpWidget)
|
||||||
|
{
|
||||||
return tmpWidget->getColor();
|
return tmpWidget->getColor();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VColorProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VColorProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
@ -39,8 +40,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
||||||
virtual bool setEditorData(QWidget* editor);
|
virtual bool setEditorData(QWidget* editor);
|
||||||
|
@ -53,7 +56,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ VColorPropertyEditor::VColorPropertyEditor(QWidget *parent) :
|
||||||
ToolButton->setText(tr("..."));
|
ToolButton->setText(tr("..."));
|
||||||
ToolButton->setFixedWidth(20);
|
ToolButton->setFixedWidth(20);
|
||||||
ToolButton->installEventFilter(this);
|
ToolButton->installEventFilter(this);
|
||||||
setFocusProxy(ToolButton); // Make the ToolButton the focus proxy
|
setFocusProxy(ToolButton); // Make the ToolButton the focus proxy
|
||||||
setFocusPolicy(ToolButton->focusPolicy());
|
setFocusPolicy(ToolButton->focusPolicy());
|
||||||
connect(ToolButton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked()));
|
connect(ToolButton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked()));
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ VColorPropertyEditor::VColorPropertyEditor(QWidget *parent) :
|
||||||
layout->addItem(Spacer);
|
layout->addItem(Spacer);
|
||||||
layout->addWidget(ToolButton);
|
layout->addWidget(ToolButton);
|
||||||
//TextLabel->hide();
|
//TextLabel->hide();
|
||||||
//ColorLabel->hide(); // for now, we just use the standard display and only add the button
|
//ColorLabel->hide(); // for now, we just use the standard display and only add the button
|
||||||
}
|
}
|
||||||
|
|
||||||
void VColorPropertyEditor::setColor(const QColor& color_)
|
void VColorPropertyEditor::setColor(const QColor& color_)
|
||||||
|
@ -101,7 +101,8 @@ void VColorPropertyEditor::onToolButtonClicked()
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QRgb oldRgba = Color.rgba();
|
QRgb oldRgba = Color.rgba();
|
||||||
QRgb newRgba = QColorDialog::getRgba(oldRgba, &ok, this);
|
QRgb newRgba = QColorDialog::getRgba(oldRgba, &ok, this);
|
||||||
if (ok && newRgba != oldRgba) {
|
if (ok && newRgba != oldRgba)
|
||||||
|
{
|
||||||
setColor(QColor::fromRgba(newRgba));
|
setColor(QColor::fromRgba(newRgba));
|
||||||
emit dataChangedByUser(Color, this);
|
emit dataChangedByUser(Color, this);
|
||||||
UserChangeEvent *event = new UserChangeEvent();
|
UserChangeEvent *event = new UserChangeEvent();
|
||||||
|
@ -111,7 +112,7 @@ void VColorPropertyEditor::onToolButtonClicked()
|
||||||
|
|
||||||
bool VColorPropertyEditor::eventFilter(QObject *obj, QEvent *ev)
|
bool VColorPropertyEditor::eventFilter(QObject *obj, QEvent *ev)
|
||||||
{
|
{
|
||||||
if(obj == ToolButton && (ev->type() == QEvent::KeyPress || ev->type() == QEvent::KeyPress))
|
if (obj == ToolButton && (ev->type() == QEvent::KeyPress || ev->type() == QEvent::KeyPress))
|
||||||
{
|
{
|
||||||
// Ignore the event, so that eventually the delegate gets the event.
|
// Ignore the event, so that eventually the delegate gets the event.
|
||||||
ev->ignore();
|
ev->ignore();
|
||||||
|
@ -127,8 +128,6 @@ VColorPropertyEditor::~VColorPropertyEditor()
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QColor VColorPropertyEditor::getColor()
|
QColor VColorPropertyEditor::getColor()
|
||||||
{
|
{
|
||||||
return Color;
|
return Color;
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QSpacerItem>
|
#include <QSpacerItem>
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VColorPropertyEditor : public QWidget
|
class VPROPERTYEXPLORERSHARED_EXPORT VColorPropertyEditor : public QWidget
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,18 +42,25 @@ VEmptyProperty::~VEmptyProperty()
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
QVariant VEmptyProperty::data (int column, int role) const
|
QVariant VEmptyProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
else if(role == Qt::BackgroundRole)
|
}
|
||||||
return QBrush(QColor(217,217,217));
|
else if (role == Qt::BackgroundRole)
|
||||||
else if(role == Qt::FontRole)
|
{
|
||||||
{ QFont tmpFont; tmpFont.setBold(true); return tmpFont; }
|
return QBrush(QColor(217, 217, 217));
|
||||||
|
}
|
||||||
|
else if (role == Qt::FontRole)
|
||||||
|
{
|
||||||
|
QFont tmpFont; tmpFont.setBold(true); return tmpFont;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
QWidget* VEmptyProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VEmptyProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VEmptyProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VEmptyProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
@ -40,8 +41,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
@ -54,7 +57,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -37,25 +37,34 @@ VEnumProperty::VEnumProperty(const QString& name)
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
QVariant VEnumProperty::data (int column, int role) const
|
QVariant VEnumProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if(EnumerationLiterals.empty())
|
if (EnumerationLiterals.empty())
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
int tmpIndex = VProperty::d_ptr->VariantValue.toInt();
|
int tmpIndex = VProperty::d_ptr->VariantValue.toInt();
|
||||||
|
|
||||||
if(tmpIndex < 0 || tmpIndex >= EnumerationLiterals.count())
|
if (tmpIndex < 0 || tmpIndex >= EnumerationLiterals.count())
|
||||||
|
{
|
||||||
tmpIndex = 0;
|
tmpIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(column == DPC_Data && Qt::DisplayRole == role)
|
if (column == DPC_Data && Qt::DisplayRole == role)
|
||||||
|
{
|
||||||
return EnumerationLiterals.at(tmpIndex);
|
return EnumerationLiterals.at(tmpIndex);
|
||||||
else if(column == DPC_Data && Qt::EditRole == role)
|
}
|
||||||
|
else if (column == DPC_Data && Qt::EditRole == role)
|
||||||
|
{
|
||||||
return tmpIndex;
|
return tmpIndex;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
QWidget* VEnumProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VEnumProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
Q_UNUSED(delegate);
|
Q_UNUSED(delegate);
|
||||||
|
@ -74,8 +83,10 @@ QWidget* VEnumProperty::createEditor(QWidget * parent, const QStyleOptionViewIte
|
||||||
QVariant VEnumProperty::getEditorData(QWidget* editor) const
|
QVariant VEnumProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
|
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
|
||||||
if(tmpEditor)
|
if (tmpEditor)
|
||||||
|
{
|
||||||
return tmpEditor->currentIndex();
|
return tmpEditor->currentIndex();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant(0);
|
return QVariant(0);
|
||||||
}
|
}
|
||||||
|
@ -97,8 +108,10 @@ void VEnumProperty::setValue(const QVariant& value)
|
||||||
{
|
{
|
||||||
int tmpIndex = value.toInt();
|
int tmpIndex = value.toInt();
|
||||||
|
|
||||||
if(tmpIndex < 0 || tmpIndex >= EnumerationLiterals.count())
|
if (tmpIndex < 0 || tmpIndex >= EnumerationLiterals.count())
|
||||||
|
{
|
||||||
tmpIndex = 0;
|
tmpIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
VProperty::d_ptr->VariantValue = tmpIndex;
|
VProperty::d_ptr->VariantValue = tmpIndex;
|
||||||
VProperty::d_ptr->VariantValue.convert(QVariant::Int);
|
VProperty::d_ptr->VariantValue.convert(QVariant::Int);
|
||||||
|
@ -121,14 +134,18 @@ VProperty* VEnumProperty::clone(bool include_children, VProperty* container) con
|
||||||
|
|
||||||
void VEnumProperty::setSetting(const QString& key, const QVariant& value)
|
void VEnumProperty::setSetting(const QString& key, const QVariant& value)
|
||||||
{
|
{
|
||||||
if(key == "literals")
|
if (key == "literals")
|
||||||
|
{
|
||||||
setLiterals(value.toString().split(";;"));
|
setLiterals(value.toString().split(";;"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant VEnumProperty::getSetting(const QString& key) const
|
QVariant VEnumProperty::getSetting(const QString& key) const
|
||||||
{
|
{
|
||||||
if(key == "literals")
|
if (key == "literals")
|
||||||
|
{
|
||||||
return getLiterals().join(";;");
|
return getLiterals().join(";;");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::getSetting(key);
|
return VProperty::getSetting(key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VEnumProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VEnumProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
@ -43,8 +44,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
@ -63,7 +66,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
||||||
|
|
||||||
|
@ -84,7 +88,8 @@ public slots:
|
||||||
protected:
|
protected:
|
||||||
//! The list of possible options to choose frome
|
//! The list of possible options to choose frome
|
||||||
QStringList EnumerationLiterals;
|
QStringList EnumerationLiterals;
|
||||||
// No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other members by reimplementing the VPropertyPrivate class without touching this header file.
|
// No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other
|
||||||
|
//members by reimplementing the VPropertyPrivate class without touching this header file.
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ QString VFileProperty::getFile() const
|
||||||
|
|
||||||
QVariant VFileProperty::data (int column, int role) const
|
QVariant VFileProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
||||||
{
|
{
|
||||||
QFileInfo tmpFile(d_ptr->VariantValue.toString());
|
QFileInfo tmpFile(d_ptr->VariantValue.toString());
|
||||||
return tmpFile.fileName();
|
return tmpFile.fileName();
|
||||||
|
@ -76,14 +76,18 @@ QVariant VFileProperty::data (int column, int role) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QWidget* VFileProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VFileProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
|
|
||||||
VFileEditWidget* tmpWidget = new VFileEditWidget(parent);
|
VFileEditWidget* tmpWidget = new VFileEditWidget(parent);
|
||||||
if(delegate)
|
if (delegate)
|
||||||
|
{
|
||||||
VFileEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*)));
|
VFileEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*)));
|
||||||
tmpWidget->setFilter(static_cast<VFilePropertyPrivate*>(d_ptr)->FileFilters); // todo: parse this string
|
|
||||||
|
}
|
||||||
|
tmpWidget->setFilter(static_cast<VFilePropertyPrivate*>(d_ptr)->FileFilters); // todo: parse this string
|
||||||
tmpWidget->setFile(d_ptr->VariantValue.toString());
|
tmpWidget->setFile(d_ptr->VariantValue.toString());
|
||||||
tmpWidget->setDirectory(static_cast<VFilePropertyPrivate*>(d_ptr)->Directory);
|
tmpWidget->setDirectory(static_cast<VFilePropertyPrivate*>(d_ptr)->Directory);
|
||||||
return tmpWidget;
|
return tmpWidget;
|
||||||
|
@ -93,8 +97,10 @@ QWidget* VFileProperty::createEditor(QWidget * parent, const QStyleOptionViewIte
|
||||||
bool VFileProperty::setEditorData(QWidget* editor)
|
bool VFileProperty::setEditorData(QWidget* editor)
|
||||||
{
|
{
|
||||||
VFileEditWidget* tmpWidget = qobject_cast<VFileEditWidget*>(editor);
|
VFileEditWidget* tmpWidget = qobject_cast<VFileEditWidget*>(editor);
|
||||||
if(tmpWidget)
|
if (tmpWidget)
|
||||||
|
{
|
||||||
tmpWidget->setFile(d_ptr->VariantValue.toString());
|
tmpWidget->setFile(d_ptr->VariantValue.toString());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -105,26 +111,36 @@ bool VFileProperty::setEditorData(QWidget* editor)
|
||||||
QVariant VFileProperty::getEditorData(QWidget* editor) const
|
QVariant VFileProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
VFileEditWidget* tmpWidget = qobject_cast<VFileEditWidget*>(editor);
|
VFileEditWidget* tmpWidget = qobject_cast<VFileEditWidget*>(editor);
|
||||||
if(tmpWidget)
|
if (tmpWidget)
|
||||||
|
{
|
||||||
return tmpWidget->getFile();
|
return tmpWidget->getFile();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFileProperty::setSetting(const QString& key, const QVariant& value)
|
void VFileProperty::setSetting(const QString& key, const QVariant& value)
|
||||||
{
|
{
|
||||||
if(key == "FileFilters")
|
if (key == "FileFilters")
|
||||||
|
{
|
||||||
setFileFilters(value.toString());
|
setFileFilters(value.toString());
|
||||||
else if(key == "Directory")
|
}
|
||||||
|
else if (key == "Directory")
|
||||||
|
{
|
||||||
setDirectory(value.toBool());
|
setDirectory(value.toBool());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant VFileProperty::getSetting(const QString& key) const
|
QVariant VFileProperty::getSetting(const QString& key) const
|
||||||
{
|
{
|
||||||
if(key == "FileFilters")
|
if (key == "FileFilters")
|
||||||
|
{
|
||||||
return getFileFilters();
|
return getFileFilters();
|
||||||
else if(key == "Directory")
|
}
|
||||||
|
else if (key == "Directory")
|
||||||
|
{
|
||||||
return isDirectory();
|
return isDirectory();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::getSetting(key);
|
return VProperty::getSetting(key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VFileProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VFileProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
@ -55,8 +56,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
||||||
virtual bool setEditorData(QWidget* editor);
|
virtual bool setEditorData(QWidget* editor);
|
||||||
|
@ -80,7 +83,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ VFileEditWidget::VFileEditWidget(QWidget *parent, bool is_directory)
|
||||||
ToolButton->setText(tr("..."));
|
ToolButton->setText(tr("..."));
|
||||||
ToolButton->setFixedWidth(20);
|
ToolButton->setFixedWidth(20);
|
||||||
ToolButton->installEventFilter(this);
|
ToolButton->installEventFilter(this);
|
||||||
setFocusProxy(ToolButton); // Make the ToolButton the focus proxy
|
setFocusProxy(ToolButton); // Make the ToolButton the focus proxy
|
||||||
setFocusPolicy(ToolButton->focusPolicy());
|
setFocusPolicy(ToolButton->focusPolicy());
|
||||||
connect(ToolButton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked()));
|
connect(ToolButton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked()));
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ void VFileEditWidget::setFile(const QString &value, bool emit_signal)
|
||||||
CurrentFilePath = value;
|
CurrentFilePath = value;
|
||||||
FileLineEdit->setText(CurrentFilePath);
|
FileLineEdit->setText(CurrentFilePath);
|
||||||
|
|
||||||
if(emit_signal)
|
if (emit_signal)
|
||||||
{
|
{
|
||||||
emit dataChangedByUser(CurrentFilePath, this);
|
emit dataChangedByUser(CurrentFilePath, this);
|
||||||
emit commitData(this);
|
emit commitData(this);
|
||||||
|
@ -101,36 +101,46 @@ QString VFileEditWidget::getFile()
|
||||||
|
|
||||||
void VFileEditWidget::onToolButtonClicked()
|
void VFileEditWidget::onToolButtonClicked()
|
||||||
{
|
{
|
||||||
QString filepath = (Directory ? QFileDialog::getExistingDirectory(0, tr("Directory"), CurrentFilePath) : QFileDialog::getOpenFileName(0, tr("Open File"), CurrentFilePath, FileDialogFilter));
|
QString filepath = (Directory ? QFileDialog::getExistingDirectory(0, tr("Directory"), CurrentFilePath)
|
||||||
if (!filepath.isNull())
|
: QFileDialog::getOpenFileName(0, tr("Open File"), CurrentFilePath,
|
||||||
|
FileDialogFilter));
|
||||||
|
if (filepath.isNull() == false)
|
||||||
|
{
|
||||||
setFile(filepath, true);
|
setFile(filepath, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool VFileEditWidget::eventFilter(QObject *obj, QEvent *ev)
|
bool VFileEditWidget::eventFilter(QObject *obj, QEvent *ev)
|
||||||
{
|
{
|
||||||
if(ev->type() == QEvent::DragEnter || ev->type() == QEvent::Drop)
|
if (ev->type() == QEvent::DragEnter || ev->type() == QEvent::Drop)
|
||||||
{
|
{
|
||||||
ev->ignore();
|
ev->ignore();
|
||||||
if(ev->type() == QEvent::DragEnter)
|
if (ev->type() == QEvent::DragEnter)
|
||||||
|
{
|
||||||
dragEnterEvent(static_cast<QDragEnterEvent*>(ev));
|
dragEnterEvent(static_cast<QDragEnterEvent*>(ev));
|
||||||
else if(ev->type() == QEvent::Drop)
|
}
|
||||||
|
else if (ev->type() == QEvent::Drop)
|
||||||
|
{
|
||||||
dropEvent(static_cast<QDropEvent*>(ev));
|
dropEvent(static_cast<QDropEvent*>(ev));
|
||||||
|
}
|
||||||
|
|
||||||
if(ev->isAccepted())
|
if (ev->isAccepted())
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return QWidget::eventFilter(obj, ev);
|
return QWidget::eventFilter(obj, ev);
|
||||||
}
|
}
|
||||||
else if(obj == ToolButton && (ev->type() == QEvent::KeyPress || ev->type() == QEvent::KeyPress))
|
else if (obj == ToolButton && (ev->type() == QEvent::KeyPress || ev->type() == QEvent::KeyPress))
|
||||||
{
|
{
|
||||||
// Ignore the event, so that eventually the delegate gets the event.
|
// Ignore the event, so that eventually the delegate gets the event.
|
||||||
ev->ignore();
|
ev->ignore();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(obj == FileLineEdit)
|
else if (obj == FileLineEdit)
|
||||||
{
|
{
|
||||||
if(ev->type() == QEvent::FocusOut)
|
if (ev->type() == QEvent::FocusOut)
|
||||||
{
|
{
|
||||||
setFile(FileLineEdit->text(), true);
|
setFile(FileLineEdit->text(), true);
|
||||||
// We don't return true here because we still want the line edit to catch the event as well
|
// We don't return true here because we still want the line edit to catch the event as well
|
||||||
|
@ -150,7 +160,7 @@ bool VFileEditWidget::isDirectory()
|
||||||
void VFileEditWidget::dragEnterEvent(QDragEnterEvent* event)
|
void VFileEditWidget::dragEnterEvent(QDragEnterEvent* event)
|
||||||
{
|
{
|
||||||
QString tmpFileName;
|
QString tmpFileName;
|
||||||
if(checkMimeData(event->mimeData(), tmpFileName))
|
if (checkMimeData(event->mimeData(), tmpFileName))
|
||||||
{
|
{
|
||||||
event->accept();
|
event->accept();
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
|
@ -170,7 +180,7 @@ void VFileEditWidget::dragLeaveEvent(QDragLeaveEvent* event)
|
||||||
void VFileEditWidget::dropEvent(QDropEvent* event)
|
void VFileEditWidget::dropEvent(QDropEvent* event)
|
||||||
{
|
{
|
||||||
QString tmpFileName;
|
QString tmpFileName;
|
||||||
if(checkMimeData(event->mimeData(), tmpFileName))
|
if (checkMimeData(event->mimeData(), tmpFileName))
|
||||||
{
|
{
|
||||||
setFile(tmpFileName);
|
setFile(tmpFileName);
|
||||||
emit dataChangedByUser(getFile(), this);
|
emit dataChangedByUser(getFile(), this);
|
||||||
|
@ -189,10 +199,12 @@ bool VFileEditWidget::checkMimeData(const QMimeData* data, QString& file) const
|
||||||
QFileInfo tmpFileInfo;
|
QFileInfo tmpFileInfo;
|
||||||
|
|
||||||
foreach(QUrl tmpUrl, tmpUrlList)
|
foreach(QUrl tmpUrl, tmpUrlList)
|
||||||
if(QFile::exists(tmpUrl.toLocalFile()))
|
if (QFile::exists(tmpUrl.toLocalFile()))
|
||||||
{ tmpFileInfo = QFileInfo(tmpUrl.toLocalFile()); break; }
|
{
|
||||||
|
tmpFileInfo = QFileInfo(tmpUrl.toLocalFile()); break;
|
||||||
|
}
|
||||||
|
|
||||||
if(checkFileFilter(tmpFileInfo.fileName()))
|
if (checkFileFilter(tmpFileInfo.fileName()))
|
||||||
{
|
{
|
||||||
file = tmpFileInfo.absoluteFilePath();
|
file = tmpFileInfo.absoluteFilePath();
|
||||||
return true;
|
return true;
|
||||||
|
@ -204,21 +216,26 @@ bool VFileEditWidget::checkMimeData(const QMimeData* data, QString& file) const
|
||||||
|
|
||||||
bool VFileEditWidget::checkFileFilter(const QString& file) const
|
bool VFileEditWidget::checkFileFilter(const QString& file) const
|
||||||
{
|
{
|
||||||
if(FilterList.isEmpty())
|
if (FilterList.isEmpty())
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QFileInfo tmpFileInfo(file);
|
QFileInfo tmpFileInfo(file);
|
||||||
|
|
||||||
if((Directory && !tmpFileInfo.isDir()) || (!Directory && !tmpFileInfo.isFile()))
|
if ((Directory && !tmpFileInfo.isDir()) || (!Directory && !tmpFileInfo.isFile()))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
foreach(QString tmpFilter, FilterList)
|
foreach(QString tmpFilter, FilterList)
|
||||||
{
|
{
|
||||||
QRegExp tmpRegExpFilter(tmpFilter, Qt::CaseInsensitive, QRegExp::Wildcard);
|
QRegExp tmpRegExpFilter(tmpFilter, Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||||
if(tmpRegExpFilter.exactMatch(file))
|
if (tmpRegExpFilter.exactMatch(file))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VFileEditWidget : public QWidget
|
class VPROPERTYEXPLORERSHARED_EXPORT VFileEditWidget : public QWidget
|
||||||
|
@ -85,8 +86,6 @@ protected:
|
||||||
void dragLeaveEvent(QDragLeaveEvent* event);
|
void dragLeaveEvent(QDragLeaveEvent* event);
|
||||||
void dropEvent(QDropEvent* event);
|
void dropEvent(QDropEvent* event);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! This function checks the mime data, if it is compatible with the filters
|
//! This function checks the mime data, if it is compatible with the filters
|
||||||
virtual bool checkMimeData(const QMimeData* data, QString& getFile) const;
|
virtual bool checkMimeData(const QMimeData* data, QString& getFile) const;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ const int VIntegerProperty::StandardMin = -1000000;
|
||||||
const int VIntegerProperty::StandardMax = 1000000;
|
const int VIntegerProperty::StandardMax = 1000000;
|
||||||
|
|
||||||
VIntegerProperty::VIntegerProperty(const QString& name, const QMap<QString, QVariant>& settings)
|
VIntegerProperty::VIntegerProperty(const QString& name, const QMap<QString, QVariant>& settings)
|
||||||
: VProperty(name, QVariant::Int), min(StandardMin), max(StandardMax), singleStep(1.0)
|
: VProperty(name, QVariant::Int), minValue(StandardMin), maxValue(StandardMax), singleStep(1.0)
|
||||||
{
|
{
|
||||||
VProperty::setSettings(settings);
|
VProperty::setSettings(settings);
|
||||||
VProperty::d_ptr->VariantValue.setValue(0);
|
VProperty::d_ptr->VariantValue.setValue(0);
|
||||||
|
@ -42,21 +42,22 @@ VIntegerProperty::VIntegerProperty(const QString& name, const QMap<QString, QVar
|
||||||
}
|
}
|
||||||
|
|
||||||
VIntegerProperty::VIntegerProperty(const QString &name)
|
VIntegerProperty::VIntegerProperty(const QString &name)
|
||||||
: VProperty(name), min(StandardMin), max(StandardMax)
|
: VProperty(name), minValue(StandardMin), maxValue(StandardMax)
|
||||||
{
|
{
|
||||||
VProperty::d_ptr->VariantValue.setValue(0);
|
VProperty::d_ptr->VariantValue.setValue(0);
|
||||||
VProperty::d_ptr->VariantValue.convert(QVariant::Int);
|
VProperty::d_ptr->VariantValue.convert(QVariant::Int);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
QWidget* VIntegerProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VIntegerProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
Q_UNUSED(delegate);
|
Q_UNUSED(delegate);
|
||||||
|
|
||||||
QSpinBox* tmpEditor = new QSpinBox(parent);
|
QSpinBox* tmpEditor = new QSpinBox(parent);
|
||||||
tmpEditor->setMinimum(min);
|
tmpEditor->setMinimum(minValue);
|
||||||
tmpEditor->setMaximum(max);
|
tmpEditor->setMaximum(maxValue);
|
||||||
tmpEditor->setSingleStep(singleStep);
|
tmpEditor->setSingleStep(singleStep);
|
||||||
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
tmpEditor->setValue(VProperty::d_ptr->VariantValue.toInt());
|
tmpEditor->setValue(VProperty::d_ptr->VariantValue.toInt());
|
||||||
|
@ -71,37 +72,51 @@ QWidget* VIntegerProperty::createEditor(QWidget * parent, const QStyleOptionView
|
||||||
QVariant VIntegerProperty::getEditorData(QWidget* editor) const
|
QVariant VIntegerProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
QSpinBox* tmpEditor = qobject_cast<QSpinBox*>(editor);
|
QSpinBox* tmpEditor = qobject_cast<QSpinBox*>(editor);
|
||||||
if(tmpEditor)
|
if (tmpEditor)
|
||||||
|
{
|
||||||
return tmpEditor->value();
|
return tmpEditor->value();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant(0);
|
return QVariant(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VIntegerProperty::setSettings(int minimum, int maxiumum, int singleStep)
|
void VIntegerProperty::setSettings(int minimum, int maxiumum, int singleStep)
|
||||||
{
|
{
|
||||||
min = minimum;
|
minValue = minimum;
|
||||||
max = maxiumum;
|
maxValue = maxiumum;
|
||||||
this->singleStep = singleStep;
|
this->singleStep = singleStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VIntegerProperty::setSetting(const QString& key, const QVariant& value)
|
void VIntegerProperty::setSetting(const QString& key, const QVariant& value)
|
||||||
{
|
{
|
||||||
if(key == QLatin1String("Min"))
|
if (key == QLatin1String("Min"))
|
||||||
setSettings(value.toInt(), max);
|
{
|
||||||
else if(key == QLatin1String("Max"))
|
setSettings(value.toInt(), maxValue);
|
||||||
setSettings(min, value.toInt());
|
}
|
||||||
else if(key == QLatin1String("Step"))
|
else if (key == QLatin1String("Max"))
|
||||||
|
{
|
||||||
|
setSettings(minValue, value.toInt());
|
||||||
|
}
|
||||||
|
else if (key == QLatin1String("Step"))
|
||||||
|
{
|
||||||
setSettings(singleStep, value.toInt());
|
setSettings(singleStep, value.toInt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant VIntegerProperty::getSetting(const QString& key) const
|
QVariant VIntegerProperty::getSetting(const QString& key) const
|
||||||
{
|
{
|
||||||
if(key == QLatin1String("Min"))
|
if (key == QLatin1String("Min"))
|
||||||
return min;
|
{
|
||||||
if(key == QLatin1String("Max"))
|
return minValue;
|
||||||
return max;
|
}
|
||||||
if(key == QLatin1String("Step"))
|
if (key == QLatin1String("Max"))
|
||||||
|
{
|
||||||
|
return maxValue;
|
||||||
|
}
|
||||||
|
if (key == QLatin1String("Step"))
|
||||||
|
{
|
||||||
return singleStep;
|
return singleStep;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::getSetting(key);
|
return VProperty::getSetting(key);
|
||||||
}
|
}
|
||||||
|
@ -128,10 +143,6 @@ void VIntegerProperty::valueChanged(int i)
|
||||||
QCoreApplication::postEvent ( VProperty::d_ptr->editor, event );
|
QCoreApplication::postEvent ( VProperty::d_ptr->editor, event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const double VDoubleProperty::StandardPrecision = 5;
|
const double VDoubleProperty::StandardPrecision = 5;
|
||||||
|
|
||||||
VDoubleProperty::VDoubleProperty(const QString& name, const QMap<QString, QVariant>& settings)
|
VDoubleProperty::VDoubleProperty(const QString& name, const QMap<QString, QVariant>& settings)
|
||||||
|
@ -152,13 +163,14 @@ VDoubleProperty::VDoubleProperty(const QString &name)
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
QWidget* VDoubleProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VDoubleProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
Q_UNUSED(delegate);
|
Q_UNUSED(delegate);
|
||||||
QDoubleSpinBox* tmpEditor = new QDoubleSpinBox(parent);
|
QDoubleSpinBox* tmpEditor = new QDoubleSpinBox(parent);
|
||||||
tmpEditor->setMinimum(min);
|
tmpEditor->setMinimum(minValue);
|
||||||
tmpEditor->setMaximum(max);
|
tmpEditor->setMaximum(maxValue);
|
||||||
tmpEditor->setDecimals(Precision);
|
tmpEditor->setDecimals(Precision);
|
||||||
tmpEditor->setSingleStep(singleStep);
|
tmpEditor->setSingleStep(singleStep);
|
||||||
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
@ -174,42 +186,60 @@ QWidget* VDoubleProperty::createEditor(QWidget * parent, const QStyleOptionViewI
|
||||||
QVariant VDoubleProperty::getEditorData(QWidget* editor) const
|
QVariant VDoubleProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
QDoubleSpinBox* tmpEditor = qobject_cast<QDoubleSpinBox*>(editor);
|
QDoubleSpinBox* tmpEditor = qobject_cast<QDoubleSpinBox*>(editor);
|
||||||
if(tmpEditor)
|
if (tmpEditor)
|
||||||
|
{
|
||||||
return tmpEditor->value();
|
return tmpEditor->value();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant(0);
|
return QVariant(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VDoubleProperty::setSettings(double minimum, double maxiumum, double singleStep, int precision)
|
void VDoubleProperty::setSettings(double minimum, double maxiumum, double singleStep, int precision)
|
||||||
{
|
{
|
||||||
min = minimum;
|
minValue = minimum;
|
||||||
max = maxiumum;
|
maxValue = maxiumum;
|
||||||
this->singleStep = singleStep;
|
this->singleStep = singleStep;
|
||||||
Precision = precision;
|
Precision = precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VDoubleProperty::setSetting(const QString& key, const QVariant& value)
|
void VDoubleProperty::setSetting(const QString& key, const QVariant& value)
|
||||||
{
|
{
|
||||||
if(key == QLatin1String("Min"))
|
if (key == QLatin1String("Min"))
|
||||||
setSettings(value.toDouble(), max, singleStep, Precision);
|
{
|
||||||
else if(key == QLatin1String("Max"))
|
setSettings(value.toDouble(), maxValue, singleStep, Precision);
|
||||||
setSettings(min, value.toDouble(), singleStep, Precision);
|
}
|
||||||
else if(key == QLatin1String("Step"))
|
else if (key == QLatin1String("Max"))
|
||||||
setSettings(min, max, value.toDouble(), Precision);
|
{
|
||||||
else if(key == QLatin1String("Precision"))
|
setSettings(minValue, value.toDouble(), singleStep, Precision);
|
||||||
setSettings(min, max, singleStep, value.toDouble());
|
}
|
||||||
|
else if (key == QLatin1String("Step"))
|
||||||
|
{
|
||||||
|
setSettings(minValue, maxValue, value.toDouble(), Precision);
|
||||||
|
}
|
||||||
|
else if (key == QLatin1String("Precision"))
|
||||||
|
{
|
||||||
|
setSettings(minValue, maxValue, singleStep, value.toDouble());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant VDoubleProperty::getSetting(const QString& key) const
|
QVariant VDoubleProperty::getSetting(const QString& key) const
|
||||||
{
|
{
|
||||||
if(key == QLatin1String("Min"))
|
if (key == QLatin1String("Min"))
|
||||||
return min;
|
{
|
||||||
if(key == QLatin1String("Max"))
|
return minValue;
|
||||||
return max;
|
}
|
||||||
if(key == QLatin1String("Step"))
|
if (key == QLatin1String("Max"))
|
||||||
|
{
|
||||||
|
return maxValue;
|
||||||
|
}
|
||||||
|
if (key == QLatin1String("Step"))
|
||||||
|
{
|
||||||
return singleStep;
|
return singleStep;
|
||||||
if(key == QLatin1String("Precision"))
|
}
|
||||||
|
if (key == QLatin1String("Precision"))
|
||||||
|
{
|
||||||
return Precision;
|
return Precision;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::getSetting(key);
|
return VProperty::getSetting(key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
//! Class for holding an integer property
|
//! Class for holding an integer property
|
||||||
|
@ -39,8 +40,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
@ -67,13 +70,14 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
public slots:
|
public slots:
|
||||||
void valueChanged(int i);
|
void valueChanged(int i);
|
||||||
protected:
|
protected:
|
||||||
double min, max, singleStep;
|
double minValue, maxValue, singleStep;
|
||||||
|
|
||||||
static const int StandardMin;// = -1000000;
|
static const int StandardMin;// = -1000000;
|
||||||
static const int StandardMax;// = 1000000;
|
static const int StandardMax;// = 1000000;
|
||||||
|
@ -92,8 +96,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
@ -121,7 +127,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -37,17 +37,21 @@ VObjectProperty::VObjectProperty(const QString& name)
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
QVariant VObjectProperty::data (int column, int role) const
|
QVariant VObjectProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if(objects.empty())
|
if (objects.empty())
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
QComboBox* tmpEditor = qobject_cast<QComboBox*>(VProperty::d_ptr->editor);
|
QComboBox* tmpEditor = qobject_cast<QComboBox*>(VProperty::d_ptr->editor);
|
||||||
|
|
||||||
if(column == DPC_Data && Qt::DisplayRole == role)
|
if (column == DPC_Data && Qt::DisplayRole == role)
|
||||||
{
|
{
|
||||||
return VProperty::d_ptr->VariantValue;
|
return VProperty::d_ptr->VariantValue;
|
||||||
}
|
}
|
||||||
else if(column == DPC_Data && Qt::EditRole == role)
|
else if (column == DPC_Data && Qt::EditRole == role)
|
||||||
|
{
|
||||||
return tmpEditor->currentIndex();
|
return tmpEditor->currentIndex();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
@ -71,11 +75,13 @@ QWidget* VObjectProperty::createEditor(QWidget * parent, const QStyleOptionViewI
|
||||||
|
|
||||||
bool VObjectProperty::setEditorData(QWidget *editor)
|
bool VObjectProperty::setEditorData(QWidget *editor)
|
||||||
{
|
{
|
||||||
if(!editor)
|
if (!editor)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
|
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
|
||||||
if(tmpEditor)
|
if (tmpEditor)
|
||||||
{
|
{
|
||||||
quint32 objId = VProperty::d_ptr->VariantValue.toUInt();
|
quint32 objId = VProperty::d_ptr->VariantValue.toUInt();
|
||||||
qint32 tmpIndex = tmpEditor->findData(objId);
|
qint32 tmpIndex = tmpEditor->findData(objId);
|
||||||
|
@ -97,8 +103,10 @@ bool VObjectProperty::setEditorData(QWidget *editor)
|
||||||
QVariant VObjectProperty::getEditorData(QWidget* editor) const
|
QVariant VObjectProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
|
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
|
||||||
if(tmpEditor)
|
if (tmpEditor)
|
||||||
|
{
|
||||||
return tmpEditor->itemData(tmpEditor->currentIndex());
|
return tmpEditor->itemData(tmpEditor->currentIndex());
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant(0);
|
return QVariant(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
|
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VObjectProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VObjectProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
@ -45,8 +46,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
||||||
virtual bool setEditorData(QWidget* editor);
|
virtual bool setEditorData(QWidget* editor);
|
||||||
|
@ -68,7 +71,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
||||||
|
|
||||||
|
@ -80,7 +84,8 @@ protected:
|
||||||
QMap<QString, quint32> objects;
|
QMap<QString, quint32> objects;
|
||||||
|
|
||||||
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
|
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
|
||||||
// No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other members by reimplementing the VPropertyPrivate class without touching this header file.
|
// No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other
|
||||||
|
//members by reimplementing the VPropertyPrivate class without touching this header file.
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ VPE::VPointFProperty::VPointFProperty(const QString &name)
|
||||||
|
|
||||||
QVariant VPointFProperty::data(int column, int role) const
|
QVariant VPointFProperty::data(int column, int role) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Data && Qt::DisplayRole == role)
|
if (column == DPC_Data && Qt::DisplayRole == role)
|
||||||
{
|
{
|
||||||
return getPointF();
|
return getPointF();
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,10 @@ QVariant VPointFProperty::data(int column, int role) const
|
||||||
|
|
||||||
Qt::ItemFlags VPointFProperty::flags(int column) const
|
Qt::ItemFlags VPointFProperty::flags(int column) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Name || column == DPC_Data)
|
if (column == DPC_Name || column == DPC_Data)
|
||||||
|
{
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
}
|
}
|
||||||
|
@ -65,8 +67,10 @@ QPointF VPointFProperty::getPointF() const
|
||||||
{
|
{
|
||||||
QPointF tmpValue;
|
QPointF tmpValue;
|
||||||
|
|
||||||
if(d_ptr->Children.count() < 2)
|
if (d_ptr->Children.count() < 2)
|
||||||
|
{
|
||||||
return tmpValue;
|
return tmpValue;
|
||||||
|
}
|
||||||
|
|
||||||
tmpValue.setX(d_ptr->Children.at(0)->getValue().toDouble());
|
tmpValue.setX(d_ptr->Children.at(0)->getValue().toDouble());
|
||||||
tmpValue.setY(d_ptr->Children.at(1)->getValue().toDouble());
|
tmpValue.setY(d_ptr->Children.at(1)->getValue().toDouble());
|
||||||
|
@ -81,8 +85,10 @@ void VPointFProperty::setPointF(const QPointF &point)
|
||||||
|
|
||||||
void VPointFProperty::setPointF(qreal x, qreal y)
|
void VPointFProperty::setPointF(qreal x, qreal y)
|
||||||
{
|
{
|
||||||
if(d_ptr->Children.count() < 2)
|
if (d_ptr->Children.count() < 2)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant tmpX(x);
|
QVariant tmpX(x);
|
||||||
tmpX.convert(QVariant::Double);
|
tmpX.convert(QVariant::Double);
|
||||||
|
@ -101,19 +107,22 @@ QString VPointFProperty::type() const
|
||||||
|
|
||||||
VProperty *VPointFProperty::clone(bool include_children, VProperty *container) const
|
VProperty *VPointFProperty::clone(bool include_children, VProperty *container) const
|
||||||
{
|
{
|
||||||
if(!container) {
|
if (!container)
|
||||||
|
{
|
||||||
container = new VPointFProperty(getName());
|
container = new VPointFProperty(getName());
|
||||||
|
|
||||||
if(!include_children) {
|
if (!include_children)
|
||||||
|
{
|
||||||
QList<VProperty*> tmpChildren = container->getChildren();
|
QList<VProperty*> tmpChildren = container->getChildren();
|
||||||
foreach(VProperty* tmpChild, tmpChildren) {
|
foreach(VProperty* tmpChild, tmpChildren)
|
||||||
|
{
|
||||||
container->removeChild(tmpChild);
|
container->removeChild(tmpChild);
|
||||||
delete tmpChild;
|
delete tmpChild;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return VProperty::clone(false, container); // Child
|
return VProperty::clone(false, container); // Child
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPointFProperty::setValue(const QVariant &value)
|
void VPointFProperty::setValue(const QVariant &value)
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VPointFProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VPointFProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
@ -54,7 +55,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ VShortcutProperty::~VShortcutProperty()
|
||||||
|
|
||||||
QVariant VShortcutProperty::data (int column, int role) const
|
QVariant VShortcutProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
||||||
{
|
{
|
||||||
return d_ptr->VariantValue;
|
return d_ptr->VariantValue;
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,10 @@ QWidget* VShortcutProperty::createEditor(QWidget * parent, const QStyleOptionVie
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
|
|
||||||
VShortcutEditWidget* tmpWidget = new VShortcutEditWidget(parent);
|
VShortcutEditWidget* tmpWidget = new VShortcutEditWidget(parent);
|
||||||
if(delegate)
|
if (delegate)
|
||||||
|
{
|
||||||
VShortcutEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*)));
|
VShortcutEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*)));
|
||||||
|
}
|
||||||
|
|
||||||
return tmpWidget;
|
return tmpWidget;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -68,8 +70,10 @@ QWidget* VShortcutProperty::createEditor(QWidget * parent, const QStyleOptionVie
|
||||||
bool VShortcutProperty::setEditorData(QWidget* editor)
|
bool VShortcutProperty::setEditorData(QWidget* editor)
|
||||||
{
|
{
|
||||||
VShortcutEditWidget* tmpWidget = qobject_cast<VShortcutEditWidget*>(editor);
|
VShortcutEditWidget* tmpWidget = qobject_cast<VShortcutEditWidget*>(editor);
|
||||||
if(tmpWidget)
|
if (tmpWidget)
|
||||||
|
{
|
||||||
tmpWidget->setShortcut(d_ptr->VariantValue.toString(), false);
|
tmpWidget->setShortcut(d_ptr->VariantValue.toString(), false);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -80,8 +84,10 @@ bool VShortcutProperty::setEditorData(QWidget* editor)
|
||||||
QVariant VShortcutProperty::getEditorData(QWidget* editor) const
|
QVariant VShortcutProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
VShortcutEditWidget* tmpWidget = qobject_cast<VShortcutEditWidget*>(editor);
|
VShortcutEditWidget* tmpWidget = qobject_cast<VShortcutEditWidget*>(editor);
|
||||||
if(tmpWidget)
|
if (tmpWidget)
|
||||||
|
{
|
||||||
return tmpWidget->getShortcutAsString();
|
return tmpWidget->getShortcutAsString();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -101,4 +107,3 @@ void VShortcutProperty::setValue(const QVariant &value)
|
||||||
{
|
{
|
||||||
VProperty::setValue(QKeySequence::fromString(value.toString()).toString());
|
VProperty::setValue(QKeySequence::fromString(value.toString()).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
//! This property can be used to handle key shortcuts
|
//! This property can be used to handle key shortcuts
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VShortcutProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VShortcutProperty : public VProperty
|
||||||
|
@ -41,7 +42,8 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
|
//! slots.
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
const QAbstractItemDelegate* delegate);
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
|
@ -56,7 +58,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -51,13 +51,15 @@ VShortcutEditWidget::~VShortcutEditWidget()
|
||||||
|
|
||||||
bool VShortcutEditWidget::eventFilter(QObject *obj, QEvent *event)
|
bool VShortcutEditWidget::eventFilter(QObject *obj, QEvent *event)
|
||||||
{
|
{
|
||||||
if (obj == LineEdit) {
|
if (obj == LineEdit)
|
||||||
if (event->type() == QEvent::KeyPress) {
|
{
|
||||||
|
if (event->type() == QEvent::KeyPress)
|
||||||
|
{
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
||||||
|
|
||||||
int keys = keyEvent->key();
|
int keys = keyEvent->key();
|
||||||
|
|
||||||
if(keys != Qt::Key_Shift &&
|
if (keys != Qt::Key_Shift &&
|
||||||
keys != Qt::Key_Control &&
|
keys != Qt::Key_Control &&
|
||||||
keys != Qt::Key_Meta &&
|
keys != Qt::Key_Meta &&
|
||||||
keys != Qt::Key_AltGr &&
|
keys != Qt::Key_AltGr &&
|
||||||
|
@ -83,8 +85,6 @@ QKeySequence VShortcutEditWidget::getShortcut()
|
||||||
return CurrentKeySequence;
|
return CurrentKeySequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void VShortcutEditWidget::setShortcut(const QString &shortcut, bool emit_signal)
|
void VShortcutEditWidget::setShortcut(const QString &shortcut, bool emit_signal)
|
||||||
{
|
{
|
||||||
setShortcut(QKeySequence::fromString(shortcut), emit_signal);
|
setShortcut(QKeySequence::fromString(shortcut), emit_signal);
|
||||||
|
@ -92,11 +92,14 @@ void VShortcutEditWidget::setShortcut(const QString &shortcut, bool emit_signal)
|
||||||
|
|
||||||
void VShortcutEditWidget::setShortcut(const QKeySequence &shortcut, bool emit_signal)
|
void VShortcutEditWidget::setShortcut(const QKeySequence &shortcut, bool emit_signal)
|
||||||
{
|
{
|
||||||
if(shortcut != CurrentKeySequence) {
|
if (shortcut != CurrentKeySequence)
|
||||||
|
{
|
||||||
CurrentKeySequence = shortcut;
|
CurrentKeySequence = shortcut;
|
||||||
LineEdit->setText(CurrentKeySequence.toString());
|
LineEdit->setText(CurrentKeySequence.toString());
|
||||||
if(emit_signal)
|
if (emit_signal)
|
||||||
|
{
|
||||||
emit dataChangedByUser(CurrentKeySequence, this);
|
emit dataChangedByUser(CurrentKeySequence, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VShortcutEditWidget : public QWidget
|
class VPROPERTYEXPLORERSHARED_EXPORT VShortcutEditWidget : public QWidget
|
||||||
|
|
|
@ -61,8 +61,10 @@ QWidget *VPE::VStringProperty::createEditor(QWidget *parent, const QStyleOptionV
|
||||||
QVariant VPE::VStringProperty::getEditorData(QWidget *editor) const
|
QVariant VPE::VStringProperty::getEditorData(QWidget *editor) const
|
||||||
{
|
{
|
||||||
QLineEdit* tmpEditor = qobject_cast<QLineEdit*>(editor);
|
QLineEdit* tmpEditor = qobject_cast<QLineEdit*>(editor);
|
||||||
if(tmpEditor)
|
if (tmpEditor)
|
||||||
|
{
|
||||||
return tmpEditor->text();
|
return tmpEditor->text();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant(QStringLiteral(""));
|
return QVariant(QStringLiteral(""));
|
||||||
}
|
}
|
||||||
|
@ -74,18 +76,26 @@ void VPE::VStringProperty::setReadOnly(bool readOnly)
|
||||||
|
|
||||||
void VPE::VStringProperty::setSetting(const QString &key, const QVariant &value)
|
void VPE::VStringProperty::setSetting(const QString &key, const QVariant &value)
|
||||||
{
|
{
|
||||||
if(key == QLatin1String("ReadOnly"))
|
if (key == QLatin1String("ReadOnly"))
|
||||||
|
{
|
||||||
setReadOnly(value.toBool());
|
setReadOnly(value.toBool());
|
||||||
if(key == QLatin1String("TypeForParent"))
|
}
|
||||||
|
if (key == QLatin1String("TypeForParent"))
|
||||||
|
{
|
||||||
setTypeForParent(value.toInt());
|
setTypeForParent(value.toInt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant VPE::VStringProperty::getSetting(const QString &key) const
|
QVariant VPE::VStringProperty::getSetting(const QString &key) const
|
||||||
{
|
{
|
||||||
if(key == QLatin1String("ReadOnly"))
|
if (key == QLatin1String("ReadOnly"))
|
||||||
|
{
|
||||||
return readOnly;
|
return readOnly;
|
||||||
|
}
|
||||||
else if (key == QLatin1String("TypeForParent"))
|
else if (key == QLatin1String("TypeForParent"))
|
||||||
|
{
|
||||||
return typeForParent;
|
return typeForParent;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::getSetting(key);
|
return VProperty::getSetting(key);
|
||||||
}
|
}
|
||||||
|
@ -121,4 +131,3 @@ void VStringProperty::setTypeForParent(int value)
|
||||||
{
|
{
|
||||||
typeForParent = value;
|
typeForParent = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
//! Class for holding a string property
|
//! Class for holding a string property
|
||||||
|
@ -38,8 +39,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
@ -60,7 +63,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,6 @@
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VWidgetProperty::VWidgetProperty(const QString& name, QWidget* widget)
|
VWidgetProperty::VWidgetProperty(const QString& name, QWidget* widget)
|
||||||
: VEmptyProperty(new VWidgetPropertyPrivate(name, QVariant::Invalid, widget))
|
: VEmptyProperty(new VWidgetPropertyPrivate(name, QVariant::Invalid, widget))
|
||||||
{
|
{
|
||||||
|
@ -47,8 +44,10 @@ void VWidgetProperty::setWidget(QWidget* widget)
|
||||||
{
|
{
|
||||||
VWidgetPropertyPrivate* tmpDPtr = static_cast<VWidgetPropertyPrivate*>(d_ptr);
|
VWidgetPropertyPrivate* tmpDPtr = static_cast<VWidgetPropertyPrivate*>(d_ptr);
|
||||||
QWidget* tmpOldWidget = tmpDPtr->Widget.data();
|
QWidget* tmpOldWidget = tmpDPtr->Widget.data();
|
||||||
if(tmpOldWidget)
|
if (tmpOldWidget)
|
||||||
|
{
|
||||||
tmpOldWidget->deleteLater();
|
tmpOldWidget->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
tmpDPtr->Widget = widget;
|
tmpDPtr->Widget = widget;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +60,8 @@ QString VWidgetProperty::type() const
|
||||||
|
|
||||||
VProperty* VWidgetProperty::clone(bool include_children, VProperty* container) const
|
VProperty* VWidgetProperty::clone(bool include_children, VProperty* container) const
|
||||||
{
|
{
|
||||||
// todo: This is a tricky one to clone... don't know what would be the best way to do so... Maybe serialize the widget somehow?
|
/* todo: This is a tricky one to clone... don't know what would be the best way to do so... Maybe serialize the
|
||||||
|
* widget somehow?
|
||||||
|
*/
|
||||||
return VProperty::clone(include_children, container ? container : new VWidgetProperty(getName()));
|
return VProperty::clone(include_children, container ? container : new VWidgetProperty(getName()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,14 @@
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
// todo: this way, this class doesn't really make sense. What we have to do is pass a widget factory instead of the actual widget!
|
// todo: this way, this class doesn't really make sense. What we have to do is pass a widget factory instead of the
|
||||||
|
// actual widget!
|
||||||
|
|
||||||
//! This property holds a QWidget and displays it, if the view supports that. If not, it will behave like an empty property
|
//! This property holds a QWidget and displays it, if the view supports that. If not, it will behave like an empty
|
||||||
|
//! property
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VWidgetProperty : public VEmptyProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VWidgetProperty : public VEmptyProperty
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -52,7 +55,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VProperty;
|
class VProperty;
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,11 @@
|
||||||
|
|
||||||
#include "vproperty_p.h"
|
#include "vproperty_p.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VFilePropertyPrivate : public VPropertyPrivate {
|
class VFilePropertyPrivate : public VPropertyPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! File filters
|
//! File filters
|
||||||
QString FileFilters;
|
QString FileFilters;
|
||||||
|
|
|
@ -45,7 +45,7 @@ VProperty::~VProperty()
|
||||||
{
|
{
|
||||||
setParent(nullptr);
|
setParent(nullptr);
|
||||||
|
|
||||||
while(!d_ptr->Children.isEmpty())
|
while (!d_ptr->Children.isEmpty())
|
||||||
{
|
{
|
||||||
VProperty* tmpChild = d_ptr->Children.takeLast();
|
VProperty* tmpChild = d_ptr->Children.takeLast();
|
||||||
delete tmpChild;
|
delete tmpChild;
|
||||||
|
@ -62,12 +62,18 @@ QString VProperty::type() const
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
QVariant VProperty::data (int column, int role) const
|
QVariant VProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Name && Qt::DisplayRole == role)
|
if (column == DPC_Name && Qt::DisplayRole == role)
|
||||||
|
{
|
||||||
return QVariant(d_ptr->Name);
|
return QVariant(d_ptr->Name);
|
||||||
else if(column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
}
|
||||||
|
else if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
||||||
|
{
|
||||||
return d_ptr->VariantValue;
|
return d_ptr->VariantValue;
|
||||||
else if(Qt::ToolTipRole == role)
|
}
|
||||||
|
else if (Qt::ToolTipRole == role)
|
||||||
|
{
|
||||||
return QVariant(d_ptr->Description);
|
return QVariant(d_ptr->Description);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -75,7 +81,7 @@ QVariant VProperty::data (int column, int role) const
|
||||||
bool VProperty::setData(const QVariant &data, int role)
|
bool VProperty::setData(const QVariant &data, int role)
|
||||||
{
|
{
|
||||||
bool tmpResult = false;
|
bool tmpResult = false;
|
||||||
if(Qt::EditRole == role)
|
if (Qt::EditRole == role)
|
||||||
{
|
{
|
||||||
tmpResult = (d_ptr->VariantValue != data);
|
tmpResult = (d_ptr->VariantValue != data);
|
||||||
setValue(data);
|
setValue(data);
|
||||||
|
@ -84,7 +90,8 @@ bool VProperty::setData(const QVariant &data, int role)
|
||||||
return tmpResult;
|
return tmpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VProperty::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, const QAbstractItemDelegate *delegate) const
|
bool VProperty::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index,
|
||||||
|
const QAbstractItemDelegate *delegate) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(painter);
|
Q_UNUSED(painter);
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
|
@ -95,7 +102,8 @@ bool VProperty::paint(QPainter *painter, const QStyleOptionViewItem &option, con
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
QWidget* VProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
Q_UNUSED(delegate);
|
Q_UNUSED(delegate);
|
||||||
|
@ -111,12 +119,15 @@ QWidget* VProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& o
|
||||||
|
|
||||||
bool VProperty::setEditorData(QWidget* editor)
|
bool VProperty::setEditorData(QWidget* editor)
|
||||||
{
|
{
|
||||||
if(!editor)
|
if (!editor)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray n = editor->metaObject()->userProperty().name();
|
QByteArray n = editor->metaObject()->userProperty().name();
|
||||||
|
|
||||||
if (!n.isEmpty()) {
|
if (!n.isEmpty())
|
||||||
|
{
|
||||||
editor->blockSignals(true);
|
editor->blockSignals(true);
|
||||||
editor->setProperty(n, d_ptr->VariantValue);
|
editor->setProperty(n, d_ptr->VariantValue);
|
||||||
editor->blockSignals(false);
|
editor->blockSignals(false);
|
||||||
|
@ -129,13 +140,17 @@ bool VProperty::setEditorData(QWidget* editor)
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
QVariant VProperty::getEditorData(QWidget* editor) const
|
QVariant VProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
if(!editor)
|
if (!editor)
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray n = editor->metaObject()->userProperty().name();
|
QByteArray n = editor->metaObject()->userProperty().name();
|
||||||
|
|
||||||
if (!n.isEmpty())
|
if (!n.isEmpty())
|
||||||
|
{
|
||||||
return editor->property(n);
|
return editor->property(n);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -143,10 +158,14 @@ QVariant VProperty::getEditorData(QWidget* editor) const
|
||||||
//! Returns item flags
|
//! Returns item flags
|
||||||
Qt::ItemFlags VProperty::flags(int column) const
|
Qt::ItemFlags VProperty::flags(int column) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Name)
|
if (column == DPC_Name)
|
||||||
|
{
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
else if(column == DPC_Data)
|
}
|
||||||
|
else if (column == DPC_Data)
|
||||||
|
{
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +181,6 @@ void VProperty::setValue(const QVariant &value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant VProperty::getValue() const
|
QVariant VProperty::getValue() const
|
||||||
{
|
{
|
||||||
return d_ptr->VariantValue;
|
return d_ptr->VariantValue;
|
||||||
|
@ -202,9 +220,6 @@ QString VProperty::getDescription() const
|
||||||
return d_ptr->Description;
|
return d_ptr->Description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! Returns a reference to the list of children
|
//! Returns a reference to the list of children
|
||||||
QList<VProperty*>& VProperty::getChildren()
|
QList<VProperty*>& VProperty::getChildren()
|
||||||
{
|
{
|
||||||
|
@ -220,8 +235,10 @@ const QList<VProperty*>& VProperty::getChildren() const
|
||||||
//! Returns the child at a certain row
|
//! Returns the child at a certain row
|
||||||
VProperty* VProperty::getChild(int row) const
|
VProperty* VProperty::getChild(int row) const
|
||||||
{
|
{
|
||||||
if(row >= 0 && row < getRowCount())
|
if (row >= 0 && row < getRowCount())
|
||||||
|
{
|
||||||
return d_ptr->Children.at(row);
|
return d_ptr->Children.at(row);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -241,25 +258,33 @@ VProperty* VProperty::getParent() const
|
||||||
//! Sets the parent of this property
|
//! Sets the parent of this property
|
||||||
void VProperty::setParent(VProperty* parent)
|
void VProperty::setParent(VProperty* parent)
|
||||||
{
|
{
|
||||||
if(d_ptr->Parent == parent)
|
if (d_ptr->Parent == parent)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VProperty* oldParent = d_ptr->Parent;
|
VProperty* oldParent = d_ptr->Parent;
|
||||||
d_ptr->Parent = parent;
|
d_ptr->Parent = parent;
|
||||||
|
|
||||||
if(oldParent)
|
if (oldParent)
|
||||||
|
{
|
||||||
oldParent->removeChild(this);
|
oldParent->removeChild(this);
|
||||||
|
}
|
||||||
|
|
||||||
if(d_ptr->Parent && d_ptr->Parent->getChildRow(this) == -1)
|
if (d_ptr->Parent && d_ptr->Parent->getChildRow(this) == -1)
|
||||||
|
{
|
||||||
d_ptr->Parent->addChild(this);
|
d_ptr->Parent->addChild(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int VProperty::addChild(VProperty *child)
|
int VProperty::addChild(VProperty *child)
|
||||||
{
|
{
|
||||||
if(child && child->getParent() != this)
|
if (child && child->getParent() != this)
|
||||||
|
{
|
||||||
child->setParent(this);
|
child->setParent(this);
|
||||||
|
}
|
||||||
|
|
||||||
if(!d_ptr->Children.contains(child) && child != nullptr)
|
if (!d_ptr->Children.contains(child) && child != nullptr)
|
||||||
{
|
{
|
||||||
d_ptr->Children.push_back(child);
|
d_ptr->Children.push_back(child);
|
||||||
return d_ptr->Children.count()-1;
|
return d_ptr->Children.count()-1;
|
||||||
|
@ -275,8 +300,10 @@ void VProperty::removeChild(VProperty* child)
|
||||||
{
|
{
|
||||||
d_ptr->Children.removeAll(child);
|
d_ptr->Children.removeAll(child);
|
||||||
|
|
||||||
if(child && child->getParent() == this)
|
if (child && child->getParent() == this)
|
||||||
|
{
|
||||||
child->setParent(nullptr);
|
child->setParent(nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns the row the child has
|
//! Returns the row the child has
|
||||||
|
@ -285,7 +312,6 @@ int VProperty::getChildRow(VProperty* child) const
|
||||||
return d_ptr->Children.indexOf(child);
|
return d_ptr->Children.indexOf(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Returns whether the views have to update the parent of this property if it changes
|
//! Returns whether the views have to update the parent of this property if it changes
|
||||||
bool VProperty::getUpdateParent() const
|
bool VProperty::getUpdateParent() const
|
||||||
{
|
{
|
||||||
|
@ -309,7 +335,8 @@ void VProperty::setUpdateBehaviour(bool update_parent, bool update_children)
|
||||||
void VProperty::setSettings(const QMap<QString, QVariant>& settings)
|
void VProperty::setSettings(const QMap<QString, QVariant>& settings)
|
||||||
{
|
{
|
||||||
QMap<QString, QVariant>::const_iterator tmpIterator = settings.constBegin();
|
QMap<QString, QVariant>::const_iterator tmpIterator = settings.constBegin();
|
||||||
for (; tmpIterator != settings.constEnd(); ++tmpIterator) {
|
for (; tmpIterator != settings.constEnd(); ++tmpIterator)
|
||||||
|
{
|
||||||
setSetting(tmpIterator.key(), tmpIterator.value());
|
setSetting(tmpIterator.key(), tmpIterator.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,8 +373,10 @@ QStringList VProperty::getSettingKeys() const
|
||||||
|
|
||||||
VProperty* VProperty::clone(bool include_children, VProperty* container) const
|
VProperty* VProperty::clone(bool include_children, VProperty* container) const
|
||||||
{
|
{
|
||||||
if(!container)
|
if (!container)
|
||||||
|
{
|
||||||
container = new VProperty(getName(), d_ptr->PropertyVariantType);
|
container = new VProperty(getName(), d_ptr->PropertyVariantType);
|
||||||
|
}
|
||||||
|
|
||||||
container->setName(getName());
|
container->setName(getName());
|
||||||
container->setDescription(getDescription());
|
container->setDescription(getDescription());
|
||||||
|
@ -356,7 +385,8 @@ VProperty* VProperty::clone(bool include_children, VProperty* container) const
|
||||||
container->setUpdateBehaviour(getUpdateParent(), getUpdateChildren());
|
container->setUpdateBehaviour(getUpdateParent(), getUpdateChildren());
|
||||||
container->setPropertyType(propertyType());
|
container->setPropertyType(propertyType());
|
||||||
|
|
||||||
if(include_children) {
|
if (include_children)
|
||||||
|
{
|
||||||
foreach(VProperty* tmpChild, d_ptr->Children)
|
foreach(VProperty* tmpChild, d_ptr->Children)
|
||||||
container->addChild(tmpChild->clone(true));
|
container->addChild(tmpChild->clone(true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,8 @@
|
||||||
#include <QAbstractItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
enum class Property : char{Simple, Complex};
|
enum class Property : char{Simple, Complex};
|
||||||
|
|
||||||
|
@ -48,7 +49,8 @@ class VPROPERTYEXPLORERSHARED_EXPORT VProperty : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum DPC_DisplayColumn {
|
enum DPC_DisplayColumn
|
||||||
|
{
|
||||||
DPC_Name = 0,
|
DPC_Name = 0,
|
||||||
DPC_Data
|
DPC_Data
|
||||||
};
|
};
|
||||||
|
@ -74,13 +76,16 @@ public:
|
||||||
//! This is called by the delegate when the property value is being drawn.
|
//! This is called by the delegate when the property value is being drawn.
|
||||||
//! The standard implementation doesn't do anything.
|
//! The standard implementation doesn't do anything.
|
||||||
//! If you reimplement this in a sub property, make sure to return true or the delegate will draw the item.
|
//! If you reimplement this in a sub property, make sure to return true or the delegate will draw the item.
|
||||||
virtual bool paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, const QAbstractItemDelegate* delegate) const;
|
virtual bool paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index,
|
||||||
|
const QAbstractItemDelegate* delegate) const;
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
||||||
virtual bool setEditorData(QWidget* editor);
|
virtual bool setEditorData(QWidget* editor);
|
||||||
|
@ -104,12 +109,15 @@ public:
|
||||||
virtual void deserialize(const QString& value);
|
virtual void deserialize(const QString& value);
|
||||||
|
|
||||||
// The following functions are experimental and not yet implemented.
|
// The following functions are experimental and not yet implemented.
|
||||||
/*//! Returns a pointer to the data stored and handled by this property. In most cases this function shouldn't be used.
|
/*//! Returns a pointer to the data stored and handled by this property. In most cases this function shouldn't be
|
||||||
//! \return Returns a void pointer to the data. Not all properties have to support this. By default, this implementation returns a NULL pointer.
|
//! used.
|
||||||
|
//! \return Returns a void pointer to the data. Not all properties have to support this. By default, this
|
||||||
|
//! implementation returns a NULL pointer.
|
||||||
virtual void* getDataPointer();
|
virtual void* getDataPointer();
|
||||||
|
|
||||||
//! Sets the data.
|
//! Sets the data.
|
||||||
//! \return Returns a void pointer to the data. Not all properties have to support this. By default, this implementation returns a NULL pointer.
|
//! \return Returns a void pointer to the data. Not all properties have to support this. By default, this
|
||||||
|
//! implementation returns a NULL pointer.
|
||||||
virtual bool setDataPointer(void* pointer);*/
|
virtual bool setDataPointer(void* pointer);*/
|
||||||
|
|
||||||
//! Sets the name of the property
|
//! Sets the name of the property
|
||||||
|
@ -160,7 +168,8 @@ public:
|
||||||
//! Sets whether the views should update Parents or children after this property changes
|
//! Sets whether the views should update Parents or children after this property changes
|
||||||
virtual void setUpdateBehaviour(bool update_parent, bool update_children);
|
virtual void setUpdateBehaviour(bool update_parent, bool update_children);
|
||||||
|
|
||||||
//! Sets the settings by calling the overloaded setSetting(const QString& key, const QVariant& value) for each item in the map.
|
//! Sets the settings by calling the overloaded setSetting(const QString& key, const QVariant& value) for each item
|
||||||
|
//! in the map.
|
||||||
virtual void setSettings(const QMap<QString, QVariant>& settings);
|
virtual void setSettings(const QMap<QString, QVariant>& settings);
|
||||||
|
|
||||||
//! Get the settings.
|
//! Get the settings.
|
||||||
|
@ -177,7 +186,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,11 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyPrivate {
|
class VPropertyPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! The property's value.
|
//! The property's value.
|
||||||
//! This does not have to be used by subclasses, but it makes sense in cases where QVariant supports
|
//! This does not have to be used by subclasses, but it makes sense in cases where QVariant supports
|
||||||
|
|
|
@ -38,10 +38,11 @@ VPropertyDelegate::~VPropertyDelegate()
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* VPropertyDelegate::createEditor (QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
QWidget* VPropertyDelegate::createEditor (QWidget* parent, const QStyleOptionViewItem& option,
|
||||||
|
const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
QWidget* tmpWidget = nullptr;
|
QWidget* tmpWidget = nullptr;
|
||||||
if(index.isValid())
|
if (index.isValid())
|
||||||
{
|
{
|
||||||
VProperty* tmpProperty = reinterpret_cast<VProperty*>(index.internalPointer());
|
VProperty* tmpProperty = reinterpret_cast<VProperty*>(index.internalPointer());
|
||||||
tmpWidget = tmpProperty->createEditor(parent, option, this);
|
tmpWidget = tmpProperty->createEditor(parent, option, this);
|
||||||
|
@ -55,28 +56,32 @@ QWidget* VPropertyDelegate::createEditor (QWidget* parent, const QStyleOptionVie
|
||||||
void VPropertyDelegate::setEditorData (QWidget * editor, const QModelIndex & index) const
|
void VPropertyDelegate::setEditorData (QWidget * editor, const QModelIndex & index) const
|
||||||
{
|
{
|
||||||
bool done = false;
|
bool done = false;
|
||||||
if(index.isValid() && editor)
|
if (index.isValid() && editor)
|
||||||
{
|
{
|
||||||
VProperty* tmpProperty = reinterpret_cast<VProperty*>(index.internalPointer());
|
VProperty* tmpProperty = reinterpret_cast<VProperty*>(index.internalPointer());
|
||||||
done = tmpProperty->setEditorData(editor);
|
done = tmpProperty->setEditorData(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!done)
|
if (!done)
|
||||||
|
{
|
||||||
QStyledItemDelegate::setEditorData(editor, index);
|
QStyledItemDelegate::setEditorData(editor, index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Updates the index data
|
//! Updates the index data
|
||||||
void VPropertyDelegate::setModelData (QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
|
void VPropertyDelegate::setModelData (QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
|
||||||
{
|
{
|
||||||
QVariant tmpData;
|
QVariant tmpData;
|
||||||
if(index.isValid() && editor)
|
if (index.isValid() && editor)
|
||||||
{
|
{
|
||||||
VProperty* tmpProperty = reinterpret_cast<VProperty*>(index.internalPointer());
|
VProperty* tmpProperty = reinterpret_cast<VProperty*>(index.internalPointer());
|
||||||
tmpData = tmpProperty->getEditorData(editor);
|
tmpData = tmpProperty->getEditorData(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tmpData.isNull())
|
if (tmpData.isNull())
|
||||||
|
{
|
||||||
QStyledItemDelegate::setModelData(editor, model, index);
|
QStyledItemDelegate::setModelData(editor, model, index);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
model->setData(index, tmpData);
|
model->setData(index, tmpData);
|
||||||
}
|
}
|
||||||
|
@ -86,8 +91,10 @@ QSize VPropertyDelegate::sizeHint (const QStyleOptionViewItem& option, const QMo
|
||||||
QSize tmpStandardSizeHint = QStyledItemDelegate::sizeHint(option, index);
|
QSize tmpStandardSizeHint = QStyledItemDelegate::sizeHint(option, index);
|
||||||
tmpStandardSizeHint.setHeight(tmpStandardSizeHint.height() + 1);
|
tmpStandardSizeHint.setHeight(tmpStandardSizeHint.height() + 1);
|
||||||
|
|
||||||
if(RowHeight > 0)
|
if (RowHeight > 0)
|
||||||
|
{
|
||||||
return QSize(tmpStandardSizeHint.width(), AddRowHeight ? tmpStandardSizeHint.height() + RowHeight : RowHeight);
|
return QSize(tmpStandardSizeHint.width(), AddRowHeight ? tmpStandardSizeHint.height() + RowHeight : RowHeight);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return tmpStandardSizeHint;
|
return tmpStandardSizeHint;
|
||||||
}
|
}
|
||||||
|
@ -101,11 +108,15 @@ void VPropertyDelegate::setRowHeight(int height, bool add_to_standard)
|
||||||
void VPropertyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
void VPropertyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
bool done = false;
|
bool done = false;
|
||||||
if(index.isValid() && index.column() == 1)
|
if (index.isValid() && index.column() == 1)
|
||||||
|
{
|
||||||
done = reinterpret_cast<VProperty*>(index.internalPointer())->paint(painter, option, index, this);
|
done = reinterpret_cast<VProperty*>(index.internalPointer())->paint(painter, option, index, this);
|
||||||
|
}
|
||||||
|
|
||||||
if(!done)
|
if (!done)
|
||||||
|
{
|
||||||
QStyledItemDelegate::paint(painter, option, index);
|
QStyledItemDelegate::paint(painter, option, index);
|
||||||
|
}
|
||||||
|
|
||||||
QColor tmpPenColor = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &option));
|
QColor tmpPenColor = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &option));
|
||||||
|
|
||||||
|
@ -115,6 +126,3 @@ void VPropertyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opt
|
||||||
painter->drawLine(option.rect.x(), option.rect.bottom(), option.rect.right(), option.rect.bottom());
|
painter->drawLine(option.rect.x(), option.rect.bottom(), option.rect.right(), option.rect.bottom());
|
||||||
painter->setPen(tmpOldPen);
|
painter->setPen(tmpOldPen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyDelegate : public QStyledItemDelegate
|
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,8 @@ VPropertyFactoryManager::~VPropertyFactoryManager()
|
||||||
{
|
{
|
||||||
// Delete all factories
|
// Delete all factories
|
||||||
QList<VAbstractPropertyFactory*> tmpFactories = d_ptr->Factories.values();
|
QList<VAbstractPropertyFactory*> tmpFactories = d_ptr->Factories.values();
|
||||||
while(!tmpFactories.isEmpty()) {
|
while (!tmpFactories.isEmpty())
|
||||||
|
{
|
||||||
VAbstractPropertyFactory* tmpFactory = tmpFactories.takeLast();
|
VAbstractPropertyFactory* tmpFactory = tmpFactories.takeLast();
|
||||||
tmpFactories.removeAll(tmpFactory);
|
tmpFactories.removeAll(tmpFactory);
|
||||||
delete tmpFactory;
|
delete tmpFactory;
|
||||||
|
@ -47,14 +48,18 @@ VPropertyFactoryManager::~VPropertyFactoryManager()
|
||||||
|
|
||||||
|
|
||||||
delete d_ptr;
|
delete d_ptr;
|
||||||
if(this == DefaultManager)
|
if (this == DefaultManager)
|
||||||
|
{
|
||||||
DefaultManager = NULL;
|
DefaultManager = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFactoryManager::registerFactory(const QString& type, VAbstractPropertyFactory* factory)
|
void VPropertyFactoryManager::registerFactory(const QString& type, VAbstractPropertyFactory* factory)
|
||||||
{
|
{
|
||||||
if(type.isEmpty())
|
if (type.isEmpty())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove old factory
|
// Remove old factory
|
||||||
unregisterFactory(getFactory(type), type, true);
|
unregisterFactory(getFactory(type), type, true);
|
||||||
|
@ -62,26 +67,40 @@ void VPropertyFactoryManager::registerFactory(const QString& type, VAbstractProp
|
||||||
d_ptr->Factories[type] = factory;
|
d_ptr->Factories[type] = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFactoryManager::unregisterFactory(VAbstractPropertyFactory* factory, const QString& type, bool delete_if_unused)
|
void VPropertyFactoryManager::unregisterFactory(VAbstractPropertyFactory* factory, const QString& type,
|
||||||
|
bool delete_if_unused)
|
||||||
{
|
{
|
||||||
if(!factory)
|
if (!factory)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!type.isEmpty()) {
|
|
||||||
// Remove all occurances
|
|
||||||
QString tmpKey;
|
|
||||||
do {
|
|
||||||
tmpKey = d_ptr->Factories.key(factory, QString());
|
|
||||||
if(!tmpKey.isEmpty()) d_ptr->Factories.remove(tmpKey);
|
|
||||||
} while(!tmpKey.isEmpty());
|
|
||||||
} else {
|
|
||||||
// Only remove one type
|
|
||||||
if(d_ptr->Factories.value(type, NULL) == factory)
|
|
||||||
d_ptr->Factories.remove(type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(delete_if_unused && !isRegistered(factory))
|
if (!type.isEmpty())
|
||||||
|
{
|
||||||
|
// Remove all occurances
|
||||||
|
QString tmpKey;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
tmpKey = d_ptr->Factories.key(factory, QString());
|
||||||
|
if (!tmpKey.isEmpty())
|
||||||
|
{
|
||||||
|
d_ptr->Factories.remove(tmpKey);
|
||||||
|
}
|
||||||
|
} while(!tmpKey.isEmpty());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Only remove one type
|
||||||
|
if (d_ptr->Factories.value(type, NULL) == factory)
|
||||||
|
{
|
||||||
|
d_ptr->Factories.remove(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delete_if_unused && !isRegistered(factory))
|
||||||
|
{
|
||||||
delete factory;
|
delete factory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VPropertyFactoryManager::isRegistered(VAbstractPropertyFactory* factory)
|
bool VPropertyFactoryManager::isRegistered(VAbstractPropertyFactory* factory)
|
||||||
|
@ -95,18 +114,23 @@ VAbstractPropertyFactory* VPropertyFactoryManager::getFactory(const QString& typ
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VProperty* VPropertyFactoryManager::createProperty(const QString& type, const QString& name, const QString& description, const QString &default_value)
|
VProperty* VPropertyFactoryManager::createProperty(const QString& type, const QString& name, const QString& description,
|
||||||
|
const QString &default_value)
|
||||||
{
|
{
|
||||||
VAbstractPropertyFactory* tmpFactory = getFactory(type);
|
VAbstractPropertyFactory* tmpFactory = getFactory(type);
|
||||||
VProperty* tmpResult = NULL;
|
VProperty* tmpResult = NULL;
|
||||||
if(tmpFactory) {
|
if (tmpFactory)
|
||||||
|
{
|
||||||
tmpResult = tmpFactory->createProperty(type, name);
|
tmpResult = tmpFactory->createProperty(type, name);
|
||||||
|
|
||||||
if(tmpResult) {
|
if (tmpResult)
|
||||||
|
{
|
||||||
tmpResult->setDescription(description);
|
tmpResult->setDescription(description);
|
||||||
|
|
||||||
if(!default_value.isEmpty())
|
if (!default_value.isEmpty())
|
||||||
|
{
|
||||||
tmpResult->deserialize(default_value);
|
tmpResult->deserialize(default_value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +139,8 @@ VProperty* VPropertyFactoryManager::createProperty(const QString& type, const QS
|
||||||
|
|
||||||
VPropertyFactoryManager *VPropertyFactoryManager::getDefaultManager()
|
VPropertyFactoryManager *VPropertyFactoryManager::getDefaultManager()
|
||||||
{
|
{
|
||||||
if(!DefaultManager) {
|
if (!DefaultManager)
|
||||||
|
{
|
||||||
DefaultManager = new VPropertyFactoryManager();
|
DefaultManager = new VPropertyFactoryManager();
|
||||||
/*VStandardPropertyFactory* tmpStandardProp = */new VStandardPropertyFactory(DefaultManager);
|
/*VStandardPropertyFactory* tmpStandardProp = */new VStandardPropertyFactory(DefaultManager);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VAbstractPropertyFactory;
|
class VAbstractPropertyFactory;
|
||||||
class VPropertyFactoryManagerPrivate;
|
class VPropertyFactoryManagerPrivate;
|
||||||
|
@ -47,8 +48,10 @@ public:
|
||||||
|
|
||||||
//! Removes a factory from the manager.
|
//! Removes a factory from the manager.
|
||||||
//! \param factory The factory to unregister
|
//! \param factory The factory to unregister
|
||||||
//! \param type The type from which to remove the factory. If this is empty, all the types the factory is registered for are being removed
|
//! \param type The type from which to remove the factory. If this is empty, all the types the factory is registered
|
||||||
//! \param delete_if_unused Determines whether the factory should be deleted, if it not used anymore by this manager. Default: true. Otherwise, if the factory is unused by this manager, ownership is being passed on.
|
//! for are being removed
|
||||||
|
//! \param delete_if_unused Determines whether the factory should be deleted, if it not used anymore by this
|
||||||
|
//! manager. Default: true. Otherwise, if the factory is unused by this manager, ownership is being passed on.
|
||||||
void unregisterFactory(VAbstractPropertyFactory* factory, const QString& type = QString(),
|
void unregisterFactory(VAbstractPropertyFactory* factory, const QString& type = QString(),
|
||||||
bool delete_if_unused = true);
|
bool delete_if_unused = true);
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,13 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VAbstractPropertyFactory;
|
class VAbstractPropertyFactory;
|
||||||
|
|
||||||
class VPropertyFactoryManagerPrivate {
|
class VPropertyFactoryManagerPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
QMap<QString, VAbstractPropertyFactory*> Factories;
|
QMap<QString, VAbstractPropertyFactory*> Factories;
|
||||||
|
|
||||||
|
|
|
@ -67,16 +67,21 @@ void VPropertyFormView::setModel(VPropertyModel *model)
|
||||||
|
|
||||||
// Set model
|
// Set model
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model = model;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model = model;
|
||||||
if(model) {
|
if (model)
|
||||||
|
{
|
||||||
// Set the property list
|
// Set the property list
|
||||||
if(model->getPropertySet())
|
if (model->getPropertySet())
|
||||||
|
{
|
||||||
d_ptr->Properties = model->getPropertySet()->getRootProperties();
|
d_ptr->Properties = model->getPropertySet()->getRootProperties();
|
||||||
|
}
|
||||||
|
|
||||||
// Connect signals // todo: more signals neccesary!!!
|
// Connect signals // todo: more signals neccesary!!!
|
||||||
connect(model, SIGNAL(destroyed()), this, SLOT(modelDestroyed()));
|
connect(model, SIGNAL(destroyed()), this, SLOT(modelDestroyed()));
|
||||||
connect(model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this, SLOT(rowsInserted(QModelIndex,int,int)));
|
connect(model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this,
|
||||||
|
SLOT(rowsInserted(QModelIndex, int, int)));
|
||||||
connect(model, SIGNAL(modelReset()), this, SLOT(modelReset()));
|
connect(model, SIGNAL(modelReset()), this, SLOT(modelReset()));
|
||||||
connect(model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, SLOT(rowsRemoved(QModelIndex,int,int)));
|
connect(model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this,
|
||||||
|
SLOT(rowsRemoved(QModelIndex, int, int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the widget
|
// Build the widget
|
||||||
|
@ -90,7 +95,8 @@ void VPropertyFormView::setPropertySet(VPropertySet* property_set)
|
||||||
|
|
||||||
// Set property set
|
// Set property set
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->PropertySet = property_set;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->PropertySet = property_set;
|
||||||
if(property_set) {
|
if (property_set)
|
||||||
|
{
|
||||||
// Set the property list
|
// Set the property list
|
||||||
d_ptr->Properties = property_set->getRootProperties();
|
d_ptr->Properties = property_set->getRootProperties();
|
||||||
}
|
}
|
||||||
|
@ -130,8 +136,10 @@ void VPropertyFormView::modelDestroyed()
|
||||||
|
|
||||||
void VPropertyFormView::dataChanged(const QModelIndex &top_left, const QModelIndex &bottom_right)
|
void VPropertyFormView::dataChanged(const QModelIndex &top_left, const QModelIndex &bottom_right)
|
||||||
{
|
{
|
||||||
if(static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal)
|
if (static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
// todo: handle data changes
|
// todo: handle data changes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +147,8 @@ void VPropertyFormView::dataSubmitted(VProperty *property)
|
||||||
{
|
{
|
||||||
VPropertyModel* tmpModel = static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model;
|
VPropertyModel* tmpModel = static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model;
|
||||||
|
|
||||||
if(tmpModel && d_ptr->UpdateEditors) {
|
if (tmpModel && d_ptr->UpdateEditors)
|
||||||
|
{
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal = true;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal = true;
|
||||||
tmpModel->onDataChangedByModel(property);
|
tmpModel->onDataChangedByModel(property);
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal = false;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal = false;
|
||||||
|
@ -149,8 +158,10 @@ void VPropertyFormView::dataSubmitted(VProperty *property)
|
||||||
void VPropertyFormView::showEvent(QShowEvent *event)
|
void VPropertyFormView::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
if(static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild)
|
if (static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild)
|
||||||
|
{
|
||||||
build();
|
build();
|
||||||
|
}
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild = false;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,22 +170,29 @@ void VPropertyFormView::updatePropertyList()
|
||||||
VPropertyModel* tmpModel = static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model;
|
VPropertyModel* tmpModel = static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model;
|
||||||
VPropertySet* tmpSet = static_cast<VPropertyFormViewPrivate*>(d_ptr)->PropertySet;
|
VPropertySet* tmpSet = static_cast<VPropertyFormViewPrivate*>(d_ptr)->PropertySet;
|
||||||
|
|
||||||
if(tmpModel && tmpModel->getPropertySet())
|
if (tmpModel && tmpModel->getPropertySet())
|
||||||
|
{
|
||||||
d_ptr->Properties = tmpModel->getPropertySet()->getRootProperties();
|
d_ptr->Properties = tmpModel->getPropertySet()->getRootProperties();
|
||||||
else if(tmpSet)
|
}
|
||||||
|
else if (tmpSet)
|
||||||
|
{
|
||||||
d_ptr->Properties = tmpSet->getRootProperties();
|
d_ptr->Properties = tmpSet->getRootProperties();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
d_ptr->Properties.clear();
|
d_ptr->Properties.clear();
|
||||||
|
|
||||||
if(isVisible())
|
if (isVisible())
|
||||||
|
{
|
||||||
build();
|
build();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild = true;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormView::removeModelAndSet()
|
void VPropertyFormView::removeModelAndSet()
|
||||||
{
|
{
|
||||||
if(static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model) {
|
if (static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model)
|
||||||
|
{
|
||||||
disconnect(static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model, 0, this, 0);
|
disconnect(static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model, 0, this, 0);
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model = nullptr;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -186,14 +204,17 @@ void VPropertyFormView::removeModelAndSet()
|
||||||
|
|
||||||
void VPropertyFormView::connectPropertyFormWidget(VPropertyFormWidget *widget)
|
void VPropertyFormView::connectPropertyFormWidget(VPropertyFormWidget *widget)
|
||||||
{
|
{
|
||||||
if(!widget)
|
if (!widget)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
connect(widget, &VPropertyFormWidget::propertyDataSubmitted, this, &VPropertyFormView::dataSubmitted,
|
connect(widget, &VPropertyFormWidget::propertyDataSubmitted, this, &VPropertyFormView::dataSubmitted,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
QList<VPropertyFormWidget*> tmpList = widget->getChildPropertyFormWidgets();
|
QList<VPropertyFormWidget*> tmpList = widget->getChildPropertyFormWidgets();
|
||||||
|
|
||||||
foreach(VPropertyFormWidget* tmpEditorWidget, tmpList) {
|
foreach(VPropertyFormWidget* tmpEditorWidget, tmpList)
|
||||||
|
{
|
||||||
connectPropertyFormWidget(tmpEditorWidget);
|
connectPropertyFormWidget(tmpEditorWidget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include "vpropertyformwidget.h"
|
#include "vpropertyformwidget.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VProperty;
|
class VProperty;
|
||||||
class VPropertyModel;
|
class VPropertyModel;
|
||||||
|
@ -57,7 +58,8 @@ public slots:
|
||||||
//! \param model The model to use
|
//! \param model The model to use
|
||||||
void setModel(VPropertyModel* model);
|
void setModel(VPropertyModel* model);
|
||||||
|
|
||||||
//! Set the property set to use. Note that if using a property set directly, adding and removing properties to the property set leads to undifined behaviour for the property set misses notification signals.
|
//! Set the property set to use. Note that if using a property set directly, adding and removing properties to the
|
||||||
|
//! property set leads to undifined behaviour for the property set misses notification signals.
|
||||||
//! \param model The property set to use
|
//! \param model The property set to use
|
||||||
void setPropertySet(VPropertySet* property_set);
|
void setPropertySet(VPropertySet* property_set);
|
||||||
|
|
||||||
|
@ -96,6 +98,6 @@ protected:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace VPE
|
} // Namespace VPE
|
||||||
|
|
||||||
#endif // VPROPERTYFORMVIEW_H
|
#endif // VPROPERTYFORMVIEW_H
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#include "vpropertyformwidget_p.h"
|
#include "vpropertyformwidget_p.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyModel;
|
class VPropertyModel;
|
||||||
class VPropertySet;
|
class VPropertySet;
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VPropertyFormWidget::VPropertyFormWidget(const QString &title, const QString &description, const QList<VProperty*>& properties, QWidget *parent)
|
VPropertyFormWidget::VPropertyFormWidget(const QString &title, const QString &description,
|
||||||
|
const QList<VProperty*>& properties, QWidget *parent)
|
||||||
: QGroupBox(title, parent), d_ptr(new VPropertyFormWidgetPrivate(properties))
|
: QGroupBox(title, parent), d_ptr(new VPropertyFormWidgetPrivate(properties))
|
||||||
{
|
{
|
||||||
build();
|
build();
|
||||||
|
@ -42,7 +43,8 @@ VPropertyFormWidget::VPropertyFormWidget(const QString &title, const QString &de
|
||||||
VPropertyFormWidget::VPropertyFormWidget(VProperty *parent_property, QWidget *parent)
|
VPropertyFormWidget::VPropertyFormWidget(VProperty *parent_property, QWidget *parent)
|
||||||
: QGroupBox(parent), d_ptr(new VPropertyFormWidgetPrivate())
|
: QGroupBox(parent), d_ptr(new VPropertyFormWidgetPrivate())
|
||||||
{
|
{
|
||||||
if(parent_property) {
|
if (parent_property)
|
||||||
|
{
|
||||||
d_ptr->Properties = parent_property->getChildren();
|
d_ptr->Properties = parent_property->getChildren();
|
||||||
build();
|
build();
|
||||||
setTitle(parent_property->getName());
|
setTitle(parent_property->getName());
|
||||||
|
@ -51,7 +53,8 @@ VPropertyFormWidget::VPropertyFormWidget(VProperty *parent_property, QWidget *pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertyFormWidget::VPropertyFormWidget(VPropertyFormWidgetPrivate *d_pointer, QWidget *parent, const QString &title, const QString &description)
|
VPropertyFormWidget::VPropertyFormWidget(VPropertyFormWidgetPrivate *d_pointer, QWidget *parent, const QString &title,
|
||||||
|
const QString &description)
|
||||||
: QGroupBox(title, parent), d_ptr(d_pointer)
|
: QGroupBox(title, parent), d_ptr(d_pointer)
|
||||||
{
|
{
|
||||||
build();
|
build();
|
||||||
|
@ -69,28 +72,40 @@ void VPropertyFormWidget::build()
|
||||||
{
|
{
|
||||||
// Clear the old content, delete old widgets
|
// Clear the old content, delete old widgets
|
||||||
d_ptr->EditorWidgets.clear();
|
d_ptr->EditorWidgets.clear();
|
||||||
if(layout()) {
|
if (layout())
|
||||||
|
{
|
||||||
QLayoutItem *child;
|
QLayoutItem *child;
|
||||||
while (layout()->count() > 0 && (child = layout()->takeAt(0)) != 0) {
|
while (layout()->count() > 0 && (child = layout()->takeAt(0)) != 0)
|
||||||
if(child->widget())
|
{
|
||||||
|
if (child->widget())
|
||||||
|
{
|
||||||
delete child->widget();
|
delete child->widget();
|
||||||
|
}
|
||||||
delete child;
|
delete child;
|
||||||
}
|
}
|
||||||
delete layout();
|
delete layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new content
|
// Create new content
|
||||||
if(d_ptr->Properties.isEmpty()) return; //... only if there are properties
|
if (d_ptr->Properties.isEmpty())
|
||||||
|
{
|
||||||
|
return; //... only if there are properties
|
||||||
|
}
|
||||||
|
|
||||||
QFormLayout* tmpFormLayout = new QFormLayout(this);
|
QFormLayout* tmpFormLayout = new QFormLayout(this);
|
||||||
setLayout(tmpFormLayout);
|
setLayout(tmpFormLayout);
|
||||||
|
|
||||||
for(int i = 0; i < d_ptr->Properties.count(); ++i) {
|
for (int i = 0; i < d_ptr->Properties.count(); ++i)
|
||||||
|
{
|
||||||
// Get the current property
|
// Get the current property
|
||||||
VProperty* tmpProperty = d_ptr->Properties.value(i, nullptr);
|
VProperty* tmpProperty = d_ptr->Properties.value(i, nullptr);
|
||||||
if(!tmpProperty) continue;
|
if (!tmpProperty)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(tmpProperty->getRowCount() > 0) {
|
if (tmpProperty->getRowCount() > 0)
|
||||||
|
{
|
||||||
if (tmpProperty->propertyType() == Property::Complex)
|
if (tmpProperty->propertyType() == Property::Complex)
|
||||||
{
|
{
|
||||||
buildEditor(tmpProperty, tmpFormLayout, Property::Complex);
|
buildEditor(tmpProperty, tmpFormLayout, Property::Complex);
|
||||||
|
@ -122,11 +137,15 @@ void VPropertyFormWidget::build()
|
||||||
d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpNewFormWidget));
|
d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpNewFormWidget));
|
||||||
tmpNewFormWidget->setCommitBehaviour(d_ptr->UpdateEditors);
|
tmpNewFormWidget->setCommitBehaviour(d_ptr->UpdateEditors);
|
||||||
}
|
}
|
||||||
} else if(tmpProperty->type() == "widget") {
|
}
|
||||||
|
else if (tmpProperty->type() == "widget")
|
||||||
|
{
|
||||||
VWidgetProperty* tmpWidgetProperty = static_cast<VWidgetProperty*>(tmpProperty);
|
VWidgetProperty* tmpWidgetProperty = static_cast<VWidgetProperty*>(tmpProperty);
|
||||||
tmpFormLayout->addRow(tmpWidgetProperty->getWidget());
|
tmpFormLayout->addRow(tmpWidgetProperty->getWidget());
|
||||||
d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpWidgetProperty->getWidget()));
|
d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpWidgetProperty->getWidget()));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
buildEditor(tmpProperty, tmpFormLayout);
|
buildEditor(tmpProperty, tmpFormLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,8 +156,10 @@ void VPropertyFormWidget::buildEditor(VProperty* property, QFormLayout* formLayo
|
||||||
// Add property (no child properties)
|
// Add property (no child properties)
|
||||||
// Create the editor (if it doesn't work, create empty widget)
|
// Create the editor (if it doesn't work, create empty widget)
|
||||||
QWidget* tmpEditor = property->createEditor(this, QStyleOptionViewItem(), nullptr);
|
QWidget* tmpEditor = property->createEditor(this, QStyleOptionViewItem(), nullptr);
|
||||||
if(!tmpEditor)
|
if (!tmpEditor)
|
||||||
|
{
|
||||||
tmpEditor = new QWidget(this);
|
tmpEditor = new QWidget(this);
|
||||||
|
}
|
||||||
|
|
||||||
// set tooltip and whats this
|
// set tooltip and whats this
|
||||||
tmpEditor->setToolTip(property->getDescription());
|
tmpEditor->setToolTip(property->getDescription());
|
||||||
|
@ -166,25 +187,34 @@ void VPropertyFormWidget::buildEditor(VProperty* property, QFormLayout* formLayo
|
||||||
|
|
||||||
void VPropertyFormWidget::commitData()
|
void VPropertyFormWidget::commitData()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < d_ptr->Properties.count(); ++i)
|
for (int i = 0; i < d_ptr->Properties.count(); ++i)
|
||||||
|
{
|
||||||
commitData(i);
|
commitData(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormWidget::loadData()
|
void VPropertyFormWidget::loadData()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < d_ptr->Properties.count(); ++i)
|
for (int i = 0; i < d_ptr->Properties.count(); ++i)
|
||||||
|
{
|
||||||
loadData(i);
|
loadData(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormWidget::commitData(int row)
|
void VPropertyFormWidget::commitData(int row)
|
||||||
{
|
{
|
||||||
if(row < 0 || row >= d_ptr->EditorWidgets.count() || row >= d_ptr->Properties.count()) return;
|
if (row < 0 || row >= d_ptr->EditorWidgets.count() || row >= d_ptr->Properties.count())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[row];
|
VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[row];
|
||||||
VProperty* tmpProperty = d_ptr->Properties[row];
|
VProperty* tmpProperty = d_ptr->Properties[row];
|
||||||
if(tmpEditorWidget.FormWidget)
|
if (tmpEditorWidget.FormWidget)
|
||||||
|
{
|
||||||
tmpEditorWidget.FormWidget->commitData();
|
tmpEditorWidget.FormWidget->commitData();
|
||||||
else if(tmpEditorWidget.Editor && tmpProperty)
|
}
|
||||||
|
else if (tmpEditorWidget.Editor && tmpProperty)
|
||||||
{
|
{
|
||||||
QVariant newValue = tmpProperty->getEditorData(tmpEditorWidget.Editor);
|
QVariant newValue = tmpProperty->getEditorData(tmpEditorWidget.Editor);
|
||||||
QVariant oldValue = tmpProperty->data(VProperty::DPC_Data, Qt::EditRole);
|
QVariant oldValue = tmpProperty->data(VProperty::DPC_Data, Qt::EditRole);
|
||||||
|
@ -212,13 +242,19 @@ void VPropertyFormWidget::commitData(int row)
|
||||||
|
|
||||||
void VPropertyFormWidget::loadData(int row)
|
void VPropertyFormWidget::loadData(int row)
|
||||||
{
|
{
|
||||||
if(row < 0 || row >= d_ptr->EditorWidgets.count() || row >= d_ptr->Properties.count()) return;
|
if (row < 0 || row >= d_ptr->EditorWidgets.count() || row >= d_ptr->Properties.count())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[row];
|
VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[row];
|
||||||
VProperty* tmpProperty = d_ptr->Properties[row];
|
VProperty* tmpProperty = d_ptr->Properties[row];
|
||||||
if(tmpEditorWidget.FormWidget)
|
if (tmpEditorWidget.FormWidget)
|
||||||
|
{
|
||||||
tmpEditorWidget.FormWidget->loadData();
|
tmpEditorWidget.FormWidget->loadData();
|
||||||
else if(tmpEditorWidget.Editor && tmpProperty) {
|
}
|
||||||
|
else if (tmpEditorWidget.Editor && tmpProperty)
|
||||||
|
{
|
||||||
tmpProperty->setEditorData(tmpEditorWidget.Editor);
|
tmpProperty->setEditorData(tmpEditorWidget.Editor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,18 +264,24 @@ void VPropertyFormWidget::setCommitBehaviour(bool auto_commit)
|
||||||
d_ptr->UpdateEditors = auto_commit;
|
d_ptr->UpdateEditors = auto_commit;
|
||||||
|
|
||||||
QList<VPropertyFormWidget*> tmpChildFormWidgets = getChildPropertyFormWidgets();
|
QList<VPropertyFormWidget*> tmpChildFormWidgets = getChildPropertyFormWidgets();
|
||||||
foreach(VPropertyFormWidget* tmpChild, tmpChildFormWidgets) {
|
foreach(VPropertyFormWidget* tmpChild, tmpChildFormWidgets)
|
||||||
if(tmpChild)
|
{
|
||||||
|
if (tmpChild)
|
||||||
|
{
|
||||||
tmpChild->setCommitBehaviour(auto_commit);
|
tmpChild->setCommitBehaviour(auto_commit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<VPropertyFormWidget *> VPropertyFormWidget::getChildPropertyFormWidgets() const
|
QList<VPropertyFormWidget *> VPropertyFormWidget::getChildPropertyFormWidgets() const
|
||||||
{
|
{
|
||||||
QList<VPropertyFormWidget *> tmpResult;
|
QList<VPropertyFormWidget *> tmpResult;
|
||||||
foreach(const VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget, d_ptr->EditorWidgets) {
|
foreach(const VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget, d_ptr->EditorWidgets)
|
||||||
if(tmpEditorWidget.FormWidget)
|
{
|
||||||
|
if (tmpEditorWidget.FormWidget)
|
||||||
|
{
|
||||||
tmpResult.append(tmpEditorWidget.FormWidget);
|
tmpResult.append(tmpEditorWidget.FormWidget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmpResult;
|
return tmpResult;
|
||||||
|
@ -247,15 +289,21 @@ QList<VPropertyFormWidget *> VPropertyFormWidget::getChildPropertyFormWidgets()
|
||||||
|
|
||||||
bool VPropertyFormWidget::eventFilter(QObject *object, QEvent *event)
|
bool VPropertyFormWidget::eventFilter(QObject *object, QEvent *event)
|
||||||
{
|
{
|
||||||
if(!d_ptr->UpdateEditors)
|
if (!d_ptr->UpdateEditors)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QWidget* editor = qobject_cast<QWidget*>(object);
|
QWidget* editor = qobject_cast<QWidget*>(object);
|
||||||
if (!editor)
|
if (!editor)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (event->type() == QEvent::KeyPress) {
|
if (event->type() == QEvent::KeyPress)
|
||||||
switch (static_cast<QKeyEvent *>(event)->key()) {
|
{
|
||||||
|
switch (static_cast<QKeyEvent *>(event)->key())
|
||||||
|
{
|
||||||
case Qt::Key_Tab:
|
case Qt::Key_Tab:
|
||||||
case Qt::Key_Backtab:
|
case Qt::Key_Backtab:
|
||||||
case Qt::Key_Enter:
|
case Qt::Key_Enter:
|
||||||
|
@ -267,20 +315,27 @@ bool VPropertyFormWidget::eventFilter(QObject *object, QEvent *event)
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (event->type() == QEvent::FocusOut || (event->type() == QEvent::Hide && editor->isWindow())) {
|
}
|
||||||
|
else if (event->type() == QEvent::FocusOut || (event->type() == QEvent::Hide && editor->isWindow()))
|
||||||
|
{
|
||||||
commitData(editor);
|
commitData(editor);
|
||||||
return false;
|
return false;
|
||||||
} else if (event->type() == QEvent::ShortcutOverride) {
|
}
|
||||||
if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) {
|
else if (event->type() == QEvent::ShortcutOverride)
|
||||||
|
{
|
||||||
|
if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape)
|
||||||
|
{
|
||||||
commitData(editor);
|
commitData(editor);
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->type() == MyCustomEventType) {
|
}
|
||||||
|
else if (event->type() == MyCustomEventType)
|
||||||
|
{
|
||||||
commitData(editor);
|
commitData(editor);
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return QGroupBox::eventFilter(object, event);
|
return QGroupBox::eventFilter(object, event);
|
||||||
|
@ -292,12 +347,17 @@ bool VPropertyFormWidget::eventFilter(QObject *object, QEvent *event)
|
||||||
|
|
||||||
void VPropertyFormWidget::commitData(QWidget *editor)
|
void VPropertyFormWidget::commitData(QWidget *editor)
|
||||||
{
|
{
|
||||||
if(!editor)
|
if (!editor)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < d_ptr->EditorWidgets.count(); ++i) {
|
for (int i = 0; i < d_ptr->EditorWidgets.count(); ++i)
|
||||||
|
{
|
||||||
VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[i];
|
VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[i];
|
||||||
if(tmpEditorWidget.Editor == editor)
|
if (tmpEditorWidget.Editor == editor)
|
||||||
|
{
|
||||||
commitData(i);
|
commitData(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
|
|
||||||
class QFormLayout;
|
class QFormLayout;
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyFormWidgetPrivate;
|
class VPropertyFormWidgetPrivate;
|
||||||
class VPropertySet;
|
class VPropertySet;
|
||||||
|
@ -38,7 +39,8 @@ class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFormWidget : public QGroupBox
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VPropertyFormWidget(const QString& title, const QString& description, const QList<VProperty*>& properties, QWidget* parent);
|
VPropertyFormWidget(const QString& title, const QString& description, const QList<VProperty*>& properties,
|
||||||
|
QWidget* parent);
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VPropertyFormWidget(VProperty* parent_property, QWidget* parent);
|
VPropertyFormWidget(VProperty* parent_property, QWidget* parent);
|
||||||
|
@ -69,7 +71,8 @@ public slots:
|
||||||
void loadData(int row);
|
void loadData(int row);
|
||||||
|
|
||||||
//! Sets the update behaviour
|
//! Sets the update behaviour
|
||||||
//! \param auto_commit If set to true, whenever an event like focusOut is triggered on an editor, the data will be submitted to the property.
|
//! \param auto_commit If set to true, whenever an event like focusOut is triggered on an editor, the data will be
|
||||||
|
//! submitted to the property.
|
||||||
void setCommitBehaviour(bool auto_commit = true);
|
void setCommitBehaviour(bool auto_commit = true);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -92,6 +95,6 @@ protected:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace VPE
|
} // Namespace VPE
|
||||||
|
|
||||||
#endif // VPROPERTYFORMWIDGET_H
|
#endif // VPROPERTYFORMWIDGET_H
|
||||||
|
|
|
@ -26,12 +26,15 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyFormWidgetPrivate {
|
class VPropertyFormWidgetPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! Stores either another VPropertyFormWidget (then Editor is null) or an editor widget (then FormWidget is null)
|
//! Stores either another VPropertyFormWidget (then Editor is null) or an editor widget (then FormWidget is null)
|
||||||
struct SEditorWidget {
|
struct SEditorWidget
|
||||||
|
{
|
||||||
SEditorWidget() : FormWidget(nullptr), Editor(nullptr) {}
|
SEditorWidget() : FormWidget(nullptr), Editor(nullptr) {}
|
||||||
SEditorWidget(VPropertyFormWidget* form_widget) : FormWidget(form_widget), Editor(nullptr) {}
|
SEditorWidget(VPropertyFormWidget* form_widget) : FormWidget(form_widget), Editor(nullptr) {}
|
||||||
SEditorWidget(QWidget* editor_widget) : FormWidget(nullptr), Editor(editor_widget) {}
|
SEditorWidget(QWidget* editor_widget) : FormWidget(nullptr), Editor(editor_widget) {}
|
||||||
|
@ -46,7 +49,8 @@ public:
|
||||||
//! Binds the properties to their editors
|
//! Binds the properties to their editors
|
||||||
QList<SEditorWidget> EditorWidgets;
|
QList<SEditorWidget> EditorWidgets;
|
||||||
|
|
||||||
//! Determines the behaviour of the editors. If this is true, when a focus out event etc. happens, the data will be submitted to the VProperty. If false, you will have to call commitData() yourself.
|
//! Determines the behaviour of the editors. If this is true, when a focus out event etc. happens, the data will be
|
||||||
|
//! submitted to the VProperty. If false, you will have to call commitData() yourself.
|
||||||
bool UpdateEditors;
|
bool UpdateEditors;
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
|
|
|
@ -40,8 +40,10 @@ VPropertyModel::VPropertyModel(QObject * parent) :
|
||||||
|
|
||||||
VPropertyModel::~VPropertyModel()
|
VPropertyModel::~VPropertyModel()
|
||||||
{
|
{
|
||||||
if(d_ptr->Properties)
|
if (d_ptr->Properties)
|
||||||
|
{
|
||||||
delete d_ptr->Properties;
|
delete d_ptr->Properties;
|
||||||
|
}
|
||||||
|
|
||||||
delete d_ptr;
|
delete d_ptr;
|
||||||
}
|
}
|
||||||
|
@ -49,13 +51,18 @@ VPropertyModel::~VPropertyModel()
|
||||||
//! Adds the property to the model and attaches it to the parentid
|
//! Adds the property to the model and attaches it to the parentid
|
||||||
bool VPropertyModel::addProperty(VProperty* property, const QString& id, const QString &parentid, bool emitsignals)
|
bool VPropertyModel::addProperty(VProperty* property, const QString& id, const QString &parentid, bool emitsignals)
|
||||||
{
|
{
|
||||||
if(!property)
|
if (!property)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(!d_ptr->Properties) // If not existant, create property set
|
if (!d_ptr->Properties) // If not existant, create property set
|
||||||
|
{
|
||||||
d_ptr->Properties = new VPropertySet();
|
d_ptr->Properties = new VPropertySet();
|
||||||
|
}
|
||||||
|
|
||||||
if(emitsignals) {
|
if (emitsignals)
|
||||||
|
{
|
||||||
VProperty* tmpParent = getProperty(parentid);
|
VProperty* tmpParent = getProperty(parentid);
|
||||||
int tmpRow = tmpParent != nullptr ? tmpParent->getRowCount() : d_ptr->Properties->getRootPropertyCount();
|
int tmpRow = tmpParent != nullptr ? tmpParent->getRowCount() : d_ptr->Properties->getRootPropertyCount();
|
||||||
beginInsertRows((tmpParent != nullptr ? getIndexFromProperty(tmpParent) : QModelIndex()), tmpRow, tmpRow);
|
beginInsertRows((tmpParent != nullptr ? getIndexFromProperty(tmpParent) : QModelIndex()), tmpRow, tmpRow);
|
||||||
|
@ -63,20 +70,25 @@ bool VPropertyModel::addProperty(VProperty* property, const QString& id, const Q
|
||||||
|
|
||||||
d_ptr->Properties->addProperty(property, id, parentid);
|
d_ptr->Properties->addProperty(property, id, parentid);
|
||||||
|
|
||||||
if(emitsignals)
|
if (emitsignals)
|
||||||
|
{
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Creates a property and adds it to the model
|
//! Creates a property and adds it to the model
|
||||||
VProperty* VPropertyModel::createProperty(const QString& id, const QString& name, const QString& parentid, const QVariant& data)
|
VProperty* VPropertyModel::createProperty(const QString& id, const QString& name, const QString& parentid,
|
||||||
|
const QVariant& data)
|
||||||
{
|
{
|
||||||
VProperty* tmpProp = new VProperty(name);
|
VProperty* tmpProp = new VProperty(name);
|
||||||
tmpProp->setValue(data);
|
tmpProp->setValue(data);
|
||||||
if(tmpProp && addProperty(tmpProp, id, parentid))
|
if (tmpProp && addProperty(tmpProp, id, parentid))
|
||||||
|
{
|
||||||
return tmpProp;
|
return tmpProp;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -87,23 +99,29 @@ VProperty* VPropertyModel::getProperty(const QString& id)
|
||||||
return d_ptr->Properties != nullptr ? d_ptr->Properties->getProperty(id) : nullptr;
|
return d_ptr->Properties != nullptr ? d_ptr->Properties->getProperty(id) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! Returns the model index at row/column
|
//! Returns the model index at row/column
|
||||||
QModelIndex VPropertyModel::index(int row, int column, const QModelIndex& parent) const
|
QModelIndex VPropertyModel::index(int row, int column, const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
if (d_ptr->Properties == nullptr || (parent.isValid() && parent.column() > 1))
|
if (d_ptr->Properties == nullptr || (parent.isValid() && parent.column() > 1))
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
if(parent.isValid()) {
|
if (parent.isValid())
|
||||||
|
{
|
||||||
// Get the parent index
|
// Get the parent index
|
||||||
VProperty* parentItem = getProperty(parent);
|
VProperty* parentItem = getProperty(parent);
|
||||||
if(parentItem) {
|
if (parentItem)
|
||||||
|
{
|
||||||
VProperty* childItem = parentItem->getChild(row);
|
VProperty* childItem = parentItem->getChild(row);
|
||||||
if (childItem)
|
if (childItem)
|
||||||
|
{
|
||||||
return createIndex(row, column, childItem);
|
return createIndex(row, column, childItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if(row >= 0 && row < d_ptr->Properties->count()) {
|
}
|
||||||
|
else if (row >= 0 && row < d_ptr->Properties->count())
|
||||||
|
{
|
||||||
return createIndex(row, column, d_ptr->Properties->getRootProperty(row));
|
return createIndex(row, column, d_ptr->Properties->getRootProperty(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,17 +132,24 @@ QModelIndex VPropertyModel::index(int row, int column, const QModelIndex& parent
|
||||||
QModelIndex VPropertyModel::parent ( const QModelIndex & index ) const
|
QModelIndex VPropertyModel::parent ( const QModelIndex & index ) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
VProperty* childItem = getProperty(index);
|
VProperty* childItem = getProperty(index);
|
||||||
if(childItem) {
|
if (childItem)
|
||||||
|
{
|
||||||
VProperty* parentItem = childItem->getParent();
|
VProperty* parentItem = childItem->getParent();
|
||||||
if(parentItem) {
|
if (parentItem)
|
||||||
|
{
|
||||||
VProperty* grandParentItem = parentItem->getParent();
|
VProperty* grandParentItem = parentItem->getParent();
|
||||||
int parents_row = grandParentItem != nullptr ? grandParentItem->getChildRow(parentItem) : d_ptr->Properties->getRootProperties().indexOf(parentItem);
|
int parents_row = grandParentItem != nullptr ? grandParentItem->getChildRow(parentItem)
|
||||||
|
: d_ptr->Properties->getRootProperties().indexOf(parentItem);
|
||||||
|
|
||||||
if(parents_row >= 0)
|
if (parents_row >= 0)
|
||||||
|
{
|
||||||
return createIndex(parents_row, 0, parentItem);
|
return createIndex(parents_row, 0, parentItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,8 +160,10 @@ QModelIndex VPropertyModel::parent ( const QModelIndex & index ) const
|
||||||
Qt::ItemFlags VPropertyModel::flags (const QModelIndex& index) const
|
Qt::ItemFlags VPropertyModel::flags (const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
VProperty* tmpProperty = getProperty(index);
|
VProperty* tmpProperty = getProperty(index);
|
||||||
if(!tmpProperty)
|
if (!tmpProperty)
|
||||||
|
{
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return tmpProperty->flags(index.column());
|
return tmpProperty->flags(index.column());
|
||||||
}
|
}
|
||||||
|
@ -145,15 +172,19 @@ Qt::ItemFlags VPropertyModel::flags (const QModelIndex& index) const
|
||||||
bool VPropertyModel::setData (const QModelIndex& index, const QVariant& value, int role)
|
bool VPropertyModel::setData (const QModelIndex& index, const QVariant& value, int role)
|
||||||
{
|
{
|
||||||
VProperty* tmpProperty = getProperty(index);
|
VProperty* tmpProperty = getProperty(index);
|
||||||
if(index.column() == 1 && tmpProperty) {
|
if (index.column() == 1 && tmpProperty)
|
||||||
|
{
|
||||||
bool tmpHasChanged = tmpProperty->setData(value, role);
|
bool tmpHasChanged = tmpProperty->setData(value, role);
|
||||||
if(tmpProperty->getUpdateParent() && tmpHasChanged) { // If neccessary, update the parent as well
|
if (tmpProperty->getUpdateParent() && tmpHasChanged)
|
||||||
|
{ // If neccessary, update the parent as well
|
||||||
QModelIndex tmpParentIndex = parent(index);
|
QModelIndex tmpParentIndex = parent(index);
|
||||||
emit dataChanged(tmpParentIndex, tmpParentIndex);
|
emit dataChanged(tmpParentIndex, tmpParentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tmpHasChanged)
|
if (tmpHasChanged)
|
||||||
|
{
|
||||||
emit onDataChangedByEditor(tmpProperty);
|
emit onDataChangedByEditor(tmpProperty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,8 +196,10 @@ bool VPropertyModel::setData (const QModelIndex& index, const QVariant& value, i
|
||||||
QVariant VPropertyModel::data ( const QModelIndex & index, int role ) const
|
QVariant VPropertyModel::data ( const QModelIndex & index, int role ) const
|
||||||
{
|
{
|
||||||
VProperty* tmpProperty = getProperty(index);
|
VProperty* tmpProperty = getProperty(index);
|
||||||
if(!tmpProperty)
|
if (!tmpProperty)
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return tmpProperty->data(index.column(), role);
|
return tmpProperty->data(index.column(), role);
|
||||||
}
|
}
|
||||||
|
@ -174,13 +207,22 @@ QVariant VPropertyModel::data ( const QModelIndex & index, int role ) const
|
||||||
|
|
||||||
QVariant VPropertyModel::headerData (int section, Qt::Orientation orientation, int role) const
|
QVariant VPropertyModel::headerData (int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if(orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
|
||||||
|
{
|
||||||
// Header data
|
// Header data
|
||||||
if (section == 0) return d_ptr->HeadlineProperty;
|
if (section == 0)
|
||||||
else if (section == 1) return d_ptr->HeadlineValue;
|
{
|
||||||
|
return d_ptr->HeadlineProperty;
|
||||||
|
}
|
||||||
|
else if (section == 1)
|
||||||
|
{
|
||||||
|
return d_ptr->HeadlineValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(role == Qt::DisplayRole)
|
else if (role == Qt::DisplayRole)
|
||||||
|
{
|
||||||
return QVariant(section);
|
return QVariant(section);
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -189,15 +231,20 @@ QVariant VPropertyModel::headerData (int section, Qt::Orientation orientation, i
|
||||||
//! Returns the number of rows
|
//! Returns the number of rows
|
||||||
int VPropertyModel::rowCount ( const QModelIndex & parent ) const
|
int VPropertyModel::rowCount ( const QModelIndex & parent ) const
|
||||||
{
|
{
|
||||||
if(parent.isValid()) {
|
if (parent.isValid())
|
||||||
|
{
|
||||||
VProperty* tmpParent = getProperty(parent);
|
VProperty* tmpParent = getProperty(parent);
|
||||||
if(tmpParent)
|
if (tmpParent)
|
||||||
|
{
|
||||||
return tmpParent->getRowCount();
|
return tmpParent->getRowCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the root property count
|
// Return the root property count
|
||||||
if(d_ptr->Properties)
|
if (d_ptr->Properties)
|
||||||
|
{
|
||||||
return d_ptr->Properties->getRootPropertyCount();
|
return d_ptr->Properties->getRootPropertyCount();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -214,11 +261,14 @@ int VPropertyModel::columnCount ( const QModelIndex & parent) const
|
||||||
//! Gets a property by its ModelIndex
|
//! Gets a property by its ModelIndex
|
||||||
VProperty* VPropertyModel::getProperty(const QModelIndex &index) const
|
VProperty* VPropertyModel::getProperty(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.isValid()) {
|
if (index.isValid())
|
||||||
|
{
|
||||||
VProperty* prop = static_cast<VProperty*>(index.internalPointer());
|
VProperty* prop = static_cast<VProperty*>(index.internalPointer());
|
||||||
|
|
||||||
if (prop)
|
if (prop)
|
||||||
|
{
|
||||||
return prop;
|
return prop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -231,12 +281,15 @@ QString VPropertyModel::getPropertyID(VProperty *prop) const
|
||||||
QModelIndex VPropertyModel::getIndexFromProperty(VProperty* property, int column) const
|
QModelIndex VPropertyModel::getIndexFromProperty(VProperty* property, int column) const
|
||||||
{
|
{
|
||||||
if (!property || column > columnCount() || column < 0)
|
if (!property || column > columnCount() || column < 0)
|
||||||
return QModelIndex();
|
{
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
VProperty* parentItem = property->getParent();
|
VProperty* parentItem = property->getParent();
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
if(parentItem) {
|
if (parentItem)
|
||||||
|
{
|
||||||
row = parentItem->getChildRow(property);
|
row = parentItem->getChildRow(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +300,7 @@ QModelIndex VPropertyModel::getIndexFromProperty(VProperty* property, int column
|
||||||
void VPropertyModel::onDataChangedByModel(VProperty* property)
|
void VPropertyModel::onDataChangedByModel(VProperty* property)
|
||||||
{
|
{
|
||||||
QModelIndex tmpIndex = getIndexFromProperty(property, 1);
|
QModelIndex tmpIndex = getIndexFromProperty(property, 1);
|
||||||
if(tmpIndex.isValid())
|
if (tmpIndex.isValid())
|
||||||
{
|
{
|
||||||
emit dataChanged(tmpIndex, tmpIndex);
|
emit dataChanged(tmpIndex, tmpIndex);
|
||||||
emit onDataChangedByEditor(property);
|
emit onDataChangedByEditor(property);
|
||||||
|
@ -268,9 +321,15 @@ VPropertySet *VPropertyModel::takePropertySet(VPropertySet *new_property_set, bo
|
||||||
{
|
{
|
||||||
VPropertySet* tmpOldPropertySet = d_ptr->Properties;
|
VPropertySet* tmpOldPropertySet = d_ptr->Properties;
|
||||||
|
|
||||||
if(emit_signals) emit beginResetModel();
|
if (emit_signals)
|
||||||
|
{
|
||||||
|
emit beginResetModel();
|
||||||
|
}
|
||||||
d_ptr->Properties = new_property_set;
|
d_ptr->Properties = new_property_set;
|
||||||
if(emit_signals) emit endResetModel();
|
if (emit_signals)
|
||||||
|
{
|
||||||
|
emit endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
return tmpOldPropertySet;
|
return tmpOldPropertySet;
|
||||||
}
|
}
|
||||||
|
@ -278,14 +337,17 @@ VPropertySet *VPropertyModel::takePropertySet(VPropertySet *new_property_set, bo
|
||||||
void VPropertyModel::setPropertySet(VPropertySet *property_set, bool emit_signals)
|
void VPropertyModel::setPropertySet(VPropertySet *property_set, bool emit_signals)
|
||||||
{
|
{
|
||||||
VPropertySet* tmpOldPropertySet = takePropertySet(property_set, emit_signals);
|
VPropertySet* tmpOldPropertySet = takePropertySet(property_set, emit_signals);
|
||||||
if(tmpOldPropertySet)
|
if (tmpOldPropertySet)
|
||||||
|
{
|
||||||
delete tmpOldPropertySet;
|
delete tmpOldPropertySet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VProperty *VPropertyModel::takeProperty(const QString &id)
|
VProperty *VPropertyModel::takeProperty(const QString &id)
|
||||||
{
|
{
|
||||||
QModelIndex tmpIndex = getIndexFromProperty(getProperty(id));
|
QModelIndex tmpIndex = getIndexFromProperty(getProperty(id));
|
||||||
if(d_ptr->Properties && tmpIndex.isValid()) {
|
if (d_ptr->Properties && tmpIndex.isValid())
|
||||||
|
{
|
||||||
beginRemoveRows(tmpIndex.parent(), tmpIndex.row(), tmpIndex.row());
|
beginRemoveRows(tmpIndex.parent(), tmpIndex.row(), tmpIndex.row());
|
||||||
VProperty* tmpProp = d_ptr->Properties->takeProperty(id);
|
VProperty* tmpProp = d_ptr->Properties->takeProperty(id);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
@ -298,7 +360,8 @@ VProperty *VPropertyModel::takeProperty(const QString &id)
|
||||||
void VPropertyModel::removeProperty(const QString &id)
|
void VPropertyModel::removeProperty(const QString &id)
|
||||||
{
|
{
|
||||||
QModelIndex tmpIndex = getIndexFromProperty(getProperty(id));
|
QModelIndex tmpIndex = getIndexFromProperty(getProperty(id));
|
||||||
if(d_ptr->Properties && tmpIndex.isValid()) {
|
if (d_ptr->Properties && tmpIndex.isValid())
|
||||||
|
{
|
||||||
beginRemoveRows(tmpIndex.parent(), tmpIndex.row(), tmpIndex.row());
|
beginRemoveRows(tmpIndex.parent(), tmpIndex.row(), tmpIndex.row());
|
||||||
d_ptr->Properties->removeProperty(id);
|
d_ptr->Properties->removeProperty(id);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
|
|
@ -29,17 +29,18 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyModelPrivate;
|
class VPropertyModelPrivate;
|
||||||
class VPropertySet;
|
class VPropertySet;
|
||||||
|
|
||||||
//! \brief This is the base model for managing all the properties
|
//! \brief This is the base model for managing all the properties
|
||||||
//! and passing them to the view.
|
//! and passing them to the view.
|
||||||
//!
|
//!
|
||||||
//! When you create your own "proxy models", this is the place to
|
//! When you create your own "proxy models", this is the place to
|
||||||
//! start: just subclass VPropertyModel and extend the new class.
|
//! start: just subclass VPropertyModel and extend the new class.
|
||||||
//! Have a look at existing examples of proxies.
|
//! Have a look at existing examples of proxies.
|
||||||
//!
|
//!
|
||||||
//! <strong>Note that in this context, the term "proxy model" does not refer
|
//! <strong>Note that in this context, the term "proxy model" does not refer
|
||||||
//! to VProxyModel as that is another concept.</strong>
|
//! to VProxyModel as that is another concept.</strong>
|
||||||
|
@ -61,7 +62,8 @@ public:
|
||||||
virtual ~VPropertyModel();
|
virtual ~VPropertyModel();
|
||||||
|
|
||||||
//! Adds the property to the model and attaches it to the parentid
|
//! Adds the property to the model and attaches it to the parentid
|
||||||
//! \param emitsignals If this is set to false, this function will not call beginInsertRows() and endInsertRows(), so it has to be called from a subclass
|
//! \param emitsignals If this is set to false, this function will not call beginInsertRows() and endInsertRows(),
|
||||||
|
//! so it has to be called from a subclass
|
||||||
virtual bool addProperty(VProperty* property, const QString& id, const QString& parentid = QString(),
|
virtual bool addProperty(VProperty* property, const QString& id, const QString& parentid = QString(),
|
||||||
bool emitsignals = true);
|
bool emitsignals = true);
|
||||||
|
|
||||||
|
@ -96,8 +98,6 @@ public:
|
||||||
//! Returns the number of columns
|
//! Returns the number of columns
|
||||||
virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
|
virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! Gets a property by its ModelIndex
|
//! Gets a property by its ModelIndex
|
||||||
//! \param index The modelIndex of the property.
|
//! \param index The modelIndex of the property.
|
||||||
//! \return Returns the property with the given index, or NULL if none such property exists
|
//! \return Returns the property with the given index, or NULL if none such property exists
|
||||||
|
@ -110,23 +110,29 @@ public:
|
||||||
//! \return Returns the ID under which the property is stored within the model
|
//! \return Returns the ID under which the property is stored within the model
|
||||||
virtual QString getPropertyID(VProperty* prop) const;
|
virtual QString getPropertyID(VProperty* prop) const;
|
||||||
|
|
||||||
//! Returns a const pointer to the property set managed by this model. If you want to manipulate the property set, either use the methods provided by the model or use takePropertySet() and setPropertySet().
|
//! Returns a const pointer to the property set managed by this model. If you want to manipulate the property set,
|
||||||
|
//! either use the methods provided by the model or use takePropertySet() and setPropertySet().
|
||||||
//! \return A constant pointer to the property set or NULL if there currently is none.
|
//! \return A constant pointer to the property set or NULL if there currently is none.
|
||||||
virtual const VPropertySet* getPropertySet() const;
|
virtual const VPropertySet* getPropertySet() const;
|
||||||
|
|
||||||
//! Clears the model, deletes the property set managed by this model.
|
//! Clears the model, deletes the property set managed by this model.
|
||||||
//! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset model signals
|
//! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset
|
||||||
|
//! model signals
|
||||||
virtual void clear(bool emit_signals = true);
|
virtual void clear(bool emit_signals = true);
|
||||||
|
|
||||||
//! Removes the current property set and returns it. If new_property_set is set, the old one will be replaced by the new one
|
//! Removes the current property set and returns it. If new_property_set is set, the old one will be replaced by the
|
||||||
|
//! new one
|
||||||
//! \param new_property_set The new property set to replace the old one with. Default: NULL
|
//! \param new_property_set The new property set to replace the old one with. Default: NULL
|
||||||
//! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset model signals
|
//! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset
|
||||||
|
//! model signals
|
||||||
//! \return A constant pointer to the property set or NULL if there currently is none.
|
//! \return A constant pointer to the property set or NULL if there currently is none.
|
||||||
virtual VPropertySet* takePropertySet(VPropertySet* new_property_set = nullptr, bool emit_signals = true);
|
virtual VPropertySet* takePropertySet(VPropertySet* new_property_set = nullptr, bool emit_signals = true);
|
||||||
|
|
||||||
//! Sets a new property set. The model will take ownership of the property set. The old property set will be deleted.
|
//! Sets a new property set. The model will take ownership of the property set. The old property set will be
|
||||||
|
//! deleted.
|
||||||
//! \param property_set The new property set. Setting this to NULL has the same effect as calling clear.
|
//! \param property_set The new property set. Setting this to NULL has the same effect as calling clear.
|
||||||
//! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset model signals
|
//! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset
|
||||||
|
//! model signals
|
||||||
//! \return A constant pointer to the property set or NULL if there currently is none.
|
//! \return A constant pointer to the property set or NULL if there currently is none.
|
||||||
virtual void setPropertySet(VPropertySet* property_set, bool emit_signals = true);
|
virtual void setPropertySet(VPropertySet* property_set, bool emit_signals = true);
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,14 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VProperty;
|
class VProperty;
|
||||||
class VPropertySet;
|
class VPropertySet;
|
||||||
|
|
||||||
class VPropertyModelPrivate {
|
class VPropertyModelPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! The property set holding the properties
|
//! The property set holding the properties
|
||||||
VPropertySet* Properties;
|
VPropertySet* Properties;
|
||||||
|
|
|
@ -41,8 +41,10 @@ VPropertySet::~VPropertySet()
|
||||||
bool VPropertySet::addProperty(VProperty *property, const QString &id, const QString &parentid)
|
bool VPropertySet::addProperty(VProperty *property, const QString &id, const QString &parentid)
|
||||||
{
|
{
|
||||||
// Check if the property to add is not a null pointer
|
// Check if the property to add is not a null pointer
|
||||||
if(!property)
|
if (!property)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
VProperty* tmpParent = parentid.isEmpty() ? NULL : getProperty(parentid);
|
VProperty* tmpParent = parentid.isEmpty() ? NULL : getProperty(parentid);
|
||||||
return addProperty(property, id, tmpParent);
|
return addProperty(property, id, tmpParent);
|
||||||
|
@ -51,31 +53,44 @@ bool VPropertySet::addProperty(VProperty *property, const QString &id, const QSt
|
||||||
bool VPropertySet::addProperty(VProperty *property, const QString &id, VProperty *parent_property)
|
bool VPropertySet::addProperty(VProperty *property, const QString &id, VProperty *parent_property)
|
||||||
{
|
{
|
||||||
// Check if the property to add is not a null pointer
|
// Check if the property to add is not a null pointer
|
||||||
if(!property)
|
if (!property)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QString tmpOldID = getPropertyID(property);
|
|
||||||
if(!tmpOldID.isEmpty())
|
|
||||||
d_ptr->Properties.remove(tmpOldID);
|
|
||||||
|
|
||||||
if(parent_property)
|
|
||||||
parent_property->addChild(property);
|
|
||||||
else {
|
|
||||||
d_ptr->RootProperties.append(property);
|
|
||||||
if(property->getParent())
|
|
||||||
property->getParent()->removeChild(property);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!id.isEmpty())
|
QString tmpOldID = getPropertyID(property);
|
||||||
|
if (!tmpOldID.isEmpty())
|
||||||
|
{
|
||||||
|
d_ptr->Properties.remove(tmpOldID);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent_property)
|
||||||
|
{
|
||||||
|
parent_property->addChild(property);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d_ptr->RootProperties.append(property);
|
||||||
|
if (property->getParent())
|
||||||
|
{
|
||||||
|
property->getParent()->removeChild(property);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!id.isEmpty())
|
||||||
|
{
|
||||||
d_ptr->Properties.insert(id, property);
|
d_ptr->Properties.insert(id, property);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VPropertySet::hasProperty(VProperty *property) const
|
bool VPropertySet::hasProperty(VProperty *property) const
|
||||||
{
|
{
|
||||||
if(!property)
|
if (!property)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return hasProperty(property, NULL);
|
return hasProperty(property, NULL);
|
||||||
}
|
}
|
||||||
|
@ -97,8 +112,10 @@ VProperty *VPropertySet::takeProperty(const QString &id)
|
||||||
void VPropertySet::removeProperty(const QString &id)
|
void VPropertySet::removeProperty(const QString &id)
|
||||||
{
|
{
|
||||||
VProperty* tmpProp = takeProperty(id);
|
VProperty* tmpProp = takeProperty(id);
|
||||||
if(tmpProp)
|
if (tmpProp)
|
||||||
|
{
|
||||||
delete tmpProp;
|
delete tmpProp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertySet::removeProperty(VProperty* prop, bool delete_property)
|
void VPropertySet::removeProperty(VProperty* prop, bool delete_property)
|
||||||
|
@ -107,11 +124,14 @@ void VPropertySet::removeProperty(VProperty* prop, bool delete_property)
|
||||||
removePropertyFromSet(prop);
|
removePropertyFromSet(prop);
|
||||||
|
|
||||||
// Remove from parent and optionally delete
|
// Remove from parent and optionally delete
|
||||||
if(prop) {
|
if (prop)
|
||||||
|
{
|
||||||
prop->setParent(NULL);
|
prop->setParent(NULL);
|
||||||
|
|
||||||
if(delete_property)
|
if (delete_property)
|
||||||
|
{
|
||||||
delete prop;
|
delete prop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,9 +143,11 @@ int VPropertySet::count() const
|
||||||
void VPropertySet::clear(bool delete_properties)
|
void VPropertySet::clear(bool delete_properties)
|
||||||
{
|
{
|
||||||
d_ptr->Properties.clear();
|
d_ptr->Properties.clear();
|
||||||
while(!d_ptr->RootProperties.isEmpty()) {
|
while (!d_ptr->RootProperties.isEmpty())
|
||||||
|
{
|
||||||
VProperty* tmpProp = d_ptr->RootProperties.takeLast();
|
VProperty* tmpProp = d_ptr->RootProperties.takeLast();
|
||||||
if(tmpProp != nullptr && delete_properties) {
|
if (tmpProp != nullptr && delete_properties)
|
||||||
|
{
|
||||||
delete tmpProp;
|
delete tmpProp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,15 +158,20 @@ QString VPropertySet::getPropertyID(const VProperty *prop, bool look_for_parent_
|
||||||
QString tmpResult;
|
QString tmpResult;
|
||||||
const VProperty* tmpCurrentProp = prop;
|
const VProperty* tmpCurrentProp = prop;
|
||||||
|
|
||||||
while(tmpCurrentProp && (look_for_parent_id || prop == tmpCurrentProp) && tmpResult.isEmpty()) {
|
while (tmpCurrentProp && (look_for_parent_id || prop == tmpCurrentProp) && tmpResult.isEmpty())
|
||||||
|
{
|
||||||
|
|
||||||
// todo: The following code doesn't work, because .key() doesn't accept a const VProperty* pointer ...
|
// todo: The following code doesn't work, because .key() doesn't accept a const VProperty* pointer ...
|
||||||
//tmpResult = d_ptr->Properties.key(tmpCurrentProp, QString());
|
//tmpResult = d_ptr->Properties.key(tmpCurrentProp, QString());
|
||||||
|
|
||||||
// ... which is why we need the code below
|
// ... which is why we need the code below
|
||||||
for (QMap<QString, VProperty*>::const_iterator i = d_ptr->Properties.constBegin(); i != d_ptr->Properties.constEnd(); ++i) {
|
for (QMap<QString, VProperty*>::const_iterator i = d_ptr->Properties.constBegin();
|
||||||
if(tmpCurrentProp == (*i))
|
i != d_ptr->Properties.constEnd(); ++i)
|
||||||
|
{
|
||||||
|
if (tmpCurrentProp == (*i))
|
||||||
|
{
|
||||||
return i.key();
|
return i.key();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpCurrentProp = tmpCurrentProp->getParent();
|
tmpCurrentProp = tmpCurrentProp->getParent();
|
||||||
|
@ -184,35 +211,47 @@ VPropertySet* VPropertySet::clone() const
|
||||||
return tmpResult;
|
return tmpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool VPropertySet::hasProperty(VProperty *property, VProperty *parent) const
|
bool VPropertySet::hasProperty(VProperty *property, VProperty *parent) const
|
||||||
{
|
{
|
||||||
if(!property)
|
if (!property)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const QList<VProperty*>& tmpChildrenList = (parent != NULL ? parent->getChildren() : d_ptr->RootProperties);
|
const QList<VProperty*>& tmpChildrenList = (parent != NULL ? parent->getChildren() : d_ptr->RootProperties);
|
||||||
foreach(VProperty* tmpProp, tmpChildrenList) {
|
foreach(VProperty* tmpProp, tmpChildrenList)
|
||||||
if(!tmpProp)
|
{
|
||||||
|
if (!tmpProp)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
else if(tmpProp == property || hasProperty(property, tmpProp))
|
}
|
||||||
|
else if (tmpProp == property || hasProperty(property, tmpProp))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertySet::cloneProperty(VProperty* property_to_clone, VProperty *parent_property, VPropertySet *output_set) const
|
void VPropertySet::cloneProperty(VProperty* property_to_clone, VProperty *parent_property,
|
||||||
|
VPropertySet *output_set) const
|
||||||
{
|
{
|
||||||
if(!output_set || !property_to_clone || !hasProperty(property_to_clone))
|
if (!output_set || !property_to_clone || !hasProperty(property_to_clone))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString tmpID = getPropertyID(property_to_clone, false);
|
QString tmpID = getPropertyID(property_to_clone, false);
|
||||||
VProperty* tmpNewProperty = property_to_clone->clone(false); // We want to clone the children ourselves (because of the IDs)
|
|
||||||
|
// We want to clone the children ourselves (because of the IDs)
|
||||||
|
VProperty* tmpNewProperty = property_to_clone->clone(false);
|
||||||
|
|
||||||
output_set->addProperty(tmpNewProperty, tmpID, parent_property);
|
output_set->addProperty(tmpNewProperty, tmpID, parent_property);
|
||||||
for(int i = 0; i < property_to_clone->getRowCount(); ++i)
|
for (int i = 0; i < property_to_clone->getRowCount(); ++i)
|
||||||
|
{
|
||||||
cloneProperty(property_to_clone->getChild(i), tmpNewProperty, output_set);
|
cloneProperty(property_to_clone->getChild(i), tmpNewProperty, output_set);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertySet::removePropertyFromSet(VProperty *prop)
|
void VPropertySet::removePropertyFromSet(VProperty *prop)
|
||||||
|
|
|
@ -28,15 +28,16 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
// Forward declaration
|
// Forward declaration
|
||||||
class VPropertySetPrivate;
|
class VPropertySetPrivate;
|
||||||
|
|
||||||
// todo: better description
|
// todo: better description
|
||||||
//! \brief VPropertySet is a simple class for managing a set of properties.
|
//! \brief VPropertySet is a simple class for managing a set of properties.
|
||||||
//! If you don't need all the Model-functionality, chose this class
|
//! If you don't need all the Model-functionality, chose this class
|
||||||
//! over VPropertyModel.
|
//! over VPropertyModel.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
//!
|
//!
|
||||||
|
@ -49,15 +50,19 @@ public:
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~VPropertySet();
|
virtual ~VPropertySet();
|
||||||
|
|
||||||
//! Adds the property to the model and attaches it to the parentid. Note that if the property has a parent which is not part of this set, it will be removed from that parent.
|
//! Adds the property to the model and attaches it to the parentid. Note that if the property has a parent which is
|
||||||
|
//! not part of this set, it will be removed from that parent.
|
||||||
//! \param property The property to add
|
//! \param property The property to add
|
||||||
//! \param id The property ID. If id is empty, the property will not be accessable by it's id but still be added. If the property was filed under another ID before, that will no longer be valid.
|
//! \param id The property ID. If id is empty, the property will not be accessable by it's id but still be added.
|
||||||
//! \param parentid The property's ID to which to add the property as child. Pass empty string to add it to the root properties.
|
//! If the property was filed under another ID before, that will no longer be valid.
|
||||||
|
//! \param parentid The property's ID to which to add the property as child. Pass empty string to add it to the
|
||||||
|
//! root properties.
|
||||||
virtual bool addProperty(VProperty* property, const QString& id, const QString& parentid);
|
virtual bool addProperty(VProperty* property, const QString& id, const QString& parentid);
|
||||||
|
|
||||||
//! Adds the property to the model and attaches it to the parent property.
|
//! Adds the property to the model and attaches it to the parent property.
|
||||||
//! \param property The property to add
|
//! \param property The property to add
|
||||||
//! \param id The property ID. If id is empty, the property will not be accessable by it's id but still be added. If the property was filed under another ID before, that will no longer be valid.
|
//! \param id The property ID. If id is empty, the property will not be accessable by it's id but still be added.
|
||||||
|
//! If the property was filed under another ID before, that will no longer be valid.
|
||||||
//! \param parentid The property to which to add the property as child. Pass NULL to add it to the root properties.
|
//! \param parentid The property to which to add the property as child. Pass NULL to add it to the root properties.
|
||||||
virtual bool addProperty(VProperty* property, const QString& id, VProperty* parent_property = nullptr);
|
virtual bool addProperty(VProperty* property, const QString& id, VProperty* parent_property = nullptr);
|
||||||
|
|
||||||
|
|
|
@ -26,14 +26,17 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VProperty;
|
class VProperty;
|
||||||
|
|
||||||
class VPropertySetPrivate {
|
class VPropertySetPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! Property map (ID, Property)
|
//! Property map (ID, Property)
|
||||||
QMap<QString, VProperty*> Properties; // All the Properties managed by this model are being stored in this map for quick access
|
QMap<QString, VProperty*> Properties; // All the Properties managed by this model are being stored in this map for
|
||||||
|
//quick access
|
||||||
|
|
||||||
//! List containing the root properties
|
//! List containing the root properties
|
||||||
QList<VProperty*> RootProperties;
|
QList<VProperty*> RootProperties;
|
||||||
|
|
|
@ -38,15 +38,19 @@ VPropertyTreeView::VPropertyTreeView(VPropertyModel *model, QWidget *parent)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
if(model)
|
if (model)
|
||||||
|
{
|
||||||
setModel(model);
|
setModel(model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertyTreeView::VPropertyTreeView(VPropertyTreeViewPrivate *d, bool init_, QWidget *parent)
|
VPropertyTreeView::VPropertyTreeView(VPropertyTreeViewPrivate *d, bool init_, QWidget *parent)
|
||||||
: QTreeView(parent), d_ptr(d)
|
: QTreeView(parent), d_ptr(d)
|
||||||
{
|
{
|
||||||
if(init_)
|
if (init_)
|
||||||
|
{
|
||||||
init();
|
init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertyTreeView::~VPropertyTreeView()
|
VPropertyTreeView::~VPropertyTreeView()
|
||||||
|
@ -73,5 +77,3 @@ void VPropertyTreeView::init()
|
||||||
|
|
||||||
setEditTriggers(QAbstractItemView::CurrentChanged | QAbstractItemView::SelectedClicked);
|
setEditTriggers(QAbstractItemView::CurrentChanged | QAbstractItemView::SelectedClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyTreeViewPrivate;
|
class VPropertyTreeViewPrivate;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyDelegate;
|
class VPropertyDelegate;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ VSerializedProperty::VSerializedProperty()
|
||||||
VSerializedProperty::VSerializedProperty(const VProperty* property, const VPropertySet* set)
|
VSerializedProperty::VSerializedProperty(const VProperty* property, const VPropertySet* set)
|
||||||
: ID(), Type(property ? property->type() : QString()), Value(property ? property->getValue() : QVariant())
|
: ID(), Type(property ? property->type() : QString()), Value(property ? property->getValue() : QVariant())
|
||||||
{
|
{
|
||||||
if(set) {
|
if (set)
|
||||||
|
{
|
||||||
ID = set->getPropertyID(property);
|
ID = set->getPropertyID(property);
|
||||||
|
|
||||||
initChildren(property, set);
|
initChildren(property, set);
|
||||||
|
@ -58,12 +59,13 @@ VPE::VSerializedProperty::~VSerializedProperty()
|
||||||
|
|
||||||
void VSerializedProperty::initChildren(const VProperty *property, const VPropertySet *set)
|
void VSerializedProperty::initChildren(const VProperty *property, const VPropertySet *set)
|
||||||
{
|
{
|
||||||
if(property && set) {
|
if (property && set)
|
||||||
|
{
|
||||||
const QList<VProperty*>& tmpChildren = property->getChildren();
|
const QList<VProperty*>& tmpChildren = property->getChildren();
|
||||||
foreach(const VProperty* tmpChild, tmpChildren) {
|
foreach(const VProperty* tmpChild, tmpChildren)
|
||||||
|
{
|
||||||
QString tmpChildID = set->getPropertyID(property);
|
QString tmpChildID = set->getPropertyID(property);
|
||||||
Children.append(VSerializedProperty(tmpChild, tmpChildID, set));
|
Children.append(VSerializedProperty(tmpChild, tmpChildID, set));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
#include "vpropertyset.h"
|
#include "vpropertyset.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VSerializedProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VSerializedProperty
|
||||||
|
|
|
@ -44,7 +44,8 @@ VStandardPropertyFactory::VStandardPropertyFactory()
|
||||||
VStandardPropertyFactory::VStandardPropertyFactory(VPropertyFactoryManager *manager)
|
VStandardPropertyFactory::VStandardPropertyFactory(VPropertyFactoryManager *manager)
|
||||||
: VAbstractPropertyFactory()
|
: VAbstractPropertyFactory()
|
||||||
{
|
{
|
||||||
if(manager) {
|
if (manager)
|
||||||
|
{
|
||||||
manager->registerFactory("string", this);
|
manager->registerFactory("string", this);
|
||||||
manager->registerFactory("bool", this);
|
manager->registerFactory("bool", this);
|
||||||
manager->registerFactory("color", this);
|
manager->registerFactory("color", this);
|
||||||
|
@ -60,25 +61,44 @@ VStandardPropertyFactory::VStandardPropertyFactory(VPropertyFactoryManager *mana
|
||||||
|
|
||||||
VProperty *VStandardPropertyFactory::createProperty(const QString &type, const QString &name)
|
VProperty *VStandardPropertyFactory::createProperty(const QString &type, const QString &name)
|
||||||
{
|
{
|
||||||
if(type == QString("string")) {
|
if (type == QString("string"))
|
||||||
|
{
|
||||||
return new VProperty(name);
|
return new VProperty(name);
|
||||||
} else if(type == QString("bool")) {
|
}
|
||||||
|
else if (type == QString("bool"))
|
||||||
|
{
|
||||||
return new VBoolProperty(name);
|
return new VBoolProperty(name);
|
||||||
} else if(type == QString("color")) {
|
}
|
||||||
|
else if (type == QString("color"))
|
||||||
|
{
|
||||||
return new VColorProperty(name);
|
return new VColorProperty(name);
|
||||||
} else if(type == QString("empty")) {
|
}
|
||||||
|
else if (type == QString("empty"))
|
||||||
|
{
|
||||||
return new VEmptyProperty(name);
|
return new VEmptyProperty(name);
|
||||||
} else if(type == QString("enum")) {
|
}
|
||||||
|
else if (type == QString("enum"))
|
||||||
|
{
|
||||||
return new VEnumProperty(name);
|
return new VEnumProperty(name);
|
||||||
} else if(type == QString("file")) {
|
}
|
||||||
|
else if (type == QString("file"))
|
||||||
|
{
|
||||||
return new VFileProperty(name);
|
return new VFileProperty(name);
|
||||||
} else if(type == QString("integer")) {
|
}
|
||||||
|
else if (type == QString("integer"))
|
||||||
|
{
|
||||||
return new VIntegerProperty(name);
|
return new VIntegerProperty(name);
|
||||||
} else if(type == QString("double")) {
|
}
|
||||||
|
else if (type == QString("double"))
|
||||||
|
{
|
||||||
return new VDoubleProperty(name);
|
return new VDoubleProperty(name);
|
||||||
} else if(type == QString("shortcut")) {
|
}
|
||||||
|
else if (type == QString("shortcut"))
|
||||||
|
{
|
||||||
return new VShortcutProperty(name);
|
return new VShortcutProperty(name);
|
||||||
} else if(type == QString("vector3d")) {
|
}
|
||||||
|
else if (type == QString("vector3d"))
|
||||||
|
{
|
||||||
return new QVector3DProperty(name);
|
return new QVector3DProperty(name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include "vabstractpropertyfactory.h"
|
#include "vabstractpropertyfactory.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VProperty;
|
class VProperty;
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,11 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VWidgetPropertyPrivate : public VPropertyPrivate {
|
class VWidgetPropertyPrivate : public VPropertyPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! The widget to show
|
//! The widget to show
|
||||||
QPointer<QWidget> Widget;
|
QPointer<QWidget> Widget;
|
||||||
|
@ -44,9 +46,12 @@ public:
|
||||||
: VPropertyPrivate(), Widget(nullptr) {}
|
: VPropertyPrivate(), Widget(nullptr) {}
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~VWidgetPropertyPrivate() {
|
~VWidgetPropertyPrivate()
|
||||||
if(Widget)
|
{
|
||||||
|
if (Widget)
|
||||||
|
{
|
||||||
Widget->deleteLater();
|
Widget->deleteLater();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user