diff --git a/project_fs/icons/edit-find.png b/project_fs/icons/edit-find.png
index 9a462c0..140e581 100644
Binary files a/project_fs/icons/edit-find.png and b/project_fs/icons/edit-find.png differ
diff --git a/project_fs/icons/utilities-terminal.png b/project_fs/icons/utilities-terminal.png
new file mode 100644
index 0000000..9c8effe
Binary files /dev/null and b/project_fs/icons/utilities-terminal.png differ
diff --git a/project_fs/projectfilesystem.qrc b/project_fs/projectfilesystem.qrc
index 49af6d4..2b5712f 100644
--- a/project_fs/projectfilesystem.qrc
+++ b/project_fs/projectfilesystem.qrc
@@ -1,5 +1,6 @@
icons/edit-find.png
+ icons/utilities-terminal.png
diff --git a/project_fs/projectfilesystemwidget.cpp b/project_fs/projectfilesystemwidget.cpp
index e9cf626..4d6e9c6 100644
--- a/project_fs/projectfilesystemwidget.cpp
+++ b/project_fs/projectfilesystemwidget.cpp
@@ -23,54 +23,11 @@
#include
#include
-/*
-class ProjectsModel: public QAbstractItemModel
-{
-public:
- ProjectsModel() {fsm.setRootPath(qApp->applicationDirPath());}
- QFileInfo fileInfo(const QModelIndex & i) {return fsm.fileInfo(i);}
- QModelIndex index(const QString & path, int column = 0) const {return fsm.index(path, column);}
- QModelIndex index(int row, int column, const QModelIndex & parent) const {
- return fsm.index(row, column, parent);
- }
- QModelIndex parent(const QModelIndex & child) const {
- return fsm.parent(child);
- }
- int rowCount(const QModelIndex & parent) const {
- return fsm.rowCount(parent);
- }
- int columnCount(const QModelIndex & parent) const {
- return fsm.columnCount(parent);
- }
- QVariant data(const QModelIndex & index, int role) const {
- return fsm.data(index, role);
- }
- QVariant headerData(int section, Qt::Orientation orientation, int role) const {
- return fsm.headerData(section, orientation, role);
- }
- Qt::ItemFlags flags(const QModelIndex & index) const {
- return fsm.flags(index);
- }
- void sort(int column, Qt::SortOrder order) {
- fsm.sort(column, order);
- }
- QHash roleNames() const {
- return fsm.roleNames();
- }
- QModelIndex sibling(int row, int column, const QModelIndex & idx) const {
- return fsm.sibling(row, column, idx);
- }
- bool hasChildren(const QModelIndex & parent) const {
- return fsm.hasChildren(parent);
- }
-private:
- QFileSystemModel fsm;
-
-};
-*/
ProjectFilesystemWidget::ProjectFilesystemWidget(QWidget * parent): QWidget(parent) {
setupUi(this);
+ int is = style()->pixelMetric(QStyle::PM_ButtonIconSize, 0, this);
+ label->setFixedSize(is, is);
buttonClear->setIcon(Utils::Icons::CLEAN.icon());
buttonExpand->setIcon(Utils::Icons::EXPAND.icon());
buttonCollapse->setIcon(Utils::Icons::COLLAPSE.icon());
@@ -79,27 +36,10 @@ ProjectFilesystemWidget::ProjectFilesystemWidget(QWidget * parent): QWidget(pare
actionShow_external->setIcon(Core::FileIconProvider::icon(QFileIconProvider::Folder));
actionCopy_name->setIcon(Utils::Icons::COPY.icon());
actionCopy_path->setIcon(Utils::Icons::COPY.icon());
- popup_menu.addActions(QList() << actionOpen_here << actionOpen_external << actionShow_external);
+ popup_menu.addActions(QList() << actionOpen_here << actionOpen_external << actionShow_external << actionOpen_terminal);
popup_menu.addSeparator();
popup_menu.addActions(QList() << actionCopy_name << actionCopy_path);
proj_plug = 0;
- /*QList plugs = ExtensionSystem::PluginManager::allObjects();
- QStringList sl;
- foreach (QObject * o, plugs) {
- ExtensionSystem::IPlugin * p = qobject_cast(o);
- if (!p) continue;
- QString cn = QString::fromLatin1(o->metaObject()->className());
- if (cn.startsWith("ProjectExplorer"))
- sl << cn;
- ExtensionSystem::PluginSpec * ps = p->pluginSpec();
- if (!ps) continue;
- if (ps->name() == "ProjectExplorer") {
- proj_plug = p;
- connect(p, SIGNAL(fileListChanged()), this, SLOT(projectsChanged()), Qt::UniqueConnection);
- break;
- }
- }*/
- //QMessageBox::information(this, "", sl.join("\n"));
//connect(ProjectExplorer::ProjectTree::instance(), SIGNAL(subtreeChanged(ProjectExplorer::FolderNode*)), this, SLOT(projectsChanged()));
connect(ProjectExplorer::SessionManager::instance(), SIGNAL(startupProjectChanged(ProjectExplorer::Project *)), this, SLOT(startupProjectChanged()));
connect(ProjectExplorer::SessionManager::instance(), SIGNAL(projectAdded(ProjectExplorer::Project*)), this, SLOT(projectsChanged()));
@@ -107,12 +47,6 @@ ProjectFilesystemWidget::ProjectFilesystemWidget(QWidget * parent): QWidget(pare
connect(ProjectExplorer::SessionManager::instance(), SIGNAL(projectRemoved(ProjectExplorer::Project*)), this, SLOT(projectsChanged()));
//connect(ProjectExplorer::SessionManager::instance(), SIGNAL(), this, SLOT(startupProjectChanged()));
connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(fileChanged()));
- //model = new ProjectsModel();
- //tree->setModel(model);
- //model.setNameFilterDisables(false);
- /*for (int i = 1; i < tree->header()->count(); ++i)
- tree->header()->setSectionHidden(i, true);
- tree->setHeaderHidden(true);*/
projectsChanged();
}
@@ -136,11 +70,6 @@ void ProjectFilesystemWidget::changeEvent(QEvent *e) {
void ProjectFilesystemWidget::createTree(QTreeWidgetItem * ti, const QString & dir) {
- /*int rc = model.rowCount(dir);
- QTreeWidgetItem * ni = new QTreeWidgetItem(ti);
- ni->setText(0, QString::number(rc));
- ti->addChild(ni);
- return;*/
QFileInfoList fl = QDir(dir).entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot, QDir::LocaleAware | QDir::DirsFirst);
for (QFileInfo i: fl) {
QString nit = i.fileName();
@@ -195,13 +124,6 @@ bool ProjectFilesystemWidget::filterTree(QTreeWidgetItem * ti, const QString & f
void ProjectFilesystemWidget::filter() {
QString f = lineFilter->text();
- /*QStringList nf;
- if (!f.isEmpty()) {
- if (!f.startsWith("*")) f.prepend('*');
- if (!f.endsWith("*")) f.append('*');
- nf << f;
- }
- model.setNameFilters(nf);*/
for (int i = 0; i < tree->topLevelItemCount(); ++i) {
QTreeWidgetItem * ti = tree->topLevelItem(i);
filterTree(ti, f);
@@ -296,17 +218,6 @@ void ProjectFilesystemWidget::startupProjectChanged() {
}
-void ProjectFilesystemWidget::on_tree_doubleClicked(const QModelIndex & index) {
- /*if (!index.isValid()) return;
- QFileInfo fi = model->fileInfo(index);
- QStringList ext_ext;
- ext_ext << "ui" << "ts";
- if (ext_ext.contains(fi.suffix()))
- QDesktopServices::openUrl(QUrl::fromLocalFile(fi.absoluteFilePath()));
- else
- Core::EditorManager::openEditor(fi.absoluteFilePath());*/
-}
-
void ProjectFilesystemWidget::on_tree_itemDoubleClicked(QTreeWidgetItem * item, int) {
if (!item) return;
QString afp = item->data(0, Qt::UserRole).toString();
@@ -331,44 +242,6 @@ void ProjectFilesystemWidget::on_tree_customContextMenuRequested(const QPoint &
actionOpen_here->setEnabled(!menu_target.isDir());
actionOpen_external->setEnabled(!menu_target.isDir());
popup_menu.popup(tree->mapToGlobal(pos));
- /*Utils::FileName fileName(menu_target);
- //Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_FILECONTEXT)->menu()->popup(tree->mapToGlobal(pos));
- ProjectExplorer::ProjectExplorerPlugin::updateContextMenuActions();
- ProjectExplorer::Node * n = 0;//ProjectExplorer::Internal::ProjectTreeWidget::nodeForFile(Utils::FileName(menu_target));
- for (ProjectExplorer::Project * project: ProjectExplorer::SessionManager::projects()) {
- if (ProjectExplorer::ProjectNode * projectNode = project->rootProjectNode()) {
- projectNode->forEachGenericNode([&](ProjectExplorer::Node *node) {
- if (node->filePath() == fileName) {
- if (!n) {
- n = node;
- }
- }
- });
- if (n) break;
- }
- }
- if (!n) return;
- ProjectExplorer::Internal::ProjectTreeWidget * ptw = 0;
- QString ss = QString::fromLatin1("ProjectTreeWidget");
- QWidgetList wl = qApp->topLevelWidgets();
- for (QWidget * w : wl) {
- QList ol = w->findChildren();
- if (QString::fromLatin1(w->metaObject()->className()).endsWith(ss)) {
- ptw = (ProjectExplorer::Internal::ProjectTreeWidget *)w;
- break;
- }
- for (QObject * o : ol) {
- if (QString::fromLatin1(o->metaObject()->className()).endsWith(ss)) {
- ptw = (ProjectExplorer::Internal::ProjectTreeWidget *)o;
- break;
- }
- }
- if (ptw) break;
- }
- if (!ptw) return;
- ptw->setFocus();
- qApp->processEvents();
- ProjectExplorer::ProjectTree::showContextMenu(ptw, tree->mapToGlobal(pos), n);*/
}
@@ -380,7 +253,10 @@ void ProjectFilesystemWidget::on_actionOpen_here_triggered() {
void ProjectFilesystemWidget::on_actionOpen_external_triggered() {
if (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(wd);
}
@@ -390,6 +266,12 @@ void ProjectFilesystemWidget::on_actionShow_external_triggered() {
}
+void ProjectFilesystemWidget::on_actionOpen_terminal_triggered() {
+ if (menu_target.path().isEmpty()) return;
+ Core::FileUtils::openTerminal(QDir(menu_target.absoluteFilePath()).path());
+}
+
+
void ProjectFilesystemWidget::on_actionCopy_name_triggered() {
if (menu_target.path().isEmpty()) return;
QApplication::clipboard()->setText(menu_target.fileName());
diff --git a/project_fs/projectfilesystemwidget.h b/project_fs/projectfilesystemwidget.h
index a7559b0..eb1ac97 100644
--- a/project_fs/projectfilesystemwidget.h
+++ b/project_fs/projectfilesystemwidget.h
@@ -31,7 +31,6 @@ protected:
void restoreExpanded(QTreeWidgetItem * ti);
ExtensionSystem::IPlugin * proj_plug;
- //ProjectsModel * model;
QMenu popup_menu;
QFileInfo menu_target;
QMap item_map;
@@ -47,13 +46,13 @@ private slots:
void fileChanged();
void startupProjectChanged();
- void on_tree_doubleClicked(const QModelIndex &index);
void on_tree_itemDoubleClicked(QTreeWidgetItem * item, int );
void on_lineFilter_textChanged(const QString &);
void on_tree_customContextMenuRequested(const QPoint & pos);
void on_actionOpen_here_triggered();
void on_actionOpen_external_triggered();
void on_actionShow_external_triggered();
+ void on_actionOpen_terminal_triggered();
void on_actionCopy_name_triggered();
void on_actionCopy_path_triggered();
diff --git a/project_fs/projectfilesystemwidget.ui b/project_fs/projectfilesystemwidget.ui
index e9c9e48..c05af68 100644
--- a/project_fs/projectfilesystemwidget.ui
+++ b/project_fs/projectfilesystemwidget.ui
@@ -6,8 +6,8 @@
0
0
- 327
- 284
+ 386
+ 390
@@ -18,6 +18,9 @@
:/icons/edit-find.png
+
+ true
+
-
@@ -114,6 +117,15 @@
Copy path
+
+
+
+ :/icons/utilities-terminal.png:/icons/utilities-terminal.png
+
+
+ Open terminal ...
+
+