summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/kjanuswidget.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kdeui/kjanuswidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kjanuswidget.cpp140
1 files changed, 74 insertions, 66 deletions
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
@@ -19,21 +19,29 @@
*/
#include <qpixmap.h>
#include <qbitmap.h>
#include <qlayout.h>
#include <qlabel.h>
-#include <qwidgetstack.h>
+#include <q3widgetstack.h>
#include <qtabwidget.h>
-#include <qlistview.h>
-#include <qhbox.h>
-#include <qvbox.h>
-#include <qgrid.h>
+#include <q3listview.h>
+#include <q3hbox.h>
+#include <q3vbox.h>
+#include <q3grid.h>
#include <qpainter.h>
-#include <qobjectlist.h>
+#include <qobject.h>
#include <qstringlist.h>
+//Added by qt3to4:
+#include <Q3HBoxLayout>
+#include <Q3GridLayout>
+#include <Q3PtrList>
+#include <Q3Frame>
+#include <QEvent>
+#include <Q3VBoxLayout>
+#include <QShowEvent>
/*US
#include <qbitmap.h>
#include <qgrid.h>
#include <qhbox.h>
#include <qheader.h>
#include <qlabel.h>
@@ -62,19 +70,19 @@
#include <kdialog.h> // Access to some static members
#include <kdebug.h>
#include <klistview.h>
#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:
const QPixmap &defaultPixmap();
void paint( QPainter *painter );
@@ -95,27 +103,27 @@ public:
// Reverse dictionary. Used because showPage() may be performance critical.
QMap<QWidget*,int> mPageToInt;
// Dictionary of title string associated with page.
QMap<int, QString> mIntToTitle;
};
-template class QPtrList<QListViewItem>;
+template class Q3PtrList<Q3ListViewItem>;
KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face )
: QWidget( parent, name ),
mValid(false), mPageList(0),
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
qDebug("KJanusWidget::KJanusWidget TreeList not implemented yet");
/*US
QSplitter *splitter = new QSplitter( this );
@@ -142,46 +150,46 @@ KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face )
page = new QFrame( p );
hbox->addWidget( page, 10 );
*/
}
else
{
- QHBoxLayout *hbox = new QHBoxLayout( topLayout );
+ Q3HBoxLayout *hbox = new Q3HBoxLayout( topLayout );
mIconList = new IconListBox( this );
QFont listFont( mIconList->font() );
listFont.setBold( true );
mIconList->setFont( listFont );
mIconList->verticalScrollBar()->installEventFilter( this );
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 );
}
//
// Rest of page area. Title at top with a separator below and a
// 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 );
QFont titleFont( mTitleLabel->font() );
titleFont.setBold( true );
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 );
}
else if( mFace == Tabbed )
{
@@ -196,13 +204,13 @@ KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face )
mSwallowPage = new QWidget( this );
topLayout->addWidget( mSwallowPage, 10 );
}
else
{
mFace = Plain;
- mPlainPage = new QFrame( this );
+ mPlainPage = new Q3Frame( this );
topLayout->addWidget( mPlainPage, 10 );
}
/*US
if ( kapp )
connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged()));
*/
@@ -242,13 +250,13 @@ KJanusWidget::~KJanusWidget()
bool KJanusWidget::isValid() const
{
return( mValid );
}
-QFrame *KJanusWidget::plainPage()
+Q3Frame *KJanusWidget::plainPage()
{
return( mPlainPage );
}
int KJanusWidget::face() const
@@ -263,135 +271,135 @@ QWidget *KJanusWidget::FindParent()
}
else {
return this;
}
}
-QFrame *KJanusWidget::addPage( const QStringList &items, const QString &header,
+Q3Frame *KJanusWidget::addPage( const QStringList &items, const QString &header,
const QPixmap &pixmap )
{
if( mValid == false )
{
kdDebug() << "addPage: Invalid object" << endl;
return( 0 );
}
- QFrame *page = new QFrame( FindParent(), "page" );
+ Q3Frame *page = new Q3Frame( FindParent(), "page" );
addPageWidget( page, items, header, pixmap );
return page;
}
void KJanusWidget::pageGone( QObject *obj )
{
// QObject* obj = (QObject*)sender();
removePage( static_cast<QWidget*>( 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 )
{
QStringList items;
items << itemName;
return addPage(items, header, pixmap);
}
-QVBox *KJanusWidget::addVBoxPage( const QStringList &items,
+Q3VBox *KJanusWidget::addVBoxPage( const QStringList &items,
const QString &header,
const QPixmap &pixmap )
{
if( mValid == false )
{
qDebug("addPage: Invalid object ");
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 )
{
QStringList items;
items << itemName;
return addVBoxPage(items, header, pixmap);
}
-QHBox *KJanusWidget::addHBoxPage( const QStringList &items,
+Q3HBox *KJanusWidget::addHBoxPage( const QStringList &items,
const QString &header,
const QPixmap &pixmap )
{
if( mValid == false ) {
kdDebug() << "addPage: Invalid object" << endl;
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 )
{
QStringList items;
items << 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 )
{
if( mValid == false )
{
kdDebug() << "addPage: Invalid object" << endl;
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 );
return page;
}
-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 )
{
QStringList items;
items << itemName;
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;
for ( QStringList::ConstIterator it = items.begin(); it != items.end(); ++it, index++ ) {
QString name = (*it);
bool isPath = ( index != items.count() );
@@ -409,15 +417,15 @@ void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &p
for (last = 0; child && child->text(0) != name ; last = child, child = child->nextSibling());
if (last == 0 && child == 0) {
// 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) {
// we found the given name in this child.
if (!isPath) {
kdDebug() << "The element inserted was already in the TreeList box!" << endl;
@@ -428,15 +436,15 @@ void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &p
newChild = child;
}
}
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
// ready for next loop
if (isPath) {
newChild->setExpandable(true);
@@ -456,13 +464,13 @@ void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &p
}
mTreeListToPageStack.insert(newChild, page);
}
}
}
-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.
Why not just remove all pages in the destructor??
*/
//US connect(page, SIGNAL(destroyed(QObject*)), this, SLOT(pageGone(QObject*)));
@@ -547,21 +555,21 @@ bool KJanusWidget::setSwallowedWidget( QWidget *widget )
// Remove current layout and make a new.
//
if( mSwallowPage->layout() != 0 )
{
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();
}
}
@@ -594,22 +602,22 @@ bool KJanusWidget::slotShowPage()
{
return( false );
}
if( mFace == TreeList )
{
- QListViewItem *node = mTreeList->selectedItem();
+ Q3ListViewItem *node = mTreeList->selectedItem();
if( node == 0 ) { return( false ); }
QWidget *stackItem = mTreeListToPageStack[node];
// Make sure to call through the virtual function showPage(int)
return showPage(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];
// Make sure to call through the virtual function showPage(int)
return showPage(d->mPageToInt[stackItem]);
}
@@ -643,27 +651,27 @@ bool KJanusWidget::showPage( QWidget *w )
mActivePageWidget = w;
int index = d->mPageToInt[w];
mTitleLabel->setText( d->mIntToTitle[index] );
if( mFace == TreeList )
{
- QMap<QListViewItem *, QWidget *>::Iterator it;
+ QMap<Q3ListViewItem *, QWidget *>::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 );
break;
}
}
}
else
{
- QMap<QListBoxItem *, QWidget *>::Iterator it;
+ QMap<Q3ListBoxItem *, QWidget *>::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 );
break;
}
}
@@ -683,19 +691,19 @@ 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];
}
else if( mFace == Tabbed ) {
QWidget *widget = mTabControl->currentPage();
@@ -758,13 +766,13 @@ void KJanusWidget::slotFontChanged()
mIconList->invalidateWidth();
}
}
*/
// 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());
}
void KJanusWidget::setFocus()
@@ -892,17 +900,17 @@ void KJanusWidget::setRootIsDecorated( bool state )
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 );
}
}
void KJanusWidget::showEvent( QShowEvent * )
{
@@ -950,25 +958,25 @@ bool KJanusWidget::eventFilter( QObject *o, QEvent *e )
//
// Code for the icon list box
//
KJanusWidget::IconListBox::IconListBox( QWidget *parent, const char *name,
- WFlags f )
+ Qt::WFlags f )
:KListBox( parent, name, f ), mShowAll(false), mHeightValid(false),
mWidthValid(false)
{
}
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 );
}
setMinimumHeight( h );
mHeightValid = true;
}
@@ -977,19 +985,19 @@ void KJanusWidget::IconListBox::updateMinimumHeight()
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 );
}
if( verticalScrollBar()->isVisible() )
{
@@ -1019,15 +1027,15 @@ void KJanusWidget::IconListBox::setShowAll( bool showAll )
mShowAll = showAll;
mHeightValid = false;
}
-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 )
{
mPixmap = defaultPixmap();
}
@@ -1080,26 +1088,26 @@ void KJanusWidget::IconListItem::paint( QPainter *painter )
if( text().isEmpty() == false )
{
painter->drawText( 0, hp+7, mMinimumWidth, ht, Qt::AlignCenter, text() );
}
}
-int KJanusWidget::IconListItem::height( const QListBox *lb ) const
+int KJanusWidget::IconListItem::height( const Q3ListBox *lb ) const
{
if( text().isEmpty() == true )
{
return( mPixmap.height() );
}
else
{
return( mPixmap.height() + lb->fontMetrics().lineSpacing()+10 );
}
}
-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;
int w = QMAX( wt, wp );
return( QMAX( w, mMinimumWidth ) );
}
@@ -1119,13 +1127,13 @@ void KJanusWidget::removePage( QWidget *page )
}
int index = d->mPageToInt[page];
if ( mFace == TreeList )
{
- QMap<QListViewItem*, QWidget *>::Iterator i;
+ QMap<Q3ListViewItem*, QWidget *>::Iterator i;
for( i = mTreeListToPageStack.begin(); i != mTreeListToPageStack.end(); ++i )
if (i.data()==page)
{
delete i.key();
mPageStack->removeWidget(page);
mTreeListToPageStack.remove(i);
@@ -1134,13 +1142,13 @@ void KJanusWidget::removePage( QWidget *page )
d->mIntToPage.remove(index);
break;
}
}
else if ( mFace == IconList )
{
- QMap<QListBoxItem*, QWidget *>::Iterator i;
+ QMap<Q3ListBoxItem*, QWidget *>::Iterator i;
for( i = mIconListToPageStack.begin(); i != mIconListToPageStack.end(); ++i )
if (i.data()==page)
{
delete i.key();
mPageStack->removeWidget(page);
mIconListToPageStack.remove(i);