work save

This commit is contained in:
royqh1979@gmail.com 2021-09-09 18:36:54 +08:00
parent 98db43420c
commit 515a5a71fa
2 changed files with 61 additions and 3 deletions

View File

@ -670,6 +670,51 @@ int Project::getUnitFromString(const QString &s)
return indexInUnits(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 && topLeft<mUnits.count() && mUnits[topLeft]->editor()) {
mUnits[topLeft]->editor()->activate();
}
}
PCppParser Project::cppParser() PCppParser Project::cppParser()
{ {
return mParser; return mParser;
@ -700,6 +745,16 @@ int Project::indexInUnits(const Editor *editor) const
return indexInUnits(editor->filename()); return indexInUnits(editor->filename());
} }
std::shared_ptr<QSettings> &Project::iniFile()
{
return mIniFile;
}
void Project::setIniFile(const std::shared_ptr<QSettings> &newIniFile)
{
mIniFile = newIniFile;
}
const QString &Project::filename() const const QString &Project::filename() const
{ {
return mFilename; return mFilename;

View File

@ -163,6 +163,9 @@ public:
QChar getCompilerOption(const QString& optionString); QChar getCompilerOption(const QString& optionString);
QString getFolderPath(PFolderNode node); QString getFolderPath(PFolderNode node);
int getUnitFromString(const QString& s); int getUnitFromString(const QString& s);
void incrementBuildNumber();
QString listUnitStr(const QChar& separator);
void loadLayout(); // load all [UnitX]
int newUnit(bool newProject, int newUnit(bool newProject,
PFolderNode parentNode, PFolderNode parentNode,
@ -171,7 +174,6 @@ public:
Editor* openUnit(int index); Editor* openUnit(int index);
void saveUnitAs(int i, const QString& sFileName); // save single [UnitX] void saveUnitAs(int i, const QString& sFileName); // save single [UnitX]
void saveAll(); // save [Project] and all [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 loadUnitLayout(Editor *e, int index); // load single [UnitX] cursor positions
void saveLayout(); // save all [UnitX] void saveLayout(); // save all [UnitX]
void saveUnitLayout(Editor* e, int index); // save single [UnitX] cursor positions void saveUnitLayout(Editor* e, int index); // save single [UnitX] cursor positions
@ -184,19 +186,20 @@ public:
bool removeFolder(PFolderNode node); bool removeFolder(PFolderNode node);
bool removeEditor(int index, bool doClose); bool removeEditor(int index, bool doClose);
void rebuildNodes(); void rebuildNodes();
QString listUnitStr(const QChar& separator);
void showOptions(); void showOptions();
// bool assignTemplate(const QString& aFileName, const PTemplate& aTemplate); // bool assignTemplate(const QString& aFileName, const PTemplate& aTemplate);
void updateNodeIndexes(); void updateNodeIndexes();
void setNodeValue(PFolderNode value); void setNodeValue(PFolderNode value);
void incrementBuildNumber();
void setCompilerOption(const QString& optionString, const QChar& value); void setCompilerOption(const QString& optionString, const QChar& value);
void saveToLog(); void saveToLog();
std::shared_ptr<CppParser> cppParser(); std::shared_ptr<CppParser> cppParser();
const QString &filename() const; const QString &filename() const;
std::shared_ptr<QSettings> &iniFile();
void setIniFile(const std::shared_ptr<QSettings> &newIniFile);
signals: signals:
void nodesChanged(); void nodesChanged();
void modifyChanged(bool value); void modifyChanged(bool value);