From kde-commits Sun Mar 11 21:08:27 2007 From: Andreas Zehender Date: Sun, 11 Mar 2007 21:08:27 +0000 To: kde-commits Subject: KDE/kdegraphics/kpovmodeler Message-Id: <1173647307.509670.31516.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=117364732416972 SVN commit 641577 by azehende: -- Qt3Support fixed view layout selection M +4 -0 pmdialogeditbase.cpp M +2 -1 pmdialogeditbase.h M +15 -63 pmdialogview.cpp M +3 -8 pmdialogview.h M +6 -7 pmgridsettings.cpp M +5 -5 pminserterrordialog.cpp M +3 -5 pminserterrordialog.h M +21 -32 pmlayoutsettings.cpp M +2 -2 pmlayoutsettings.h M +1 -1 pmshell.cpp M +15 -2 pmviewlayoutmanager.cpp M +8 -0 pmviewlayoutmanager.h --- trunk/KDE/kdegraphics/kpovmodeler/pmdialogeditbase.cpp #641576:641577 @@ -569,4 +569,8 @@ m_pOutputWidget->show( ); } +QSize PMDialogEditBase::sizeHint() const { + return QWidget::minimumSizeHint(); +} + #include "pmdialogeditbase.moc" --- trunk/KDE/kdegraphics/kpovmodeler/pmdialogeditbase.h #641576:641577 @@ -3,7 +3,7 @@ ************************************************************************** description -------------------- - copyright : (C) 2000-2001 by Andreas Zehender + copyright : (C) 2000-2007 by Andreas Zehender email : zehender@kde.org ************************************************************************** @@ -265,6 +265,7 @@ static void saveConfig( KConfig* cfg ); static void restoreConfig( KConfig* cfg ); + virtual QSize sizeHint () const; protected: /** * Sets the help topic --- trunk/KDE/kdegraphics/kpovmodeler/pmdialogview.cpp #641576:641577 @@ -33,89 +33,42 @@ #include #include -#include -#include -#include -#include -#include -//Added by qt3to4: +#include +#include +#include +#include +#include +#include #include #include #include #include PMDialogEditContent::PMDialogEditContent( QWidget* parent ) - : Q3ScrollView( parent ) + : QScrollArea( parent ) { m_pContents = 0; - setVScrollBarMode( AlwaysOff ); - setHScrollBarMode( AlwaysOff ); + setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); + setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); setFrameStyle( Panel | Sunken ); setLineWidth( 1 ); - setResizePolicy( Manual ); + setWidgetResizable(true); } void PMDialogEditContent::setContents( QWidget* wid ) { if( m_pContents ) - removeChild( m_pContents ); + takeWidget(); m_pContents = wid; if( m_pContents ) { - addChild( m_pContents ); - calculateSize( ); + m_pContents->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) ); + setWidget( m_pContents ); } } -void PMDialogEditContent::calculateSize( ) -{ - int fw = lineWidth( ) * 2; - if( m_pContents ) - { - QSize newSize = m_pContents->minimumSizeHint( ); - - setVScrollBarMode( AlwaysOff ); - setHScrollBarMode( AlwaysOff ); - setMargins( 0, 0, 0, 0 ); - - if( width( ) - fw < newSize.width( ) ) - { - setHScrollBarMode( AlwaysOn ); - - if( ( height( ) - horizontalScrollBar( )->height( ) - fw ) - < newSize.height( ) ) - setVScrollBarMode( AlwaysOn ); - else - newSize.setHeight( height( ) - horizontalScrollBar( )->height( ) - 2 ); - } - else if( height( ) - fw < newSize.height( ) ) - { - setVScrollBarMode( AlwaysOn ); - - if( ( width( ) - verticalScrollBar( )->width( ) - fw ) - < newSize.width( ) ) - setHScrollBarMode( AlwaysOn ); - else - newSize.setWidth( width( ) - verticalScrollBar( )->width( ) - fw ); - } - else - { - newSize.setWidth( width( ) - fw ); - newSize.setHeight( height( ) - fw ); - } - - resizeContents( newSize.width( ), newSize.height( ) ); - m_pContents->resize( newSize ); - } -} - -void PMDialogEditContent::resizeEvent( QResizeEvent* /* ev */ ) -{ - calculateSize( ); -} - PMDialogView::PMDialogView( PMPart* part, QWidget* parent ) : PMViewBase( parent ) { @@ -326,7 +279,6 @@ if( m_pDisplayedWidget ) if( m_pDisplayedWidget->layout( ) ) m_pDisplayedWidget->layout( )->activate( ); - m_pHelper->calculateSize( ); } void PMDialogView::slotControlPointSelectionChanged( ) @@ -345,7 +297,7 @@ if( m_pDisplayedWidget ) old = m_pDisplayedWidget; - m_pDisplayedWidget = new PMDialogEditBase( m_pHelper->viewport( ) ); + m_pDisplayedWidget = new PMDialogEditBase( m_pHelper->widget( ) ); m_pDisplayedWidget->createWidgets( ); m_pHelper->setContents( m_pDisplayedWidget ); m_pPixmapLabel->setText( "" ); @@ -372,7 +324,7 @@ // first create the new widget, then delete the old one. if( m_pDisplayedWidget ) old = m_pDisplayedWidget; - m_pDisplayedWidget = obj->editWidget( m_pHelper->viewport( ) ); + m_pDisplayedWidget = obj->editWidget( m_pHelper->widget( ) ); m_pDisplayedWidget->setPart( m_pPart ); m_pDisplayedWidget->createWidgets( ); m_pHelper->setContents( m_pDisplayedWidget ); --- trunk/KDE/kdegraphics/kpovmodeler/pmdialogview.h #641576:641577 @@ -23,9 +23,7 @@ #include #endif -#include -#include -//Added by qt3to4: +#include #include #include #include @@ -38,22 +36,19 @@ class PMDialogEditBase; class PMObject; class PMPart; -class Q3GroupBox; +class QGroupBox; class QBoxLayout; class QLabel; /** * Helper class for @ref PMDialogView */ -class PMDialogEditContent : public Q3ScrollView +class PMDialogEditContent : public QScrollArea { Q_OBJECT public: PMDialogEditContent( QWidget* parent ); void setContents( QWidget* wid ); - void calculateSize( ); -protected: - void resizeEvent( QResizeEvent* ); private: QWidget* m_pContents; }; --- trunk/KDE/kdegraphics/kpovmodeler/pmgridsettings.cpp #641576:641577 @@ -22,10 +22,9 @@ #include "pmcontrolpoint.h" #include "pmdefaults.h" -#include -#include -#include -//Added by qt3to4: +#include +#include +#include #include #include #include @@ -39,12 +38,12 @@ QVBoxLayout* vlayout; QVBoxLayout* gvl; QGridLayout* grid; - Q3GroupBox* gb; + QGroupBox* gb; vlayout = new QVBoxLayout( this ); vlayout->setSpacing( KDialog::spacingHint( ) ); vlayout->setMargin( 0 ); - gb = new Q3GroupBox( i18n( "Displayed Grid" ), this ); + gb = new QGroupBox( i18n( "Displayed Grid" ), this ); vlayout->addWidget( gb ); gvl = new QVBoxLayout( gb ); gvl->setSpacing( KDialog::spacingHint( ) ); @@ -66,7 +65,7 @@ hlayout->addWidget( m_pGridDistance ); hlayout->addStretch( 1 ); - gb = new Q3GroupBox( i18n( "Control Point Grid" ), this ); + gb = new QGroupBox( i18n( "Control Point Grid" ), this ); vlayout->addWidget( gb ); gvl = new QVBoxLayout( gb ); gvl->setSpacing( KDialog::spacingHint( ) ); --- trunk/KDE/kdegraphics/kpovmodeler/pminserterrordialog.cpp #641576:641577 @@ -2,7 +2,7 @@ ************************************************************************** description -------------------- - copyright : (C) 2000-2001 by Andreas Zehender + copyright : (C) 2000-2007 by Andreas Zehender email : zehender@kde.org ************************************************************************** @@ -18,8 +18,8 @@ #include "pminserterrordialog.h" #include -#include -#include +#include +#include #include PMInsertErrorDialog::PMInsertErrorDialog( @@ -40,8 +40,8 @@ m_pDetailsLabel = new QLabel( i18n( "Objects not inserted:" ), page ); m_pDetailsLabel->hide( ); - m_pDetails = new Q3ListBox( page ); - m_pDetails->insertStringList( details, 0 ); + m_pDetails = new QListWidget( page ); + m_pDetails->addItems( details ); m_pDetails->setMinimumHeight( 150 ); m_pDetails->hide( ); connect(this,SIGNAL(user1Clicked()),this,SLOT(slotUser1( ))); --- trunk/KDE/kdegraphics/kpovmodeler/pminserterrordialog.h #641576:641577 @@ -3,7 +3,7 @@ ************************************************************************** description -------------------- - copyright : (C) 2000-2001 by Andreas Zehender + copyright : (C) 2000-2007 by Andreas Zehender email : zehender@kde.org ************************************************************************** @@ -26,10 +26,8 @@ #include #include -//Added by qt3to4: -#include -class Q3ListBox; +class QListWidget; class QLabel; /** @@ -49,7 +47,7 @@ void slotUser1( ); private: - Q3ListBox* m_pDetails; + QListWidget* m_pDetails; QLabel* m_pDetailsLabel; }; --- trunk/KDE/kdegraphics/kpovmodeler/pmlayoutsettings.cpp #641576:641577 @@ -23,12 +23,11 @@ #include #include -#include +#include #include #include #include -#include -//Added by qt3to4: +#include #include #include #include @@ -42,8 +41,8 @@ QVBoxLayout* vlayout; QVBoxLayout* gvl; QGridLayout* grid; - Q3GroupBox* gb; - Q3GroupBox* gbe; + QGroupBox* gb; + QGroupBox* gbe; QHBoxLayout* ghe; QVBoxLayout* gvle; @@ -58,7 +57,7 @@ hlayout->addWidget( m_pDefaultLayout, 1 ); hlayout->addStretch( 1 ); - gb = new Q3GroupBox( i18n( "Available View Layouts" ), this ); + gb = new QGroupBox( i18n( "Available View Layouts" ), this ); vlayout->addWidget( gb ); gvl = new QVBoxLayout( gb ); gvl->setSpacing( KDialog::spacingHint( ) ); @@ -67,8 +66,8 @@ grid = new QGridLayout( ); gvl->addLayout( grid ); - m_pViewLayouts = new Q3ListBox( gb ); - connect( m_pViewLayouts, SIGNAL( highlighted( int ) ), + m_pViewLayouts = new QListWidget( gb ); + connect( m_pViewLayouts, SIGNAL( currentRowChanged( int ) ), SLOT( slotLayoutSelected( int ) ) ); grid->addWidget( m_pViewLayouts, 0, 0, 3, 1 ); m_pAddLayout = new QPushButton( i18n( "Add" ), gb ); @@ -79,7 +78,7 @@ grid->addWidget( m_pRemoveLayout, 1, 1 ); grid->setRowStretch( 2, 1 ); - gbe = new Q3GroupBox( i18n( "View Layout" ), gb ); + gbe = new QGroupBox( i18n( "View Layout" ), gb ); gvl->addWidget( gbe ); gvle = new QVBoxLayout( gbe ); gvle->setSpacing( KDialog::spacingHint( ) ); @@ -207,8 +206,8 @@ ( *m_defaultViewLayout ).name( ) != m->defaultLayout( ); ++m_defaultViewLayout ); displayLayoutList( ); - m_pViewLayouts->setCurrentItem( 0 ); - if( m_pViewLayouts->numRows( ) == 1 ) + m_pViewLayouts->setCurrentRow( 0 ); + if( m_pViewLayouts->count( ) == 1 ) m_pRemoveLayout->setEnabled( false ); } @@ -261,7 +260,7 @@ m_pDefaultLayout->clear( ); for( it = m_viewLayouts.begin( ); it != m_viewLayouts.end( ); ++it ) { - m_pViewLayouts->insertItem( ( *it ).name( ) ); + m_pViewLayouts->addItem( ( *it ).name( ) ); m_pDefaultLayout->addItem( ( *it ).name( ) ); if( it == m_defaultViewLayout ) m_pDefaultLayout->setCurrentIndex( m_pDefaultLayout->findText( ( *it ).name( ) ) ); @@ -271,17 +270,10 @@ void PMLayoutSettings::slotAddLayout( ) { QString new_name; - int i = 1; - QString str; - + new_name = i18n( "Unnamed" ); - str.setNum( i ); - while( m_pViewLayouts->findItem( new_name, Q3ListBox::ExactMatch ) ) - { - new_name = i18n( "Unnamed" ) + str; - i++; - str.setNum( i ); - } + QList items = m_pViewLayouts->findItems( new_name, Qt::MatchStartsWith ); + if(items.count() > 0) new_name = i18n( "Unnamed" ) + QString::number(items.count() + 1); PMViewLayout l; l.setName( new_name ); @@ -289,7 +281,7 @@ m_currentViewLayout++; m_viewLayouts.insert( m_currentViewLayout, l ); displayLayoutList( ); - m_pViewLayouts->setCurrentItem( m_pViewLayouts->findItem( new_name, Q3ListBox::ExactMatch ) ); + m_pViewLayouts->setCurrentRow( m_pViewLayouts->count() - 1 ); m_pRemoveLayout->setEnabled( true ); } @@ -306,9 +298,9 @@ } m_viewLayouts.erase( m_currentViewLayout ); displayLayoutList( ); - m_pViewLayouts->setCurrentItem( 0 ); + m_pViewLayouts->setCurrentRow( 0 ); - if( m_pViewLayouts->numRows( ) == 1 ) + if( m_pViewLayouts->count() == 1 ) m_pRemoveLayout->setEnabled( false ); } @@ -318,6 +310,8 @@ QString str; bool sb; + if(index < 0) return; + m_currentViewLayout = m_viewLayouts.begin() + index; m_currentViewEntry = ( *m_currentViewLayout ).begin( ); @@ -346,13 +340,8 @@ void PMLayoutSettings::slotLayoutNameChanged( const QString& text ) { - int n_item = m_pViewLayouts->currentItem( ); - bool sb = m_pViewLayouts->signalsBlocked( ); - m_pViewLayouts->blockSignals( true ); - m_pViewLayouts->removeItem( n_item ); - m_pViewLayouts->insertItem( text, n_item ); - m_pViewLayouts->setCurrentItem( n_item ); - m_pViewLayouts->blockSignals( sb ); + QListWidgetItem* item = m_pViewLayouts->currentItem(); + if(item) item->setText(text); ( *m_currentViewLayout ).setName( text ); --- trunk/KDE/kdegraphics/kpovmodeler/pmlayoutsettings.h #641576:641577 @@ -33,7 +33,7 @@ class PMIntEdit; class PMViewOptionsWidget; class QComboBox; -class Q3ListBox; +class QListWidget; class QPushButton; class QLabel; @@ -140,7 +140,7 @@ void displayCustomOptions( ); QComboBox* m_pDefaultLayout; - Q3ListBox* m_pViewLayouts; + QListWidget* m_pViewLayouts; QPushButton* m_pAddLayout; QPushButton* m_pRemoveLayout; QLineEdit* m_pViewLayoutName; --- trunk/KDE/kdegraphics/kpovmodeler/pmshell.cpp #641576:641577 @@ -661,7 +661,7 @@ void PMShell::slotSelectedLayout( QAction* action ) { - PMViewLayoutManager::theManager( )->displayLayout( action->text( ), this ); + PMViewLayoutManager::theManager( )->displayLayout( action->data( ).toInt( ), this ); } void PMShell::slotSaveViewLayout( ) --- trunk/KDE/kdegraphics/kpovmodeler/pmviewlayoutmanager.cpp #641576:641577 @@ -786,7 +786,15 @@ void PMViewLayoutManager::displayLayout( const QString& name, PMShell* shell ) { PMViewLayout* v_layout = findLayout( name ); + if( v_layout ) displayLayout( v_layout, shell ); +} +void PMViewLayoutManager::displayLayout( int i, PMShell* shell ) +{ + if(i >= 0 && m_layouts.count() > i) displayLayout( &m_layouts[i], shell ); +} + +void PMViewLayoutManager::displayLayout( PMViewLayout* v_layout, PMShell* shell ){ if( v_layout ) { // Destroy the existing dock widgets @@ -796,7 +804,7 @@ if( shell->centralWidget( ) ) shell->manager( )->findChildDockWidget( shell->centralWidget( ), lst ); - while( lst->first( ) ) + while( lst->count( ) > 0 ) { ( ( PMDockWidget* )lst->first( ) )->undock( ); ( ( PMDockWidget* )lst->first( ) )->close( ); @@ -839,12 +847,17 @@ { QStringList lst = availableLayouts( ); QStringList::ConstIterator it = lst.begin( ); + int i = 0; pMenu->clear( ); if( it != lst.end( ) ) { for( ; it != lst.end( ); ++it ) - pMenu->addAction( ( *it ) ); + { + QAction* act = pMenu->addAction( ( *it ) ); + act->setData( i ); + i++; + } } } --- trunk/KDE/kdegraphics/kpovmodeler/pmviewlayoutmanager.h #641576:641577 @@ -229,6 +229,10 @@ */ void displayLayout( const QString& name, PMShell* shell ); /** + * Destroy all dock widgets in PMShell and create the new ones + */ + void displayLayout( int i, PMShell* shell ); + /** * Displays the layout indicated as default */ void displayDefaultLayout( PMShell* shell ); @@ -273,6 +277,10 @@ * Constructor */ PMViewLayoutManager( ); + /** + * Destroy all dock widgets in PMShell and create the new ones + */ + void displayLayout( PMViewLayout* layout, PMShell* shell ); bool m_layoutsLoaded; bool m_layoutDisplayed;