void ObjectTypesEditor::renamePropertyTo(const QString &name) { if (name.isEmpty()) return; QtBrowserItem *item = mUi->propertiesView->currentItem(); if (!item) return; const QString oldName = item->property()->propertyName(); if (oldName == name) return; const auto selectionModel = mUi->objectTypesTable->selectionModel(); const auto selectedRows = selectionModel->selectedRows(); for (const QModelIndex &index : selectedRows) { Properties properties = mObjectTypesModel->objectTypeAt(index).defaultProperties; if (properties.contains(oldName)) properties.insert(name, properties.take(oldName)); mObjectTypesModel->setObjectTypeProperties(index.row(), properties); } applyObjectTypes(); updateProperties(); }
void IqtFit::unFixItem() { QtBrowserItem *item = m_ffTree->currentItem(); QtProperty *prop = item->property(); if (prop->subProperties().empty()) { item = item->parent(); prop = item->property(); } item->parent()->property()->addSubProperty(m_fixedProps[prop]); item->parent()->property()->removeSubProperty(prop); m_fixedProps.remove(prop); QtProperty *proplbl = prop->subProperties()[0]; delete proplbl; delete prop; }
void MainWindow::updateExpandState() { QList<QtBrowserItem *> list = propertyEditor->topLevelItems(); QListIterator<QtBrowserItem *> it(list); while (it.hasNext()) { QtBrowserItem *item = it.next(); QtProperty *prop = item->property(); idToExpanded[propertyToId[prop]] = propertyEditor->isExpanded(item); } }
void PropertyBrowser::updateExpandState() { QList<QtBrowserItem *> list = QtTreePropertyBrowser::topLevelItems(); QListIterator<QtBrowserItem *> it(list); while (it.hasNext()) { QtBrowserItem *item = it.next(); QtProperty *prop = item->property(); m_idToExpanded[m_propertyToId[prop]] = QtTreePropertyBrowser::isExpanded(item); } }
void PropertyEditor::updateColors() { if (m_treeBrowser && m_currentBrowser == m_treeBrowser) { QList<QtBrowserItem *> items = m_treeBrowser->topLevelItems(); QListIterator<QtBrowserItem *> itItem(items); while (itItem.hasNext()) { QtBrowserItem *item = itItem.next(); m_treeBrowser->setBackgroundColor(item, propertyColor(item->property())); } } }
void PropertiesDock::removeProperty() { QtBrowserItem *item = mPropertyBrowser->currentItem(); Object *object = mMapDocument->currentObject(); if (!item || !object) return; const QString name = item->property()->propertyName(); QUndoStack *undoStack = mMapDocument->undoStack(); undoStack->push(new RemoveProperty(mMapDocument, mMapDocument->currentObjects(), name)); // TODO: Would be nice to automatically select the next property }
void IqtFit::fixItem() { QtBrowserItem *item = m_ffTree->currentItem(); // Determine what the property is. QtProperty *prop = item->property(); QtProperty *fixedProp = m_stringManager->addProperty(prop->propertyName()); QtProperty *fprlbl = m_stringManager->addProperty("Fixed"); fixedProp->addSubProperty(fprlbl); m_stringManager->setValue(fixedProp, prop->valueText()); item->parent()->property()->addSubProperty(fixedProp); m_fixedProps[fixedProp] = prop; item->parent()->property()->removeSubProperty(prop); }
void PropertiesDock::renameProperty() { QtBrowserItem *item = mPropertyBrowser->currentItem(); if (!mPropertyBrowser->isCustomPropertyItem(item)) return; const QString oldName = item->property()->propertyName(); QInputDialog *dialog = new QInputDialog(mPropertyBrowser); dialog->setInputMode(QInputDialog::TextInput); dialog->setLabelText(tr("Name:")); dialog->setTextValue(oldName); dialog->setWindowTitle(tr("Rename Property")); dialog->open(this, SLOT(renamePropertyTo(QString))); }
void ObjectTypesEditor::renameProperty() { QtBrowserItem *item = mUi->propertiesView->currentItem(); if (!item) return; const QString oldName = item->property()->propertyName(); QInputDialog *dialog = new QInputDialog(mUi->propertiesView); dialog->setInputMode(QInputDialog::TextInput); dialog->setLabelText(tr("Name:")); dialog->setTextValue(oldName); dialog->setWindowTitle(tr("Rename Property")); dialog->open(this, SLOT(renamePropertyTo(QString))); }
int PropertyEditor::applyPropertiesFilter(const QList<QtBrowserItem *> &items) { int showCount = 0; const bool matchAll = m_filterPattern.isEmpty(); QListIterator<QtBrowserItem *> itProperty(items); while (itProperty.hasNext()) { QtBrowserItem *propertyItem = itProperty.next(); QtProperty *property = propertyItem->property(); const QString propertyName = property->propertyName(); const bool showProperty = matchAll || propertyName.contains(m_filterPattern, Qt::CaseInsensitive); setItemVisible(propertyItem, showProperty); if (showProperty) showCount++; } return showCount; }
void PropertiesDock::renameProperty(const QString &name) { if (name.isEmpty()) return; QtBrowserItem *item = mPropertyBrowser->currentItem(); if (!item) return; const QString oldName = item->property()->propertyName(); if (oldName == name) return; QUndoStack *undoStack = mMapDocument->undoStack(); undoStack->push(new RenameProperty(mMapDocument, mMapDocument->currentObjects(), oldName, name)); }
void GeneralTreeBrowser::contextMenuEvent(QContextMenuEvent *evt) { QtBrowserItem *citem = currentItem(); if(citem == 0) return; CBaseEditor *e = OgitorsRoot::getSingletonPtr()->GetSelection()->getAsSingle(); LastProperty = static_cast<GeneralPropertiesViewWidget*>(parent())->getOgitorProperty(citem->property()); if(!LastProperty) LastPropertyName = citem->property()->propertyName(); else LastPropertyName = LastProperty->getName().c_str(); if(e != 0) { UTFStringVector menuList; e->getPropertyContextMenu(LastPropertyName.toStdString(), menuList); if(menuList.size() > 0) { UTFStringVector vList; int counter = 0; QMenu* contextMenu = new QMenu(this); QSignalMapper *signalMapper = new QSignalMapper(this); for(unsigned int i = 0;i < menuList.size();i++) { OgitorsUtils::ParseUTFStringVector(menuList[i], vList); if(vList.size() > 0 && vList[0] != "") { QAction *item = contextMenu->addAction( ConvertToQString(vList[0]), signalMapper, SLOT(map()), 0); if(vList.size() > 1) item->setIcon(QIcon(ConvertToQString(vList[1]))); signalMapper->setMapping(item, i); counter++; } } if(counter) { connect(signalMapper, SIGNAL(mapped( int )), this, SLOT(contextMenu( int ))); contextMenu->exec(QCursor::pos()); } delete contextMenu; delete signalMapper; }
void PropertyEditor::storePropertiesExpansionState(const QList<QtBrowserItem *> &items) { const QChar bar = QLatin1Char('|'); QListIterator<QtBrowserItem *> itProperty(items); while (itProperty.hasNext()) { QtBrowserItem *propertyItem = itProperty.next(); if (!propertyItem->children().empty()) { QtProperty *property = propertyItem->property(); const QString propertyName = property->propertyName(); const QMap<QtProperty *, QString>::const_iterator itGroup = m_propertyToGroup.constFind(property); if (itGroup != m_propertyToGroup.constEnd()) { QString key = itGroup.value(); key += bar; key += propertyName; m_expansionState[key] = isExpanded(propertyItem); } } } }
void PropertyEditor::storeExpansionState() { const QList<QtBrowserItem *> items = m_currentBrowser->topLevelItems(); if (m_sorting) { storePropertiesExpansionState(items); } else { QListIterator<QtBrowserItem *> itGroup(items); while (itGroup.hasNext()) { QtBrowserItem *item = itGroup.next(); const QString groupName = item->property()->propertyName(); QList<QtBrowserItem *> propertyItems = item->children(); if (!propertyItems.empty()) m_expansionState[groupName] = isExpanded(item); // properties stuff here storePropertiesExpansionState(propertyItems); } } }
void PropertyEditor::applyExpansionState() { const QList<QtBrowserItem *> items = m_currentBrowser->topLevelItems(); if (m_sorting) { applyPropertiesExpansionState(items); } else { QListIterator<QtBrowserItem *> itTopLevel(items); const QMap<QString, bool>::const_iterator excend = m_expansionState.constEnd(); while (itTopLevel.hasNext()) { QtBrowserItem *item = itTopLevel.next(); const QString groupName = item->property()->propertyName(); const QMap<QString, bool>::const_iterator git = m_expansionState.constFind(groupName); if (git != excend) setExpanded(item, git.value()); else setExpanded(item, true); // properties stuff here applyPropertiesExpansionState(item->children()); } } }
// The current property item is changed. Update the help box. void GenericHID::onPropertiesCurrentItemChanged( QtBrowserItem * current ) { // Set the help text if ( current == NULL || current->property() == NULL ) ui.textBrowser->setSource( QString(":index.html") ); else { QString sText = current->property()->toolTip(); if ( sText.isEmpty() ) { QtBrowserItem * item = current; while ( (item = item->parent()) != NULL ) { sText = item->property()->toolTip(); if ( !sText.isEmpty() ) break; } } ui.textBrowser->setSource( sText ); } }
void ObjectTypesEditor::removeProperty() { QtBrowserItem *item = mUi->propertiesView->currentItem(); if (!item) return; const QString name = item->property()->propertyName(); QList<QtBrowserItem *> items = mUi->propertiesView->topLevelItems(); if (items.count() > 1) { int currentItemIndex = items.indexOf(item); if (item == items.last()) { mUi->propertiesView->setCurrentItem(items.at(currentItemIndex - 1)); } else { mUi->propertiesView->setCurrentItem(items.at(currentItemIndex + 1)); } } mProperties.remove(name); delete mNameToProperty.take(name); removePropertyFromSelectedTypes(name); }
void PropertyEditor::applyPropertiesExpansionState(const QList<QtBrowserItem *> &items) { const QChar bar = QLatin1Char('|'); QListIterator<QtBrowserItem *> itProperty(items); while (itProperty.hasNext()) { const QMap<QString, bool>::const_iterator excend = m_expansionState.constEnd(); QtBrowserItem *propertyItem = itProperty.next(); QtProperty *property = propertyItem->property(); const QString propertyName = property->propertyName(); const QMap<QtProperty *, QString>::const_iterator itGroup = m_propertyToGroup.constFind(property); if (itGroup != m_propertyToGroup.constEnd()) { QString key = itGroup.value(); key += bar; key += propertyName; const QMap<QString, bool>::const_iterator pit = m_expansionState.constFind(key); if (pit != excend) setExpanded(propertyItem, pit.value()); else setExpanded(propertyItem, false); } } }