File indexing completed on 2024-05-05 17:04:26
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2014 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 * 0004 * This program is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU General Public License as 0006 * published by the Free Software Foundation; either version 2 of 0007 * the License or (at your option) version 3 or any later version 0008 * accepted by the membership of KDE e.V. (or its successor approved 0009 * by the membership of KDE e.V.), which shall act as a proxy 0010 * defined in Section 14 of version 3 of the license. 0011 * 0012 * This program is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0015 * GNU General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU General Public License 0018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0019 * 0020 */ 0021 0022 #ifndef PARAGRAPHSTYLESMODEL_H 0023 #define PARAGRAPHSTYLESMODEL_H 0024 0025 #include <QModelIndex> 0026 0027 class ParagraphStylesModel : public QAbstractListModel 0028 { 0029 Q_OBJECT 0030 Q_PROPERTY(QObject* document READ document WRITE setDocument NOTIFY documentChanged) 0031 Q_PROPERTY(QObject* textEditor READ textEditor WRITE setTextEditor NOTIFY textEditorChanged) 0032 Q_PROPERTY(QFont cursorFont READ cursorFont NOTIFY cursorFontChanged) 0033 Q_PROPERTY(int currentStyle READ currentStyle NOTIFY cursorFontChanged) 0034 Q_PROPERTY(qreal zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged) 0035 0036 public: 0037 enum ParagraphStyleRoles { 0038 Name = Qt::UserRole + 1, 0039 Current, 0040 Font, 0041 FontFamily, 0042 FontPointSize, 0043 FontWeight, 0044 FontItalic, 0045 FontUnderline 0046 }; 0047 ParagraphStylesModel(); 0048 ~ParagraphStylesModel() override; 0049 QVariant data(const QModelIndex& index, int role) const override; 0050 int rowCount(const QModelIndex& parent) const override; 0051 0052 QObject* document() const; 0053 void setDocument(QObject* newDocument); 0054 0055 QObject* textEditor() const; 0056 void setTextEditor(QObject* newEditor); 0057 0058 Q_SLOT void cursorPositionChanged(); 0059 0060 Q_INVOKABLE void activate(int index); 0061 0062 QFont cursorFont() const; 0063 int currentStyle() const; 0064 0065 qreal zoomLevel() const; 0066 void setZoomLevel(const qreal& newZoom); 0067 Q_SIGNALS: 0068 void documentChanged(); 0069 void textEditorChanged(); 0070 void cursorFontChanged(); 0071 void zoomLevelChanged(); 0072 0073 private: 0074 class Private; 0075 Private* d; 0076 }; 0077 0078 #endif // PARAGRAPHSTYLESMODEL_H