Skip to content
Snippets Groups Projects
Commit ecbcbb07 authored by Jarek Kobus's avatar Jarek Kobus
Browse files

Handle property nonlinear wizards


Reviewed-by: default avatardt <qtc-committer@nokia.com>
Task-number: QTCREATORBUG-2511
parent 0a5cb17f
No related branches found
No related tags found
No related merge requests found
......@@ -89,6 +89,7 @@ private slots:
void slotItemRemoved(WizardProgressItem *item);
void slotItemChanged(WizardProgressItem *item);
void slotNextItemsChanged(WizardProgressItem *item, const QList<WizardProgressItem *> &nextItems);
void slotNextShownItemChanged(WizardProgressItem *item, WizardProgressItem *nextItem);
void slotStartItemChanged(WizardProgressItem *item);
void slotCurrentItemChanged(WizardProgressItem *item);
......@@ -135,6 +136,8 @@ LinearProgressWidget::LinearProgressWidget(WizardProgress *progress, QWidget *pa
this, SLOT(slotItemChanged(WizardProgressItem *)));
connect(m_wizardProgress, SIGNAL(nextItemsChanged(WizardProgressItem *, const QList<WizardProgressItem *> &)),
this, SLOT(slotNextItemsChanged(WizardProgressItem *, const QList<WizardProgressItem *> &)));
connect(m_wizardProgress, SIGNAL(nextShownItemChanged(WizardProgressItem *, WizardProgressItem *)),
this, SLOT(slotNextShownItemChanged(WizardProgressItem *, WizardProgressItem *)));
connect(m_wizardProgress, SIGNAL(startItemChanged(WizardProgressItem *)),
this, SLOT(slotStartItemChanged(WizardProgressItem *)));
connect(m_wizardProgress, SIGNAL(currentItemChanged(WizardProgressItem *)),
......@@ -188,6 +191,13 @@ void LinearProgressWidget::slotNextItemsChanged(WizardProgressItem *item, const
recreateLayout();
}
void LinearProgressWidget::slotNextShownItemChanged(WizardProgressItem *item, WizardProgressItem *nextItem)
{
Q_UNUSED(nextItem)
if (m_visibleItems.contains(item))
recreateLayout();
}
void LinearProgressWidget::slotStartItemChanged(WizardProgressItem *item)
{
Q_UNUSED(item)
......@@ -471,6 +481,7 @@ public:
QList<int> m_pages;
QList<WizardProgressItem *> m_nextItems;
QList<WizardProgressItem *> m_prevItems;
WizardProgressItem *m_nextShownItem;
};
bool WizardProgressPrivate::isNextItem(WizardProgressItem *item, WizardProgressItem *nextItem) const
......@@ -553,8 +564,8 @@ void WizardProgressPrivate::updateReachableItems()
}
if (!item)
return;
while (item->nextItems().count() == 1) {
item = item->nextItems().first();
while (item->nextShownItem()) {
item = item->nextShownItem();
m_reachableItems.append(item);
}
}
......@@ -774,6 +785,7 @@ WizardProgressItem::WizardProgressItem(WizardProgress *progress, const QString &
d_ptr->m_title = title;
d_ptr->m_titleWordWrap = false;
d_ptr->m_wizardProgress = progress;
d_ptr->m_nextShownItem = 0;
}
WizardProgressItem::~WizardProgressItem()
......@@ -816,6 +828,9 @@ void WizardProgressItem::setNextItems(const QList<WizardProgressItem *> &items)
if (d->m_nextItems == items) // nothing changes
return;
if (!items.contains(d->m_nextShownItem))
setNextShownItem(0);
// update prev items (remove this item from the old next items)
for (int i = 0; i < d->m_nextItems.count(); i++) {
WizardProgressItem *nextItem = d->m_nextItems.at(i);
......@@ -829,9 +844,13 @@ void WizardProgressItem::setNextItems(const QList<WizardProgressItem *> &items)
WizardProgressItem *nextItem = d->m_nextItems.at(i);
nextItem->d_ptr->m_prevItems.append(this);
}
d->m_wizardProgress->d_ptr->updateReachableItems();
emit d->m_wizardProgress->nextItemsChanged(this, items);
if (items.count() == 1)
setNextShownItem(items.first());
}
QList<WizardProgressItem *> WizardProgressItem::nextItems() const
......@@ -841,6 +860,30 @@ QList<WizardProgressItem *> WizardProgressItem::nextItems() const
return d->m_nextItems;
}
void WizardProgressItem::setNextShownItem(WizardProgressItem *item)
{
Q_D(WizardProgressItem);
if (d->m_nextShownItem == item) // nothing changes
return;
if (item && !d->m_nextItems.contains(item)) // the "item" is not a one of next items
return;
d->m_nextShownItem = item;
d->m_wizardProgress->d_ptr->updateReachableItems();
emit d->m_wizardProgress->nextShownItemChanged(this, item);
}
WizardProgressItem *WizardProgressItem::nextShownItem() const
{
Q_D(const WizardProgressItem);
return d->m_nextShownItem;
}
bool WizardProgressItem::isFinalItem() const
{
return nextItems().isEmpty();
......
......@@ -112,6 +112,7 @@ Q_SIGNALS:
void itemAdded(WizardProgressItem *item);
void itemRemoved(WizardProgressItem *item);
void nextItemsChanged(WizardProgressItem *item, const QList<WizardProgressItem *> &items);
void nextShownItemChanged(WizardProgressItem *item, WizardProgressItem *nextShownItem);
void startItemChanged(WizardProgressItem *item);
private:
......@@ -138,6 +139,8 @@ public:
QList<int> pages() const;
void setNextItems(const QList<WizardProgressItem *> &items);
QList<WizardProgressItem *> nextItems() const;
void setNextShownItem(WizardProgressItem *item);
WizardProgressItem *nextShownItem() const;
bool isFinalItem() const; // return nextItems().isEmpty();
void setTitle(const QString &title);
......
......@@ -58,29 +58,18 @@ AddLibraryWizard::AddLibraryWizard(const QString &fileName, QWidget *parent) :
Utils::Wizard(parent), m_proFile(fileName)
{
setWindowTitle(tr("Add Library"));
setAutomaticProgressCreationEnabled(false);
m_libraryTypePage = new LibraryTypePage(this);
m_detailsPage = new DetailsPage(this);
m_summaryPage = new SummaryPage(this);
setPage(LibraryTypePageId, m_libraryTypePage);
setPage(DetailsPageId, m_detailsPage);
setPage(SummaryPageId, m_summaryPage);
const int libraryTypePageId = addPage(m_libraryTypePage);
const int detailsPageId = addPage(m_detailsPage);
const int summaryPageId = addPage(m_summaryPage);
Utils::WizardProgress *progress = wizardProgress();
Utils::WizardProgressItem *kindItem = progress->addItem(tr("Type"));
Utils::WizardProgressItem *detailsItem = progress->addItem(tr("Details"));
Utils::WizardProgressItem *summaryItem = progress->addItem(tr("Summary"));
kindItem->addPage(LibraryTypePageId);
detailsItem->addPage(DetailsPageId);
summaryItem->addPage(SummaryPageId);
kindItem->setNextItems(QList<Utils::WizardProgressItem *>() << detailsItem);
detailsItem->setNextItems(QList<Utils::WizardProgressItem *>() << summaryItem);
setStartId(LibraryTypePageId);
progress->item(libraryTypePageId)->setTitle(tr("Type"));
progress->item(detailsPageId)->setTitle(tr("Details"));
progress->item(summaryPageId)->setTitle(tr("Summary"));
}
AddLibraryWizard::~AddLibraryWizard()
......@@ -177,11 +166,6 @@ AddLibraryWizard::LibraryKind LibraryTypePage::libraryKind() const
return AddLibraryWizard::PackageLibrary;
}
int LibraryTypePage::nextId() const
{
return AddLibraryWizard::DetailsPageId;
}
/////////////
DetailsPage::DetailsPage(AddLibraryWizard *parent)
......@@ -198,11 +182,6 @@ bool DetailsPage::isComplete() const
return false;
}
int DetailsPage::nextId() const
{
return AddLibraryWizard::SummaryPageId;
}
QString DetailsPage::snippet() const
{
if (m_libraryDetailsController)
......
......@@ -27,12 +27,6 @@ class AddLibraryWizard : public Utils::Wizard
{
Q_OBJECT
public:
enum PageId {
LibraryTypePageId,
DetailsPageId,
SummaryPageId
};
enum LibraryKind {
InternalLibrary,
ExternalLibrary,
......@@ -85,7 +79,6 @@ class LibraryTypePage : public QWizardPage
public:
LibraryTypePage(AddLibraryWizard *parent);
AddLibraryWizard::LibraryKind libraryKind() const;
virtual int nextId() const;
private:
QRadioButton *m_internalRadio;
......@@ -100,7 +93,6 @@ class DetailsPage : public QWizardPage
public:
DetailsPage(AddLibraryWizard *parent);
virtual void initializePage();
virtual int nextId() const;
virtual bool isComplete() const;
QString snippet() const;
......
......@@ -49,16 +49,25 @@ AbstractMobileAppWizardDialog::AbstractMobileAppWizardDialog(QWidget *parent)
m_targetsPage = new TargetSetupPage;
resize(900, 450);
m_targetsPage->setImportDirectoryBrowsingEnabled(false);
addPageWithTitle(m_targetsPage, tr("Qt Versions"));
m_targetsPageId = addPageWithTitle(m_targetsPage, tr("Qt Versions"));
m_genericOptionsPage = new MobileAppWizardGenericOptionsPage;
m_genericOptionsPageId = addPageWithTitle(m_genericOptionsPage,
tr("Generic Mobile Application Options"));
tr("Mobile Options"));
m_symbianOptionsPage = new MobileAppWizardSymbianOptionsPage;
m_symbianOptionsPageId = addPageWithTitle(m_symbianOptionsPage,
tr("Symbian-specific Options"));
QLatin1String(" ") + tr("Symbian Specific"));
m_maemoOptionsPage = new MobileAppWizardMaemoOptionsPage;
m_maemoOptionsPageId = addPageWithTitle(m_maemoOptionsPage,
tr("Maemo-specific Options"));
QLatin1String(" ") + tr("Maemo Specific"));
m_targetItem = wizardProgress()->item(m_targetsPageId);
m_genericItem = wizardProgress()->item(m_genericOptionsPageId);
m_symbianItem = wizardProgress()->item(m_symbianOptionsPageId);
m_maemoItem = wizardProgress()->item(m_maemoOptionsPageId);
m_targetItem->setNextShownItem(0);
m_genericItem->setNextShownItem(0);
m_symbianItem->setNextShownItem(0);
}
int AbstractMobileAppWizardDialog::addPageWithTitle(QWizardPage *page, const QString &title)
......@@ -96,11 +105,52 @@ int AbstractMobileAppWizardDialog::nextId() const
}
}
void AbstractMobileAppWizardDialog::initializePage(int id)
{
if (id == startId()) {
m_targetItem->setNextItems(QList<Utils::WizardProgressItem *>() << m_genericItem << itemOfNextGenericPage());
m_genericItem->setNextItems(QList<Utils::WizardProgressItem *>() << m_symbianItem << m_maemoItem);
m_symbianItem->setNextItems(QList<Utils::WizardProgressItem *>() << m_maemoItem << itemOfNextGenericPage());
} else if (id == m_genericOptionsPageId) {
const bool symbianTargetSelected =
m_targetsPage->isTargetSelected(QLatin1String(Constants::S60_EMULATOR_TARGET_ID))
|| m_targetsPage->isTargetSelected(QLatin1String(Constants::S60_DEVICE_TARGET_ID));
const bool maemoTargetSelected =
m_targetsPage->isTargetSelected(QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID));
QList<Utils::WizardProgressItem *> order;
order << m_genericItem;
if (symbianTargetSelected)
order << m_symbianItem;
if (maemoTargetSelected)
order << m_maemoItem;
order << itemOfNextGenericPage();
for (int i = 0; i < order.count() - 1; i++)
order.at(i)->setNextShownItem(order.at(i + 1));
}
BaseProjectWizardDialog::initializePage(id);
}
void AbstractMobileAppWizardDialog::cleanupPage(int id)
{
if (id == m_genericOptionsPageId) {
m_genericItem->setNextShownItem(0);
m_symbianItem->setNextShownItem(0);
}
BaseProjectWizardDialog::cleanupPage(id);
}
int AbstractMobileAppWizardDialog::idOfNextGenericPage() const
{
return pageIds().at(pageIds().indexOf(m_maemoOptionsPageId) + 1);
}
Utils::WizardProgressItem *AbstractMobileAppWizardDialog::itemOfNextGenericPage() const
{
return wizardProgress()->item(idOfNextGenericPage());
}
AbstractMobileAppWizard::AbstractMobileAppWizard(const Core::BaseFileWizardParameters &params,
QObject *parent) : Core::BaseFileWizard(params, parent)
{
......
......@@ -55,15 +55,23 @@ public:
protected:
int addPageWithTitle(QWizardPage *page, const QString &title);
virtual void initializePage(int id);
virtual void cleanupPage(int id);
private:
virtual int nextId() const;
int idOfNextGenericPage() const;
Utils::WizardProgressItem *itemOfNextGenericPage() const;
int m_genericOptionsPageId;
int m_symbianOptionsPageId;
int m_maemoOptionsPageId;
int m_targetsPageId;
Utils::WizardProgressItem *m_targetItem;
Utils::WizardProgressItem *m_genericItem;
Utils::WizardProgressItem *m_symbianItem;
Utils::WizardProgressItem *m_maemoItem;
};
class AbstractMobileAppWizard : public Core::BaseFileWizard
......
......@@ -152,7 +152,18 @@ LibraryWizardDialog::LibraryWizardDialog(const QString &templateName,
setIntroDescription(tr("This wizard generates a C++ library project."));
m_targetPageId = addTargetSetupPage();
Utils::WizardProgressItem *targetItem = wizardProgress()->item(m_targetPageId);
m_mobilePageId = addPage(m_mobilePage);
Utils::WizardProgressItem *mobileItem = wizardProgress()->item(m_mobilePageId);
mobileItem->setTitle(QLatin1String(" ") + tr("Symbian Specific"));
m_modulesPageId = addModulesPage();
Utils::WizardProgressItem *modulesItem = wizardProgress()->item(m_modulesPageId);
targetItem->setNextItems(QList<Utils::WizardProgressItem *>()
<< mobileItem << modulesItem);
targetItem->setNextShownItem(0);
m_filesPage->setNamespacesEnabled(true);
m_filesPage->setFormFileInputVisible(false);
......@@ -161,9 +172,6 @@ LibraryWizardDialog::LibraryWizardDialog(const QString &templateName,
m_filesPageId = addPage(m_filesPage);
wizardProgress()->item(m_filesPageId)->setTitle(tr("Details"));
m_mobilePageId = addPage(m_mobilePage);
wizardProgress()->item(m_mobilePageId)->setTitle(tr("Symbian Specific"));
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotCurrentIdChanged(int)));
foreach (QWizardPage *p, extensionPages)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment