added UI for merge tool (merge tool itself is still missing)

sceneinput
Marc Zinnschlag 10 years ago
parent 9ee3f1bfe7
commit b83f9445a9

@ -94,7 +94,7 @@ opencs_hdrs_noqt (view/render
opencs_units (view/tools
reportsubview reporttable searchsubview searchbox
reportsubview reporttable searchsubview searchbox merge
)
opencs_units_noqt (view/tools

@ -40,9 +40,12 @@ CS::Editor::Editor ()
mNewGame.setLocalData (mLocal);
mFileDialog.setLocalData (mLocal);
mMerge.setLocalData (mLocal);
connect (&mDocumentManager, SIGNAL (documentAdded (CSMDoc::Document *)),
this, SLOT (documentAdded (CSMDoc::Document *)));
connect (&mDocumentManager, SIGNAL (documentAboutToBeRemoved (CSMDoc::Document *)),
this, SLOT (documentAboutToBeRemoved (CSMDoc::Document *)));
connect (&mDocumentManager, SIGNAL (lastDocumentDeleted()),
this, SLOT (lastDocumentDeleted()));
@ -50,6 +53,7 @@ CS::Editor::Editor ()
connect (&mViewManager, SIGNAL (newAddonRequest ()), this, SLOT (createAddon ()));
connect (&mViewManager, SIGNAL (loadDocumentRequest ()), this, SLOT (loadDocument ()));
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 (createAddon()), this, SLOT (createAddon ()));
@ -360,7 +364,19 @@ void CS::Editor::documentAdded (CSMDoc::Document *document)
mViewManager.addView (document);
}
void CS::Editor::documentAboutToBeRemoved (CSMDoc::Document *document)
{
if (mMerge.getDocument()==document)
mMerge.cancel();
}
void CS::Editor::lastDocumentDeleted()
{
QApplication::quit();
}
void CS::Editor::mergeDocument (CSMDoc::Document *document)
{
mMerge.configure (document);
mMerge.show();
}

@ -27,11 +27,18 @@
#include "view/settings/dialog.hpp"
#include "view/tools/merge.hpp"
namespace VFS
{
class Manager;
}
namespace CSMDoc
{
class Document;
}
namespace CS
{
class Editor : public QObject
@ -55,6 +62,7 @@ namespace CS
boost::interprocess::file_lock mLock;
boost::filesystem::ofstream mPidFile;
bool mFsStrict;
CSVTools::Merge mMerge;
void setupDataFiles (const Files::PathContainer& dataDirs);
@ -94,8 +102,12 @@ namespace CS
void documentAdded (CSMDoc::Document *document);
void documentAboutToBeRemoved (CSMDoc::Document *document);
void lastDocumentDeleted();
void mergeDocument (CSMDoc::Document *document);
private:
QString mIpcServerName;

@ -73,6 +73,8 @@ void CSMDoc::DocumentManager::removeDocument (CSMDoc::Document *document)
if (iter==mDocuments.end())
throw std::runtime_error ("removing invalid document");
emit documentAboutToBeRemoved (document);
mDocuments.erase (iter);
document->deleteLater();

@ -88,6 +88,8 @@ namespace CSMDoc
void documentAdded (CSMDoc::Document *document);
void documentAboutToBeRemoved (CSMDoc::Document *document);
void loadRequest (CSMDoc::Document *document);
void lastDocumentDeleted();

@ -56,3 +56,11 @@ void CSVDoc::FileWidget::extensionLabelIsVisible(bool 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 <string>
class QLabel;
class QString;
class QLineEdit;
@ -29,6 +31,8 @@ namespace CSVDoc
void extensionLabelIsVisible(bool visible);
void setName (const std::string& text);
private slots:
void textChanged (const QString& text);

@ -66,6 +66,10 @@ void CSVDoc::View::setupFileMenu()
connect (mVerify, SIGNAL (triggered()), this, SLOT (verify()));
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);
connect (loadErrors, SIGNAL (triggered()), this, SLOT (loadErrorLog()));
file->addAction (loadErrors);
@ -393,6 +397,8 @@ void CSVDoc::View::updateActions()
mGlobalDebugProfileMenu->updateActions (running);
mStopDebug->setEnabled (running);
mMerge->setEnabled (mDocument->getContentFiles().size()>1);
}
CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews)
@ -969,3 +975,8 @@ void CSVDoc::View::updateScrollbar()
else
mSubViewWindow.setMinimumWidth(0);
}
void CSVDoc::View::merge()
{
emit mergeDocument (mDocument);
}

@ -43,6 +43,7 @@ namespace CSVDoc
QAction *mVerify;
QAction *mShowStatusBar;
QAction *mStopDebug;
QAction *mMerge;
std::vector<QAction *> mEditingActions;
Operations *mOperations;
SubViewFactoryManager mSubViewFactory;
@ -129,6 +130,8 @@ namespace CSVDoc
void editSettingsRequest();
void mergeDocument (CSMDoc::Document *document);
public slots:
void addSubView (const CSMWorld::UniversalId& id, const std::string& hint = "");
@ -237,6 +240,8 @@ namespace CSVDoc
void closeRequest (SubView *subView);
void moveScrollBarToEnd(int min, int max);
void merge();
};
}

@ -175,6 +175,7 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document)
connect (view, SIGNAL (newAddonRequest ()), this, SIGNAL (newAddonRequest()));
connect (view, SIGNAL (loadDocumentRequest ()), this, SIGNAL (loadDocumentRequest()));
connect (view, SIGNAL (editSettingsRequest()), this, SIGNAL (editSettingsRequest()));
connect (view, SIGNAL (mergeDocument (CSMDoc::Document *)), this, SIGNAL (mergeDocument (CSMDoc::Document *)));
connect (&CSMSettings::UserSettings::instance(),
SIGNAL (userSettingUpdated(const QString &, const QStringList &)),

@ -77,6 +77,8 @@ namespace CSVDoc
void editSettingsRequest();
void mergeDocument (CSMDoc::Document *document);
public slots:
void exitApplication (CSVDoc::View *view);

@ -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);
}

@ -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…
Cancel
Save