From: vsv Date: Mon, 29 Dec 2014 13:50:03 +0000 (+0300) Subject: Provide Copy command for items in Group operation X-Git-Tag: V_0.7.0_rc1~17^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=191a50b8ac97678636360d2a63efc718d340b0b8;p=modules%2Fshaper.git Provide Copy command for items in Group operation --- 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 000000000..12968bf76 Binary files /dev/null and b/src/XGUI/pictures/copy.png differ