work save
This commit is contained in:
parent
c120d0a23f
commit
98db43420c
|
@ -11,6 +11,7 @@
|
|||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include "settings.h"
|
||||
|
||||
Project::Project(const QString &filename, const QString &name, QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
@ -34,13 +35,13 @@ Project::Project(const QString &filename, const QString &name, QObject *parent)
|
|||
}
|
||||
}
|
||||
|
||||
QString Project::directory()
|
||||
QString Project::directory() const
|
||||
{
|
||||
QFileInfo fileInfo(mFilename);
|
||||
return fileInfo.absolutePath();
|
||||
}
|
||||
|
||||
QString Project::executable()
|
||||
QString Project::executable() const
|
||||
{
|
||||
QString exeFileName;
|
||||
if (mOptions.overrideOutput && !mOptions.overridenOutput.isEmpty()) {
|
||||
|
@ -76,7 +77,7 @@ QString Project::makeFileName()
|
|||
return QDir(directory()).filePath(MAKEFILE_NAME);
|
||||
}
|
||||
|
||||
bool Project::modified()
|
||||
bool Project::modified() const
|
||||
{
|
||||
// Project file modified? Done
|
||||
if (mModified)
|
||||
|
@ -633,6 +634,42 @@ PFolderNode Project::folderNodeFromName(const QString &name)
|
|||
return mNode;
|
||||
}
|
||||
|
||||
QChar Project::getCompilerOption(const QString &optionString)
|
||||
{
|
||||
// Does the option exist?
|
||||
Settings::PCompilerSet compilerSet = pSettings->compilerSets().getSet(mOptions.compilerSet);
|
||||
if (!compilerSet)
|
||||
return '0';
|
||||
int index = compilerSet->findOptionIndex(optionString);
|
||||
if (index>=0 && index<mOptions.compilerOptions.length()) {
|
||||
return mOptions.compilerOptions[index];
|
||||
}
|
||||
return '0';
|
||||
}
|
||||
|
||||
QString Project::getFolderPath(PFolderNode node)
|
||||
{
|
||||
QString result;
|
||||
if (!node)
|
||||
return result;
|
||||
|
||||
if (node->unitIndex>=0) // not a folder
|
||||
return result;
|
||||
|
||||
FolderNode* p = node.get();
|
||||
while (p && p->unitIndex==-1) {
|
||||
if (!result.isEmpty())
|
||||
result = p->text + "/" + result;
|
||||
p = p->parent;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int Project::getUnitFromString(const QString &s)
|
||||
{
|
||||
return indexInUnits(s);
|
||||
}
|
||||
|
||||
PCppParser Project::cppParser()
|
||||
{
|
||||
return mParser;
|
||||
|
@ -645,6 +682,24 @@ void Project::sortUnitsByPriority()
|
|||
});
|
||||
}
|
||||
|
||||
int Project::indexInUnits(const QString &fileName) const
|
||||
{
|
||||
QDir dir(directory());
|
||||
for (int i=0;i<mUnits.count();i++) {
|
||||
PProjectUnit unit = mUnits[i];
|
||||
if (dir.absoluteFilePath(fileName) == dir.absoluteFilePath(unit->fileName()))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Project::indexInUnits(const Editor *editor) const
|
||||
{
|
||||
if (!editor)
|
||||
return -1;
|
||||
return indexInUnits(editor->filename());
|
||||
}
|
||||
|
||||
const QString &Project::filename() const
|
||||
{
|
||||
return mFilename;
|
||||
|
|
|
@ -142,10 +142,10 @@ class Project : public QObject
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit Project(const QString& filename, const QString& name,QObject *parent = nullptr);
|
||||
QString directory();
|
||||
QString executable();
|
||||
QString directory() const;
|
||||
QString executable() const;
|
||||
QString makeFileName();
|
||||
bool modified();
|
||||
bool modified() const;
|
||||
void setFileName(const QString& value);
|
||||
void setModified(bool value);
|
||||
|
||||
|
@ -160,11 +160,13 @@ public:
|
|||
void doAutoOpen();
|
||||
bool fileAlreadyExists(const QString& s);
|
||||
PFolderNode folderNodeFromName(const QString& name);
|
||||
QChar getCompilerOption(const QString& optionString);
|
||||
QString getFolderPath(PFolderNode node);
|
||||
int getUnitFromString(const QString& s);
|
||||
|
||||
int newUnit(bool newProject,
|
||||
PFolderNode parentNode,
|
||||
const QString customFileName);
|
||||
QString getFolderPath(PFolderNode node);
|
||||
void updateFolders();
|
||||
Editor* openUnit(int index);
|
||||
void saveUnitAs(int i, const QString& sFileName); // save single [UnitX]
|
||||
|
@ -181,7 +183,6 @@ public:
|
|||
// procedure Open;
|
||||
bool removeFolder(PFolderNode node);
|
||||
bool removeEditor(int index, bool doClose);
|
||||
int getUnitFromString(const QString& s);
|
||||
void rebuildNodes();
|
||||
QString listUnitStr(const QChar& separator);
|
||||
|
||||
|
@ -190,7 +191,6 @@ public:
|
|||
void updateNodeIndexes();
|
||||
void setNodeValue(PFolderNode value);
|
||||
void incrementBuildNumber();
|
||||
QChar getCompilerOption(const QString& optionString);
|
||||
void setCompilerOption(const QString& optionString, const QChar& value);
|
||||
void saveToLog();
|
||||
|
||||
|
@ -203,6 +203,8 @@ signals:
|
|||
private:
|
||||
void open();
|
||||
void sortUnitsByPriority();
|
||||
int indexInUnits(const QString& fileName) const;
|
||||
int indexInUnits(const Editor* editor) const;
|
||||
private:
|
||||
QList<PProjectUnit> mUnits;
|
||||
ProjectOptions mOptions;
|
||||
|
|
|
@ -1223,6 +1223,17 @@ PCompilerOption Settings::CompilerSet::findOption(const QString &setting)
|
|||
return PCompilerOption();
|
||||
}
|
||||
|
||||
int Settings::CompilerSet::findOptionIndex(const QString &setting)
|
||||
{
|
||||
for (int i=0;i<mOptions.size();i++) {
|
||||
PCompilerOption pOption = mOptions[i];
|
||||
if (pOption->setting == setting) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
char Settings::CompilerSet::getOptionValue(const QString &setting)
|
||||
{
|
||||
PCompilerOption pOption = findOption(setting);
|
||||
|
@ -2270,8 +2281,13 @@ void Settings::CompilerSets::setDefaultIndex(int value)
|
|||
|
||||
Settings::PCompilerSet Settings::CompilerSets::defaultSet()
|
||||
{
|
||||
if (mDefaultIndex>=0 && mDefaultIndex<mList.size()) {
|
||||
return mList[mDefaultIndex];
|
||||
return getSet(mDefaultIndex);
|
||||
}
|
||||
|
||||
Settings::PCompilerSet Settings::CompilerSets::getSet(int index)
|
||||
{
|
||||
if (index>=0 && index<mList.size()) {
|
||||
return mList[index];
|
||||
}
|
||||
return PCompilerSet();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ typedef struct {
|
|||
|
||||
using PCompilerOption = std::shared_ptr<CompilerOption>;
|
||||
|
||||
using CompilerOptionList=std::vector<std::shared_ptr<CompilerOption>>;
|
||||
using CompilerOptionList=QVector<std::shared_ptr<CompilerOption>>;
|
||||
|
||||
class Settings
|
||||
{
|
||||
|
@ -802,6 +802,7 @@ public:
|
|||
int value, const QString& setting,
|
||||
const QStringList& choices = QStringList());
|
||||
PCompilerOption findOption(const QString& setting);
|
||||
int findOptionIndex(const QString& setting);
|
||||
char getOptionValue(const QString& setting);
|
||||
void setOption(const QString& setting, char valueChar);
|
||||
void setOption(PCompilerOption& option, char valueChar);
|
||||
|
@ -941,6 +942,7 @@ public:
|
|||
int defaultIndex() const;
|
||||
void setDefaultIndex(int value);
|
||||
PCompilerSet defaultSet();
|
||||
PCompilerSet getSet(int index);
|
||||
private:
|
||||
void savePath(const QString& name, const QString& path);
|
||||
void savePathList(const QString& name, const QStringList& pathList);
|
||||
|
|
Loading…
Reference in New Issue