v1.17.0: Change gloabl setting to project level settings to sync syttings with projects

This commit is contained in:
Markus
2025-04-09 13:30:59 +02:00
parent 6ec57c9cff
commit 2e2ccb7ffc
14 changed files with 358 additions and 193 deletions

BIN
.prjctmngr Normal file

Binary file not shown.

View File

@@ -52,15 +52,15 @@ RESOURCES += \
ressources.qrc
# MUpdaterLib:
win32:CONFIG(release, debug|release): LIBS += -LC:/Users/Markus/Nextcloud/CPP-Projekte/Bibliotheken/MUpdater/release/ -lMUpdater
win32:CONFIG(release, debug|release): LIBS += -LC:/Users/Markus/Nextcloud/Projekte/CPP-Projekte/Bibliotheken/MUpdater/release/ -lMUpdater
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../Bibliotheken/MUpdater/debug/ -lMUpdater
INCLUDEPATH += C:/Users/Markus/Nextcloud/CPP-Projekte/Bibliotheken/MUpdater/
DEPENDPATH += C:/Users/Markus/Nextcloud/CPP-Projekte/Bibliotheken/MUpdater/
INCLUDEPATH += C:/Users/Markus/Nextcloud/Projekte/CPP-Projekte/Bibliotheken/MUpdater/
DEPENDPATH += C:/Users/Markus/Nextcloud/Projekte/CPP-Projekte/Bibliotheken/MUpdater/
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += C:/Users/Markus/Nextcloud/CPP-Projekte/Bibliotheken/MUpdater/release/libMUpdater.a
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += C:/Users/Markus/Nextcloud/Projekte/CPP-Projekte/Bibliotheken/MUpdater/release/libMUpdater.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../Bibliotheken/MUpdater/debug/libMUpdater.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += C:/Users/Markus/Nextcloud/CPP-Projekte/Bibliotheken/MUpdater/release/MUpdater.lib
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += C:/Users/Markus/Nextcloud/Projekte/CPP-Projekte/Bibliotheken/MUpdater/release/MUpdater.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../Bibliotheken/MUpdater/debug/MUpdater.lib
# Application Icon

View File

@@ -1,6 +1,6 @@
#include <windows.h>
IDI_ICON1 ICON "C:/Users/Markus/Nextcloud/CPP-Projekte/AutoTools/ProjektManager/icons/appicon.ico"
IDI_ICON1 ICON "C:\\Users\\Markus\\Nextcloud\\Projekte\\CPP-Projekte\\AutoTools\\ProjektManager\\icons\\appicon.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,0

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

BIN
icons/appSymbol.png.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

View File

@@ -3,6 +3,8 @@
<Name>ProjektManager</Name>
<Version>1.16.3</Version>
<Title><Name>ProjektManager</Name> Installer</Title>
<InstallerApplicationIcon>installerIcon1</InstallerApplicationIcon>
<InstallerWindowIcon>installerIcon2</InstallerWindowIcon>
<Publisher>Markus</Publisher>
<StartMenuDir>ProjektManager</StartMenuDir>
<TargetDir>@ApplicationsDir@/ProjektManager/</TargetDir>
@@ -11,7 +13,7 @@
<MaintenanceToolName>ProjektManagerMaintenanceTool</MaintenanceToolName>
<RemoteRepositories>
<Repository>
<Url>https://code.obermui.de/Markus/ProjektManager/media/branch/main/installer/repository</Url>
<Url>https://code.obermui.de/Markus/ProjektManagerC/media/branch/main/installer/repository</Url>
<Enabled>1</Enabled>
<DisplayName>Main-Repo</DisplayName>
</Repository>

View File

@@ -6,9 +6,9 @@ Component.prototype.createOperations = function() {
component.createOperations();
if(systemInfo.productType === "windows") {
component.addOperation("CreateShortcut", "@TargetDir@/bin/ProjektManager.exe", "@StartMenuDir@/ProjektManager.lnk", "description=");
component.addOperation("CreateShortcut", "@TargetDir@/bin/ProjektManager.exe", "@StartMenuDir@/ProjektManager.lnk", "description=aaaaa");
component.addOperation("CreateShortcut", "@TargetDir@/bin/ProjektManager.exe", "@HomeDir@/Desktop/ProjektManager.lnk", "description=");
component.addOperation("CreateShortcut", "@TargetDir@/bin/ProjektManager.exe", "@HomeDir@/Desktop/ProjektManager.lnk", "description=aaaaa");
}
}

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Package>
<DisplayName>ProjektManager 1.16.3</DisplayName>
<Description></Description>
<Description>aaaaa</Description>
<Version>1.16.3</Version>
<Default>true</Default>
<ReleaseDate>2025-01-16</ReleaseDate>
<ReleaseDate>2025-04-09</ReleaseDate>
<Operations>
<Operation name="Extract">
<Argument>@TargetDir@/bin/</Argument>

View File

@@ -6,6 +6,8 @@
#include "stylehandler.h"
#include "switch.h"
namespace Ui {
class MainSettingsDialog;
}

View File

@@ -59,14 +59,16 @@ MainWindow::MainWindow(QWidget *parent)
ueberdialog->setPixmap("://icons/appicon.ico");
updater = ueberdialog->updater();
mainsettingsDialog = new MainSettingsDialog(ueberdialog->styleHandler());
projects = new ProjektDataList(settingsPath);
// Initialize ProjektDataList with company and app name
projects = new ProjektDataList("M$RKUS", appName);
projects->load();
reloadEntryList();
statDialog = new StatisticsDialog(projects);
//START cleanup...
QString autoremdir = MainSettingsDialog::getAutoRemoveDir();
if(!autoremdir.isEmpty() && QDir(autoremdir).exists()) {
@@ -112,8 +114,10 @@ void MainWindow::createNewProjektEntry()
if(npd->exec() == QDialog::Accepted) {
auto data = npd->getProjektStruct(projects);
createNewtask(CREATE_NEW_PROJECT, data);
projects->append(data);
projects->store();
// Use addProject to handle both adding to list and saving to file
projects->addProject(data);
addProjectToListWidget(data);
}
@@ -166,18 +170,13 @@ void MainWindow::on_pushButton_rm_clicked()
{
qDebug() << "ui->listWidget->currentRow(): " << ui->listWidget->currentRow() << "\nui->listWidget->selectedItems()" << ui->listWidget->selectedItems();
if (ui->listWidget->currentRow() != -1) {
// Löschen des ausgewählten Elements
auto item = ui->listWidget->takeItem(ui->listWidget->currentRow());
// Get the selected item and its ID
auto item = ui->listWidget->item(ui->listWidget->currentRow());
size_t id = item->data(187).toULongLong();
for(int i = 0; i < projects->size(); i++) {
if(projects->at(i)->getId() == id) {
projects->removeAt(i);
projects->store();
break;
}
}
delete item;
// Remove from list and delete from UI
projects->removeProject(id);
delete ui->listWidget->takeItem(ui->listWidget->currentRow());
}
}
@@ -210,8 +209,10 @@ void MainWindow::projectSettings_clicked(unsigned long long id)
connect(npd, SIGNAL(removeClicked(unsigned long long)), this, SLOT(projectSettings_remove_clicked(unsigned long long)));
if(npd->exec() == QDialog::Accepted) {
auto data = npd->getProjektStruct(projects);
projects->replace(i, data);
projects->store();
// Replace project at index i with the updated data
projects->replaceProject(i, data);
reloadEntryList();
createNewtask(S_TASK::UPDATE_PROJECT_DATA, data);
}
@@ -229,14 +230,9 @@ void MainWindow::projectSettings_remove_clicked(unsigned long long id)
break;
}
}
for(int i = 0; i < projects->size(); i++) {
if(projects->at(i)->getId() == id) {
projects->removeAt(i);
projects->store();
break;
}
}
// Remove from project list and save changes
projects->removeProject(id);
}
void MainWindow::on_actionAuf_Updates_pr_fen_triggered()
@@ -287,3 +283,5 @@ void MainWindow::on_actionListe_Aktualiseren_triggered()
reloadEntryList();
}

View File

@@ -75,5 +75,6 @@ public:
// QWidget interface
protected:
void closeEvent(QCloseEvent *event);
};
#endif // MAINWINDOW_H

View File

@@ -104,7 +104,6 @@ void NewProjektDialog::loadSettingsFromProjektData(ProjektData *projektData) {
this->id = projektData->getId();
}
ProjektData *NewProjektDialog::getProjektStruct(ProjektDataList *projektDataParent)
{
QString name = ui->lineEditProjektName->text();
@@ -158,17 +157,21 @@ ProjektData *NewProjektDialog::getProjektStruct(ProjektDataList *projektDataPare
// Erstelle ein ProjektData Objekt mit den extrahierten Informationen
ProjektData *projektData = new ProjektData(name, path, id, qt_installer_name, qt_installer_version, qt_installer_titel,
qt_installer_publisher, qt_installer_start_menue_dir, qt_installer_online_repo_url,
qt_installer_package_name, qt_installer_description, qt_installer_updater_icon_path,
qt_installer_online_repo, qt_installer_start_menue_link, qt_installer_desktop_link,
qt_installer_gpl3_licence, qt_m_updater_lib, false,
qt_move_files_to_src_sub_dir, qt_app_icon, qt_installer_start_after_install, qt_app_icon_path,
git_init, git_enable_daily_auto_commit, git_init_readme, git_add_git_ignore,
git_set_remote_repo, remote_repo_url, qt_installer, readmeinittext, git_overwriteReadmeFile, lineEditVersionFile,
git_lfs);
qt_installer_publisher, qt_installer_start_menue_dir, qt_installer_online_repo_url,
qt_installer_package_name, qt_installer_description, qt_installer_updater_icon_path,
qt_installer_online_repo, qt_installer_start_menue_link, qt_installer_desktop_link,
qt_installer_gpl3_licence, qt_m_updater_lib, false,
qt_move_files_to_src_sub_dir, qt_app_icon, qt_installer_start_after_install, qt_app_icon_path,
git_init, git_enable_daily_auto_commit, git_init_readme, git_add_git_ignore,
git_set_remote_repo, remote_repo_url, qt_installer, readmeinittext, git_overwriteReadmeFile, lineEditVersionFile,
git_lfs);
projektData->setParentList(projektDataParent);
// Save the new project to its own file
projektData->save();
return projektData;
}

View File

@@ -3,6 +3,7 @@
#include "qdir.h"
#include "qprocess.h"
#include <QFileInfo>
#include "mainsettingsdialog.h"
ProjektData::ProjektData(QString version)
@@ -69,11 +70,185 @@ ProjektData::ProjektData(QString name, QString path, size_t id, QString qt_insta
}
// Convert an absolute path to a portable relative path
QString ProjektData::toPortablePath(const QString& absolutePath) const
{
if (absolutePath.isEmpty())
return absolutePath;
QString projectDir = getProjectDirPath();
// Check if path is within the project directory
if (absolutePath.startsWith(projectDir)) {
// Make it relative to project directory
return QDir(projectDir).relativeFilePath(absolutePath);
}
// If not within project dir, just return the absolute path
// (this will be converted back when loaded)
return absolutePath;
}
// Convert a portable path back to an absolute path
QString ProjektData::toAbsolutePath(const QString& portablePath) const
{
if (portablePath.isEmpty())
return portablePath;
QString projectDir = getProjectDirPath();
// Check if it's already an absolute path
QFileInfo fileInfo(portablePath);
if (fileInfo.isAbsolute())
return portablePath;
// If it's relative, make it absolute relative to the project directory
return QDir(projectDir).absoluteFilePath(portablePath);
}
QString ProjektData::getConfigFilePath() const
{
QFileInfo fileInfo(this->path);
return fileInfo.absolutePath() + "/.prjctmngr";
}
bool ProjektData::save()
{
QFile file(getConfigFilePath());
if (file.open(QIODevice::WriteOnly)) {
QDataStream out(&file);
// Write version information
out << DATA_VERSION;
// Write project data
writeToStream(out);
file.close();
qDebug() << "Project data saved to" << getConfigFilePath();
return true;
} else {
qWarning() << "Failed to open file for writing:" << getConfigFilePath();
return false;
}
}
ProjektData* ProjektData::load(const QString& projectPath)
{
QFileInfo fileInfo(projectPath);
QString configPath = fileInfo.absolutePath() + "/.prjctmngr";
QString projectDir = fileInfo.absolutePath();
QFile file(configPath);
if (!file.exists()) {
qWarning() << "Project config file does not exist:" << configPath;
return nullptr;
}
if (file.open(QIODevice::ReadOnly)) {
QDataStream in(&file);
// Read version information
QString version;
in >> version;
// Create a new project data object with the right version and project directory
ProjektData* data = readFromStream(in, projectDir);
file.close();
if (data) {
qDebug() << "Project data loaded from" << configPath;
}
return data;
} else {
qWarning() << "Failed to open file for reading:" << configPath;
return nullptr;
}
}
void ProjektData::writeToStream(QDataStream& out) const
{
// Save the absolute path in QSettings, but store a portable path in the project file
// The project file path will always be absolute when loaded back
out << magicNumber
<< name << path << id;
// Serialize all data members - convert paths to portable format where needed
out << qt_installer_name << qt_installer_version << toPortablePath(qt_installer_versionFile)
<< qt_installer_titel << qt_installer_publisher << qt_installer_start_menue_dir
<< qt_installer_online_repo_url << qt_installer_package_name << qt_installer_description
<< toPortablePath(qt_installer_updater_icon_path) << qt_installer_online_repo
<< qt_installer_start_menue_link << qt_installer_desktop_link
<< qt_installer_gpl3_licence << qt_m_updater_lib << qt_remove_shadow_build_setting
<< qt_move_files_to_src_sub_dir << qt_app_icon << qt_installer_start_after_install
<< toPortablePath(qt_app_icon_path) << git_init << git_enable_daily_auto_commit << git_init_readme
<< git_add_git_ignore << git_set_remote_repo << remote_repo_url << qt_installer << readme_init_text
<< git_overwriteReadmeFile << git_lfs;
}
ProjektData* ProjektData::readFromStream(QDataStream& in, const QString& projectDir)
{
ProjektData* data = new ProjektData(DATA_VERSION);
in >> data->magicNumber;
// Deserialize basic data members
in >> data->name >> data->path >> data->id;
// Deserialize all other data members - convert paths from portable to absolute where needed
QString portableVersionFile, portableUpdaterIconPath, portableAppIconPath;
in >> data->qt_installer_name >> data->qt_installer_version >> portableVersionFile
>> data->qt_installer_titel >> data->qt_installer_publisher >> data->qt_installer_start_menue_dir
>> data->qt_installer_online_repo_url >> data->qt_installer_package_name >> data->qt_installer_description
>> portableUpdaterIconPath >> data->qt_installer_online_repo >> data->qt_installer_start_menue_link
>> data->qt_installer_desktop_link >> data->qt_installer_gpl3_licence >> data->qt_m_updater_lib
>> data->qt_remove_shadow_build_setting >> data->qt_move_files_to_src_sub_dir >> data->qt_app_icon
>> data->qt_installer_start_after_install >> portableAppIconPath >> data->git_init
>> data->git_enable_daily_auto_commit >> data->git_init_readme >> data->git_add_git_ignore
>> data->git_set_remote_repo >> data->remote_repo_url >> data->qt_installer
>> data->readme_init_text >> data->git_overwriteReadmeFile >> data->git_lfs;
// Convert portable paths to absolute paths
QDir dir(projectDir);
// Convert version file path
data->qt_installer_versionFile = QFileInfo(portableVersionFile).isAbsolute() ?
portableVersionFile : dir.absoluteFilePath(portableVersionFile);
// Convert updater icon path
data->qt_installer_updater_icon_path = QFileInfo(portableUpdaterIconPath).isAbsolute() ?
portableUpdaterIconPath : dir.absoluteFilePath(portableUpdaterIconPath);
// Convert app icon path
data->qt_app_icon_path = QFileInfo(portableAppIconPath).isAbsolute() ?
portableAppIconPath : dir.absoluteFilePath(portableAppIconPath);
// Check if data is valid
if (!data->dataValid()) {
delete data;
return nullptr;
}
return data;
}
bool ProjektData::dataValid() const {
return magicNumber == MAGIC_NUM;
}
QString ProjektData::getProjectDirPath()
QString ProjektData::getProjectDirPath() const
{
QFileInfo fileInfo(this->path);
return fileInfo.absolutePath() + "/";
@@ -174,7 +349,7 @@ size_t ProjektData::countLinesOfCode(ProjektData *data)
// qDebug() << data->getAppName() << ": Line: " << zeilen;
return zeilen;
}
#include "mainsettingsdialog.h"
size_t ProjektData::countGitCommits( ProjektData *data)
{
@@ -380,69 +555,123 @@ bool ProjektData::getGit_lfs() const
}
// ProjektDataList implementation
ProjektDataList::ProjektDataList(const QString& company, const QString& appName)
: company(company), appName(appName)
{
qDebug() << " ProjektDataList()";
}
ProjektDataList::~ProjektDataList()
{
if(!this->settingsPath.isEmpty())
this->store();
// Store projects before destruction
this->store();
// Clean up project data
while(this->size())
delete this->takeAt(0);
qDebug() << " ~ProjektDataList()";
}
ProjektDataList::ProjektDataList(QString settingsPath)
: settingsPath(settingsPath)
bool ProjektDataList::store()
{
qDebug() << " ProjektDataList()";
}
QSettings settings(company, appName);
bool ProjektDataList::store() {
return store(this->settingsPath);
}
bool ProjektDataList::store(QString path) {
if(path.isEmpty())
return false;
QFile file(path);
if (file.open(QIODevice::WriteOnly)) {
QDataStream out(&file);
out << *this;
file.close();
} else {
return false;
// Create a list of project paths
QStringList projectPaths;
for (ProjektData* project : *this) {
projectPaths.append(project->getPath());
}
// Store the paths in QSettings
settings.setValue("ProjectPaths", projectPaths);
qDebug() << "Stored" << projectPaths.size() << "project paths to QSettings";
return true;
}
bool ProjektDataList::load() {
return load(this->settingsPath);
bool ProjektDataList::load()
{
// Clear the current list
while(this->size())
delete this->takeAt(0);
}
QSettings settings(company, appName);
bool ProjektDataList::load(QString path) {
if(path.isEmpty())
return false;
QFile file(path);
// Get the list of project paths
QStringList projectPaths = settings.value("ProjectPaths").toStringList();
if (file.open(QIODevice::ReadOnly)) {
QDataStream in(&file);
in >> *this;
file.close();
} else {
return false;
}
// Validate loaded data and remove invalid items
for(int i = 0; i < this->length(); i++) {
if(!this->at(i)->dataValid()) {
this->remove(i--);
// Load each project
for (const QString& path : projectPaths) {
QFileInfo fileInfo(path);
if (fileInfo.exists()) {
ProjektData* project = ProjektData::load(path);
if (project) {
project->setParentList(this);
this->append(project);
}
}
else
this->at(i)->setParentList(this);
}
qDebug() << "Loaded" << this->size() << "projects from QSettings";
return true;
}
void ProjektDataList::addProject(ProjektData* project)
{
// Add to the list
project->setParentList(this);
this->append(project);
// Save the project to its own file
project->save();
// Update the list of paths in QSettings
this->store();
}
bool ProjektDataList::removeProject(ProjektData* project)
{
for (int i = 0; i < this->size(); i++) {
if (this->at(i) == project) {
return removeProject(i);
}
}
return false;
}
bool ProjektDataList::removeProject(size_t id)
{
for (int i = 0; i < this->size(); i++) {
if (this->at(i)->getId() == id) {
return removeProject(i);
}
}
return false;
}
bool ProjektDataList::removeProject(int index)
{
if (index >= 0 && index < this->size()) {
delete this->takeAt(index);
this->store();
return true;
}
return false;
}
bool ProjektDataList::replaceProject(int index, ProjektData* newProject)
{
if (index >= 0 && index < this->size()) {
delete this->at(index);
this->replace(index, newProject);
newProject->setParentList(this);
newProject->save();
this->store();
return true;
}
return false;
}

View File

@@ -5,13 +5,15 @@
#include <QDataStream>
#include <QFile>
#include <QList>
#include <QDataStream>
#include <QSettings>
#include <QDir>
class ProjektDataList;
#define DATA_VERSION QString("1.4.0")
#define DATA_VERSION QString("1.5.0")
@@ -33,75 +35,19 @@ public:
bool git_overwriteReadmeFile, QString qt_installer_versionFile, bool gitlfs,
QString version = DATA_VERSION);
friend QDataStream &operator<<(QDataStream &out, const ProjektData &obj) {
out << obj.MAGIC_NUM
<< obj.name << obj.path << obj.id;
// Save project data to a .prjctmngr file in the project directory
bool save();
// Hier serialisieren Sie alle zusätzlichen Datenmember
out << obj.qt_installer_name << obj.qt_installer_version << obj.qt_installer_titel
<< obj.qt_installer_publisher << obj.qt_installer_start_menue_dir << obj.qt_installer_online_repo_url
<< obj.qt_installer_package_name << obj.qt_installer_description << obj.qt_installer_updater_icon_path
<< obj.qt_installer_online_repo << obj.qt_installer_start_menue_link << obj.qt_installer_desktop_link
<< obj.qt_installer_gpl3_licence << obj.qt_m_updater_lib << obj.qt_remove_shadow_build_setting
<< obj.qt_move_files_to_src_sub_dir << obj.qt_app_icon << obj.qt_installer_start_after_install
<< obj.qt_app_icon_path << obj.git_init << obj.git_enable_daily_auto_commit << obj.git_init_readme
<< obj.git_add_git_ignore << obj.git_set_remote_repo << obj.remote_repo_url << obj.qt_installer << obj.readme_init_text
<< obj.git_overwriteReadmeFile << obj.git_lfs << obj.qt_installer_versionFile;
// Load project data from a .prjctmngr file
static ProjektData* load(const QString& projectPath);
return out;
}
friend QDataStream &operator>>(QDataStream &in, ProjektData &obj) {
// Get the path to the .prjctmngr file for this project
QString getConfigFilePath() const;
if(obj.data_version == DATA_VERSION) {
in >> obj.magicNumber;
// Hier deserialisieren Sie alle zusätzlichen Datenmember
in >> obj.name >> obj.path >> obj.id
>> obj.qt_installer_name >> obj.qt_installer_version >> obj.qt_installer_titel
>> obj.qt_installer_publisher >> obj.qt_installer_start_menue_dir >> obj.qt_installer_online_repo_url
>> obj.qt_installer_package_name >> obj.qt_installer_description >> obj.qt_installer_updater_icon_path
>> obj.qt_installer_online_repo >> obj.qt_installer_start_menue_link >> obj.qt_installer_desktop_link
>> obj.qt_installer_gpl3_licence >> obj.qt_m_updater_lib >> obj.qt_remove_shadow_build_setting
>> obj.qt_move_files_to_src_sub_dir >> obj.qt_app_icon >> obj.qt_installer_start_after_install
>> obj.qt_app_icon_path >> obj.git_init >> obj.git_enable_daily_auto_commit >> obj.git_init_readme
>> obj.git_add_git_ignore >> obj.git_set_remote_repo >> obj.remote_repo_url >> obj.qt_installer
>> obj.readme_init_text >> obj.git_overwriteReadmeFile >> obj.git_lfs >> obj.qt_installer_versionFile;
//Backwards Compatibility
} else if(obj.data_version == "1.3.0") {
qDebug() << "Convert Data from 1.3.0";
in >> obj.magicNumber;
// Hier deserialisieren Sie alle zusätzlichen Datenmember
in >> obj.name >> obj.path >> obj.id
>> obj.qt_installer_name >> obj.qt_installer_version >> obj.qt_installer_titel
>> obj.qt_installer_publisher >> obj.qt_installer_start_menue_dir >> obj.qt_installer_online_repo_url
>> obj.qt_installer_package_name >> obj.qt_installer_description >> obj.qt_installer_updater_icon_path
>> obj.qt_installer_online_repo >> obj.qt_installer_start_menue_link >> obj.qt_installer_desktop_link
>> obj.qt_installer_gpl3_licence >> obj.qt_m_updater_lib >> obj.qt_remove_shadow_build_setting
>> obj.qt_move_files_to_src_sub_dir >> obj.qt_app_icon >> obj.qt_installer_start_after_install
>> obj.qt_app_icon_path >> obj.git_init >> obj.git_enable_daily_auto_commit >> obj.git_init_readme
>> obj.git_add_git_ignore >> obj.git_set_remote_repo >> obj.remote_repo_url >> obj.qt_installer
>> obj.readme_init_text >> obj.git_overwriteReadmeFile >> obj.qt_installer_versionFile;
obj.git_overwriteReadmeFile = false; // init new values!
} else if(obj.data_version == "-1.0.0") {
} else if(obj.data_version == "-1.0.0") {
} else {
in >> obj.magicNumber;
obj.magicNumber = -1;
}
return in;
}
bool dataValid() const;
QString getProjectDirPath();
QString getProjectDirPath() const;
QString getExePath();
QString getAppName();
QString getAppVersion();
@@ -110,7 +56,11 @@ public:
static size_t countComments(ProjektData *data);
static QList<QPointF> countCommitsByDate(ProjektData *data);
// Convert paths to portable format
QString toPortablePath(const QString& absolutePath) const;
// Convert paths from portable format to absolute
QString toAbsolutePath(const QString& portablePath) const;
QString getName() const { return name; }
QString getPath() const { return path; }
@@ -162,6 +112,11 @@ public:
bool getGit_lfs() const;
private:
// Helper method to write project data to a QDataStream
void writeToStream(QDataStream &out) const;
// Helper method to read project data from a QDataStream
static ProjektData* readFromStream(QDataStream &in, const QString& projectDir);
size_t magicNumber = -1;
static constexpr size_t MAGIC_NUM = 1225356987344;
@@ -219,54 +174,29 @@ class ProjektDataList : public QList<ProjektData*>
public:
~ProjektDataList();
friend QDataStream& operator<<(QDataStream& out, const ProjektDataList& list) {
//Version
out << DATA_VERSION;
//Data
for (const ProjektData* data : list) {
out << *data; // Serialize each ProjektData object in the list
}
return out;
}
friend QDataStream& operator>>(QDataStream& in, ProjektDataList& list) {
// Clear the list before reading new data
list.clear();
//Version
in >> list.dataVersion;
if(list.dataVersion != DATA_VERSION) {
//Create BackUp
qDebug() << "list.dataVersion != DATA_VERSION ==> Create BackUP!";
list.store(list.settingsPath + "_Backup");
}
// Read each ProjektData object and add it to the list
while (!in.atEnd()) {
ProjektData* data = new ProjektData(list.dataVersion);
in >> *data;
list.append(data);
}
return in;
}
ProjektDataList(QString settingsPath);
// Constructor with company and application names for QSettings
ProjektDataList(const QString& company, const QString& appName);
// Save the list of project paths to QSettings
bool store();
bool store(QString path);
// Load projects from paths stored in QSettings
bool load();
bool load(QString path);
// Add a project to the list and save its path to QSettings
void addProject(ProjektData* project);
// Remove a project from the list and QSettings
bool removeProject(ProjektData* project);
bool removeProject(size_t id);
bool removeProject(int index);
// Replace a project in the list
bool replaceProject(int index, ProjektData* newProject);
private:
QString settingsPath;
QString dataVersion = DATA_VERSION;
QString company;
QString appName;
};
#endif // PROJEKTDATA_H