void MainWindow::on_treeView_clicked(const QModelIndex &index) { auto item = (ProjectItem*) Workspace::Instance.GetProjectsModel()->itemFromIndex(index); std::string name = item->GetName(); if (item->IsDocument()) { ProjectItem* parent = (ProjectItem*) item->parent(); if (Workspace::Instance.GetCurrentProject()->GetName() == parent->GetName() && Workspace::Instance.GetCurrentDocument()->GetName() == item->GetName()) return; Workspace::Instance.SetCurrent(parent->GetName(), item->GetName()); } else { if (Workspace::Instance.GetCurrentProject()->GetName() == name) return; Workspace::Instance.SetCurrent(item->GetName()); } RefreshImage(); on_actionFit_to_Window_triggered(); }
//---------------------------------------------------------------- wxXmlNode* ProjectItemFile::WriteNode() /** * \brief Writes a 'projectitem' xml element node. * See class description for more information. * \return The 'projectitem' xml element node. **/ { wxXmlNode* node = PenvHelper::CreateXmlNode(_T("projectitem")); node->AddProperty(_T("name"), m_name); node->AddProperty(_T("type"), _T("file")); node->AddProperty(_T("virtual"), PenvHelper::CreateBoolean(m_virtual)); wxString parentpath; if (m_parent->GetProjectParent() == NULL) { ProjectItem* item = m_parent->GetProjectItemParent(); parentpath = item->GetPathString(); } else { Project* project = m_parent->GetProjectParent(); parentpath = project->GetFileNameString(); } wxXmlNode* filename = PenvHelper::CreateXmlNode(_T("filename"), Path::MakeRelative(parentpath, m_filename.GetPath())); PenvHelper::AddXmlChildNode(node, filename); wxXmlNode* propnode = m_properties->WriteNode(); PenvHelper::AddXmlChildNode(node, propnode); return (node); }
void Workspace::AddDocument(string projectName, QString& imageFullPath, ProcessingOptions& options) { QFileInfo imageFileInfo(imageFullPath); // Get project. Project* project = m_Projects[projectName].get(); m_ProjectsPersistentState[projectName] = false; QString projectDirPath = QString(project->GetDocumentsPath().c_str()); QDir projectDir(projectDirPath); // Copy image to project dir. QString dstImageFullPath = projectDir.absoluteFilePath(imageFileInfo.fileName()); QFile::copy(imageFullPath, dstImageFullPath); // Get image name. QString docNameQ = imageFileInfo.baseName(); std::string docName = Utils::StringQ2W(docNameQ); // Add image to project. Document* document = project->AddDocument( docName, Utils::StringQ2W(dstImageFullPath), options); // Add image to view model. auto projRowItem = m_ProjectsModel.findItems(Utils::StringW2Q(projectName)); ProjectItem* projectItem = (ProjectItem*) projRowItem.first(); ProjectItem* docItem = new ProjectItem(docName, true); QList<QStandardItem*> docRowItem; docRowItem << docItem; projectItem->appendRow(docItem); SetCurrent(project, projectItem, document, docItem); }
void ProjectFrame::ItemProperties() { ProjectItem *itm = prjTree->GetSelectedNode(); if (itm) { if (itm->ItemProperties()) prjTree->UpdateNode(itm); } }
QSize IconViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { ProjectItem* item = static_cast<ProjectItem*>(index.internalPointer()); if (item) { QRect r = option.fontMetrics.boundingRect(QString(item->toString())); return QSize(128 + 16, 128 + r.height() + 8); } return QSize(); }
int ProjectFrame::SaveFile() { EditorView *vw = GetActiveEditor(); if (vw) { ProjectItem *itm = vw->GetItem(); if (itm) return itm->SaveItem(); } return 0; }
void FilelistOrder::OnFileMvdn(wxCommandEvent& evt) { int sel = fileList->GetSelection(); if (sel == wxNOT_FOUND) return; ProjectItem *p = (ProjectItem *)fileList->GetClientData(sel); fileList->Delete(sel); sel++; fileList->Insert(p->GetName(), (unsigned int)sel, reinterpret_cast<void*>(p)); fileList->SetSelection(sel); EnableUpDn(); }
void Workspace::SetCurrent(std::string projectName, std::string documentName) { Project* proj = nullptr; ProjectItem* projItem = nullptr; Document* doc = nullptr; ProjectItem* docItem = nullptr; // Get project; proj = m_Projects[projectName].get(); // Get project view item. auto projRowItem = m_ProjectsModel.findItems(Utils::StringW2Q(projectName)); projItem = (ProjectItem*) projRowItem.first(); // If document is not specified, use first doc. auto docs = proj->GetDocuments(); if (documentName.empty() && !docs.empty()) { documentName = docs.front()->GetName(); } // If there is document, get document and document view item. if (!documentName.empty()) { // Get document. for (auto d : docs) { if (d->GetName().compare(documentName) == 0) { doc = d; break; } } // Get document view item. for (int i = 0; i < (int) docs.size(); i++) { ProjectItem* di = (ProjectItem*) projItem->child(i); if(di->GetName().compare(documentName) == 0) { docItem = di; break; } } } SetCurrent(proj, projItem, doc, docItem); }
void Project::RecursiveAdd(wxXmlNode *xmlNode, ProjectTreePtr &ptp, ProjectTreeNode *nodeParent) { // Build the key for this node std::list<wxString> nameList; wxXmlNode *parent = xmlNode->GetParent(); while ( parent ) { nameList.push_front(parent->GetPropVal(wxT("Name"), wxEmptyString)); parent = parent->GetParent(); } wxString key; for (size_t i=0; i<nameList.size(); i++) { key += nameList.front(); key += wxT(":"); nameList.pop_front(); } key += xmlNode->GetPropVal(wxT("Name"), wxEmptyString); // Create the tree node data ProjectItem item; if ( xmlNode->GetName() == wxT("Project") ) { item = ProjectItem(key, xmlNode->GetPropVal(wxT("Name"), wxEmptyString), wxEmptyString, ProjectItem::TypeProject); } else if ( xmlNode->GetName() == wxT("VirtualDirectory") ) { item = ProjectItem(key, xmlNode->GetPropVal(wxT("Name"), wxEmptyString), wxEmptyString, ProjectItem::TypeVirtualDirectory); } else if ( xmlNode->GetName() == wxT("File") ) { wxFileName filename(xmlNode->GetPropVal(wxT("Name"), wxEmptyString)); //convert this file name to absolute path DirSaver ds; ::wxSetWorkingDirectory(m_fileName.GetPath()); filename.MakeAbsolute(); item = ProjectItem(key, filename.GetFullName(), filename.GetFullPath(), ProjectItem::TypeFile); } else { // un-recognised or not viewable item in the tree, // skip it and its children return; } ProjectTreeNode *newNode = ptp->AddChild(item.Key(), item, nodeParent); // This node has children, add them as well wxXmlNode *children = xmlNode->GetChildren(); while ( children ) { RecursiveAdd(children, ptp, newNode); children = children->GetNext(); } SetModified(true); }
void FilelistOrder::OnOK(wxCommandEvent& evt) { ProjectItem *itm; int count = (int)fileList->GetCount(); int index = 0; while (index < count) { itm = (ProjectItem *) fileList->GetClientData(index); itm->AddRef(); prjTree->RemoveNode(itm); prjTree->AddNode(itm); itm->Release(); index++; } theProject->SetChange(1); EndModal(1); }
void ScoreErrorsDlg::Refresh() { itmSel.ResetContent(); ProjectItem *pi = prjTree->FirstChild(theProject->nlInfo); while (pi) { if (pi->GetType() == PRJNODE_NOTEFILE) { int ndx = itmSel.AddString(pi->GetName()); itmSel.SetItemDataPtr(ndx, (void*)pi); } pi = prjTree->NextSibling(pi); } itmSel.SetCurSel(0); ShowErrors(); }
int InstrList::Save(XmlSynthElem *node) { XmlSynthElem *child = node->AddChild("instrlib"); ProjectItem *pi = prjTree->FirstChild(this); while (pi) { if (pi->GetType() == PRJNODE_INSTR) { XmlSynthElem *instr = child->AddChild("instr"); InstrItem *ii = (InstrItem *) pi; ii->Save(instr); delete instr; } pi = prjTree->NextSibling(pi); } delete child; return 0; }
void FilelistOrder::OnInitDialog(wxInitDialogEvent& evt) { CenterOnParent(); if (pi) { ProjectItem *ch = prjTree->FirstChild(pi); while (ch) { fileList->Append(ch->GetName(), reinterpret_cast<void*>(ch)); ch = prjTree->NextSibling(ch); } } if (fileList->GetCount() > 0) fileList->SetSelection(0); EnableUpDn(); }
void ProjectFrame::RemoveItem() { ProjectItem *itm = prjTree->GetSelectedNode(); if(itm) { bsString prompt; prompt = "Remove item '"; prompt += itm->GetName(); prompt += "'?"; if (prjFrame->Verify(prompt, "Verify...")) { if (itm->RemoveItem()) { CloseEditor(itm); prjTree->RemoveNode(itm); theProject->SetChange(1); } } } }
void WavetableSelectDlg::OnInitDialog(wxInitDialogEvent& evt) { CenterOnParent(); wxWindow *frm = FindWindow("IDC_WT_GRAPH"); if (!frm) return; wxPoint pos = frm->GetPosition(); wxSize siz = frm->GetSize(); frm->Destroy(); plotter = new WavetableDraw(this, 99, pos, siz); plotter->index = initSelect; lst = (wxListBox*)FindWindow("IDC_WT_LIST"); lst->Append("Sin", (void*)0); lst->Append("Sawtooth (sum)", (void*)1); lst->Append("Square (sum)", (void*)2); lst->Append("Triangle (sum)", (void*)3); lst->Append("Pulse (sum)", (void*)4); lst->Append("Sawtooth (direct)", (void*)5); lst->Append("Square (direct)", (void*)6); lst->Append("Triangle (direct)", (void*)7); lst->Append("Sawtooth (positive)", (void*)8); lst->Append("Triangle (positive)", (void*)9); int selected = initSelect; ProjectItem *pi = prjTree->FirstChild(theProject->synthInfo); while (pi) { if (pi->GetType() == PRJNODE_WVTABLE) { WavetableItem *wi = (WavetableItem*)pi; int index = lst->Append(wi->GetName(), (void*)(long)wi->GetID()); if (wi->GetID() == initSelect) selected = index; } pi = prjTree->NextSibling(pi); } if ((unsigned int)selected < lst->GetCount()) lst->SetSelection(selected); }
int InstrList::NextInum() { int inum = 1; InstrConfig *ic = 0; ProjectItem *pi = prjTree->FirstChild(theProject->instrInfo); while (pi) { if (pi->GetType() == PRJNODE_INSTR) { InstrItem *ii = (InstrItem *) pi; ic = ii->GetConfig(); if (ic && ic->inum < 16384 && ic->inum >= inum) inum = ic->inum+1; } pi = prjTree->NextSibling(pi); } // check against library values... while ((ic = theProject->mgr.FindInstr(inum)) != 0) inum++; return inum; }
void MainWindow::on_treeView_customContextMenuRequested(const QPoint &pt) { QPoint globalPt = ui->treeView->mapToGlobal(pt); QModelIndex index = ui->treeView->indexAt(pt); QMenu menu; if (index.isValid()) { on_treeView_clicked(index); ProjectItem* item = (ProjectItem*) Workspace::Instance.GetProjectsModel()->itemFromIndex(index); switchToAct->setEnabled(!item->IsSelected()); menu.addAction(switchToAct); if(!item->IsDocument()) { menu.addAction(addImageAct); menu.addSeparator(); menu.addAction(saveProjctAct); menu.addAction(closeProjectAct); menu.addSeparator(); } else { menu.addAction(removeImageAct); menu.addSeparator(); } } menu.addAction(newProjectAct); menu.addAction(openProjectAct); menu.addSeparator(); menu.addAction(saveAllAct); menu.addAction(closeAllAct); menu.exec(globalPt); }
void MainWindow::on_actionClose_Project_triggered() { if (Workspace::Instance.GetCurrentProject() == nullptr) return; bool cancel = false; if (!Workspace::Instance.IsCurrentProjectPersistent()) { QMessageBox msgBox; msgBox.setWindowTitle(QString("Pitanje")); msgBox.setText(QString("Želite li da sačuvate promene?")); msgBox.setIcon(QMessageBox::Question); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Yes); int ret = msgBox.exec(); if (ret == QMessageBox::Yes) { Workspace::Instance.SaveCurrentProject(); } else if (ret == QMessageBox::Cancel) { cancel = true; } } if (!cancel) { Workspace::Instance.CloseCurrentProject(); QModelIndex index = ui->treeView->currentIndex(); if (index.isValid()) { ProjectItem* item = (ProjectItem*) Workspace::Instance.GetProjectsModel()->itemFromIndex(index); if (item->IsDocument()) { ProjectItem* parent = (ProjectItem*) item->parent(); Workspace::Instance.SetCurrent(parent->GetName(), item->GetName()); } else { Workspace::Instance.SetCurrent(item->GetName()); } } RefreshImage(); } }
void MainWindow::on_actionRemove_Image_triggered() { Workspace::Instance.RemoveCurrentDocument(); QModelIndex index = ui->treeView->currentIndex(); if (index.isValid()) { ProjectItem* item = (ProjectItem*) Workspace::Instance.GetProjectsModel()->itemFromIndex(index); if (item->IsDocument()) { ProjectItem* parent = (ProjectItem*) item->parent(); Workspace::Instance.SetCurrent(parent->GetName(), item->GetName()); } else { Workspace::Instance.SetCurrent(item->GetName()); } } RefreshImage(); }
void ProjectFrame::CopyItem() { ProjectItem *itm = prjTree->GetSelectedNode(); if (itm) itm->CopyItem(); }
QString Report::generateReportContent(TreeModel * model) { QString header = "<html><head><style type=\"text/css\"> TABLE.MYTABLE { font-family:arial; font-size:10pt; width:500px; border-style:double; border-color:black; border-width:1px; } TH.MYTABLE { font-size:10pt; background-color:#FFFFFF; color:black; border-width:1px; } TR.MYTABLE { } TD.MYTABLE { font-size:10pt; background-color:#FFFFFF; color:black; border-style:solid; border-width:1px; text-align:center; } TD.MYTABLEGREEN { font-size:10pt; background-color:#00EB4E; color:black; border-style:solid; border-width:1px; text-align:center; } TD.MYTABLERED { font-size:10pt; background-color:#FF0033; color:black; border-style:solid; border-width:1px; text-align:center; }</style></head><body><center> <TABLE border=\"0\"><tr><td><TABLE CLASS=\"MYTABLE\"> <THEAD> <TR CLASS=\"MYTABLE\"> <TH CLASS=\"MYTABLE\">Project name</TH> <TH CLASS=\"MYTABLE\">Suite name</TH> <TH CLASS=\"MYTABLE\">Test Case name</TH> <TH CLASS=\"MYTABLE\">Status</TH> </TR> </THEAD> <TBODY>"; QString table_footer = "</TBODY></TABLE>"; QString footer = "</center></body>"; QString td_start = "<TD CLASS=\"MYTABLE\">"; QString td_start_green = "<TD CLASS=\"MYTABLEGREEN\">"; QString td_start_red = "<TD CLASS=\"MYTABLERED\">"; QString td_end = "</TD>"; QString tr_start = "<TR CLASS=\"MYTABLE\">"; QString tr_end = "</TR>"; QString src; int total_pass = 0; int total_fail = 0; int total_norun = 0; ProjectItem * proj; SuiteItem * suite; TestCaseItem * test; src += header; for(int i = 0; i < model->rowCount(); i++) { QModelIndex child = model->index(i,0); proj = static_cast<ProjectItem *>(child.internalPointer()); for(int j = 0; j < proj->childCount(); j++) { suite = static_cast<SuiteItem *>(proj->child(j)); for(int k = 0; k < suite->childCount(); k++) { test = static_cast<TestCaseItem *>(suite->child(k)); src += tr_start; src += td_start + QString("%1").arg(proj->getItemName()) + td_end; src += td_start + QString("%1").arg(suite->getItemName()) + td_end; src += td_start + QString("%1").arg(test->getItemName()) + td_end; if(test->getStatus() == TestCaseStatus::Passed) { src += td_start_green + QString("PASS<br>") + td_end; total_pass++; } else if(test->getStatus() == TestCaseStatus::Failed) { src += td_start_red + QString("FAIL<br>") + td_end; total_fail++; } else { src += td_start + QString("No run<br>") + td_end; total_norun++; } src += tr_end; } } } src += table_footer; src += "</td></tr><tr><td><br>"; src += "PASS: "******"%1").arg(total_pass) + "<br>FAIL: " + QString("%1").arg(total_fail) + "<br>No run: " + QString("%1").arg(total_norun) + "<br>"; src += "<br>Report generated on " + QDate::currentDate().toString("d MMMM yyyy") + " at " + QTime::currentTime().toString(); src += "</td></tr></table>"; src += footer; return src; }
// void ProcessChain::compile( ProcessOptions * options ) void ProcessChain::compile() { // If the micro id in the options is empty, then attempt to get it from any // open project (it might not be necessarily...but won't hurt if it isn't). if ( m_processOptions.m_picID.isEmpty() ) { if ( ProjectInfo * projectInfo = ProjectManager::self()->currentProject() ) { ProjectItem * projectItem = projectInfo->findItem( m_processOptions.inputFiles().first() ); if (projectItem) m_processOptions.m_picID = projectItem->microID(); } } switch ( m_processOptions.processPath() ) { #define DIRECT_PROCESS( path, processor ) \ case ProcessOptions::ProcessPath::path: \ { \ processor()->processInput(m_processOptions); break; \ } #define INDIRECT_PROCESS( path, processor, extension ) \ case ProcessOptions::ProcessPath::path: \ { \ KTemporaryFile f; \ f.setSuffix( extension ); \ f.open(); \ f.close(); \ m_processOptions.setIntermediaryOutput( f.fileName() ); \ processor()->processInput(m_processOptions); \ break; \ } INDIRECT_PROCESS( AssemblyAbsolute_PIC, gpasm, ".hex" ) DIRECT_PROCESS( AssemblyAbsolute_Program, gpasm ) INDIRECT_PROCESS( AssemblyRelocatable_Library, gpasm, ".o" ) DIRECT_PROCESS( AssemblyRelocatable_Object, gpasm ) INDIRECT_PROCESS( AssemblyRelocatable_PIC, gpasm, ".o" ) INDIRECT_PROCESS( AssemblyRelocatable_Program, gpasm, ".o" ) DIRECT_PROCESS( C_AssemblyRelocatable, sdcc ) INDIRECT_PROCESS( C_Library, sdcc, ".asm" ) INDIRECT_PROCESS( C_Object, sdcc, ".asm" ) INDIRECT_PROCESS( C_PIC, sdcc, ".asm" ) INDIRECT_PROCESS( C_Program, sdcc, ".asm" ) INDIRECT_PROCESS( FlowCode_AssemblyAbsolute, flowCode, ".microbe" ) DIRECT_PROCESS( FlowCode_Microbe, flowCode ) INDIRECT_PROCESS( FlowCode_PIC, flowCode, ".microbe" ) INDIRECT_PROCESS( FlowCode_Program, flowCode, ".microbe" ) DIRECT_PROCESS( Microbe_AssemblyAbsolute, microbe ) INDIRECT_PROCESS( Microbe_PIC, microbe, ".asm" ) INDIRECT_PROCESS( Microbe_Program, microbe, ".asm" ) DIRECT_PROCESS( Object_Disassembly, gpdasm ) DIRECT_PROCESS( Object_Library, gplib ) INDIRECT_PROCESS( Object_PIC, gplink, ".lib" ) DIRECT_PROCESS( Object_Program, gplink ) DIRECT_PROCESS( PIC_AssemblyAbsolute, picProgrammer ) DIRECT_PROCESS( Program_Disassembly, gpdasm ) DIRECT_PROCESS( Program_PIC, picProgrammer ) #undef DIRECT_PROCESS #undef INDIRECT_PROCESS case ProcessOptions::ProcessPath::Invalid: kWarning() << k_funcinfo << "Process path is invalid" << endl; case ProcessOptions::ProcessPath::None: kWarning() << k_funcinfo << "Nothing to do" << endl; break; } }
void Workspace::AddProject(QString& projectFullPath, bool load) { QFileInfo projectFileInfo(projectFullPath); // Extract project name from path. QString projectNameQ = projectFileInfo.fileName().remove(".ndtr"); std::string projectName = Utils::StringQ2W(projectNameQ); // If not exists, create dir to store images. QDir projectDir = projectFileInfo.absoluteDir(); // Create dir if not exist. if (!projectDir.exists(projectNameQ)) { projectDir.mkdir(projectNameQ); } projectDir.cd(projectNameQ); // There can't be more projects with same name. if (m_Projects.count(projectName)) { // "Project with the same name is already loaded." throw std::exception(); } // Initialize project. m_Projects[projectName] = unique_ptr<Project>(new Project()); m_ProjectsPersistentState[projectName] = true; // loaded or saved Project* project = m_Projects[projectName].get(); project->Init(projectName, projectFullPath.toStdString(), projectDir.absolutePath().toStdString()); // Load/Save project. if (load) { // If exists load project from file. if(!ProjectParser::Load(project)) { // "Failed to load project file." throw std::exception(); } } else { // Save project file. Serialize as XML. if (!ProjectParser::Save(project)) { // "Failed to save project file." throw std::exception(); } } // TODO: Move to method. Add images to view. // Add project to project model view. QStandardItem* rootItem = m_ProjectsModel.invisibleRootItem(); ProjectItem* projectItem = new ProjectItem(projectName); QList<QStandardItem*> projectItems; projectItems << projectItem; rootItem->appendRow(projectItems); for (Document* doc : project->GetDocuments()) { auto projRowItem = m_ProjectsModel.findItems(Utils::StringW2Q(projectName)); ProjectItem* projectItem = (ProjectItem*) projRowItem.first(); ProjectItem* docItem = new ProjectItem(doc->GetName(), true); QList<QStandardItem*> docRowItem; docRowItem << docItem; projectItem->appendRow(docItem); } // Set new project as current project. SetCurrent(projectName); }