X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetMultiSelector.cpp;h=5ee8ac64a38bd0bab91c132eb4b3a475fdebfac9;hb=a2982d2108f929cf9e7f996cfd590c4ce59dc21c;hp=4204870979762d92365ea481ea3a52fefba947d7;hpb=b52164791e6cc6cdc2c009c7ef6667d9f476d3aa;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 420487097..5ee8ac64a 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 @@ -34,7 +37,7 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen const Config_WidgetAPI* theData, const std::string& theParentId) : ModuleBase_ModelWidget(theParent, theData, theParentId), - myWorkshop(theWorkshop), myIsActive(false), myUseSubShapes(false) + myWorkshop(theWorkshop), myIsActive(false) { myMainWidget = new QWidget(theParent); QGridLayout* aMainLay = new QGridLayout(myMainWidget); @@ -59,11 +62,16 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen aMainLay->addWidget(new QLabel(myMainWidget)); aMainLay->setRowMinimumHeight(3, 20); myMainWidget->setLayout(aMainLay); - //TODO: Move into the base class - myUseSubShapes = theData->getBooleanAttribute("use_subshapes", false); - //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 +269,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()); +} +