mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-20 23:09:40 +00:00
added UI for merge tool (merge tool itself is still missing)
(cherry picked from commit b83f9445a9
)
Conflicts:
apps/opencs/editor.cpp
apps/opencs/editor.hpp
This commit is contained in:
parent
6fb658daa4
commit
ef1e01639e
13 changed files with 247 additions and 1 deletions
|
@ -94,7 +94,7 @@ opencs_hdrs_noqt (view/render
|
||||||
|
|
||||||
|
|
||||||
opencs_units (view/tools
|
opencs_units (view/tools
|
||||||
reportsubview reporttable searchsubview searchbox
|
reportsubview reporttable searchsubview searchbox merge
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (view/tools
|
opencs_units_noqt (view/tools
|
||||||
|
|
|
@ -48,9 +48,12 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
|
||||||
|
|
||||||
mNewGame.setLocalData (mLocal);
|
mNewGame.setLocalData (mLocal);
|
||||||
mFileDialog.setLocalData (mLocal);
|
mFileDialog.setLocalData (mLocal);
|
||||||
|
mMerge.setLocalData (mLocal);
|
||||||
|
|
||||||
connect (&mDocumentManager, SIGNAL (documentAdded (CSMDoc::Document *)),
|
connect (&mDocumentManager, SIGNAL (documentAdded (CSMDoc::Document *)),
|
||||||
this, SLOT (documentAdded (CSMDoc::Document *)));
|
this, SLOT (documentAdded (CSMDoc::Document *)));
|
||||||
|
connect (&mDocumentManager, SIGNAL (documentAboutToBeRemoved (CSMDoc::Document *)),
|
||||||
|
this, SLOT (documentAboutToBeRemoved (CSMDoc::Document *)));
|
||||||
connect (&mDocumentManager, SIGNAL (lastDocumentDeleted()),
|
connect (&mDocumentManager, SIGNAL (lastDocumentDeleted()),
|
||||||
this, SLOT (lastDocumentDeleted()));
|
this, SLOT (lastDocumentDeleted()));
|
||||||
|
|
||||||
|
@ -58,6 +61,7 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
|
||||||
connect (&mViewManager, SIGNAL (newAddonRequest ()), this, SLOT (createAddon ()));
|
connect (&mViewManager, SIGNAL (newAddonRequest ()), this, SLOT (createAddon ()));
|
||||||
connect (&mViewManager, SIGNAL (loadDocumentRequest ()), this, SLOT (loadDocument ()));
|
connect (&mViewManager, SIGNAL (loadDocumentRequest ()), this, SLOT (loadDocument ()));
|
||||||
connect (&mViewManager, SIGNAL (editSettingsRequest()), this, SLOT (showSettings ()));
|
connect (&mViewManager, SIGNAL (editSettingsRequest()), this, SLOT (showSettings ()));
|
||||||
|
connect (&mViewManager, SIGNAL (mergeDocument (CSMDoc::Document *)), this, SLOT (mergeDocument (CSMDoc::Document *)));
|
||||||
|
|
||||||
connect (&mStartup, SIGNAL (createGame()), this, SLOT (createGame ()));
|
connect (&mStartup, SIGNAL (createGame()), this, SLOT (createGame ()));
|
||||||
connect (&mStartup, SIGNAL (createAddon()), this, SLOT (createAddon ()));
|
connect (&mStartup, SIGNAL (createAddon()), this, SLOT (createAddon ()));
|
||||||
|
@ -490,6 +494,12 @@ void CS::Editor::documentAdded (CSMDoc::Document *document)
|
||||||
showSplashMessage();
|
showSplashMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CS::Editor::documentAboutToBeRemoved (CSMDoc::Document *document)
|
||||||
|
{
|
||||||
|
if (mMerge.getDocument()==document)
|
||||||
|
mMerge.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
void CS::Editor::lastDocumentDeleted()
|
void CS::Editor::lastDocumentDeleted()
|
||||||
{
|
{
|
||||||
QApplication::quit();
|
QApplication::quit();
|
||||||
|
@ -535,3 +545,9 @@ void CS::Editor::showSplashMessage()
|
||||||
splash->raise(); // for X windows
|
splash->raise(); // for X windows
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CS::Editor::mergeDocument (CSMDoc::Document *document)
|
||||||
|
{
|
||||||
|
mMerge.configure (document);
|
||||||
|
mMerge.show();
|
||||||
|
}
|
||||||
|
|
|
@ -32,11 +32,18 @@
|
||||||
#include "view/settings/dialog.hpp"
|
#include "view/settings/dialog.hpp"
|
||||||
#include "view/render/overlaysystem.hpp"
|
#include "view/render/overlaysystem.hpp"
|
||||||
|
|
||||||
|
#include "view/tools/merge.hpp"
|
||||||
|
|
||||||
namespace OgreInit
|
namespace OgreInit
|
||||||
{
|
{
|
||||||
class OgreInit;
|
class OgreInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace CSMDoc
|
||||||
|
{
|
||||||
|
class Document;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CS
|
namespace CS
|
||||||
{
|
{
|
||||||
class Editor : public QObject
|
class Editor : public QObject
|
||||||
|
@ -59,6 +66,7 @@ namespace CS
|
||||||
boost::interprocess::file_lock mLock;
|
boost::interprocess::file_lock mLock;
|
||||||
boost::filesystem::ofstream mPidFile;
|
boost::filesystem::ofstream mPidFile;
|
||||||
bool mFsStrict;
|
bool mFsStrict;
|
||||||
|
CSVTools::Merge mMerge;
|
||||||
|
|
||||||
void showSplashMessage();
|
void showSplashMessage();
|
||||||
|
|
||||||
|
@ -103,8 +111,12 @@ namespace CS
|
||||||
|
|
||||||
void documentAdded (CSMDoc::Document *document);
|
void documentAdded (CSMDoc::Document *document);
|
||||||
|
|
||||||
|
void documentAboutToBeRemoved (CSMDoc::Document *document);
|
||||||
|
|
||||||
void lastDocumentDeleted();
|
void lastDocumentDeleted();
|
||||||
|
|
||||||
|
void mergeDocument (CSMDoc::Document *document);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString mIpcServerName;
|
QString mIpcServerName;
|
||||||
|
|
|
@ -72,6 +72,8 @@ void CSMDoc::DocumentManager::removeDocument (CSMDoc::Document *document)
|
||||||
if (iter==mDocuments.end())
|
if (iter==mDocuments.end())
|
||||||
throw std::runtime_error ("removing invalid document");
|
throw std::runtime_error ("removing invalid document");
|
||||||
|
|
||||||
|
emit documentAboutToBeRemoved (document);
|
||||||
|
|
||||||
mDocuments.erase (iter);
|
mDocuments.erase (iter);
|
||||||
document->deleteLater();
|
document->deleteLater();
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,8 @@ namespace CSMDoc
|
||||||
|
|
||||||
void documentAdded (CSMDoc::Document *document);
|
void documentAdded (CSMDoc::Document *document);
|
||||||
|
|
||||||
|
void documentAboutToBeRemoved (CSMDoc::Document *document);
|
||||||
|
|
||||||
void loadRequest (CSMDoc::Document *document);
|
void loadRequest (CSMDoc::Document *document);
|
||||||
|
|
||||||
void lastDocumentDeleted();
|
void lastDocumentDeleted();
|
||||||
|
|
|
@ -55,3 +55,11 @@ void CSVDoc::FileWidget::extensionLabelIsVisible(bool visible)
|
||||||
{
|
{
|
||||||
mType->setVisible(visible);
|
mType->setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::FileWidget::setName (const std::string& text)
|
||||||
|
{
|
||||||
|
QString text2 = QString::fromUtf8 (text.c_str());
|
||||||
|
|
||||||
|
mInput->setText (text2);
|
||||||
|
textChanged (text2);
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QString;
|
class QString;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
|
@ -29,6 +31,8 @@ namespace CSVDoc
|
||||||
|
|
||||||
void extensionLabelIsVisible(bool visible);
|
void extensionLabelIsVisible(bool visible);
|
||||||
|
|
||||||
|
void setName (const std::string& text);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void textChanged (const QString& text);
|
void textChanged (const QString& text);
|
||||||
|
|
|
@ -83,6 +83,10 @@ void CSVDoc::View::setupFileMenu()
|
||||||
connect (mVerify, SIGNAL (triggered()), this, SLOT (verify()));
|
connect (mVerify, SIGNAL (triggered()), this, SLOT (verify()));
|
||||||
file->addAction (mVerify);
|
file->addAction (mVerify);
|
||||||
|
|
||||||
|
mMerge = new QAction (tr ("Merge"), this);
|
||||||
|
connect (mMerge, SIGNAL (triggered()), this, SLOT (merge()));
|
||||||
|
file->addAction (mMerge);
|
||||||
|
|
||||||
QAction *loadErrors = new QAction (tr ("Load Error Log"), this);
|
QAction *loadErrors = new QAction (tr ("Load Error Log"), this);
|
||||||
connect (loadErrors, SIGNAL (triggered()), this, SLOT (loadErrorLog()));
|
connect (loadErrors, SIGNAL (triggered()), this, SLOT (loadErrorLog()));
|
||||||
file->addAction (loadErrors);
|
file->addAction (loadErrors);
|
||||||
|
@ -418,6 +422,8 @@ void CSVDoc::View::updateActions()
|
||||||
|
|
||||||
mGlobalDebugProfileMenu->updateActions (running);
|
mGlobalDebugProfileMenu->updateActions (running);
|
||||||
mStopDebug->setEnabled (running);
|
mStopDebug->setEnabled (running);
|
||||||
|
|
||||||
|
mMerge->setEnabled (mDocument->getContentFiles().size()>1);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews)
|
CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews)
|
||||||
|
@ -1054,3 +1060,8 @@ void CSVDoc::View::updateScrollbar()
|
||||||
else
|
else
|
||||||
mSubViewWindow.setMinimumWidth(0);
|
mSubViewWindow.setMinimumWidth(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::View::merge()
|
||||||
|
{
|
||||||
|
emit mergeDocument (mDocument);
|
||||||
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace CSVDoc
|
||||||
QAction *mVerify;
|
QAction *mVerify;
|
||||||
QAction *mShowStatusBar;
|
QAction *mShowStatusBar;
|
||||||
QAction *mStopDebug;
|
QAction *mStopDebug;
|
||||||
|
QAction *mMerge;
|
||||||
std::vector<QAction *> mEditingActions;
|
std::vector<QAction *> mEditingActions;
|
||||||
Operations *mOperations;
|
Operations *mOperations;
|
||||||
SubViewFactoryManager mSubViewFactory;
|
SubViewFactoryManager mSubViewFactory;
|
||||||
|
@ -137,6 +138,8 @@ namespace CSVDoc
|
||||||
|
|
||||||
void editSettingsRequest();
|
void editSettingsRequest();
|
||||||
|
|
||||||
|
void mergeDocument (CSMDoc::Document *document);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void addSubView (const CSMWorld::UniversalId& id, const std::string& hint = "");
|
void addSubView (const CSMWorld::UniversalId& id, const std::string& hint = "");
|
||||||
|
@ -251,6 +254,8 @@ namespace CSVDoc
|
||||||
void saveWindowState();
|
void saveWindowState();
|
||||||
|
|
||||||
void moveScrollBarToEnd(int min, int max);
|
void moveScrollBarToEnd(int min, int max);
|
||||||
|
|
||||||
|
void merge();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,7 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document)
|
||||||
connect (view, SIGNAL (newAddonRequest ()), this, SIGNAL (newAddonRequest()));
|
connect (view, SIGNAL (newAddonRequest ()), this, SIGNAL (newAddonRequest()));
|
||||||
connect (view, SIGNAL (loadDocumentRequest ()), this, SIGNAL (loadDocumentRequest()));
|
connect (view, SIGNAL (loadDocumentRequest ()), this, SIGNAL (loadDocumentRequest()));
|
||||||
connect (view, SIGNAL (editSettingsRequest()), this, SIGNAL (editSettingsRequest()));
|
connect (view, SIGNAL (editSettingsRequest()), this, SIGNAL (editSettingsRequest()));
|
||||||
|
connect (view, SIGNAL (mergeDocument (CSMDoc::Document *)), this, SIGNAL (mergeDocument (CSMDoc::Document *)));
|
||||||
|
|
||||||
connect (&CSMSettings::UserSettings::instance(),
|
connect (&CSMSettings::UserSettings::instance(),
|
||||||
SIGNAL (userSettingUpdated(const QString &, const QStringList &)),
|
SIGNAL (userSettingUpdated(const QString &, const QStringList &)),
|
||||||
|
|
|
@ -77,6 +77,8 @@ namespace CSVDoc
|
||||||
|
|
||||||
void editSettingsRequest();
|
void editSettingsRequest();
|
||||||
|
|
||||||
|
void mergeDocument (CSMDoc::Document *document);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void exitApplication (CSVDoc::View *view);
|
void exitApplication (CSVDoc::View *view);
|
||||||
|
|
123
apps/opencs/view/tools/merge.cpp
Normal file
123
apps/opencs/view/tools/merge.cpp
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
|
||||||
|
#include "merge.hpp"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
#include "../../model/doc/document.hpp"
|
||||||
|
|
||||||
|
#include "../doc/filewidget.hpp"
|
||||||
|
#include "../doc/adjusterwidget.hpp"
|
||||||
|
|
||||||
|
CSVTools::Merge::Merge (QWidget *parent)
|
||||||
|
: QDialog (parent), mDocument (0)
|
||||||
|
{
|
||||||
|
setWindowTitle ("Merge Content Files into a new Game File");
|
||||||
|
|
||||||
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
|
setLayout (mainLayout);
|
||||||
|
|
||||||
|
QSplitter *splitter = new QSplitter (Qt::Horizontal, this);
|
||||||
|
|
||||||
|
mainLayout->addWidget (splitter, 1);
|
||||||
|
|
||||||
|
// left panel (files to be merged)
|
||||||
|
QWidget *left = new QWidget (this);
|
||||||
|
left->setContentsMargins (0, 0, 0, 0);
|
||||||
|
splitter->addWidget (left);
|
||||||
|
|
||||||
|
QVBoxLayout *leftLayout = new QVBoxLayout;
|
||||||
|
left->setLayout (leftLayout);
|
||||||
|
|
||||||
|
leftLayout->addWidget (new QLabel ("Files to be merged", this));
|
||||||
|
|
||||||
|
mFiles = new QListWidget (this);
|
||||||
|
leftLayout->addWidget (mFiles, 1);
|
||||||
|
|
||||||
|
// right panel (new game file)
|
||||||
|
QWidget *right = new QWidget (this);
|
||||||
|
right->setContentsMargins (0, 0, 0, 0);
|
||||||
|
splitter->addWidget (right);
|
||||||
|
|
||||||
|
QVBoxLayout *rightLayout = new QVBoxLayout;
|
||||||
|
rightLayout->setAlignment (Qt::AlignTop);
|
||||||
|
right->setLayout (rightLayout);
|
||||||
|
|
||||||
|
rightLayout->addWidget (new QLabel ("New game file", this));
|
||||||
|
|
||||||
|
mNewFile = new CSVDoc::FileWidget (this);
|
||||||
|
mNewFile->setType (false);
|
||||||
|
mNewFile->extensionLabelIsVisible (true);
|
||||||
|
rightLayout->addWidget (mNewFile);
|
||||||
|
|
||||||
|
mAdjuster = new CSVDoc::AdjusterWidget (this);
|
||||||
|
|
||||||
|
rightLayout->addWidget (mAdjuster);
|
||||||
|
|
||||||
|
connect (mNewFile, SIGNAL (nameChanged (const QString&, bool)),
|
||||||
|
mAdjuster, SLOT (setName (const QString&, bool)));
|
||||||
|
connect (mAdjuster, SIGNAL (stateChanged (bool)), this, SLOT (stateChanged (bool)));
|
||||||
|
|
||||||
|
// buttons
|
||||||
|
QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Cancel, Qt::Horizontal, this);
|
||||||
|
|
||||||
|
connect (buttons->button (QDialogButtonBox::Cancel), SIGNAL (clicked()), this, SLOT (reject()));
|
||||||
|
mOkay = new QPushButton ("Merge", this);
|
||||||
|
mOkay->setDefault (true);
|
||||||
|
buttons->addButton (mOkay, QDialogButtonBox::AcceptRole);
|
||||||
|
|
||||||
|
mainLayout->addWidget (buttons);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVTools::Merge::configure (CSMDoc::Document *document)
|
||||||
|
{
|
||||||
|
mDocument = document;
|
||||||
|
|
||||||
|
mNewFile->setName ("");
|
||||||
|
|
||||||
|
// content files
|
||||||
|
while (mFiles->count())
|
||||||
|
delete mFiles->takeItem (0);
|
||||||
|
|
||||||
|
std::vector<boost::filesystem::path> files = document->getContentFiles();
|
||||||
|
|
||||||
|
for (std::vector<boost::filesystem::path>::const_iterator iter (files.begin());
|
||||||
|
iter!=files.end(); ++iter)
|
||||||
|
mFiles->addItem (QString::fromUtf8 (iter->filename().string().c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVTools::Merge::setLocalData (const boost::filesystem::path& localData)
|
||||||
|
{
|
||||||
|
mAdjuster->setLocalData (localData);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMDoc::Document *CSVTools::Merge::getDocument() const
|
||||||
|
{
|
||||||
|
return mDocument;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVTools::Merge::cancel()
|
||||||
|
{
|
||||||
|
mDocument = 0;
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVTools::Merge::accept()
|
||||||
|
{
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVTools::Merge::reject()
|
||||||
|
{
|
||||||
|
QDialog::reject();
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVTools::Merge::stateChanged (bool valid)
|
||||||
|
{
|
||||||
|
mOkay->setEnabled (valid);
|
||||||
|
}
|
60
apps/opencs/view/tools/merge.hpp
Normal file
60
apps/opencs/view/tools/merge.hpp
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
#ifndef CSV_TOOLS_REPORTTABLE_H
|
||||||
|
#define CSV_TOOLS_REPORTTABLE_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
|
class QPushButton;
|
||||||
|
class QListWidget;
|
||||||
|
|
||||||
|
namespace CSMDoc
|
||||||
|
{
|
||||||
|
class Document;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSVDoc
|
||||||
|
{
|
||||||
|
class FileWidget;
|
||||||
|
class AdjusterWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSVTools
|
||||||
|
{
|
||||||
|
class Merge : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
CSMDoc::Document *mDocument;
|
||||||
|
QPushButton *mOkay;
|
||||||
|
QListWidget *mFiles;
|
||||||
|
CSVDoc::FileWidget *mNewFile;
|
||||||
|
CSVDoc::AdjusterWidget *mAdjuster;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Merge (QWidget *parent = 0);
|
||||||
|
|
||||||
|
/// Configure dialogue for a new merge
|
||||||
|
void configure (CSMDoc::Document *document);
|
||||||
|
|
||||||
|
void setLocalData (const boost::filesystem::path& localData);
|
||||||
|
|
||||||
|
CSMDoc::Document *getDocument() const;
|
||||||
|
|
||||||
|
void cancel();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
virtual void accept();
|
||||||
|
|
||||||
|
virtual void reject();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void stateChanged (bool valid);
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue