git-svn-id: svn://db.shs.com.ru/libs@363 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2018-03-05 09:25:33 +00:00
parent 300d30109d
commit 44c4a85237
3 changed files with 49 additions and 20 deletions

View File

@@ -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());
}