Version fix
[qstardict] / qstardict / cssedit.h
1 /*****************************************************************************
2  * cssedit.h - QStarDict, a StarDict clone written with using Qt             *
3  * Copyright (C) 2008 Alexander Rodin                                        *
4  *                                                                           *
5  * This program is free software; you can redistribute it and/or modify      *
6  * it under the terms of the GNU General Public License as published by      *
7  * the Free Software Foundation; either version 2 of the License, or         *
8  * (at your option) any later version.                                       *
9  *                                                                           *
10  * This program 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             *
13  * GNU General Public License for more details.                              *
14  *                                                                           *
15  * You should have received a copy of the GNU General Public License along   *
16  * with this program; if not, write to the Free Software Foundation, Inc.,   *
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.               *
18  *****************************************************************************/
19
20 #ifndef CSSEDIT_H
21 #define CSSEDIT_H
22
23 #include "ui_cssedit.h"
24
25 #include <QHash>
26
27 namespace QStarDict
28 {
29 /**
30  * CSS styles editor.
31  */
32 class CSSEdit: public QWidget, private Ui::CSSEdit
33 {
34     Q_OBJECT
35
36     public:
37         /**
38          * Constructor.
39          */
40         CSSEdit(QWidget *parent = 0);
41
42         /**
43          * Set CSS style for editing.
44          */
45         void setCSS(const QString &css);
46         /**
47          * Returns edited CSS style.
48          */
49         QString css() const;
50         /**
51          * Set aliases for elements.
52          */
53         void setElementsAliases(const QHash<QString, QString> &aliases);
54         /**
55          * Returns elements aliases.
56          */
57         const QHash<QString, QString> &elementsAliases() const
58         { return m_elementsAliases; }
59
60     private slots:
61         void colorSelectClicked();
62         void setCurrentElement(int index);
63         void propertyChanged();
64
65     private:
66         typedef QHash<QString, QString> Element;
67
68         void updateElementCombo();
69         void updatePreview();
70         Element getParentElement(const QString &elementName);
71
72         QHash<QString, Element> m_elements;
73         QHash<QString, QString> m_elementsAliases;
74         QString m_currentElement;
75 };
76 }
77
78 #endif // CSSEDIT_H
79
80 // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent
81