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