summaryrefslogtreecommitdiff
path: root/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp
diff options
context:
space:
mode:
authordt_ <qtc-committer@nokia.com>2011-06-21 17:12:44 +0200
committerDaniel Teske <daniel.teske@nokia.com>2011-06-22 18:04:02 +0200
commit86889dded8421b20e5f778d454c9f863ee3991ca (patch)
treef6725d75f39f8880d5971a8f0b6281c9a6f66acb /src/plugins/genericprojectmanager/filesselectionwizardpage.cpp
parentcd737c7325942d5eb6f386f0731785f5449befd7 (diff)
downloadqt-creator-86889dded8421b20e5f778d454c9f863ee3991ca.tar.gz
On new generic project, show progress and dialog
Task-Nr: QTCREATORBUG-2226 Change-Id: I62e1c740a008663396960cfc12a05202f8800892 Reviewed-on: http://codereview.qt.nokia.com/594 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
Diffstat (limited to 'src/plugins/genericprojectmanager/filesselectionwizardpage.cpp')
-rw-r--r--src/plugins/genericprojectmanager/filesselectionwizardpage.cpp113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp b/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp
new file mode 100644
index 0000000000..51a58c822e
--- /dev/null
+++ b/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp
@@ -0,0 +1,113 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (info@qt.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.
+**
+** Other Usage
+**
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at info@qt.nokia.com.
+**
+**************************************************************************/
+
+#include "filesselectionwizardpage.h"
+
+#include "genericprojectwizard.h"
+#include "selectablefilesmodel.h"
+
+#include <coreplugin/mimedatabase.h>
+#include <coreplugin/icore.h>
+#include <QtGui/QVBoxLayout>
+
+using namespace GenericProjectManager;
+using namespace GenericProjectManager::Internal;
+
+FilesSelectionWizardPage::FilesSelectionWizardPage(GenericProjectWizardDialog *genericProjectWizard, QWidget *parent)
+ : QWizardPage(parent), m_genericProjectWizardDialog(genericProjectWizard), m_model(0), m_finished(false)
+{
+ QVBoxLayout *layout = new QVBoxLayout(this);
+
+ m_view = new QTreeView;
+ m_view->setMinimumSize(500, 400);
+ m_view->setHeaderHidden(true);
+ m_view->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
+ m_label = new QLabel;
+ m_label->setMaximumWidth(500);
+
+ layout->addWidget(m_view);
+ layout->addWidget(m_label);
+}
+
+void FilesSelectionWizardPage::initializePage()
+{
+ m_view->setModel(0);
+ delete m_model;
+ Core::MimeDatabase *mimeDatabase = Core::ICore::instance()->mimeDatabase();
+ m_model = new SelectableFilesModel(m_genericProjectWizardDialog->path(), this);
+ m_model->setSuffixes(mimeDatabase->suffixes().toSet());
+ connect(m_model, SIGNAL(parsingProgress(QString)),
+ this, SLOT(parsingProgress(QString)));
+ connect(m_model, SIGNAL(parsingFinished()),
+ this, SLOT(parsingFinished()));
+ m_model->startParsing();
+ m_view->setVisible(false);
+ m_label->setVisible(true);
+ m_view->setModel(m_model);
+}
+
+void FilesSelectionWizardPage::cleanupPage()
+{
+ m_model->cancel();
+ m_model->waitForFinished();
+}
+
+void FilesSelectionWizardPage::parsingProgress(const QString &text)
+{
+ m_label->setText(tr("Generating file list...\n\n%1").arg(text));
+}
+
+void FilesSelectionWizardPage::parsingFinished()
+{
+ m_finished = true;
+ m_view->setVisible(true);
+ m_label->setVisible(false);
+ m_view->expand(m_view->model()->index(0,0, QModelIndex()));
+ emit completeChanged();
+ // work around qt
+ m_genericProjectWizardDialog->setTitleFormat(m_genericProjectWizardDialog->titleFormat());
+}
+
+bool FilesSelectionWizardPage::isComplete() const
+{
+ return m_finished;
+}
+
+QStringList FilesSelectionWizardPage::selectedPaths() const
+{
+ return m_model ? m_model->selectedPaths() : QStringList();
+}
+
+QStringList FilesSelectionWizardPage::selectedFiles() const
+{
+ return m_model ? m_model->selectedFiles() : QStringList();
+}