From 7167ce41b61d2ba2cdb526777a4233eb84a3b66a Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sat, 6 Dec 2014 17:33:25 -0500 Subject: Imported Upstream version 2.99.6 --- .../guiSQLiteStudio/multieditor/multieditor.h | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 SQLiteStudio3/guiSQLiteStudio/multieditor/multieditor.h (limited to 'SQLiteStudio3/guiSQLiteStudio/multieditor/multieditor.h') diff --git a/SQLiteStudio3/guiSQLiteStudio/multieditor/multieditor.h b/SQLiteStudio3/guiSQLiteStudio/multieditor/multieditor.h new file mode 100644 index 0000000..2576c97 --- /dev/null +++ b/SQLiteStudio3/guiSQLiteStudio/multieditor/multieditor.h @@ -0,0 +1,96 @@ +#ifndef MULTIEDITOR_H +#define MULTIEDITOR_H + +#include "guiSQLiteStudio_global.h" +#include "datagrid/sqlquerymodelcolumn.h" +#include +#include + +class QCheckBox; +class QTabWidget; +class MultiEditorWidget; +class QLabel; +class MultiEditorWidgetPlugin; +class QToolButton; + +class GUI_API_EXPORT MultiEditor : public QWidget +{ + Q_OBJECT + + Q_PROPERTY(QVariant value READ getValue WRITE setValue) + + public: + enum BuiltInEditor + { + TEXT, + NUMERIC, + BOOLEAN, + DATE, + TIME, + DATETIME, + HEX + }; + + explicit MultiEditor(QWidget *parent = 0); + + void addEditor(MultiEditorWidget* editorWidget); + void showTab(int idx); + + void setValue(const QVariant& value); + QVariant getValue() const; + bool isModified() const; + bool eventFilter(QObject* obj, QEvent* event); + bool getReadOnly() const; + void setReadOnly(bool value); + void setDeletedRow(bool value); + void setDataType(const DataType& dataType); + void focusThisEditor(); + + static void loadBuiltInEditors(); + + private: + void init(); + void updateVisibility(); + void updateNullEffect(); + void updateValue(const QVariant& newValue); + void updateLabel(); + QVariant getValueOmmitNull() const; + + static QList getEditorTypes(const DataType& dataType); + + static const int margins = 2; + static const int spacing = 2; + + QCheckBox* nullCheck = nullptr; + QTabWidget* tabs = nullptr; + QList editors; + QLabel* stateLabel = nullptr; + bool readOnly = false; + bool deleted = false; + bool invalidatingDisabled = false; + QGraphicsEffect* nullEffect = nullptr; + bool valueModified = false; + QVariant valueBeforeNull; + QToolButton* configBtn = nullptr; + DataType dataType; + + /** + * @brief currentTab + * Hold current tab index. It might seem as duplicate for tabs->currentIndex, + * but this is necessary when we want to know what was the previous tab, + * while being in tabChanged() slot. + */ + int currentTab = -1; + + private slots: + void configClicked(); + void tabChanged(int idx); + void nullStateChanged(int state); + void invalidateValue(); + void setModified(); + + signals: + void modified(); +}; + +#endif // MULTIEDITOR_H -- cgit v1.2.3