• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • sources
  • kde-4.12
  • applications
  • kate
  • part
  • completion
  • expandingtree
expandingtree.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries and the Kate part.
2  *
3  * Copyright (C) 2007 David Nolden <david.nolden.kdevelop@art-master.de>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #include "expandingtree.h"
22 
23 #include <QTextLayout>
24 #include <QTextDocument>
25 #include <QAbstractTextDocumentLayout>
26 #include <QPainter>
27 #include <kdebug.h>
28 #include "expandingwidgetmodel.h"
29 
30 ExpandingTree::ExpandingTree(QWidget* parent) : QTreeView(parent) {
31  m_drawText.documentLayout()->setPaintDevice(this);
32  setUniformRowHeights(false);
33 }
34 
35 void ExpandingTree::drawRow ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const {
36  QTreeView::drawRow( painter, option, index );
37 
38  const ExpandingWidgetModel* eModel = qobject_cast<const ExpandingWidgetModel*>(model());
39  if( eModel && eModel->isPartiallyExpanded( index ) )
40  {
41  QRect rect = eModel->partialExpandRect( index );
42  if( rect.isValid() )
43  {
44  painter->fillRect(rect,QBrush(0xffffffff));
45 
46  QAbstractTextDocumentLayout::PaintContext ctx;
47  // since arbitrary HTML can be shown use a black on white color scheme here
48  ctx.palette = QPalette( Qt::black, Qt::white );
49  ctx.clip = QRectF(0,0,rect.width(),rect.height());;
50  painter->setViewTransformEnabled(true);
51  painter->translate(rect.left(), rect.top());
52 
53  m_drawText.setHtml( eModel->partialExpandText( index ) );
54  m_drawText.setPageSize(QSizeF(rect.width(), rect.height()));
55  m_drawText.documentLayout()->draw( painter, ctx );
56 
57  painter->translate(-rect.left(), -rect.top());
58  }
59  }
60 }
61 
62 int ExpandingTree::sizeHintForColumn ( int column ) const {
63  return columnWidth( column );
64 }
kdebug.h
ExpandingWidgetModel::partialExpandText
QString partialExpandText(const QModelIndex &row) const
Definition: expandingwidgetmodel.cpp:244
QWidget
ExpandingWidgetModel::isPartiallyExpanded
ExpansionType isPartiallyExpanded(const QModelIndex &index) const
Returns whether the given index is currently partially expanded. Does not do any other checks like ca...
Definition: expandingwidgetmodel.cpp:139
ExpandingTree::drawRow
virtual void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: expandingtree.cpp:35
expandingwidgetmodel.h
expandingtree.h
QTreeView
ExpandingTree::ExpandingTree
ExpandingTree(QWidget *parent)
Definition: expandingtree.cpp:30
ExpandingTree::sizeHintForColumn
virtual int sizeHintForColumn(int column) const
Definition: expandingtree.cpp:62
QRect
ExpandingWidgetModel
Cares about expanding/un-expanding items in a tree-view together with ExpandingDelegate.
Definition: expandingwidgetmodel.h:36
ExpandingWidgetModel::partialExpandRect
QRect partialExpandRect(const QModelIndex &row) const
Returns the rectangle for the partially expanded part of the given row.
Definition: expandingwidgetmodel.cpp:251
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

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

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Applications
  •   Libraries
  •     libkonq
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal