void MainWindow::newProject() { if(m_project) { if(!closeProject()) return; } //TODO show project wizard m_project = new Project(); m_project->setName("Test Project"); connect (m_project, SIGNAL(projectChanged()), this, SLOT(unsavedChanges())); showProjectView(); m_unsavedChanges = false; ui->actSaveProject->setEnabled(true); ui->actSaveProjectAs->setEnabled(true); ui->actCloseProject->setEnabled(true); ui->actImportAutomaton->setEnabled(true); ui->menuAutomata->setEnabled(true); ui->menuServer->setEnabled(true); ui->actShowSettings->setEnabled(true); ui->actDeleteAutomaton->setEnabled(true); m_projectWidget->setMode("unknown"); }
void Project::CreateNewSubdomain() { if (fullDomain && projectFile) { CreateSubdomainDialog dlg; dlg.SetFullDomainDirectory(projectFile->GetFullDomainDirectory()); if (dlg.exec() && dlg.CreateTargetDir()) { QString name = dlg.GetSubdomainName(); QString targetDir = dlg.GetSubdomainDirectory(); int version = 1; int recordFrequency = dlg.GetRecordFrequency(); if (!name.isEmpty() && !targetDir.isEmpty() && (version == 1 || version == 2) && recordFrequency > 0) { SubdomainCreator creator; bool newSubdomain = creator.CreateSubdomain(name, projectFile, targetDir, fullDomain, version, recordFrequency); if (newSubdomain) { BuildSubdomain(name); PopulateProjectTree(); emit showProjectView(); projectTree->setCurrentItem(projectTree->findItems(name, Qt::MatchExactly | Qt::MatchRecursive).first()); } } } } }
void MainWindow::CreateProjectNew(bool newProjectFile) { if (newProject) delete newProject; if (newProjectFile) { newProject = new Project_new(this); } else { QStringList selections; QFileDialog dialog(0, "Open an ADCIRC Subdomain Project", QDir::homePath()); dialog.setModal(true); dialog.setNameFilter("ADCIRC Subdomain Projects (*.spf)"); dialog.setFileMode(QFileDialog::ExistingFile); if (dialog.exec()) { selections = dialog.selectedFiles(); if (!selections.isEmpty()) { newProject = new Project_new(selections.first(), this); } } else { return; } } newProject->SetOpenGLPanel(ui->GLPanel); newProject->SetProgressBar(ui->progressBar); newProject->SetProjectTree(ui->projectTree); /* Subdomain Creation */ connect(ui->createSubdomainButton, SIGNAL(clicked()), newProject, SLOT(CreateNewSubdomain())); /* Selection Tools */ connect(ui->selectNodesCircle, SIGNAL(clicked()), newProject, SLOT(SelectFullDomainCircleElements())); connect(ui->selectElementSingle, SIGNAL(clicked()), newProject, SLOT(SelectFullDomainClickElements())); connect(ui->selectNodeSingle, SIGNAL(clicked()), newProject, SLOT(SelectFullDomainPolygonElements())); connect(ui->selectNodesSquare, SIGNAL(clicked()), newProject, SLOT(SelectFullDomainRectangleElements())); connect(ui->undoButton, SIGNAL(clicked()), newProject, SLOT(Undo())); connect(ui->redoButton, SIGNAL(clicked()), newProject, SLOT(Redo())); /* U/I Updates */ connect(newProject, SIGNAL(mouseX(float)), this, SLOT(showMouseX(float))); connect(newProject, SIGNAL(mouseY(float)), this, SLOT(showMouseY(float))); connect(newProject, SIGNAL(undoAvailable(bool)), ui->undoButton, SLOT(setEnabled(bool))); connect(newProject, SIGNAL(redoAvailable(bool)), ui->redoButton, SLOT(setEnabled(bool))); connect(newProject, SIGNAL(numElements(int)), this, SLOT(showNumElements(int))); connect(newProject, SIGNAL(numNodes(int)), this, SLOT(showNumNodes(int))); connect(newProject, SIGNAL(numElementsSelected(int)), this, SLOT(showNumSelectedElements(int))); connect(newProject, SIGNAL(numNodesSelected(int)), this, SLOT(showNumSelectedNodes(int))); connect(newProject, SIGNAL(maxSelectedZ(float)), this, SLOT(showMaxSelectedZ(float))); connect(newProject, SIGNAL(minSelectedZ(float)), this, SLOT(showMinSelectedZ(float))); connect(newProject, SIGNAL(showProjectView()), this, SLOT(showProjectExplorerPane())); /* Running ADCIRC */ connect(ui->actionFull_Domain, SIGNAL(triggered()), newProject, SLOT(RunFullDomain())); }
void MainWindow::openProject() { if(m_project) if(!closeProject()) return; QString fileName = QFileDialog::getOpenFileName(this, tr("Open DES Project"), QDir::currentPath(), tr("DES Files (*.xml)")); if (fileName.isEmpty()) return; QFile file(fileName); if (!file.open(QFile::ReadOnly | QFile::Text)) { QMessageBox::warning(this, tr("DES Project Reader"), tr("Cannot open file %1:\n%2.") .arg(fileName) .arg(file.errorString())); return; } ProjectSerializer serializer; m_project = serializer.loadProject(&file); if(m_project) { statusBar()->showMessage(tr("Project opened"), 20000); m_project->setFileName(fileName); connect (m_project, SIGNAL(projectChanged()), this, SLOT(unsavedChanges())); showProjectView(); m_unsavedChanges = false; ui->actSaveProject->setEnabled(true); ui->actSaveProjectAs->setEnabled(true); ui->actCloseProject->setEnabled(true); ui->actImportAutomaton->setEnabled(true); ui->menuAutomata->setEnabled(true); ui->menuServer->setEnabled(true); ui->actShowSettings->setEnabled(true); ui->actDeleteAutomaton->setEnabled(true); m_projectWidget->setMode("unknown"); } else { delete m_project; m_project = 0; } }
void MainWindow::newProject() { qDebug() << "\n[*] MainWindow::newProject"; if (mProject != NULL) { qCritical() << "[-] Project already in Progress"; exit(1); } mProject = new Project; /* Get Project Name */ bool ok; QString projectName = QInputDialog::getText(this, tr("QInputDialog::getText()"), tr("Enter a Project Name:"), QLineEdit::Normal, QDir::home().dirName(), &ok); if (ok && !projectName.isEmpty()) mProject->setProjectName(projectName); qDebug() << "[+] New Project name: " << projectName; /* Setting up directory structure */ // TODO: Add HOl and Haskell folders, latex qDebug() << "[+] Setting up directory structure"; QDir cur; cur.mkdir(projectName); cur.cd(projectName); mProject->mTopLevel = cur; cur.mkdir("xml"); cur.cd("xml"); mProject->mXmlFolder = cur; qDebug() << "[+] \tTop Level:" << mProject->mTopLevel.path(); qDebug() << "[+] \tXml: " << mProject->mXmlFolder.path(); showTransistionDiagram(); showProjectView(); }
void MainWindow::createActions() { mNewFileAction = new QAction(QIcon(":/images/new.png"), tr("&New"), this); mNewFileAction->setShortcut(QKeySequence::New); mNewFileAction->setStatusTip(tr("Open a new file")); connect(mNewFileAction, SIGNAL(triggered()), this, SLOT(newBlankPage())); mOpenFileAction = new QAction(QIcon(":/images/open.png"), tr("&Open"), this); mOpenFileAction->setShortcut(QKeySequence::Open); mOpenFileAction->setStatusTip(tr("Open file")); connect(mOpenFileAction, SIGNAL(triggered()), this, SLOT(openPage())); mSaveFileAction = new QAction(QIcon(":/images/save.png"), tr("&Save"), this); mSaveFileAction->setShortcut(QKeySequence::Save); mSaveFileAction->setStatusTip(tr("Save file")); connect(mSaveFileAction, SIGNAL(triggered()), this, SLOT(saveTab())); mSaveAsFileAction = new QAction(QIcon(":/images/saveAs.png"), tr("Save &As"), this); mSaveAsFileAction->setShortcut(QKeySequence::SaveAs); mSaveAsFileAction->setStatusTip(tr("Save file as")); connect(mSaveAsFileAction, SIGNAL(triggered()), this, SLOT(savePageAs())); mExitAction = new QAction(tr("&Exit"), this); mExitAction->setShortcut(QKeySequence::Quit); mExitAction->setStatusTip(tr("Exit the application")); connect(mExitAction, SIGNAL(triggered()), this, SLOT(close())); /* Project Actions */ mNewProjectAction = new QAction(tr("New Project"), this); mNewFileAction->setStatusTip(tr("Creates a new Project")); connect(mNewProjectAction, SIGNAL(triggered()), this, SLOT(newProject())); mOpenProjectAction = new QAction(tr("Open Project"), this); mOpenProjectAction->setStatusTip(tr("Open an existing project")); mSaveProjectAction = new QAction(tr("Save Project"), this); mSaveProjectAction->setStatusTip(tr("Save current project")); mSaveProjectAsAction = new QAction(tr("Save Project As"), this); mSaveProjectAsAction->setStatusTip(tr("Save current project as")); mShowProjectViewAction = new QAction(tr("Show Project View"), this); mShowProjectViewAction->setStatusTip(tr("Show Project Settings and Properties")); connect(mShowProjectViewAction, SIGNAL(triggered()), this, SLOT(showProjectView())); mShowTransistionDiagramAction = new QAction(tr("Show Transistion Diagram"), this); mShowTransistionDiagramAction->setStatusTip(tr("Show the Projects Transistion Diagram")); connect(mShowTransistionDiagramAction, SIGNAL(triggered()), this, SLOT(showTransistionDiagram())); mGenerateHOLAction = new QAction(tr("Generate HOL"), this); mGenerateHOLAction->setStatusTip(tr("Generate all the HOL files for the project")); mGenerateHaskellAction = new QAction(tr("Generate Haskell"), this); mGenerateHaskellAction->setStatusTip(tr("Generate all the Haskell files for the project")); mGenerateDocAction = new QAction(tr("Generate Documentation"), this); mGenerateDocAction->setStatusTip(tr("Generate Documentation for project")); mCloseProjectAction = new QAction(tr("Close project"), this); mCloseProjectAction->setStatusTip(tr("Closes the current project")); /* Edit Actions */ mUndoAction = new QAction(tr("&Undo"), this); mUndoAction->setShortcut(QKeySequence::Undo); mUndoAction->setStatusTip(tr("Undo")); connect(mUndoAction, SIGNAL(triggered()), this, SLOT(undo())); mRedoAction = new QAction(tr("&Redo"), this); mRedoAction->setShortcut(QKeySequence::Redo); mRedoAction->setStatusTip(tr("Redo")); connect(mRedoAction, SIGNAL(triggered()), this, SLOT(redo())); mCutAction = new QAction(tr("&Cut"), this); mCutAction->setShortcut(QKeySequence::Cut); mCutAction->setStatusTip(tr("Cut")); connect(mCutAction, SIGNAL(triggered()), this, SLOT(cut())); mCopyAction = new QAction(tr("&Copy"), this); mCopyAction->setShortcut(QKeySequence::Copy); mCopyAction->setStatusTip(tr("Copy")); connect(mCopyAction, SIGNAL(triggered()), this, SLOT(copy())); mPasteAction = new QAction(tr("&Paste"), this); mPasteAction->setShortcut(QKeySequence::Paste); mPasteAction->setStatusTip(tr("Paste")); connect(mPasteAction, SIGNAL(triggered()), this, SLOT(paste())); mSelectAllAction = new QAction(tr("Select &All"), this); mSelectAllAction->setShortcut(QKeySequence::SelectAll); mSelectAllAction->setStatusTip(tr("Select All")); connect(mSelectAllAction, SIGNAL(triggered()), this, SLOT(selectAll())); mFindReplaceAction = new QAction(tr("&Find/Replace"), this); mFindReplaceAction->setShortcut(QKeySequence::Find); mFindReplaceAction->setStatusTip(tr("Find/Replace")); connect(mSelectAllAction, SIGNAL(triggered()), this, SLOT(findReplace())); /* HOL Menu Actions */ mHOLRestartAction = new QAction(tr("Restart HOL"), this); mHOLRestartAction->setStatusTip(tr("Restart the HOL buffer")); connect(mHOLRestartAction, SIGNAL(triggered()), mHOLWidget, SLOT(restart())); mHOLSendRegionToAction = new QAction(tr("Send Region to HOL"), this); mHOLSendRegionToAction->setStatusTip(tr("Sends the highlighted region to the HOL buffer")); //connect mHOLRunHolmakeAction = new QAction(tr("Run Holmake"), this); mHOLRunHolmakeAction->setStatusTip(tr("Runs Holamake in current directory")); connect(mHOLRunHolmakeAction, SIGNAL(triggered()), this, SLOT(runHolmake())); mHOLShowTypesAction = new QAction(tr("Show Types"), this); mHOLShowTypesAction->setStatusTip(tr("Show Types")); connect(mHOLShowTypesAction, SIGNAL(triggered()), mHOLWidget, SLOT(showTypes())); mHOLShowTypesVerboseAction = new QAction(tr("Show Types Verbosely"), this); mHOLShowTypesVerboseAction->setStatusTip(tr("Show Types Verbosely")); connect(mHOLShowTypesVerboseAction, SIGNAL(triggered()), mHOLWidget, SLOT(showTypesVerbose())); mHOLShowNumericalTypesAction = new QAction(tr("Show Numerical Types"), this); mHOLShowNumericalTypesAction->setStatusTip(tr("Show Numerical Types")); connect(mHOLShowNumericalTypesAction, SIGNAL(triggered()), mHOLWidget, SLOT(showNumericalTypes())); mHOLShowAssumptionsAction = new QAction(tr("Show Assumptions"), this); mHOLShowAssumptionsAction->setStatusTip(tr("Show Assumptions")); connect(mHOLShowAssumptionsAction, SIGNAL(triggered()), mHOLWidget, SLOT(showAssumptions())); /* Help Menu Actions */ mHOLDocumentationAction = new QAction(tr("HOL Documentation"), this); mHOLDocumentationAction->setStatusTip(tr("Show HOL Documentation")); mAboutAction = new QAction(tr("About"), this); mAboutAction->setStatusTip(tr("About")); /* Transistion Diagram Actions */ mAddStateAction = new QAction(tr("Add State"), this); mAddStateAction->setStatusTip("Add a new State to the Transistion Diagram"); mDeleteStateAction = new QAction(tr("Remove State"), this); mDeleteStateAction->setStatusTip("Remove state from Transistion Diagram"); mMakeLinkAction = new QAction(tr("Connect States"), this); mMakeLinkAction->setStatusTip("Connect two states"); mDeleteLinkAction = new QAction(tr("Remove Link"), this); mDeleteLinkAction->setStatusTip("Remove the Link between two States"); mStatePropertiesAction = new QAction(tr("State Properties"), this); mStatePropertiesAction->setStatusTip("Display the Properties of the State"); mZoomInAction = new QAction(tr("Zoom In"), this); mZoomInAction->setStatusTip("Zoom In on the Diagrams"); mZoomOutAction = new QAction(tr("Zoom Out"), this); mZoomOutAction->setStatusTip("Zoom Out on the Diagram"); }