From a08aff328d4393031d5ba7d622c2b05705a89d73 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Wed, 04 Jul 2007 11:23:42 +0000 Subject: initial public commit of qt4 port --- (limited to 'microkde/kdeui/kjanuswidget.cpp') diff --git a/microkde/kdeui/kjanuswidget.cpp b/microkde/kdeui/kjanuswidget.cpp index 462c44f..3d9173d 100644 --- a/microkde/kdeui/kjanuswidget.cpp +++ b/microkde/kdeui/kjanuswidget.cpp @@ -22,15 +22,23 @@ #include #include #include -#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include #include -#include +#include #include +//Added by qt3to4: +#include +#include +#include +#include +#include +#include +#include /*US #include #include @@ -65,13 +73,13 @@ #include "kjanuswidget.h" -class KJanusWidget::IconListItem : public QListBoxItem +class KJanusWidget::IconListItem : public Q3ListBoxItem { public: - IconListItem( QListBox *listbox, const QPixmap &pixmap, + IconListItem( Q3ListBox *listbox, const QPixmap &pixmap, const QString &text ); - virtual int height( const QListBox *lb ) const; - virtual int width( const QListBox *lb ) const; + virtual int height( const Q3ListBox *lb ) const; + virtual int width( const Q3ListBox *lb ) const; int expandMinimumWidth( int width ); protected: @@ -98,7 +106,7 @@ public: QMap mIntToTitle; }; -template class QPtrList; +template class Q3PtrList; KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face ) @@ -107,12 +115,12 @@ KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face ) mTitleList(0), mFace(face), mTitleLabel(0), mActivePageWidget(0), mShowIconsInTreeList(false), d(0) { - QVBoxLayout *topLayout = new QVBoxLayout( this ); + Q3VBoxLayout *topLayout = new Q3VBoxLayout( this ); if( mFace == TreeList || mFace == IconList ) { d = new KJanusWidgetPrivate; - QFrame *page = 0; + Q3Frame *page = 0; if( mFace == TreeList ) { //US @@ -145,7 +153,7 @@ KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face ) } else { - QHBoxLayout *hbox = new QHBoxLayout( topLayout ); + Q3HBoxLayout *hbox = new Q3HBoxLayout( topLayout ); mIconList = new IconListBox( this ); QFont listFont( mIconList->font() ); @@ -156,7 +164,7 @@ KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face ) hbox->addWidget( mIconList ); connect( mIconList, SIGNAL(selectionChanged()), SLOT(slotShowPage())); hbox->addSpacing( KDialog::marginHint() ); - page = new QFrame( this ); + page = new Q3Frame( this ); hbox->addWidget( page, 10 ); } @@ -165,7 +173,7 @@ KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face ) // pagestack using all available space at bottom. // - QVBoxLayout *vbox = new QVBoxLayout( page, 0, KDialog::spacingHint() ); + Q3VBoxLayout *vbox = new Q3VBoxLayout( page, 0, KDialog::spacingHint() ); mTitleLabel = new QLabel( QString::fromLatin1("Empty page"), page, "KJanusWidgetTitleLabel" ); vbox->addWidget( mTitleLabel ); @@ -175,10 +183,10 @@ KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face ) mTitleLabel->setFont( titleFont ); mTitleSep = new KSeparator( page ); - mTitleSep->setFrameStyle( QFrame::HLine|QFrame::Plain ); + mTitleSep->setFrameStyle( Q3Frame::HLine|Q3Frame::Plain ); vbox->addWidget( mTitleSep ); - mPageStack = new QWidgetStack( page ); + mPageStack = new Q3WidgetStack( page ); connect(mPageStack, SIGNAL(aboutToShow(QWidget *)), SIGNAL(aboutToShowPage(QWidget *))); vbox->addWidget( mPageStack, 10 ); @@ -199,7 +207,7 @@ KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face ) else { mFace = Plain; - mPlainPage = new QFrame( this ); + mPlainPage = new Q3Frame( this ); topLayout->addWidget( mPlainPage, 10 ); } /*US @@ -245,7 +253,7 @@ bool KJanusWidget::isValid() const } -QFrame *KJanusWidget::plainPage() +Q3Frame *KJanusWidget::plainPage() { return( mPlainPage ); } @@ -266,7 +274,7 @@ QWidget *KJanusWidget::FindParent() } } -QFrame *KJanusWidget::addPage( const QStringList &items, const QString &header, +Q3Frame *KJanusWidget::addPage( const QStringList &items, const QString &header, const QPixmap &pixmap ) { if( mValid == false ) @@ -275,7 +283,7 @@ QFrame *KJanusWidget::addPage( const QStringList &items, const QString &header, return( 0 ); } - QFrame *page = new QFrame( FindParent(), "page" ); + Q3Frame *page = new Q3Frame( FindParent(), "page" ); addPageWidget( page, items, header, pixmap ); return page; @@ -287,13 +295,13 @@ void KJanusWidget::pageGone( QObject *obj ) removePage( static_cast( obj ) ); } -void KJanusWidget::slotReopen( QListViewItem * item ) +void KJanusWidget::slotReopen( Q3ListViewItem * item ) { if( item ) item->setOpen( true ); } -QFrame *KJanusWidget::addPage( const QString &itemName, const QString &header, +Q3Frame *KJanusWidget::addPage( const QString &itemName, const QString &header, const QPixmap &pixmap ) { @@ -304,7 +312,7 @@ QFrame *KJanusWidget::addPage( const QString &itemName, const QString &header, -QVBox *KJanusWidget::addVBoxPage( const QStringList &items, +Q3VBox *KJanusWidget::addVBoxPage( const QStringList &items, const QString &header, const QPixmap &pixmap ) { @@ -315,14 +323,14 @@ QVBox *KJanusWidget::addVBoxPage( const QStringList &items, return( 0 ); } - QVBox *page = new QVBox(FindParent() , "vbox_page" ); + Q3VBox *page = new Q3VBox(FindParent() , "vbox_page" ); page->setSpacing( KDialog::spacingHintSmall() ); addPageWidget( page, items, header, pixmap ); return page; } -QVBox *KJanusWidget::addVBoxPage( const QString &itemName, +Q3VBox *KJanusWidget::addVBoxPage( const QString &itemName, const QString &header, const QPixmap &pixmap ) { @@ -331,7 +339,7 @@ QVBox *KJanusWidget::addVBoxPage( const QString &itemName, return addVBoxPage(items, header, pixmap); } -QHBox *KJanusWidget::addHBoxPage( const QStringList &items, +Q3HBox *KJanusWidget::addHBoxPage( const QStringList &items, const QString &header, const QPixmap &pixmap ) { @@ -340,14 +348,14 @@ QHBox *KJanusWidget::addHBoxPage( const QStringList &items, return( 0 ); } - QHBox *page = new QHBox(FindParent(), "hbox_page"); + Q3HBox *page = new Q3HBox(FindParent(), "hbox_page"); page->setSpacing( KDialog::spacingHint() ); addPageWidget( page, items, header, pixmap ); return page; } -QHBox *KJanusWidget::addHBoxPage( const QString &itemName, +Q3HBox *KJanusWidget::addHBoxPage( const QString &itemName, const QString &header, const QPixmap &pixmap ) { @@ -356,7 +364,7 @@ QHBox *KJanusWidget::addHBoxPage( const QString &itemName, return addHBoxPage(items, header, pixmap); } -QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir, +Q3Grid *KJanusWidget::addGridPage( int n, Qt::Orientation dir, const QStringList &items, const QString &header, const QPixmap &pixmap ) @@ -367,7 +375,7 @@ QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir, return( 0 ); } - QGrid *page = new QGrid( n, dir, FindParent(), "page" ); + Q3Grid *page = new Q3Grid( n, dir, FindParent(), "page" ); page->setSpacing( KDialog::spacingHint() ); addPageWidget( page, items, header, pixmap ); @@ -375,7 +383,7 @@ QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir, } -QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir, +Q3Grid *KJanusWidget::addGridPage( int n, Qt::Orientation dir, const QString &itemName, const QString &header, const QPixmap &pixmap ) @@ -385,10 +393,10 @@ QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir, return addGridPage(n, dir, items, header, pixmap); } -void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, QFrame *page) +void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, Q3Frame *page) { bool isTop = true; - QListViewItem *curTop = 0, *child, *last, *newChild; + Q3ListViewItem *curTop = 0, *child, *last, *newChild; unsigned int index = 1; QStringList curPath; @@ -412,9 +420,9 @@ void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &p // This node didn't have any children at all, lets just insert the // new child. if (isTop) - newChild = new QListViewItem(mTreeList, name); + newChild = new Q3ListViewItem(mTreeList, name); else - newChild = new QListViewItem(curTop, name); + newChild = new Q3ListViewItem(curTop, name); } else if (child != 0) { @@ -431,9 +439,9 @@ void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &p else { // the node had some children, but we didn't find the given name if (isTop) - newChild = new QListViewItem(mTreeList, last, name); + newChild = new Q3ListViewItem(mTreeList, last, name); else - newChild = new QListViewItem(curTop, last, name); + newChild = new Q3ListViewItem(curTop, last, name); } // Now make the element expandable if it is a path component, and make @@ -459,7 +467,7 @@ void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &p } } -void KJanusWidget::addPageWidget( QFrame *page, const QStringList &items, +void KJanusWidget::addPageWidget( Q3Frame *page, const QStringList &items, const QString &header,const QPixmap &pixmap ) { /*US the following signal causes a segmentation fault while closing the dialog. @@ -550,15 +558,15 @@ bool KJanusWidget::setSwallowedWidget( QWidget *widget ) { delete mSwallowPage->layout(); } - QGridLayout *gbox = new QGridLayout( mSwallowPage, 1, 1, 0 ); + Q3GridLayout *gbox = new Q3GridLayout( mSwallowPage, 1, 1, 0 ); // // Hide old children // - QObjectList *l = (QObjectList*)mSwallowPage->children(); // silence please - for( uint i=0; i < l->count(); i++ ) + QObjectList l = mSwallowPage->children(); // silence please + for( uint i=0; i < l.count(); i++ ) { - QObject *o = l->at(i); + QObject *o = l.at(i); if( o->isWidgetType() ) { ((QWidget*)o)->hide(); @@ -597,7 +605,7 @@ bool KJanusWidget::slotShowPage() if( mFace == TreeList ) { - QListViewItem *node = mTreeList->selectedItem(); + Q3ListViewItem *node = mTreeList->selectedItem(); if( node == 0 ) { return( false ); } QWidget *stackItem = mTreeListToPageStack[node]; @@ -606,7 +614,7 @@ bool KJanusWidget::slotShowPage() } else if( mFace == IconList ) { - QListBoxItem *node = mIconList->item( mIconList->currentItem() ); + Q3ListBoxItem *node = mIconList->item( mIconList->currentItem() ); if( node == 0 ) { return( false ); } QWidget *stackItem = mIconListToPageStack[node]; // Make sure to call through the virtual function showPage(int) @@ -646,9 +654,9 @@ bool KJanusWidget::showPage( QWidget *w ) mTitleLabel->setText( d->mIntToTitle[index] ); if( mFace == TreeList ) { - QMap::Iterator it; + QMap::Iterator it; for (it = mTreeListToPageStack.begin(); it != mTreeListToPageStack.end(); ++it){ - QListViewItem *key = it.key(); + Q3ListViewItem *key = it.key(); QWidget *val = it.data(); if (val == w) { mTreeList->setSelected(key, true ); @@ -658,9 +666,9 @@ bool KJanusWidget::showPage( QWidget *w ) } else { - QMap::Iterator it; + QMap::Iterator it; for (it = mIconListToPageStack.begin(); it != mIconListToPageStack.end(); ++it){ - QListBoxItem *key = it.key(); + Q3ListBoxItem *key = it.key(); QWidget *val = it.data(); if (val == w) { mIconList->setSelected( key, true ); @@ -686,13 +694,13 @@ bool KJanusWidget::showPage( QWidget *w ) int KJanusWidget::activePageIndex() const { if( mFace == TreeList) { - QListViewItem *node = mTreeList->selectedItem(); + Q3ListViewItem *node = mTreeList->selectedItem(); if( node == 0 ) { return -1; } QWidget *stackItem = mTreeListToPageStack[node]; return d->mPageToInt[stackItem]; } else if (mFace == IconList) { - QListBoxItem *node = mIconList->item( mIconList->currentItem() ); + Q3ListBoxItem *node = mIconList->item( mIconList->currentItem() ); if( node == 0 ) { return( false ); } QWidget *stackItem = mIconListToPageStack[node]; return d->mPageToInt[stackItem]; @@ -761,7 +769,7 @@ void KJanusWidget::slotFontChanged() */ // makes the treelist behave like the list of kcontrol -void KJanusWidget::slotItemClicked(QListViewItem *it) +void KJanusWidget::slotItemClicked(Q3ListViewItem *it) { if(it && (it->childCount()>0)) it->setOpen(!it->isOpen()); @@ -895,11 +903,11 @@ void KJanusWidget::unfoldTreeList( bool persist ) if( mFace == TreeList ) { if( persist ) - connect( mTreeList, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( slotReopen( QListViewItem * ) ) ); + connect( mTreeList, SIGNAL( collapsed( Q3ListViewItem * ) ), this, SLOT( slotReopen( Q3ListViewItem * ) ) ); else - disconnect( mTreeList, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( slotReopen( QListViewItem * ) ) ); + disconnect( mTreeList, SIGNAL( collapsed( Q3ListViewItem * ) ), this, SLOT( slotReopen( Q3ListViewItem * ) ) ); - for( QListViewItem * item = mTreeList->firstChild(); item; item = item->itemBelow() ) + for( Q3ListViewItem * item = mTreeList->firstChild(); item; item = item->itemBelow() ) item->setOpen( true ); } } @@ -953,7 +961,7 @@ bool KJanusWidget::eventFilter( QObject *o, QEvent *e ) KJanusWidget::IconListBox::IconListBox( QWidget *parent, const char *name, - WFlags f ) + Qt::WFlags f ) :KListBox( parent, name, f ), mShowAll(false), mHeightValid(false), mWidthValid(false) { @@ -965,7 +973,7 @@ void KJanusWidget::IconListBox::updateMinimumHeight() if( mShowAll == true && mHeightValid == false ) { int h = frameWidth()*2; - for( QListBoxItem *i = item(0); i != 0; i = i->next() ) + for( Q3ListBoxItem *i = item(0); i != 0; i = i->next() ) { h += i->height( this ); } @@ -980,13 +988,13 @@ void KJanusWidget::IconListBox::updateWidth() if( mWidthValid == false ) { int maxWidth = 10; - for( QListBoxItem *i = item(0); i != 0; i = i->next() ) + for( Q3ListBoxItem *i = item(0); i != 0; i = i->next() ) { int w = ((IconListItem *)i)->width(this); maxWidth = QMAX( w, maxWidth ); } - for( QListBoxItem *i = item(0); i != 0; i = i->next() ) + for( Q3ListBoxItem *i = item(0); i != 0; i = i->next() ) { ((IconListItem *)i)->expandMinimumWidth( maxWidth ); } @@ -1022,9 +1030,9 @@ void KJanusWidget::IconListBox::setShowAll( bool showAll ) -KJanusWidget::IconListItem::IconListItem( QListBox *listbox, const QPixmap &pixmap, +KJanusWidget::IconListItem::IconListItem( Q3ListBox *listbox, const QPixmap &pixmap, const QString &text ) - : QListBoxItem( listbox ) + : Q3ListBoxItem( listbox ) { mPixmap = pixmap; if( mPixmap.isNull() == true ) @@ -1083,7 +1091,7 @@ void KJanusWidget::IconListItem::paint( QPainter *painter ) } } -int KJanusWidget::IconListItem::height( const QListBox *lb ) const +int KJanusWidget::IconListItem::height( const Q3ListBox *lb ) const { if( text().isEmpty() == true ) { @@ -1096,7 +1104,7 @@ int KJanusWidget::IconListItem::height( const QListBox *lb ) const } -int KJanusWidget::IconListItem::width( const QListBox *lb ) const +int KJanusWidget::IconListItem::width( const Q3ListBox *lb ) const { int wt = lb->fontMetrics().boundingRect(text()).width()+10; int wp = mPixmap.width() + 10; @@ -1122,7 +1130,7 @@ void KJanusWidget::removePage( QWidget *page ) if ( mFace == TreeList ) { - QMap::Iterator i; + QMap::Iterator i; for( i = mTreeListToPageStack.begin(); i != mTreeListToPageStack.end(); ++i ) if (i.data()==page) { @@ -1137,7 +1145,7 @@ void KJanusWidget::removePage( QWidget *page ) } else if ( mFace == IconList ) { - QMap::Iterator i; + QMap::Iterator i; for( i = mIconListToPageStack.begin(); i != mIconListToPageStack.end(); ++i ) if (i.data()==page) { -- cgit v0.9.0.2