forked from teamnwah/openmw-tes3coop
Modified components widget so the checked items can be stored for all pages to access
This commit is contained in:
parent
77fe73799a
commit
30710bad70
8 changed files with 108 additions and 7 deletions
|
@ -10,6 +10,8 @@ set(WIZARD
|
||||||
main.cpp
|
main.cpp
|
||||||
mainwizard.cpp
|
mainwizard.cpp
|
||||||
methodselectionpage.cpp
|
methodselectionpage.cpp
|
||||||
|
|
||||||
|
utils/componentlistwidget.cpp
|
||||||
)
|
)
|
||||||
# if(NOT WIN32)
|
# if(NOT WIN32)
|
||||||
# LIST(APPEND WIZARD unshieldthread.cpp)
|
# LIST(APPEND WIZARD unshieldthread.cpp)
|
||||||
|
@ -26,6 +28,8 @@ set(WIZARD_HEADER
|
||||||
languageselectionpage.hpp
|
languageselectionpage.hpp
|
||||||
mainwizard.hpp
|
mainwizard.hpp
|
||||||
methodselectionpage.hpp
|
methodselectionpage.hpp
|
||||||
|
|
||||||
|
utils/componentlistwidget.hpp
|
||||||
)
|
)
|
||||||
# if(NOT WIN32)
|
# if(NOT WIN32)
|
||||||
# LIST(APPEND WIZARD_HEADER unshieldthread.hpp)
|
# LIST(APPEND WIZARD_HEADER unshieldthread.hpp)
|
||||||
|
@ -44,6 +48,8 @@ set(WIZARD_HEADER_MOC
|
||||||
languageselectionpage.hpp
|
languageselectionpage.hpp
|
||||||
mainwizard.hpp
|
mainwizard.hpp
|
||||||
methodselectionpage.hpp
|
methodselectionpage.hpp
|
||||||
|
|
||||||
|
utils/componentlistwidget.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# if(NOT WIN32)
|
# if(NOT WIN32)
|
||||||
|
|
|
@ -14,8 +14,16 @@ Wizard::ComponentSelectionPage::ComponentSelectionPage(MainWizard *wizard) :
|
||||||
setCommitPage(true);
|
setCommitPage(true);
|
||||||
setButtonText(QWizard::CommitButton, tr("&Install"));
|
setButtonText(QWizard::CommitButton, tr("&Install"));
|
||||||
|
|
||||||
connect(componentsList, SIGNAL(itemChanged(QListWidgetItem*)),
|
registerField("installation.components", componentsList);
|
||||||
this, SLOT(updateButton(QListWidgetItem*)));
|
|
||||||
|
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)
|
void Wizard::ComponentSelectionPage::updateButton(QListWidgetItem *item)
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace Wizard
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateButton(QListWidgetItem *item);
|
void updateButton(QListWidgetItem *item);
|
||||||
|
void debugMe(QString &text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainWizard *mWizard;
|
MainWizard *mWizard;
|
||||||
|
|
|
@ -14,9 +14,11 @@ Wizard::InstallationPage::InstallationPage(MainWizard *wizard) :
|
||||||
void Wizard::InstallationPage::initializePage()
|
void Wizard::InstallationPage::initializePage()
|
||||||
{
|
{
|
||||||
QString path = field("installation.path").toString();
|
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
|
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
|
// Set the property for comboboxes to the text instead of index
|
||||||
setDefaultProperty("QComboBox", "currentText", "currentIndexChanged");
|
setDefaultProperty("QComboBox", "currentText", "currentIndexChanged");
|
||||||
|
|
||||||
|
setDefaultProperty("ComponentListWidget", "mCheckedItems", "checkedItemsChanged");
|
||||||
|
|
||||||
setupInstallations();
|
setupInstallations();
|
||||||
setupPages();
|
setupPages();
|
||||||
}
|
}
|
||||||
|
|
46
apps/wizard/utils/componentlistwidget.cpp
Normal file
46
apps/wizard/utils/componentlistwidget.cpp
Normal file
|
@ -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);
|
||||||
|
|
||||||
|
}
|
29
apps/wizard/utils/componentlistwidget.hpp
Normal file
29
apps/wizard/utils/componentlistwidget.hpp
Normal file
|
@ -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>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>454</width>
|
<width>448</width>
|
||||||
<height>393</height>
|
<height>387</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="componentsList"/>
|
<widget class="ComponentListWidget" name="componentsList"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
|
@ -55,6 +55,13 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>ComponentListWidget</class>
|
||||||
|
<extends>QListWidget</extends>
|
||||||
|
<header>apps/wizard/utils/componentlistwidget.hpp</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in a new issue