|  | Home · All Classes · Main Classes · Annotated · Grouped Classes · Functions |

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

        /****************************************************************************
        **
        ** Copyright (C) 2004-2005 Trolltech AS. All rights reserved.
        **
        ** This file is part of an example program for Qt.
        ** EDITIONS: NOLIMITS
        **
        ** 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;
            ItemFlags flags(const QModelIndex &index) const;
            QVariant headerData(int section, Qt::Orientation orientation,
                                int role = 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