• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Kate

katehighlightmenu.cpp

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 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 //BEGIN Includes
00020 #include "katehighlightmenu.h"
00021 #include "katehighlightmenu.moc"
00022 
00023 #include "katedocument.h"
00024 #include "kateconfig.h"
00025 #include "kateview.h"
00026 #include "kateglobal.h"
00027 #include "katesyntaxmanager.h"
00028 #include "katesyntaxdocument.h"
00029 
00030 #include "ui_filetypeconfigwidget.h"
00031 
00032 #include <kconfig.h>
00033 #include <kmimetype.h>
00034 #include <kmimetypechooser.h>
00035 #include <kdebug.h>
00036 #include <kiconloader.h>
00037 #include <knuminput.h>
00038 #include <klocale.h>
00039 #include <kmenu.h>
00040 
00041 #include <QtCore/QRegExp>
00042 #include <QtGui/QCheckBox>
00043 #include <QtGui/QComboBox>
00044 #include <QtGui/QGroupBox>
00045 
00046 #include <QtGui/QLabel>
00047 #include <QtGui/QLayout>
00048 #include <QtGui/QPushButton>
00049 #include <QtGui/QToolButton>
00050 #include <kvbox.h>
00051 //END Includes
00052 
00053 KateHighlightingMenu::~KateHighlightingMenu()
00054 {
00055   qDeleteAll (subMenus);
00056 }
00057 
00058 void KateHighlightingMenu::init()
00059 {
00060   m_doc = 0;
00061 
00062   connect(menu(),SIGNAL(aboutToShow()),this,SLOT(slotAboutToShow()));
00063 }
00064 
00065 void KateHighlightingMenu::updateMenu (KateDocument *doc)
00066 {
00067   m_doc = doc;
00068 }
00069 
00070 void KateHighlightingMenu::slotAboutToShow()
00071 {
00072   for (int z=0; z < KateHlManager::self()->highlights(); z++)
00073   {
00074     QString hlName = KateHlManager::self()->hlNameTranslated (z);
00075     QString hlSection = KateHlManager::self()->hlSection (z);
00076 
00077     if (!KateHlManager::self()->hlHidden(z))
00078     {
00079       if ( !hlSection.isEmpty() && !names.contains(hlName) )
00080       {
00081         if (!subMenusName.contains(hlSection))
00082         {
00083           subMenusName << hlSection;
00084           QMenu *qmenu = new QMenu ('&'+hlSection);
00085           subMenus.append(qmenu);
00086           menu()->addMenu( qmenu );
00087         }
00088 
00089         int m = subMenusName.indexOf (hlSection);
00090         names << hlName;
00091         QAction *a=subMenus.at(m)->addAction( '&' + hlName, this, SLOT(setHl()));
00092         a->setData(KateHlManager::self()->hlName (z));
00093         a->setCheckable(true);
00094         subActions.append(a);
00095       }
00096       else if (!names.contains(hlName))
00097       {
00098         names << hlName;
00099         QAction *a=menu()->addAction ( '&' + hlName, this, SLOT(setHl()));
00100         a->setData(KateHlManager::self()->hlName (z));
00101         a->setCheckable(true);
00102         subActions.append(a);
00103       }
00104     }
00105   }
00106 
00107   if (!m_doc) return;
00108   QString mode=m_doc->highlightingMode();
00109   for (int i=0;i<subActions.count();i++) {
00110         subActions[i]->setChecked(subActions[i]->data().toString()==mode);
00111   }
00112 }
00113 
00114 void KateHighlightingMenu::setHl ()
00115 {
00116   if (!m_doc || !sender()) return;
00117   QAction *action=qobject_cast<QAction*>(sender());
00118   if (!action) return;
00119   QString mode=action->data().toString();
00120   m_doc->setHighlightingMode(mode);
00121 }
00122 
00123 // kate: space-indent on; indent-width 2; replace-tabs on;

Kate

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal