Changeset View
Changeset View
Standalone View
Standalone View
plugins/quickopen/expandingtree/expandingtree.cpp
Show All 16 Lines | |||||
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | * Boston, MA 02110-1301, USA. | 18 | * Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "expandingtree.h" | 21 | #include "expandingtree.h" | ||
22 | 22 | | |||
23 | #include <QTextLayout> | 23 | #include <QTextLayout> | ||
24 | #include <QTextDocument> | 24 | #include <QTextDocument> | ||
25 | #include <QAbstractProxyModel> | ||||
25 | #include <QAbstractTextDocumentLayout> | 26 | #include <QAbstractTextDocumentLayout> | ||
26 | #include <QPainter> | 27 | #include <QPainter> | ||
27 | #include "expandingwidgetmodel.h" | 28 | #include "expandingwidgetmodel.h" | ||
28 | 29 | | |||
29 | #include <util/path.h> | 30 | #include <util/path.h> | ||
30 | #include <util/widgetcolorizer.h> | 31 | #include <util/widgetcolorizer.h> | ||
31 | 32 | | |||
32 | using namespace KDevelop; | 33 | using namespace KDevelop; | ||
33 | 34 | | |||
34 | ExpandingTree::ExpandingTree(QWidget* parent) : QTreeView(parent) { | 35 | ExpandingTree::ExpandingTree(QWidget* parent) : QTreeView(parent) { | ||
35 | m_drawText.documentLayout()->setPaintDevice(this); | 36 | m_drawText.documentLayout()->setPaintDevice(this); | ||
36 | setUniformRowHeights(false); | 37 | setUniformRowHeights(false); | ||
37 | } | 38 | } | ||
38 | 39 | | |||
39 | void ExpandingTree::drawRow ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const { | 40 | void ExpandingTree::drawRow ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const { | ||
40 | QTreeView::drawRow( painter, option, index ); | 41 | QTreeView::drawRow( painter, option, index ); | ||
41 | 42 | | |||
42 | const ExpandingWidgetModel* eModel = qobject_cast<const ExpandingWidgetModel*>(model()); | 43 | const ExpandingWidgetModel* eModel = qobject_cast<const ExpandingWidgetModel*>( qobject_cast<const QAbstractProxyModel*>(model())->sourceModel()); | ||
43 | if( eModel && eModel->isPartiallyExpanded( index ) != ExpandingWidgetModel::ExpansionType::NotExpanded) | 44 | Q_ASSERT(eModel); | ||
45 | const QModelIndex sourceIndex = eModel->mapToSource(index); | ||||
brauch: This makes no sense, first you deference it and then you have a check below | |||||
46 | if (eModel->isPartiallyExpanded( sourceIndex ) != ExpandingWidgetModel::ExpansionType::NotExpanded) | ||||
44 | { | 47 | { | ||
45 | QRect rect = eModel->partialExpandRect( index ); | 48 | QRect rect = eModel->partialExpandRect( sourceIndex ); | ||
46 | if( rect.isValid() ) | 49 | if( rect.isValid() ) | ||
47 | { | 50 | { | ||
48 | painter->fillRect(rect,QBrush(0xffffffff)); | 51 | painter->fillRect(rect,QBrush(0xffffffff)); | ||
49 | 52 | | |||
50 | QAbstractTextDocumentLayout::PaintContext ctx; | 53 | QAbstractTextDocumentLayout::PaintContext ctx; | ||
51 | // since arbitrary HTML can be shown use a black on white color scheme here | 54 | // since arbitrary HTML can be shown use a black on white color scheme here | ||
52 | ctx.palette = QPalette( Qt::black, Qt::white ); | 55 | ctx.palette = QPalette( Qt::black, Qt::white ); | ||
53 | ctx.clip = QRectF(0,0,rect.width(),rect.height());; | 56 | ctx.clip = QRectF(0,0,rect.width(),rect.height());; | ||
54 | painter->setViewTransformEnabled(true); | 57 | painter->setViewTransformEnabled(true); | ||
55 | painter->translate(rect.left(), rect.top()); | 58 | painter->translate(rect.left(), rect.top()); | ||
56 | 59 | | |||
57 | m_drawText.setHtml( eModel->partialExpandText( index ) ); | 60 | m_drawText.setHtml( eModel->partialExpandText( sourceIndex ) ); | ||
58 | m_drawText.setPageSize(QSizeF(rect.width(), rect.height())); | 61 | m_drawText.setPageSize(QSizeF(rect.width(), rect.height())); | ||
59 | m_drawText.documentLayout()->draw( painter, ctx ); | 62 | m_drawText.documentLayout()->draw( painter, ctx ); | ||
60 | 63 | | |||
61 | painter->translate(-rect.left(), -rect.top()); | 64 | painter->translate(-rect.left(), -rect.top()); | ||
62 | } | 65 | } | ||
63 | } | 66 | } | ||
64 | } | 67 | } | ||
65 | 68 | | |||
Show All 13 Lines |
This makes no sense, first you deference it and then you have a check below