Loading...
Searching...
No Matches
propertyEditor.h
Go to the documentation of this file.
#ifndef BALL_VIEW_WIDGETS_PROPERTYEDITOR_H
#define BALL_VIEW_WIDGETS_PROPERTYEDITOR_H
#ifndef BALL_COMMON_GLOBAL_H
# include <BALL/COMMON/global.h>
#endif
#ifndef BALL_DATATYPE_HASHMAP_H
# include <BALL/DATATYPE/hashMap.h>
#endif
#include <BALL/VIEW/UIC/ui_propertyEditor.h>
#include <BALL/VIEW/UIC/ui_propEditorWidget.h>
#include <BALL/VIEW/UIC/ui_editorPDBInfoDialog.h>
#ifndef BALL_FORMAT_PDBINFO_H
# include <BALL/FORMAT/PDBInfo.h>
#endif
#include <QtWidgets/QWidget>
class QLabel;
class QSpinBox;
class QLineEdit;
class QCheckBox;
namespace BALL
{
class NamedProperty;
class PropertyManager;
namespace VIEW
{
class PropEditorWidget : public QWidget
{
Q_OBJECT
public:
PropEditorWidget(const std::string& name, QWidget* parent);
virtual const QString& getName() const;
void setEditable(bool mode);
bool isEditable() const;
void apply(PropertyManager* man, bool create = false);
void reset(PropertyManager* man);
virtual PropEditorWidget* clone(const std::string& name, QWidget* parent) = 0;
Q_SIGNALS:
void deleteProperty();
void duplicateProperty();
void valueChanged();
protected:
void setupUi_();
bool addWidget_(int i, QWidget* w);
virtual void apply_(PropertyManager* man) = 0;
virtual void reset_(const NamedProperty& prop) = 0;
QString name_;
Ui::PropEditorWidget ui_;
};
class BoolEditorWidget : public PropEditorWidget
{
Q_OBJECT
public:
BoolEditorWidget(const NamedProperty& prop, QWidget* parent);
virtual BoolEditorWidget* clone(const std::string& name, QWidget* parent);
protected:
virtual void apply_(PropertyManager* man);
virtual void reset_(const NamedProperty& prop);
private:
QCheckBox* box_;
};
class IntEditorWidget : public PropEditorWidget
{
Q_OBJECT
public:
IntEditorWidget(const NamedProperty& prop, QWidget* parent);
virtual IntEditorWidget* clone(const std::string& name, QWidget* parent);
protected:
virtual void apply_(PropertyManager* man);
virtual void reset_(const NamedProperty& prop);
private:
QSpinBox* box_;
};
class UIntEditorWidget : public PropEditorWidget
{
Q_OBJECT
public:
UIntEditorWidget(const NamedProperty& prop, QWidget* parent);
virtual UIntEditorWidget* clone(const std::string& name, QWidget* parent);
protected:
virtual void apply_(PropertyManager* man);
virtual void reset_(const NamedProperty& prop);
private:
QSpinBox* box_;
};
class FloatEditorWidget : public PropEditorWidget
{
Q_OBJECT
public:
FloatEditorWidget(const NamedProperty& prop, QWidget* parent);
virtual FloatEditorWidget* clone(const std::string& name, QWidget* parent);
protected:
virtual void apply_(PropertyManager* man);
virtual void reset_(const NamedProperty& prop);
private:
QLineEdit* edit_;
};
class DoubleEditorWidget : public PropEditorWidget
{
Q_OBJECT
public:
DoubleEditorWidget(const NamedProperty& prop, QWidget* parent);
virtual DoubleEditorWidget* clone(const std::string& name, QWidget* parent);
protected:
virtual void apply_(PropertyManager* man);
virtual void reset_(const NamedProperty& prop);
private:
QLineEdit* edit_;
};
class StringEditorWidget : public PropEditorWidget
{
Q_OBJECT
public:
StringEditorWidget(const NamedProperty& prop, QWidget* parent);
virtual StringEditorWidget* clone(const std::string& name, QWidget* parent);
protected:
virtual void apply_(PropertyManager* man);
virtual void reset_(const NamedProperty& prop);
private:
QLineEdit* edit_;
};
class PropDeleteWidget : public PropEditorWidget
{
public:
PropDeleteWidget(const NamedProperty& prop, QWidget* parent)
: PropEditorWidget(prop.getName(), parent)
{
addWidget_(1,new QLabel(tr("(not editable)"),this));
ui_.duplicate_button->setEnabled(false);
}
virtual PropEditorWidget* clone(const std::string&, QWidget*)
{
return NULL;
}
protected:
virtual void apply_(PropertyManager *) {}
virtual void reset_(const NamedProperty &) {}
};
class PDBInfoEditorWidget : public PropEditorWidget
{
Q_OBJECT
public:
PDBInfoEditorWidget(const PDBInfo& info, QWidget* parent);
virtual PDBInfoEditorWidget* clone(const std::string& name, QWidget* parent);
protected Q_SLOTS:
void startEditorDialog();
protected:
virtual void apply_(PropertyManager* man);
virtual void reset_(const NamedProperty& prop);
private:
// TODO: This should maybe become a generic TextEditor and not be as hackish.
class EditorPDBInfoDialog : public QDialog {
public:
EditorPDBInfoDialog(QWidget* parent) : QDialog(parent)
{
ui_.setupUi(this);
QFont mono("Monaco"); mono.setStyleHint(QFont::TypeWriter);
ui_.textEditor->setFont(mono);
}
protected:
friend class PDBInfoEditorWidget;
Ui::editorPDBInfoDialog ui_;
};
PDBInfo localCopy_;
EditorPDBInfoDialog* editorDialog_;
};
class BALL_VIEW_EXPORT PropertyEditor : public QWidget
{
Q_OBJECT
public:
explicit PropertyEditor(QWidget* parent = 0, bool editable = true);
PropertyEditor(PropertyManager* manager, QWidget* parent, bool editable = true);
void setPropertyManager(PropertyManager* man);
void setEditable(bool mode);
bool isEditable() const;
bool hasChanges() const;
public Q_SLOTS:
void apply();
void reset();
Q_SIGNALS:
void valueChanged();
protected:
void setupUi_();
PropEditorWidget* addProperty_(const NamedProperty& prop);
PropEditorWidget* addProperty_(PropEditorWidget* editor);
PropEditorWidget* createEditorWidget_(const NamedProperty& prop);
QString chooseName_(const QString& initial);
void deleteProperty_(PropEditorWidget* editor);
protected Q_SLOTS:
void scheduleDelete_();
void scheduleDuplicate_();
void valueChanged_();
void createNewBool_();
void createNewInt_();
void createNewUInt_();
void createNewFloat_();
void createNewDouble_();
void createNewString_();
private:
bool has_changes_;
bool is_editable_;
PropertyManager* manager_;
QList<PropEditorWidget*> new_properties_;
QList<PropEditorWidget*> deleted_properties_;
Ui::PropertyEditor ui_;
};
}
}
#endif //BALL_VIEW_WIDGETS_PROPERTYEDITOR_H
global.h
BALL_VIEW_EXPORT
#define BALL_VIEW_EXPORT
Definition COMMON/global.h:52
PDBInfo.h
BALL::NamedProperty
Definition property.h:40
BALL::PDBInfo
Definition PDBInfo.h:33
BALL::PropertyManager
Definition property.h:344
BALL::VIEW::BoolEditorWidget::BoolEditorWidget
BoolEditorWidget(const NamedProperty &prop, QWidget *parent)
BALL::VIEW::BoolEditorWidget::apply_
virtual void apply_(PropertyManager *man)
BALL::VIEW::BoolEditorWidget::clone
virtual BoolEditorWidget * clone(const std::string &name, QWidget *parent)
BALL::VIEW::BoolEditorWidget::reset_
virtual void reset_(const NamedProperty &prop)
BALL::VIEW::DoubleEditorWidget::reset_
virtual void reset_(const NamedProperty &prop)
BALL::VIEW::DoubleEditorWidget::apply_
virtual void apply_(PropertyManager *man)
BALL::VIEW::DoubleEditorWidget::clone
virtual DoubleEditorWidget * clone(const std::string &name, QWidget *parent)
BALL::VIEW::DoubleEditorWidget::DoubleEditorWidget
DoubleEditorWidget(const NamedProperty &prop, QWidget *parent)
BALL::VIEW::FloatEditorWidget::clone
virtual FloatEditorWidget * clone(const std::string &name, QWidget *parent)
BALL::VIEW::FloatEditorWidget::reset_
virtual void reset_(const NamedProperty &prop)
BALL::VIEW::FloatEditorWidget::apply_
virtual void apply_(PropertyManager *man)
BALL::VIEW::FloatEditorWidget::FloatEditorWidget
FloatEditorWidget(const NamedProperty &prop, QWidget *parent)
BALL::VIEW::IntEditorWidget::reset_
virtual void reset_(const NamedProperty &prop)
BALL::VIEW::IntEditorWidget::IntEditorWidget
IntEditorWidget(const NamedProperty &prop, QWidget *parent)
BALL::VIEW::IntEditorWidget::apply_
virtual void apply_(PropertyManager *man)
BALL::VIEW::IntEditorWidget::clone
virtual IntEditorWidget * clone(const std::string &name, QWidget *parent)
BALL::VIEW::PDBInfoEditorWidget
Definition propertyEditor.h:242
BALL::VIEW::PDBInfoEditorWidget::clone
virtual PDBInfoEditorWidget * clone(const std::string &name, QWidget *parent)
BALL::VIEW::PDBInfoEditorWidget::apply_
virtual void apply_(PropertyManager *man)
BALL::VIEW::PDBInfoEditorWidget::reset_
virtual void reset_(const NamedProperty &prop)
BALL::VIEW::PDBInfoEditorWidget::PDBInfoEditorWidget
PDBInfoEditorWidget(const PDBInfo &info, QWidget *parent)
BALL::VIEW::PDBInfoEditorWidget::startEditorDialog
void startEditorDialog()
BALL::VIEW::PropDeleteWidget::reset_
virtual void reset_(const NamedProperty &)
Definition propertyEditor.h:238
BALL::VIEW::PropDeleteWidget::clone
virtual PropEditorWidget * clone(const std::string &, QWidget *)
Definition propertyEditor.h:232
BALL::VIEW::PropDeleteWidget::apply_
virtual void apply_(PropertyManager *)
Definition propertyEditor.h:237
BALL::VIEW::PropDeleteWidget::PropDeleteWidget
PropDeleteWidget(const NamedProperty &prop, QWidget *parent)
Definition propertyEditor.h:226
BALL::VIEW::PropEditorWidget
Definition propertyEditor.h:39
BALL::VIEW::PropEditorWidget::reset_
virtual void reset_(const NamedProperty &prop)=0
BALL::VIEW::PropEditorWidget::clone
virtual PropEditorWidget * clone(const std::string &name, QWidget *parent)=0
BALL::VIEW::PropEditorWidget::apply
void apply(PropertyManager *man, bool create=false)
BALL::VIEW::PropEditorWidget::PropEditorWidget
PropEditorWidget(const std::string &name, QWidget *parent)
BALL::VIEW::PropEditorWidget::isEditable
bool isEditable() const
BALL::VIEW::PropEditorWidget::name_
QString name_
Definition propertyEditor.h:119
BALL::VIEW::PropEditorWidget::duplicateProperty
void duplicateProperty()
BALL::VIEW::PropEditorWidget::deleteProperty
void deleteProperty()
BALL::VIEW::PropEditorWidget::ui_
Ui::PropEditorWidget ui_
Definition propertyEditor.h:120
BALL::VIEW::PropEditorWidget::reset
void reset(PropertyManager *man)
BALL::VIEW::PropEditorWidget::getName
virtual const QString & getName() const
BALL::VIEW::PropEditorWidget::apply_
virtual void apply_(PropertyManager *man)=0
BALL::VIEW::PropEditorWidget::setEditable
void setEditable(bool mode)
BALL::VIEW::PropEditorWidget::valueChanged
void valueChanged()
BALL::VIEW::PropEditorWidget::setupUi_
void setupUi_()
BALL::VIEW::PropEditorWidget::addWidget_
bool addWidget_(int i, QWidget *w)
BALL::VIEW::PropertyEditor::apply
void apply()
BALL::VIEW::PropertyEditor::setPropertyManager
void setPropertyManager(PropertyManager *man)
BALL::VIEW::PropertyEditor::deleteProperty_
void deleteProperty_(PropEditorWidget *editor)
BALL::VIEW::PropertyEditor::setEditable
void setEditable(bool mode)
BALL::VIEW::PropertyEditor::PropertyEditor
PropertyEditor(QWidget *parent=0, bool editable=true)
BALL::VIEW::PropertyEditor::chooseName_
QString chooseName_(const QString &initial)
BALL::VIEW::PropertyEditor::scheduleDuplicate_
void scheduleDuplicate_()
BALL::VIEW::PropertyEditor::isEditable
bool isEditable() const
BALL::VIEW::PropertyEditor::valueChanged_
void valueChanged_()
BALL::VIEW::PropertyEditor::setupUi_
void setupUi_()
BALL::VIEW::PropertyEditor::createNewUInt_
void createNewUInt_()
BALL::VIEW::PropertyEditor::createNewDouble_
void createNewDouble_()
BALL::VIEW::PropertyEditor::createNewInt_
void createNewInt_()
BALL::VIEW::PropertyEditor::hasChanges
bool hasChanges() const
BALL::VIEW::PropertyEditor::scheduleDelete_
void scheduleDelete_()
BALL::VIEW::PropertyEditor::createEditorWidget_
PropEditorWidget * createEditorWidget_(const NamedProperty &prop)
BALL::VIEW::PropertyEditor::reset
void reset()
BALL::VIEW::PropertyEditor::addProperty_
PropEditorWidget * addProperty_(PropEditorWidget *editor)
BALL::VIEW::PropertyEditor::valueChanged
void valueChanged()
BALL::VIEW::PropertyEditor::createNewFloat_
void createNewFloat_()
BALL::VIEW::PropertyEditor::addProperty_
PropEditorWidget * addProperty_(const NamedProperty &prop)
BALL::VIEW::PropertyEditor::createNewString_
void createNewString_()
BALL::VIEW::PropertyEditor::createNewBool_
void createNewBool_()
BALL::VIEW::PropertyEditor::PropertyEditor
PropertyEditor(PropertyManager *manager, QWidget *parent, bool editable=true)
BALL::VIEW::StringEditorWidget::reset_
virtual void reset_(const NamedProperty &prop)
BALL::VIEW::StringEditorWidget::StringEditorWidget
StringEditorWidget(const NamedProperty &prop, QWidget *parent)
BALL::VIEW::StringEditorWidget::clone
virtual StringEditorWidget * clone(const std::string &name, QWidget *parent)
BALL::VIEW::StringEditorWidget::apply_
virtual void apply_(PropertyManager *man)
BALL::VIEW::UIntEditorWidget::reset_
virtual void reset_(const NamedProperty &prop)
BALL::VIEW::UIntEditorWidget::clone
virtual UIntEditorWidget * clone(const std::string &name, QWidget *parent)
BALL::VIEW::UIntEditorWidget::UIntEditorWidget
UIntEditorWidget(const NamedProperty &prop, QWidget *parent)
BALL::VIEW::UIntEditorWidget::apply_
virtual void apply_(PropertyManager *man)
QDialog
QLineEdit
QWidget
hashMap.h
BALL::VIEW
Definition constraints.h:35
BALL
Definition constants.h:13