issue #0001649: Changing names on Pads does not change them everywere

This commit is contained in:
wmayer 2016-10-21 15:33:43 +02:00
parent c92dbb3269
commit 58cb2e2ddc
2 changed files with 27 additions and 11 deletions

View File

@ -122,10 +122,14 @@ void TaskMirroredParameters::setupUI()
std::vector<App::DocumentObject*> originals = pcMirrored->Originals.getValues(); std::vector<App::DocumentObject*> originals = pcMirrored->Originals.getValues();
// Fill data into dialog elements // Fill data into dialog elements
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i) for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i) {
{ const App::DocumentObject* obj = *i;
if ((*i) != NULL) if (obj != NULL) {
ui->listWidgetFeatures->addItem(QString::fromLatin1((*i)->getNameInDocument())); QListWidgetItem* item = new QListWidgetItem();
item->setText(QString::fromUtf8(obj->Label.getValue()));
item->setData(Qt::UserRole, QString::fromLatin1(obj->getNameInDocument()));
ui->listWidgetFeatures->addItem(item);
}
} }
// --------------------- // ---------------------
@ -178,10 +182,22 @@ void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg
if (msg.Type == Gui::SelectionChanges::AddSelection) { if (msg.Type == Gui::SelectionChanges::AddSelection) {
if (originalSelected(msg)) { if (originalSelected(msg)) {
if (selectionMode == addFeature) Gui::SelectionObject selObj(msg);
ui->listWidgetFeatures->addItem(QString::fromLatin1(msg.pObjectName)); App::DocumentObject* obj = selObj.getObject();
else Q_ASSERT(obj);
removeItemFromListWidget(ui->listWidgetFeatures, QString::fromLatin1(msg.pObjectName));
QString label = QString::fromUtf8(obj->Label.getValue());
QString objectName = QString::fromLatin1(msg.pObjectName);
if (selectionMode == addFeature) {
QListWidgetItem* item = new QListWidgetItem();
item->setText(label);
item->setData(Qt::UserRole, objectName);
ui->listWidgetFeatures->addItem(item);
}
else {
removeItemFromListWidget(ui->listWidgetFeatures, label);
}
exitSelectionMode(); exitSelectionMode();
} else { } else {
if ( selectionMode == reference) { if ( selectionMode == reference) {

View File

@ -64,7 +64,7 @@ public:
* will go out of sync, and crashes may result. * will go out of sync, and crashes may result.
*/ */
ComboLinks(QComboBox &combo); ComboLinks(QComboBox &combo);
ComboLinks() {_combo = 0; doc = 0;}; ComboLinks() {_combo = 0; doc = 0;}
void setCombo(QComboBox &combo) {assert(_combo == 0); this->_combo = &combo; _combo->clear();} void setCombo(QComboBox &combo) {assert(_combo == 0); this->_combo = &combo; _combo->clear();}
/** /**
@ -97,9 +97,9 @@ public:
*/ */
int setCurrentLink(const App::PropertyLinkSub &lnk); int setCurrentLink(const App::PropertyLinkSub &lnk);
QComboBox& combo(void) const {assert(_combo); return *_combo;}; QComboBox& combo(void) const {assert(_combo); return *_combo;}
~ComboLinks() {_combo = 0; clear();}; ~ComboLinks() {_combo = 0; clear();}
private: private:
QComboBox* _combo; QComboBox* _combo;
App::Document* doc; App::Document* doc;