src/sql/models/qsqlquerymodel.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtSql module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QSQLQUERYMODEL_H
       
    43 #define QSQLQUERYMODEL_H
       
    44 
       
    45 #include <QtCore/qabstractitemmodel.h>
       
    46 #include <QtSql/qsqldatabase.h>
       
    47 
       
    48 QT_BEGIN_HEADER
       
    49 
       
    50 QT_BEGIN_NAMESPACE
       
    51 
       
    52 QT_MODULE(Sql)
       
    53 
       
    54 class QSqlQueryModelPrivate;
       
    55 class QSqlError;
       
    56 class QSqlRecord;
       
    57 class QSqlQuery;
       
    58 
       
    59 class Q_SQL_EXPORT QSqlQueryModel: public QAbstractTableModel
       
    60 {
       
    61     Q_OBJECT
       
    62     Q_DECLARE_PRIVATE(QSqlQueryModel)
       
    63 
       
    64 public:
       
    65     explicit QSqlQueryModel(QObject *parent = 0);
       
    66     virtual ~QSqlQueryModel();
       
    67 
       
    68     int rowCount(const QModelIndex &parent = QModelIndex()) const;
       
    69     int columnCount(const QModelIndex &parent = QModelIndex()) const;
       
    70     QSqlRecord record(int row) const;
       
    71     QSqlRecord record() const;
       
    72 
       
    73     QVariant data(const QModelIndex &item, int role = Qt::DisplayRole) const;
       
    74     QVariant headerData(int section, Qt::Orientation orientation,
       
    75                         int role = Qt::DisplayRole) const;
       
    76     bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
       
    77                        int role = Qt::EditRole);
       
    78 
       
    79     bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
       
    80     bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
       
    81 
       
    82     void setQuery(const QSqlQuery &query);
       
    83     void setQuery(const QString &query, const QSqlDatabase &db = QSqlDatabase());
       
    84     QSqlQuery query() const;
       
    85 
       
    86     virtual void clear();
       
    87 
       
    88     QSqlError lastError() const;
       
    89 
       
    90     void fetchMore(const QModelIndex &parent = QModelIndex());
       
    91     bool canFetchMore(const QModelIndex &parent = QModelIndex()) const;
       
    92 
       
    93 protected:
       
    94     virtual void queryChange();
       
    95 
       
    96     QModelIndex indexInQuery(const QModelIndex &item) const;
       
    97     void setLastError(const QSqlError &error);
       
    98     QSqlQueryModel(QSqlQueryModelPrivate &dd, QObject *parent = 0);
       
    99 };
       
   100 
       
   101 QT_END_NAMESPACE
       
   102 
       
   103 QT_END_HEADER
       
   104 
       
   105 #endif // QSQLQUERYMODEL_H