saving ...
This commit is contained in:
parent
2d8a947cb4
commit
5338c30e79
@ -598,6 +598,22 @@ int PushLocalRepository(char const *local_path, char const *branch_name, char co
|
|||||||
|
|
||||||
static QMap<QString, LocalGitRepository *> localGitRepos;
|
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) {
|
int32_t GetFileMenuSizeInternal(char const *localGitRepo) {
|
||||||
if (localGitRepos.count(localGitRepo) == 0) {
|
if (localGitRepos.count(localGitRepo) == 0) {
|
||||||
localGitRepos.insert(localGitRepo,
|
localGitRepos.insert(localGitRepo,
|
||||||
|
@ -10,6 +10,9 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void DeleteMem(char *p) CALCULATOR_C_INTERFACE_LIB_EXPORT;
|
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
|
// interface for menu of webpage
|
||||||
char const *GetFileMenuInternal(char const *localRepo) CALCULATOR_C_INTERFACE_LIB_EXPORT;
|
char const *GetFileMenuInternal(char const *localRepo) CALCULATOR_C_INTERFACE_LIB_EXPORT;
|
||||||
|
@ -9,6 +9,17 @@
|
|||||||
#include <QRegularExpressionMatch>
|
#include <QRegularExpressionMatch>
|
||||||
#include <QFile>
|
#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)
|
LocalGitRepository::LocalGitRepository(QString const &localRepository)
|
||||||
: m_localRepository(localRepository)
|
: m_localRepository(localRepository)
|
||||||
, m_fileMenu("{}")
|
, m_fileMenu("{}")
|
||||||
@ -21,8 +32,9 @@ int32_t LocalGitRepository::GetFileMenuSizeInternal() const {
|
|||||||
|
|
||||||
QByteArray LocalGitRepository::GetFileMenuInternal() {
|
QByteArray LocalGitRepository::GetFileMenuInternal() {
|
||||||
if (m_fileMenuSize == -1) {
|
if (m_fileMenuSize == -1) {
|
||||||
QFile f(QDir::cleanPath(QString(baseDir) + m_localRepository + QDir::separator()
|
QFile f(QDir::cleanPath(m_repoRootDirectory + QDir::separator()
|
||||||
+ "etc/psa_webinterface/menu_config.json"));
|
+ m_localRepository + QDir::separator()
|
||||||
|
+ "etc/psa_webinterface/menu_config.json"));
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
m_fileMenu = QTextStream(&f).readAll().toUtf8();
|
m_fileMenu = QTextStream(&f).readAll().toUtf8();
|
||||||
@ -51,7 +63,7 @@ QByteArray LocalGitRepository::GetFileNameInternal(QString const &fId) {
|
|||||||
if (s != "master") {
|
if (s != "master") {
|
||||||
if (fId.contains("psa_tariff")) {
|
if (fId.contains("psa_tariff")) {
|
||||||
QString fn(QDir::cleanPath(
|
QString fn(QDir::cleanPath(
|
||||||
QString(baseDir) + QDir::separator() +
|
m_repoRootDirectory + QDir::separator() +
|
||||||
QString(m_localRepository) + QDir::separator()
|
QString(m_localRepository) + QDir::separator()
|
||||||
+ path + QDir::separator()
|
+ path + QDir::separator()
|
||||||
+ QString("tariff%1.json").arg(s.toUInt(), 2, 10, QChar('0'))));
|
+ QString("tariff%1.json").arg(s.toUInt(), 2, 10, QChar('0'))));
|
||||||
|
@ -3,20 +3,29 @@
|
|||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
class LocalGitRepository {
|
class LocalGitRepository {
|
||||||
QString m_localRepository;
|
QString m_localRepository;
|
||||||
mutable QByteArray m_fileMenu;
|
mutable QByteArray m_fileMenu;
|
||||||
mutable int32_t m_fileMenuSize;
|
mutable int32_t m_fileMenuSize;
|
||||||
|
|
||||||
|
static QString m_repoRootDirectory;
|
||||||
public:
|
public:
|
||||||
|
static void SetReposRootDirectory(QString s);
|
||||||
|
static QString GetReposRootDirectory();
|
||||||
|
|
||||||
LocalGitRepository(QString const &localRepository);
|
LocalGitRepository(QString const &localRepository);
|
||||||
|
|
||||||
static char const constexpr *baseDir = "H:\\";
|
QString localRepository() const { return m_localRepository; }
|
||||||
QString gitRepository() const { return m_localRepository; }
|
|
||||||
|
QString localRepositoryPath() {
|
||||||
|
return QDir::cleanPath(
|
||||||
|
m_repoRootDirectory + QDir::separator() + m_localRepository);
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray GetFileMenuInternal();
|
QByteArray GetFileMenuInternal();
|
||||||
int32_t GetFileMenuSizeInternal() const;
|
int32_t GetFileMenuSizeInternal() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user