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 .
21 #include <QStyleOptionHeader>
22 #include <QStylePainter>
24 #include <KGlobalSettings>
27 #include "qs_statusbar.h"
31 QsStatusBar::QsStatusBar(QWidget
*parent
)
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
;
47 opt
.state
= QStyle::State_None
| QStyle::State_Raised
;
48 opt
.state
|= QStyle::State_Horizontal
;
49 opt
.state
|= QStyle::State_Enabled
;
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
)
74 void QsStatusBar::slotCurrentRowChanged(int newRow
)
76 m_currentItem
= newRow
+ 1;
80 } //namespace QuickSand
82 #include "qs_statusbar.moc"