Author: dmacvicar
Date: Mon Dec 3 00:37:34 2007
New Revision: 42584
URL: http://svn.opensuse.org/viewcvs/yast?rev=42584&view=rev
Log:
YQSelectionBox
Modified:
branches/tmp/coolo/qt4-port/src/YQSelectionBox.cc
branches/tmp/coolo/qt4-port/src/YQSelectionBox.h
Modified: branches/tmp/coolo/qt4-port/src/YQSelectionBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/coolo/qt4-port/src/YQSelectionBox.cc?rev=42584&r1=42583&r2=42584&view=diff
==============================================================================
--- branches/tmp/coolo/qt4-port/src/YQSelectionBox.cc (original)
+++ branches/tmp/coolo/qt4-port/src/YQSelectionBox.cc Mon Dec 3 00:37:34 2007
@@ -16,17 +16,12 @@
/-*/
-#define QT3_SUPPORT
-
-#include
-#include
-#include
+#include <QString>
+#include <QLabel>
+#include <QListWidget>
#include
-//Added by qt3to4:
-#include
-#include
-#include
-#include
+#include <QPixmap>
+#include <QEvent>
#include <QVBoxLayout>
#define y2log_component "qt-ui"
#include
@@ -64,22 +59,22 @@
YUI_CHECK_NEW( _caption );
layout->addWidget( _caption );
- _qt_listBox = new Q3ListBox( this );
+ _qt_listBox = new QListWidget( this );
YUI_CHECK_NEW( _qt_listBox );
layout->addWidget( _qt_listBox );
_qt_listBox->installEventFilter( this );
- _qt_listBox->setVariableHeight( false );
+ //FIXME _qt_listBox->setVariableHeight( false );
_qt_listBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,
QSizePolicy::Expanding ) );
- _qt_listBox->setTopItem(0);
+ //FIXME _qt_listBox->setTopItem(0);
_caption->setBuddy( _qt_listBox );
connect( _qt_listBox, SIGNAL( highlighted ( int ) ),
this, SLOT ( slotSelected( int ) ) );
- connect( _qt_listBox, SIGNAL( doubleClicked( Q3ListBoxItem * ) ),
- this, SLOT ( slotActivated( Q3ListBoxItem * ) ) );
+ connect( _qt_listBox, SIGNAL( doubleClicked( QListWidgetItem * ) ),
+ this, SLOT ( slotActivated( QListWidgetItem * ) ) );
connect( &_timer, SIGNAL( timeout() ),
this, SLOT ( returnImmediately() ) );
@@ -114,14 +109,21 @@
}
if ( icon.isNull() )
- _qt_listBox->insertItem( fromUTF8( item->label() ) );
+ {
+ _qt_listBox->addItem( fromUTF8( item->label() ) );
+ }
else
- _qt_listBox->insertItem( icon, fromUTF8( item->label() ) );
+ {
+ QListWidgetItem *i = new QListWidgetItem(_qt_listBox);
+ i->setData(Qt::DisplayRole, fromUTF8( item->label() ) );
+ i->setData(Qt::DecorationRole, icon );
+ _qt_listBox->addItem( i );
+ }
if ( item->selected() )
{
YQSignalBlocker sigBlocker( _qt_listBox );
- _qt_listBox->setCurrentItem( item->index() );
+ _qt_listBox->setCurrentItem( _qt_listBox->item( item->index() ) );
}
}
@@ -131,7 +133,7 @@
YQSignalBlocker sigBlocker( _qt_listBox );
YSelectionBox::selectItem( item, selected );
- _qt_listBox->setCurrentItem( selected ? item->index() : -1 );
+ _qt_listBox->setCurrentRow( selected ? item->index() : -1 );
}
@@ -161,7 +163,7 @@
YSelectionBox::deselectAllItems();
_qt_listBox->clearSelection();
- if ( _qt_listBox->currentItem() > -1 )
+ if ( _qt_listBox->currentRow() > -1 )
{
// Some item is selected after all; the Qt documtation says this
// happens if the QListBox is in single selection mode (which it is)
@@ -171,7 +173,7 @@
// displays. This has a small performance penalty because it calls
// YSelectionBox::deselectAllItems() again which again iterates over
// all items.
- selectItem( _qt_listBox->currentItem() );
+ selectItem( _qt_listBox->row(_qt_listBox->currentItem()) );
}
}
@@ -216,7 +218,7 @@
{
_caption->setEnabled( enabled );
_qt_listBox->setEnabled( enabled );
- _qt_listBox->triggerUpdate( true );
+ //FIXME needed? _qt_listBox->triggerUpdate( true );
YWidget::setEnabled( enabled );
}
@@ -236,7 +238,7 @@
QKeyEvent * event = ( QKeyEvent * ) ev;
if ( ( event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter ) &&
- ( event->state() == 0 || event->state() == Qt::Keypad ) )
+ ( (event->modifiers() & Qt::NoModifier) || (event->modifiers() & Qt::KeypadModifier) ) )
{
YQDialog * dia = (YQDialog *) findDialog();
@@ -292,9 +294,9 @@
}
-void YQSelectionBox::slotActivated( Q3ListBoxItem * qItem )
+void YQSelectionBox::slotActivated( QListWidgetItem * qItem )
{
- selectItem( _qt_listBox->index( qItem ) );
+ selectItem( _qt_listBox->row( qItem ) );
if ( notify() )
YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::Activated ) );
Modified: branches/tmp/coolo/qt4-port/src/YQSelectionBox.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/coolo/qt4-port/src/YQSelectionBox.h?rev=42584&r1=42583&r2=42584&view=diff
==============================================================================
--- branches/tmp/coolo/qt4-port/src/YQSelectionBox.h (original)
+++ branches/tmp/coolo/qt4-port/src/YQSelectionBox.h Mon Dec 3 00:37:34 2007
@@ -21,13 +21,13 @@
#define YQSelectionBox_h
#include <QFrame>
-#include
+#include <QTimer>
#include "YSelectionBox.h"
class YQWidgetCaption;
-class Q3ListBox;
-class Q3ListBoxItem;
+class QListWidget;
+class QListWidgetItem;
class YQSelectionBox : public QFrame, public YSelectionBox
@@ -135,7 +135,7 @@
/**
* Notification that an item has been activated (double clicked).
**/
- void slotActivated( Q3ListBoxItem * item );
+ void slotActivated( QListWidgetItem * item );
/**
* Return after some millseconds delay - collect multiple events.
@@ -163,7 +163,7 @@
//
YQWidgetCaption * _caption;
- Q3ListBox * _qt_listBox;
+ QListWidget * _qt_listBox;
QTimer _timer;
};
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org