1 | /* $Id: QITreeWidget.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
5 | * VirtualBox Qt extensions: QITreeWidget class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2008-2009 Oracle Corporation
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | */
|
---|
19 |
|
---|
20 | /* Global includes */
|
---|
21 | #include <QPainter>
|
---|
22 | #include <QResizeEvent>
|
---|
23 |
|
---|
24 | /* Local includes */
|
---|
25 | #include "QITreeWidget.h"
|
---|
26 |
|
---|
27 | QITreeWidget::QITreeWidget (QWidget *aParent)
|
---|
28 | : QTreeWidget (aParent)
|
---|
29 | {
|
---|
30 | }
|
---|
31 |
|
---|
32 | void QITreeWidget::paintEvent (QPaintEvent *aEvent)
|
---|
33 | {
|
---|
34 | /* Opens Items Painter */
|
---|
35 | QPainter painter;
|
---|
36 | painter.begin (viewport());
|
---|
37 |
|
---|
38 | /* Notify connected objects about painting */
|
---|
39 | QTreeWidgetItemIterator it (this);
|
---|
40 | while (*it)
|
---|
41 | {
|
---|
42 | emit painted (*it, &painter);
|
---|
43 | ++ it;
|
---|
44 | }
|
---|
45 |
|
---|
46 | /* Close Items Painter */
|
---|
47 | painter.end();
|
---|
48 |
|
---|
49 | /* Base-class paint-event */
|
---|
50 | QTreeWidget::paintEvent (aEvent);
|
---|
51 | }
|
---|
52 |
|
---|
53 | void QITreeWidget::resizeEvent (QResizeEvent *aEvent)
|
---|
54 | {
|
---|
55 | /* Base-class resize-event */
|
---|
56 | QTreeWidget::resizeEvent (aEvent);
|
---|
57 |
|
---|
58 | /* Notify connected objects about resize */
|
---|
59 | emit resized (aEvent->size(), aEvent->oldSize());
|
---|
60 | }
|
---|
61 |
|
---|
62 | void QITreeWidget::addTopBottomMarginToItems (int aMargin)
|
---|
63 | {
|
---|
64 | for (int i = 0; i < topLevelItemCount(); ++ i)
|
---|
65 | {
|
---|
66 | QTreeWidgetItem *item = topLevelItem (i);
|
---|
67 | QSize s = item->sizeHint (0);
|
---|
68 | item->setSizeHint (0, QSize (s.width(), s.height() + 2 * aMargin));
|
---|
69 | }
|
---|
70 | }
|
---|
71 |
|
---|