1
/* This file is part of the KDE libraries
2
Copyright (C) 2001-2003 Christoph Cullmann <cullmann@kde.org>
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.
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.
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.
20
#include "katehighlightmenu.h"
21
#include "katehighlightmenu.moc"
23
#include "katedocument.h"
24
#include "kateconfig.h"
26
#include "kateglobal.h"
27
#include "katesyntaxmanager.h"
28
#include "katesyntaxdocument.h"
30
#include "ui_filetypeconfigwidget.h"
33
#include <kmimetype.h>
34
#include <kmimetypechooser.h>
36
#include <kiconloader.h>
37
#include <knuminput.h>
41
#include <QtCore/QRegExp>
42
#include <QtGui/QCheckBox>
43
#include <QtGui/QComboBox>
44
#include <QtGui/QGroupBox>
46
#include <QtGui/QLabel>
47
#include <QtGui/QLayout>
48
#include <QtGui/QPushButton>
49
#include <QtGui/QToolButton>
53
KateHighlightingMenu::~KateHighlightingMenu()
55
qDeleteAll (subMenus);
58
void KateHighlightingMenu::init()
62
connect(menu(),SIGNAL(aboutToShow()),this,SLOT(slotAboutToShow()));
63
m_actionGroup = new QActionGroup(menu());
66
void KateHighlightingMenu::updateMenu (KateDocument *doc)
71
void KateHighlightingMenu::slotAboutToShow()
73
for (int z=0; z < KateHlManager::self()->highlights(); z++)
75
QString hlName = KateHlManager::self()->hlNameTranslated (z);
76
QString hlSection = KateHlManager::self()->hlSection (z);
78
if (!KateHlManager::self()->hlHidden(z))
80
if ( !hlSection.isEmpty() && !names.contains(hlName) )
82
if (!subMenusName.contains(hlSection))
84
subMenusName << hlSection;
85
QMenu *qmenu = new QMenu ('&'+hlSection);
86
subMenus.append(qmenu);
87
menu()->addMenu( qmenu );
90
int m = subMenusName.indexOf (hlSection);
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);
98
else if (!names.contains(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);
111
QString mode=m_doc->highlightingMode();
112
for (int i=0;i<subActions.count();i++) {
113
subActions[i]->setChecked(subActions[i]->data().toString()==mode);
117
void KateHighlightingMenu::setHl ()
119
if (!m_doc || !sender()) return;
120
QAction *action=qobject_cast<QAction*>(sender());
122
QString mode=action->data().toString();
123
m_doc->setHighlightingMode(mode);
125
// use change, honor this
126
m_doc->setDontChangeHlOnSave();
129
// kate: space-indent on; indent-width 2; replace-tabs on;