2 * Copyright (C) 2007-2008 Ryan P. Bitanga <ryan.bitanga@gmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA .
22 #include <QResizeEvent>
26 #include "qs_completionbox.h"
27 #include "qs_statusbar.h"
31 QsCompletionBox::QsCompletionBox(QWidget
*parent
)
32 : KCompletionBox(parent
),
35 m_status
= new QsStatusBar(this);
36 connect(model(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)), this, SLOT(slotRowsChanged(const QModelIndex
&, int, int)));
37 connect(model(), SIGNAL(rowsRemoved(const QModelIndex
&, int, int)), this, SLOT(slotRowsChanged(const QModelIndex
&, int, int)));
38 connect(this, SIGNAL(currentRowChanged(int)), m_status
, SLOT(slotCurrentRowChanged(int)));
41 QRect
QsCompletionBox::calculateGeometry() const
43 QRect geom
= KCompletionBox::calculateGeometry();
44 geom
.setHeight(geom
.height() + m_status
->geometry().height());
45 geom
.setWidth(geom
.width() * 3/4);
49 QSize
QsCompletionBox::minimumSizeHint() const
54 QSize
QsCompletionBox::sizeHint() const
56 return calculateGeometry().size();
59 void QsCompletionBox::popup()
61 KCompletionBox::popup();
62 resize(calculateGeometry().size());
65 void QsCompletionBox::updateGeometries()
67 KCompletionBox::updateGeometries();
68 int statusHeight
= m_status
->geometry().height();
70 // setGeometry(calculateGeometry());
72 setViewportMargins(0,0,0,statusHeight
);
74 QRect vg
= viewport()->geometry();
75 int statusTop
= vg
.bottom();
77 m_status
->setGeometry(vg
.left(), statusTop
, vg
.width(), statusHeight
);
80 void QsCompletionBox::slotRowsChanged(const QModelIndex
&, int, int)
82 int rows
= model()->rowCount();
83 m_status
->setTotalRows(rows
);
86 QPoint
QsCompletionBox::globalPositionHint() const
88 QWidget
*p
= qobject_cast
<QWidget
*>(parent());
92 return p
->mapToGlobal(QPoint(p
->width(), 22));
95 } // Namespace QuickSand
97 #include "qs_completionbox.moc"