• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • syntax
katehighlightmenu.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2001-2003 Christoph Cullmann <cullmann@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 //BEGIN Includes
20 #include "katehighlightmenu.h"
21 #include "katehighlightmenu.moc"
22 
23 #include "katedocument.h"
24 #include "kateconfig.h"
25 #include "kateview.h"
26 #include "kateglobal.h"
27 #include "katesyntaxmanager.h"
28 #include "katesyntaxdocument.h"
29 
30 #include "ui_filetypeconfigwidget.h"
31 
32 #include <kconfig.h>
33 #include <kmimetype.h>
34 #include <kmimetypechooser.h>
35 #include <kdebug.h>
36 #include <kiconloader.h>
37 #include <knuminput.h>
38 #include <klocale.h>
39 #include <kmenu.h>
40 
41 #include <QtCore/QRegExp>
42 #include <QtGui/QCheckBox>
43 #include <QtGui/QComboBox>
44 #include <QtGui/QGroupBox>
45 
46 #include <QtGui/QLabel>
47 #include <QtGui/QLayout>
48 #include <QtGui/QPushButton>
49 #include <QtGui/QToolButton>
50 #include <kvbox.h>
51 //END Includes
52 
53 KateHighlightingMenu::~KateHighlightingMenu()
54 {
55  qDeleteAll (subMenus);
56 }
57 
58 void KateHighlightingMenu::init()
59 {
60  m_doc = 0;
61 
62  connect(menu(),SIGNAL(aboutToShow()),this,SLOT(slotAboutToShow()));
63  m_actionGroup = new QActionGroup(menu());
64 }
65 
66 void KateHighlightingMenu::updateMenu (KateDocument *doc)
67 {
68  m_doc = doc;
69 }
70 
71 void KateHighlightingMenu::slotAboutToShow()
72 {
73  for (int z=0; z < KateHlManager::self()->highlights(); z++)
74  {
75  QString hlName = KateHlManager::self()->hlNameTranslated (z);
76  QString hlSection = KateHlManager::self()->hlSection (z);
77 
78  if (!KateHlManager::self()->hlHidden(z))
79  {
80  if ( !hlSection.isEmpty() && !names.contains(hlName) )
81  {
82  if (!subMenusName.contains(hlSection))
83  {
84  subMenusName << hlSection;
85  QMenu *qmenu = new QMenu ('&'+hlSection);
86  subMenus.append(qmenu);
87  menu()->addMenu( qmenu );
88  }
89 
90  int m = subMenusName.indexOf (hlSection);
91  names << hlName;
92  QAction *a=subMenus.at(m)->addAction( '&' + hlName, this, SLOT(setHl()));
93  m_actionGroup->addAction(a);
94  a->setData(KateHlManager::self()->hlName (z));
95  a->setCheckable(true);
96  subActions.append(a);
97  }
98  else if (!names.contains(hlName))
99  {
100  names << hlName;
101  QAction *a=menu()->addAction ( '&' + hlName, this, SLOT(setHl()));
102  m_actionGroup->addAction(a);
103  a->setData(KateHlManager::self()->hlName (z));
104  a->setCheckable(true);
105  subActions.append(a);
106  }
107  }
108  }
109 
110  if (!m_doc) return;
111  QString mode=m_doc->highlightingMode();
112  for (int i=0;i<subActions.count();i++) {
113  subActions[i]->setChecked(subActions[i]->data().toString()==mode);
114  }
115 }
116 
117 void KateHighlightingMenu::setHl ()
118 {
119  if (!m_doc || !sender()) return;
120  QAction *action=qobject_cast<QAction*>(sender());
121  if (!action) return;
122  QString mode=action->data().toString();
123  m_doc->setHighlightingMode(mode);
124 
125  // use change, honor this
126  m_doc->setDontChangeHlOnSave();
127 }
128 
129 // kate: space-indent on; indent-width 2; replace-tabs on;
kateview.h
katehighlightmenu.h
QActionGroup
QAction::data
QVariant data() const
QList::at
const T & at(int i) const
QStringList::contains
bool contains(const QString &str, Qt::CaseSensitivity cs) const
katedocument.h
KateHighlightingMenu::updateMenu
void updateMenu(KateDocument *doc)
Definition: katehighlightmenu.cpp:66
QActionGroup::addAction
QAction * addAction(QAction *action)
KateHlManager::hlNameTranslated
QString hlNameTranslated(int n)
Definition: katesyntaxmanager.cpp:365
QList::count
int count(const T &value) const
QList::append
void append(const T &value)
katesyntaxmanager.h
kateglobal.h
QString::isEmpty
bool isEmpty() const
katesyntaxdocument.h
KateHighlightingMenu::~KateHighlightingMenu
~KateHighlightingMenu()
Definition: katehighlightmenu.cpp:53
QString
QAction::setData
void setData(const QVariant &userData)
QMenu
KateDocument
Definition: katedocument.h:74
QAction::setCheckable
void setCheckable(bool)
KateHlManager::hlSection
QString hlSection(int n)
Definition: katesyntaxmanager.cpp:370
KateHighlightingMenu::slotAboutToShow
void slotAboutToShow()
Definition: katehighlightmenu.cpp:71
QAction
QStringList::indexOf
int indexOf(const QRegExp &rx, int from) const
kateconfig.h
QVariant::toString
QString toString() const
KateHlManager::self
static KateHlManager * self()
Definition: katesyntaxmanager.cpp:103
KateHlManager::highlights
int highlights()
Definition: katesyntaxmanager.cpp:355
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal