Merge remote-tracking branch 'cc9cii/master'

c++11
Marc Zinnschlag 10 years ago
commit 62c5f185d7

@ -95,7 +95,7 @@ void CS::Editor::setupDataFiles (const Files::PathContainer& dataDirs)
} }
} }
std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfig() std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfig(bool quiet)
{ {
boost::program_options::variables_map variables; boost::program_options::variables_map variables;
boost::program_options::options_description desc("Syntax: openmw-cs <options>\nAllowed options"); boost::program_options::options_description desc("Syntax: openmw-cs <options>\nAllowed options");
@ -115,7 +115,7 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
boost::program_options::notify(variables); boost::program_options::notify(variables);
mCfgMgr.readConfiguration(variables, desc); mCfgMgr.readConfiguration(variables, desc, quiet);
mDocumentManager.setEncoding ( mDocumentManager.setEncoding (
ToUTF8::calculateEncoding (variables["encoding"].as<std::string>())); ToUTF8::calculateEncoding (variables["encoding"].as<std::string>()));
@ -195,6 +195,11 @@ void CS::Editor::cancelCreateGame()
void CS::Editor::createAddon() void CS::Editor::createAddon()
{ {
mStartup.hide(); mStartup.hide();
mFileDialog.clearFiles();
std::pair<Files::PathContainer, std::vector<std::string> > config = readConfig(/*quiet*/true);
setupDataFiles (config.first);
mFileDialog.showDialog (CSVDoc::ContentAction_New); mFileDialog.showDialog (CSVDoc::ContentAction_New);
} }
@ -215,6 +220,11 @@ void CS::Editor::cancelFileDialog()
void CS::Editor::loadDocument() void CS::Editor::loadDocument()
{ {
mStartup.hide(); mStartup.hide();
mFileDialog.clearFiles();
std::pair<Files::PathContainer, std::vector<std::string> > config = readConfig(/*quiet*/true);
setupDataFiles (config.first);
mFileDialog.showDialog (CSVDoc::ContentAction_Edit); mFileDialog.showDialog (CSVDoc::ContentAction_Edit);
} }

@ -62,7 +62,7 @@ namespace CS
void setupDataFiles (const Files::PathContainer& dataDirs); void setupDataFiles (const Files::PathContainer& dataDirs);
std::pair<Files::PathContainer, std::vector<std::string> > readConfig(); std::pair<Files::PathContainer, std::vector<std::string> > readConfig(bool quiet=false);
///< \return data paths ///< \return data paths
// not implemented // not implemented

@ -33,6 +33,11 @@ void CSVDoc::FileDialog::addFiles(const QString &path)
mSelector->addFiles(path); mSelector->addFiles(path);
} }
void CSVDoc::FileDialog::clearFiles()
{
mSelector->clearFiles();
}
QStringList CSVDoc::FileDialog::selectedFilePaths() QStringList CSVDoc::FileDialog::selectedFilePaths()
{ {
QStringList filePaths; QStringList filePaths;
@ -105,7 +110,6 @@ void CSVDoc::FileDialog::buildNewFileView()
connect (mFileWidget, SIGNAL (nameChanged(const QString &, bool)), connect (mFileWidget, SIGNAL (nameChanged(const QString &, bool)),
this, SLOT (slotUpdateAcceptButton(const QString &, bool))); this, SLOT (slotUpdateAcceptButton(const QString &, bool)));
} }
ui.projectGroupBoxLayout->insertWidget (0, mFileWidget); ui.projectGroupBoxLayout->insertWidget (0, mFileWidget);
@ -139,7 +143,7 @@ void CSVDoc::FileDialog::slotUpdateAcceptButton(int)
{ {
QString name = ""; QString name = "";
if (mAction == ContentAction_New) if (mFileWidget && mAction == ContentAction_New)
name = mFileWidget->getName(); name = mFileWidget->getName();
slotUpdateAcceptButton (name, true); slotUpdateAcceptButton (name, true);

@ -45,6 +45,7 @@ namespace CSVDoc
void showDialog (ContentAction action); void showDialog (ContentAction action);
void addFiles (const QString &path); void addFiles (const QString &path);
void clearFiles ();
QString filename() const; QString filename() const;
QStringList selectedFilePaths(); QStringList selectedFilePaths();

@ -473,6 +473,13 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path)
sortFiles(); sortFiles();
} }
void ContentSelectorModel::ContentModel::clearFiles()
{
beginRemoveRows(QModelIndex(), 0, mFiles.count()-1);
mFiles.clear();
endRemoveRows();
}
QStringList ContentSelectorModel::ContentModel::gameFiles() const QStringList ContentSelectorModel::ContentModel::gameFiles() const
{ {
QStringList gameFiles; QStringList gameFiles;

@ -44,6 +44,7 @@ namespace ContentSelectorModel
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
void addFiles(const QString &path); void addFiles(const QString &path);
void clearFiles();
QModelIndex indexFromItem(const EsmFile *item) const; QModelIndex indexFromItem(const EsmFile *item) const;
const EsmFile *item(const QString &name) const; const EsmFile *item(const QString &name) const;

@ -150,6 +150,11 @@ void ContentSelectorView::ContentSelector::addFiles(const QString &path)
mContentModel->uncheckAll(); mContentModel->uncheckAll();
} }
void ContentSelectorView::ContentSelector::clearFiles()
{
mContentModel->clearFiles();
}
QString ContentSelectorView::ContentSelector::currentFile() const QString ContentSelectorView::ContentSelector::currentFile() const
{ {
QModelIndex currentIdx = ui.addonView->currentIndex(); QModelIndex currentIdx = ui.addonView->currentIndex();

@ -29,6 +29,7 @@ namespace ContentSelectorView
QString currentFile() const; QString currentFile() const;
void addFiles(const QString &path); void addFiles(const QString &path);
void clearFiles();
void setProfileContent (const QStringList &fileList); void setProfileContent (const QStringList &fileList);
void clearCheckStates(); void clearCheckStates();

@ -52,8 +52,11 @@ void ConfigurationManager::setupTokensMapping()
} }
void ConfigurationManager::readConfiguration(boost::program_options::variables_map& variables, void ConfigurationManager::readConfiguration(boost::program_options::variables_map& variables,
boost::program_options::options_description& description) boost::program_options::options_description& description, bool quiet)
{ {
bool silent = mSilent;
mSilent = quiet;
loadConfig(mFixedPath.getUserConfigPath(), variables, description); loadConfig(mFixedPath.getUserConfigPath(), variables, description);
boost::program_options::notify(variables); boost::program_options::notify(variables);
@ -62,6 +65,7 @@ void ConfigurationManager::readConfiguration(boost::program_options::variables_m
loadConfig(mFixedPath.getGlobalConfigPath(), variables, description); loadConfig(mFixedPath.getGlobalConfigPath(), variables, description);
boost::program_options::notify(variables); boost::program_options::notify(variables);
mSilent = silent;
} }
void ConfigurationManager::processPaths(Files::PathContainer& dataDirs, bool create) void ConfigurationManager::processPaths(Files::PathContainer& dataDirs, bool create)

@ -29,7 +29,7 @@ struct ConfigurationManager
virtual ~ConfigurationManager(); virtual ~ConfigurationManager();
void readConfiguration(boost::program_options::variables_map& variables, void readConfiguration(boost::program_options::variables_map& variables,
boost::program_options::options_description& description); boost::program_options::options_description& description, bool quiet=false);
void processPaths(Files::PathContainer& dataDirs, bool create = false); void processPaths(Files::PathContainer& dataDirs, bool create = false);
///< \param create Try creating the directory, if it does not exist. ///< \param create Try creating the directory, if it does not exist.

Loading…
Cancel
Save