Fix for file path issues

actorid
graffy76 11 years ago
parent ba365ff49e
commit 9b483c3ae3

@ -20,6 +20,7 @@ CS::Editor::Editor()
setupDataFiles();
mNewGame.setLocalData (mLocal);
mFileDialog.setLocalData (mLocal);
connect (&mViewManager, SIGNAL (newGameRequest ()), this, SLOT (createGame ()));
connect (&mViewManager, SIGNAL (newAddonRequest ()), this, SLOT (createAddon ()));
@ -31,9 +32,11 @@ CS::Editor::Editor()
connect (&mStartup, SIGNAL (loadDocument()), this, SLOT (loadDocument ()));
connect (&mStartup, SIGNAL (editConfig()), this, SLOT (showSettings ()));
connect (&mFileDialog, SIGNAL(openFiles()), this, SLOT(openFiles()));
connect (&mFileDialog, SIGNAL(createNewFile ()),
this, SLOT(createNewFile ()));
connect (&mFileDialog, SIGNAL(signalOpenFiles (const boost::filesystem::path&)),
this, SLOT(openFiles (const boost::filesystem::path&)));
connect (&mFileDialog, SIGNAL(signalCreateNewFile (const boost::filesystem::path&)),
this, SLOT(createNewFile (const boost::filesystem::path&)));
connect (&mNewGame, SIGNAL (createRequest (const boost::filesystem::path&)),
this, SLOT (createNewGame (const boost::filesystem::path&)));
@ -125,15 +128,12 @@ void CS::Editor::loadDocument()
mFileDialog.showDialog (CSVDoc::FileDialog::DialogType_Open);
}
void CS::Editor::openFiles()
void CS::Editor::openFiles (const boost::filesystem::path &savePath)
{
std::vector<boost::filesystem::path> files;
foreach (const QString &path, mFileDialog.selectedFilePaths()) {
foreach (const QString &path, mFileDialog.selectedFilePaths())
files.push_back(path.toStdString());
}
boost::filesystem::path savePath = mFileDialog.filename().toStdString();
CSMDoc::Document *document = mDocumentManager.addDocument (files, savePath, false);
@ -141,7 +141,7 @@ void CS::Editor::openFiles()
mFileDialog.hide();
}
void CS::Editor::createNewFile ()
void CS::Editor::createNewFile (const boost::filesystem::path &savePath)
{
std::vector<boost::filesystem::path> files;
@ -151,8 +151,6 @@ void CS::Editor::createNewFile ()
files.push_back(mFileDialog.filename().toStdString());
boost::filesystem::path savePath = mFileDialog.filename().toStdString();
CSMDoc::Document *document = mDocumentManager.addDocument (files, savePath, true);
mViewManager.addView (document);

@ -59,8 +59,8 @@ namespace CS
void createAddon();
void loadDocument();
void openFiles();
void createNewFile ();
void openFiles (const boost::filesystem::path &path);
void createNewFile (const boost::filesystem::path& path);
void createNewGame (const boost::filesystem::path& file);
void showStartup();

@ -17,14 +17,17 @@
#include "filewidget.hpp"
#include "adjusterwidget.hpp"
#include <QDebug>
CSVDoc::FileDialog::FileDialog(QWidget *parent) :
QDialog(parent), mSelector (0)
QDialog(parent), mSelector (0), mFileWidget (0), mAdjusterWidget (0)
{
ui.setupUi (this);
resize(400, 400);
setObjectName ("FileDialog");
mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget);
mAdjusterWidget = new AdjusterWidget (this);
}
void CSVDoc::FileDialog::addFiles(const QString &path)
@ -42,6 +45,14 @@ QStringList CSVDoc::FileDialog::selectedFilePaths()
return filePaths;
}
void CSVDoc::FileDialog::setLocalData (const boost::filesystem::path& localData)
{
if (mDialogType != DialogType_New)
return;
mAdjusterWidget->setLocalData (localData);
}
void CSVDoc::FileDialog::showDialog(DialogType dialogType)
{
mDialogType = dialogType;
@ -63,7 +74,6 @@ void CSVDoc::FileDialog::showDialog(DialogType dialogType)
connect (mSelector, SIGNAL (signalCurrentGamefileIndexChanged (int)),
this, SLOT (slotUpdateAcceptButton (int)));
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SIGNAL (createNewFile()));
connect (ui.projectButtonBox, SIGNAL (rejected()), this, SLOT (slotRejected()));
show();
@ -85,17 +95,26 @@ void CSVDoc::FileDialog::buildNewFileView()
mFileWidget->extensionLabelIsVisible(true);
ui.projectGroupBoxLayout->insertWidget (0, mFileWidget);
ui.projectGroupBoxLayout->insertWidget (1, mAdjusterWidget);
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.projectGroupBox->layout()->addWidget (mAdjusterWidget);
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled (false);
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile()));
}
void CSVDoc::FileDialog::slotUpdateAcceptButton (int)
@ -121,7 +140,7 @@ void CSVDoc::FileDialog::slotUpdateAcceptButton(const QString &name, bool)
QString CSVDoc::FileDialog::filename() const
{
if (mDialogType == DialogType_New)
return mFileWidget->getName();
return "";
return mSelector->currentFile();
}
@ -131,3 +150,17 @@ void CSVDoc::FileDialog::slotRejected()
emit rejected();
close();
}
void CSVDoc::FileDialog::slotNewFile()
{
emit signalCreateNewFile (mAdjusterWidget->getPath());
}
void CSVDoc::FileDialog::slotOpenFile()
{
ContentSelectorModel::EsmFile *file = mSelector->selectedFiles().back();
mAdjusterWidget->setName (file->fileName(), !file->isGameFile());
emit signalOpenFiles (mAdjusterWidget->getPath());
}

@ -4,6 +4,13 @@
#include <QDialog>
#include <QModelIndex>
#include <boost/filesystem/path.hpp>
#ifndef CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
#define CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
Q_DECLARE_METATYPE (boost::filesystem::path)
#endif
#include "ui_filedialog.h"
class DataFilesModel;
@ -17,6 +24,7 @@ namespace ContentSelectorView
namespace CSVDoc
{
class FileWidget;
class AdjusterWidget;
class FileDialog : public QDialog
{
@ -36,6 +44,7 @@ namespace CSVDoc
Ui::FileDialog ui;
DialogType mDialogType;
FileWidget *mFileWidget;
AdjusterWidget *mAdjusterWidget;
public:
@ -47,6 +56,8 @@ namespace CSVDoc
QString filename() const;
QStringList selectedFilePaths();
void setLocalData (const boost::filesystem::path& localData);
private:
void buildNewFileView();
@ -54,13 +65,15 @@ namespace CSVDoc
signals:
void openFiles();
void createNewFile ();
void signalOpenFiles (const boost::filesystem::path &path);
void signalCreateNewFile (const boost::filesystem::path &path);
void signalUpdateAcceptButton (bool, int);
private slots:
void slotNewFile();
void slotOpenFile();
void slotUpdateAcceptButton (int);
void slotUpdateAcceptButton (const QString &, bool);
void slotRejected();

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>518</width>
<height>108</height>
<height>109</height>
</rect>
</property>
<property name="sizePolicy">
@ -52,7 +52,7 @@
</property>
<item>
<widget class="QWidget" name="projectWidget" native="true">
<layout class="QHBoxLayout" name="projectButtonBoxLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QDialogButtonBox" name="projectButtonBox">
<property name="standardButtons">

Loading…
Cancel
Save