git-svn-id: svn://db.shs.com.ru/libs@361 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 634 B After Width: | Height: | Size: 42 KiB |
BIN
project_fs/icons/utilities-terminal.png
Normal file
BIN
project_fs/icons/utilities-terminal.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -1,5 +1,6 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>icons/edit-find.png</file>
|
<file>icons/edit-find.png</file>
|
||||||
|
<file>icons/utilities-terminal.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -23,54 +23,11 @@
|
|||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
|
||||||
/*
|
|
||||||
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<int, QByteArray> 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) {
|
ProjectFilesystemWidget::ProjectFilesystemWidget(QWidget * parent): QWidget(parent) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
int is = style()->pixelMetric(QStyle::PM_ButtonIconSize, 0, this);
|
||||||
|
label->setFixedSize(is, is);
|
||||||
buttonClear->setIcon(Utils::Icons::CLEAN.icon());
|
buttonClear->setIcon(Utils::Icons::CLEAN.icon());
|
||||||
buttonExpand->setIcon(Utils::Icons::EXPAND.icon());
|
buttonExpand->setIcon(Utils::Icons::EXPAND.icon());
|
||||||
buttonCollapse->setIcon(Utils::Icons::COLLAPSE.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));
|
actionShow_external->setIcon(Core::FileIconProvider::icon(QFileIconProvider::Folder));
|
||||||
actionCopy_name->setIcon(Utils::Icons::COPY.icon());
|
actionCopy_name->setIcon(Utils::Icons::COPY.icon());
|
||||||
actionCopy_path->setIcon(Utils::Icons::COPY.icon());
|
actionCopy_path->setIcon(Utils::Icons::COPY.icon());
|
||||||
popup_menu.addActions(QList<QAction*>() << actionOpen_here << actionOpen_external << actionShow_external);
|
popup_menu.addActions(QList<QAction*>() << actionOpen_here << actionOpen_external << actionShow_external << actionOpen_terminal);
|
||||||
popup_menu.addSeparator();
|
popup_menu.addSeparator();
|
||||||
popup_menu.addActions(QList<QAction*>() << actionCopy_name << actionCopy_path);
|
popup_menu.addActions(QList<QAction*>() << actionCopy_name << actionCopy_path);
|
||||||
proj_plug = 0;
|
proj_plug = 0;
|
||||||
/*QList<QObject * > plugs = ExtensionSystem::PluginManager::allObjects();
|
|
||||||
QStringList sl;
|
|
||||||
foreach (QObject * o, plugs) {
|
|
||||||
ExtensionSystem::IPlugin * p = qobject_cast<ExtensionSystem::IPlugin * >(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::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(startupProjectChanged(ProjectExplorer::Project *)), this, SLOT(startupProjectChanged()));
|
||||||
connect(ProjectExplorer::SessionManager::instance(), SIGNAL(projectAdded(ProjectExplorer::Project*)), this, SLOT(projectsChanged()));
|
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(projectRemoved(ProjectExplorer::Project*)), this, SLOT(projectsChanged()));
|
||||||
//connect(ProjectExplorer::SessionManager::instance(), SIGNAL(), this, SLOT(startupProjectChanged()));
|
//connect(ProjectExplorer::SessionManager::instance(), SIGNAL(), this, SLOT(startupProjectChanged()));
|
||||||
connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(fileChanged()));
|
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();
|
projectsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,11 +70,6 @@ void ProjectFilesystemWidget::changeEvent(QEvent *e) {
|
|||||||
|
|
||||||
|
|
||||||
void ProjectFilesystemWidget::createTree(QTreeWidgetItem * ti, const QString & dir) {
|
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);
|
QFileInfoList fl = QDir(dir).entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot, QDir::LocaleAware | QDir::DirsFirst);
|
||||||
for (QFileInfo i: fl) {
|
for (QFileInfo i: fl) {
|
||||||
QString nit = i.fileName();
|
QString nit = i.fileName();
|
||||||
@@ -195,13 +124,6 @@ bool ProjectFilesystemWidget::filterTree(QTreeWidgetItem * ti, const QString & f
|
|||||||
|
|
||||||
void ProjectFilesystemWidget::filter() {
|
void ProjectFilesystemWidget::filter() {
|
||||||
QString f = lineFilter->text();
|
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) {
|
for (int i = 0; i < tree->topLevelItemCount(); ++i) {
|
||||||
QTreeWidgetItem * ti = tree->topLevelItem(i);
|
QTreeWidgetItem * ti = tree->topLevelItem(i);
|
||||||
filterTree(ti, f);
|
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) {
|
void ProjectFilesystemWidget::on_tree_itemDoubleClicked(QTreeWidgetItem * item, int) {
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
QString afp = item->data(0, Qt::UserRole).toString();
|
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_here->setEnabled(!menu_target.isDir());
|
||||||
actionOpen_external->setEnabled(!menu_target.isDir());
|
actionOpen_external->setEnabled(!menu_target.isDir());
|
||||||
popup_menu.popup(tree->mapToGlobal(pos));
|
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<QObject*> ol = w->findChildren<QObject*>();
|
|
||||||
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() {
|
void ProjectFilesystemWidget::on_actionOpen_external_triggered() {
|
||||||
if (menu_target.path().isEmpty()) return;
|
if (menu_target.path().isEmpty()) return;
|
||||||
|
QString wd = QDir::current().absolutePath();
|
||||||
|
QDir::setCurrent(menu_target.absoluteDir().path());
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(menu_target.absoluteFilePath()));
|
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() {
|
void ProjectFilesystemWidget::on_actionCopy_name_triggered() {
|
||||||
if (menu_target.path().isEmpty()) return;
|
if (menu_target.path().isEmpty()) return;
|
||||||
QApplication::clipboard()->setText(menu_target.fileName());
|
QApplication::clipboard()->setText(menu_target.fileName());
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ protected:
|
|||||||
void restoreExpanded(QTreeWidgetItem * ti);
|
void restoreExpanded(QTreeWidgetItem * ti);
|
||||||
|
|
||||||
ExtensionSystem::IPlugin * proj_plug;
|
ExtensionSystem::IPlugin * proj_plug;
|
||||||
//ProjectsModel * model;
|
|
||||||
QMenu popup_menu;
|
QMenu popup_menu;
|
||||||
QFileInfo menu_target;
|
QFileInfo menu_target;
|
||||||
QMap<QString, QTreeWidgetItem*> item_map;
|
QMap<QString, QTreeWidgetItem*> item_map;
|
||||||
@@ -47,13 +46,13 @@ private slots:
|
|||||||
void fileChanged();
|
void fileChanged();
|
||||||
void startupProjectChanged();
|
void startupProjectChanged();
|
||||||
|
|
||||||
void on_tree_doubleClicked(const QModelIndex &index);
|
|
||||||
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_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();
|
||||||
void on_actionShow_external_triggered();
|
void on_actionShow_external_triggered();
|
||||||
|
void on_actionOpen_terminal_triggered();
|
||||||
void on_actionCopy_name_triggered();
|
void on_actionCopy_name_triggered();
|
||||||
void on_actionCopy_path_triggered();
|
void on_actionCopy_path_triggered();
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>327</width>
|
<width>386</width>
|
||||||
<height>284</height>
|
<height>390</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
@@ -18,6 +18,9 @@
|
|||||||
<property name="pixmap">
|
<property name="pixmap">
|
||||||
<pixmap resource="projectfilesystem.qrc">:/icons/edit-find.png</pixmap>
|
<pixmap resource="projectfilesystem.qrc">:/icons/edit-find.png</pixmap>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -114,6 +117,15 @@
|
|||||||
<string>Copy path</string>
|
<string>Copy path</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionOpen_terminal">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="projectfilesystem.qrc">
|
||||||
|
<normaloff>:/icons/utilities-terminal.png</normaloff>:/icons/utilities-terminal.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Open terminal ...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="projectfilesystem.qrc"/>
|
<include location="projectfilesystem.qrc"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user