23 #include <QFileDialog>
24 #include <QMessageBox>
30 namespace ProjectActions {
32 ExportActions::ExportActions(
33 const shared_ptr<Ws::IProject>& project,
34 const Session::ISession::ExportersType& exporters,
36 : m_project(project), m_parent(parent)
38 for (
auto& exporter : exporters) {
39 QAction* a =
new QAction(QString::fromStdString(exporter.first) +
" ...",
this);
40 m_actions.push_back(a);
41 m_callback_map[a] = exporter;
42 connect(a, SIGNAL(triggered()),
this, SLOT(SLOT_Trigger()));
46 ExportActions::~ExportActions()
50 const vector<QAction*>& ExportActions::GetActions()
const
55 void ExportActions::SLOT_Trigger()
57 auto& exp = m_callback_map[sender()];
58 auto& exp_name = exp.first;
59 auto& exp_extension = exp.second.extension;
60 auto& exp_callback = exp.second.callback;
62 QString dir = QString::fromStdString(m_project->GetPath());
63 QString filters = QString::fromStdString(exp_name) +
" (*."
64 + QString::fromStdString(exp_extension) +
");;All Files (*)";
65 QFileDialog* fd =
new QFileDialog(m_parent,
"Export " + QString::fromStdString(exp_name),
67 fd->setFileMode(QFileDialog::AnyFile);
68 fd->setAcceptMode(QFileDialog::AcceptSave);
70 if (fd->exec() == QDialog::Accepted) {
72 QStringList paths = fd->selectedFiles();
76 QMessageBox::warning(m_parent,
"Error",
"No filename given!");
77 emit
static_cast<QAction*
>(sender())->trigger();
83 QString extension = fi.suffix();
84 if (extension.isEmpty()) {
85 extension = QString::fromStdString(exp_extension);
91 (exp_callback)(path.toStdString());
see the online Qt documentation
Namespace for generic graphical shell for simulators.