KTutorial  0.5.1
TutorialListModel.h
00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Daniel Calviño Sánchez <danxuliu@gmail.com>     *
00003  *   Copyright (C) 2009 by Daniel Calviño Sánchez <danxuliu@gmail.com>     *
00004  *   Copyright (C) 2010 by Daniel Calviño Sánchez <danxuliu@gmail.com>     *
00005  *   Copyright (C) 2012 by Daniel Calviño Sánchez <danxuliu@gmail.com>     *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; If not, see <http://www.gnu.org/licenses/>.  *
00019  ***************************************************************************/
00020 
00021 #ifndef KTUTORIAL_VIEW_TUTORIALLISTMODEL_H
00022 #define KTUTORIAL_VIEW_TUTORIALLISTMODEL_H
00023 
00024 #include <QAbstractListModel>
00025 
00026 namespace ktutorial {
00027 class TutorialInformation;
00028 class TutorialManager;
00029 }
00030 
00031 namespace ktutorial {
00032 namespace view {
00033 
00043 class TutorialListModel: public QAbstractListModel {
00044 Q_OBJECT
00045 public:
00046 
00054     explicit TutorialListModel(const TutorialManager* tutorialManager,
00055                                QObject* parent = 0):
00056         QAbstractListModel(parent),
00057         mTutorialManager(tutorialManager) {
00058     }
00059 
00066     virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
00067 
00077     virtual QVariant data(const QModelIndex &index, int role) const;
00078 
00089     virtual QVariant headerData(int section, Qt::Orientation orientation,
00090                                 int role = Qt::DisplayRole) const;
00091 
00099     const TutorialInformation* getTutorialInformationForIndex(
00100                                                 const QModelIndex& index) const;
00101 
00102 private:
00103 
00107     const TutorialManager* mTutorialManager;
00108 
00109 };
00110 
00111 }
00112 }
00113 
00114 #endif