summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/kbuttonbox.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (side-by-side diff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdeui/kbuttonbox.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kdeui/kbuttonbox.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kbuttonbox.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/microkde/kdeui/kbuttonbox.cpp b/microkde/kdeui/kbuttonbox.cpp
index 83d622a..3ea6703 100644
--- a/microkde/kdeui/kbuttonbox.cpp
+++ b/microkde/kdeui/kbuttonbox.cpp
@@ -36,57 +36,59 @@
*
* 01/17/98 Mario Weilguni <mweilguni@sime.com>
* Fixed a bug in sizeHint()
* Improved the handling of Motif default buttons
*
* 01/09/98 Mario Weilguni <mweilguni@sime.com>
* The last button was to far right away from the right/bottom border.
* Fixed this. Removed old code. Buttons get now a minimum width.
* Programmer may now override minimum width and height of a button.
*
*/
//US #include "kbuttonbox.moc"
#include <kbuttonbox.h>
#include <qpushbutton.h>
-#include <qptrlist.h>
+#include <q3ptrlist.h>
+//Added by qt3to4:
+#include <QResizeEvent>
#include <assert.h>
#define minButtonWidth 50
class KButtonBox::Item {
public:
QPushButton *button;
bool noexpand;
unsigned short stretch;
unsigned short actual_size;
};
-template class QPtrList<KButtonBox::Item>;
+template class Q3PtrList<KButtonBox::Item>;
class KButtonBoxPrivate {
public:
unsigned short border;
unsigned short autoborder;
unsigned short orientation;
bool activated;
- QPtrList<KButtonBox::Item> buttons;
+ Q3PtrList<KButtonBox::Item> buttons;
};
-KButtonBox::KButtonBox(QWidget *parent, Orientation _orientation,
+KButtonBox::KButtonBox(QWidget *parent, Qt::Orientation _orientation,
int border, int autoborder)
: QWidget(parent)
{
data = new KButtonBoxPrivate;
assert(data != 0);
data->orientation = _orientation;
data->border = border;
data->autoborder = autoborder < 0 ? border : autoborder;
data->buttons.setAutoDelete(TRUE);
}
KButtonBox::~KButtonBox() {
delete data;
}
@@ -136,33 +138,33 @@ void KButtonBox::layout() {
Item *item = data->buttons.at(i);
QPushButton *b = item->button;
if(b != 0) {
if(item->noexpand)
b->setFixedSize(buttonSizeHint(b));
else
b->setFixedSize(bs);
}
}
setMinimumSize(sizeHint());
}
void KButtonBox::placeButtons() {
unsigned int i;
- if(data->orientation == Horizontal) {
+ if(data->orientation == Qt::Horizontal) {
// calculate free size and stretches
int fs = width() - 2 * data->border;
int stretch = 0;
for(i = 0; i < data->buttons.count(); i++) {
Item *item = data->buttons.at(i);
if(item->button != 0) {
fs -= item->button->width();
// Last button?
if(i != data->buttons.count() - 1)
fs -= data->autoborder;
} else
stretch +=item->stretch;
}
// distribute buttons
@@ -238,52 +240,52 @@ QSize KButtonBox::sizeHint() const {
return QSize(0, 0);
else {
dw = 2 * data->border;
QSize bs = bestButtonSize();
for(i = 0; i < data->buttons.count(); i++) {
KButtonBox *that = (KButtonBox*)this;
Item *item = that->data->buttons.at(i);
QPushButton *b = item->button;
if(b != 0) {
QSize s;
if(item->noexpand)
s = that->buttonSizeHint(b);
else
s = bs;
- if(data->orientation == Horizontal)
+ if(data->orientation == Qt::Horizontal)
dw += s.width();
else
dw += s.height();
if( i != data->buttons.count() - 1 )
dw += data->autoborder;
}
}
- if(data->orientation == Horizontal)
+ if(data->orientation == Qt::Horizontal)
return QSize(dw, bs.height() + 2 * data->border);
else
return QSize(bs.width() + 2 * data->border, dw);
}
}
QSizePolicy KButtonBox::sizePolicy() const
{
- return data->orientation == Horizontal?
+ return data->orientation == Qt::Horizontal?
QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) :
QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum );
}
/*
* Returns the best size for a button. If a button is less than
* minButtonWidth pixels wide, return minButtonWidth pixels
* as minimum width
*/
QSize KButtonBox::buttonSizeHint(QPushButton *b) const {
QSize s = b->sizeHint();
QSize ms = b->minimumSize();
if(s.width() < minButtonWidth)
s.setWidth(minButtonWidth);
// allows the programmer to override the settings