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:
Friedemann Kleint
2009-11-27 10:33:24 +01:00
parent 4827ba9dfb
commit 0e554fac91
35 changed files with 163 additions and 343 deletions

View File

@@ -36,6 +36,7 @@
#include <QtGui/QHeaderView>
#include <QtGui/QPushButton>
#include <QtCore/QDebug>
Q_DECLARE_METATYPE(Core::IWizard*)
@@ -70,10 +71,20 @@ NewDialog::NewDialog(QWidget *parent) :
connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
void NewDialog::setWizards(const QList<IWizard*> wizards)
// Sort by category. id
bool wizardLessThan(const IWizard *w1, const IWizard *w2)
{
if (const int cc = w1->category().compare(w2->category()))
return cc < 0;
return w1->id().compare(w2->id()) < 0;
}
void NewDialog::setWizards(QList<IWizard*> wizards)
{
typedef QMap<QString, QTreeWidgetItem *> CategoryItemMap;
qStableSort(wizards.begin(), wizards.end(), wizardLessThan);
CategoryItemMap categories;
QVariant wizardPtr;