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

Kate

expandingwidgetmodel.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2007 David Nolden <david.nolden.kdevelop@art-master.de>
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 #ifndef EXPANDING_WIDGET_MODEL_H
00019 #define EXPANDING_WIDGET_MODEL_H
00020 
00021 #include <QAbstractTableModel>
00022 #include <QtCore/QHash>
00023 #include <QIcon>
00024 #include <QPersistentModelIndex>
00025 #include <QPointer>
00026 
00027 class KWidget;
00028 class QTreeView;
00029 class QTextEdit;
00030 
00034 class ExpandingWidgetModel : public QAbstractTableModel {
00035     Q_OBJECT
00036     public:
00037         
00038     ExpandingWidgetModel( QWidget* parent );
00039     virtual ~ExpandingWidgetModel();
00040     
00041     enum ExpandingType {
00042       NotExpandable=0,
00043       Expandable,
00044       Expanded
00045     };
00046 
00049     bool canExpandCurrentItem() const;
00051     bool canCollapseCurrentItem() const;
00053     void setCurrentItemExpanded( bool );
00054 
00055     void clearMatchQualities();
00056     
00058     void clearExpanding();
00059     
00061     bool isExpandable(const QModelIndex& index) const;
00062 
00063     enum ExpansionType {
00064         NotExpanded = 0,
00065         ExpandDownwards, //The additional(expanded) information is shown UNDER the original information
00066         ExpandUpwards //The additional(expanded) information is shown ABOVE the original information
00067     };
00068     
00070     ExpansionType isPartiallyExpanded(const QModelIndex& index) const;
00071 
00073     bool isExpanded(const QModelIndex & row) const;
00075     void setExpanded(QModelIndex index, bool expanded);
00076 
00078     int expandingWidgetsHeight() const;
00079     
00082     QWidget* expandingWidget(const QModelIndex & row) const;
00083 
00085     int partiallyExpandWidgetHeight() const;
00094 
00095     virtual void rowSelected(const QModelIndex & row);
00096 
00098     QRect partialExpandRect(const QModelIndex & row) const;
00099 
00100     QString partialExpandText(const QModelIndex & row) const;
00101     
00104     void placeExpandingWidget(const QModelIndex & row);
00105     
00106     virtual QTreeView* treeView() const = 0;
00107     
00109     virtual bool indexIsItem(const QModelIndex& index) const = 0;
00110 
00112     virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
00113 
00115     QModelIndex partiallyExpandedRow() const;
00116 
00118     uint matchColor(const QModelIndex& index) const;
00119     
00120     public slots:
00122     void placeExpandingWidgets();
00123 
00124     protected:
00128     virtual int contextMatchQuality(const QModelIndex & index) const = 0;
00129 
00130     //Makes sure m_expandedIcon and m_collapsedIcon are loaded
00131     void cacheIcons() const;
00132     
00133     static QIcon m_expandedIcon;
00134     static QIcon m_collapsedIcon;
00135     
00136     //Does not update the view
00137     void partiallyUnExpand(const QModelIndex& index);
00138     //Finds out the basic height of the row represented by the given index. Basic means without respecting any expansion.
00139     int basicRowHeight( const QModelIndex& index ) const;
00140     
00141     private:
00142     QMap<QPersistentModelIndex, ExpansionType> m_partiallyExpanded;
00143     // Store expanding-widgets and cache whether items can be expanded
00144     mutable QMap<QPersistentModelIndex, ExpandingType> m_expandState;
00145     QMap< QPersistentModelIndex, QPointer<QWidget> > m_expandingWidgets; //Map rows to their expanding-widgets
00146     QMap< QPersistentModelIndex, int > m_contextMatchQualities; //Map rows to their context-match qualities(undefined if unknown, else 0 to 10). Not used yet, eventually remove.
00147 };
00148 
00149 
00157 QList<QVariant> mergeCustomHighlighting( QStringList strings, QList<QVariantList> highlights, int gapBetweenStrings = 0 );
00158 #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
  • 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