From 75e611acc5b7123ed0b5d892985659cf2e1b75e8 Mon Sep 17 00:00:00 2001 From: kh1 Date: Tue, 31 May 2011 17:22:24 +0200 Subject: Add missing files to make the testapp compile fully. Review-by: tjenssen --- examples/testapp/updateagent.cpp | 129 ++++++++++++++ examples/testapp/updateagent.h | 49 +++++ examples/testapp/updatesettingsdialog.cpp | 83 +++++++++ examples/testapp/updatesettingsdialog.h | 51 ++++++ examples/testapp/updatesettingsdialog.ui | 39 ++++ examples/testapp/updatesettingswidget.cpp | 161 +++++++++++++++++ examples/testapp/updatesettingswidget.h | 57 ++++++ examples/testapp/updatesettingswidget.ui | 286 ++++++++++++++++++++++++++++++ 8 files changed, 855 insertions(+) create mode 100644 examples/testapp/updateagent.cpp create mode 100644 examples/testapp/updateagent.h create mode 100644 examples/testapp/updatesettingsdialog.cpp create mode 100644 examples/testapp/updatesettingsdialog.h create mode 100644 examples/testapp/updatesettingsdialog.ui create mode 100644 examples/testapp/updatesettingswidget.cpp create mode 100644 examples/testapp/updatesettingswidget.h create mode 100644 examples/testapp/updatesettingswidget.ui (limited to 'examples') diff --git a/examples/testapp/updateagent.cpp b/examples/testapp/updateagent.cpp new file mode 100644 index 000000000..52d299785 --- /dev/null +++ b/examples/testapp/updateagent.cpp @@ -0,0 +1,129 @@ +/************************************************************************** +** +** This file is part of Qt SDK** +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** +** Contact: Nokia Corporation qt-info@nokia.com** +** +** No Commercial Usage +** +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception version +** 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you are unsure which license is appropriate for your use, please contact +** (qt-info@nokia.com). +** +**************************************************************************/ +#include "updateagent.h" + +#include "updatesettings.h" + +#include +#include + +#include + +#include "qinstaller.h" +#include "qinstallercomponent.h" + +#include "common/binaryformatenginehandler.h" +#include "common/binaryformat.h" + +using namespace QInstaller; +using QInstallerCreator::ComponentIndex; +using QInstallerCreator::BinaryFormatEngineHandler; + +class UpdateAgent::Private +{ +public: + Private( UpdateAgent* qq ) + : q( qq ) + { + connect( &checkTimer, SIGNAL( timeout() ), q, SLOT( maybeCheck() ) ); + checkTimer.start( 1000 ); + } + +private: + UpdateAgent* const q; + +public: + void maybeCheck() + { + checkTimer.stop(); + + UpdateSettings settings; + + try + { + if( settings.updateInterval() > 0 && settings.lastCheck().secsTo( QDateTime::currentDateTime() ) >= settings.updateInterval() ) + { + QScopedPointer handler( new BinaryFormatEngineHandler( ComponentIndex() ) ); + handler->setComponentIndex( QInstallerCreator::ComponentIndex() ); + + settings.setLastCheck( QDateTime::currentDateTime() ); + + KDUpdater::Application app; + Installer installer(QInstaller::MagicUpdaterMarker); + installer.setUpdaterApplication(&app); + installer.setTemporaryRepositories( settings.repositories() ); + installer.fetchUpdaterPackages(); + QList components = installer.components(false, UpdaterMode); + + // remove all unimportant updates + if( settings.checkOnlyImportantUpdates() ) + { + for( int i = components.count() - 1; i >= 0; --i ) + { + const Component* const comp = components[ i ]; + if( comp->value( QLatin1String( "Important" ) ).toLower() != QLatin1String( "true" ) ) + components.removeAt( i ); + } + } + + settings.setLastResult( tr( "Software Update run successfully." ) ); + + // no updates available + if( components.isEmpty() ) + return; + + emit q->updatesAvailable(); + } + } + catch( ... ) + { + settings.setLastResult( tr( "Software Update failed." ) ); + } + + checkTimer.start(); + } + + QTimer checkTimer; +}; + +UpdateAgent::UpdateAgent( QObject* parent ) + : QObject( parent ), + d( new Private( this ) ) +{ +} + +UpdateAgent::~UpdateAgent() +{ +} + +#include "moc_updateagent.cpp" diff --git a/examples/testapp/updateagent.h b/examples/testapp/updateagent.h new file mode 100644 index 000000000..7f7840739 --- /dev/null +++ b/examples/testapp/updateagent.h @@ -0,0 +1,49 @@ +/************************************************************************** +** +** This file is part of Qt SDK** +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).* +** +** Contact: Nokia Corporation qt-info@nokia.com** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception version +** 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you are unsure which license is appropriate for your use, please contact +** (qt-info@nokia.com). +** +**************************************************************************/ +#ifndef UPDATEAGENT_H +#define UPDATEAGENT_H + +#include +#include + +class UpdateAgent : public QObject +{ + Q_OBJECT +public: + explicit UpdateAgent( QObject* parent = 0 ); + ~UpdateAgent(); + +Q_SIGNALS: + void updatesAvailable(); + +private: + Q_PRIVATE_SLOT( d, void maybeCheck() ); + + class Private; + kdtools::pimpl_ptr< Private > d; +}; + +#endif diff --git a/examples/testapp/updatesettingsdialog.cpp b/examples/testapp/updatesettingsdialog.cpp new file mode 100644 index 000000000..0c3c676cb --- /dev/null +++ b/examples/testapp/updatesettingsdialog.cpp @@ -0,0 +1,83 @@ +/************************************************************************** +** +** This file is part of Qt SDK** +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** +** Contact: Nokia Corporation qt-info@nokia.com** +** +** No Commercial Usage +** +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception version +** 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you are unsure which license is appropriate for your use, please contact +** (qt-info@nokia.com). +** +**************************************************************************/ +#include "updatesettingsdialog.h" +#include "ui_updatesettingsdialog.h" + +#include "common/repository.h" + +#include "updatesettings.h" + +#include +#include + +using namespace QInstaller; + +class UpdateSettingsDialog::Private +{ +public: + Private( UpdateSettingsDialog* qq ) + : q( qq ) + { + ui.setupUi( q ); + } + +private: + UpdateSettingsDialog* const q; + +public: + Ui::UpdateSettingsDialog ui; +}; + +UpdateSettingsDialog::UpdateSettingsDialog( QWidget* parent ) + : QDialog( parent ), + d( new Private( this ) ) +{ + connect( d->ui.buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); + connect( d->ui.buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) ); + + connect( d->ui.widget, SIGNAL( checkForUpdates() ), this, SLOT( accept() ) ); + connect( d->ui.widget, SIGNAL( checkForUpdates() ), this, SIGNAL( checkForUpdates() ) ); + setFixedSize( size() ); +} + +UpdateSettingsDialog::~UpdateSettingsDialog() +{ +} + +void UpdateSettingsDialog::accept() +{ + d->ui.widget->accept(); + QDialog::accept(); +} + +#include "moc_updatesettingsdialog.cpp" diff --git a/examples/testapp/updatesettingsdialog.h b/examples/testapp/updatesettingsdialog.h new file mode 100644 index 000000000..a8f6f1ae7 --- /dev/null +++ b/examples/testapp/updatesettingsdialog.h @@ -0,0 +1,51 @@ +/************************************************************************** +** +** This file is part of Qt SDK** +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).* +** +** Contact: Nokia Corporation qt-info@nokia.com** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception version +** 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you are unsure which license is appropriate for your use, please contact +** (qt-info@nokia.com). +** +**************************************************************************/ +#ifndef UPDATESETTINGSDIALOG_H +#define UPDATESETTINGSDIALOG_H + +#include + +#include + +class UpdateSettingsDialog : public QDialog +{ + Q_OBJECT +public: + explicit UpdateSettingsDialog( QWidget* parent = 0 ); + ~UpdateSettingsDialog(); + +Q_SIGNALS: + void checkForUpdates(); + +public Q_SLOTS: + void accept(); + +private: + class Private; + kdtools::pimpl_ptr< Private > d; +}; + +#endif diff --git a/examples/testapp/updatesettingsdialog.ui b/examples/testapp/updatesettingsdialog.ui new file mode 100644 index 000000000..0a879257b --- /dev/null +++ b/examples/testapp/updatesettingsdialog.ui @@ -0,0 +1,39 @@ + + + UpdateSettingsDialog + + + + 0 + 0 + 447 + 312 + + + + Software Update Settings + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + UpdateSettingsWidget + QWidget +
updatesettingswidget.h
+ 1 +
+
+ + +
diff --git a/examples/testapp/updatesettingswidget.cpp b/examples/testapp/updatesettingswidget.cpp new file mode 100644 index 000000000..d28a25168 --- /dev/null +++ b/examples/testapp/updatesettingswidget.cpp @@ -0,0 +1,161 @@ +/************************************************************************** +** +** This file is part of Qt SDK** +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** +** Contact: Nokia Corporation qt-info@nokia.com** +** +** No Commercial Usage +** +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception version +** 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you are unsure which license is appropriate for your use, please contact +** (qt-info@nokia.com). +** +**************************************************************************/ +#include "updatesettingswidget.h" +#include "ui_updatesettingswidget.h" + +#include "common/repository.h" + +#include "updatesettings.h" + +#include +#include + +using namespace QInstaller; + +class UpdateSettingsWidget::Private +{ +public: + Private( UpdateSettingsWidget* qq ) + : q( qq ), + initialized( false ) + { + ui.setupUi( q ); + } + + void addUpdateSource() + { + const int newRow = model.rowCount(); + if( model.insertRow( newRow ) ) + ui.treeViewUpdateSources->edit( model.index( newRow, 0 ) ); + } + + void removeUpdateSource() + { + model.removeRow( ui.treeViewUpdateSources->currentIndex().row() ); + } + +private: + UpdateSettingsWidget* const q; + +public: + bool initialized; + Ui::UpdateSettingsWidget ui; + UpdateSettings settings; + QStringListModel model; +}; + +UpdateSettingsWidget::UpdateSettingsWidget( QWidget* parent ) + : QWidget( parent ), + d( new Private( this ) ) +{ +} + +UpdateSettingsWidget::~UpdateSettingsWidget() +{ +} + +/*! + \reimpl +*/ +void UpdateSettingsWidget::showEvent( QShowEvent* event ) +{ + Q_UNUSED( event ) + if( d->initialized ) + return; + + d->ui.checkBoxCheckForUpdates->setChecked( d->settings.updateInterval() > 0 ); + d->ui.checkBoxCheckOnlyImportant->setChecked( d->settings.checkOnlyImportantUpdates() ); + switch( qAbs( d->settings.updateInterval() ) ) + { + case UpdateSettings::Daily: + d->ui.comboBoxFrequency->setCurrentIndex( 0 ); + break; + case UpdateSettings::Weekly: + d->ui.comboBoxFrequency->setCurrentIndex( 1 ); + break; + case UpdateSettings::Monthly: + d->ui.comboBoxFrequency->setCurrentIndex( 2 ); + break; + } + + connect( d->ui.buttonAddUpdateSource, SIGNAL( clicked() ), this, SLOT( addUpdateSource() ) ); + connect( d->ui.buttonRemoveUpdateSource, SIGNAL( clicked() ), this, SLOT( removeUpdateSource() ) ); + + connect( d->ui.buttonCheckNow, SIGNAL( clicked() ), this, SIGNAL( checkForUpdates() ) ); + + QStringList reps; + const QList< Repository > repositories = d->settings.repositories(); + for( QList< Repository >::const_iterator it = repositories.begin(); it != repositories.end(); ++it ) + reps.push_back( it->url().toString() ); + d->model.setStringList( reps ); + d->ui.treeViewUpdateSources->setModel( &d->model ); + + d->ui.labelLastUpdateResult->clear(); + if( d->settings.lastResult().isEmpty() ) + d->ui.labelLastCheck->clear(); + else + d->ui.labelLastUpdateResult->setText( d->settings.lastResult() + QLatin1Char( '\n' ) + d->settings.lastCheck().toString() ); + + d->initialized = true; +} + +void UpdateSettingsWidget::accept() +{ + switch( d->ui.comboBoxFrequency->currentIndex() ) + { + case 0: + d->settings.setUpdateInterval( UpdateSettings::Daily ); + break; + case 1: + d->settings.setUpdateInterval( UpdateSettings::Weekly ); + break; + case 2: + d->settings.setUpdateInterval( UpdateSettings::Monthly ); + break; + } + if( !d->ui.checkBoxCheckForUpdates->isChecked() ) + d->settings.setUpdateInterval( -d->settings.updateInterval() ); + d->settings.setCheckOnlyImportantUpdates( d->ui.checkBoxCheckOnlyImportant->isChecked() ); + + const QStringList reps = d->model.stringList(); + QList< Repository > repositories; + Repository rep; + for( QStringList::const_iterator it = reps.begin(); it != reps.end(); ++it ) + { + rep.setUrl( QUrl( *it ) ); + repositories.push_back( rep ); + } + d->settings.setRepositories( repositories ); +} + +#include "moc_updatesettingswidget.cpp" diff --git a/examples/testapp/updatesettingswidget.h b/examples/testapp/updatesettingswidget.h new file mode 100644 index 000000000..fe586f9c6 --- /dev/null +++ b/examples/testapp/updatesettingswidget.h @@ -0,0 +1,57 @@ +/************************************************************************** +** +** This file is part of Qt SDK** +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).* +** +** Contact: Nokia Corporation qt-info@nokia.com** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception version +** 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you are unsure which license is appropriate for your use, please contact +** (qt-info@nokia.com). +** +**************************************************************************/ +#ifndef UPDATESETTINGSWIDGET_H +#define UPDATESETTINGSWIDGET_H + +#include + +#include + +class UpdateSettingsWidget : public QWidget +{ + Q_OBJECT +public: + explicit UpdateSettingsWidget( QWidget* parent = 0 ); + ~UpdateSettingsWidget(); + +Q_SIGNALS: + void checkForUpdates(); + +public Q_SLOTS: + void accept(); + +protected: + void showEvent( QShowEvent* event ); + +private: + Q_PRIVATE_SLOT( d, void addUpdateSource() ); + Q_PRIVATE_SLOT( d, void removeUpdateSource() ); + + class Private; + kdtools::pimpl_ptr< Private > d; +}; + +#endif diff --git a/examples/testapp/updatesettingswidget.ui b/examples/testapp/updatesettingswidget.ui new file mode 100644 index 000000000..49525e1b9 --- /dev/null +++ b/examples/testapp/updatesettingswidget.ui @@ -0,0 +1,286 @@ + + + UpdateSettingsWidget + + + + 0 + 0 + 438 + 247 + + + + Software Update Settings + + + + + + + Scheduled Check + + + + + + + + Qt::Horizontal + + + + 16 + 20 + + + + + + + + Check for updates: + + + + + + + false + + + + Daily + + + + + Weekly + + + + + Monthly + + + + + + + + Qt::Horizontal + + + + 16 + 20 + + + + + + + + + 0 + 0 + + + + + 8 + 0 + + + + + 8 + 16777215 + + + + + + + + false + + + Check only for important updates + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 11 + + + + + + + + + + Check Now + + + + + + + Last check: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Software Update ran successfully. +Monday, 2009 december 16 20.36 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + 1 + 20 + + + + + + + + Qt::Horizontal + + + + 1 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 23 + + + + + + + + + Update Sources + + + + + + false + + + true + + + + + + + + 25 + 25 + + + + + + + + + + + + + 25 + 25 + + + + - + + + + + + + + + + + + + checkBoxCheckForUpdates + toggled(bool) + comboBoxFrequency + setEnabled(bool) + + + 179 + 59 + + + 293 + 61 + + + + + checkBoxCheckForUpdates + toggled(bool) + checkBoxCheckOnlyImportant + setEnabled(bool) + + + 135 + 64 + + + 149 + 91 + + + + + -- cgit v1.2.3