diff options
author | kh1 <qt-info@nokia.com> | 2011-06-01 14:07:47 +0200 |
---|---|---|
committer | kh1 <qt-info@nokia.com> | 2011-06-01 14:07:47 +0200 |
commit | e7e57db90a2c35411ee3a75400fd3819a3fc7a00 (patch) | |
tree | 599f6f2b7d14e588f72aaa56459cd006667c0d84 /examples | |
parent | 3023e6c7bb5e5da19f769daeea56e988590f2214 (diff) |
Cleanup. Style changes.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/testapp/updatesettingsdialog.cpp | 35 | ||||
-rw-r--r-- | examples/testapp/updatesettingsdialog.h | 13 | ||||
-rw-r--r-- | examples/testapp/updatesettingswidget.cpp | 118 | ||||
-rw-r--r-- | examples/testapp/updatesettingswidget.h | 20 |
4 files changed, 90 insertions, 96 deletions
diff --git a/examples/testapp/updatesettingsdialog.cpp b/examples/testapp/updatesettingsdialog.cpp index 0c3c676cb..f65a391b6 100644 --- a/examples/testapp/updatesettingsdialog.cpp +++ b/examples/testapp/updatesettingsdialog.cpp @@ -33,45 +33,46 @@ #include "updatesettingsdialog.h" #include "ui_updatesettingsdialog.h" -#include "common/repository.h" +#include <common/repository.h> +#include <updatesettings.h> -#include "updatesettings.h" +#include <QtCore/QDateTime> -#include <QDateTime> -#include <QStringListModel> +#include <QtGui/QStringListModel> using namespace QInstaller; class UpdateSettingsDialog::Private { public: - Private( UpdateSettingsDialog* qq ) - : q( qq ) + Private(UpdateSettingsDialog *qq) + : q(qq) { - ui.setupUi( q ); + ui.setupUi(q); } private: - UpdateSettingsDialog* const q; + UpdateSettingsDialog *const q; public: Ui::UpdateSettingsDialog ui; }; -UpdateSettingsDialog::UpdateSettingsDialog( QWidget* parent ) - : QDialog( parent ), - d( new Private( this ) ) +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() ); + 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() { + delete d; } void UpdateSettingsDialog::accept() diff --git a/examples/testapp/updatesettingsdialog.h b/examples/testapp/updatesettingsdialog.h index a8f6f1ae7..78daad7fb 100644 --- a/examples/testapp/updatesettingsdialog.h +++ b/examples/testapp/updatesettingsdialog.h @@ -28,24 +28,23 @@ #include <QtGui/QDialog> -#include <KDToolsCore/pimpl_ptr.h> - class UpdateSettingsDialog : public QDialog { Q_OBJECT + public: - explicit UpdateSettingsDialog( QWidget* parent = 0 ); + explicit UpdateSettingsDialog(QWidget *parent = 0); ~UpdateSettingsDialog(); -Q_SIGNALS: - void checkForUpdates(); - public Q_SLOTS: void accept(); +Q_SIGNALS: + void checkForUpdates(); + private: class Private; - kdtools::pimpl_ptr< Private > d; + Private *const d; }; #endif diff --git a/examples/testapp/updatesettingswidget.cpp b/examples/testapp/updatesettingswidget.cpp index d28a25168..92c60bcf5 100644 --- a/examples/testapp/updatesettingswidget.cpp +++ b/examples/testapp/updatesettingswidget.cpp @@ -33,129 +33,123 @@ #include "updatesettingswidget.h" #include "ui_updatesettingswidget.h" -#include "common/repository.h" - +#include <common/repository.h> #include "updatesettings.h" -#include <QDateTime> -#include <QStringListModel> +#include <QtCore/QDateTime> + +#include <QtGui/QStringListModel> using namespace QInstaller; class UpdateSettingsWidget::Private { public: - Private( UpdateSettingsWidget* qq ) - : q( qq ), - initialized( false ) + Private(UpdateSettingsWidget *qq) + : q(qq), + initialized(false) { - ui.setupUi( q ); + ui.setupUi(q); } void addUpdateSource() { const int newRow = model.rowCount(); - if( model.insertRow( newRow ) ) - ui.treeViewUpdateSources->edit( model.index( newRow, 0 ) ); + if(model.insertRow(newRow)) + ui.treeViewUpdateSources->edit(model.index(newRow, 0)); } void removeUpdateSource() { - model.removeRow( ui.treeViewUpdateSources->currentIndex().row() ); + model.removeRow(ui.treeViewUpdateSources->currentIndex().row()); } private: - UpdateSettingsWidget* const q; + UpdateSettingsWidget *const q; public: bool initialized; - Ui::UpdateSettingsWidget ui; - UpdateSettings settings; QStringListModel model; + UpdateSettings settings; + + Ui::UpdateSettingsWidget ui; }; -UpdateSettingsWidget::UpdateSettingsWidget( QWidget* parent ) - : QWidget( parent ), - d( new Private( this ) ) + +// -- UpdateSettingsWidget + +UpdateSettingsWidget::UpdateSettingsWidget(QWidget *parent) + : QWidget(parent), + d(new Private(this)) { } UpdateSettingsWidget::~UpdateSettingsWidget() { + delete d; } -/*! - \reimpl -*/ -void UpdateSettingsWidget::showEvent( QShowEvent* event ) +void UpdateSettingsWidget::showEvent(QShowEvent *event) { - Q_UNUSED( event ) - if( d->initialized ) + 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() ) ) - { + 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 ); + d->ui.comboBoxFrequency->setCurrentIndex(0); break; case UpdateSettings::Weekly: - d->ui.comboBoxFrequency->setCurrentIndex( 1 ); + d->ui.comboBoxFrequency->setCurrentIndex(1); break; case UpdateSettings::Monthly: - d->ui.comboBoxFrequency->setCurrentIndex( 2 ); + 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() ) ); + connect(d->ui.buttonCheckNow, SIGNAL(clicked()), this, SIGNAL(checkForUpdates())); + connect(d->ui.buttonAddUpdateSource, SIGNAL(clicked()), this, SLOT(addUpdateSource())); + connect(d->ui.buttonRemoveUpdateSource, SIGNAL(clicked()), this, SLOT(removeUpdateSource())); 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 ); + foreach (const Repository &repository, d->settings.repositories()) + reps.append(repository.url().toString()); - 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->model.setStringList(reps); + d->ui.treeViewUpdateSources->setModel(&d->model); + d->ui.labelLastUpdateResult->clear(); + if(!d->settings.lastResult().isEmpty()) { + d->ui.labelLastUpdateResult->setText(d->settings.lastResult() + QLatin1Char('\n') + + d->settings.lastCheck().toString()); + } d->initialized = true; } void UpdateSettingsWidget::accept() { - switch( d->ui.comboBoxFrequency->currentIndex() ) - { + switch(d->ui.comboBoxFrequency->currentIndex()) { case 0: - d->settings.setUpdateInterval( UpdateSettings::Daily ); + d->settings.setUpdateInterval(UpdateSettings::Daily); break; case 1: - d->settings.setUpdateInterval( UpdateSettings::Weekly ); + d->settings.setUpdateInterval(UpdateSettings::Weekly); break; case 2: - d->settings.setUpdateInterval( UpdateSettings::Monthly ); + 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 ); + + if(!d->ui.checkBoxCheckForUpdates->isChecked()) + d->settings.setUpdateInterval(-d->settings.updateInterval()); + d->settings.setCheckOnlyImportantUpdates(d->ui.checkBoxCheckOnlyImportant->isChecked()); + + QList<Repository> repositories; + foreach (const QString &url, d->model.stringList()) + repositories.append(Repository(QUrl(url))); + d->settings.setRepositories(repositories); } #include "moc_updatesettingswidget.cpp" diff --git a/examples/testapp/updatesettingswidget.h b/examples/testapp/updatesettingswidget.h index fe586f9c6..25f75daae 100644 --- a/examples/testapp/updatesettingswidget.h +++ b/examples/testapp/updatesettingswidget.h @@ -28,30 +28,30 @@ #include <QtGui/QWidget> -#include <KDToolsCore/pimpl_ptr.h> - class UpdateSettingsWidget : public QWidget { Q_OBJECT + public: - explicit UpdateSettingsWidget( QWidget* parent = 0 ); + explicit UpdateSettingsWidget(QWidget *parent = 0); ~UpdateSettingsWidget(); -Q_SIGNALS: - void checkForUpdates(); - public Q_SLOTS: void accept(); +Q_SIGNALS: + void checkForUpdates(); + protected: - void showEvent( QShowEvent* event ); + void showEvent(QShowEvent *event); private: - Q_PRIVATE_SLOT( d, void addUpdateSource() ); - Q_PRIVATE_SLOT( d, void removeUpdateSource() ); + Q_PRIVATE_SLOT(d, void addUpdateSource()); + Q_PRIVATE_SLOT(d, void removeUpdateSource()); +private: class Private; - kdtools::pimpl_ptr< Private > d; + Private *const d; }; #endif |