mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +01:00
Elements panel: added contextual actions so users can easily find elements, title block templates and projects on their filesystem.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2023 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -53,6 +53,8 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
|||||||
elements_panel = new ElementsPanel(this);
|
elements_panel = new ElementsPanel(this);
|
||||||
|
|
||||||
// initialise les actions
|
// initialise les actions
|
||||||
|
open_directory = new QAction(QET::Icons::DocumentOpen, tr("Ouvrir le dossier correspondant"), this);
|
||||||
|
copy_path = new QAction(QET::Icons::CopyFile, tr("Copier le chemin"), this);
|
||||||
reload = new QAction(QET::Icons::ViewRefresh, tr("Recharger les collections"), this);
|
reload = new QAction(QET::Icons::ViewRefresh, tr("Recharger les collections"), this);
|
||||||
new_category = new QAction(QET::Icons::FolderNew, tr("Nouvelle cat\351gorie"), this);
|
new_category = new QAction(QET::Icons::FolderNew, tr("Nouvelle cat\351gorie"), this);
|
||||||
edit_category = new QAction(QET::Icons::FolderEdit, tr("\311diter la cat\351gorie"), this);
|
edit_category = new QAction(QET::Icons::FolderEdit, tr("\311diter la cat\351gorie"), this);
|
||||||
@@ -95,6 +97,8 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
|||||||
|
|
||||||
context_menu = new QMenu(this);
|
context_menu = new QMenu(this);
|
||||||
|
|
||||||
|
connect(open_directory, SIGNAL(triggered()), this, SLOT(openDirectoryForSelectedItem()));
|
||||||
|
connect(copy_path, SIGNAL(triggered()), this, SLOT(copyPathForSelectedItem()));
|
||||||
connect(reload, SIGNAL(triggered()), this, SLOT(reloadAndFilter()));
|
connect(reload, SIGNAL(triggered()), this, SLOT(reloadAndFilter()));
|
||||||
connect(new_category, SIGNAL(triggered()), this, SLOT(newCategory()));
|
connect(new_category, SIGNAL(triggered()), this, SLOT(newCategory()));
|
||||||
connect(edit_category, SIGNAL(triggered()), this, SLOT(editCategory()));
|
connect(edit_category, SIGNAL(triggered()), this, SLOT(editCategory()));
|
||||||
@@ -189,6 +193,33 @@ void ElementsPanelWidget::clearFilterTextField() {
|
|||||||
filterEdited(QString());
|
filterEdited(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Require the desktop environment to open the directory containing the file
|
||||||
|
represented by the selected item, if any.
|
||||||
|
*/
|
||||||
|
void ElementsPanelWidget::openDirectoryForSelectedItem() {
|
||||||
|
if (QTreeWidgetItem *qtwi = elements_panel -> currentItem()) {
|
||||||
|
QString dir_path = elements_panel -> dirPathForItem(qtwi);
|
||||||
|
if (!dir_path.isEmpty()) {
|
||||||
|
QDesktopServices::openUrl(dir_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Copy the full path to the file represented by the selected item to the
|
||||||
|
clipboard.
|
||||||
|
*/
|
||||||
|
void ElementsPanelWidget::copyPathForSelectedItem() {
|
||||||
|
if (QTreeWidgetItem *qtwi = elements_panel -> currentItem()) {
|
||||||
|
QString file_path = elements_panel -> filePathForItem(qtwi);
|
||||||
|
file_path = QDir::toNativeSeparators(file_path);
|
||||||
|
if (!file_path.isEmpty()) {
|
||||||
|
QApplication::clipboard() -> setText(file_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Recharge le panel d'elements
|
Recharge le panel d'elements
|
||||||
*/
|
*/
|
||||||
@@ -468,6 +499,13 @@ void ElementsPanelWidget::handleContextMenu(const QPoint &pos) {
|
|||||||
updateButtons();
|
updateButtons();
|
||||||
context_menu -> clear();
|
context_menu -> clear();
|
||||||
|
|
||||||
|
QString dir_path = elements_panel -> dirPathForItem(item);
|
||||||
|
if (!dir_path.isEmpty()) {
|
||||||
|
context_menu -> addAction(open_directory);
|
||||||
|
context_menu -> addAction(copy_path);
|
||||||
|
context_menu -> addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
switch(item -> type()) {
|
switch(item -> type()) {
|
||||||
case QET::ElementsCategory:
|
case QET::ElementsCategory:
|
||||||
context_menu -> addAction(new_category);
|
context_menu -> addAction(new_category);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class ElementsPanelWidget : public QWidget {
|
|||||||
private:
|
private:
|
||||||
ElementsPanel *elements_panel;
|
ElementsPanel *elements_panel;
|
||||||
QToolBar *toolbar, *filter_toolbar;
|
QToolBar *toolbar, *filter_toolbar;
|
||||||
|
QAction *open_directory, *copy_path;
|
||||||
QAction *reload;
|
QAction *reload;
|
||||||
QAction *new_category, *edit_category, *delete_category;
|
QAction *new_category, *edit_category, *delete_category;
|
||||||
QAction *delete_collection;
|
QAction *delete_collection;
|
||||||
@@ -69,6 +70,8 @@ class ElementsPanelWidget : public QWidget {
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clearFilterTextField();
|
void clearFilterTextField();
|
||||||
|
void openDirectoryForSelectedItem();
|
||||||
|
void copyPathForSelectedItem();
|
||||||
void reloadAndFilter();
|
void reloadAndFilter();
|
||||||
void activateProject();
|
void activateProject();
|
||||||
void closeProject();
|
void closeProject();
|
||||||
|
|||||||
Reference in New Issue
Block a user