work save

This commit is contained in:
royqh1979@gmail.com 2021-09-06 08:45:53 +08:00
parent 2fa54411c3
commit 51ea099868
3 changed files with 75 additions and 4 deletions

View File

@ -1,12 +1,59 @@
#include "project.h"
#include "editor.h"
#include "mainwindow.h"
#include "utils.h"
#include "systemconsts.h"
#include <QDir>
#include <QFileInfo>
Project::Project(QObject *parent) : QObject(parent)
{
}
QString Project::directory()
{
QFileInfo fileInfo(mFilename);
return fileInfo.absolutePath();
}
QString Project::executableName()
{
QString exeFileName;
if (mOptions.overrideOutput && !mOptions.overridenOutput.isEmpty()) {
exeFileName = mOptions.overridenOutput;
} else {
switch(mOptions.type) {
case ProjectType::StaticLib:
exeFileName = changeFileExt(baseFileName(mFilename),STATIC_LIB_EXT);
break;
case ProjectType::DynamicLib:
exeFileName = changeFileExt(baseFileName(mFilename),DYNAMIC_LIB_EXT);
break;
default:
exeFileName = changeFileExt(baseFileName(mFilename),EXECUTABLE_EXT);
}
}
QString exePath;
if (!mOptions.exeOutput.isEmpty()) {
QDir baseDir(directory());
exePath = baseDir.filePath(mOptions.exeOutput);
} else {
exePath = directory();
}
QDir exeDir(exePath);
return exeDir.filePath(exeFileName);
}
QString Project::makeFileName()
{
if fOptions.UseCustomMakefile then
Result := fOptions.CustomMakefile
else
Result := Directory + DEV_MAKE_FILE;
}
const std::weak_ptr<Project> &ProjectUnit::parent() const
{
return mParent;

View File

@ -2,6 +2,7 @@
#define PROJECT_H
#include <QObject>
#include <QSettings>
#include <memory>
enum class ProjectType {
@ -13,6 +14,8 @@ enum class ProjectType {
class Project;
class Editor;
class CppParser;
class ProjectUnit {
public:
@ -62,6 +65,8 @@ private:
QByteArray mEncoding;
};
using PProjectUnit = std::shared_ptr<ProjectUnit>;
struct ProjectVersionInfo{
int major;
int minor;
@ -123,9 +128,24 @@ class Project : public QObject
Q_OBJECT
public:
explicit Project(QObject *parent = nullptr);
QString directory();
QString executableName();
QString makeFileName();
procedure SetFileName(const value: AnsiString);
function GetModified: boolean;
procedure SetModified(value: boolean);
procedure SortUnitsByPriority;
procedure Open;
signals:
private:
QList<PProjectUnit> mUnits;
ProjectOptions mOptions;
QSettings mIniFile;
QString mFilename;
QString mName;
bool mModified;
QStringList mFolders;
std::shared_ptr<CppParser> mParser;
};
#endif // PROJECT_H

View File

@ -21,11 +21,15 @@
#ifdef Q_OS_WIN
# define PATH_SENSITIVITY Qt::CaseInsensitive
# define NULL_FILE "NUL"
# define EXECUTABE_EXT "exe"
# define EXECUTABLE_EXT "exe"
# define STATIC_LIB_EXT "a"
# define DYNAMIC_LIB_EXT "dll"
#elif Q_OS_LINUX
# define PATH_SENSITIVITY Qt::CaseSensitive
# define NULL_FILE "/dev/null"
# define EXECUTABE_EXT ""
# define EXECUTABLE_EXT ""
# define STATIC_LIB_EXT "a"
# define DYNAMIC_LIB_EXT "d"
#else
#error "Only support windows and linux now!"
#endif