dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
iwizard.cpp
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #include "iwizard.h"
29 
31 
128 using namespace Core;
129 
130 /* A utility to find all wizards supporting a view mode and matching a predicate */
131 template <class Predicate>
132 QList<IWizard *> findWizards(Predicate predicate)
133 {
134  // Filter all wizards
135  const QList<IWizard *> allWizards = IWizard::allWizards();
136  QList<IWizard *> rc;
137  const QList<IWizard *>::const_iterator cend = allWizards.constEnd();
138  for (QList<IWizard *>::const_iterator it = allWizards.constBegin(); it != cend; ++it)
139  if (predicate(*(*it)))
140  rc.push_back(*it);
141  return rc;
142 }
143 
145 {
146  return ExtensionSystem::PluginManager::instance()->getObjects<IWizard>();
147 }
148 
149 // Utility to find all registered wizards of a certain kind
150 
152 {
153 public:
155  : m_kind(kind)
156  {
157  }
158  bool operator()(const IWizard &w) const { return w.kind() == m_kind; }
159 private:
160  const IWizard::Kind m_kind;
161 };
162 
164 {
165  return findWizards(WizardKindPredicate(kind));
166 }
bool operator()(const IWizard &w) const
Definition: iwizard.cpp:158
virtual Kind kind() const =0
QList< IWizard * > findWizards(Predicate predicate)
Definition: iwizard.cpp:132
static QList< IWizard * > allWizards()
Definition: iwizard.cpp:144
The class IWizard is the base class for all wizards (for example shown in {File | New})...
Definition: iwizard.h:40
Definition: icore.h:39
WizardKindPredicate(IWizard::Kind kind)
Definition: iwizard.cpp:154
static QList< IWizard * > wizardsOfKind(Kind kind)
Definition: iwizard.cpp:163