add more spacing
[personal-kdebase.git] / workspace / krunner / interfaces / quicksand / qs_statusbar.cpp
blob7e24c4d56785d48ae7f05c250b04c65560d9d016
1 /*
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 .
20 #include <QStyle>
21 #include <QStyleOptionHeader>
22 #include <QStylePainter>
24 #include <KGlobalSettings>
25 #include <KDebug>
27 #include "qs_statusbar.h"
29 namespace QuickSand {
31 QsStatusBar::QsStatusBar(QWidget *parent)
32 : QLabel(parent),
33 m_currentItem(0),
34 m_totalItems(0)
38 // Patterned after QHeaderView
39 void QsStatusBar::paintEvent(QPaintEvent *)
41 QStylePainter painter(this);
43 QRect rect(0, 0, geometry().width(), geometry().height());
45 QStyleOptionHeader opt;
46 opt.initFrom(this);
47 opt.state = QStyle::State_None | QStyle::State_Raised;
48 opt.state |= QStyle::State_Horizontal;
49 opt.state |= QStyle::State_Enabled;
51 opt.rect = rect;
52 opt.section = 0;
53 opt.textAlignment = Qt::AlignRight;
55 opt.iconAlignment = Qt::AlignVCenter;
56 opt.text = QString("%1 of %2").arg(m_currentItem).arg(m_totalItems);
58 opt.position = QStyleOptionHeader::OnlyOneSection;
59 opt.orientation = Qt::Horizontal;
61 QFont font = painter.font();
62 font.setPointSize(qMax(font.pointSize() - 2,
63 KGlobalSettings::smallestReadableFont().pointSize()));
64 painter.setFont(font);
66 painter.drawControl(QStyle::CE_Header, opt);
69 void QsStatusBar::setTotalRows(int total)
71 m_totalItems = total;
74 void QsStatusBar::slotCurrentRowChanged(int newRow)
76 m_currentItem = newRow + 1;
77 update();
80 } //namespace QuickSand
82 #include "qs_statusbar.moc"