|  | Home · All Namespaces · All Classes · Main Classes · Grouped Classes · Modules · Functions |

# tablemodel.h Example File
itemviews/addressbook/tablemodel.h

     /****************************************************************************
     **
     ** Copyright (C) 2008-$THISYEAR$ $TROLLTECH$. All rights reserved.
     **
     ** This file is part of the $MODULE$ of the Qt Toolkit.
     **
     ** $TROLLTECH_DUAL_LICENSE$
     **
     ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
     ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
     **
     ****************************************************************************/

     #ifndef TABLEMODEL_H
     #define TABLEMODEL_H

     #include <QAbstractTableModel>
     #include <QPair>
     #include <QList>

     class TableModel : public QAbstractTableModel
     {
         Q_OBJECT

     public:
         TableModel(QObject *parent=0);
         TableModel(QList< QPair<QString, QString> > listofPairs, QObject *parent=0);

         int rowCount(const QModelIndex &parent) const;
         int columnCount(const QModelIndex &parent) const;
         QVariant data(const QModelIndex &index, int role) const;
         QVariant headerData(int section, Qt::Orientation orientation, int role) const;
         Qt::ItemFlags flags(const QModelIndex &index) const;
         bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole);
         bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex());
         bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex());
         QList< QPair<QString, QString> > getList();

     private:
         QList< QPair<QString, QString> > listOfPairs;
     };

     #endif