saving ...
This commit is contained in:
		| @@ -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, | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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,7 +32,8 @@ int32_t LocalGitRepository::GetFileMenuSizeInternal() const { | ||||
|  | ||||
| QByteArray LocalGitRepository::GetFileMenuInternal() { | ||||
|     if (m_fileMenuSize == -1) { | ||||
|         QFile f(QDir::cleanPath(QString(baseDir) + m_localRepository + QDir::separator() | ||||
|         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)) { | ||||
| @@ -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')))); | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user