1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 10:09:39 +00:00

Move OpenDialog to editor and use it in startup dialogue.

Remove debug output from DataFilesList.
This commit is contained in:
Michal Sciubidlo 2013-02-05 22:06:36 +01:00
parent f7e5ea24f4
commit 347a734364
5 changed files with 21 additions and 50 deletions

View file

@ -15,6 +15,8 @@ CS::Editor::Editor() : mViewManager (mDocumentManager), mNewDocumentIndex (0)
connect (&mStartup, SIGNAL (createDocument()), this, SLOT (createDocument ())); connect (&mStartup, SIGNAL (createDocument()), this, SLOT (createDocument ()));
connect (&mStartup, SIGNAL (loadDocument()), this, SLOT (loadDocument ())); connect (&mStartup, SIGNAL (loadDocument()), this, SLOT (loadDocument ()));
connect (&mOpenDialog, SIGNAL(accepted()), this, SLOT(openFiles()));
} }
void CS::Editor::createDocument() void CS::Editor::createDocument()
@ -36,26 +38,24 @@ void CS::Editor::createDocument()
} }
void CS::Editor::loadDocument() void CS::Editor::loadDocument()
{
mOpenDialog.show();
mOpenDialog.raise();
mOpenDialog.activateWindow();
}
void CS::Editor::openFiles()
{ {
mStartup.hide(); mStartup.hide();
std::vector<boost::filesystem::path> paths;
/// \todo open the ESX picker instead mOpenDialog.getFileList(paths);
/// \todo remove the manual record creation and load the ESX files instead CSMDoc::Document *document = mDocumentManager.addDocument(paths, false);
std::ostringstream stream;
stream << "Document" << (++mNewDocumentIndex);
std::vector<boost::filesystem::path> files;
files.push_back (stream.str());
CSMDoc::Document *document = mDocumentManager.addDocument (files, false);
static const char *sGlobals[] = static const char *sGlobals[] =
{ {
"Day", "DaysPassed", "GameHour", "Month", "PCRace", "PCVampire", "PCWerewolf", "PCYear", 0 "Day", "DaysPassed", "GameHour", "Month", "PCRace", "PCVampire", "PCWerewolf", "PCYear", 0
}; };
for (int i=0; sGlobals[i]; ++i) for (int i=0; sGlobals[i]; ++i)
{ {
ESM::Global record; ESM::Global record;
@ -64,9 +64,9 @@ void CS::Editor::loadDocument()
record.mType = ESM::VT_Float; record.mType = ESM::VT_Float;
document->getData().getGlobals().add (record); document->getData().getGlobals().add (record);
} }
document->getData().merge(); /// \todo remove once proper ESX loading is implemented document->getData().merge(); /// \todo remove once proper ESX loading is implemented
mViewManager.addView (document); mViewManager.addView (document);
} }

View file

@ -7,6 +7,7 @@
#include "view/doc/viewmanager.hpp" #include "view/doc/viewmanager.hpp"
#include "view/doc/startup.hpp" #include "view/doc/startup.hpp"
#include "view/doc/opendialog.hpp"
namespace CS namespace CS
{ {
@ -19,6 +20,7 @@ namespace CS
CSMDoc::DocumentManager mDocumentManager; CSMDoc::DocumentManager mDocumentManager;
CSVDoc::ViewManager mViewManager; CSVDoc::ViewManager mViewManager;
CSVDoc::StartupDialogue mStartup; CSVDoc::StartupDialogue mStartup;
OpenDialog mOpenDialog;
// not implemented // not implemented
Editor (const Editor&); Editor (const Editor&);
@ -36,6 +38,7 @@ namespace CS
void createDocument(); void createDocument();
void loadDocument(); void loadDocument();
void openFiles();
}; };
} }

View file

@ -14,7 +14,6 @@
#include "../tools/subviews.hpp" #include "../tools/subviews.hpp"
#include "opendialog.hpp"
#include "viewmanager.hpp" #include "viewmanager.hpp"
#include "operations.hpp" #include "operations.hpp"
#include "subview.hpp" #include "subview.hpp"
@ -32,12 +31,8 @@ void CSVDoc::View::setupFileMenu()
QAction *new_ = new QAction (tr ("New"), this); QAction *new_ = new QAction (tr ("New"), this);
connect (new_, SIGNAL (triggered()), this, SIGNAL (newDocumentRequest())); connect (new_, SIGNAL (triggered()), this, SIGNAL (newDocumentRequest()));
file->addAction (new_); file->addAction (new_);
mOpen = new QAction(tr ("&Open"), this);
connect (mOpen, SIGNAL (triggered()), this, SLOT (open()));
file->addAction (mOpen);
QAction *open = new QAction (tr ("Open"), this); QAction *open = new QAction (tr ("&Open"), this);
connect (open, SIGNAL (triggered()), this, SIGNAL (loadDocumentRequest())); connect (open, SIGNAL (triggered()), this, SIGNAL (loadDocumentRequest()));
file->addAction (open); file->addAction (open);
@ -119,7 +114,7 @@ void CSVDoc::View::updateActions()
} }
CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews) CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews)
: mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1), mViewTotal (totalViews), mOpenDialog(0) : mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1), mViewTotal (totalViews)
{ {
setDockOptions (QMainWindow::AllowNestedDocks); setDockOptions (QMainWindow::AllowNestedDocks);
@ -214,26 +209,6 @@ void CSVDoc::View::save()
mDocument->save(); mDocument->save();
} }
void CSVDoc::View::open()
{
if (!mOpenDialog) {
mOpenDialog = new OpenDialog(this);
connect(mOpenDialog, SIGNAL(accepted()), this, SLOT(openNewFiles()));
}
mOpenDialog->show();
mOpenDialog->raise();
mOpenDialog->activateWindow();
}
void CSVDoc::View::openNewFiles()
{
std::vector<boost::filesystem::path> paths;
mOpenDialog->getFileList(paths);
//FIXME load new files
}
void CSVDoc::View::verify() void CSVDoc::View::verify()
{ {
addSubView (mDocument->verify()); addSubView (mDocument->verify());

View file

@ -9,7 +9,6 @@
#include "subviewfactory.hpp" #include "subviewfactory.hpp"
class QAction; class QAction;
class OpenDialog;
namespace CSMDoc namespace CSMDoc
{ {
@ -37,12 +36,10 @@ namespace CSVDoc
QAction *mUndo; QAction *mUndo;
QAction *mRedo; QAction *mRedo;
QAction *mSave; QAction *mSave;
QAction *mOpen;
QAction *mVerify; QAction *mVerify;
std::vector<QAction *> mEditingActions; std::vector<QAction *> mEditingActions;
Operations *mOperations; Operations *mOperations;
SubViewFactoryManager mSubViewFactory; SubViewFactoryManager mSubViewFactory;
OpenDialog * mOpenDialog;
// not implemented // not implemented
View (const View&); View (const View&);
@ -97,8 +94,6 @@ namespace CSVDoc
void newView(); void newView();
void open();
void openNewFiles();
void save(); void save();
void verify(); void verify();

View file

@ -204,13 +204,11 @@ void DataFilesList::selectedFiles(std::vector<boost::filesystem::path>& paths)
foreach (const QString &path, masterPaths) foreach (const QString &path, masterPaths)
{ {
paths.push_back(path.toStdString()); paths.push_back(path.toStdString());
cerr << path.toStdString() << endl;
} }
QStringList pluginPaths = mPluginsModel->checkedItemsPaths(); QStringList pluginPaths = mPluginsModel->checkedItemsPaths();
foreach (const QString &path, pluginPaths) foreach (const QString &path, pluginPaths)
{ {
paths.push_back(path.toStdString()); paths.push_back(path.toStdString());
cerr << path.toStdString() << endl;
} }
} }