From 191a50b8ac97678636360d2a63efc718d340b0b8 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 29 Dec 2014 16:50:03 +0300 Subject: [PATCH] Provide Copy command for items in Group operation --- .../ModuleBase_WidgetMultiSelector.cpp | 35 ++++++++++++++++++ .../ModuleBase_WidgetMultiSelector.h | 7 ++++ src/XGUI/XGUI_pictures.qrc | 1 + src/XGUI/pictures/copy.png | Bin 0 -> 766 bytes 4 files changed, 43 insertions(+) create mode 100644 src/XGUI/pictures/copy.png diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 420487097..114a76748 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include #include @@ -64,6 +67,14 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen //TODO_END connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectionTypeChanged())); + myCopyAction = new QAction(QIcon(":pictures/copy.png"), tr("Copy"), this); + myCopyAction->setShortcut(QKeySequence::Copy); + myCopyAction->setEnabled(false); + connect(myCopyAction, SIGNAL(triggered(bool)), SLOT(onCopyItem())); + myListControl->addAction(myCopyAction); + myListControl->setContextMenuPolicy(Qt::ActionsContextMenu); + connect(myListControl, SIGNAL(itemSelectionChanged()), SLOT(onListSelection())); + activateSelection(true); } @@ -261,3 +272,27 @@ void ModuleBase_WidgetMultiSelector::updateSelectionList(AttributeSelectionListP myListControl->addItem(aAttr->namingName().c_str()); } } + +//******************************************************************** +void ModuleBase_WidgetMultiSelector::onCopyItem() +{ + QList aItems = myListControl->selectedItems(); + QString aRes; + foreach(QListWidgetItem* aItem, aItems) { + if (!aRes.isEmpty()) + aRes += "\n"; + aRes += aItem->text(); + } + if (!aRes.isEmpty()) { + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(aRes); + } +} + +//******************************************************************** +void ModuleBase_WidgetMultiSelector::onListSelection() +{ + QList aItems = myListControl->selectedItems(); + myCopyAction->setEnabled(!aItems.isEmpty()); +} + diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 47f08a5e6..111b27f0d 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -29,6 +29,7 @@ class QWidget; class QListWidget; class QComboBox; class ModuleBase_IWorkshop; +class QAction; class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_ModelWidget { @@ -61,6 +62,10 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Model void onSelectionTypeChanged(); void onSelectionChanged(); +protected slots: + void onCopyItem(); + void onListSelection(); + protected: void filterShapes(const NCollection_List& theShapesToFilter, NCollection_List& theResult); @@ -83,6 +88,8 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Model typedef QPair GeomSelection; QList mySelection; + + QAction* myCopyAction; }; #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */ diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index b7c79dd9b..3176442f6 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -8,6 +8,7 @@ pictures/undo.png pictures/rebuild.png pictures/preferences.png + pictures/copy.png pictures/params_folder.png pictures/constr_folder.png diff --git a/src/XGUI/pictures/copy.png b/src/XGUI/pictures/copy.png new file mode 100644 index 0000000000000000000000000000000000000000..12968bf76c909fc6c281f6765b94b94a382ad44f GIT binary patch literal 766 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b zK-vS0-A-oPfdtD69Mgd`SU*F|v9*U87?{*OT^vI!PM1zP>pdk<?`+h6WoC4wR@Q7o4Zg#|8IAn#?d`18K+ zuea=Y-!tvofxCCA&sWa-JjY!(Z^_;H*S|cuXtCUd!GU37!5)r#hmW^DW#>PhwfRr8 z#@3)+QN8(d-gG$$KG^$!bq@P;md6Rd&YrS-kih&eiCK`dRc?*&8s=Qp%cTNu*&c5$ zHG8e6At15F<;#@M8myH|JE~VF`^V+=ZVBmX$oo^Z&Tg&R@_y0JtEU#p z+{c>#;QRx2Rv~wSCuBVQTGKqgboxw|?RwL8*hmDw)?dK8M6GAq42KI>ev7C?N!Z47 z@oSoFT_CXRS=r3!%Z--7iLp1%Y~7r?hvQ=Fzlyit{(f|~j9Iw#{j$d0$>r~2B{f8| zYd_kB-Fo9GJ9qX$JpZhlH;S|w0}fr+kx hp{}7th@pv