From 988c8f9ebe1a04037d4a62c149c84d52b90d7b4f Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 8 Sep 2014 16:18:31 +1000 Subject: [PATCH 1/5] Ignore duplicate connections. --- apps/opencs/view/doc/filedialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/view/doc/filedialog.cpp b/apps/opencs/view/doc/filedialog.cpp index ab56415a14..2c6470784e 100644 --- a/apps/opencs/view/doc/filedialog.cpp +++ b/apps/opencs/view/doc/filedialog.cpp @@ -115,7 +115,7 @@ void CSVDoc::FileDialog::buildOpenFileView() connect (mSelector, SIGNAL (signalAddonFileSelected (int)), this, SLOT (slotUpdateAcceptButton (int))); connect (mSelector, SIGNAL (signalAddonFileUnselected (int)), this, SLOT (slotUpdateAcceptButton (int))); - connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile())); + connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile()), Qt::UniqueConnection); } void CSVDoc::FileDialog::slotUpdateAcceptButton (int) From 567562648299d8d035a71f172452868c7cd40237 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 9 Sep 2014 07:24:18 +1000 Subject: [PATCH 2/5] Cleanup signals when finished. --- apps/opencs/view/doc/filedialog.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/doc/filedialog.cpp b/apps/opencs/view/doc/filedialog.cpp index 2c6470784e..8c6344bb57 100644 --- a/apps/opencs/view/doc/filedialog.cpp +++ b/apps/opencs/view/doc/filedialog.cpp @@ -115,7 +115,7 @@ void CSVDoc::FileDialog::buildOpenFileView() connect (mSelector, SIGNAL (signalAddonFileSelected (int)), this, SLOT (slotUpdateAcceptButton (int))); connect (mSelector, SIGNAL (signalAddonFileUnselected (int)), this, SLOT (slotUpdateAcceptButton (int))); - connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile()), Qt::UniqueConnection); + connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile())); } void CSVDoc::FileDialog::slotUpdateAcceptButton (int) @@ -162,6 +162,11 @@ void CSVDoc::FileDialog::slotRejected() void CSVDoc::FileDialog::slotNewFile() { emit signalCreateNewFile (mAdjusterWidget->getPath()); + + mFileWidget->disconnect(); + mSelector->disconnect(); + ui.projectButtonBox->disconnect(); + close(); } void CSVDoc::FileDialog::slotOpenFile() @@ -171,4 +176,8 @@ void CSVDoc::FileDialog::slotOpenFile() mAdjusterWidget->setName (file->filePath(), !file->isGameFile()); emit signalOpenFiles (mAdjusterWidget->getPath()); + + mSelector->disconnect(); + ui.projectButtonBox->disconnect(); + close(); } From 3a5ed9c5bbe7bb8822174af535e54d1d328dd7de Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 10 Sep 2014 07:14:01 +1000 Subject: [PATCH 3/5] Build objects and connections only once. --- apps/opencs/view/doc/filedialog.cpp | 63 +++++++++++++++-------------- apps/opencs/view/doc/filedialog.hpp | 1 + 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/apps/opencs/view/doc/filedialog.cpp b/apps/opencs/view/doc/filedialog.cpp index 8c6344bb57..0975d80300 100644 --- a/apps/opencs/view/doc/filedialog.cpp +++ b/apps/opencs/view/doc/filedialog.cpp @@ -18,7 +18,7 @@ #include "adjusterwidget.hpp" CSVDoc::FileDialog::FileDialog(QWidget *parent) : - QDialog(parent), mSelector (0), mFileWidget (0), mAdjusterWidget (0) + QDialog(parent), mSelector (0), mFileWidget (0), mAdjusterWidget (0), mDialogBuilt(false) { ui.setupUi (this); resize(400, 400); @@ -70,11 +70,15 @@ void CSVDoc::FileDialog::showDialog (ContentAction action) mAdjusterWidget->setFilenameCheck (mAction == ContentAction_New); - //connections common to both dialog view flavors - connect (mSelector, SIGNAL (signalCurrentGamefileIndexChanged (int)), - this, SLOT (slotUpdateAcceptButton (int))); + if(!mDialogBuilt) + { + //connections common to both dialog view flavors + connect (mSelector, SIGNAL (signalCurrentGamefileIndexChanged (int)), + this, SLOT (slotUpdateAcceptButton (int))); - connect (ui.projectButtonBox, SIGNAL (rejected()), this, SLOT (slotRejected())); + connect (ui.projectButtonBox, SIGNAL (rejected()), this, SLOT (slotRejected())); + mDialogBuilt = true; + } show(); raise(); @@ -85,37 +89,41 @@ void CSVDoc::FileDialog::buildNewFileView() { setWindowTitle(tr("Create a new addon")); - QPushButton* createButton = ui.projectButtonBox->button (QDialogButtonBox::Ok); - createButton->setText ("Create"); - createButton->setEnabled (false); + QPushButton* createButton = ui.projectButtonBox->button (QDialogButtonBox::Ok); + createButton->setText ("Create"); + createButton->setEnabled (false); - mFileWidget = new FileWidget (this); + if(!mFileWidget) + { + mFileWidget = new FileWidget (this); - mFileWidget->setType (true); - mFileWidget->extensionLabelIsVisible(true); + mFileWidget->setType (true); + mFileWidget->extensionLabelIsVisible(true); + + connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)), + mAdjusterWidget, SLOT (setName (const QString&, bool))); + + connect (mFileWidget, SIGNAL (nameChanged(const QString &, bool)), + this, SLOT (slotUpdateAcceptButton(const QString &, bool))); + + connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotNewFile())); + } ui.projectGroupBoxLayout->insertWidget (0, mFileWidget); - - connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)), - mAdjusterWidget, SLOT (setName (const QString&, bool))); - - connect (mFileWidget, SIGNAL (nameChanged(const QString &, bool)), - this, SLOT (slotUpdateAcceptButton(const QString &, bool))); - - connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotNewFile())); } void CSVDoc::FileDialog::buildOpenFileView() { setWindowTitle(tr("Open")); ui.projectGroupBox->setTitle (QString("")); - ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled (false); - connect (mSelector, SIGNAL (signalAddonFileSelected (int)), this, SLOT (slotUpdateAcceptButton (int))); - connect (mSelector, SIGNAL (signalAddonFileUnselected (int)), this, SLOT (slotUpdateAcceptButton (int))); - - connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile())); + if(!mDialogBuilt) + { + connect (mSelector, SIGNAL (signalAddonFileSelected (int)), this, SLOT (slotUpdateAcceptButton (int))); + connect (mSelector, SIGNAL (signalAddonFileUnselected (int)), this, SLOT (slotUpdateAcceptButton (int))); + connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile())); + } } void CSVDoc::FileDialog::slotUpdateAcceptButton (int) @@ -162,10 +170,6 @@ void CSVDoc::FileDialog::slotRejected() void CSVDoc::FileDialog::slotNewFile() { emit signalCreateNewFile (mAdjusterWidget->getPath()); - - mFileWidget->disconnect(); - mSelector->disconnect(); - ui.projectButtonBox->disconnect(); close(); } @@ -176,8 +180,5 @@ void CSVDoc::FileDialog::slotOpenFile() mAdjusterWidget->setName (file->filePath(), !file->isGameFile()); emit signalOpenFiles (mAdjusterWidget->getPath()); - - mSelector->disconnect(); - ui.projectButtonBox->disconnect(); close(); } diff --git a/apps/opencs/view/doc/filedialog.hpp b/apps/opencs/view/doc/filedialog.hpp index d9fd569435..111cc0d807 100644 --- a/apps/opencs/view/doc/filedialog.hpp +++ b/apps/opencs/view/doc/filedialog.hpp @@ -37,6 +37,7 @@ namespace CSVDoc ContentAction mAction; FileWidget *mFileWidget; AdjusterWidget *mAdjusterWidget; + bool mDialogBuilt; public: From f0e0494f031b683b4481e191a593e910863a89db Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 10 Sep 2014 08:13:10 +1000 Subject: [PATCH 4/5] Since commit 8bce460f3446df7347d9426675beae2b94e03c1f negative value checks no longer make sense. Not sure what to do about Vampire flag, however. --- apps/opencs/model/tools/bodypartcheck.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/opencs/model/tools/bodypartcheck.cpp b/apps/opencs/model/tools/bodypartcheck.cpp index da7fe7b574..20d6e8b00c 100644 --- a/apps/opencs/model/tools/bodypartcheck.cpp +++ b/apps/opencs/model/tools/bodypartcheck.cpp @@ -27,16 +27,16 @@ void CSMTools::BodyPartCheckStage::perform ( int stage, Messages &messages ) // Check BYDT - if ( bodyPart.mData.mPart < 0 || bodyPart.mData.mPart > 14 ) + if ( bodyPart.mData.mPart > 14 ) messages.push_back(std::make_pair( id, bodyPart.mId + " has out of range part value." )); if ( bodyPart.mData.mVampire < 0 ) messages.push_back(std::make_pair( id, bodyPart.mId + " has negative vampire flag." )); - if ( bodyPart.mData.mFlags < 0 || bodyPart.mData.mFlags > 3 ) + if ( bodyPart.mData.mFlags > 3 ) messages.push_back(std::make_pair( id, bodyPart.mId + " has out of range flags value." )); - if ( bodyPart.mData.mType < 0 || bodyPart.mData.mType > 2 ) + if ( bodyPart.mData.mType > 2 ) messages.push_back(std::make_pair( id, bodyPart.mId + " has out of range type value." )); // Check MODL From 88cf2bd59738022cffc2a483f302643e39604ba1 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 11 Sep 2014 07:27:48 +1000 Subject: [PATCH 5/5] Deal with signal source being overloaded. Clear filename after creating a new addon. Enable "Open" button if a game file is already selected. --- apps/opencs/view/doc/filedialog.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/doc/filedialog.cpp b/apps/opencs/view/doc/filedialog.cpp index 0975d80300..300656f334 100644 --- a/apps/opencs/view/doc/filedialog.cpp +++ b/apps/opencs/view/doc/filedialog.cpp @@ -106,24 +106,29 @@ void CSVDoc::FileDialog::buildNewFileView() connect (mFileWidget, SIGNAL (nameChanged(const QString &, bool)), this, SLOT (slotUpdateAcceptButton(const QString &, bool))); - connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotNewFile())); } ui.projectGroupBoxLayout->insertWidget (0, mFileWidget); + + connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotNewFile())); } void CSVDoc::FileDialog::buildOpenFileView() { setWindowTitle(tr("Open")); ui.projectGroupBox->setTitle (QString("")); - ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled (false); + ui.projectButtonBox->button(QDialogButtonBox::Ok)->setText ("Open"); + if(mSelector->isGamefileSelected()) + ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled (true); + else + ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled (false); if(!mDialogBuilt) { connect (mSelector, SIGNAL (signalAddonFileSelected (int)), this, SLOT (slotUpdateAcceptButton (int))); connect (mSelector, SIGNAL (signalAddonFileUnselected (int)), this, SLOT (slotUpdateAcceptButton (int))); - connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile())); } + connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile())); } void CSVDoc::FileDialog::slotUpdateAcceptButton (int) @@ -164,12 +169,25 @@ QString CSVDoc::FileDialog::filename() const void CSVDoc::FileDialog::slotRejected() { emit rejected(); + disconnect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotNewFile())); + disconnect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile())); + if(mFileWidget) + { + delete mFileWidget; + mFileWidget = NULL; + } close(); } void CSVDoc::FileDialog::slotNewFile() { emit signalCreateNewFile (mAdjusterWidget->getPath()); + if(mFileWidget) + { + delete mFileWidget; + mFileWidget = NULL; + } + disconnect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotNewFile())); close(); } @@ -180,5 +198,6 @@ void CSVDoc::FileDialog::slotOpenFile() mAdjusterWidget->setName (file->filePath(), !file->isGameFile()); emit signalOpenFiles (mAdjusterWidget->getPath()); + disconnect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile())); close(); }