update: file path convert api

This commit is contained in:
dreamsourcelabTAI 2022-06-22 13:50:02 +08:00
parent 9f7bd786ed
commit ea94e901dd
8 changed files with 22 additions and 19 deletions

View File

@ -299,16 +299,6 @@ std::string AppConfig::GetProtocolFormat(const std::string &protocolName)
}
//-------------api
QString GetDirectoryName(QString path)
{
int lstdex = path.lastIndexOf('/');
if (lstdex != -1)
{
return path.left(lstdex);
}
return path;
}
QString GetIconPath()
{
QString style = AppConfig::Instance()._frameOptions.style;

View File

@ -35,8 +35,6 @@
#define APP_NAME "DSView"
//--------------------api---
QString GetDirectoryName(QString path);
QString GetIconPath();
QString GetAppDataDir();
QString GetResourceDir();

View File

@ -39,6 +39,7 @@
#include "../config/appconfig.h"
#include "../dsvdef.h"
#include "../utility/encoding.h"
#include "../utility/path.h"
using namespace boost;
using namespace std;
@ -140,7 +141,7 @@ void ProtocolExp::accept()
if(f.suffix().compare(ext))
file_name+=tr(".")+ext;
QString fname = GetDirectoryName(file_name);
QString fname = path::GetDirectoryName(file_name);
if (fname != app._userHistory.openDir)
{
app._userHistory.protocolExportPath = fname;

View File

@ -94,6 +94,7 @@
#include "dsvdef.h"
#include "appcontrol.h"
#include "utility/encoding.h"
#include "utility/path.h"
#define BASE_SESSION_VERSION 2
@ -920,7 +921,7 @@ void MainWindow::on_screenShot()
pixmap.save(fileName, suffix.toLatin1());
fileName = GetDirectoryName(fileName);
fileName = path::GetDirectoryName(fileName);
if (app._userHistory.screenShotPath != fileName){
app._userHistory.screenShotPath = fileName;

View File

@ -1189,7 +1189,7 @@ QString StoreSession::MakeSaveFile(bool bDlg)
return ""; //no select file
}
QString _dir_path = GetDirectoryName(default_name);
QString _dir_path = path::GetDirectoryName(default_name);
if (_dir_path != app._userHistory.saveDir)
{
@ -1261,7 +1261,7 @@ QString StoreSession::MakeExportFile(bool bDlg)
}
bool bChange = false;
QString _dir_path = GetDirectoryName(default_name);
QString _dir_path = path::GetDirectoryName(default_name);
if (_dir_path != app._userHistory.exportDir)
{
app._userHistory.exportDir = _dir_path;

View File

@ -29,6 +29,7 @@
#include "../device/devinst.h"
#include "../ui/msgbox.h"
#include "../config/appconfig.h"
#include "../utility/path.h"
namespace pv {
namespace toolbars {
@ -143,7 +144,7 @@ void FileBar::on_actionOpen_triggered()
tr("DSView Data (*.dsl)"));
if (!file_name.isEmpty()) {
QString fname = GetDirectoryName(file_name);
QString fname = path::GetDirectoryName(file_name);
if (fname != app._userHistory.openDir){
app._userHistory.openDir = fname;
app.SaveHistory();
@ -180,7 +181,7 @@ void FileBar::on_actionLoad_triggered()
tr("DSView Session (*.dsc)"));
if (!file_name.isEmpty()) {
QString fname = GetDirectoryName(file_name);
QString fname = path::GetDirectoryName(file_name);
if (fname != app._userHistory.sessionDir){
app._userHistory.sessionDir = fname;
app.SaveHistory();
@ -229,7 +230,7 @@ void FileBar::on_actionStore_triggered()
if(f.suffix().compare("dsc"))
file_name.append(tr(".dsc"));
QString fname = GetDirectoryName(file_name);
QString fname = path::GetDirectoryName(file_name);
if (fname != app._userHistory.sessionDir){
app._userHistory.sessionDir = fname;
app.SaveHistory();

View File

@ -38,4 +38,14 @@ namespace pv::path
#endif
return fileName.toUtf8().toStdString();
}
QString GetDirectoryName(QString path)
{
int lstdex = path.lastIndexOf('/');
if (lstdex != -1)
{
return path.left(lstdex);
}
return path;
}
}

View File

@ -28,6 +28,8 @@
namespace pv::path
{
std::string ConvertPath(QString fileName);
QString GetDirectoryName(QString path);
}
#endif