Extract file format UI code into separate files
This commit is contained in:
parent
71435869cf
commit
8f89c577ef
@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "clipboardhelper.h"
|
#include "clipboardhelper.h"
|
||||||
|
#include "fileformatoptions.h"
|
||||||
#include "jumpurl.h"
|
#include "jumpurl.h"
|
||||||
#include "logsmodel.h"
|
#include "logsmodel.h"
|
||||||
#include "logswindow.h"
|
#include "logswindow.h"
|
||||||
@ -547,7 +548,7 @@ bool MainWindow::openSession(QString fileName, QString &error)
|
|||||||
goto _fail;
|
goto _fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((optDialog = fmt->openOptionsDialog()))
|
if ((optDialog = FileFormatOptions::openOptionsDialog(fmt)))
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
optDialog->setParent(this, Qt::Dialog);
|
optDialog->setParent(this, Qt::Dialog);
|
||||||
|
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "port.h"
|
#include "port.h"
|
||||||
|
|
||||||
#include "emulation.h"
|
#include "emulation.h"
|
||||||
|
#include "fileformatoptions.h"
|
||||||
#include "streamfileformat.h"
|
#include "streamfileformat.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -604,7 +605,7 @@ bool Port::openStreams(QString fileName, bool append, QString &error)
|
|||||||
goto _fail;
|
goto _fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((optDialog = fmt->openOptionsDialog()))
|
if ((optDialog = FileFormatOptions::openOptionsDialog(fmt)))
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
optDialog->setParent(mainWindow, Qt::Dialog);
|
optDialog->setParent(mainWindow, Qt::Dialog);
|
||||||
|
47
common/fileformatoptions.cpp
Normal file
47
common/fileformatoptions.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2022 Srivats P.
|
||||||
|
|
||||||
|
This file is part of "Ostinato"
|
||||||
|
|
||||||
|
This is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "fileformatoptions.h"
|
||||||
|
|
||||||
|
#include "pcapfileformat.h"
|
||||||
|
#include "pcapoptionsdialog.h"
|
||||||
|
#include "streamfileformat.h"
|
||||||
|
|
||||||
|
QDialog* FileFormatOptions::openOptionsDialog(StreamFileFormat *fileFormat)
|
||||||
|
{
|
||||||
|
if (dynamic_cast<PcapFileFormat*>(fileFormat))
|
||||||
|
return new PcapImportOptionsDialog(fileFormat->options());
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDialog* FileFormatOptions::saveOptionsDialog(StreamFileFormat* /*fileFormat*/)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDialog* FileFormatOptions::openOptionsDialog(SessionFileFormat* /*fileFormat*/)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDialog* FileFormatOptions::saveOptionsDialog(SessionFileFormat* /*fileFormat*/)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
41
common/fileformatoptions.h
Normal file
41
common/fileformatoptions.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2022 Srivats P.
|
||||||
|
|
||||||
|
This file is part of "Ostinato"
|
||||||
|
|
||||||
|
This is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _FILE_FORMAT_OPTIONS_H
|
||||||
|
#define _FILE_FORMAT_OPTIONS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class SessionFileFormat;
|
||||||
|
class StreamFileFormat;
|
||||||
|
class QDialog;
|
||||||
|
|
||||||
|
class FileFormatOptions : QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
static QDialog* openOptionsDialog(StreamFileFormat *fileFormat);
|
||||||
|
static QDialog* saveOptionsDialog(StreamFileFormat *fileFormat);
|
||||||
|
|
||||||
|
static QDialog* openOptionsDialog(SessionFileFormat *fileFormat);
|
||||||
|
static QDialog* saveOptionsDialog(SessionFileFormat *fileFormat);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -25,6 +25,7 @@ HEADERS = \
|
|||||||
streamfileformat.h
|
streamfileformat.h
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
fileformatoptions.h \
|
||||||
pcapoptionsdialog.h
|
pcapoptionsdialog.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
@ -43,6 +44,7 @@ SOURCES += \
|
|||||||
spinboxdelegate.cpp
|
spinboxdelegate.cpp
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
fileformatoptions.cpp \
|
||||||
pcapoptionsdialog.cpp
|
pcapoptionsdialog.cpp
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
@ -701,9 +701,9 @@ _exit:
|
|||||||
return isOk;
|
return isOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog* PcapFileFormat::openOptionsDialog()
|
QVariantMap* PcapFileFormat::options()
|
||||||
{
|
{
|
||||||
return new PcapImportOptionsDialog(&importOptions_);
|
return &importOptions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PcapFileFormat::isMyFileFormat(const QString /*fileName*/)
|
bool PcapFileFormat::isMyFileFormat(const QString /*fileName*/)
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
bool save(const OstProto::StreamConfigList streams,
|
bool save(const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error);
|
const QString fileName, QString &error);
|
||||||
|
|
||||||
virtual QDialog* openOptionsDialog();
|
virtual QVariantMap* options();
|
||||||
|
|
||||||
bool isMyFileFormat(const QString fileName);
|
bool isMyFileFormat(const QString fileName);
|
||||||
bool isMyFileType(const QString fileType);
|
bool isMyFileType(const QString fileType);
|
||||||
|
@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
PcapImportOptionsDialog::PcapImportOptionsDialog(QVariantMap *options)
|
PcapImportOptionsDialog::PcapImportOptionsDialog(QVariantMap *options)
|
||||||
: QDialog(NULL)
|
: QDialog(NULL)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(options != NULL);
|
||||||
|
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
options_ = options;
|
options_ = options;
|
||||||
|
@ -32,12 +32,7 @@ SessionFileFormat::~SessionFileFormat()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog* SessionFileFormat::openOptionsDialog()
|
QVariantMap* SessionFileFormat::options()
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDialog* SessionFileFormat::saveOptionsDialog()
|
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "fileformat.pb.h"
|
#include "fileformat.pb.h"
|
||||||
#include "protocol.pb.h"
|
#include "protocol.pb.h"
|
||||||
|
|
||||||
#include <QThread>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QThread>
|
||||||
class QDialog;
|
#include <QVariantMap>
|
||||||
|
|
||||||
class SessionFileFormat : public QThread
|
class SessionFileFormat : public QThread
|
||||||
{
|
{
|
||||||
@ -42,8 +41,7 @@ public:
|
|||||||
virtual bool save(const OstProto::SessionContent &session,
|
virtual bool save(const OstProto::SessionContent &session,
|
||||||
const QString fileName, QString &error) = 0;
|
const QString fileName, QString &error) = 0;
|
||||||
|
|
||||||
virtual QDialog* openOptionsDialog();
|
virtual QVariantMap* options();
|
||||||
virtual QDialog* saveOptionsDialog();
|
|
||||||
|
|
||||||
void openAsync(const QString fileName,
|
void openAsync(const QString fileName,
|
||||||
OstProto::SessionContent &session, QString &error);
|
OstProto::SessionContent &session, QString &error);
|
||||||
|
@ -35,12 +35,7 @@ StreamFileFormat::~StreamFileFormat()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog* StreamFileFormat::openOptionsDialog()
|
QVariantMap* StreamFileFormat::options()
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDialog* StreamFileFormat::saveOptionsDialog()
|
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,7 @@ public:
|
|||||||
virtual bool save(const OstProto::StreamConfigList streams,
|
virtual bool save(const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error) = 0;
|
const QString fileName, QString &error) = 0;
|
||||||
|
|
||||||
virtual QDialog* openOptionsDialog();
|
virtual QVariantMap* options();
|
||||||
virtual QDialog* saveOptionsDialog();
|
|
||||||
|
|
||||||
void openAsync(const QString fileName,
|
void openAsync(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error);
|
OstProto::StreamConfigList &streams, QString &error);
|
||||||
|
Loading…
Reference in New Issue
Block a user