summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2013-03-22 18:54:04 +0100
committerTannin <devnull@localhost>2013-03-22 18:54:04 +0100
commit24cc3861912cc33235af587d4f4feb538c1054dc (patch)
treee8d3c1b042bc116f25a94c01121706d4efb2a5ea /src
parent0a19f0433992be5f9791c8869380d09cd06b66b8 (diff)
removed obsolete files
Diffstat (limited to 'src')
-rw-r--r--src/baincomplexinstallerdialog.cpp124
-rw-r--r--src/baincomplexinstallerdialog.h95
-rw-r--r--src/fomodinstallerdialog.cpp959
-rw-r--r--src/fomodinstallerdialog.h214
-rw-r--r--src/installdialog.cpp308
-rw-r--r--src/installdialog.h127
-rw-r--r--src/simpleinstalldialog.cpp55
-rw-r--r--src/simpleinstalldialog.h69
8 files changed, 0 insertions, 1951 deletions
diff --git a/src/baincomplexinstallerdialog.cpp b/src/baincomplexinstallerdialog.cpp
deleted file mode 100644
index f1440ff3..00000000
--- a/src/baincomplexinstallerdialog.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
-Copyright (C) 2012 Sebastian Herbord. All rights reserved.
-
-This file is part of Mod Organizer.
-
-Mod Organizer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Mod Organizer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "baincomplexinstallerdialog.h"
-#include "textviewer.h"
-#include "ui_baincomplexinstallerdialog.h"
-
-#include <QDir>
-
-
-using namespace MOBase;
-
-
-BainComplexInstallerDialog::BainComplexInstallerDialog(DirectoryTree *tree, const QString &modName, bool hasPackageTXT, QWidget *parent)
- : TutorableDialog("BainInstaller", parent), ui(new Ui::BainComplexInstallerDialog), m_Manual(false)
-{
- ui->setupUi(this);
-
- ui->nameEdit->setText(modName);
-
- for (DirectoryTree::const_node_iterator iter = tree->nodesBegin(); iter != tree->nodesEnd(); ++iter) {
- const QString &dirName = (*iter)->getData().name;
- if ((dirName.compare("fomod", Qt::CaseInsensitive) == 0) ||
- (dirName.startsWith("--"))) {
- continue;
- }
-
- QListWidgetItem *item = new QListWidgetItem(ui->optionsList);
- item->setText((*iter)->getData().name);
- item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
- item->setCheckState(item->text().mid(0, 2) == "00" ? Qt::Checked : Qt::Unchecked);
- item->setData(Qt::UserRole, qVariantFromValue((void*)(*iter)));
- ui->optionsList->addItem(item);
- }
-
- ui->packageBtn->setEnabled(hasPackageTXT);
-}
-
-
-BainComplexInstallerDialog::~BainComplexInstallerDialog()
-{
- delete ui;
-}
-
-
-QString BainComplexInstallerDialog::getName() const
-{
- return ui->nameEdit->text();
-}
-
-
-void BainComplexInstallerDialog::moveTreeUp(DirectoryTree *target, DirectoryTree::Node *child)
-{
- for (DirectoryTree::const_node_iterator iter = child->nodesBegin();
- iter != child->nodesEnd();) {
- target->addNode(*iter, true);
- iter = child->detach(iter);
- }
-
- for (DirectoryTree::const_leaf_reverse_iterator iter = child->leafsRBegin();
- iter != child->leafsREnd(); ++iter) {
- target->addLeaf(*iter);
- }
-}
-
-
-DirectoryTree *BainComplexInstallerDialog::updateTree(DirectoryTree *tree)
-{
- DirectoryTree *newTree = new DirectoryTree;
-
- for (DirectoryTree::const_node_reverse_iterator iter = tree->nodesRBegin();
- iter != tree->nodesREnd();) {
- QList<QListWidgetItem*> items = ui->optionsList->findItems((*iter)->getData().name, Qt::MatchFixedString);
- if ((items.count() == 1) && (items.at(0)->checkState() == Qt::Checked)) {
- moveTreeUp(newTree, *iter);
- }
- iter = tree->erase(iter);
- }
-
- return newTree;
-}
-
-
-void BainComplexInstallerDialog::on_okBtn_clicked()
-{
- this->accept();
-}
-
-
-void BainComplexInstallerDialog::on_cancelBtn_clicked()
-{
- this->reject();
-}
-
-
-void BainComplexInstallerDialog::on_manualBtn_clicked()
-{
- m_Manual = true;
- this->reject();
-}
-
-void BainComplexInstallerDialog::on_packageBtn_clicked()
-{
- TextViewer viewer("package.txt", this);
- viewer.setDescription("");
- viewer.addFile(QDir::tempPath().append("/package.txt"), false);
- viewer.exec();
-}
diff --git a/src/baincomplexinstallerdialog.h b/src/baincomplexinstallerdialog.h
deleted file mode 100644
index 136a4e54..00000000
--- a/src/baincomplexinstallerdialog.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
-Copyright (C) 2012 Sebastian Herbord. All rights reserved.
-
-This file is part of Mod Organizer.
-
-Mod Organizer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Mod Organizer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef BAINCOMPLEXINSTALLERDIALOG_H
-#define BAINCOMPLEXINSTALLERDIALOG_H
-
-
-#include "mytree.h"
-#include "installdialog.h"
-#include "tutorabledialog.h"
-
-
-namespace Ui {
-class BainComplexInstallerDialog;
-}
-
-
-/**
- * @brief Dialog to choose from options offered by a (complex) bain package
- **/
-class BainComplexInstallerDialog : public MOBase::TutorableDialog
-{
- Q_OBJECT
-
-public:
- /**
- * @brief Constructor
- *
- * @param tree the directory tree of the archive. The caller is resonsible to verify this actually qualifies as a bain installer
- * @param modName proposed name for the mod. The dialog allows the user to change this
- * @param hasPackageTXT set to true if a package.txt is available for this archive. The file has to be unpacked to QDir::tempPath before displaying the dialog!
- * @param parent parent widget
- **/
- explicit BainComplexInstallerDialog(MOBase::DirectoryTree *tree, const QString &modName, bool hasPackageTXT, QWidget *parent);
- ~BainComplexInstallerDialog();
-
- /**
- * @return bool true if the user requested the manual dialog
- **/
- bool manualRequested() const { return m_Manual; }
-
- /**
- * @return QString the (user-modified) name to be used for the mod
- **/
- QString getName() const;
-
- /**
- * @brief retrieve the updated archive tree from the dialog. The caller is responsible to delete the returned tree.
- *
- * @note This call is destructive on the input tree!
- *
- * @param tree input tree. (TODO isn't this the same as the tree passed in the constructor?)
- * @return DataTree* a new tree with only the selected options and directories arranged correctly. The caller takes custody of this pointer!
- **/
- MOBase::DirectoryTree *updateTree(MOBase::DirectoryTree *tree);
-
-private slots:
-
- void on_manualBtn_clicked();
-
- void on_okBtn_clicked();
-
- void on_cancelBtn_clicked();
-
- void on_packageBtn_clicked();
-
-private:
-
- void moveTreeUp(MOBase::DirectoryTree *target, MOBase::DirectoryTree::Node *child);
-
-private:
-
- Ui::BainComplexInstallerDialog *ui;
-
- bool m_Manual;
-
-};
-
-#endif // BAINCOMPLEXINSTALLERDIALOG_H
diff --git a/src/fomodinstallerdialog.cpp b/src/fomodinstallerdialog.cpp
deleted file mode 100644
index 97476092..00000000
--- a/src/fomodinstallerdialog.cpp
+++ /dev/null
@@ -1,959 +0,0 @@
-/*
-Copyright (C) 2012 Sebastian Herbord. All rights reserved.
-
-This file is part of Mod Organizer.
-
-Mod Organizer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Mod Organizer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "fomodinstallerdialog.h"
-#include "report.h"
-#include "utility.h"
-#include "ui_fomodinstallerdialog.h"
-
-#include <QFile>
-#include <QDir>
-#include <QImage>
-#include <QCheckBox>
-#include <QRadioButton>
-#include <QScrollArea>
-#include <Shellapi.h>
-
-
-using namespace MOBase;
-
-
-bool ControlsAscending(QAbstractButton *LHS, QAbstractButton *RHS)
-{
- return LHS->text() < RHS->text();
-}
-
-
-bool ControlsDescending(QAbstractButton *LHS, QAbstractButton *RHS)
-{
- return LHS->text() > RHS->text();
-}
-
-
-bool PagesAscending(QGroupBox *LHS, QGroupBox *RHS)
-{
- return LHS->title() < RHS->title();
-}
-
-
-bool PagesDescending(QGroupBox *LHS, QGroupBox *RHS)
-{
- return LHS->title() > RHS->title();
-}
-
-
-FomodInstallerDialog::FomodInstallerDialog(const QString &modName, bool nameWasGuessed, const QString &fomodPath, QWidget *parent)
- : QDialog(parent), ui(new Ui::FomodInstallerDialog), m_NameWasGuessed(nameWasGuessed), m_FomodPath(fomodPath), m_Manual(false)
-{
- ui->setupUi(this);
- ui->nameEdit->setText(modName);
-}
-
-FomodInstallerDialog::~FomodInstallerDialog()
-{
- delete ui;
-}
-
-
-int FomodInstallerDialog::bomOffset(const QByteArray &buffer)
-{
- static const unsigned char BOM_UTF8[] = { 0xEF, 0xBB, 0xBF };
- static const unsigned char BOM_UTF16BE[] = { 0xFE, 0xFF };
- static const unsigned char BOM_UTF16LE[] = { 0xFF, 0xFE };
-
- if (buffer.startsWith(reinterpret_cast<const char*>(BOM_UTF8))) return 3;
- if (buffer.startsWith(reinterpret_cast<const char*>(BOM_UTF16BE)) ||
- buffer.startsWith(reinterpret_cast<const char*>(BOM_UTF16LE))) return 2;
-
- return 0;
-}
-
-#pragma message("implement module dependencies->file dependencies")
-
-void FomodInstallerDialog::initData()
-{
- { // parse provided package information
- QFile file(QDir::tempPath().append("/info.xml"));
- if (file.open(QIODevice::ReadOnly)) {
- // nmm allows files with wrong encoding and of course there are now files with broken
- // so, let's do as nmm does and ignore the standard. yay
- QByteArray header = file.readLine();
- if (strncmp(header.constData() + bomOffset(header), "<?", 2) != 0) {
- // not a header, rewind
- file.seek(0);
- }
- parseInfo(file.readAll());
- }
- file.close();
- }
-
- QImage screenshot(QDir::tempPath().append("/screenshot.png"));
- if (!screenshot.isNull()) {
- screenshot = screenshot.scaledToWidth(ui->screenshotLabel->width());
- ui->screenshotLabel->setPixmap(QPixmap::fromImage(screenshot));
- }
-
- { // parse xml installer file
- QFile file(QDir::tempPath().append("/ModuleConfig.xml"));
- if (!file.open(QIODevice::ReadOnly)) {
- throw MyException(tr("ModuleConfig.xml missing"));
- }
- // nmm allows files with wrong encoding and of course there are now files that are broken
- QByteArray header = file.readLine();
-
- if (strncmp(header.constData() + bomOffset(header), "<?", 2) != 0) {
- // not a header, rewind
- if (!file.seek(0)) {
- qCritical("failed to rewind file");
- }
- }
- parseModuleConfig(file.readAll());
- file.close();
- }
-}
-
-
-QString FomodInstallerDialog::getName() const
-{
- return ui->nameEdit->text();
-}
-
-
-void FomodInstallerDialog::moveTree(DirectoryTree::Node *target, DirectoryTree::Node *source)
-{
- for (DirectoryTree::const_node_iterator iter = source->nodesBegin(); iter != source->nodesEnd();) {
- target->addNode(*iter, true);
- iter = source->detach(iter);
- }
-
- for (DirectoryTree::const_leaf_reverse_iterator iter = source->leafsRBegin();
- iter != source->leafsREnd(); ++iter) {
- target->addLeaf(*iter);
- }
-}
-
-
-DirectoryTree::Node *FomodInstallerDialog::findNode(DirectoryTree::Node *node, const QString &path, bool create)
-{
- if (path.length() == 0) {
- return node;
- }
-
-// static QRegExp pathSeparator("[/\\]");
- int pos = path.indexOf('\\');
- if (pos == -1) {
- pos = path.indexOf('/');
- }
- QString subPath = path;
- if (pos > 0) {
- subPath = path.mid(0, pos);
- }
- for (DirectoryTree::const_node_iterator iter = node->nodesBegin(); iter != node->nodesEnd(); ++iter) {
- if ((*iter)->getData().name.compare(subPath, Qt::CaseInsensitive) == 0) {
- if (pos <= 0) {
- return *iter;
- } else {
- return findNode(*iter, path.mid(pos + 1), create);
- }
- }
- }
- if (create) {
- DirectoryTree::Node *newNode = new DirectoryTree::Node;
- newNode->setData(subPath);
- node->addNode(newNode, false);
- if (pos <= 0) {
- return newNode;
- } else {
- return findNode(newNode, path.mid(pos + 1), create);
- }
- } else {
- throw MyException(QString("%1 not found in archive").arg(path));
- }
-}
-
-void FomodInstallerDialog::copyLeaf(DirectoryTree::Node *sourceTree, const QString &sourcePath,
- DirectoryTree::Node *destinationTree, const QString &destinationPath)
-{
- int sourceFileIndex = sourcePath.lastIndexOf('\\');
- if (sourceFileIndex == -1) {
- sourceFileIndex = sourcePath.lastIndexOf('/');
- if (sourceFileIndex == -1) {
- sourceFileIndex = 0;
- }
- }
- DirectoryTree::Node *sourceNode = sourceFileIndex == 0 ? sourceTree : findNode(sourceTree, sourcePath.mid(0, sourceFileIndex), false);
-
- int destinationFileIndex = destinationPath.lastIndexOf('\\');
- if (destinationFileIndex == -1) {
- destinationFileIndex = destinationPath.lastIndexOf('/');
- if (destinationFileIndex == -1) {
- destinationFileIndex = 0;
- }
- }
-
- DirectoryTree::Node *destinationNode =
- destinationFileIndex == 0 ? destinationTree
- : findNode(destinationTree, destinationPath.mid(0, destinationFileIndex), true);
-
- QString sourceName = sourcePath.mid((sourceFileIndex != 0) ? sourceFileIndex + 1 : 0);
- QString destinationName = (destinationFileIndex != 0) ? destinationPath.mid(destinationFileIndex + 1) : destinationPath;
- if (destinationName.length() == 0) {
- destinationName = sourceName;
- }
-
- bool found = false;
- for (DirectoryTree::const_leaf_reverse_iterator iter = sourceNode->leafsRBegin();
- iter != sourceNode->leafsREnd(); ++iter) {
- if (iter->getName().compare(sourceName, Qt::CaseInsensitive) == 0) {
- destinationNode->addLeaf(*iter);
- found = true;
- }
- }
- if (!found) {
- qCritical("%s not found!", sourceName.toUtf8().constData());
- }
-}
-
-
-void dumpTree(DirectoryTree::Node *node, int indent)
-{
- for (DirectoryTree::const_leaf_reverse_iterator iter = node->leafsRBegin();
- iter != node->leafsREnd(); ++iter) {
- qDebug("%.*s%s", indent, " ", iter->getName().toUtf8().constData());
- }
-
- for (DirectoryTree::const_node_iterator iter = node->nodesBegin(); iter != node->nodesEnd(); ++iter) {
- qDebug("%.*s-- %s", indent, " ", (*iter)->getData().name.toUtf8().constData());
- dumpTree(*iter, indent + 2);
- }
-}
-
-
-bool FomodInstallerDialog::copyFileIterator(DirectoryTree *sourceTree, DirectoryTree *destinationTree, FileDescriptor *descriptor)
-{
- QString source = (m_FomodPath.length() != 0) ? m_FomodPath.mid(0).append("\\").append(descriptor->m_Source)
- : descriptor->m_Source;
- QString destination = descriptor->m_Destination;
- try {
- if (descriptor->m_IsFolder) {
- DirectoryTree::Node *sourceNode = findNode(sourceTree, source, false);
- DirectoryTree::Node *targetNode = findNode(destinationTree, destination, true);
- moveTree(targetNode, sourceNode);
- } else {
- copyLeaf(sourceTree, source, destinationTree, destination);
- }
- return true;
- } catch (const MyException &e) {
- qCritical("failed to extract %s to %s: %s",
- source.toUtf8().constData(), destination.toUtf8().constData(), e.what());
- return false;
- }
-}
-
-
-DirectoryTree *FomodInstallerDialog::updateTree(DirectoryTree *tree)
-{
- DirectoryTree *newTree = new DirectoryTree;
-
- for (std::vector<FileDescriptor*>::iterator iter = m_RequiredFiles.begin(); iter != m_RequiredFiles.end(); ++iter) {
- copyFileIterator(tree, newTree, *iter);
- }
-
- for (std::vector<ConditionalInstall>::iterator installIter = m_ConditionalInstalls.begin();
- installIter != m_ConditionalInstalls.end(); ++installIter) {
- bool match = installIter->m_Operator == ConditionalInstall::OP_AND;
- for (std::vector<Condition>::iterator conditionIter = installIter->m_Conditions.begin();
- conditionIter != installIter->m_Conditions.end(); ++conditionIter) {
- bool conditionMatches = testCondition(ui->stepsStack->count(), conditionIter->m_Name, conditionIter->m_Value);
- if (conditionMatches && (installIter->m_Operator == ConditionalInstall::OP_OR)) {
- match = true;
- break;
- } else if (!conditionMatches && (installIter->m_Operator == ConditionalInstall::OP_AND)) {
- match = false;
- break;
- }
- }
- if (match) {
- for (std::vector<FileDescriptor*>::iterator fileIter = installIter->m_Files.begin();
- fileIter != installIter->m_Files.end(); ++fileIter) {
- copyFileIterator(tree, newTree, *fileIter);
- }
- }
- }
-
- QList<QAbstractButton*> choices = ui->stepsStack->findChildren<QAbstractButton*>("choice");
- foreach (QAbstractButton* choice, choices) {
- if (choice->isChecked()) {
- QVariantList fileList = choice->property("files").toList();
- foreach (QVariant fileVariant, fileList) {
- copyFileIterator(tree, newTree, fileVariant.value<FileDescriptor*>());
- }
- }
- }
-
-// dumpTree(newTree, 0);
-
- return newTree;
-}
-
-
-void FomodInstallerDialog::highlightControl(QAbstractButton *button)
-{
- QVariant screenshotName = button->property("screenshot");
- if (screenshotName.isValid()) {
- QString screenshotFileName = screenshotName.toString();
- if (!screenshotFileName.isEmpty()) {
- QString temp = QFileInfo(screenshotFileName).fileName();
- QImage screenshot(QDir::tempPath().append("/").append(temp));
- if (screenshot.isNull()) {
- qWarning(">%s< is a null image", screenshotName.toString().toUtf8().constData());
- }
- screenshot = screenshot.scaledToWidth(ui->screenshotLabel->width());
- ui->screenshotLabel->setPixmap(QPixmap::fromImage(screenshot));
- } else {
- ui->screenshotLabel->setPixmap(QPixmap());
- }
- }
- ui->descriptionText->setText(button->property("description").toString());
-}
-
-
-bool FomodInstallerDialog::eventFilter(QObject *object, QEvent *event)
-{
- QAbstractButton *button = qobject_cast<QAbstractButton*>(object);
- if ((button != NULL) && (event->type() == QEvent::HoverEnter)) {
- highlightControl(button);
-
- }
- return QDialog::eventFilter(object, event);
-}
-
-
-QString FomodInstallerDialog::readContent(QXmlStreamReader &reader)
-{
- if (reader.readNext() == QXmlStreamReader::Characters) {
- return reader.text().toString();
- } else {
- return QString();
- }
-}
-
-
-void FomodInstallerDialog::parseInfo(const QByteArray &data)
-{
- QXmlStreamReader reader(data);
-/* while (reader.readNext() != QXmlStreamReader::StartDocument) {}
- QTextDecoder *decoder = QTextCodec::codecForName(reader.documentEncoding().toLocal8Bit())->makeDecoder(QTextCodec::ConvertInvalidToNull);
- QString test(decoder->toUnicode(data));
- qDebug("test: %d, %s", test.isNull(), test.toUtf8().constData());
-
- qDebug(">%s<", reader.documentEncoding().toUtf8().constData());*/
- while (!reader.atEnd() && !reader.hasError()) {
- switch (reader.readNext()) {
- case QXmlStreamReader::StartElement: {
- if (reader.name() == "Name") {
- if (ui->nameEdit->text().isEmpty() || m_NameWasGuessed) {
- ui->nameEdit->setText(readContent(reader));
- }
- } else if (reader.name() == "Author") {
- ui->authorLabel->setText(readContent(reader));
- } else if (reader.name() == "Version") {
- ui->versionLabel->setText(readContent(reader));
- } else if (reader.name() == "Website") {
- QString url = readContent(reader);
- ui->websiteLabel->setText(tr("<a href=\"%1\">Link</a>").arg(url));
- ui->websiteLabel->setToolTip(url);
- }
- } break;
- default: {} break;
- }
- }
- if (reader.hasError()) {
- throw MyException(tr("failed to parse info.xml: %1 (%2) (line %3, column %4)")
- .arg(reader.errorString())
- .arg(reader.error())
- .arg(reader.lineNumber())
- .arg(reader.columnNumber()));
-
- }
-}
-
-
-FomodInstallerDialog::ItemOrder FomodInstallerDialog::getItemOrder(const QString &orderString)
-{
- if (orderString == "Ascending") {
- return ORDER_ASCENDING;
- } else if (orderString == "Descending") {
- return ORDER_DESCENDING;
- } else if (orderString == "Explicit") {
- return ORDER_EXPLICIT;
- } else {
- throw MyException(tr("unsupported order type %1").arg(orderString));
- }
-}
-
-
-FomodInstallerDialog::GroupType FomodInstallerDialog::getGroupType(const QString &typeString)
-{
- if (typeString == "SelectAtLeastOne") {
- return TYPE_SELECTATLEASTONE;
- } else if (typeString == "SelectAtMostOne") {
- return TYPE_SELECTATMOSTONE;
- } else if (typeString == "SelectExactlyOne") {
- return TYPE_SELECTEXACTLYONE;
- } else if (typeString == "SelectAny") {
- return TYPE_SELECTANY;
- } else if (typeString == "SelectAll") {
- return TYPE_SELECTALL;
- } else {
- throw MyException(tr("unsupported group type %1").arg(typeString));
- }
-}
-
-
-FomodInstallerDialog::PluginType FomodInstallerDialog::getPluginType(const QString &typeString)
-{
- if (typeString == "Required") {
- return FomodInstallerDialog::TYPE_REQUIRED;
- } else if (typeString == "Optional") {
- return FomodInstallerDialog::TYPE_OPTIONAL;
- } else if (typeString == "Recommended") {
- return FomodInstallerDialog::TYPE_RECOMMENDED;
- } else if (typeString == "NotUsable") {
- return FomodInstallerDialog::TYPE_NOTUSABLE;
- } else if (typeString == "CouldBeUsable") {
- return FomodInstallerDialog::TYPE_COULDBEUSABLE;
- } else {
- qCritical("invalid plugin type %s", typeString.toUtf8().constData());
- return FomodInstallerDialog::TYPE_OPTIONAL;
- }
-}
-
-
-void FomodInstallerDialog::readFileList(QXmlStreamReader &reader, std::vector<FileDescriptor*> &fileList)
-{
- QStringRef openTag = reader.name();
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == openTag))) {
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if ((reader.name() == "folder") ||
- (reader.name() == "file")) {
- QXmlStreamAttributes attributes = reader.attributes();
- FileDescriptor *file = new FileDescriptor(this);
- file->m_Source = attributes.value("source").toString();
- file->m_Destination = attributes.hasAttribute("destination") ? attributes.value("destination").toString()
- : file->m_Source;
- file->m_Priority = attributes.hasAttribute("priority") ? attributes.value("priority").string()->toInt()
- : 0;
- file->m_IsFolder = reader.name() == "folder";
- file->m_InstallIfUsable = attributes.hasAttribute("installIfUsable") ? (attributes.value("installIfUsable").compare("true") == 0)
- : false;
- file->m_AlwaysInstall = attributes.hasAttribute("alwaysInstall") ? (attributes.value("alwaysInstall").compare("true") == 0)
- : false;
-
- fileList.push_back(file);
- }
- }
- }
-}
-
-
-void FomodInstallerDialog::readPluginType(QXmlStreamReader &reader, Plugin &plugin)
-{
- plugin.m_Type = TYPE_OPTIONAL;
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == "typeDescriptor"))) {
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "type") {
- plugin.m_Type = getPluginType(reader.attributes().value("name").toString());
- }
- }
- }
-}
-
-
-void FomodInstallerDialog::readConditionFlags(QXmlStreamReader &reader, Plugin &plugin)
-{
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == "conditionFlags"))) {
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "flag") {
- QString name = reader.attributes().value("name").toString();
- plugin.m_Conditions.push_back(Condition(name, readContent(reader)));
- }
- }
- }
-}
-
-
-bool FomodInstallerDialog::byPriority(const FileDescriptor *LHS, const FileDescriptor *RHS)
-{
- return LHS->m_Priority < RHS->m_Priority;
-}
-
-
-FomodInstallerDialog::Plugin FomodInstallerDialog::readPlugin(QXmlStreamReader &reader)
-{
- Plugin result;
- result.m_Name = reader.attributes().value("name").toString();
-
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == "plugin"))) {
-// QXmlStreamReader::TokenType type = reader.tokenType();
-// QString name = reader.name().toUtf8();
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "description") {
- result.m_Description = readContent(reader).trimmed();
- } else if (reader.name() == "image") {
- result.m_ImagePath = reader.attributes().value("path").toString();
- } else if (reader.name() == "typeDescriptor") {
- readPluginType(reader, result);
- } else if (reader.name() == "conditionFlags") {
- readConditionFlags(reader, result);
- } else if (reader.name() == "files") {
- readFileList(reader, result.m_Files);
- }
- }
- }
-
- std::sort(result.m_Files.begin(), result.m_Files.end(), byPriority);
-
- return result;
-}
-
-
-void FomodInstallerDialog::readPlugins(QXmlStreamReader &reader, GroupType groupType, QLayout *layout)
-{
- ItemOrder pluginOrder = reader.attributes().hasAttribute("order") ? getItemOrder(reader.attributes().value("order").toString())
- : ORDER_ASCENDING;
- bool first = true;
- bool maySelectMore = true;
-
- std::vector<QAbstractButton*> controls;
-
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == "plugins"))) {
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "plugin") {
- Plugin plugin = readPlugin(reader);
- QAbstractButton *newControl = NULL;
- switch (groupType) {
- case TYPE_SELECTATLEASTONE:
- case TYPE_SELECTANY: {
- newControl = new QCheckBox(plugin.m_Name);
- } break;
- case TYPE_SELECTATMOSTONE: {
- newControl = new QRadioButton(plugin.m_Name);
- } break;
- case TYPE_SELECTEXACTLYONE: {
- newControl = new QRadioButton(plugin.m_Name);
- if (first) {
- newControl->setChecked(true);
- }
- } break;
- case TYPE_SELECTALL: {
- newControl = new QCheckBox(plugin.m_Name);
- newControl->setChecked(true);
- newControl->setEnabled(false);
- } break;
- }
- newControl->setObjectName("choice");
- switch (plugin.m_Type) {
- case TYPE_REQUIRED: {
- newControl->setChecked(true);
- newControl->setEnabled(false);
- newControl->setToolTip(tr("This component is required"));
- } break;
- case TYPE_RECOMMENDED: {
- if (maySelectMore) {
- newControl->setChecked(true);
- }
- newControl->setToolTip(tr("It is recommended you enable this component"));
- if ((groupType == TYPE_SELECTATMOSTONE) || (groupType == TYPE_SELECTEXACTLYONE)) {
- maySelectMore = false;
- }
- } break;
- case TYPE_OPTIONAL: {
- newControl->setToolTip(tr("Optional component"));
- } break;
- case TYPE_NOTUSABLE: {
- newControl->setChecked(false);
- newControl->setEnabled(false);
- newControl->setToolTip(tr("This component is not usable in combination with other installed plugins"));
- } break;
- case TYPE_COULDBEUSABLE: {
- newControl->setCheckable(true);
- newControl->setIcon(QIcon(":/new/guiresources/resources/dialog-warning_16.png"));
- newControl->setToolTip(tr("You may be experiencing instability in combination with other installed plugins"));
- } break;
- }
-
- newControl->setProperty("plugintype", plugin.m_Type);
- newControl->setProperty("screenshot", plugin.m_ImagePath);
- newControl->setProperty("description", plugin.m_Description);
- QVariantList fileList;
- for (std::vector<FileDescriptor*>::iterator iter = plugin.m_Files.begin(); iter != plugin.m_Files.end(); ++iter) {
- fileList.append(qVariantFromValue(*iter));
- }
- newControl->setProperty("files", fileList);
- QVariantList conditionFlags;
- for (std::vector<Condition>::const_iterator iter = plugin.m_Conditions.begin(); iter != plugin.m_Conditions.end(); ++iter) {
- if (iter->m_Name.length() != 0) {
- conditionFlags.append(qVariantFromValue(Condition(iter->m_Name, iter->m_Value)));
- }
- }
- newControl->setProperty("conditionFlags", conditionFlags);
- newControl->installEventFilter(this);
- controls.push_back(newControl);
- first = false;
- }
- }
- }
-
- if (pluginOrder == ORDER_ASCENDING) {
- std::sort(controls.begin(), controls.end(), ControlsAscending);
- } else if (pluginOrder == ORDER_DESCENDING) {
- std::sort(controls.begin(), controls.end(), ControlsDescending);
- }
-
- for (std::vector<QAbstractButton*>::const_iterator iter = controls.begin(); iter != controls.end(); ++iter) {
- layout->addWidget(*iter);
- }
-
- if (groupType == TYPE_SELECTATMOSTONE) {
- QRadioButton *newButton = new QRadioButton(tr("None"));
- if (maySelectMore) {
- newButton->setChecked(true);
- }
- layout->addWidget(newButton);
- }
-}
-
-
-void FomodInstallerDialog::readGroup(QXmlStreamReader &reader, QLayout *layout)
-{
- //FileGroup result;
- QString name = reader.attributes().value("name").toString();
- GroupType type = getGroupType(reader.attributes().value("type").toString());
-
- if (type == TYPE_SELECTATLEASTONE) {
- QLabel *label = new QLabel(tr("Select one or more of these options:"));
- layout->addWidget(label);
- }
-
- QGroupBox *groupBox = new QGroupBox(name);
-
- QVBoxLayout *groupLayout = new QVBoxLayout;
-
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == "group"))) {
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "plugins") {
- readPlugins(reader, type, groupLayout);
- }
- }
- }
-
- groupBox->setLayout(groupLayout);
- layout->addWidget(groupBox);
-}
-
-
-void FomodInstallerDialog::readGroups(QXmlStreamReader &reader, QLayout *layout)
-{
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == "optionalFileGroups"))) {
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "group") {
- readGroup(reader, layout);
- }
- }
- }
-}
-
-
-void FomodInstallerDialog::readVisible(QXmlStreamReader &reader, QVariantList &conditions)
-{
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == "visible"))) {
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "flagDependency") {
- Condition condition(reader.attributes().value("flag").toString(),
- reader.attributes().value("value").toString());
- conditions.append(qVariantFromValue(condition));
- }
- }
- }
-}
-
-QGroupBox *FomodInstallerDialog::readInstallerStep(QXmlStreamReader &reader)
-{
- QString name = reader.attributes().value("name").toString();
- QGroupBox *page = new QGroupBox(name);
- QVBoxLayout *pageLayout = new QVBoxLayout;
- QScrollArea *scrollArea = new QScrollArea;
- QFrame *scrolledArea = new QFrame;
- QVBoxLayout *scrollLayout = new QVBoxLayout;
-
- QVariantList conditions;
-
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == "installStep"))) {
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "optionalFileGroups") {
- readGroups(reader, scrollLayout);
- } else if (reader.name() == "visible") {
- readVisible(reader, conditions);
- }
- }
- }
- if (conditions.length() != 0) {
- page->setProperty("conditions", conditions);
- }
-
- scrolledArea->setLayout(scrollLayout);
- scrollArea->setWidget(scrolledArea);
- scrollArea->setWidgetResizable(true);
- pageLayout->addWidget(scrollArea);
- page->setLayout(pageLayout);
- return page;
-}
-
-
-void FomodInstallerDialog::readInstallerSteps(QXmlStreamReader &reader)
-{
- ItemOrder stepOrder = reader.attributes().hasAttribute("order") ? getItemOrder(reader.attributes().value("order").toString())
- : ORDER_ASCENDING;
-
- std::vector<QGroupBox*> pages;
-
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == "installSteps"))) {
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "installStep") {
- pages.push_back(readInstallerStep(reader));
- }
- }
- }
-
- if (stepOrder == ORDER_ASCENDING) {
- std::sort(pages.begin(), pages.end(), PagesAscending);
- } else if (stepOrder == ORDER_DESCENDING) {
- std::sort(pages.begin(), pages.end(), PagesDescending);
- }
-
- for (std::vector<QGroupBox*>::const_iterator iter = pages.begin(); iter != pages.end(); ++iter) {
- ui->stepsStack->addWidget(*iter);
- }
-}
-
-
-FomodInstallerDialog::ConditionalInstall FomodInstallerDialog::readConditionalPattern(QXmlStreamReader &reader)
-{
- ConditionalInstall result;
- result.m_Operator = ConditionalInstall::OP_AND;
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == "pattern"))) {
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "dependencies") {
- QStringRef dependencyOperator = reader.attributes().value("operator");
- if (dependencyOperator == "And") {
- result.m_Operator = ConditionalInstall::OP_AND;
- } else if (dependencyOperator == "Or") {
- result.m_Operator = ConditionalInstall::OP_OR;
- } // otherwise operator is not set (which we can ignore) or invalid (which we should report actually)
-
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == "dependencies"))) {
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "flagDependency") {
- result.m_Conditions.push_back(Condition(reader.attributes().value("flag").toString(),
- reader.attributes().value("value").toString()));
- }
- }
- }
- } else if (reader.name() == "files") {
- readFileList(reader, result.m_Files);
- }
- }
- }
- return result;
-}
-
-
-void FomodInstallerDialog::readConditionalFileInstalls(QXmlStreamReader &reader)
-{
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == "conditionalFileInstalls"))) {
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "patterns") {
- while (!((reader.readNext() == QXmlStreamReader::EndElement) &&
- (reader.name() == "patterns"))) {
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "pattern") {
- m_ConditionalInstalls.push_back(readConditionalPattern(reader));
- }
- }
- }
- }
- }
- }
-}
-
-
-void FomodInstallerDialog::parseModuleConfig(const QByteArray &data)
-{
- QXmlStreamReader reader(data);
- while (!reader.atEnd() && !reader.hasError()) {
- switch (reader.readNext()) {
- case QXmlStreamReader::StartElement: {
- if (reader.name() == "installSteps") {
- readInstallerSteps(reader);
- } else if (reader.name() == "requiredInstallFiles") {
- readFileList(reader, m_RequiredFiles);
- } else if (reader.name() == "conditionalFileInstalls") {
- readConditionalFileInstalls(reader);
- }
- } break;
- default: {} break;
- }
- }
- if (reader.hasError()) {
- reportError(tr("failed to parse ModuleConfig.xml: %1 - %2").arg(reader.errorString()).arg(reader.lineNumber()));
- }
- activateCurrentPage();
-}
-
-
-void FomodInstallerDialog::on_manualBtn_clicked()
-{
- m_Manual = true;
- this->reject();
-}
-
-void FomodInstallerDialog::on_cancelBtn_clicked()
-{
- this->reject();
-}
-
-
-void FomodInstallerDialog::on_websiteLabel_linkActivated(const QString &link)
-{
- ::ShellExecuteW(NULL, L"open", ToWString(link).c_str(), NULL, NULL, SW_SHOWNORMAL);
-}
-
-
-void FomodInstallerDialog::activateCurrentPage()
-{
- QList<QAbstractButton*> choices = ui->stepsStack->currentWidget()->findChildren<QAbstractButton*>("choice");
- if (choices.count() > 0) {
- highlightControl(choices.at(0));
- }
-}
-
-
-bool FomodInstallerDialog::testCondition(int maxIndex, const QString &flag, const QString &value)
-{
- // iterate through all set condition flags on all activated controls on all visible pages if one of them matches the condition
- for (int i = 0; i < maxIndex; ++i) {
- if (testVisible(i)) {
- QWidget *page = ui->stepsStack->widget(i);
- QList<QAbstractButton*> choices = page->findChildren<QAbstractButton*>("choice");
- foreach (QAbstractButton* choice, choices) {
- if (choice->isChecked()) {
- QVariant temp = choice->property("conditionFlags");
- if (temp.isValid()) {
- QVariantList conditionFlags = temp.toList();
- for (QVariantList::const_iterator iter = conditionFlags.begin(); iter != conditionFlags.end(); ++iter) {
- Condition condition = iter->value<Condition>();
- if ((condition.m_Name == flag) && (condition.m_Value == value)) {
- return true;
- }
- }
- }
- }
- }
- }
- }
- return false;
-}
-
-
-bool FomodInstallerDialog::testVisible(int pageIndex)
-{
- QWidget *page = ui->stepsStack->widget(pageIndex);
- QVariant temp = page->property("conditions");
- if (temp.isValid()) {
- QVariantList conditions = temp.toList();
- for (QVariantList::const_iterator iter = conditions.begin(); iter != conditions.end(); ++iter) {
- Condition condition = iter->value<Condition>();
- if (!testCondition(pageIndex, condition.m_Name, condition.m_Value)) {
- return false;
- }
- }
- return true;
- } else {
- return true;
- }
-}
-
-
-bool FomodInstallerDialog::nextPage()
-{
- int index = ui->stepsStack->currentIndex() + 1;
- while (index < ui->stepsStack->count()) {
- if (testVisible(index)) {
- ui->stepsStack->setCurrentIndex(index);
- return true;
- }
- ++index;
- }
- // no more visible pages -> install
- return false;
-}
-
-
-void FomodInstallerDialog::on_nextBtn_clicked()
-{
- if (ui->stepsStack->currentIndex() == ui->stepsStack->count() - 1) {
- this->accept();
- } else {
- if (nextPage()) {
- if (ui->stepsStack->currentIndex() == ui->stepsStack->count() - 1) {
- ui->nextBtn->setText(tr("Install"));
- }
- ui->prevBtn->setEnabled(true);
- activateCurrentPage();
- } else {
- this->accept();
- }
- }
-}
-
-void FomodInstallerDialog::on_prevBtn_clicked()
-{
- if (ui->stepsStack->currentIndex() != 0) {
- ui->stepsStack->setCurrentIndex(ui->stepsStack->currentIndex() - 1);
- ui->nextBtn->setText(tr("Next"));
- }
- if (ui->stepsStack->currentIndex() == 0) {
- ui->prevBtn->setEnabled(false);
- }
- activateCurrentPage();
-}
diff --git a/src/fomodinstallerdialog.h b/src/fomodinstallerdialog.h
deleted file mode 100644
index be4e34b2..00000000
--- a/src/fomodinstallerdialog.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
-Copyright (C) 2012 Sebastian Herbord. All rights reserved.
-
-This file is part of Mod Organizer.
-
-Mod Organizer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Mod Organizer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef FOMODINSTALLERDIALOG_H
-#define FOMODINSTALLERDIALOG_H
-
-#include "installdialog.h"
-#include <QDialog>
-#include <QAbstractButton>
-#include <QXmlStreamReader>
-#include <QGroupBox>
-#include <QSharedPointer>
-
-namespace Ui {
-class FomodInstallerDialog;
-}
-
-
-class Condition : public QObject {
- Q_OBJECT
-public:
- Condition(QObject *parent = NULL) : QObject(parent) { }
- Condition(const Condition &reference) : QObject(reference.parent()), m_Name(reference.m_Name), m_Value(reference.m_Value) { }
- Condition(const QString &name, const QString &value) : QObject(), m_Name(name), m_Value(value) { }
- QString m_Name;
- QString m_Value;
-private:
- Condition &operator=(const Condition&);
-};
-
-Q_DECLARE_METATYPE(Condition)
-
-
-class FileDescriptor : public QObject {
- Q_OBJECT
-public:
- FileDescriptor(QObject *parent)
- : QObject(parent), m_Source(), m_Destination(), m_Priority(0), m_IsFolder(false), m_AlwaysInstall(false),
- m_InstallIfUsable(false) {}
- FileDescriptor(const FileDescriptor &reference)
- : QObject(reference.parent()), m_Source(reference.m_Source), m_Destination(reference.m_Destination),
- m_Priority(reference.m_Priority), m_IsFolder(reference.m_IsFolder), m_AlwaysInstall(reference.m_AlwaysInstall),
- m_InstallIfUsable(reference.m_InstallIfUsable) {}
- QString m_Source;
- QString m_Destination;
- int m_Priority;
- bool m_IsFolder;
- bool m_AlwaysInstall;
- bool m_InstallIfUsable;
-private:
- FileDescriptor &operator=(const FileDescriptor&);
-};
-
-Q_DECLARE_METATYPE(FileDescriptor*)
-
-
-class FomodInstallerDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit FomodInstallerDialog(const QString &modName, bool nameWasGuessed, const QString &fomodPath, QWidget *parent = 0);
- ~FomodInstallerDialog();
-
- void initData();
-
- /**
- * @return bool true if the user requested the manual dialog
- **/
- bool manualRequested() const { return m_Manual; }
-
- /**
- * @return QString the (user-modified) name to be used for the mod
- **/
- QString getName() const;
-
- /**
- * @brief retrieve the updated archive tree from the dialog. The caller is responsible to delete the returned tree.
- *
- * @note This call is destructive on the input tree!
- *
- * @param tree input tree. (TODO isn't this the same as the tree passed in the constructor?)
- * @return DataTree* a new tree with only the selected options and directories arranged correctly. The caller takes custody of this pointer!
- **/
- MOBase::DirectoryTree *updateTree(MOBase::DirectoryTree *tree);
-
-protected:
-
- virtual bool eventFilter(QObject *object, QEvent *event);
-
-private slots:
-
- void on_cancelBtn_clicked();
-
- void on_manualBtn_clicked();
-
- void on_websiteLabel_linkActivated(const QString &link);
-
- void on_nextBtn_clicked();
-
- void on_prevBtn_clicked();
-
-private:
-
- enum ItemOrder {
- ORDER_ASCENDING,
- ORDER_DESCENDING,
- ORDER_EXPLICIT
- };
-
- enum GroupType {
- TYPE_SELECTATLEASTONE,
- TYPE_SELECTATMOSTONE,
- TYPE_SELECTEXACTLYONE,
- TYPE_SELECTANY,
- TYPE_SELECTALL
- };
-
- enum PluginType {
- TYPE_REQUIRED,
- TYPE_RECOMMENDED,
- TYPE_OPTIONAL,
- TYPE_NOTUSABLE,
- TYPE_COULDBEUSABLE
- };
-
- struct Plugin {
- QString m_Name;
- QString m_Description;
- QString m_ImagePath;
- PluginType m_Type;
- std::vector<Condition> m_Conditions;
- std::vector<FileDescriptor*> m_Files;
- };
-
- struct ConditionalInstall {
- enum {
- OP_AND,
- OP_OR
- } m_Operator;
- std::vector<Condition> m_Conditions;
- std::vector<FileDescriptor*> m_Files;
- };
-
-private:
-
- static int bomOffset(const QByteArray &buffer);
-
- QString readContent(QXmlStreamReader &reader);
- void parseInfo(const QByteArray &data);
-
- static ItemOrder getItemOrder(const QString &orderString);
- static GroupType getGroupType(const QString &typeString);
- static PluginType getPluginType(const QString &typeString);
- static bool byPriority(const FileDescriptor *LHS, const FileDescriptor *RHS);
-
- bool copyFileIterator(MOBase::DirectoryTree *sourceTree, MOBase::DirectoryTree *destinationTree, FileDescriptor *descriptor);
- void readFileList(QXmlStreamReader &reader, std::vector<FileDescriptor*> &fileList);
- void readPluginType(QXmlStreamReader &reader, Plugin &plugin);
- void readConditionFlags(QXmlStreamReader &reader, Plugin &plugin);
- FomodInstallerDialog::Plugin readPlugin(QXmlStreamReader &reader);
- void readPlugins(QXmlStreamReader &reader, GroupType groupType, QLayout *layout);
- void readGroup(QXmlStreamReader &reader, QLayout *layout);
- void readGroups(QXmlStreamReader &reader, QLayout *layout);
- void readVisible(QXmlStreamReader &reader, QVariantList &conditions);
- QGroupBox *readInstallerStep(QXmlStreamReader &reader);
- ConditionalInstall readConditionalPattern(QXmlStreamReader &reader);
- void readConditionalFileInstalls(QXmlStreamReader &reader);
- void readInstallerSteps(QXmlStreamReader &reader);
- void parseModuleConfig(const QByteArray &data);
- void highlightControl(QAbstractButton *button);
-
- bool testCondition(int maxIndex, const QString &flag, const QString &value);
- bool testVisible(int pageIndex);
- bool nextPage();
- void activateCurrentPage();
- void moveTree(MOBase::DirectoryTree::Node *target, MOBase::DirectoryTree::Node *source);
- MOBase::DirectoryTree::Node *findNode(MOBase::DirectoryTree::Node *node, const QString &path, bool create);
- void copyLeaf(MOBase::DirectoryTree::Node *sourceTree, const QString &sourcePath,
- MOBase::DirectoryTree::Node *destinationTree, const QString &destinationPath);
-
-private:
-
- Ui::FomodInstallerDialog *ui;
-
- bool m_NameWasGuessed;
-
- QString m_FomodPath;
- bool m_Manual;
-
-// ItemOrder m_StepOrder;
-// std::vector<InstallationStep> m_Steps;
- std::vector<FileDescriptor*> m_RequiredFiles;
- std::vector<ConditionalInstall> m_ConditionalInstalls;
-
-};
-
-#endif // FOMODINSTALLERDIALOG_H
diff --git a/src/installdialog.cpp b/src/installdialog.cpp
deleted file mode 100644
index ac508516..00000000
--- a/src/installdialog.cpp
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
-Copyright (C) 2012 Sebastian Herbord. All rights reserved.
-
-This file is part of Mod Organizer.
-
-Mod Organizer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Mod Organizer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "installdialog.h"
-#include "ui_installdialog.h"
-
-#include "report.h"
-#include "utility.h"
-#include "installationtester.h"
-
-#include <QMenu>
-#include <QInputDialog>
-#include <QMessageBox>
-
-
-using namespace MOBase;
-
-
-InstallDialog::InstallDialog(DirectoryTree *tree, const QString &modName, QWidget *parent)
- : TutorableDialog("InstallDialog", parent), ui(new Ui::InstallDialog),
- m_DataTree(tree), m_TreeRoot(NULL), m_DataRoot(NULL), m_TreeSelection(NULL),
- m_Updating(false)
-{
- ui->setupUi(this);
-
- QLineEdit *editName = findChild<QLineEdit*>("editName");
- editName->setText(modName);
-
- m_Tree = findChild<ArchiveTree*>("treeContent");
-
- m_ProblemLabel = findChild<QLabel*>("problemLabel");
-
- connect(m_Tree, SIGNAL(changed()), this, SLOT(treeChanged()));
-
- updatePreview();
-}
-
-InstallDialog::~InstallDialog()
-{
- delete ui;
-}
-
-
-QString InstallDialog::getModName() const
-{
- QLineEdit *editName = findChild<QLineEdit*>("editName");
- return editName->text();
-}
-
-
-void InstallDialog::mapDataNode(DirectoryTree::Node *node, QTreeWidgetItem *baseItem) const
-{
- for (int i = 0; i < baseItem->childCount(); ++i) {
- QTreeWidgetItem *currentItem = baseItem->child(i);
-
- if (currentItem->checkState(0) != Qt::Unchecked) {
- if (currentItem->data(0, Qt::UserRole).isNull()) {
- DirectoryTree::Node *newNode = new DirectoryTree::Node;
- newNode->setData(currentItem->text(0));
- mapDataNode(newNode, currentItem);
- node->addNode(newNode, true);
- } else {
- node->addLeaf(FileTreeInformation(currentItem->text(0), currentItem->data(0, Qt::UserRole).toInt()));
- }
- }
- }
-}
-
-
-DirectoryTree *InstallDialog::getDataTree() const
-{
- DirectoryTree *base = new DirectoryTree;
-
- mapDataNode(base, m_Tree->topLevelItem(0));
- return base;
-}
-
-
-QString InstallDialog::getFullPath(const DirectoryTree::Node *node)
-{
- QString result(node->getData().name);
- const DirectoryTree::Node *parent = node->getParent();
- while (parent != NULL) {
- if (parent->getParent() != NULL) {
- result.prepend("\\");
- }
- result.prepend(parent->getData().name);
- parent = parent->getParent();
- }
- return result;
-}
-
-
-void InstallDialog::addDataToTree(DirectoryTree::Node *node, QTreeWidgetItem *treeItem)
-{
- QString path = getFullPath(node);
-
- // add directory elements
- for (DirectoryTree::node_iterator iter = node->nodesBegin(); iter != node->nodesEnd(); ++iter) {
- QStringList fields((*iter)->getData().name);
- QTreeWidgetItem *newNodeItem = new QTreeWidgetItem(treeItem, fields);
- newNodeItem->setFlags(newNodeItem->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsTristate);
- newNodeItem->setCheckState(0, Qt::Checked);
- addDataToTree(*iter, newNodeItem);
- treeItem->addChild(newNodeItem);
- }
-
- // add file elements
- for (DirectoryTree::leaf_iterator iter = node->leafsBegin(); iter != node->leafsEnd(); ++iter) {
- QStringList fields(iter->getName());
-
- QTreeWidgetItem *newLeafItem = new QTreeWidgetItem(treeItem, fields);
- newLeafItem->setFlags(newLeafItem->flags() | Qt::ItemIsUserCheckable);
- newLeafItem->setCheckState(0, Qt::Checked);
- if (path.size() != 0) {
- newLeafItem->setToolTip(0, path.mid(0).append("\\").append(iter->getName()));
- } else {
- newLeafItem->setToolTip(0, iter->getName());
- }
- newLeafItem->setData(0, Qt::UserRole, iter->getIndex());
-
- treeItem->addChild(newLeafItem);
- }
-}
-
-
-void InstallDialog::updatePreview()
-{
- m_Updating = true;
- m_Tree->clear();
- delete m_TreeRoot;
-
- m_TreeRoot = new QTreeWidgetItem(m_Tree, QStringList("<data>"));
-
- addDataToTree(m_DataTree, m_TreeRoot);
-
- setDataRoot(m_TreeRoot);
- m_Updating = false;
- updateProblems();
-}
-
-
-bool InstallDialog::testForProblem()
-{
- bool ok = false;
- QTreeWidgetItem *tlWidget = m_Tree->topLevelItem(0);
- for (int i = 0; i < tlWidget->childCount(); ++i) {
- QTreeWidgetItem *widget = tlWidget->child(i);
- if (widget->checkState(0) == Qt::Unchecked) {
- continue;
- }
-
- if (widget->data(0, Qt::UserRole).isValid()) {
- // file
- if (InstallationTester::isTopLevelSuffix(widget->text(0))) {
- ok = true;
- break;
- }
- } else {
- // directory
- if (InstallationTester::isTopLevelDirectory(widget->text(0))) {
- ok = true;
- break;
- }
- }
- }
- return ok;
-}
-
-
-void InstallDialog::updateProblems()
-{
-
- if (testForProblem()) {
- m_ProblemLabel->setText(tr("Looks good"));
- m_ProblemLabel->setToolTip(tr("No problem detected"));
- m_ProblemLabel->setStyleSheet("color: darkGreen;");
- } else {
- m_ProblemLabel->setText(tr("No game data on top level"));
- m_ProblemLabel->setToolTip(tr("There is no esp/esm file or asset directory (textures, meshes, interface, ...) "
- "on the top level."));
- m_ProblemLabel->setStyleSheet("color: red;");
- }
-}
-
-
-void InstallDialog::setDataRoot(QTreeWidgetItem* root)
-{
- if (root != NULL) {
- m_DataRoot = root;
-
- m_Tree->takeTopLevelItem(0);
- QTreeWidgetItem *temp = root->clone();
-// temp->setCheckState(0, Qt::Checked);
- temp->setFlags(temp->flags() & ~(Qt::ItemIsUserCheckable | Qt::ItemIsTristate));
- temp->setText(0, "<data>");
- temp->setData(0, Qt::CheckStateRole, QVariant());
- m_Tree->addTopLevelItem(temp);
- temp->setExpanded(true);
- } else {
- m_Tree->takeTopLevelItem(0);
- }
- updateProblems();
-}
-
-
-void InstallDialog::use_as_data()
-{
- if (m_TreeSelection != NULL) {
- setDataRoot(m_TreeSelection);
- m_TreeSelection = NULL;
- }
- updateProblems();
-}
-
-
-void InstallDialog::unset_data()
-{
- m_TreeSelection = NULL;
-
- setDataRoot(m_TreeRoot);
- updateProblems();
-}
-
-
-void InstallDialog::create_directory()
-{
- bool ok = false;
- QString result = QInputDialog::getText(this, tr("Enter a directory name"), tr("Name"),
- QLineEdit::Normal, QString(), &ok);
- if (ok && !result.isEmpty()) {
- for (int i = 0; i < m_TreeSelection->childCount(); ++i) {
- if (m_TreeSelection->child(i)->text(0) == result) {
- reportError(tr("A directory with that name exists"));
- return;
- }
- }
- QStringList fields(result);
- QTreeWidgetItem *newItem = new QTreeWidgetItem(m_TreeSelection, fields);
- newItem->setFlags(newItem->flags() | Qt::ItemIsUserCheckable);
- newItem->setCheckState(0, Qt::Checked);
- m_TreeSelection->addChild(newItem);
- updateProblems();
- }
-}
-
-void InstallDialog::open_file()
-{
- emit openFile(m_TreeSelection->toolTip(0));
-}
-
-
-void InstallDialog::on_treeContent_customContextMenuRequested(QPoint pos)
-{
- m_TreeSelection = m_Tree->itemAt(pos);
- if (m_TreeSelection == 0) {
- return;
- }
-
- QMenu menu;
- menu.addAction(tr("Set data directory"), this, SLOT(use_as_data()));
- menu.addAction(tr("Unset data directory"), this, SLOT(unset_data()));
- if (m_TreeSelection->data(0, Qt::UserRole).isNull()) {
- menu.addAction(tr("Create directory..."), this, SLOT(create_directory()));
- } else {
- menu.addAction(tr("&Open"), this, SLOT(open_file()));
- }
- menu.exec(m_Tree->mapToGlobal(pos));
-}
-
-
-void InstallDialog::treeChanged()
-{
- updateProblems();
-}
-
-
-void InstallDialog::on_okButton_clicked()
-{
- if (!testForProblem()) {
- if (QMessageBox::question(this, tr("Continue?"), tr("This mod was probably NOT set up correctly, most likely it will NOT work. Really continue?"),
- QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
- return;
- }
- }
- this->accept();
-}
-
-void InstallDialog::on_cancelButton_clicked()
-{
- this->reject();
-}
diff --git a/src/installdialog.h b/src/installdialog.h
deleted file mode 100644
index e44d7eee..00000000
--- a/src/installdialog.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
-Copyright (C) 2012 Sebastian Herbord. All rights reserved.
-
-This file is part of Mod Organizer.
-
-Mod Organizer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Mod Organizer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef INSTALLDIALOG_H
-#define INSTALLDIALOG_H
-
-#include "mytree.h"
-#include "archivetree.h"
-#include "tutorabledialog.h"
-#include <QDialog>
-#include <QUuid>
-#include <QTreeWidgetItem>
-#include <QProgressDialog>
-#define WIN32_LEAN_AND_MEAN
-#include <Windows.h>
-#include <archive.h>
-#include <directorytree.h>
-
-
-namespace Ui {
- class InstallDialog;
-}
-
-
-/**
- * a dialog presented to manually define how a mod is to be installed. It provides
- * a tree view of the file contents that can modified directly
- **/
-class InstallDialog : public MOBase::TutorableDialog
-{
- Q_OBJECT
-
-public:
- /**
- * @brief constructor
- *
- * @param tree tree structure describing the vanilla archive structure. The InstallDialog does NOT take custody of this pointer!
- * @param modName name of the mod. The name can be modified through the dialog
- * @param parent parent widget
- **/
- explicit InstallDialog(MOBase::DirectoryTree *tree, const QString &modName, QWidget *parent = 0);
- ~InstallDialog();
-
- /**
- * @brief retrieve the (modified) mod name
- *
- * @return updated mod name
- **/
- QString getModName() const;
-
- /**
- * @brief retrieve the user-modified directory structure
- *
- * @return modified data structure. This is a NEW datatree object for which the caller takes custody
- **/
- MOBase::DirectoryTree *getDataTree() const;
-
-signals:
-
- void openFile(const QString fileName);
-
-private:
-
- void updatePreview();
- bool testForProblem();
- void updateProblems();
-
- void setDataRoot(QTreeWidgetItem* root);
-
- void updateFileList(QTreeWidgetItem *item, QString targetName, FileData* const *fileData, size_t size) const;
-
- void updateCheckState(QTreeWidgetItem *item);
-// void recursiveCheck(QTreeWidgetItem *item);
-// void recursiveUncheck(QTreeWidgetItem *item);
-
- void addDataToTree(MOBase::DirectoryTree::Node *node, QTreeWidgetItem *treeItem);
-
- void mapDataNode(MOBase::DirectoryTree::Node *node, QTreeWidgetItem *baseItem) const;
-
- static QString getFullPath(const MOBase::DirectoryTree::Node *node);
-
-private slots:
-
- void on_treeContent_customContextMenuRequested(QPoint pos);
-
- void unset_data();
- void use_as_data();
- void create_directory();
- void open_file();
-
- void treeChanged();
-
- void on_cancelButton_clicked();
-
- void on_okButton_clicked();
-
-private:
- Ui::InstallDialog *ui;
-
- MOBase::DirectoryTree *m_DataTree;
-
- ArchiveTree *m_Tree;
- QLabel *m_ProblemLabel;
- QTreeWidgetItem *m_TreeRoot;
- QTreeWidgetItem *m_DataRoot;
- QTreeWidgetItem *m_TreeSelection;
- bool m_Updating;
-
-};
-
-#endif // INSTALLDIALOG_H
diff --git a/src/simpleinstalldialog.cpp b/src/simpleinstalldialog.cpp
deleted file mode 100644
index ef694780..00000000
--- a/src/simpleinstalldialog.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-Copyright (C) 2012 Sebastian Herbord. All rights reserved.
-
-This file is part of Mod Organizer.
-
-Mod Organizer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Mod Organizer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "simpleinstalldialog.h"
-#include "ui_simpleinstalldialog.h"
-
-SimpleInstallDialog::SimpleInstallDialog(const QString &preset, QWidget *parent) :
- QDialog(parent), ui(new Ui::SimpleInstallDialog), m_Manual(false)
-{
- ui->setupUi(this);
- ui->nameEdit->setText(preset);
- setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
-}
-
-SimpleInstallDialog::~SimpleInstallDialog()
-{
- delete ui;
-}
-
-QString SimpleInstallDialog::getName() const
-{
- return ui->nameEdit->text();
-}
-
-void SimpleInstallDialog::on_okBtn_clicked()
-{
- this->accept();
-}
-
-void SimpleInstallDialog::on_cancelBtn_clicked()
-{
- this->reject();
-}
-
-void SimpleInstallDialog::on_manualBtn_clicked()
-{
- m_Manual = true;
- this->reject();
-}
diff --git a/src/simpleinstalldialog.h b/src/simpleinstalldialog.h
deleted file mode 100644
index 5e8765de..00000000
--- a/src/simpleinstalldialog.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-Copyright (C) 2012 Sebastian Herbord. All rights reserved.
-
-This file is part of Mod Organizer.
-
-Mod Organizer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Mod Organizer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef SIMPLEINSTALLDIALOG_H
-#define SIMPLEINSTALLDIALOG_H
-
-#include <QDialog>
-
-namespace Ui {
- class SimpleInstallDialog;
-}
-
-/**
- * @brief Dialog for the installation of a simple archive
- * a simple archive is one that doesn't require any manual changes to work correctly
- **/
-class SimpleInstallDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- /**
- * @brief constructor
- *
- * @param preset suggested name for the mod
- * @param parent parent widget
- **/
- explicit SimpleInstallDialog(const QString &preset, QWidget *parent = 0);
- ~SimpleInstallDialog();
-
- /**
- * @return true if the user requested the manual installation dialog
- **/
- bool manualRequested() const { return m_Manual; }
- /**
- * @return the (user-modified) mod name
- **/
- QString getName() const;
-
-private slots:
-
- void on_okBtn_clicked();
-
- void on_cancelBtn_clicked();
-
- void on_manualBtn_clicked();
-
-private:
- Ui::SimpleInstallDialog *ui;
- bool m_Manual;
-};
-
-#endif // SIMPLEINSTALLDIALOG_H