File indexing completed on 2024-05-05 17:09:09

0001 /*
0002  * This file is part of the KDE project
0003  *
0004  * Copyright (C) 2013 Dan Leinir Turthra Jensen <admin@leinir.dk>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Library General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Library General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Library General Public License
0017  * along with this library; see the file COPYING.LIB.  If not, write to
0018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020  *
0021  */
0022 
0023 #ifndef CQTEXTTOCMODEL_H
0024 #define CQTEXTTOCMODEL_H
0025 
0026 #include <QAbstractListModel>
0027 
0028 class CQTextToCModel : public QAbstractListModel
0029 {
0030     Q_OBJECT
0031     Q_PROPERTY(QObject* canvas READ canvas WRITE setCanvas NOTIFY canvasChanged);
0032 public:
0033     enum TextToCModelRoleNames {
0034         Title = Qt::UserRole + 1,
0035         Level,
0036         PageNumber
0037     };
0038     explicit CQTextToCModel(QObject* parent = 0);
0039     virtual ~CQTextToCModel();
0040     virtual QVariant data(const QModelIndex& index, int role) const;
0041     virtual int rowCount(const QModelIndex& parent) const;
0042 
0043 
0044     QObject* canvas() const;
0045     void setCanvas(QObject* newCanvas);
0046 Q_SIGNALS:
0047     void canvasChanged();
0048 
0049 private Q_SLOTS:
0050     void requestGeneration();
0051     void startDoneTimer();
0052     void timeout();
0053     void updateToC();
0054 
0055 private:
0056     class Private;
0057     Private* const d;
0058 };
0059 
0060 #endif // CQTEXTTOCMODEL_H