From c211a7ad1fb58812102b0fd0971e30b86ece04bf Mon Sep 17 00:00:00 2001 From: Sergey Batanov Date: Mon, 23 Apr 2018 18:06:20 +0300 Subject: [PATCH] =?UTF-8?q?GUI:=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D1=81=20=D0=BD=D0=B5=D0=BB=D0=B0=D1=82=D0=B8=D0=BD=D1=81=D0=BA?= =?UTF-8?q?=D0=B8=D0=BC=D0=B8=20=D0=BF=D1=83=D1=82=D1=8F=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gtool1cd/container_form.cpp | 3 ++- src/gtool1cd/mainwindow.cpp | 2 +- src/gtool1cd/starter.cpp | 2 +- src/tool1cd/Class_1CD.cpp | 19 ++++++++++++++----- src/tool1cd/Class_1CD.h | 8 ++++++-- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/gtool1cd/container_form.cpp b/src/gtool1cd/container_form.cpp index c7619ac4..d5b1bce2 100644 --- a/src/gtool1cd/container_form.cpp +++ b/src/gtool1cd/container_form.cpp @@ -18,7 +18,8 @@ ContainerForm::~ContainerForm() void ContainerForm::open(const QString &filename) { QFileInfo finfo(filename); - auto stream = new TFileStream(filename.toStdString(), fmOpenRead); + boost::filesystem::path filepath(filename.toStdWString()); + auto stream = new TFileStream(filepath, fmOpenRead); ui->widget->setStream(stream, finfo.baseName()); setWindowTitle(filename); } diff --git a/src/gtool1cd/mainwindow.cpp b/src/gtool1cd/mainwindow.cpp index 87243951..f05105d9 100644 --- a/src/gtool1cd/mainwindow.cpp +++ b/src/gtool1cd/mainwindow.cpp @@ -42,7 +42,7 @@ void MainWindow::open(T_1CD *database) { db = database; ui->tableListView->setModel(new TablesListModel(db)); - setWindowTitle(QString::fromStdString(db->get_filename())); + setWindowTitle(QString::fromStdWString(db->get_filepath().wstring())); // refresh data } diff --git a/src/gtool1cd/starter.cpp b/src/gtool1cd/starter.cpp index 52f1b79b..6efeefba 100644 --- a/src/gtool1cd/starter.cpp +++ b/src/gtool1cd/starter.cpp @@ -108,7 +108,7 @@ bool StarterWindow::openDatabase(const QString &filename) T_1CD *db = nullptr; try { - db = new T_1CD(filename.toStdString(), reg); + db = new T_1CD(boost::filesystem::path(filename.toStdWString()), reg); if (!db->is_open()) { lw->show(); return false; diff --git a/src/tool1cd/Class_1CD.cpp b/src/tool1cd/Class_1CD.cpp index 5b56905d..3c756098 100755 --- a/src/tool1cd/Class_1CD.cpp +++ b/src/tool1cd/Class_1CD.cpp @@ -207,8 +207,14 @@ T_1CD::~T_1CD() if(pagemap) delete[] pagemap; } +T_1CD::T_1CD(const boost::filesystem::path &_filename, MessageRegistrator *mess, bool _monopoly) +{ + msreg_m.AddMessageRegistrator(mess); + open(_filename, _monopoly); +} + //--------------------------------------------------------------------------- -T_1CD::T_1CD(const string &_filename, MessageRegistrator *mess, bool _monopoly) +void T_1CD::open(const boost::filesystem::path &_filename, bool _monopoly) { char* b = nullptr; uint32_t* table_blocks = nullptr; @@ -217,17 +223,15 @@ T_1CD::T_1CD(const string &_filename, MessageRegistrator *mess, bool _monopoly) root_80* root80 = nullptr; root_81* root81 = nullptr; - msreg_m.AddMessageRegistrator(mess); - init(); - filename = System::Ioutils::TPath::GetFullPath(_filename); + filename = boost::filesystem::absolute(_filename).string(); std::shared_ptr base_file; try { base_file.reset( - new TFileStream(boost::filesystem::path(filename), + new TFileStream(_filename, _monopoly ? (fmOpenReadWrite | fmShareDenyWrite) : (fmOpenRead | fmShareDenyNone))); } @@ -2157,6 +2161,11 @@ bool T_1CD::test_block_by_template(uint32_t testblock, char* tt, uint32_t num, i } std::string T_1CD::get_filename() const +{ + return filename.string(); +} + +const boost::filesystem::path &T_1CD::get_filepath() const { return filename; } diff --git a/src/tool1cd/Class_1CD.h b/src/tool1cd/Class_1CD.h index 9c630bff..0f67314b 100755 --- a/src/tool1cd/Class_1CD.h +++ b/src/tool1cd/Class_1CD.h @@ -20,6 +20,7 @@ #include "cfapi/TV8FileStream.h" #include "SupplierConfig.h" #include "TableRecord.h" +#include //--------------------------------------------------------------------------- @@ -186,9 +187,11 @@ class T_1CD std::string ver; - T_1CD(const std::string &_filename, MessageRegistrator *mess = nullptr, bool monopoly = true); + T_1CD(const boost::filesystem::path &_filename, MessageRegistrator *mess = nullptr, bool monopoly = true); T_1CD(); ~T_1CD(); + void open(const boost::filesystem::path &filename, bool monopoly); + bool is_open(); bool is_infobase() const; int32_t get_numtables(); @@ -219,6 +222,7 @@ class T_1CD void restore_DATA_allocation_table(Table* tab); bool test_block_by_template(uint32_t testblock, char* tt, uint32_t num, int32_t rlen, int32_t len); std::string get_filename() const; + const boost::filesystem::path &get_filepath() const; uint32_t get_pagesize() const; SupplierConfigs& supplier_configs(); @@ -234,7 +238,7 @@ class T_1CD private: mutable Registrator msreg_m; mutable MemBlockManager memBlockManager; - std::string filename; + boost::filesystem::path filename; std::shared_ptr fs; db_ver version; // версия базы