void LLPanelMainInventory::onCustomAction(const LLSD& userdata) { if (!isActionEnabled(userdata)) return; const std::string command_name = userdata.asString(); if (command_name == "new_window") { newWindow(); } if (command_name == "sort_by_name") { const LLSD arg = "name"; setSortBy(arg); } if (command_name == "sort_by_recent") { const LLSD arg = "date"; setSortBy(arg); } if (command_name == "show_filters") { toggleFindOptions(); } if (command_name == "reset_filters") { resetFilters(); } if (command_name == "close_folders") { closeAllFolders(); } if (command_name == "empty_trash") { const std::string notification = "ConfirmEmptyTrash"; gInventory.emptyFolderType(notification, LLFolderType::FT_TRASH); } if (command_name == "empty_lostnfound") { const std::string notification = "ConfirmEmptyLostAndFound"; gInventory.emptyFolderType(notification, LLFolderType::FT_LOST_AND_FOUND); } if (command_name == "save_texture") { saveTexture(userdata); } // This doesn't currently work, since the viewer can't change an assetID an item. if (command_name == "regenerate_link") { LLInventoryPanel *active_panel = getActivePanel(); LLFolderViewItem* current_item = active_panel->getRootFolder()->getCurSelectedItem(); if (!current_item) { return; } const LLUUID item_id = current_item->getListener()->getUUID(); LLViewerInventoryItem *item = gInventory.getItem(item_id); if (item) { item->regenerateLink(); } active_panel->setSelection(item_id, TAKE_FOCUS_NO); } if (command_name == "find_original") { LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); if (!current_item) { return; } current_item->getListener()->performAction(getActivePanel()->getModel(), "goto"); } if (command_name == "find_links") { LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); if (!current_item) { return; } const LLUUID& item_id = current_item->getListener()->getUUID(); const std::string &item_name = current_item->getListener()->getName(); mFilterSubString = item_name; LLInventoryFilter *filter = mActivePanel->getFilter(); filter->setFilterSubString(item_name); mFilterEditor->setText(item_name); mFilterEditor->setFocus(TRUE); filter->setFilterUUID(item_id); filter->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); filter->setFilterLinks(LLInventoryFilter::FILTERLINK_ONLY_LINKS); } }
FileSystemWidget::FileSystemWidget(LiteApi::IApplication *app, QWidget *parent) : QWidget(parent), m_liteApp(app) { m_tree = new SymbolTreeView; m_tree->setHeaderHidden(true); #if QT_VERSION >= 0x050000 m_tree->header()->setSectionResizeMode(QHeaderView::ResizeToContents); #else m_tree->header()->setResizeMode(QHeaderView::ResizeToContents); #endif m_tree->header()->setStretchLastSection(false); m_model = new FileSystemModel(this); QDir::Filters filters = QDir::AllDirs | QDir::Files | QDir::Drives | QDir::Readable| QDir::Writable | QDir::Executable/* | QDir::Hidden*/ | QDir::NoDotAndDotDot; #ifdef Q_OS_WIN // Symlinked directories can cause file watcher warnings on Win32. filters |= QDir::NoSymLinks; #endif m_model->setFilter(filters); m_tree->setContextMenuPolicy(Qt::CustomContextMenu); m_tree->setModel(m_model); QVBoxLayout *layout = new QVBoxLayout; layout->setMargin(0); layout->addWidget(m_tree); this->setLayout(layout); connect(m_tree,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(openPathIndex(QModelIndex))); connect(m_liteApp->editorManager(),SIGNAL(currentEditorChanged(LiteApi::IEditor*)),this,SLOT(currentEditorChanged(LiteApi::IEditor*))); m_fileMenu = new QMenu(this); m_folderMenu = new QMenu(this); m_rootMenu = new QMenu(this); m_openEditorAct = new QAction(tr("Open File"),this); m_newFileAct = new QAction(tr("New File..."),this); m_newFileWizardAct = new QAction(tr("New File Wizard..."),this); m_renameFileAct = new QAction(tr("Rename File..."),this); m_removeFileAct = new QAction(tr("Delete File"),this); m_newFolderAct = new QAction(tr("New Folder..."),this); m_renameFolderAct = new QAction(tr("Rename Folder..."),this); m_removeFolderAct = new QAction(tr("Delete Folder"),this); m_openShellAct = new QAction(tr("Open Terminal Here"),this); m_openExplorerAct = new QAction(tr("Open Explorer Here"),this); m_viewGodocAct = new QAction(tr("View Godoc Here"),this); m_addFolderAct = new QAction(tr("Add Folder..."),this); m_closeFolerAct = new QAction(tr("Close Folder"),this); m_closeAllFoldersAct = new QAction(tr("Close All Folders"),this); m_fileMenu->addAction(m_openEditorAct); m_fileMenu->addSeparator(); m_fileMenu->addAction(m_newFileAct); m_fileMenu->addAction(m_newFileWizardAct); m_fileMenu->addAction(m_renameFileAct); m_fileMenu->addAction(m_removeFileAct); m_fileMenu->addSeparator(); m_fileMenu->addAction(m_viewGodocAct); m_fileMenu->addSeparator(); m_fileMenu->addAction(m_openShellAct); m_fileMenu->addAction(m_openExplorerAct); m_folderMenu->addAction(m_newFileAct); m_folderMenu->addAction(m_newFileWizardAct); m_folderMenu->addAction(m_newFolderAct); m_folderMenu->addAction(m_renameFolderAct); m_folderMenu->addAction(m_removeFolderAct); m_folderMenu->addSeparator(); m_folderMenu->addAction(m_closeFolerAct); m_folderMenu->addSeparator(); m_folderMenu->addAction(m_viewGodocAct); m_folderMenu->addSeparator(); m_folderMenu->addAction(m_openShellAct); m_folderMenu->addAction(m_openExplorerAct); m_rootMenu->addAction(m_addFolderAct); m_rootMenu->addSeparator(); //m_rootMenu->addAction(m_closeAllFoldersAct); connect(m_model->fileWatcher(),SIGNAL(directoryChanged(QString)),this,SLOT(directoryChanged(QString))); connect(m_openEditorAct,SIGNAL(triggered()),this,SLOT(openEditor())); connect(m_newFileAct,SIGNAL(triggered()),this,SLOT(newFile())); connect(m_newFileWizardAct,SIGNAL(triggered()),this,SLOT(newFileWizard())); connect(m_renameFileAct,SIGNAL(triggered()),this,SLOT(renameFile())); connect(m_removeFileAct,SIGNAL(triggered()),this,SLOT(removeFile())); connect(m_newFolderAct,SIGNAL(triggered()),this,SLOT(newFolder())); connect(m_renameFolderAct,SIGNAL(triggered()),this,SLOT(renameFolder())); connect(m_removeFolderAct,SIGNAL(triggered()),this,SLOT(removeFolder())); connect(m_openShellAct,SIGNAL(triggered()),this,SLOT(openShell())); connect(m_openExplorerAct,SIGNAL(triggered()),this,SLOT(openExplorer())); connect(m_viewGodocAct,SIGNAL(triggered()),this,SLOT(viewGodoc())); connect(m_addFolderAct,SIGNAL(triggered()),this,SLOT(addFolder())); connect(m_closeFolerAct,SIGNAL(triggered()),this,SLOT(closeFolder())); connect(m_closeAllFoldersAct,SIGNAL(triggered()),this,SLOT(closeAllFolders())); connect(m_tree,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(treeViewContextMenuRequested(QPoint))); }