1 /* This file is part of the KDE project
2  * Copyright (C) 2007 Thomas Zander <zander@kde.org>
3  * Copyright (C) 2013 Thorsten Zachmann <zachmann@kde.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef STYLEMANAGER_H
22 #define STYLEMANAGER_H
23 
24 #include <ui_StyleManager.h>
25 
26 #include <QWidget>
27 
28 class StylesManagerModel;
29 class StylesSortFilterProxyModel;
30 class KoStyleManager;
31 class KoStyleThumbnailer;
32 class KoParagraphStyle;
33 class KoCharacterStyle;
34 
35 class QModelIndex;
36 
37 class StyleManager : public QWidget
38 {
39     Q_OBJECT
40 public:
41     explicit StyleManager(QWidget *parent = 0);
42     ~StyleManager() override;
43 
44     void setStyleManager(KoStyleManager *sm);
45 
46     void setUnit(const KoUnit &unit);
47 
48     //Check that the new name of style is unique or not
49     bool checkUniqueStyleName();
50 
51 public Q_SLOTS:
52     void save();
53     void setParagraphStyle(KoParagraphStyle *style);
54     void setCharacterStyle(KoCharacterStyle *style, bool canDelete = false);
55     bool unappliedStyleChanges();
56 
57 private Q_SLOTS:
58     void slotParagraphStyleSelected(const QModelIndex &index);
59     void slotCharacterStyleSelected(const QModelIndex &index);
60     void addParagraphStyle(KoParagraphStyle*);
61     void addCharacterStyle(KoCharacterStyle*);
62     void removeParagraphStyle(KoParagraphStyle*);
63     void removeCharacterStyle(KoCharacterStyle*);
64     void currentParagraphStyleChanged();
65     void currentParagraphNameChanged(const QString &name);
66     void currentCharacterStyleChanged();
67     void currentCharacterNameChanged(const QString &name);
68     void buttonNewPressed();
69     void tabChanged(int index);
70 
71 private:
72     bool checkUniqueStyleName(int widgetIndex);
73 
74     Ui::StyleManager widget;
75     KoStyleManager *m_styleManager;
76 
77     QMap<KoParagraphStyle *, KoParagraphStyle *> m_modifiedParagraphStyles;
78     QMap<KoCharacterStyle *, KoCharacterStyle *> m_modifiedCharacterStyles;
79 
80     StylesManagerModel *m_paragraphStylesModel;
81     StylesManagerModel *m_characterStylesModel;
82     StylesSortFilterProxyModel *m_paragraphProxyModel;
83     StylesSortFilterProxyModel *m_characterProxyModel;
84     KoStyleThumbnailer *m_thumbnailer;
85     bool m_unappliedStyleChanges;
86 };
87 
88 #endif
89