File: querymodel.h

package info (click to toggle)
sqlitestudio 3.4.21%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 54,880 kB
  • sloc: ansic: 406,208; cpp: 123,872; yacc: 2,692; tcl: 497; sh: 462; xml: 426; makefile: 19
file content (41 lines) | stat: -rw-r--r-- 932 bytes parent folder | download
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
#ifndef SQLQUERYMODEL_H
#define SQLQUERYMODEL_H

#include "db/sqlresultsrow.h"
#include <QList>
#include <QAbstractTableModel>

class Db;

class API_EXPORT QueryModel : public QAbstractTableModel
{
        Q_OBJECT

    public:
        using QAbstractItemModel::fetchMore;
        using QAbstractItemModel::canFetchMore;

        QueryModel(Db* db, QObject *parent = nullptr);

        virtual void refresh();
        QVariant data(const QModelIndex& index, int role) const;
        int rowCount(const QModelIndex& parent) const;
        int columnCount(const QModelIndex& parent) const;

        QString getQuery() const;
        void setQuery(const QString& value);

    private:
        void fetchMore();
        bool canFetchMore() const;

        QString query;
        Db* db = nullptr;
        QList<SqlResultsRowPtr> loadedRows;
        int columns = 0;

    signals:
        void refreshed();
};

#endif // SQLQUERYMODEL_H