qdesigner_internal::TreeWidget Class Reference

#include <tree_widget_p.h>

Inheritance diagram for qdesigner_internal::TreeWidget:

Inheritance graph
[legend]
Collaboration diagram for qdesigner_internal::TreeWidget:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 44 of file tree_widget_p.h.

Public Member Functions

 TreeWidget (QWidget *parent=0)
virtual ~TreeWidget ()

Protected Member Functions

void drawBranches (QPainter *painter, const QRect &rect, const QModelIndex &index) const


Constructor & Destructor Documentation

qdesigner_internal::TreeWidget::TreeWidget ( QWidget parent = 0  ) 

Definition at line 70 of file tree_widget.cpp.

References QAbstractItemView::setAlternatingRowColors(), and QAbstractItemView::setItemDelegate().

00071     : QTreeWidget(parent)
00072 {
00073     setItemDelegate(new TreeWidgetDelegate(this));
00074 
00075     setAlternatingRowColors(true);
00076 }

Here is the call graph for this function:

qdesigner_internal::TreeWidget::~TreeWidget (  )  [virtual]

Definition at line 78 of file tree_widget.cpp.

00079 {
00080 }


Member Function Documentation

void qdesigner_internal::TreeWidget::drawBranches ( QPainter painter,
const QRect rect,
const QModelIndex index 
) const [protected, virtual]

Draws the branches in the tree view on the same row as the model item index, using the painter given. The branches are drawn in the rectangle specified by rect.

Reimplemented from QTreeView.

Definition at line 93 of file tree_widget.cpp.

References QRect::bottom(), QPainter::drawLine(), QStyle::drawPrimitive(), QRect::height(), QTreeView::indentation(), index, QObject::inherits(), QTreeView::isExpanded(), QWidget::isRightToLeft(), QRect::left(), qdesigner_internal::level(), QAbstractItemView::model(), QStyle::PE_IndicatorBranch, QPainter::pen(), QStyleOption::rect, QWidget::rect(), reverse(), QRect::right(), QPainter::setPen(), QStyle::SH_Table_GridLineColor, QStyleOption::state, QStyle::State_Children, QStyle::State_Open, QApplication::style(), QWidget::style(), QStyle::styleHint(), QRect::top(), QAbstractItemView::viewOptions(), and QRect::x().

00094 {
00095     // designer figts the style it uses. :(
00096     static bool mac_style 
00097         = QApplication::style()->inherits("QMacStyle");
00098     static const int windows_deco_size = 9;
00099 
00100     QStyleOptionViewItem option = viewOptions();
00101 
00102     if (model()->hasChildren(index)) {
00103         option.state |= QStyle::State_Children;
00104 
00105         const bool reverse = isRightToLeft();
00106         int indent = level(model(), index)*indentation();
00107         QRect primitive(reverse ? rect.left() : rect.left() + indent - 2,
00108                         rect.top(), indentation(), rect.height());
00109 
00110         if (!mac_style) {
00111             primitive.moveLeft(reverse ? primitive.left()
00112                                : primitive.left() + (primitive.width() - windows_deco_size)/2);
00113             primitive.moveTop(primitive.top() + (primitive.height() - windows_deco_size)/2);
00114             primitive.setWidth(windows_deco_size);
00115             primitive.setHeight(windows_deco_size);
00116         }
00117 
00118         option.rect = primitive;
00119 
00120         if (isExpanded(index))
00121             option.state |= QStyle::State_Open;
00122 
00123         style()->drawPrimitive(QStyle::PE_IndicatorBranch, &option, painter, this);
00124     }
00125     QPen savedPen = painter->pen();
00126     QColor color = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &option));
00127     painter->setPen(QPen(color));
00128     painter->drawLine(rect.x(), rect.bottom(), rect.right(), rect.bottom());
00129     painter->setPen(savedPen);
00130 }

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 20:49:55 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1