1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
32 #include "maemoprofilesupdatedialog.h"
33 #include "ui_maemoprofilesupdatedialog.h"
35 #include "maemodeployablelistmodel.h"
37 #include <qt4projectmanager/qt4nodes.h>
39 #include <QtCore/QDir>
40 #include <QtGui/QTableWidgetItem>
42 namespace Qt4ProjectManager {
45 MaemoProFilesUpdateDialog::MaemoProFilesUpdateDialog(const QList<MaemoDeployableListModel *> &models,
49 ui(new Ui::MaemoProFilesUpdateDialog)
52 ui->tableWidget->setRowCount(models.count());
53 ui->tableWidget->setHorizontalHeaderItem(0,
54 new QTableWidgetItem(tr("Updateable Project Files")));
55 for (int row = 0; row < models.count(); ++row) {
56 QTableWidgetItem *const item
57 = new QTableWidgetItem(QDir::toNativeSeparators(models.at(row)->proFilePath()));
58 item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
59 item->setCheckState(Qt::Unchecked);
60 ui->tableWidget->setItem(row, 0, item);
62 ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
63 ui->tableWidget->resizeRowsToContents();
64 connect(ui->checkAllButton, SIGNAL(clicked()), this, SLOT(checkAll()));
65 connect(ui->uncheckAllButton, SIGNAL(clicked()), this, SLOT(uncheckAll()));
68 MaemoProFilesUpdateDialog::~MaemoProFilesUpdateDialog()
73 void MaemoProFilesUpdateDialog::checkAll()
75 setCheckStateForAll(Qt::Checked);
78 void MaemoProFilesUpdateDialog::uncheckAll()
80 setCheckStateForAll(Qt::Unchecked);
83 void MaemoProFilesUpdateDialog::setCheckStateForAll(Qt::CheckState checkState)
85 for (int row = 0; row < ui->tableWidget->rowCount(); ++row) {
86 ui->tableWidget->item(row, 0)->setCheckState(checkState);
90 QList<MaemoProFilesUpdateDialog::UpdateSetting>
91 MaemoProFilesUpdateDialog::getUpdateSettings() const
93 QList<UpdateSetting> settings;
94 for (int row = 0; row < m_models.count(); ++row) {
95 const bool doUpdate = result() != Rejected
96 && ui->tableWidget->item(row, 0)->checkState() == Qt::Checked;
97 settings << UpdateSetting(m_models.at(row), doUpdate);
102 } // namespace Qt4ProjectManager
103 } // namespace Internal