void InstallComponentsOperation::execute() { QFileDialog fileDialog(m_serviceLocator->locate<QMainWindow>(), "Install component"); fileDialog.setFileMode(QFileDialog::ExistingFiles); fileDialog.setNameFilter("Components (*.definition)"); // TODO: get from the app settings fileDialog.setDirectory(QCoreApplication::applicationDirPath() + "/externalSource"); // TODO: get last selected directory from settings if (!fileDialog.exec()) return; QFileInfo selectedFile(fileDialog.selectedFiles().first()); InstallComponentsCommand* command = m_serviceLocator->buildInstance<InstallComponentsCommand>(); command->setSourceDirectoryPath(selectedFile.absolutePath()); for (const QString &fileName : fileDialog.selectedFiles()) command->addDefinitionPath(fileName); command->pushToStack(); }
//最后修改时间 2015/2/22 21:50 void chanFileSystemDockWidget::updateActions(QTreeWidgetItem* item) { //默认选中的是文件夹 bool isFilesActionsVisible = false; bool isFoldersActionsVisible = true; //如果选择的是文件 if ((item->data(0, ITEM_TYPE_KEY).toInt() == File)) { isFilesActionsVisible = true; isFoldersActionsVisible = false; emit selectedFile((item->data(0, FILE_NAME_KEY).toString())); } std::for_each(m_actionArray, m_actionArray + CreateFile, [&](QAction* item) { item->setVisible(isFilesActionsVisible); }); std::for_each(m_actionArray + CreateFile, m_actionArray + actionArraySize, [&](QAction* item) { item->setVisible(isFoldersActionsVisible); }); }
void RKImportDialog::accept () { RK_TRACE (DIALOGS); KFileDialog::accept (); int index = format_selector->combo->currentIndex (); QString cid = component_ids[index]; RKComponentHandle *handle = RKComponentMap::getComponentHandle (cid); RKContextHandler *chandler = context->makeContextHandler (this, false); if (!(handle && chandler)) { RK_ASSERT (false); } else { RKComponentPropertyBase *filename = new RKComponentPropertyBase (chandler, false); filename->setValue (selectedFile ()); chandler->addChild ("filename", filename); chandler->invokeComponent (handle); } deleteLater (); }
void CustomFDialog::handleCompress() { QFileInfo tmp; tmp.setFile(selectedFile()); QString e(tmp.completeSuffix()); QStringList ex = e.split(".", QString::SkipEmptyParts); QString baseExt = ""; for (int a = 0; a < ex.count(); a++) { if ((ex[a] != "sla") && (ex[a] != "SLA") && (ex[a] != "gz") && (ex[a] != "GZ")) baseExt += "."+ex[a]; } if (SaveZip->isChecked()) { if (e != extZip) tmp.setFile(tmp.baseName() + baseExt + "." + extZip); } else { if (e != ext) tmp.setFile(tmp.baseName() + baseExt + "." + ext); } setSelection(tmp.fileName()); }
void CRepositoryBrowser::ShowContextMenu(CPoint point, TShadowFilesTreeList &selectedLeafs, eSelectionType selType) { CIconMenu popupMenu; popupMenu.CreatePopupMenu(); bool bAddSeparator = false; if (selectedLeafs.size() == 1) { popupMenu.AppendMenuIcon(eCmd_Open, IDS_REPOBROWSE_OPEN, IDI_OPEN); popupMenu.SetDefaultItem(eCmd_Open, FALSE); if (selType == ONLY_FILES || selType == ONLY_FILESSUBMODULES) { popupMenu.AppendMenuIcon(eCmd_OpenWith, IDS_LOG_POPUP_OPENWITH, IDI_OPEN); popupMenu.AppendMenuIcon(eCmd_OpenWithAlternativeEditor, IDS_LOG_POPUP_VIEWREV); } popupMenu.AppendMenu(MF_SEPARATOR); if (m_bHasWC && (selType == ONLY_FILES || selType == ONLY_FILESSUBMODULES)) { popupMenu.AppendMenuIcon(eCmd_CompareWC, IDS_LOG_POPUP_COMPARE, IDI_DIFF); bAddSeparator = true; } if (bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; CString temp; temp.LoadString(IDS_MENULOG); popupMenu.AppendMenuIcon(eCmd_ViewLog, temp, IDI_LOG); if (selectedLeafs[0]->m_bSubmodule) { temp.LoadString(IDS_MENULOGSUBMODULE); popupMenu.AppendMenuIcon(eCmd_ViewLogSubmodule, temp, IDI_LOG); } if (selType == ONLY_FILES) { if (m_bHasWC) popupMenu.AppendMenuIcon(eCmd_Blame, IDS_LOG_POPUP_BLAME, IDI_BLAME); popupMenu.AppendMenu(MF_SEPARATOR); temp.LoadString(IDS_LOG_POPUP_SAVE); popupMenu.AppendMenuIcon(eCmd_SaveAs, temp, IDI_SAVEAS); } bAddSeparator = true; } if (!selectedLeafs.empty() && selType == ONLY_FILES && m_bHasWC) { popupMenu.AppendMenuIcon(eCmd_Revert, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT); bAddSeparator = true; } if (bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; if (selectedLeafs.size() == 1 && selType == ONLY_FILES) { popupMenu.AppendMenuIcon(eCmd_PrepareDiff, IDS_PREPAREDIFF, IDI_DIFF); if (!m_sMarkForDiffFilename.IsEmpty()) { CString diffWith; if (selectedLeafs.at(0)->GetFullName() == m_sMarkForDiffFilename) diffWith = m_sMarkForDiffVersion; else { PathCompactPathEx(diffWith.GetBuffer(40), m_sMarkForDiffFilename, 39, 0); diffWith.ReleaseBuffer(); diffWith += _T(":") + m_sMarkForDiffVersion.ToString().Left(g_Git.GetShortHASHLength()); } CString menuEntry; menuEntry.Format(IDS_MENUDIFFNOW, (LPCTSTR)diffWith); popupMenu.AppendMenuIcon(eCmd_PrepareDiff_Compare, menuEntry, IDI_DIFF); } popupMenu.AppendMenu(MF_SEPARATOR); } if (!selectedLeafs.empty()) { popupMenu.AppendMenuIcon(eCmd_CopyPath, IDS_STATUSLIST_CONTEXT_COPY, IDI_COPYCLIP); popupMenu.AppendMenuIcon(eCmd_CopyHash, IDS_COPY_COMMIT_HASH, IDI_COPYCLIP); } eCmd cmd = (eCmd)popupMenu.TrackPopupMenuEx(TPM_LEFTALIGN|TPM_RETURNCMD, point.x, point.y, this, 0); switch(cmd) { case eCmd_ViewLog: case eCmd_ViewLogSubmodule: { CString sCmd; sCmd.Format(_T("/command:log /path:\"%s\\%s\""), (LPCTSTR)g_Git.m_CurrentDir, (LPCTSTR)selectedLeafs.at(0)->GetFullName()); if (cmd == eCmd_ViewLog && selectedLeafs.at(0)->m_bSubmodule) sCmd += _T(" /submodule"); CAppUtils::RunTortoiseGitProc(sCmd); } break; case eCmd_Blame: { CAppUtils::LaunchTortoiseBlame(g_Git.CombinePath(selectedLeafs.at(0)->GetFullName()), m_sRevision); } break; case eCmd_Open: if (!selectedLeafs.at(0)->m_bSubmodule && selectedLeafs.at(0)->m_bFolder) { FillListCtrlForTreeNode(selectedLeafs.at(0)->m_hTree); m_RepoTree.SelectItem(selectedLeafs.at(0)->m_hTree); return; } OpenFile(selectedLeafs.at(0)->GetFullName(), OPEN, selectedLeafs.at(0)->m_bSubmodule, selectedLeafs.at(0)->m_hash); break; case eCmd_OpenWith: OpenFile(selectedLeafs.at(0)->GetFullName(), OPEN_WITH, selectedLeafs.at(0)->m_bSubmodule, selectedLeafs.at(0)->m_hash); break; case eCmd_OpenWithAlternativeEditor: OpenFile(selectedLeafs.at(0)->GetFullName(), ALTERNATIVEEDITOR, selectedLeafs.at(0)->m_bSubmodule, selectedLeafs.at(0)->m_hash); break; case eCmd_CompareWC: { CTGitPath file(selectedLeafs.at(0)->GetFullName()); CGitDiff::Diff(&file, &file, GIT_REV_ZERO, m_sRevision); } break; case eCmd_Revert: { int count = 0; for (TShadowFilesTreeList::iterator itShadowTree = selectedLeafs.begin(); itShadowTree != selectedLeafs.end(); ++itShadowTree) { if (RevertItemToVersion((*itShadowTree)->GetFullName())) ++count; else break; } CString msg; msg.Format(IDS_STATUSLIST_FILESREVERTED, count, (LPCTSTR)m_sRevision); MessageBox(msg, _T("TortoiseGit"), MB_OK); } break; case eCmd_SaveAs: FileSaveAs(selectedLeafs.at(0)->GetFullName()); break; case eCmd_CopyPath: { CString sClipboard; for (TShadowFilesTreeList::iterator itShadowTree = selectedLeafs.begin(); itShadowTree != selectedLeafs.end(); ++itShadowTree) { sClipboard += (*itShadowTree)->m_sName + _T("\r\n"); } CStringUtils::WriteAsciiStringToClipboard(sClipboard); } break; case eCmd_CopyHash: { CopyHashToClipboard(selectedLeafs); } break; case eCmd_PrepareDiff: m_sMarkForDiffFilename = selectedLeafs.at(0)->GetFullName(); if (g_Git.GetHash(m_sMarkForDiffVersion, m_sRevision)) { m_sMarkForDiffFilename.Empty(); MessageBox(g_Git.GetGitLastErr(_T("Could not get SHA-1 for ") + m_sRevision), _T("TortoiseGit"), MB_ICONERROR); } break; case eCmd_PrepareDiff_Compare: { CTGitPath savedFile(m_sMarkForDiffFilename); CTGitPath selectedFile(selectedLeafs.at(0)->GetFullName()); CGitHash currentHash; if (g_Git.GetHash(currentHash, m_sRevision)) { MessageBox(g_Git.GetGitLastErr(_T("Could not get SHA-1 for ") + m_sRevision), _T("TortoiseGit"), MB_ICONERROR); return; } CGitDiff::Diff(&selectedFile, &savedFile, currentHash, m_sMarkForDiffVersion); } break; } }
ModelPtr ModelFactory::readModel( std::string filename ) { ModelPtr m; // Check extension boost::filesystem::path selectedFile( filename ); std::string extension = selectedFile.extension().string(); // Try to parse given file BaseIO* io = 0; if(extension == ".ply") { io = new PLYIO; } else if(extension == ".pts" || extension == ".3d" || extension == ".xyz") { io = new AsciiIO; } else if (extension == ".obj") { io = new ObjIO; } else if (extension == ".las") { io = new LasIO; } else if (extension ==".dat") { io = new DatIO; } #ifdef LVR_USE_PCL else if (extension == ".pcd") { io = new PCDIO; } #endif /* LVR_USE_PCL */ else if (extension == "") { bool found_3d = false; bool found_boctree = false; // Check for supported data in directory. boost::filesystem::directory_iterator lastFile; for(boost::filesystem::directory_iterator it(filename); it != lastFile; it++ ) { boost::filesystem::path p = it->path(); // Check for 3d files if(p.extension().string() == ".3d") { // Check for naming convention "scanxxx.3d" int num = 0; if(sscanf(p.filename().string().c_str(), "scan%3d", &num)) { found_3d = true; } } // Check for .oct files if(p.extension().string() == ".oct") { // Check for naming convention "scanxxx.3d" int num = 0; if(sscanf(p.filename().string().c_str(), "scan%3d", &num)) { found_boctree = true; } } } // Check and create io if(!found_boctree && found_3d) { io = new UosIO; } else if(found_boctree && found_3d) { cout << timestamp << "Found 3d files and octrees. Loading octrees per default." << endl; io = new BoctreeIO; } else if(found_boctree && !found_3d) { io = new BoctreeIO; } else { cout << timestamp << "Given directory does not contain " << endl; } } // Return data model if( io ) { m = io->read( filename ); if(m_transform.convert) { // Convert coordinates in model PointBufferPtr points = m->m_pointCloud; size_t n_points = 0; size_t n_normals = 0; floatArr p = points->getPointArray(n_points); floatArr n = points->getPointNormalArray(n_normals); // If normals are present every point should habe one if(n_normals) { assert(n_normals == n_points); } // Convert coordinates float point[3]; float normal[3]; for(size_t i = 0; i < n_points; i++) { // Re-order and scale point coordinates point[0] = p[3 * i + m_transform.x] * m_transform.sx; point[1] = p[3 * i + m_transform.y] * m_transform.sy; point[2] = p[3 * i + m_transform.z] * m_transform.sz; p[3 * i] = point[0]; p[3 * i + 1] = point[1]; p[3 * i + 2] = point[2]; if(n_normals) { normal[0] = n[3 * i + m_transform.x] * m_transform.sx; normal[1] = n[3 * i + m_transform.y] * m_transform.sy; normal[2] = n[3 * i + m_transform.z] * m_transform.sz; n[3 * i] = normal[0]; n[3 * i + 1] = normal[1]; n[3 * i + 2] = normal[2]; } } } delete io; } return m; }
void FMPanel::openSelected() { switch( tab->currentIndex() ) { case 0://this is the directory list { QStringList list = dirList->selectedFiles(); // for some reason the first .. are never returned in the list // TODO: fix this if( list.count() == 0 ) { QDir dir(currentDir); dir.cdUp(); currentFile.clear(); currentDir.clear(); currentDir.append( dir.absolutePath() ); dirList->setRootPath( currentDir ); return; } if( list.at(0).isEmpty() || list.at(0).at(0)=='/' ) { return; } if( list.at(0).at(0)=='.' && list.at(0).at(1)=='.' ) { QDir dir(currentDir); dir.cdUp(); currentFile.clear(); currentDir.clear(); currentDir.append( dir.absolutePath() ); dirList->setRootPath( currentDir ); return; } QString selectedFile( currentDir ); selectedFile.append("/"); selectedFile.append( list.at(0) ); QFileInfo inf( selectedFile ) ; //isAbsolute() //isBundle() if( inf.isDir() ) { //mainW->startAnimation(); currentFile.clear(); //TODO check the size currentDir.clear(); currentDir.append( inf.absoluteFilePath() ); dirList->setRootPath( currentDir ); return; } if( inf.isExecutable() ) { QProcess::startDetached( inf.absoluteFilePath() ); } if( inf.isFile() ) { QString url("file:///"); url.append( inf.filePath() ); //qDebug()<<url; QDesktopServices::openUrl( url ); } currentDir.clear(); currentDir.append( inf.absolutePath() ); dirList->setRootPath( currentDir ); break; } case 1://bookmark tab { break; } case 2://found tab { break; } default: { } } }