diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index 5bf3177a..2eacf158 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -1,12 +1,59 @@ #include "project.h" #include "editor.h" #include "mainwindow.h" +#include "utils.h" +#include "systemconsts.h" + +#include +#include 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 &ProjectUnit::parent() const { return mParent; diff --git a/RedPandaIDE/project.h b/RedPandaIDE/project.h index 4db1664d..def7264b 100644 --- a/RedPandaIDE/project.h +++ b/RedPandaIDE/project.h @@ -2,6 +2,7 @@ #define PROJECT_H #include +#include #include 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; + 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 mUnits; + ProjectOptions mOptions; + QSettings mIniFile; + QString mFilename; + QString mName; + bool mModified; + QStringList mFolders; + std::shared_ptr mParser; }; #endif // PROJECT_H diff --git a/RedPandaIDE/systemconsts.h b/RedPandaIDE/systemconsts.h index 3f9f0712..1544261f 100644 --- a/RedPandaIDE/systemconsts.h +++ b/RedPandaIDE/systemconsts.h @@ -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