Use the file *base* name for statistics graphs etc..

For example, if the file is foo.pcap, make the default name for a saved
PDF of some graph be foo.pdf, as it was prior to 2.6, not foo.pcap.pdf.

Change-Id: Ide99c9c7fa1f3d16f829e731f968a209fbb52b8d
Reviewed-on: https://code.wireshark.org/review/28624
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2018-07-05 17:31:02 -07:00
parent d8df975e2e
commit 874c978bbc
6 changed files with 27 additions and 4 deletions

View File

@ -158,6 +158,21 @@ const QString CaptureFile::fileName()
return name;
}
const QString CaptureFile::fileBaseName()
{
QString path, baseName;
path = filePath();
if (!path.isEmpty()) {
QFileInfo cfi(path);
baseName = cfi.baseName();
} else {
baseName = QString();
}
return baseName;
}
const QString CaptureFile::fileDisplayName()
{
QString displayName;

View File

@ -59,6 +59,14 @@ public:
*/
const QString fileName();
/** Return the plain filename without an extension.
*
* @return The last component of the pathname, without the extension,
* converted from the native OS's encoding to Unicode if necessary, or
* a null string if the conversion can't be done.
*/
const QString fileBaseName();
/** Return a string representing the file suitable for use for
* display in the UI in places such as a main window title.
*

View File

@ -571,7 +571,7 @@ void Iax2AnalysisDialog::on_actionSaveGraph_triggered()
QString save_file = path.canonicalPath();
if (!file_closed_) {
save_file += QString("/%1").arg(cap_file_.fileName());
save_file += QString("/%1").arg(cap_file_.fileBaseName());
}
file_name = WiresharkFileDialog::getSaveFileName(this, wsApp->windowTitleString(tr("Save Graph As" UTF8_HORIZONTAL_ELLIPSIS)),
save_file, filter, &extension);

View File

@ -1402,7 +1402,7 @@ void IOGraphDialog::on_buttonBox_accepted()
QString save_file = path.canonicalPath();
if (!file_closed_) {
save_file += QString("/%1").arg(cap_file_.fileName());
save_file += QString("/%1").arg(cap_file_.fileBaseName());
}
file_name = WiresharkFileDialog::getSaveFileName(this, wsApp->windowTitleString(tr("Save Graph As" UTF8_HORIZONTAL_ELLIPSIS)),
save_file, filter, &extension);

View File

@ -609,7 +609,7 @@ void RtpAnalysisDialog::on_actionSaveGraph_triggered()
QString save_file = path.canonicalPath();
if (!file_closed_) {
save_file += QString("/%1").arg(cap_file_.fileName());
save_file += QString("/%1").arg(cap_file_.fileBaseName());
}
file_name = WiresharkFileDialog::getSaveFileName(this, wsApp->windowTitleString(tr("Save Graph As" UTF8_HORIZONTAL_ELLIPSIS)),
save_file, filter, &extension);

View File

@ -497,7 +497,7 @@ void RtpStreamDialog::on_actionExportAsRtpDump_triggered()
if (stream_info) {
QString file_name;
QDir path(wsApp->lastOpenDir());
QString save_file = path.canonicalPath() + "/" + cap_file_.fileName();
QString save_file = path.canonicalPath() + "/" + cap_file_.fileBaseName();
QString extension;
file_name = WiresharkFileDialog::getSaveFileName(this, wsApp->windowTitleString(tr("Save RTPDump As" UTF8_HORIZONTAL_ELLIPSIS)),
save_file, "RTPDump Format (*.rtpdump)", &extension);