Modified components widget so the checked items can be stored for all pages to access

loadfix
pvdk 11 years ago
parent 77fe73799a
commit 30710bad70

@ -10,6 +10,8 @@ set(WIZARD
main.cpp
mainwizard.cpp
methodselectionpage.cpp
utils/componentlistwidget.cpp
)
# if(NOT WIN32)
# LIST(APPEND WIZARD unshieldthread.cpp)
@ -26,6 +28,8 @@ set(WIZARD_HEADER
languageselectionpage.hpp
mainwizard.hpp
methodselectionpage.hpp
utils/componentlistwidget.hpp
)
# if(NOT WIN32)
# LIST(APPEND WIZARD_HEADER unshieldthread.hpp)
@ -44,6 +48,8 @@ set(WIZARD_HEADER_MOC
languageselectionpage.hpp
mainwizard.hpp
methodselectionpage.hpp
utils/componentlistwidget.hpp
)
# if(NOT WIN32)

@ -14,8 +14,16 @@ Wizard::ComponentSelectionPage::ComponentSelectionPage(MainWizard *wizard) :
setCommitPage(true);
setButtonText(QWizard::CommitButton, tr("&Install"));
connect(componentsList, SIGNAL(itemChanged(QListWidgetItem*)),
this, SLOT(updateButton(QListWidgetItem*)));
registerField("installation.components", componentsList);
connect(componentsList, SIGNAL(itemChanged(QListWidgetItem *)),
this, SLOT(updateButton(QListWidgetItem *)));
}
void Wizard::ComponentSelectionPage::debugMe(QString &text)
{
qDebug() << "Debug Me" << text;
}
void Wizard::ComponentSelectionPage::updateButton(QListWidgetItem *item)

@ -19,6 +19,7 @@ namespace Wizard
private slots:
void updateButton(QListWidgetItem *item);
void debugMe(QString &text);
private:
MainWizard *mWizard;

@ -14,9 +14,11 @@ Wizard::InstallationPage::InstallationPage(MainWizard *wizard) :
void Wizard::InstallationPage::initializePage()
{
QString path = field("installation.path").toString();
QStringList components = field("installation.components").toStringList();
logTextEdit->append(QString("Installing to %1").arg(path));
logTextEdit->append(QString("Installing %1.").arg(components.join(", ")));
qDebug() << "installing to: " << field("installation.path").toString();
logTextEdit->setText(QString("Installing to %1").arg(field("installation.path").toString()));
}
int Wizard::InstallationPage::nextId() const

@ -28,6 +28,8 @@ Wizard::MainWizard::MainWizard(QWidget *parent) :
// Set the property for comboboxes to the text instead of index
setDefaultProperty("QComboBox", "currentText", "currentIndexChanged");
setDefaultProperty("ComponentListWidget", "mCheckedItems", "checkedItemsChanged");
setupInstallations();
setupPages();
}

@ -0,0 +1,46 @@
#include "componentlistwidget.hpp"
#include <QDebug>
#include <QStringList>
ComponentListWidget::ComponentListWidget(QWidget *parent) :
QListWidget(parent)
{
mCheckedItems = QStringList();
connect(this, SIGNAL(itemChanged(QListWidgetItem *)),
this, SLOT(updateCheckedItems(QListWidgetItem *)));
}
void ComponentListWidget::addItem(QListWidgetItem *item)
{
// The model does not emit a dataChanged signal when items are added
// So we need to update manually
QListWidget::insertItem(count(), item);
updateCheckedItems(item);
}
QStringList ComponentListWidget::checkedItems()
{
mCheckedItems.removeDuplicates();
return mCheckedItems;
}
void ComponentListWidget::updateCheckedItems(QListWidgetItem *item)
{
QString text = item->text();
if (item->checkState() == Qt::Checked) {
if (!mCheckedItems.contains(text))
mCheckedItems.append(text);
} else {
if (mCheckedItems.contains(text))
mCheckedItems.removeAll(text);
}
mCheckedItems.removeDuplicates();
emit checkedItemsChanged(mCheckedItems);
}

@ -0,0 +1,29 @@
#ifndef COMPONENTLISTWIDGET_HPP
#define COMPONENTLISTWIDGET_HPP
#include <QListWidget>
class ComponentListWidget : public QListWidget
{
Q_OBJECT
Q_PROPERTY(QStringList mCheckedItems READ checkedItems)
public:
ComponentListWidget(QWidget *parent = 0);
QStringList mCheckedItems;
QStringList checkedItems();
void addItem(QListWidgetItem *item);
signals:
void checkedItemsChanged(const QStringList &items);
private slots:
void updateCheckedItems(QListWidgetItem *item);
};
#endif // COMPONENTLISTWIDGET_HPP

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>393</height>
<width>448</width>
<height>387</height>
</rect>
</property>
<property name="windowTitle">
@ -38,7 +38,7 @@
</widget>
</item>
<item>
<widget class="QListWidget" name="componentsList"/>
<widget class="ComponentListWidget" name="componentsList"/>
</item>
<item>
<spacer name="verticalSpacer">
@ -55,6 +55,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ComponentListWidget</class>
<extends>QListWidget</extends>
<header>apps/wizard/utils/componentlistwidget.hpp</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

Loading…
Cancel
Save