saving ...

This commit is contained in:
Gerhard Hoffmann 2024-03-27 08:40:16 +01:00
parent 2d8a947cb4
commit 5338c30e79
4 changed files with 46 additions and 6 deletions

View File

@ -598,6 +598,22 @@ int PushLocalRepository(char const *local_path, char const *branch_name, char co
static QMap<QString, LocalGitRepository *> localGitRepos;
void SetReposRootDirectoryInternal(char const *p) {
LocalGitRepository::SetReposRootDirectory(QString::fromUtf8(p));
}
char const *GetReposRootDirectoryInternal() {
return LocalGitRepository::GetReposRootDirectory().toUtf8().constData();
}
char const *GetLocalRepositoryPathInternal(char const *localGitRepo) {
if (localGitRepos.count(localGitRepo) == 0) {
localGitRepos.insert(localGitRepo,
new LocalGitRepository(localGitRepo));
}
return localGitRepos[localGitRepo]->localRepositoryPath().toUtf8().constData();
}
int32_t GetFileMenuSizeInternal(char const *localGitRepo) {
if (localGitRepos.count(localGitRepo) == 0) {
localGitRepos.insert(localGitRepo,

View File

@ -10,6 +10,9 @@ extern "C" {
#endif
void DeleteMem(char *p) CALCULATOR_C_INTERFACE_LIB_EXPORT;
void SetReposRootDirectoryInternal(char const *p) CALCULATOR_C_INTERFACE_LIB_EXPORT;
char const *GetReposRootDirectoryInternal() CALCULATOR_C_INTERFACE_LIB_EXPORT;
char const *GetLocalRepositoryPathInternal(char const *localRepo) CALCULATOR_C_INTERFACE_LIB_EXPORT;
// interface for menu of webpage
char const *GetFileMenuInternal(char const *localRepo) CALCULATOR_C_INTERFACE_LIB_EXPORT;

View File

@ -9,6 +9,17 @@
#include <QRegularExpressionMatch>
#include <QFile>
QString LocalGitRepository::m_repoRootDirectory = "H:\\";
void LocalGitRepository::SetReposRootDirectory(QString s) {
m_repoRootDirectory = s;
}
QString LocalGitRepository::GetReposRootDirectory() {
return m_repoRootDirectory;
}
LocalGitRepository::LocalGitRepository(QString const &localRepository)
: m_localRepository(localRepository)
, m_fileMenu("{}")
@ -21,8 +32,9 @@ int32_t LocalGitRepository::GetFileMenuSizeInternal() const {
QByteArray LocalGitRepository::GetFileMenuInternal() {
if (m_fileMenuSize == -1) {
QFile f(QDir::cleanPath(QString(baseDir) + m_localRepository + QDir::separator()
+ "etc/psa_webinterface/menu_config.json"));
QFile f(QDir::cleanPath(m_repoRootDirectory + QDir::separator()
+ m_localRepository + QDir::separator()
+ "etc/psa_webinterface/menu_config.json"));
if (f.exists()) {
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
m_fileMenu = QTextStream(&f).readAll().toUtf8();
@ -51,7 +63,7 @@ QByteArray LocalGitRepository::GetFileNameInternal(QString const &fId) {
if (s != "master") {
if (fId.contains("psa_tariff")) {
QString fn(QDir::cleanPath(
QString(baseDir) + QDir::separator() +
m_repoRootDirectory + QDir::separator() +
QString(m_localRepository) + QDir::separator()
+ path + QDir::separator()
+ QString("tariff%1.json").arg(s.toUInt(), 2, 10, QChar('0'))));

View File

@ -3,20 +3,29 @@
#include <QByteArray>
#include <QString>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include <QDir>
class LocalGitRepository {
QString m_localRepository;
mutable QByteArray m_fileMenu;
mutable int32_t m_fileMenuSize;
static QString m_repoRootDirectory;
public:
static void SetReposRootDirectory(QString s);
static QString GetReposRootDirectory();
LocalGitRepository(QString const &localRepository);
static char const constexpr *baseDir = "H:\\";
QString gitRepository() const { return m_localRepository; }
QString localRepository() const { return m_localRepository; }
QString localRepositoryPath() {
return QDir::cleanPath(
m_repoRootDirectory + QDir::separator() + m_localRepository);
}
QByteArray GetFileMenuInternal();
int32_t GetFileMenuSizeInternal() const;