Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
8457bd68
Commit
8457bd68
authored
May 11, 2009
by
con
Browse files
Move wizard list generating helper methods to IWizard.
They don't have anything to do specifically with file wizards.
parent
fc78ae27
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/plugins/coreplugin/basefilewizard.cpp
View file @
8457bd68
...
...
@@ -578,26 +578,6 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l
return
yes
?
OverwriteOk
:
OverwriteCanceled
;
}
QList
<
IWizard
*>
BaseFileWizard
::
allWizards
()
{
return
ExtensionSystem
::
PluginManager
::
instance
()
->
getObjects
<
IWizard
>
();
}
// Utility to find all registered wizards of a certain kind
class
WizardKindPredicate
{
public:
WizardKindPredicate
(
IWizard
::
Kind
kind
)
:
m_kind
(
kind
)
{}
bool
operator
()(
const
IWizard
&
w
)
const
{
return
w
.
kind
()
==
m_kind
;
}
private:
const
IWizard
::
Kind
m_kind
;
};
QList
<
IWizard
*>
BaseFileWizard
::
findWizardsOfKind
(
Kind
kind
)
{
return
findWizards
(
WizardKindPredicate
(
kind
));
}
QString
BaseFileWizard
::
buildFileName
(
const
QString
&
path
,
const
QString
&
baseName
,
const
QString
&
extension
)
...
...
src/plugins/coreplugin/basefilewizard.h
View file @
8457bd68
...
...
@@ -151,11 +151,6 @@ public:
virtual
QStringList
runWizard
(
const
QString
&
path
,
QWidget
*
parent
);
// Utility to find all registered wizards
static
QList
<
IWizard
*>
allWizards
();
// Utility to find all registered wizards of a certain kind
static
QList
<
IWizard
*>
findWizardsOfKind
(
Kind
kind
);
// Build a file name, adding the extension unless baseName already has one
static
QString
buildFileName
(
const
QString
&
path
,
const
QString
&
baseName
,
const
QString
&
extension
);
...
...
@@ -222,20 +217,6 @@ protected:
QString
*
errorMessage
)
const
=
0
;
};
/* A utility to find all wizards supporting a view mode and matching a predicate */
template
<
class
Predicate
>
QList
<
IWizard
*>
findWizards
(
Predicate
predicate
)
{
// Filter all wizards
const
QList
<
IWizard
*>
allWizards
=
BaseFileWizard
::
allWizards
();
QList
<
IWizard
*>
rc
;
const
QList
<
IWizard
*>::
const_iterator
cend
=
allWizards
.
constEnd
();
for
(
QList
<
IWizard
*>::
const_iterator
it
=
allWizards
.
constBegin
();
it
!=
cend
;
++
it
)
if
(
predicate
(
*
(
*
it
)))
rc
.
push_back
(
*
it
);
return
rc
;
}
}
// namespace Core
#endif // BASEFILEWIZARD_H
src/plugins/coreplugin/dialogs/iwizard.cpp
View file @
8457bd68
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include
"iwizard.h"
#include
<extensionsystem/pluginmanager.h>
/*!
\class Core::IWizard
\mainclass
...
...
@@ -95,3 +126,40 @@
default path.
Returns a list of files (absolute paths) that have been created, if any.
*/
using
namespace
Core
;
/* A utility to find all wizards supporting a view mode and matching a predicate */
template
<
class
Predicate
>
QList
<
IWizard
*>
findWizards
(
Predicate
predicate
)
{
// Filter all wizards
const
QList
<
IWizard
*>
allWizards
=
IWizard
::
allWizards
();
QList
<
IWizard
*>
rc
;
const
QList
<
IWizard
*>::
const_iterator
cend
=
allWizards
.
constEnd
();
for
(
QList
<
IWizard
*>::
const_iterator
it
=
allWizards
.
constBegin
();
it
!=
cend
;
++
it
)
if
(
predicate
(
*
(
*
it
)))
rc
.
push_back
(
*
it
);
return
rc
;
}
QList
<
IWizard
*>
IWizard
::
allWizards
()
{
return
ExtensionSystem
::
PluginManager
::
instance
()
->
getObjects
<
IWizard
>
();
}
// Utility to find all registered wizards of a certain kind
class
WizardKindPredicate
{
public:
WizardKindPredicate
(
IWizard
::
Kind
kind
)
:
m_kind
(
kind
)
{}
bool
operator
()(
const
IWizard
&
w
)
const
{
return
w
.
kind
()
==
m_kind
;
}
private:
const
IWizard
::
Kind
m_kind
;
};
QList
<
IWizard
*>
IWizard
::
wizardsOfKind
(
Kind
kind
)
{
return
findWizards
(
WizardKindPredicate
(
kind
));
}
src/plugins/coreplugin/dialogs/iwizard.h
View file @
8457bd68
...
...
@@ -62,6 +62,11 @@ public:
virtual
QString
trCategory
()
const
=
0
;
virtual
QStringList
runWizard
(
const
QString
&
path
,
QWidget
*
parent
)
=
0
;
// Utility to find all registered wizards
static
QList
<
IWizard
*>
allWizards
();
// Utility to find all registered wizards of a certain kind
static
QList
<
IWizard
*>
wizardsOfKind
(
Kind
kind
);
};
}
// namespace Core
...
...
src/plugins/coreplugin/mainwindow.cpp
View file @
8457bd68
...
...
@@ -760,7 +760,7 @@ void MainWindow::registerDefaultActions()
void
MainWindow
::
newFile
()
{
showNewItemDialog
(
tr
(
"New"
,
"Title of dialog"
),
BaseFile
Wizard
::
allWizards
());
showNewItemDialog
(
tr
(
"New"
,
"Title of dialog"
),
I
Wizard
::
allWizards
());
}
void
MainWindow
::
openFile
()
...
...
src/plugins/projectexplorer/projectexplorer.cpp
View file @
8457bd68
...
...
@@ -797,7 +797,7 @@ void ProjectExplorerPlugin::newProject()
}
Core
::
ICore
::
instance
()
->
showNewItemDialog
(
tr
(
"New Project"
,
"Title of dialog"
),
Core
::
BaseFile
Wizard
::
findW
izardsOfKind
(
Core
::
IWizard
::
ProjectWizard
),
Core
::
I
Wizard
::
w
izardsOfKind
(
Core
::
IWizard
::
ProjectWizard
),
defaultLocation
);
updateActions
();
}
...
...
@@ -1641,8 +1641,8 @@ void ProjectExplorerPlugin::addNewFile()
return
;
const
QString
location
=
QFileInfo
(
m_currentNode
->
path
()).
dir
().
absolutePath
();
Core
::
ICore
::
instance
()
->
showNewItemDialog
(
tr
(
"New File"
,
"Title of dialog"
),
Core
::
BaseFile
Wizard
::
findW
izardsOfKind
(
Core
::
IWizard
::
FileWizard
)
+
Core
::
BaseFile
Wizard
::
findW
izardsOfKind
(
Core
::
IWizard
::
ClassWizard
),
Core
::
I
Wizard
::
w
izardsOfKind
(
Core
::
IWizard
::
FileWizard
)
+
Core
::
I
Wizard
::
w
izardsOfKind
(
Core
::
IWizard
::
ClassWizard
),
location
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment