• Skip to content
  • Skip to link menu
KDE 4.3 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     virtual void drawDecoration(QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, const QPixmap& pixmap) const;
00064     //option can be changed
00065     virtual QList<QTextLayout::FormatRange> createHighlighting(const QModelIndex& index, QStyleOptionViewItem& option) const;
00066 
00067     void adjustRect(QRect& rect) const;
00068     
00072     QList<QTextLayout::FormatRange> highlightingFromVariantList(const QList<QVariant>& customHighlights) const;
00073     
00074     //Called when an item was expanded/unexpanded and the height changed
00075     virtual void heightChanged() const;
00076   
00077     //Initializes the style options from the index
00078     void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const;
00079     
00080     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.
00081     mutable QList<int> m_currentColumnStarts;
00082     mutable QList<QTextLayout::FormatRange> m_cachedHighlights;
00083   
00084     mutable Qt::Alignment m_cachedAlignment;
00085     mutable QColor m_backgroundColor;
00086     mutable QModelIndex m_currentIndex;
00087   private:
00088 
00089     ExpandingWidgetModel* m_model;
00090 };
00091 
00092 #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
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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