summaryrefslogtreecommitdiffstats
path: root/examples/testapp
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2011-05-31 17:11:42 +0200
committerkh1 <qt-info@nokia.com>2011-05-31 17:32:26 +0200
commitf8fd66a05de9ba34b4cc0f04aed3f92e88cab96b (patch)
treea7ce3f75fd8ee5135e60f2c2d24382c6bcddf370 /examples/testapp
parent3c5279eed15f16bbb659fa95b900bb82067ff974 (diff)
Cleanup. Style changes.
Diffstat (limited to 'examples/testapp')
-rw-r--r--examples/testapp/componentselectiondialog.cpp164
1 files changed, 81 insertions, 83 deletions
diff --git a/examples/testapp/componentselectiondialog.cpp b/examples/testapp/componentselectiondialog.cpp
index 35b5e9ceb..4062857e4 100644
--- a/examples/testapp/componentselectiondialog.cpp
+++ b/examples/testapp/componentselectiondialog.cpp
@@ -46,67 +46,64 @@ class ComponentSelectionDialog::Private : public QObject
{
Q_OBJECT
public:
- Private( ComponentSelectionDialog* qq, Installer* inst )
- : q( qq ),
- installer( inst )
+ Private(ComponentSelectionDialog *qq, Installer *inst)
+ : q(qq),
+ installer(inst)
{
}
void selectionChanged()
{
- // no component selected disables the ok button
- const QList< Component* > components = installer->components( true, UpdaterMode );
int selectionCount = 0;
- for( QList< Component* >::const_iterator it = components.begin(); it != components.end(); ++it )
- {
- if( (*it)->isSelected() )
+ // no component selected disables the ok button
+ foreach (Component *component, installer->components(true, UpdaterMode)) {
+ if (component->isSelected())
++selectionCount;
}
- installBtn->setEnabled( selectionCount > 0 );
- installBtn->setText( selectionCount > 1 ? tr( "Install %1 Items" ).arg( selectionCount ) :
- selectionCount == 1 ? tr( "Install 1 Item" ) : tr( "Install" ) );
+ installBtn->setEnabled(selectionCount > 0);
+ installBtn->setText(selectionCount > 1 ? tr("Install %1 Items").arg(selectionCount) :
+ selectionCount == 1 ? tr("Install 1 Item") : tr("Install"));
if (selectionCount > 0) {
- ui.buttonBox->button( QDialogButtonBox::Cancel )->setText(tr("Cancel"));
+ ui.buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
} else {
- ui.buttonBox->button( QDialogButtonBox::Cancel )->setText(tr("Close"));
+ ui.buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Close"));
}
const QModelIndex index = ui.treeView->currentIndex();
- if( !index.isValid() )
- {
+ if (!index.isValid()) {
ui.textBrowser->clear();
return;
}
- ui.textBrowser->setHtml( index.sibling( index.row(), 0 ).data( Qt::ToolTipRole ).toString() );
+ ui.textBrowser->setHtml(index.sibling(index.row(), 0).data(Qt::ToolTipRole).toString());
}
void modelReset()
{
- ui.treeView->header()->resizeSection( 0, ui.labelTitle->sizeHint().width() / 1.5 );
- ui.treeView->header()->setStretchLastSection( true );
- for ( int i = 0; i < ui.treeView->model()->columnCount(); ++i )
- ui.treeView->resizeColumnToContents( i );
+ ui.treeView->header()->resizeSection(0, ui.labelTitle->sizeHint().width() / 1.5);
+ ui.treeView->header()->setStretchLastSection(true);
+ for (int i = 0; i < ui.treeView->model()->columnCount(); ++i)
+ ui.treeView->resizeColumnToContents(i);
bool hasChildren = false;
const int rowCount = ui.treeView->model()->rowCount();
- for( int row = 0; row < rowCount && !hasChildren; ++row )
- hasChildren = ui.treeView->model()->hasChildren( ui.treeView->model()->index( row, 0 ) );
- ui.treeView->setRootIsDecorated( hasChildren );
- ui.treeView->expandToDepth( 0 );
+ for (int row = 0; row < rowCount && !hasChildren; ++row)
+ hasChildren = ui.treeView->model()->hasChildren(ui.treeView->model()->index(row, 0));
+ ui.treeView->setRootIsDecorated(hasChildren);
+ ui.treeView->expandToDepth(0);
selectionChanged();
}
private:
- ComponentSelectionDialog* const q;
+ ComponentSelectionDialog *const q;
public:
Ui::ComponentSelectionDialog ui;
- Installer* const installer;
- ComponentModel* componentModel;
- QPushButton* installBtn;
+ Installer *const installer;
+ ComponentModel *componentModel;
+ QPushButton *installBtn;
public Q_SLOTS:
void selectAll();
@@ -115,59 +112,55 @@ public Q_SLOTS:
void ComponentSelectionDialog::Private::selectAll()
{
- QList< Component* > updaterComponents = installer->components( false, UpdaterMode );
- Q_FOREACH( Component* comp, updaterComponents )
- {
- comp->setSelected( true );
- }
+ foreach (Component *component, installer->components(false, UpdaterMode))
+ component->setSelected(true);
}
void ComponentSelectionDialog::Private::deselectAll()
{
- QList< Component* > updaterComponents = installer->components( false, UpdaterMode );
- Q_FOREACH( Component* comp, updaterComponents )
- {
- comp->setSelected( false );
- }
+ foreach (Component *component, installer->components(false, UpdaterMode))
+ component->setSelected(false);
}
-ComponentSelectionDialog::ComponentSelectionDialog( Installer* installer, QWidget* parent )
- : QDialog( parent ),
- d( new Private( this, installer ) )
+// -- ComponentSelectionDialog
+
+ComponentSelectionDialog::ComponentSelectionDialog(Installer *installer, QWidget *parent)
+ : QDialog(parent),
+ d(new Private(this, installer))
{
- d->ui.setupUi( this );
- d->componentModel = new ComponentModel( 5, installer );
- d->ui.treeView->setModel( d->componentModel );
+ d->ui.setupUi(this);
+ d->componentModel = new ComponentModel(5, installer);
+ d->ui.treeView->setModel(d->componentModel);
- d->ui.labelLicenseBlurb->setAttribute( Qt::WA_MacSmallSize );
- d->ui.labelSubTitle->setAttribute( Qt::WA_MacSmallSize );
- d->ui.treeView->setAttribute( Qt::WA_MacShowFocusRect, false );
- d->ui.textBrowser->setAttribute( Qt::WA_MacShowFocusRect, false );
- d->ui.splitter->setCollapsible( 0, false );
- d->installBtn = d->ui.buttonBox->addButton( tr( "Install" ), QDialogButtonBox::AcceptRole ) ;
- if ( !d->ui.buttonBox->button( QDialogButtonBox::Cancel )->icon().isNull() )
- d->installBtn->setIcon( style()->standardIcon( QStyle::SP_DialogOkButton ) );
-
- d->ui.icon->setPixmap( windowIcon().pixmap( 48, 48 ) );
-
- connect( d->ui.treeView->model(), SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
- this, SLOT( selectionChanged() ) );
- connect( d->ui.treeView->model(), SIGNAL( modelReset() ),
- this, SLOT( modelReset() ) );
- 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, 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 ) );
- d->ui.splitter->setStretchFactor( 0, 2 );
- d->ui.splitter->setStretchFactor( 1, 1 );
- d->ui.treeView->header()->setStretchLastSection( true );
- for ( int i = 0; i < d->ui.treeView->model()->columnCount(); ++i )
- d->ui.treeView->resizeColumnToContents( i );
+ d->ui.labelLicenseBlurb->setAttribute(Qt::WA_MacSmallSize);
+ d->ui.labelSubTitle->setAttribute(Qt::WA_MacSmallSize);
+ d->ui.treeView->setAttribute(Qt::WA_MacShowFocusRect, false);
+ d->ui.textBrowser->setAttribute(Qt::WA_MacShowFocusRect, false);
+ d->ui.splitter->setCollapsible(0, false);
+ d->installBtn = d->ui.buttonBox->addButton(tr("Install"), QDialogButtonBox::AcceptRole) ;
+ if (!d->ui.buttonBox->button(QDialogButtonBox::Cancel)->icon().isNull())
+ d->installBtn->setIcon(style()->standardIcon(QStyle::SP_DialogOkButton));
+
+ d->ui.icon->setPixmap(windowIcon().pixmap(48, 48));
+
+ connect(d->ui.treeView->model(), SIGNAL(dataChanged(QModelIndex, QModelIndex)),
+ this, SLOT(selectionChanged()));
+ connect(d->ui.treeView->model(), SIGNAL(modelReset()),
+ this, SLOT(modelReset()));
+ 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, 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));
+ d->ui.splitter->setStretchFactor(0, 2);
+ d->ui.splitter->setStretchFactor(1, 1);
+ d->ui.treeView->header()->setStretchLastSection(true);
+ for (int i = 0; i < d->ui.treeView->model()->columnCount(); ++i)
+ d->ui.treeView->resizeColumnToContents(i);
d->selectionChanged();
d->modelReset();
}
@@ -177,30 +170,35 @@ ComponentSelectionDialog::~ComponentSelectionDialog()
delete d;
}
-void ComponentSelectionDialog::selectAll() {
+void ComponentSelectionDialog::selectAll()
+{
d->selectAll();
}
-void ComponentSelectionDialog::deselectAll() {
+void ComponentSelectionDialog::deselectAll()
+{
d->deselectAll();
}
-void ComponentSelectionDialog::install() {
+void ComponentSelectionDialog::install()
+{
emit requestUpdate();
}
-void ComponentSelectionDialog::selectComponent( const QString& id ) {
- const QModelIndex idx = d->componentModel->indexFromComponentName( id );
- if ( !idx.isValid() )
+void ComponentSelectionDialog::selectComponent(const QString& id)
+{
+ const QModelIndex &idx = d->componentModel->indexFromComponentName(id);
+ if (!idx.isValid())
return;
- d->componentModel->setData( idx, Qt::Checked );
+ d->componentModel->setData(idx, Qt::Checked);
}
-void ComponentSelectionDialog::deselectComponent( const QString& id ) {
- const QModelIndex idx = d->componentModel->indexFromComponentName( id );
- if ( !idx.isValid() )
+void ComponentSelectionDialog::deselectComponent(const QString& id)
+{
+ const QModelIndex &idx = d->componentModel->indexFromComponentName(id);
+ if (!idx.isValid())
return;
- d->componentModel->setData( idx, Qt::Unchecked );
+ d->componentModel->setData(idx, Qt::Unchecked);
}
void ComponentSelectionDialog::refreshDialog()