Kate
kateschema.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2001-2003 Christoph Cullmann <cullmann@kde.org> 00003 Copyright (C) 2002, 2003 Anders Lund <anders.lund@lund.tdcadsl.dk> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef __KATE_SCHEMA_H__ 00021 #define __KATE_SCHEMA_H__ 00022 00023 #include "katehighlight.h" 00024 #include "katedialogs.h" 00025 00026 #include <QtCore/QStringList> 00027 #include <QtCore/QMap> 00028 #include <QtGui/QFont> 00029 00030 #include <kconfig.h> 00031 #include <kaction.h> 00032 00033 class KateView; 00034 class KateStyleTreeWidget; 00035 00036 00037 class QAction; 00038 class QActionGroup; 00039 class KComboBox; 00040 class KTabWidget; 00041 00042 namespace Ui { class SchemaConfigColorTab; } 00043 00044 class KateSchemaManager 00045 { 00046 public: 00047 KateSchemaManager (); 00048 ~KateSchemaManager (); 00049 00053 void update (bool readfromfile = true); 00054 00058 KConfigGroup schema (uint number); 00059 00060 void addSchema (const QString &t); 00061 00062 void removeSchema (uint number); 00063 00067 bool validSchema (uint number); 00068 bool validSchema (const QString &name); 00069 00073 uint number (const QString &name); 00074 00078 QString name (uint number); 00079 00083 const QStringList &list () { return m_schemas; } 00084 00085 static QString normalSchema (); 00086 static QString printingSchema (); 00087 00088 private: 00089 KConfig m_config; 00090 QStringList m_schemas; 00091 }; 00092 00093 00094 class KateViewSchemaAction : public KActionMenu 00095 { 00096 Q_OBJECT 00097 00098 public: 00099 KateViewSchemaAction(const QString& text, QObject *parent) 00100 : KActionMenu(text, parent) { init(); } 00101 00102 void updateMenu (KateView *view); 00103 00104 private: 00105 void init(); 00106 00107 QPointer<KateView> m_view; 00108 QStringList names; 00109 QActionGroup *m_group; 00110 int last; 00111 00112 public Q_SLOTS: 00113 void slotAboutToShow(); 00114 00115 private Q_SLOTS: 00116 void setSchema(); 00117 }; 00118 00119 // 00120 // DIALOGS 00121 // 00122 00123 class KateSchemaConfigColorTab : public QWidget 00124 { 00125 Q_OBJECT 00126 00127 public: 00128 KateSchemaConfigColorTab(); 00129 ~KateSchemaConfigColorTab(); 00130 00131 private: 00132 // Class for storing the properties on 1 schema. 00133 class SchemaColors { 00134 public: 00135 QColor back, selected, current, bracket, wwmarker, iconborder, tmarker, linenumber, spellingmistakeline; 00136 QMap<int, QColor> markerColors; // stores all markerColors 00137 QMap<int, QColor> templateColors; 00138 }; 00139 00140 // schemaid=data, created when a schema is entered 00141 QMap<int,SchemaColors> m_schemas; 00142 // current schema 00143 int m_schema; 00144 00145 Ui::SchemaConfigColorTab* ui; 00146 00147 public Q_SLOTS: 00148 void apply(); 00149 void schemaChanged( int newSchema ); 00150 00151 Q_SIGNALS: 00152 void changed(); 00153 00154 protected Q_SLOTS: 00155 void slotMarkerColorChanged(const QColor&); 00156 void slotComboBoxChanged(int index); 00157 }; 00158 00159 typedef QMap<int,QFont> FontMap; // ### remove it 00160 00161 class KateSchemaConfigFontTab : public QWidget 00162 { 00163 Q_OBJECT 00164 00165 public: 00166 KateSchemaConfigFontTab(); 00167 ~KateSchemaConfigFontTab(); 00168 00169 public: 00170 void readConfig (KConfig *config); 00171 00172 public Q_SLOTS: 00173 void apply(); 00174 void schemaChanged( int newSchema ); 00175 00176 Q_SIGNALS: 00177 void changed(); 00178 00179 private: 00180 class KFontChooser *m_fontchooser; 00181 FontMap m_fonts; 00182 int m_schema; 00183 00184 private Q_SLOTS: 00185 void slotFontSelected( const QFont &font ); 00186 }; 00187 00188 class KateSchemaConfigFontColorTab : public QWidget 00189 { 00190 Q_OBJECT 00191 00192 public: 00193 KateSchemaConfigFontColorTab(); 00194 ~KateSchemaConfigFontColorTab(); 00195 00196 Q_SIGNALS: 00197 void changed(); 00198 00199 public: 00200 void schemaChanged (uint schema); 00201 void reload (); 00202 void apply (); 00203 00204 KateAttributeList *attributeList (uint schema); 00205 00206 private: 00207 KateStyleTreeWidget* m_defaultStyles; 00208 QHash<int,KateAttributeList*> m_defaultStyleLists; 00209 }; 00210 00211 class KateSchemaConfigHighlightTab : public QWidget 00212 { 00213 Q_OBJECT 00214 00215 public: 00216 explicit KateSchemaConfigHighlightTab(KateSchemaConfigFontColorTab *page = 0); 00217 ~KateSchemaConfigHighlightTab(); 00218 00219 void schemaChanged (int schema); 00220 void reload (); 00221 void apply (); 00222 00223 Q_SIGNALS: 00224 void changed(); 00225 00226 protected Q_SLOTS: 00227 void hlChanged(int z); 00228 00229 private: 00230 KateSchemaConfigFontColorTab *m_defaults; 00231 00232 KComboBox *hlCombo; 00233 KateStyleTreeWidget *m_styles; 00234 00235 int m_schema; 00236 int m_hl; 00237 00238 QHash<int, QHash<int, QList<KateExtendedAttribute::Ptr> > > m_hlDict; 00239 }; 00240 00241 class KateSchemaConfigPage : public KateConfigPage 00242 { 00243 Q_OBJECT 00244 00245 public: 00246 explicit KateSchemaConfigPage ( QWidget *parent); 00247 ~KateSchemaConfigPage (); 00248 00249 public Q_SLOTS: 00250 void apply(); 00251 void reload(); 00252 void reset(); 00253 void defaults(); 00254 00255 private Q_SLOTS: 00256 void update (); 00257 void deleteSchema (); 00258 void newSchema (); 00259 void schemaChanged (int schema); 00260 00261 void newCurrentPage(int); 00262 00263 private: 00264 int m_lastSchema; 00265 int m_defaultSchema; 00266 00267 class KTabWidget *m_tabWidget; 00268 class QPushButton *btndel; 00269 class KComboBox *defaultSchemaCombo; 00270 class KComboBox *schemaCombo; 00271 KateSchemaConfigColorTab *m_colorTab; 00272 KateSchemaConfigFontTab *m_fontTab; 00273 KateSchemaConfigFontColorTab *m_fontColorTab; 00274 KateSchemaConfigHighlightTab *m_highlightTab; 00275 }; 00276 00277 #endif 00278 00279 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE 4.6 API Reference