aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/multieditor/multieditornumeric.cpp
blob: 526f5c45ea2d99a7b3cdd39138415c904efc2c96 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "multieditornumeric.h"
#include "common/numericspinbox.h"
#include <QVariant>
#include <QVBoxLayout>
#include <QDebug>

MultiEditorNumeric::MultiEditorNumeric(QWidget* parent)
    : MultiEditorWidget(parent)
{
    setLayout(new QVBoxLayout());
    spinBox = new NumericSpinBox();
    layout()->addWidget(spinBox);

    connect(spinBox, SIGNAL(modified()), this, SIGNAL(valueModified()));

    setFocusProxy(spinBox);
}

void MultiEditorNumeric::setValue(const QVariant& value)
{
    spinBox->setValue(value);
}

QVariant MultiEditorNumeric::getValue()
{
    return spinBox->getValue();
}

void MultiEditorNumeric::setReadOnly(bool value)
{
    spinBox->setReadOnly(value);
}

QString MultiEditorNumeric::getTabLabel()
{
    return tr("Number", "numeric multi editor tab name");
}

void MultiEditorNumeric::focusThisWidget()
{
    spinBox->setFocus();
}

QList<QWidget*> MultiEditorNumeric::getNoScrollWidgets()
{
    QList<QWidget*> list;
    list << spinBox;
    return list;
}

MultiEditorWidget*MultiEditorNumericPlugin::getInstance()
{
    return new MultiEditorNumeric();
}

bool MultiEditorNumericPlugin::validFor(const DataType& dataType)
{
    switch (dataType.getType())
    {
        case DataType::BIGINT:
        case DataType::DECIMAL:
        case DataType::DOUBLE:
        case DataType::INTEGER:
        case DataType::INT:
        case DataType::NUMERIC:
        case DataType::REAL:
            return true;
        case DataType::BOOLEAN:
        case DataType::BLOB:
        case DataType::NONE:
        case DataType::STRING:
        case DataType::TEXT:
        case DataType::CHAR:
        case DataType::VARCHAR:
        case DataType::DATE:
        case DataType::DATETIME:
        case DataType::TIME:
        case DataType::unknown:
            break;
    }
    return false;
}

int MultiEditorNumericPlugin::getPriority(const DataType& dataType)
{
    switch (dataType.getType())
    {
        case DataType::BIGINT:
        case DataType::DECIMAL:
        case DataType::DOUBLE:
        case DataType::INTEGER:
        case DataType::INT:
        case DataType::NUMERIC:
        case DataType::REAL:
            return 1;
        case DataType::BOOLEAN:
        case DataType::BLOB:
        case DataType::NONE:
        case DataType::STRING:
        case DataType::TEXT:
        case DataType::CHAR:
        case DataType::VARCHAR:
        case DataType::DATE:
        case DataType::DATETIME:
        case DataType::TIME:
        case DataType::unknown:
            break;
    }
    return 10;
}