tycho: use inheritance instead of QSharedPointers
parent
8889bcf1a4
commit
5e09c1dae8
|
@ -2,14 +2,11 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
#include "../ui/ui_mapprops.h"
|
||||||
|
|
||||||
class ProjectModel;
|
class ProjectModel;
|
||||||
|
|
||||||
namespace Ui
|
class MapProps : public QDialog, private Ui::MapProps
|
||||||
{
|
|
||||||
class MapProps;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MapProps : public QDialog
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -20,7 +17,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<ProjectModel> proj;
|
QSharedPointer<ProjectModel> proj;
|
||||||
QSharedPointer<Ui::MapProps> ui;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
|
@ -3,15 +3,11 @@
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../ui/ui_menu.h"
|
||||||
|
|
||||||
class ProjectView;
|
class ProjectView;
|
||||||
class QMdiSubWindow;
|
|
||||||
|
|
||||||
namespace Ui
|
class Menu : public QMainWindow, private Ui::Menu
|
||||||
{
|
|
||||||
class Menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Menu : public QMainWindow
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -34,8 +30,6 @@ private:
|
||||||
ProjectView *activeProject() const;
|
ProjectView *activeProject() const;
|
||||||
QMdiSubWindow *activeSubWindow() const;
|
QMdiSubWindow *activeSubWindow() const;
|
||||||
void addProject(ProjectView *view);
|
void addProject(ProjectView *view);
|
||||||
|
|
||||||
QSharedPointer<Ui::Menu> ui;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "bindings.h"
|
|
||||||
|
|
||||||
#include <QMdiSubWindow>
|
#include <QMdiSubWindow>
|
||||||
|
|
||||||
namespace Ui
|
#include "bindings.h"
|
||||||
{
|
#include "../ui/ui_projectview.h"
|
||||||
class ProjectView;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ProjectModel : public QObject
|
class ProjectModel : public QObject
|
||||||
{
|
{
|
||||||
|
@ -27,7 +23,7 @@ private:
|
||||||
Project data;
|
Project data;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProjectView : public QMdiSubWindow
|
class ProjectView : public QMdiSubWindow, private Ui::ProjectView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -41,7 +37,6 @@ protected:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<Ui::ProjectView> ui;
|
|
||||||
QSharedPointer<ProjectModel> proj;
|
QSharedPointer<ProjectModel> proj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
#include "tycho.h"
|
#include "tycho.h"
|
||||||
#include "mapprops.h"
|
#include "mapprops.h"
|
||||||
#include "../ui/ui_mapprops.h"
|
|
||||||
|
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
|
||||||
MapProps::MapProps(QSharedPointer<ProjectModel> _proj, QWidget *parent) :
|
MapProps::MapProps(QSharedPointer<ProjectModel> _proj, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::MapProps),
|
|
||||||
proj(_proj)
|
proj(_proj)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
setModal(true);
|
setModal(true);
|
||||||
|
|
||||||
auto bbox = new QDialogButtonBox(this);
|
auto bbox = new QDialogButtonBox(this);
|
||||||
bbox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
|
bbox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
|
||||||
ui->verticalLayout->addWidget(bbox);
|
verticalLayout->addWidget(bbox);
|
||||||
|
|
||||||
connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
|
connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
connect(bbox, SIGNAL(rejected()), this, SLOT(reject()));
|
connect(bbox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include "mapprops.h"
|
#include "mapprops.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "../ui/ui_menu.h"
|
|
||||||
#include "../ui/ui_about.h"
|
#include "../ui/ui_about.h"
|
||||||
#include "../ui/ui_license.h"
|
#include "../ui/ui_license.h"
|
||||||
|
|
||||||
|
@ -12,17 +11,16 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
Menu::Menu(QWidget *parent) :
|
Menu::Menu(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent)
|
||||||
ui(new Ui::Menu)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
ui->actionAbout->setShortcut(QKeySequence(QKeySequence::HelpContents));
|
actionAbout->setShortcut(QKeySequence(QKeySequence::HelpContents));
|
||||||
ui->actionClose->setShortcut(QKeySequence(QKeySequence::Close));
|
actionClose->setShortcut(QKeySequence(QKeySequence::Close));
|
||||||
ui->actionMapProps->setShortcut(QKeySequence(tr("Ctrl+P")));
|
actionMapProps->setShortcut(QKeySequence(tr("Ctrl+P")));
|
||||||
ui->actionNew->setShortcut(QKeySequence(QKeySequence::New));
|
actionNew->setShortcut(QKeySequence(QKeySequence::New));
|
||||||
ui->actionOpen->setShortcut(QKeySequence(QKeySequence::Open));
|
actionOpen->setShortcut(QKeySequence(QKeySequence::Open));
|
||||||
ui->actionQuit->setShortcut(QKeySequence(QKeySequence::Quit));
|
actionQuit->setShortcut(QKeySequence(QKeySequence::Quit));
|
||||||
|
|
||||||
dbgPrintFunc();
|
dbgPrintFunc();
|
||||||
}
|
}
|
||||||
|
@ -111,15 +109,15 @@ void Menu::updateActions()
|
||||||
auto view = activeProject();
|
auto view = activeProject();
|
||||||
bool active = view != nullptr;
|
bool active = view != nullptr;
|
||||||
|
|
||||||
ui->actionClose->setEnabled(active);
|
actionClose->setEnabled(active);
|
||||||
ui->actionMapProps->setEnabled(active);
|
actionMapProps->setEnabled(active);
|
||||||
|
|
||||||
dbgPrintFunc();
|
dbgPrintFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::closeEvent(QCloseEvent *event)
|
void Menu::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
for(auto *win : ui->mdiArea->subWindowList()) {
|
for(auto *win : mdiArea->subWindowList()) {
|
||||||
if(!win->close()) {
|
if(!win->close()) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
return;
|
return;
|
||||||
|
@ -136,12 +134,13 @@ ProjectView *Menu::activeProject() const
|
||||||
|
|
||||||
QMdiSubWindow *Menu::activeSubWindow() const
|
QMdiSubWindow *Menu::activeSubWindow() const
|
||||||
{
|
{
|
||||||
return ui->mdiArea->activeSubWindow();
|
return mdiArea->activeSubWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::addProject(ProjectView *view)
|
void Menu::addProject(ProjectView *view)
|
||||||
{
|
{
|
||||||
auto win = ui->mdiArea->addSubWindow(view);
|
auto win = mdiArea->addSubWindow(view);
|
||||||
|
|
||||||
win->showMaximized();
|
win->showMaximized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
#include "tycho.h"
|
#include "tycho.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "../ui/ui_projectview.h"
|
|
||||||
|
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
ProjectView::ProjectView(QWidget *parent) :
|
ProjectView::ProjectView(QWidget *parent) :
|
||||||
QMdiSubWindow(parent),
|
QMdiSubWindow(parent),
|
||||||
ui(new Ui::ProjectView),
|
|
||||||
proj(new ProjectModel)
|
proj(new ProjectModel)
|
||||||
{
|
{
|
||||||
auto widget = new QWidget(this);
|
auto widget = new QWidget(this);
|
||||||
|
|
||||||
ui->setupUi(widget);
|
setupUi(widget);
|
||||||
|
|
||||||
setWidget(widget);
|
setWidget(widget);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
Loading…
Reference in New Issue