From 5c6ab233652ba2bcb116269d60711753e4d4cc8b Mon Sep 17 00:00:00 2001 From: kh1 Date: Tue, 24 May 2011 23:15:05 +0200 Subject: Make it compile again. Still does not work. --- examples/testapp/componentselectiondialog.cpp | 32 +++++++------- examples/testapp/componentselectiondialog.h | 25 +++++------ examples/testapp/componentselectiondialog.ui | 8 ++-- examples/testapp/mainwindow.cpp | 60 +++++++++++++++------------ examples/testapp/mainwindow.h | 3 +- examples/testapp/testapp.pro | 5 ++- installerfw.pro | 2 +- 7 files changed, 71 insertions(+), 64 deletions(-) diff --git a/examples/testapp/componentselectiondialog.cpp b/examples/testapp/componentselectiondialog.cpp index a45524ee0..35b5e9ceb 100644 --- a/examples/testapp/componentselectiondialog.cpp +++ b/examples/testapp/componentselectiondialog.cpp @@ -36,9 +36,9 @@ #include #include -#include "qinstaller.h" -#include "qinstallercomponent.h" -#include "qinstallercomponentmodel.h" +#include +#include +#include using namespace QInstaller; @@ -59,7 +59,7 @@ public: int selectionCount = 0; for( QList< Component* >::const_iterator it = components.begin(); it != components.end(); ++it ) { - if( (*it)->isSelected( UpdaterMode ) ) + if( (*it)->isSelected() ) ++selectionCount; } @@ -118,7 +118,7 @@ void ComponentSelectionDialog::Private::selectAll() QList< Component* > updaterComponents = installer->components( false, UpdaterMode ); Q_FOREACH( Component* comp, updaterComponents ) { - comp->setSelected( true, UpdaterMode ); + comp->setSelected( true ); } } @@ -127,21 +127,17 @@ void ComponentSelectionDialog::Private::deselectAll() QList< Component* > updaterComponents = installer->components( false, UpdaterMode ); Q_FOREACH( Component* comp, updaterComponents ) { - comp->setSelected( false, UpdaterMode ); + comp->setSelected( false ); } } -void ComponentSelectionDialog::refreshDialog() -{ - d->selectionChanged(); -} ComponentSelectionDialog::ComponentSelectionDialog( Installer* installer, QWidget* parent ) : QDialog( parent ), d( new Private( this, installer ) ) { d->ui.setupUi( this ); - d->componentModel = new ComponentModel( installer, UpdaterMode ); + d->componentModel = new ComponentModel( 5, installer ); d->ui.treeView->setModel( d->componentModel ); d->ui.labelLicenseBlurb->setAttribute( Qt::WA_MacSmallSize ); @@ -162,8 +158,8 @@ ComponentSelectionDialog::ComponentSelectionDialog( Installer* installer, QWidge connect( d->ui.treeView->selectionModel(), SIGNAL( currentChanged( QModelIndex, QModelIndex ) ), this, SLOT( selectionChanged() ) ); connect( d->installBtn, SIGNAL( clicked() ), this, SIGNAL( requestUpdate() ) ); - connect( d->ui.selectAll, SIGNAL( clicked() ), d.get(), SLOT( selectAll() ), Qt::QueuedConnection ); - connect( d->ui.deselectAll, SIGNAL( clicked() ), d.get(), SLOT( deselectAll() ), Qt::QueuedConnection ); + connect( d->ui.selectAll, SIGNAL( clicked() ), d, SLOT( selectAll() ), Qt::QueuedConnection ); + connect( d->ui.deselectAll, SIGNAL( clicked() ), d, SLOT( deselectAll() ), Qt::QueuedConnection ); d->ui.treeView->setCurrentIndex( d->ui.treeView->model()->index( 0, 0 ) ); @@ -178,6 +174,7 @@ ComponentSelectionDialog::ComponentSelectionDialog( Installer* installer, QWidge ComponentSelectionDialog::~ComponentSelectionDialog() { + delete d; } void ComponentSelectionDialog::selectAll() { @@ -193,18 +190,23 @@ void ComponentSelectionDialog::install() { } void ComponentSelectionDialog::selectComponent( const QString& id ) { - const QModelIndex idx = d->componentModel->findComponent( id ); + const QModelIndex idx = d->componentModel->indexFromComponentName( id ); if ( !idx.isValid() ) return; d->componentModel->setData( idx, Qt::Checked ); } void ComponentSelectionDialog::deselectComponent( const QString& id ) { - const QModelIndex idx = d->componentModel->findComponent( id ); + const QModelIndex idx = d->componentModel->indexFromComponentName( id ); if ( !idx.isValid() ) return; d->componentModel->setData( idx, Qt::Unchecked ); } +void ComponentSelectionDialog::refreshDialog() +{ + d->selectionChanged(); +} + #include "moc_componentselectiondialog.cpp" #include "componentselectiondialog.moc" diff --git a/examples/testapp/componentselectiondialog.h b/examples/testapp/componentselectiondialog.h index 0b67084c6..f75a62c7b 100644 --- a/examples/testapp/componentselectiondialog.h +++ b/examples/testapp/componentselectiondialog.h @@ -28,20 +28,17 @@ #include -#include - -#include "installer_global.h" - -namespace QInstaller -{ -class Installer; +namespace QInstaller { + class Installer; +} -class INSTALLER_EXPORT ComponentSelectionDialog : public QDialog +class ComponentSelectionDialog : public QDialog { Q_OBJECT + public: explicit ComponentSelectionDialog( QInstaller::Installer* installer, QWidget* parent = 0 ); - ~ComponentSelectionDialog(); + virtual ~ComponentSelectionDialog(); Q_INVOKABLE void selectComponent( const QString& compoenent ); Q_INVOKABLE void deselectComponent( const QString& component ); Q_INVOKABLE void selectAll(); @@ -55,13 +52,11 @@ Q_SIGNALS: void requestUpdate(); private: - Q_PRIVATE_SLOT( d, void selectionChanged() ); - Q_PRIVATE_SLOT( d, void modelReset() ); - class Private; - kdtools::pimpl_ptr< Private > d; -}; + Private *d; -} + Q_PRIVATE_SLOT( d, void selectionChanged() ) + Q_PRIVATE_SLOT( d, void modelReset() ) +}; #endif diff --git a/examples/testapp/componentselectiondialog.ui b/examples/testapp/componentselectiondialog.ui index a161612ac..2fde9722e 100644 --- a/examples/testapp/componentselectiondialog.ui +++ b/examples/testapp/componentselectiondialog.ui @@ -7,7 +7,7 @@ 0 0 656 - 406 + 408 @@ -25,7 +25,7 @@ - :/logo.png + :/logo.png false @@ -160,7 +160,9 @@ - + + + buttonBox diff --git a/examples/testapp/mainwindow.cpp b/examples/testapp/mainwindow.cpp index 25b64e90a..46b2423f7 100644 --- a/examples/testapp/mainwindow.cpp +++ b/examples/testapp/mainwindow.cpp @@ -51,23 +51,27 @@ #include #include -#include "common/binaryformatenginehandler.h" -#include "common/binaryformat.h" +#include +#include #include "componentselectiondialog.h" -#include "getrepositorymetainfojob.h" -#include "common/errors.h" -#include "common/fileutils.h" -#include "init.h" -#include "updateagent.h" +#include +#include +#include +#include +//#include "updateagent.h" -#include "updatesettings.h" -#include "updatesettingsdialog.h" +#include +//#include "updatesettingsdialog.h" using namespace QInstaller; -MainWindow::MainWindow( const QStringList& args, QWidget* parent ) : QMainWindow( parent ) { +MainWindow::MainWindow( const QStringList& args, QWidget* parent ) + : QMainWindow( parent ) + , m_installer(new Installer(QInstaller::MagicUpdaterMarker)) +{ QInstaller::init(); + m_installer->setUpdaterApplication(&updaterapp); QMenuBar* mbar = menuBar(); QMenu* fm = mbar->addMenu( QObject::tr("File") ); @@ -77,19 +81,19 @@ MainWindow::MainWindow( const QStringList& args, QWidget* parent ) : QMainWindow QLabel* label = new QLabel( this ); label->setAlignment( Qt::AlignCenter ); setCentralWidget( label ); - label->setText( QString::fromLatin1("Version: %1\n").arg( m_installer.settings().applicationVersion() ) + args.join( QLatin1String(" ") ) ); + label->setText( QString::fromLatin1("Version: %1\n").arg( m_installer->settings().applicationVersion() ) + args.join( QLatin1String(" ") ) ); updaterapp.packagesInfo()->setApplicationName( m_settings.applicationName() ); updaterapp.packagesInfo()->setApplicationVersion( m_settings.applicationVersion() ); - UpdateAgent* const agent = new UpdateAgent( this ); - connect( agent, SIGNAL( updatesAvailable() ), this, SLOT( updatesAvailable() ) ); +// UpdateAgent* const agent = new UpdateAgent( this ); +// connect( agent, SIGNAL( updatesAvailable() ), this, SLOT( updatesAvailable() ) ); } void MainWindow::editUpdateSettings() { - UpdateSettingsDialog dialog( this ); - connect( &dialog, SIGNAL( checkForUpdates() ), this, SLOT( checkForUpdates() ) ); - dialog.exec(); +// UpdateSettingsDialog dialog( this ); +// connect( &dialog, SIGNAL( checkForUpdates() ), this, SLOT( checkForUpdates() ) ); +// dialog.exec(); } void MainWindow::checkForUpdates() { @@ -100,43 +104,45 @@ void MainWindow::checkForUpdates() { try { - m_installer.setRemoteRepositories( settings.repositories() ); + m_installer->setTemporaryRepositories( settings.repositories() ); settings.setLastCheck( QDateTime::currentDateTime() ); - + + m_installer->fetchUpdaterPackages(); + // no updates for us - if( m_installer.components(false, UpdaterMode).isEmpty() ) + if( m_installer->components(false, UpdaterMode).isEmpty() ) { QMessageBox::information( this, tr( "Check for Updates" ), tr( "There are currently no updates available for you." ) ); return; } // set the target directory to the actual one - m_installer.setValue( QLatin1String( "TargetDir" ), QFileInfo( updaterapp.packagesInfo()->fileName() ).absolutePath() ); + m_installer->setValue( QLatin1String( "TargetDir" ), QFileInfo( updaterapp.packagesInfo()->fileName() ).absolutePath() ); // this will automatically mork components as to get installed - ComponentSelectionDialog componentSelection( &m_installer, this ); + ComponentSelectionDialog componentSelection( m_installer, this ); if( componentSelection.exec() == QDialog::Rejected ) return; QProgressDialog dialog( this ); dialog.setRange( 0, 100 ); dialog.show(); - connect( &dialog, SIGNAL( canceled() ), &m_installer, SLOT( interrupt() ) ); - connect( &m_installer, SIGNAL( installationProgressTextChanged( QString ) ), &dialog, SLOT( setLabelText( QString ) ) ); - connect( &m_installer, SIGNAL( installationProgressChanged( int ) ), &dialog, SLOT( setValue( int ) ) ); - m_installer.installSelectedComponents(); + connect( &dialog, SIGNAL( canceled() ), m_installer, SLOT( interrupt() ) ); + connect( m_installer, SIGNAL( installationProgressTextChanged( QString ) ), &dialog, SLOT( setLabelText( QString ) ) ); + connect( m_installer, SIGNAL( installationProgressChanged( int ) ), &dialog, SLOT( setValue( int ) ) ); + m_installer->installSelectedComponents(); updatesInstalled(); } catch( const QInstaller::Error& error ) { QMessageBox::critical( this, tr( "Check for Updates" ), tr( "Error while installing updates:\n%1" ).arg( error.what() ) ); - m_installer.rollBackInstallation(); + m_installer->rollBackInstallation(); settings.setLastResult( tr( "Software Update failed." ) ); } catch( ... ) { QMessageBox::critical( this, tr( "Check for Updates" ), tr( "Unknown error while installing updates." ) ); - m_installer.rollBackInstallation(); + m_installer->rollBackInstallation(); settings.setLastResult( tr( "Software Update failed." ) ); } } diff --git a/examples/testapp/mainwindow.h b/examples/testapp/mainwindow.h index c0611eaab..27af19c97 100644 --- a/examples/testapp/mainwindow.h +++ b/examples/testapp/mainwindow.h @@ -34,6 +34,7 @@ class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow( const QStringList& args, QWidget* parent=0 ); + ~MainWindow() { delete m_installer; } private Q_SLOTS: void editUpdateSettings(); @@ -43,6 +44,6 @@ private Q_SLOTS: private: KDUpdater::Application updaterapp; - QInstaller::Installer m_installer; + QInstaller::Installer *m_installer; QInstaller::InstallerSettings m_settings; }; diff --git a/examples/testapp/testapp.pro b/examples/testapp/testapp.pro index 7c1bc85f9..0d5c8dbc3 100644 --- a/examples/testapp/testapp.pro +++ b/examples/testapp/testapp.pro @@ -11,8 +11,9 @@ CONFIG += uitools help QTPLUGIN += qsqlite # Input -HEADERS += mainwindow.h -SOURCES += main.cpp mainwindow.cpp +FORMS += componentselectiondialog.ui +HEADERS += mainwindow.h componentselectiondialog.h +SOURCES += main.cpp mainwindow.cpp componentselectiondialog.cpp RESOURCES += testapp.qrc macx:QMAKE_POST_LINK = ($$OUT_PWD/../../installerbuilder/bin/binarycreator -p packages -c config -t ../../installerbuilder/bin/installerbase TestAppInstaller.app com.nokia.testapp) diff --git a/installerfw.pro b/installerfw.pro index e6138d9e7..7009c613f 100644 --- a/installerfw.pro +++ b/installerfw.pro @@ -1,6 +1,6 @@ TEMPLATE=subdirs CONFIG += ordered -SUBDIRS += installerbuilder +SUBDIRS += installerbuilder examples test.target=test -- cgit v1.2.3