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

# treemodel.h Example File
itemviews/simpletreemodel/treemodel.h

     /****************************************************************************
     **
     ** Copyright (C) 2005-$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 TREEMODEL_H
     #define TREEMODEL_H

     #include <QAbstractItemModel>
     #include <QModelIndex>
     #include <QVariant>

     class TreeItem;

     class TreeModel : public QAbstractItemModel
     {
         Q_OBJECT

     public:
         TreeModel(const QString &data, QObject *parent = 0);
         ~TreeModel();

         QVariant data(const QModelIndex &index, int role) const;
         Qt::ItemFlags flags(const QModelIndex &index) const;
         QVariant headerData(int section, Qt::Orientation orientation,
                             int role = Qt::DisplayRole) const;
         QModelIndex index(int row, int column,
                           const QModelIndex &parent = QModelIndex()) const;
         QModelIndex parent(const QModelIndex &index) const;
         int rowCount(const QModelIndex &parent = QModelIndex()) const;
         int columnCount(const QModelIndex &parent = QModelIndex()) const;

     private:
         void setupModelData(const QStringList &lines, TreeItem *parent);

         TreeItem *rootItem;
     };

     #endif