From 27122b489f03b9a9126af06312c7ae5a90d62f64 Mon Sep 17 00:00:00 2001 From: dmacvicar Date: Sun, 2 Dec 2007 23:37:13 +0000 Subject: [PATCH] one signal left and qmultiselectionbox compiles git-svn-id: http://svn.opensuse.org/svn/yast/branches/tmp/coolo/qt4-port@42578 e0cc52ee-31ee-0310-8b87-e83c4596d67c --- src/YQMultiSelectionBox.cc | 57 +++++++++++++++++++------------------- src/YQMultiSelectionBox.h | 9 +++--- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/YQMultiSelectionBox.cc b/src/YQMultiSelectionBox.cc index cbaf8c3..199a717 100644 --- a/src/YQMultiSelectionBox.cc +++ b/src/YQMultiSelectionBox.cc @@ -16,7 +16,7 @@ /-*/ -#define QT3_SUPPORT 1 +//#define QT3_SUPPORT 1 #include #include @@ -56,15 +56,15 @@ YQMultiSelectionBox::YQMultiSelectionBox( YWidget * parent, YUI_CHECK_NEW( _caption ); layout->addWidget( _caption ); - _qt_listView = new Q3ListView( this ); + _qt_listView = new QTreeWidget( this ); YUI_CHECK_NEW( _qt_listView ); layout->addWidget( _qt_listView ); _qt_listView->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); - _qt_listView->addColumn( "" ); // QListView doesn't have one single column by default! - _qt_listView->setSorting( 0, false ); - _qt_listView->header()->setStretchEnabled( true ); - _qt_listView->header()->hide(); + _qt_listView->setHeaderLabel(""); // QListView doesn't have one single column by default! + _qt_listView->sortItems( 0, Qt::AscendingOrder ); + //FIXME _qt_listView->header()->setStretchEnabled( true ); + //_qt_listView->header()->hide(); _caption->setBuddy( _qt_listView ); // Very small default size if specified @@ -97,21 +97,20 @@ YQMultiSelectionBox::addItem( YItem * yItem ) YQSignalBlocker sigBlocker( _qt_listView ); YMultiSelectionBox::addItem( yItem ); // will also check for NULL - YQMultiSelectionBoxItem * msbItem = - new YQMultiSelectionBoxItem( this, _qt_listView, yItem ); + YQMultiSelectionBoxItem * msbItem = new YQMultiSelectionBoxItem( this, _qt_listView, yItem ); YUI_CHECK_NEW( msbItem ); // Take care of the item's check box if ( yItem->selected() ) - msbItem->setOn( true ); + msbItem->setCheckState(0, Qt::Checked); // Take care of the QListView's keyboard focus - if ( ! _qt_listView->selectedItem() ) - _qt_listView->setSelected( msbItem, true ); + if ( ! _qt_listView->currentItem() ) + msbItem->setSelected(true); } @@ -121,7 +120,7 @@ void YQMultiSelectionBox::selectItem( YItem * yItem, bool selected ) YQMultiSelectionBoxItem * msbItem = findItem( yItem ); if ( msbItem ) - msbItem->setOn( selected ); + msbItem->setCheckState( 1, selected ? Qt::Checked : Qt::Unchecked ); } @@ -131,16 +130,16 @@ YQMultiSelectionBox::deselectAllItems() YQSignalBlocker sigBlocker( _qt_listView ); YMultiSelectionBox::deselectAllItems(); - Q3ListViewItemIterator it( _qt_listView ); + QTreeWidgetItemIterator it( _qt_listView ); while ( *it ) { - YQMultiSelectionBoxItem * item = dynamic_cast (*it); + YQMultiSelectionBoxItem * item = dynamic_cast (*it); - if ( item ) - item->setOn( false ); + if ( item ) + item->setCheckState(0, Qt::Checked); - ++it; + ++it; } } @@ -180,7 +179,7 @@ YQMultiSelectionBox::currentItem() // For the purpose of this function, QListView::currentItem() is the // minimum requirement. - Q3ListViewItem * currentQItem = _qt_listView->currentItem(); + QTreeWidgetItem * currentQItem = _qt_listView->currentItem(); if ( currentQItem ) { @@ -214,7 +213,7 @@ YQMultiSelectionBox::setCurrentItem( YItem * yItem ) YQMultiSelectionBoxItem * msbItem = findItem( yItem ); if ( msbItem ) - _qt_listView->setSelected( msbItem, true ); + msbItem->setSelected(true); // This does NOT change the item's check box! // (see explanations in YQMultiSelectionBox::currentItem() avove) @@ -227,15 +226,15 @@ YQMultiSelectionBox::setEnabled( bool enabled ) { _caption->setEnabled( enabled ); _qt_listView->setEnabled( enabled ); - _qt_listView->triggerUpdate(); + //_qt_listView->triggerUpdate(); YWidget::setEnabled( enabled ); } int YQMultiSelectionBox::preferredWidth() { - int hintWidth = _caption->isShown() ? - _caption->sizeHint().width() + frameWidth() : 0; + int hintWidth = (!_caption->isHidden()) ? + _caption->sizeHint().width() + frameWidth() : 0; return max( 80, hintWidth ); } @@ -243,7 +242,7 @@ int YQMultiSelectionBox::preferredWidth() int YQMultiSelectionBox::preferredHeight() { - int hintHeight = _caption->isShown() ? _caption->sizeHint().height() : 0; + int hintHeight = (!_caption->isHidden()) ? _caption->sizeHint().height() : 0; int visibleLines = shrinkable() ? SHRINKABLE_VISIBLE_LINES : DEFAULT_VISIBLE_LINES; hintHeight += visibleLines * _qt_listView->fontMetrics().lineSpacing(); hintHeight += _qt_listView->frameWidth() * 2; @@ -302,7 +301,7 @@ YQMultiSelectionBoxItem * YQMultiSelectionBox::findItem( YItem * wantedItem ) { // FIXME: Don't search through all items, use the YItem::data() pointer instead - Q3ListViewItemIterator it( _qt_listView ); + QTreeWidgetItemIterator it( _qt_listView ); while ( *it ) { @@ -326,24 +325,24 @@ int YQMultiSelectionBoxItem::_item_count = 0; YQMultiSelectionBoxItem::YQMultiSelectionBoxItem( YQMultiSelectionBox * parent, - Q3ListView * listView, + QTreeWidget * listView, YItem * yItem ) - : Q3CheckListItem( listView, fromUTF8( yItem->label() ), Q3CheckListItem::CheckBox ) + : QTreeWidgetItem( listView) , _yItem( yItem ) , _multiSelectionBox( parent ) { YUI_CHECK_PTR( yItem ); - + setText(0, fromUTF8( yItem->label() )); + setFlags(Qt::ItemIsUserCheckable); _serial = _item_count++; } - void YQMultiSelectionBoxItem::stateChange( bool newState ) { _yItem->setSelected( newState ); _multiSelectionBox->sendValueChanged(); - Q3CheckListItem::stateChange( newState ); + QTreeWidgetItem::stateChange( newState ); } diff --git a/src/YQMultiSelectionBox.h b/src/YQMultiSelectionBox.h index f117f50..e9aba8c 100644 --- a/src/YQMultiSelectionBox.h +++ b/src/YQMultiSelectionBox.h @@ -22,8 +22,7 @@ #include #include -#include -#include +#include #include "YMultiSelectionBox.h" @@ -164,19 +163,19 @@ protected: YQWidgetCaption * _caption; - Q3ListView * _qt_listView; + QTreeWidget * _qt_listView; }; -class YQMultiSelectionBoxItem: public Q3CheckListItem +class YQMultiSelectionBoxItem: public QTreeWidgetItem { public: /** * Constructor. **/ YQMultiSelectionBoxItem( YQMultiSelectionBox * parent, - Q3ListView * listView, + QTreeWidget * listView, YItem * yItem ); /** -- 2.39.2