git-svn-id: svn://db.shs.com.ru/libs@363 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "projectfilesystemplugin.h"
|
||||
#include "projectfilesystempluginconstants.h"
|
||||
#include "projectfilesystemwidget.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
@@ -7,6 +8,7 @@
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <utils/macroexpander.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QMessageBox>
|
||||
@@ -59,6 +61,9 @@ namespace ProjectFilesystemPlugin {
|
||||
|
||||
void ProjectFilesystemPluginPlugin::extensionsInitialized()
|
||||
{
|
||||
Utils::globalMacroExpander()->registerPrefix("ProjectFilesystem", "Project filesystem plugin", [](QString v) -> QString {return v;} );
|
||||
Utils::globalMacroExpander()->registerFileVariables("ProjectFilesystem", "Selected item",
|
||||
[]() -> QString { return QDir(projectfs_menu_target.absoluteFilePath()).path();});
|
||||
// Retrieve objects from the plugin manager's object pool
|
||||
// In the extensionsInitialized function, a plugin can be sure that all
|
||||
// plugins that depend on it are completely initialized.
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/session.h>
|
||||
#include <utils/utilsicons.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <QApplication>
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
@@ -23,6 +24,8 @@
|
||||
#include <QScrollBar>
|
||||
#include <QClipboard>
|
||||
|
||||
QFileInfo projectfs_menu_target;
|
||||
|
||||
|
||||
ProjectFilesystemWidget::ProjectFilesystemWidget(QWidget * parent): QWidget(parent) {
|
||||
setupUi(this);
|
||||
@@ -156,6 +159,10 @@ void ProjectFilesystemWidget::restoreExpanded(QTreeWidgetItem * ti) {
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesystemWidget::setExtVariable() {
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesystemWidget::projectsChanged() {
|
||||
last_expanded.clear();
|
||||
item_map.clear();
|
||||
@@ -233,53 +240,67 @@ void ProjectFilesystemWidget::on_lineFilter_textChanged(const QString & ) {
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesystemWidget::on_tree_itemClicked(QTreeWidgetItem * item, int column) {
|
||||
projectfs_menu_target = QFileInfo();
|
||||
if (!item) {
|
||||
setExtVariable();
|
||||
return;
|
||||
}
|
||||
projectfs_menu_target = QFileInfo(item->data(0, Qt::UserRole).toString());
|
||||
setExtVariable();
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesystemWidget::on_tree_customContextMenuRequested(const QPoint & pos) {
|
||||
menu_target = QFileInfo();
|
||||
projectfs_menu_target = QFileInfo();
|
||||
QTreeWidgetItem * item = tree->itemAt(pos);
|
||||
//QMessageBox::information(this, "", QString::number(index.row()));
|
||||
if (!item) return;
|
||||
menu_target = QFileInfo(item->data(0, Qt::UserRole).toString());
|
||||
actionOpen_here->setEnabled(!menu_target.isDir());
|
||||
actionOpen_external->setEnabled(!menu_target.isDir());
|
||||
if (!item) {
|
||||
setExtVariable();
|
||||
return;
|
||||
}
|
||||
projectfs_menu_target = QFileInfo(item->data(0, Qt::UserRole).toString());
|
||||
setExtVariable();
|
||||
actionOpen_here->setEnabled(!projectfs_menu_target.isDir());
|
||||
actionOpen_external->setEnabled(!projectfs_menu_target.isDir());
|
||||
popup_menu.popup(tree->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesystemWidget::on_actionOpen_here_triggered() {
|
||||
if (menu_target.path().isEmpty()) return;
|
||||
Core::EditorManager::openEditor(menu_target.absoluteFilePath(), Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
||||
if (projectfs_menu_target.path().isEmpty()) return;
|
||||
Core::EditorManager::openEditor(projectfs_menu_target.absoluteFilePath(), Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesystemWidget::on_actionOpen_external_triggered() {
|
||||
if (menu_target.path().isEmpty()) return;
|
||||
if (projectfs_menu_target.path().isEmpty()) return;
|
||||
QString wd = QDir::current().absolutePath();
|
||||
QDir::setCurrent(menu_target.absoluteDir().path());
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(menu_target.absoluteFilePath()));
|
||||
QDir::setCurrent(projectfs_menu_target.absoluteDir().path());
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(projectfs_menu_target.absoluteFilePath()));
|
||||
QDir::setCurrent(wd);
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesystemWidget::on_actionShow_external_triggered() {
|
||||
if (menu_target.path().isEmpty()) return;
|
||||
Core::FileUtils::showInGraphicalShell(Core::ICore::mainWindow(), menu_target.absoluteFilePath());
|
||||
if (projectfs_menu_target.path().isEmpty()) return;
|
||||
Core::FileUtils::showInGraphicalShell(Core::ICore::mainWindow(), projectfs_menu_target.absoluteFilePath());
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesystemWidget::on_actionOpen_terminal_triggered() {
|
||||
if (menu_target.path().isEmpty()) return;
|
||||
Core::FileUtils::openTerminal(QDir(menu_target.absoluteFilePath()).path());
|
||||
if (projectfs_menu_target.path().isEmpty()) return;
|
||||
Core::FileUtils::openTerminal(QDir(projectfs_menu_target.absoluteFilePath()).path());
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesystemWidget::on_actionCopy_name_triggered() {
|
||||
if (menu_target.path().isEmpty()) return;
|
||||
QApplication::clipboard()->setText(menu_target.fileName());
|
||||
if (projectfs_menu_target.path().isEmpty()) return;
|
||||
QApplication::clipboard()->setText(projectfs_menu_target.fileName());
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesystemWidget::on_actionCopy_path_triggered() {
|
||||
if (menu_target.path().isEmpty()) return;
|
||||
QApplication::clipboard()->setText(menu_target.absoluteFilePath());
|
||||
if (projectfs_menu_target.path().isEmpty()) return;
|
||||
QApplication::clipboard()->setText(projectfs_menu_target.absoluteFilePath());
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <QFileSystemModel>
|
||||
#include <QMenu>
|
||||
|
||||
extern QFileInfo projectfs_menu_target;
|
||||
|
||||
class ProjectsModel;
|
||||
|
||||
class ProjectFilesystemWidget: public QWidget, private Ui::ProjectFilesystemWidget
|
||||
@@ -29,10 +31,10 @@ protected:
|
||||
void filter();
|
||||
void rememberExpanded(QTreeWidgetItem * ti);
|
||||
void restoreExpanded(QTreeWidgetItem * ti);
|
||||
void setExtVariable();
|
||||
|
||||
ExtensionSystem::IPlugin * proj_plug;
|
||||
QMenu popup_menu;
|
||||
QFileInfo menu_target;
|
||||
QMap<QString, QTreeWidgetItem*> item_map;
|
||||
QSet<QString> last_expanded;
|
||||
FilterDialog filter_dialog;
|
||||
@@ -48,6 +50,7 @@ private slots:
|
||||
|
||||
void on_tree_itemDoubleClicked(QTreeWidgetItem * item, int );
|
||||
void on_lineFilter_textChanged(const QString &);
|
||||
void on_tree_itemClicked(QTreeWidgetItem *item, int column);
|
||||
void on_tree_customContextMenuRequested(const QPoint & pos);
|
||||
void on_actionOpen_here_triggered();
|
||||
void on_actionOpen_external_triggered();
|
||||
|
||||
Reference in New Issue
Block a user