diff --git a/DSView/pv/config/appconfig.cpp b/DSView/pv/config/appconfig.cpp index c0431ae7..41c190aa 100644 --- a/DSView/pv/config/appconfig.cpp +++ b/DSView/pv/config/appconfig.cpp @@ -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; diff --git a/DSView/pv/config/appconfig.h b/DSView/pv/config/appconfig.h index 88a168df..bf300a97 100644 --- a/DSView/pv/config/appconfig.h +++ b/DSView/pv/config/appconfig.h @@ -35,8 +35,6 @@ #define APP_NAME "DSView" //--------------------api--- - -QString GetDirectoryName(QString path); QString GetIconPath(); QString GetAppDataDir(); QString GetResourceDir(); diff --git a/DSView/pv/dialogs/protocolexp.cpp b/DSView/pv/dialogs/protocolexp.cpp index 9546c0ff..739467ad 100755 --- a/DSView/pv/dialogs/protocolexp.cpp +++ b/DSView/pv/dialogs/protocolexp.cpp @@ -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; diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 54ce31c2..ec6cacd6 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -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; diff --git a/DSView/pv/storesession.cpp b/DSView/pv/storesession.cpp index a772cbd0..dde4c7db 100755 --- a/DSView/pv/storesession.cpp +++ b/DSView/pv/storesession.cpp @@ -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; diff --git a/DSView/pv/toolbars/filebar.cpp b/DSView/pv/toolbars/filebar.cpp index eef34b9d..0803a251 100755 --- a/DSView/pv/toolbars/filebar.cpp +++ b/DSView/pv/toolbars/filebar.cpp @@ -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(); diff --git a/DSView/pv/utility/path.cpp b/DSView/pv/utility/path.cpp index 1cce527c..82881628 100644 --- a/DSView/pv/utility/path.cpp +++ b/DSView/pv/utility/path.cpp @@ -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; + } } \ No newline at end of file diff --git a/DSView/pv/utility/path.h b/DSView/pv/utility/path.h index 2f5729ec..4d42a6d9 100644 --- a/DSView/pv/utility/path.h +++ b/DSView/pv/utility/path.h @@ -28,6 +28,8 @@ namespace pv::path { std::string ConvertPath(QString fileName); + + QString GetDirectoryName(QString path); } #endif \ No newline at end of file