Skip to content

Commit

Permalink
GUI: работа с нелатинскими путями
Browse files Browse the repository at this point in the history
  • Loading branch information
dmpas committed Apr 23, 2018
1 parent b9b10f9 commit c211a7a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/gtool1cd/container_form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/gtool1cd/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/gtool1cd/starter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 14 additions & 5 deletions src/tool1cd/Class_1CD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<TFileStream> base_file;
try
{
base_file.reset(
new TFileStream(boost::filesystem::path(filename),
new TFileStream(_filename,
_monopoly ? (fmOpenReadWrite | fmShareDenyWrite)
: (fmOpenRead | fmShareDenyNone)));
}
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 6 additions & 2 deletions src/tool1cd/Class_1CD.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "cfapi/TV8FileStream.h"
#include "SupplierConfig.h"
#include "TableRecord.h"
#include <boost/filesystem.hpp>

//---------------------------------------------------------------------------

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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<TFileStream> fs;

db_ver version; // версия базы
Expand Down

0 comments on commit c211a7a

Please sign in to comment.