forked from qt-creator/qt-creator
Wizards: Sort
Introduce new QString id() const-API and sort wizards by [untranslated] category and id. Introduce respective constants. Rubber-stamped-by: con <qtc-committer@nokia.com>
This commit is contained in:
@@ -32,92 +32,22 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
|
||||
#include <utils/filenamevalidatinglineedit.h>
|
||||
#include <utils/filewizardpage.h>
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QtDebug>
|
||||
|
||||
#include <QtGui/QDirModel>
|
||||
#include <QtGui/QFormLayout>
|
||||
#include <QtGui/QListView>
|
||||
#include <QtGui/QTreeView>
|
||||
#include <QtCore/QCoreApplication>
|
||||
|
||||
using namespace GenericProjectManager::Internal;
|
||||
using namespace Utils;
|
||||
|
||||
namespace {
|
||||
|
||||
class DirModel : public QDirModel
|
||||
{
|
||||
public:
|
||||
DirModel(QObject *parent)
|
||||
: QDirModel(parent)
|
||||
{ setFilter(QDir::Dirs | QDir::NoDotAndDotDot); }
|
||||
|
||||
virtual ~DirModel()
|
||||
{ }
|
||||
|
||||
public:
|
||||
virtual int columnCount(const QModelIndex &) const
|
||||
{ return 1; }
|
||||
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const
|
||||
{ return QDirModel::flags(index) | Qt::ItemIsUserCheckable; }
|
||||
|
||||
virtual QVariant data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (index.column() == 0 && role == Qt::CheckStateRole) {
|
||||
if (m_selectedPaths.contains(index))
|
||||
return Qt::Checked;
|
||||
|
||||
return Qt::Unchecked;
|
||||
}
|
||||
|
||||
return QDirModel::data(index, role);
|
||||
}
|
||||
|
||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (index.column() == 0 && role == Qt::CheckStateRole) {
|
||||
if (value.toBool())
|
||||
m_selectedPaths.insert(index);
|
||||
else
|
||||
m_selectedPaths.remove(index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return QDirModel::setData(index, value, role);
|
||||
}
|
||||
|
||||
void clearSelectedPaths()
|
||||
{ m_selectedPaths.clear(); }
|
||||
|
||||
QSet<QString> selectedPaths() const
|
||||
{
|
||||
QSet<QString> paths;
|
||||
|
||||
foreach (const QModelIndex &index, m_selectedPaths)
|
||||
paths.insert(filePath(index));
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
private:
|
||||
QSet<QModelIndex> m_selectedPaths;
|
||||
};
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// GenericProjectWizardDialog
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
GenericProjectWizardDialog::GenericProjectWizardDialog(QWidget *parent)
|
||||
: QWizard(parent)
|
||||
{
|
||||
@@ -130,44 +60,6 @@ GenericProjectWizardDialog::GenericProjectWizardDialog(QWidget *parent)
|
||||
m_firstPage->setPathLabel(tr("Location:"));
|
||||
|
||||
addPage(m_firstPage);
|
||||
|
||||
#if 0
|
||||
// second page
|
||||
QWizardPage *secondPage = new QWizardPage;
|
||||
secondPage->setTitle(tr("Second Page Title"));
|
||||
|
||||
QFormLayout *secondPageLayout = new QFormLayout(secondPage);
|
||||
|
||||
m_dirView = new QTreeView;
|
||||
m_dirModel = new DirModel(this);
|
||||
m_dirView->setModel(_dirModel);
|
||||
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
Core::MimeDatabase *mimeDatabase = core->mimeDatabase();
|
||||
|
||||
const QStringList suffixes = mimeDatabase->suffixes();
|
||||
|
||||
QStringList nameFilters;
|
||||
foreach (const QString &suffix, suffixes) {
|
||||
QString nameFilter;
|
||||
nameFilter.append(QLatin1String("*."));
|
||||
nameFilter.append(suffix);
|
||||
nameFilters.append(nameFilter);
|
||||
}
|
||||
|
||||
m_filesView = new QListView;
|
||||
m_filesModel = new QDirModel(this);
|
||||
m_filesModel->setNameFilters(nameFilters);
|
||||
m_filesModel->setFilter(QDir::Files);
|
||||
|
||||
connect(_dirView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
|
||||
this, SLOT(updateFilesView(QModelIndex,QModelIndex)));
|
||||
|
||||
secondPageLayout->addRow(_dirView);
|
||||
secondPageLayout->addRow(_filesView);
|
||||
|
||||
m_secondPageId = addPage(secondPage);
|
||||
#endif
|
||||
}
|
||||
|
||||
GenericProjectWizardDialog::~GenericProjectWizardDialog()
|
||||
@@ -188,50 +80,6 @@ QString GenericProjectWizardDialog::projectName() const
|
||||
return m_firstPage->name();
|
||||
}
|
||||
|
||||
void GenericProjectWizardDialog::updateFilesView(const QModelIndex ¤t,
|
||||
const QModelIndex &)
|
||||
{
|
||||
if (! current.isValid())
|
||||
m_filesView->setModel(0);
|
||||
|
||||
else {
|
||||
const QString selectedPath = m_dirModel->filePath(current);
|
||||
|
||||
if (! m_filesView->model())
|
||||
m_filesView->setModel(m_filesModel);
|
||||
|
||||
m_filesView->setRootIndex(m_filesModel->index(selectedPath));
|
||||
}
|
||||
}
|
||||
|
||||
void GenericProjectWizardDialog::initializePage(int id)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
#if 0
|
||||
if (id == m_secondPageId) {
|
||||
using namespace Utils;
|
||||
|
||||
const QString projectPath = m_pathChooser->path();
|
||||
|
||||
QDirModel *dirModel = qobject_cast<QDirModel *>(_dirView->model());
|
||||
m_dirView->setRootIndex(dirModel->index(projectPath));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GenericProjectWizardDialog::validateCurrentPage()
|
||||
{
|
||||
using namespace Utils;
|
||||
|
||||
#if 0
|
||||
if (currentId() == m_secondPageId) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return QWizard::validateCurrentPage();
|
||||
}
|
||||
|
||||
GenericProjectWizard::GenericProjectWizard()
|
||||
: Core::BaseFileWizard(parameters())
|
||||
{ }
|
||||
@@ -244,9 +92,10 @@ Core::BaseFileWizardParameters GenericProjectWizard::parameters()
|
||||
static Core::BaseFileWizardParameters parameters(ProjectWizard);
|
||||
parameters.setIcon(QIcon(":/wizards/images/console.png"));
|
||||
parameters.setName(tr("Import of Makefile-based Project"));
|
||||
parameters.setId(QLatin1String("Z.Makefile"));
|
||||
parameters.setDescription(tr("Creates a generic project, supporting any build system."));
|
||||
parameters.setCategory(QLatin1String("Projects"));
|
||||
parameters.setTrCategory(tr("Projects"));
|
||||
parameters.setCategory(QLatin1String(ProjectExplorer::Constants::PROJECT_WIZARD_CATEGORY));
|
||||
parameters.setTrCategory(QCoreApplication::translate("ProjectExplorer", ProjectExplorer::Constants::PROJECT_WIZARD_TR_CATEGORY));
|
||||
return parameters;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user