/** Allows to open attachment item using default application registerd for given document type in the OS. */ void Open() const { const QString title(tr("Open attachment...")); TFileAttachmentWidget* owner = GetOwner(); QString fileName(GetDisplayedFileName()); /// FIXME - actually each created temp file should be registered in the main app to be deleted at exit. QTemporaryFile tempFile(QDir::tempPath() + "/XXXXXX." + fileName); tempFile.setAutoRemove(false); if(tempFile.open() == false) { QMessageBox::warning(owner, title, tr("Cannot open temporary file to store attachment: ") + fileName); return; } QFileInfo tfi(tempFile); if(owner->SaveAttachmentItem(this, tfi, false)) { QUrl url(QUrl::fromLocalFile(tfi.absoluteFilePath())); if(QDesktopServices::openUrl(url) == false) { /// Report a message if opening failed. QMessageBox::warning(owner, title, tr("Cannot open attachment using its default application: ") + fileName); } } tempFile.close(); }
void MBUfactHandler::filterCallsiteFacts(PExprCall& dc, DFAfact& df, DFAfact& df_local) { MBUfact& mbf = (MBUfact&) df; MBUfact& mbf_local = (MBUfact&) df_local; //- 1. move all facts to mbf_local mbf_local.meet(mbf, false); //- 2. filter GREF elements back into mbf //TODO: filter also MayFreed pointers? suco_iterator<CFGfunction *> tfi(dc.getTargetFns()); while(tfi.Iterate()){ suco_iterator<AO *> aoi(mbf_local.aoset); while(aoi.Iterate()){ AO * tao = aoi.Current(); if(tfi.Current()->getGREF().Contains(*tao)){ aoi.DeleteCurrent(); mbf.aoset.Insert(tao); } } } //- 3. specially handle call arguments // for(int i = 1; dc.getArg(i); ++i) // mbf_local.filterInto(dc.getArg(i)->getDesc().getAOs(), mbf); //TODO: migrate to interProcHandleCallArgs below }
//- filter out GMOD, then cache local fact! void RDAfactHandler::filterCallsiteFacts(PExprCall& dc, DFAfact& df, DFAfact& df_local) { RDAfact& rdf = (RDAfact&) df; RDAfact& rdf_local = (RDAfact&) df_local; //- 1. move all facts to rdf_local rdf_local.meet(rdf, false); //- 2. filter GMOD elements back into rdf suco_iterator<CFGfunction *> tfi(dc.getTargetFns()); while(tfi.Iterate()) rdf_local.filterGmodInto(*tfi.Current(), rdf); //- 3. specially handle call arguments? --no need for RDA //- 4. cache local set dc.getRDAlocal().meet(rdf_local); }
void CmdRaytracingNewLuxProject::activated(int iMsg) { const char* ppReturn=0; Gui::Application::Instance->sendMsgToActiveView("GetCamera",&ppReturn); if (ppReturn) { std::string str(ppReturn); if (str.find("PerspectiveCamera") == std::string::npos) { int ret = QMessageBox::warning(Gui::getMainWindow(), qApp->translate("CmdRaytracingWriteView","No perspective camera"), qApp->translate("CmdRaytracingWriteView","The current view camera is not perspective" " and thus the result of the luxrender image later might look different to" " what you expect.\nDo you want to continue?"), QMessageBox::Yes|QMessageBox::No); if (ret != QMessageBox::Yes) return; } } std::string FeatName = getUniqueObjectName("LuxProject"); Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(getAction()); QAction* a = pcAction->actions()[iMsg]; QFileInfo tfi(a->property("Template").toString()); if (tfi.isReadable()) { try { openCommand("Create LuxRender project"); doCommand(Doc,"import Raytracing,RaytracingGui"); doCommand(Doc,"App.activeDocument().addObject('Raytracing::LuxProject','%s')",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Template = '%s'",FeatName.c_str(), (const char*)tfi.filePath().toUtf8()); doCommand(Doc,"App.activeDocument().%s.Camera = RaytracingGui.luxViewCamera()",FeatName.c_str()); commitCommand(); } catch (...) { abortCommand(); throw; } } else { QMessageBox::critical(Gui::getMainWindow(), qApp->translate("CmdRaytracingNewLuxProject","No template"), qApp->translate("CmdRaytracingNewLuxProject","No template available")); } }
void StrainPipeData::init() { QFileInfo recipefi(directory.absoluteFilePath() + "/logdir/1.RECIPEFILE"); recipefi.exists() ? recipie.reset(new RecipieList(recipefi)) : recipie.reset(new RecipieList()); base_dir.setNameFilters(QStringList("metric_*quast.csv")); QFileInfoList quastFiles=base_dir.entryInfoList(); quastFiles.empty() ? questMetrics.reset(new QuastMetrics()) : questMetrics.reset(new QuastMetrics(quastFiles.first())); base_dir.setNameFilters(QStringList("metric_*cgal.csv")); QFileInfoList cgalFiles = base_dir.entryInfoList(); cgalFiles.empty() ? cgalMetrics.reset(new CgalMetrics()) : cgalMetrics.reset(new CgalMetrics(cgalFiles.first())); base_dir.setNameFilters(QStringList("metric_*ale.csv")); QFileInfoList aleFiles=base_dir.entryInfoList(); aleFiles.empty() ? aleMetrics.reset(new AleMetrics()) : aleMetrics.reset(new AleMetrics(aleFiles.first())); QString timesFilename = base_dir.absolutePath() + "/logdir/1stats/allstats.csv"; QFileInfo tfi(timesFilename); tfi.exists() ? runTimes.reset(new RunTimes(tfi , base_dir.dirName() , directory.absolutePath())) : runTimes.reset(new RunTimes()); // register the plot document object (only needed once, no matter how many // plots will be in the QTextDocument): QCPDocumentObject *plotObjectHandler = new QCPDocumentObject(); QTextDocument::documentLayout()-> registerHandler(QCPDocumentObject::PlotTextFormat, plotObjectHandler); }
void UmlArtifact::gen_app(const Q3CString & path) { Q3CString target; Q3CString pro; propertyValue("genpro target", target); propertyValue("genpro pro", pro); if (target.isEmpty()) { if ((target = name()) == "executable") target = UmlPackage::getProject()->name(); #ifdef WIN32 target += ".exe"; #endif } if (pro.isEmpty()) { pro = target; #ifdef WIN32 if (pro.right(4) == ".exe") pro.resize(pro.length() - 4); #endif QDir d(path); pro = d.absFilePath(pro + ".pro"); } Q3CString tmplt; Q3CString config; Q3CString defines; Q3CString includepath; Q3CString dependpath; Q3CString objectsdir; Q3CString footer; if (!propertyValue("genpro tmplt", tmplt)) tmplt = "app"; if (!propertyValue("genpro config", config)) config = "debug warn_on qt"; if (!propertyValue("genpro defines", defines)) defines = "WITHCPP WITHJAVA WITHPHP WITHPYTHON WITHIDL"; else if (defines.find("WITHPHP") == -1) { int n = 0; if (defines.find("WITHCPP") != -1) n += 1; if (defines.find("WITHJAVA") != -1) n += 1; if (defines.find("WITHIDL") != -1) n += 1; if (n > 1) defines += " WITHPHP WITHPYTHON"; } else if (defines.find("WITHPYTHON") == -1) { int n = 0; if (defines.find("WITHCPP") != -1) n += 1; if (defines.find("WITHJAVA") != -1) n += 1; if (defines.find("WITHIDL") != -1) n += 1; if (defines.find("WITHPHP") != -1) n += 1; if (n > 1) defines += " WITHPYTHON"; } propertyValue("genpro includepath", includepath); propertyValue("genpro dependpath", dependpath); propertyValue("genpro objectsdir", objectsdir); propertyValue("genpro footer", footer); for (;;) { Dialog dialog(this, path, pro, target, tmplt, config, defines, includepath, dependpath, objectsdir, footer); if (dialog.exec() != QDialog::Accepted) return; set_PropertyValue("genpro pro", pro); set_PropertyValue("genpro path", path); set_PropertyValue("genpro target", target); set_PropertyValue("genpro tmplt", tmplt); set_PropertyValue("genpro config", config); set_PropertyValue("genpro defines", defines); set_PropertyValue("genpro includepath", includepath); set_PropertyValue("genpro dependpath", dependpath); set_PropertyValue("genpro objectsdir", objectsdir); set_PropertyValue("genpro footer", footer); QFile f(pro); if (! f.open(QIODevice::WriteOnly)) QMessageBox::critical((QWidget *) 0, "Error", "Cannot open " + QString(pro)); else { Q3TextStream t(&f); QFileInfo tfi(target); QFileInfo pfi(pro); t << "TEMPLATE\t= " << tmplt << '\n'; t << "TARGET\t\t= " << tfi.fileName() << '\n'; if ((target.find('/') != -1) && (pro.find('/') != -1) && (tfi.dirPath(TRUE) != pfi.dirPath(TRUE))) t << "DESTDIR\t\t= " << tfi.dirPath(TRUE) << '\n'; if (! objectsdir.isEmpty()) t << "OBJECTS_DIR\t= " << objectsdir << '\n'; t << "CONFIG\t\t+= " << config << '\n'; if (!includepath.isEmpty()) t << "INCLUDEPATH\t= " << includepath << '\n'; if (!dependpath.isEmpty()) t << "DEPENDPATH\t= " << dependpath << '\n'; if (!defines.isEmpty()) t << "DEFINES\t\t= " << defines << '\n'; QString prodir = pfi.dirPath(TRUE); const Q3PtrVector<UmlArtifact> & arts = associatedArtifacts(); unsigned index; const char * sep; Q3CString ext; ext = CppSettings::headerExtension(); sep = "HEADERS\t\t= "; for (index = 0; index != arts.count(); index += 1) { UmlArtifact * art = arts[index]; if ((art->stereotype() == "source") && !art->cppHeader().isEmpty()) { QString s = art->way(prodir, TRUE); if (! s.isEmpty()) { t << sep << s << art->name() << '.' << ext; sep = " \\\n\t\t "; } } } t << '\n'; ext = CppSettings::sourceExtension(); sep = "SOURCES\t\t= "; for (index = 0; index != arts.count(); index += 1) { UmlArtifact * art = arts[index]; if ((art->stereotype() != "source") || !art->cppSource().isEmpty()) { QString s = art->way(prodir, FALSE); if (! s.isEmpty()) { t << sep << s << art->name(); if (art->stereotype() == "source") t << '.' << ext; sep = " \\\n\t\t "; } } } t << '\n' << footer << '\n'; f.close(); return; } } }