From 515a5a71fadb40abeef7aa5de12cee6dde549660 Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Thu, 9 Sep 2021 18:36:54 +0800 Subject: [PATCH] work save --- RedPandaIDE/project.cpp | 55 +++++++++++++++++++++++++++++++++++++++++ RedPandaIDE/project.h | 9 ++++--- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index 529391cb..0dbb036a 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -670,6 +670,51 @@ int Project::getUnitFromString(const QString &s) return indexInUnits(s); } +void Project::incrementBuildNumber() +{ + mOptions.versionInfo.build++; + mOptions.versionInfo.fileVersion = QString("%1.%2.%3.%3") + .arg(mOptions.versionInfo.major) + .arg(mOptions.versionInfo.minor) + .arg(mOptions.versionInfo.release) + .arg(mOptions.versionInfo.build); + if (mOptions.versionInfo.syncProduct) + mOptions.versionInfo.productVersion = mOptions.versionInfo.fileVersion; + setModified(true); +} + +QString Project::listUnitStr(const QChar &separator) +{ + QStringList units; + foreach (const PProjectUnit& unit, mUnits) { + units.append('"'+unit->fileName()+'"'); + } + return units.join(separator); +} + +void Project::loadLayout() +{ + QSettings layIni = QSettings(changeFileExt(filename(), "layout"),QSettings::IniFormat); + layIni.beginGroup("Editors"); + int topLeft = layIni.value("Focused", -1).toInt(); + //TopRight := layIni.ReadInteger('Editors', 'FocusedRight', -1); + QString temp =layIni.value("Order", "").toString(); + layIni.endGroup(); + QStringList sl = temp.split(","); + + foreach (const QString& s,sl) { + bool ok; + int currIdx = s.toInt(&ok); + if (ok) { + openUnit(currIdx); + } + } + if (topLeft>=0 && topLefteditor()) { + mUnits[topLeft]->editor()->activate(); + } + +} + PCppParser Project::cppParser() { return mParser; @@ -700,6 +745,16 @@ int Project::indexInUnits(const Editor *editor) const return indexInUnits(editor->filename()); } +std::shared_ptr &Project::iniFile() +{ + return mIniFile; +} + +void Project::setIniFile(const std::shared_ptr &newIniFile) +{ + mIniFile = newIniFile; +} + const QString &Project::filename() const { return mFilename; diff --git a/RedPandaIDE/project.h b/RedPandaIDE/project.h index c752225a..87048e78 100644 --- a/RedPandaIDE/project.h +++ b/RedPandaIDE/project.h @@ -163,6 +163,9 @@ public: QChar getCompilerOption(const QString& optionString); QString getFolderPath(PFolderNode node); int getUnitFromString(const QString& s); + void incrementBuildNumber(); + QString listUnitStr(const QChar& separator); + void loadLayout(); // load all [UnitX] int newUnit(bool newProject, PFolderNode parentNode, @@ -171,7 +174,6 @@ public: Editor* openUnit(int index); void saveUnitAs(int i, const QString& sFileName); // save single [UnitX] void saveAll(); // save [Project] and all [UnitX] - void loadLayout(); // load all [UnitX] void loadUnitLayout(Editor *e, int index); // load single [UnitX] cursor positions void saveLayout(); // save all [UnitX] void saveUnitLayout(Editor* e, int index); // save single [UnitX] cursor positions @@ -184,19 +186,20 @@ public: bool removeFolder(PFolderNode node); bool removeEditor(int index, bool doClose); void rebuildNodes(); - QString listUnitStr(const QChar& separator); void showOptions(); // bool assignTemplate(const QString& aFileName, const PTemplate& aTemplate); void updateNodeIndexes(); void setNodeValue(PFolderNode value); - void incrementBuildNumber(); void setCompilerOption(const QString& optionString, const QChar& value); void saveToLog(); std::shared_ptr cppParser(); const QString &filename() const; + std::shared_ptr &iniFile(); + void setIniFile(const std::shared_ptr &newIniFile); + signals: void nodesChanged(); void modifyChanged(bool value);