Example #1
0
Editor::Editor(const Logger* lg, ProjectManager* pm, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Editor),
    GridVisible(true),
    LogViewerDialog(lg,this),
    LayerViewerDialog(this),
    ChooseExportTypeDialog(0),
    UndoViewerDialog(0),
    ProjectManagerPtr(pm)
{
    ui->setupUi(this);

    connect(this->ui->tabWidget,SIGNAL(requestNewArray(int)),pm,SLOT(createNewArray(int)));
    connect(this->ui->tabWidget,SIGNAL(currentArrayChanged(Array*)),pm,SLOT(setCurrentArray(Array*)));

    connect(pm,SIGNAL(newArrayCreated(int,Array*)),this->ui->tabWidget,SLOT(setNewArray(int,Array*)));
    connect(lg,SIGNAL(totalLogCountChanged(int)),&(this->LogViewerDialog),SLOT(setTotalLogCount(int)));
    connect(this->ui->tabWidget,SIGNAL(layerTreeModelChanged(LayerTreeModel*)),&LayerViewerDialog,SLOT(setLayerTreeModel(LayerTreeModel*)));
    connect(&LayerViewerDialog,SIGNAL(selectionModelChanged(QItemSelectionModel*)),this->ui->tabWidget,SLOT(setLayerSelectionModel(QItemSelectionModel*)));

    //LayerViewerDialog buttons/key stroke signals
    connect(&LayerViewerDialog,SIGNAL(deleteSelectedLayers()),SLOT(on_LayerViewer_deleteLayers()));
    connect(&LayerViewerDialog,SIGNAL(groupSelectedLayers()),SLOT(on_LayerViewer_groupLayers()));
    connect(&LayerViewerDialog,SIGNAL(ungroupSelectedLayers()),SLOT(on_LayerViewer_ungroupLayers()));
    connect(&LayerViewerDialog,SIGNAL(moveSelectedLayersUp()),SLOT(on_LayerViewer_moveLayersUp()));
    connect(&LayerViewerDialog,SIGNAL(moveSelectedLayersDown()),SLOT(on_LayerViewer_moveLayersDown()));
    connect(&LayerViewerDialog,SIGNAL(moveSelectedLayersToFront()),SLOT(on_LayerViewer_moveLayersToFront()));
    connect(&LayerViewerDialog,SIGNAL(moveSelectedLayersToBack()),SLOT(on_LayerViewer_moveLayersToBack()));

    //unchecks the tool bar buttons when the corresponding window is closed/rejected (QDialog)
    connect(&LogViewerDialog,SIGNAL(rejected()),SLOT(on_LogViewer_closed()));
    connect(&LayerViewerDialog,SIGNAL(rejected()),SLOT(on_LayerViewer_closed()));

    //hack to remove the first Tab created by the qt designer
    this->ui->tabWidget->newTab();
    this->ui->tabWidget->removeTab(0);

    //Add Undo/Redo To Toolbar
    QAction* undo = pm->getUndoAction(this);
    undo->setIcon(QIcon(":/Toolbar/Undo.ico"));
    undo->setShortcut(QKeySequence::Undo);
    this->ui->mainToolBar->insertAction(this->ui->actionUndoList,undo);
    QAction* redo = pm->getRedoAction(this);
    redo->setIcon(QIcon(":/Toolbar/Redo.ico"));
    redo->setShortcut(QKeySequence::Redo);
    this->ui->mainToolBar->insertAction(this->ui->actionCropArray,redo);

    //Create UndoViewerDialog and link it to the UndoGroup
    this->UndoViewerDialog = new UndoViewer(this);
    pm->setUndoViewer(this->UndoViewerDialog->getView());

    //TODO proper check if the grid is enabled after loading a project or change of array
    this->ui->actionShowGrid->setChecked(true);

    showMaximized();
}