OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / qt-maemo / maemoprofilesupdatedialog.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
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.
18 **
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.
22 **
23 ** Other Usage
24 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32 #include "maemoprofilesupdatedialog.h"
33 #include "ui_maemoprofilesupdatedialog.h"
34
35 #include "maemodeployablelistmodel.h"
36
37 #include <qt4projectmanager/qt4nodes.h>
38
39 #include <QtCore/QDir>
40 #include <QtGui/QTableWidgetItem>
41
42 namespace Qt4ProjectManager {
43 namespace Internal {
44
45 MaemoProFilesUpdateDialog::MaemoProFilesUpdateDialog(const QList<MaemoDeployableListModel *> &models,
46     QWidget *parent)
47     : QDialog(parent),
48     m_models(models),
49     ui(new Ui::MaemoProFilesUpdateDialog)
50 {
51     ui->setupUi(this);
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);
61     }
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()));
66 }
67
68 MaemoProFilesUpdateDialog::~MaemoProFilesUpdateDialog()
69 {
70     delete ui;
71 }
72
73 void MaemoProFilesUpdateDialog::checkAll()
74 {
75     setCheckStateForAll(Qt::Checked);
76 }
77
78 void MaemoProFilesUpdateDialog::uncheckAll()
79 {
80     setCheckStateForAll(Qt::Unchecked);
81 }
82
83 void MaemoProFilesUpdateDialog::setCheckStateForAll(Qt::CheckState checkState)
84 {
85     for (int row = 0; row < ui->tableWidget->rowCount(); ++row)  {
86         ui->tableWidget->item(row, 0)->setCheckState(checkState);
87     }
88 }
89
90 QList<MaemoProFilesUpdateDialog::UpdateSetting>
91 MaemoProFilesUpdateDialog::getUpdateSettings() const
92 {
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);
98     }
99     return settings;
100 }
101
102 } // namespace Qt4ProjectManager
103 } // namespace Internal