d/control: Recommend gdb
[gammaray-debian.git] / sidepane.cpp
blob80d1b26708e4175a6591088c851a29e96c6b6307
1 /*
2 sidepane.cpp
4 This file is part of GammaRay, the Qt application inspection and
5 manipulation tool.
7 Copyright (C) 2010-2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
8 Author: Kevin Funk <kevin.funk@kdab.com>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "sidepane.h"
26 #include <QDebug>
27 #include <QStyledItemDelegate>
29 using namespace GammaRay;
31 class Delegate : public QStyledItemDelegate
33 public:
34 explicit Delegate(QObject *parent = 0)
35 : QStyledItemDelegate(parent)
39 virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
41 static const int heightMargin = 10;
43 QSize size = QStyledItemDelegate::sizeHint(option, index);
44 size.setHeight(size.height() + heightMargin);
45 return size;
49 SidePane::SidePane(QWidget *parent)
50 : QListView(parent)
52 viewport()->setAutoFillBackground(false);
54 setItemDelegate(new Delegate(this));
57 SidePane::~SidePane()
61 QSize SidePane::sizeHint() const
63 static const int widthMargin = 10;
65 if (!model()) {
66 return QSize(0, 0);
69 const int width = sizeHintForColumn(0) + widthMargin;
70 const int height = QListView::sizeHint().height();
72 return QSize(width, height);
75 void SidePane::resizeEvent(QResizeEvent *e)
77 setMinimumWidth(sizeHint().width());
79 QListView::resizeEvent(e);
82 #include "sidepane.moc"