aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/common/numericspinbox.h
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2014-12-06 17:33:25 -0500
committerLibravatarUnit 193 <unit193@ubuntu.com>2014-12-06 17:33:25 -0500
commit7167ce41b61d2ba2cdb526777a4233eb84a3b66a (patch)
treea35c14143716e1f2c98f808c81f89426045a946f /SQLiteStudio3/guiSQLiteStudio/common/numericspinbox.h
Imported Upstream version 2.99.6upstream/2.99.6
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/common/numericspinbox.h')
-rw-r--r--SQLiteStudio3/guiSQLiteStudio/common/numericspinbox.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/common/numericspinbox.h b/SQLiteStudio3/guiSQLiteStudio/common/numericspinbox.h
new file mode 100644
index 0000000..79cd56c
--- /dev/null
+++ b/SQLiteStudio3/guiSQLiteStudio/common/numericspinbox.h
@@ -0,0 +1,57 @@
+#ifndef QNUMERICSPINBOX_H
+#define QNUMERICSPINBOX_H
+
+#include "guiSQLiteStudio_global.h"
+#include <QAbstractSpinBox>
+
+/**
+ * @brief The NumericSpinBox class
+ * This class implements a spinbox for numeric SQLite types.
+ * This includes integers, as well as decimals.
+ * User is also allowed to type in any text value (unless "strict" property is set),
+ * but once he uses "step up" or "step down", the text value
+ * gets replaced with 0.
+ * If strict propery is set, also the allowEmpty property starts to matter.
+ * Otherwise allowEmpty is ignored.
+ */
+class GUI_API_EXPORT NumericSpinBox : public QAbstractSpinBox
+{
+ Q_OBJECT
+ public:
+ explicit NumericSpinBox(QWidget *parent = 0);
+
+ void stepBy(int steps);
+ QValidator::State validate(QString& input, int& pos) const;
+
+ QVariant getValue() const;
+ void setValue(const QVariant& newValue, bool nullAsZero = true);
+
+ bool isStrict() const;
+ void setStrict(bool value, bool allowEmpty = true);
+
+ bool getAllowEmpty() const;
+ void setAllowEmpty(bool value);
+
+ protected:
+ StepEnabled stepEnabled() const;
+
+ private:
+ QVariant getFixedVariant(const QVariant& value);
+ void setValueInternal(const QVariant& newValue);
+ void stepIntBy(int steps);
+ void stepDoubleBy(int steps);
+ void updateText();
+ QValidator::State validateStrict(QString &input, int &pos) const;
+
+ QVariant value;
+ bool strict = false;
+ bool allowEmpty = true;
+
+ private slots:
+ void valueEdited(const QString& value);
+
+ signals:
+ void modified() const;
+};
+
+#endif // QNUMERICSPINBOX_H