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

Kate

expandingdelegate.h

Go to the documentation of this file.
00001 
00002 /* This file is part of the KDE libraries
00003    Copyright (C) 2006 Hamish Rodda <rodda@kde.org>
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 ExpandingDelegate_H
00021 #define ExpandingDelegate_H
00022 
00023 #include <QtGui/QItemDelegate>
00024 #include <QItemDelegate>
00025 #include <QtGui/QTextLine>
00026 #include <QModelIndex>
00027 #include <QPoint>
00028 
00029 class KateRenderer;
00030 class KateCompletionWidget;
00031 class KateDocument;
00032 class KateTextLine;
00033 class ExpandingWidgetModel;
00034 class QVariant;
00035 class QStyleOptionViewItem;
00036 
00041 class ExpandingDelegate : public QItemDelegate
00042 {
00043   Q_OBJECT
00044 
00045   public:
00046     explicit ExpandingDelegate(ExpandingWidgetModel* model, QObject* parent = 0L);
00047 
00048 
00049     // Overridden to create highlighting for current index
00050     virtual void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
00051 
00052     // Returns the basic size-hint as reported by QItemDelegate
00053     QSize basicSizeHint( const QModelIndex& index ) const;
00054     
00055     ExpandingWidgetModel* model() const;
00056   protected:
00057     //Called right before paint to allow last-minute changes to the style
00058     virtual void adjustStyle( const QModelIndex& index, QStyleOptionViewItem & option ) const;
00059     virtual void drawDisplay ( QPainter * painter, const QStyleOptionViewItem & option, const QRect & rect, const QString & text ) const;
00060     virtual QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const;
00061     virtual bool editorEvent ( QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index );
00062     virtual void drawBackground ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
00063     //option can be changed
00064     virtual QList<QTextLayout::FormatRange> createHighlighting(const QModelIndex& index, QStyleOptionViewItem& option) const;
00065 
00069     QList<QTextLayout::FormatRange> highlightingFromVariantList(const QList<QVariant>& customHighlights) const;
00070     
00071     //Called when an item was expanded/unexpanded and the height changed
00072     virtual void heightChanged() const;
00073   
00074     //Initializes the style options from the index
00075     void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const;
00076     
00077     mutable int m_currentColumnStart; //Text-offset for custom highlighting, will be applied to m_cachedHighlights(Only highlights starting after this will be used). Shoult be zero of the highlighting is not taken from kate.
00078     mutable QList<int> m_currentColumnStarts;
00079     mutable QList<QTextLayout::FormatRange> m_cachedHighlights;
00080   
00081     mutable Qt::Alignment m_cachedAlignment;
00082   private:
00083 
00084     ExpandingWidgetModel* m_model;
00085 };
00086 
00087 #endif

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
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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