void TreeWidgetEditor::on_deleteItemButton_clicked() { QTreeWidgetItem *curItem = ui.treeWidget->currentItem(); if (!curItem) return; m_updating = true; QTreeWidgetItem *nextCurrent = 0; if (curItem->parent()) { int idx = curItem->parent()->indexOfChild(curItem); if (idx == curItem->parent()->childCount() - 1) idx--; else idx++; if (idx < 0) nextCurrent = curItem->parent(); else nextCurrent = curItem->parent()->child(idx); } else { int idx = ui.treeWidget->indexOfTopLevelItem(curItem); if (idx == ui.treeWidget->topLevelItemCount() - 1) idx--; else idx++; if (idx >= 0) nextCurrent = ui.treeWidget->topLevelItem(idx); } closeEditors(); delete curItem; if (nextCurrent) ui.treeWidget->setCurrentItem(nextCurrent, ui.listWidget->currentRow()); m_updating = false; updateEditor(); }
void TreeWidgetEditor::on_moveColumnDownButton_clicked() { QListWidgetItem *currentColumn = ui.listWidget->currentItem(); if (!currentColumn) return; int idx = ui.listWidget->currentRow(); int columnCount = ui.treeWidget->columnCount(); if (idx == columnCount - 1) return; m_updating = true; moveColumnsLeft(idx, idx + 1); ui.listWidget->takeItem(idx); ui.listWidget->insertItem(idx + 1, currentColumn); ui.listWidget->setCurrentItem(currentColumn); ui.treeWidget->setCurrentItem(ui.treeWidget->currentItem(), ui.listWidget->currentRow()); m_updating = false; updateEditor(); }
void TreeWidgetEditor::on_deleteColumnButton_clicked() { QListWidgetItem *currentColumn = ui.listWidget->currentItem(); if (!currentColumn) return; m_updating = true; int idx = ui.listWidget->currentRow(); int columnCount = ui.treeWidget->columnCount(); moveColumnsRight(idx, columnCount - 1); ui.treeWidget->setColumnCount(columnCount - 1); closeEditors(); delete currentColumn; if (idx == columnCount - 1) idx--; if (idx >= 0) ui.listWidget->setCurrentRow(idx); m_updating = false; updateEditor(); }
void TreeWidgetEditor::on_moveItemLeftButton_clicked() { QTreeWidgetItem *curItem = ui.treeWidget->currentItem(); if (!curItem) return; QTreeWidgetItem *parentItem = curItem->parent(); if (!parentItem) return; ui.treeWidget->blockSignals(true); QTreeWidgetItem *takenItem = parentItem->takeChild(parentItem->indexOfChild(curItem)); if (parentItem->parent()) { int idx = parentItem->parent()->indexOfChild(parentItem); parentItem->parent()->insertChild(idx, takenItem); } else { int idx = ui.treeWidget->indexOfTopLevelItem(parentItem); ui.treeWidget->insertTopLevelItem(idx, takenItem); } ui.treeWidget->blockSignals(false); ui.treeWidget->setCurrentItem(takenItem, ui.treeWidget->currentColumn()); updateEditor(); }
TreeWidgetContents TreeWidgetEditor::fillContentsFromTreeWidget(QTreeWidget *treeWidget) { TreeWidgetContents treeCont; treeCont.fromTreeWidget(treeWidget, false); treeCont.applyToTreeWidget(ui.treeWidget, iconCache(), true); treeCont.m_headerItem.applyToListWidget(m_columnEditor->listWidget(), iconCache(), true); m_columnEditor->setupEditor(treeWidget, treeHeaderPropList); QList<QtVariantProperty*> rootProperties; rootProperties.append(setupPropertyGroup(tr("Per column properties"), treeItemColumnPropList)); rootProperties.append(setupPropertyGroup(tr("Common properties"), treeItemCommonPropList)); m_rootProperties = rootProperties; m_propertyBrowser->setPropertiesWithoutValueMarked(true); m_propertyBrowser->setRootIsDecorated(false); setupObject(treeWidget); if (ui.treeWidget->topLevelItemCount() > 0) ui.treeWidget->setCurrentItem(ui.treeWidget->topLevelItem(0)); updateEditor(); return treeCont; }
void TreeWidgetEditor::on_listWidget_itemChanged(QListWidgetItem *) { if (m_updating) return; updateEditor(); }
LLSpinCtrl::LLSpinCtrl(const LLSpinCtrl::Params& p) : LLF32UICtrl(p), mLabelBox(NULL), mbHasBeenSet( FALSE ), mPrecision(p.decimal_digits), mTextEnabledColor(p.text_enabled_color()), mTextDisabledColor(p.text_disabled_color()) { static LLUICachedControl<S32> spinctrl_spacing ("UISpinctrlSpacing", 0); static LLUICachedControl<S32> spinctrl_btn_width ("UISpinctrlBtnWidth", 0); static LLUICachedControl<S32> spinctrl_btn_height ("UISpinctrlBtnHeight", 0); S32 centered_top = getRect().getHeight(); S32 centered_bottom = getRect().getHeight() - 2 * spinctrl_btn_height; S32 btn_left = 0; // reserve space for spinner S32 label_width = llclamp(p.label_width(), 0, llmax(0, getRect().getWidth() - 40)); // Label if( !p.label().empty() ) { LLRect label_rect( 0, centered_top, label_width, centered_bottom ); LLTextBox::Params params; params.wrap(p.label_wrap); params.name("SpinCtrl Label"); params.rect(label_rect); params.initial_value(p.label()); if (p.font.isProvided()) { params.font(p.font); } mLabelBox = LLUICtrlFactory::create<LLTextBox> (params); addChild(mLabelBox); btn_left += label_rect.mRight + spinctrl_spacing; } S32 btn_right = btn_left + spinctrl_btn_width; // Spin buttons LLButton::Params up_button_params(p.up_button); up_button_params.rect = LLRect(btn_left, getRect().getHeight(), btn_right, getRect().getHeight() - spinctrl_btn_height); up_button_params.click_callback.function(boost::bind(&LLSpinCtrl::onUpBtn, this, _2)); up_button_params.mouse_held_callback.function(boost::bind(&LLSpinCtrl::onUpBtn, this, _2)); mUpBtn = LLUICtrlFactory::create<LLButton>(up_button_params); addChild(mUpBtn); LLButton::Params down_button_params(p.down_button); down_button_params.rect = LLRect(btn_left, getRect().getHeight() - spinctrl_btn_height, btn_right, getRect().getHeight() - 2 * spinctrl_btn_height); down_button_params.click_callback.function(boost::bind(&LLSpinCtrl::onDownBtn, this, _2)); down_button_params.mouse_held_callback.function(boost::bind(&LLSpinCtrl::onDownBtn, this, _2)); mDownBtn = LLUICtrlFactory::create<LLButton>(down_button_params); addChild(mDownBtn); LLRect editor_rect( btn_right + 1, centered_top, getRect().getWidth(), centered_bottom ); LLLineEditor::Params params; params.name("SpinCtrl Editor"); params.rect(editor_rect); if (p.font.isProvided()) { params.font(p.font); } params.max_length.bytes(MAX_STRING_LENGTH); params.commit_callback.function((boost::bind(&LLSpinCtrl::onEditorCommit, this, _2))); //*NOTE: allow entering of any chars for LLCalc, proper input will be evaluated on commit params.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM); mEditor = LLUICtrlFactory::create<LLLineEditor> (params); mEditor->setFocusReceivedCallback( boost::bind(&LLSpinCtrl::onEditorGainFocus, _1, this )); //RN: this seems to be a BAD IDEA, as it makes the editor behavior different when it has focus // than when it doesn't. Instead, if you always have to double click to select all the text, // it's easier to understand //mEditor->setSelectAllonFocusReceived(TRUE); mEditor->setSelectAllonCommit(FALSE); addChild(mEditor); updateEditor(); setUseBoundingRect( TRUE ); }
LLSpinCtrl::LLSpinCtrl( const std::string& name, const LLRect& rect, const std::string& label, const LLFontGL* font, void (*commit_callback)(LLUICtrl*, void*), void* callback_user_data, F32 initial_value, F32 min_value, F32 max_value, F32 increment, const std::string& control_name, S32 label_width) : LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data, FOLLOWS_LEFT | FOLLOWS_TOP ), mValue( initial_value ), mInitialValue( initial_value ), mMaxValue( max_value ), mMinValue( min_value ), mIncrement( increment ), mPrecision( 3 ), mLabelBox( NULL ), mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ), mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ), mbHasBeenSet( FALSE ) { S32 top = getRect().getHeight(); S32 bottom = top - 2 * SPINCTRL_BTN_HEIGHT; S32 centered_top = top; S32 centered_bottom = bottom; S32 btn_left = 0; // Label if( !label.empty() ) { LLRect label_rect( 0, centered_top, label_width, centered_bottom ); mLabelBox = new LLTextBox( std::string("SpinCtrl Label"), label_rect, label, font ); addChild(mLabelBox); btn_left += label_rect.mRight + SPINCTRL_SPACING; } S32 btn_right = btn_left + SPINCTRL_BTN_WIDTH; // Spin buttons LLRect up_rect( btn_left, top, btn_right, top - SPINCTRL_BTN_HEIGHT ); std::string out_id = "UIImgBtnSpinUpOutUUID"; std::string in_id = "UIImgBtnSpinUpInUUID"; mUpBtn = new LLButton(std::string("SpinCtrl Up"), up_rect, out_id, in_id, LLStringUtil::null, &LLSpinCtrl::onUpBtn, this, LLFontGL::getFontSansSerif() ); mUpBtn->setFollowsLeft(); mUpBtn->setFollowsBottom(); mUpBtn->setHeldDownCallback( &LLSpinCtrl::onUpBtn ); mUpBtn->setTabStop(FALSE); addChild(mUpBtn); LLRect down_rect( btn_left, top - SPINCTRL_BTN_HEIGHT, btn_right, bottom ); out_id = "UIImgBtnSpinDownOutUUID"; in_id = "UIImgBtnSpinDownInUUID"; mDownBtn = new LLButton(std::string("SpinCtrl Down"), down_rect, out_id, in_id, LLStringUtil::null, &LLSpinCtrl::onDownBtn, this, LLFontGL::getFontSansSerif() ); mDownBtn->setFollowsLeft(); mDownBtn->setFollowsBottom(); mDownBtn->setHeldDownCallback( &LLSpinCtrl::onDownBtn ); mDownBtn->setTabStop(FALSE); addChild(mDownBtn); LLRect editor_rect( btn_right + 1, centered_top, getRect().getWidth(), centered_bottom ); mEditor = new LLLineEditor( std::string("SpinCtrl Editor"), editor_rect, LLStringUtil::null, font, MAX_STRING_LENGTH, &LLSpinCtrl::onEditorCommit, NULL, NULL, this, &LLLineEditor::prevalidateFloat ); mEditor->setFollowsLeft(); mEditor->setFollowsBottom(); mEditor->setFocusReceivedCallback( &LLSpinCtrl::onEditorGainFocus, this ); //RN: this seems to be a BAD IDEA, as it makes the editor behavior different when it has focus // than when it doesn't. Instead, if you always have to double click to select all the text, // it's easier to understand //mEditor->setSelectAllonFocusReceived(TRUE); mEditor->setIgnoreTab(TRUE); addChild(mEditor); updateEditor(); setUseBoundingRect( TRUE ); }
void TreeWidgetEditor::on_treeWidget_currentItemChanged() { m_columnEditor->setCurrentIndex(ui.treeWidget->currentColumn()); updateEditor(); }
/** * Implements update from RPropertyListener. */ void RPropertyEditor::updateFromObject(RObject* object, RDocument* document) { if (object != NULL) { updateEditor(*object, true, document); } }
/** * Updates the property editor to contain the properties of the * property owners that are selected for editing in the given * property owner container. */ void RPropertyEditor::updateFromDocument(RDocument* document, bool onlyChanges, RS::EntityType entityTypeFilter) { if (updatesDisabled) { return; } if (document == NULL) { clearEditor(); return; } combinedProperties.clear(); combinedTypes.clear(); propertyOrder.clear(); groupOrder.clear(); updatesDisabled = true; // add all properties of the entities in the given document: QSet<RObject::Id> entityIds = document->querySelectedEntities(); QSet<RObject::Id>::iterator it; for (it = entityIds.begin(); it != entityIds.end(); ++it) { QSharedPointer<REntity> entity = document->queryEntityDirect(*it); if (entity.isNull()) { continue; } if (entityTypeFilter!=RS::EntityAll && entity->getType()!=entityTypeFilter) { continue; } updateEditor(*entity.data(), false, document); } // remove properties that are not shared by all selected entities: for (it = entityIds.begin(); it != entityIds.end(); ++it) { QSharedPointer<REntity> entity = document->queryEntityDirect(*it); if (entity.isNull()) { continue; } QPair<QVariant, RPropertyAttributes> p = entity->getProperty(REntity::PropertyType); RS::EntityType type = (RS::EntityType)p.first.toInt(); if (combinedTypes.contains(type)) { combinedTypes[type]++; } else { combinedTypes.insert(type, 1); } if (entityTypeFilter!=RS::EntityAll && entity->getType()!=entityTypeFilter) { continue; } QSet<RPropertyTypeId> propertyTypeIds = entity->getPropertyTypeIds(); QMultiMap<QString, QString> propertiesToKeep; QSet<RPropertyTypeId>::iterator it; for (it = propertyTypeIds.begin(); it != propertyTypeIds.end(); ++it) { propertiesToKeep.insert(it->getPropertyGroupTitle(), it->getPropertyTitle()); } removeAllButThese(propertiesToKeep); } updateGui(onlyChanges, entityTypeFilter); updatesDisabled = false; }
/** * Updates the property editor to contain the properties of the * objects that are selected for editing in the given document. */ void RPropertyEditor::updateFromDocument(RDocument* document, bool onlyChanges, RS::EntityType entityTypeFilter, bool manual) { if (updatesDisabled) { return; } if (document == NULL) { clearEditor(); return; } combinedProperties.clear(); combinedTypes.clear(); propertyOrder.clear(); groupOrder.clear(); updatesDisabled = true; // add all properties of the selected entities in the given document: QSet<RObject::Id> objectIds = document->queryPropertyEditorObjects(); QSet<RObject::Id>::iterator it; // only block ref and attributes selected: default to filter block ref: if (entityTypeFilter==RS::EntityAll && !manual) { bool foundBlockRef = false; bool foundAttribute = false; bool foundOther = false; for (it = objectIds.begin(); it != objectIds.end(); ++it) { QSharedPointer<RObject> obj = document->queryObjectDirect(*it); if (obj.isNull()) { continue; } if (!foundBlockRef && obj->getType()==RS::EntityBlockRef) { foundBlockRef = true; if (foundAttribute && foundOther) { break; } } if (!foundAttribute && obj->getType()==RS::EntityAttribute) { foundAttribute = true; if (foundBlockRef && foundOther) { break; } } if (!foundOther && obj->getType()!=RS::EntityBlockRef && obj->getType()!=RS::EntityAttribute) { foundOther = true; if (foundBlockRef && foundAttribute) { break; } } } if (foundBlockRef && foundAttribute && !foundOther) { entityTypeFilter = RS::EntityBlockRefAttr; } } for (it = objectIds.begin(); it != objectIds.end(); ++it) { QSharedPointer<RObject> obj = document->queryObjectDirect(*it); if (obj.isNull()) { continue; } if (entityTypeFilter!=RS::EntityAll && !checkType(obj->getType(), entityTypeFilter)) { continue; } updateEditor(*obj.data(), false, document); } RS::EntityType entityTypeFilterProp = entityTypeFilter; if (entityTypeFilterProp==RS::EntityBlockRefAttr) { // only block ref and attributes selected: show only block ref properties: entityTypeFilterProp = RS::EntityBlockRef; } // remove properties that are not shared by all selected entities: for (it = objectIds.begin(); it != objectIds.end(); ++it) { QSharedPointer<RObject> obj = document->queryObjectDirect(*it); if (obj.isNull()) { continue; } QPair<QVariant, RPropertyAttributes> p = obj->getProperty(REntity::PropertyType); RS::EntityType type = (RS::EntityType)p.first.toInt(); if (entityTypeFilterProp==RS::EntityAll || obj->getType()==entityTypeFilterProp) { bool customOnly = false; QSet<RPropertyTypeId> propertyTypeIds; if (combinedTypes.contains(type)) { // already filtered out property type IDs of this type, // only look into custom properties: propertyTypeIds = obj->getCustomPropertyTypeIds(); customOnly = true; } else { // not filtered out this type yet, look into all properties: propertyTypeIds = obj->getPropertyTypeIds(); } if (!propertyTypeIds.isEmpty()) { QMultiMap<QString, QString> propertiesToKeep; QSet<RPropertyTypeId>::iterator it; for (it = propertyTypeIds.begin(); it != propertyTypeIds.end(); ++it) { propertiesToKeep.insert(it->getPropertyGroupTitle(), it->getPropertyTitle()); } removeAllButThese(propertiesToKeep, customOnly); } } if (combinedTypes.contains(type)) { combinedTypes[type]++; } else { combinedTypes.insert(type, 1); } } if (combinedTypes.contains(RS::EntityBlockRef) && combinedTypes.contains(RS::EntityAttribute)) { combinedTypes.insert(RS::EntityBlockRefAttr, combinedTypes[RS::EntityBlockRef] + combinedTypes[RS::EntityBlockRefAttr]); } updateGui(onlyChanges, entityTypeFilter); updatesDisabled = false; }
void SmartAttributeEditorManager::switchEditor(const Model::AttributeName& name, const Model::AttributableNodeList& attributables) { EditorPtr editor = selectEditor(name, attributables); activateEditor(editor, name); updateEditor(); }