• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • 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   m_actionGroup = new QActionGroup(menu());
00064 }
00065 
00066 void KateHighlightingMenu::updateMenu (KateDocument *doc)
00067 {
00068   m_doc = doc;
00069 }
00070 
00071 void KateHighlightingMenu::slotAboutToShow()
00072 {
00073   for (int z=0; z < KateHlManager::self()->highlights(); z++)
00074   {
00075     QString hlName = KateHlManager::self()->hlNameTranslated (z);
00076     QString hlSection = KateHlManager::self()->hlSection (z);
00077 
00078     if (!KateHlManager::self()->hlHidden(z))
00079     {
00080       if ( !hlSection.isEmpty() && !names.contains(hlName) )
00081       {
00082         if (!subMenusName.contains(hlSection))
00083         {
00084           subMenusName << hlSection;
00085           QMenu *qmenu = new QMenu ('&'+hlSection);
00086           subMenus.append(qmenu);
00087           menu()->addMenu( qmenu );
00088         }
00089 
00090         int m = subMenusName.indexOf (hlSection);
00091         names << hlName;
00092         QAction *a=subMenus.at(m)->addAction( '&' + hlName, this, SLOT(setHl()));
00093         m_actionGroup->addAction(a);
00094         a->setData(KateHlManager::self()->hlName (z));
00095         a->setCheckable(true);
00096         subActions.append(a);
00097       }
00098       else if (!names.contains(hlName))
00099       {
00100         names << hlName;
00101         QAction *a=menu()->addAction ( '&' + hlName, this, SLOT(setHl()));
00102         m_actionGroup->addAction(a);
00103         a->setData(KateHlManager::self()->hlName (z));
00104         a->setCheckable(true);
00105         subActions.append(a);
00106       }
00107     }
00108   }
00109 
00110   if (!m_doc) return;
00111   QString mode=m_doc->highlightingMode();
00112   for (int i=0;i<subActions.count();i++) {
00113         subActions[i]->setChecked(subActions[i]->data().toString()==mode);
00114   }
00115 }
00116 
00117 void KateHighlightingMenu::setHl ()
00118 {
00119   if (!m_doc || !sender()) return;
00120   QAction *action=qobject_cast<QAction*>(sender());
00121   if (!action) return;
00122   QString mode=action->data().toString();
00123   m_doc->setHighlightingMode(mode);
00124 
00125   // use change, honor this
00126   m_doc->setDontChangeHlOnSave();
00127 }
00128 
00129 // 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
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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