aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/plugins/populatesequence.h
blob: 543547704783b2d2bb705ec2beb35f5364f3fdce (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
#ifndef POPULATESEQUENCE_H
#define POPULATESEQUENCE_H

#include "builtinplugin.h"
#include "populateplugin.h"
#include "config_builder.h"

CFG_CATEGORIES(PopulateSequenceConfig,
    CFG_CATEGORY(PopulateSequence,
        CFG_ENTRY(int, StartValue, 0)
        CFG_ENTRY(int, Step,       1)
    )
)

class PopulateSequence : public BuiltInPlugin, public PopulatePlugin
{
        Q_OBJECT

        SQLITESTUDIO_PLUGIN_TITLE("Sequence")
        SQLITESTUDIO_PLUGIN_DESC("Support for populating tables with sequenced values.")
        SQLITESTUDIO_PLUGIN_VERSION(10001)
        SQLITESTUDIO_PLUGIN_AUTHOR("sqlitestudio.pl")

    public:
        PopulateSequence();

        QString getTitle() const;
        PopulateEngine* createEngine();
};

class PopulateSequenceEngine : public PopulateEngine
{
    public:
        bool beforePopulating(Db* db, const QString& table);
        QVariant nextValue(bool& nextValueError);
        void afterPopulating();
        CfgMain* getConfig();
        QString getPopulateConfigFormName() const;
        bool validateOptions();

    private:
        CFG_LOCAL(PopulateSequenceConfig, cfg)
        qint64 seq = 0;
        qint64 step = 1;
};

#endif // POPULATESEQUENCE_H