Database* DataType::database() const { return dynamic_cast<Database*>(parent()); }
//最后一个内部节点(即末节点的父亲) Rank lastInternal(Rank n) { return parent(n-1); }
bool WEXPORT WBoolSwitch::checked() { /***********************************/ return( GUIIsChecked( parent()->handle(), controlId() ) != 0 ); }
int ElementFinder::FindElementsUsingSizzle(const IECommandExecutor& executor, const ElementHandle parent_wrapper, const std::wstring& criteria, Json::Value* found_elements) { LOG(TRACE) << "Entering ElementFinder::FindElementsUsingSizzle"; int result; BrowserHandle browser; result = executor.GetCurrentBrowser(&browser); if (result != WD_SUCCESS) { LOG(WARN) << "Unable to get browser"; return result; } std::wstring script_source(L"(function() { return function(){ if (!window.Sizzle) {"); script_source += atoms::asString(atoms::SIZZLE); script_source += L"}\n"; script_source += L"var root = arguments[1] ? arguments[1] : document.documentElement;"; script_source += L"if (root['querySelectorAll']) { return root.querySelectorAll(arguments[0]); } "; script_source += L"var results = []; Sizzle(arguments[0], root, results);"; script_source += L"return results;"; script_source += L"};})();"; CComPtr<IHTMLDocument2> doc; browser->GetDocument(&doc); Script script_wrapper(doc, script_source, 2); script_wrapper.AddArgument(criteria); if (parent_wrapper) { // Use a copy for the parent element? CComPtr<IHTMLElement> parent(parent_wrapper->element()); script_wrapper.AddArgument(parent); } result = script_wrapper.Execute(); if (result == WD_SUCCESS) { CComVariant snapshot = script_wrapper.result(); std::wstring get_element_count_script = L"(function(){return function() {return arguments[0].length;}})();"; Script get_element_count_script_wrapper(doc, get_element_count_script, 1); get_element_count_script_wrapper.AddArgument(snapshot); result = get_element_count_script_wrapper.Execute(); if (result == WD_SUCCESS) { if (!get_element_count_script_wrapper.ResultIsInteger()) { LOG(WARN) << "Found elements count is not integer"; result = EUNEXPECTEDJSERROR; } else { long length = get_element_count_script_wrapper.result().lVal; std::wstring get_next_element_script = L"(function(){return function() {return arguments[0][arguments[1]];}})();"; for (long i = 0; i < length; ++i) { Script get_element_script_wrapper(doc, get_next_element_script, 2); get_element_script_wrapper.AddArgument(snapshot); get_element_script_wrapper.AddArgument(i); result = get_element_script_wrapper.Execute(); if (result == WD_SUCCESS) { Json::Value json_element; get_element_script_wrapper.ConvertResultToJsonValue(executor, &json_element); found_elements->append(json_element); } else { LOG(WARN) << "Unable to get " << i << " found element"; } } } } else { LOG(WARN) << "Unable to get count of found elements"; result = EUNEXPECTEDJSERROR; } } else { LOG(WARN) << "Execution returned error"; } return result; }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool Comment::detach() { if ( parent() == NULL ) return false; return detachFrom(parent()); }
void UmlItem::memo_relation(UmlItem * r) { parent()->memo_relation(r); }
void qt_dbtreemodel_impl::_update_list_row( list_row* it, const string& sql ) { if ( _db && _db->valid() && _root && _parent && it ) { //QModelIndex parent; list_row* _add = new list_row(_db, it->rowkeyfield(), it->level(), it->parent()); _add->exec(sql.c_str()); list_row::iterator i = it->begin(); while (i!=it->end()) { list_row::iterator p = find_if(_add->begin(), _add->end(), prow_eq(*i)); if (p == _add->end()) { // элемент не найден, лишний удалить row* r = *i; _parent->beginRemoveRows(parent(r), i-it->begin(), i-it->begin()); i = it->erase(i); delete r; _parent->endRemoveRows(); continue; } ++i; } size_t j = 0; i = _add->begin(); map<size_t, row*> to_ins; map<size_t, row*> to_upd; map<size_t, row*>::iterator tmp; while(i!=_add->end()) { list_row::iterator p = find_if(it->begin(), it->end(), prow_eq(*i)); if (p != it->end()) { // update while (1) { tmp = to_upd.find((p-(it->begin()))); if (tmp == to_upd.end()) { to_upd[(p-(it->begin()))] = *i; break; } p = find_if(p+1, it->end(), prow_eq(*i)); if (p == it->end()) break; } } else { // insert to_ins[j] = *i; i = _add->erase(i); ++j; continue; } ++j; ++i; } tmp = to_upd.begin(); while(tmp != to_upd.end()) { j = tmp->first; row* r = (*it)[j]; r->swap(*tmp->second); QModelIndex iparent = parent(r); _parent->dataChanged(index(j, 0, iparent), index(j, _cc, iparent)); ++tmp; list_row* children = r->children(); if (children) _update_list_row(children, children->sql()); } tmp = to_ins.begin(); while(tmp != to_ins.end()) { j = tmp->first; row* r = tmp->second; if (j >= it->size()) { _parent->beginInsertRows(parent(r), it->size(), it->size()); it->insert(it->end(), r); _parent->endInsertRows(); } else { _parent->beginInsertRows(parent(r), j, j); it->insert(it->begin() + j, r); _parent->endInsertRows(); } ++tmp; } delete _add; } }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool ConfigModule::detach() { if ( parent() == NULL ) return false; return detachFrom(parent()); }
void Clef::layout() { // determine current number of lines and line distance int lines = 5; // assume resonable defaults qreal lineDist = 1.0; Staff* stf = staff(); StaffType* staffType = nullptr; Segment* clefSeg = static_cast<Segment*>(parent()); // check clef visibility and type compatibility if (clefSeg && stf && stf->staffType()) { bool bHide; // check staff type allows clef display staffType = staff()->staffType(); #if 0 // <<<<<<< HEAD if (!staffType->genClef()) { // if no clef, set empty bbox and do nothing qDeleteAll(elements); elements.clear(); setbbox(QRectF()); return; } // tablatures: if (staffType->group() == StaffGroup::TAB) { // if current clef type not compatible with tablature, // set tab clef according to score style if (ClefInfo::staffGroup(clefType()) != StaffGroup::TAB) setClefType( ClefType(score()->styleI(StyleIdx::tabClef)) ); #else bHide = !staffType->genClef(); // check clef is compatible with staff type group int tick = clefSeg->tick(); if (ClefInfo::staffGroup(clefType()) != staffType->group()) { if (tick > 0 && !generated()) // if clef is not generated, hide it bHide = true; else // if generated, replace with initial clef type // TODO : instead of initial staff clef (which is assumed to be compatible) // use the last compatible clef previously found in staff _clefTypes = stf->clefTypeList(0); #endif // >>>>>>> 38c666fa91f5bdaaa6d9ca0645c437c799be8c79 } // // courtesy clef // bool showClef = true; #if 0 // <<<<<<< HEAD Segment* clefSeg = static_cast<Segment*>(parent()); if (clefSeg) { int tick = clefSeg->tick(); // only if there is a clef change if (stf->clef(tick) != stf->clef(tick-1)) { // locate clef at the begining of next measure, if any Clef* clefNext = nullptr; Segment* clefSegNext = nullptr; Measure* meas = static_cast<Measure*>(clefSeg->parent()); Measure* measNext = meas->nextMeasure(); if (measNext) { clefSegNext = measNext->findSegment(SegmentType::Clef, tick); if (clefSegNext) clefNext = static_cast<Clef*>(clefSegNext->element(track())); } // show this clef if: it is not a courtesy clef (no next clef or not at the end of the measure) showClef = !clefNext || (clefSeg->tick() != meas->tick() + meas->ticks()) // if courtesy clef: show if score has courtesy clefs on || ( score()->styleB(StyleIdx::genCourtesyClef) // AND measure is not at the end of a repeat or of a section && !( (meas->repeatFlags() & Repeat::END) || meas->sectionBreak() ) // AND this clef has courtesy clef turned on && showCourtesy() ); if (!showClef) { // if no clef, set empty bbox and do nothing qDeleteAll(elements); elements.clear(); setbbox(QRectF()); return; } #else // only if there is a clef change if (!bHide && tick > 0 && stf->clef(tick) != stf->clef(tick-1)) { // locate clef at the begining of next measure, if any Clef* clefNext = nullptr; Segment* clefSegNext = nullptr; Measure* meas = static_cast<Measure*>(clefSeg->parent()); Measure* measNext = meas->nextMeasure(); if (measNext) { clefSegNext = measNext->findSegment(SegmentType::Clef, tick); if (clefSegNext) clefNext = static_cast<Clef*>(clefSegNext->element(track())); #endif // >>>>>>> 38c666fa91f5bdaaa6d9ca0645c437c799be8c79 } // show this clef if: it is not a courtesy clef (no next clef or not at the end of the measure) showClef = !clefNext || (clefSeg->tick() != meas->tick() + meas->ticks()) // if courtesy clef: show if score has courtesy clefs on || ( score()->styleB(StyleIdx::genCourtesyClef) // AND measure is not at the end of a repeat or of a section && !( (meas->repeatFlags() & Repeat::END) || meas->sectionBreak() ) // AND this clef has courtesy clef turned on && showCourtesy() ); bHide |= !showClef; } // if clef not to show or not compatible with staff group if (bHide) { qDeleteAll(elements); // set empty bbox and do nothing elements.clear(); setbbox(QRectF()); return; } lines = staffType->lines(); // init values from staff type lineDist = staffType->lineDistance().val(); } // if nothing changed since last layout, do nothing //DEBUG if (curClefType == clefType() && curLines == lines && curLineDist == lineDist) // return; // if something has changed, cache new values and re-layout curClefType = clefType(); curLines = lines; curLineDist = lineDist; layout1(); } //--------------------------------------------------------- // layout1 //--------------------------------------------------------- void Clef::layout1() { qreal smag = mag(); qreal _spatium = spatium(); // qreal msp = score()->spatium() * smag; qreal yoff = 0.0; qDeleteAll(elements); elements.clear(); Symbol* symbol = new Symbol(score()); switch (curClefType) { case ClefType::G: // G clef on 2nd line symbol->setSym(SymId::gClef); yoff = 3.0 * curLineDist; break; case ClefType::G1: // G clef 8va on 2nd line symbol->setSym(SymId::gClef8va); yoff = 3.0 * curLineDist; break; case ClefType::G2: // G clef 15ma on 2nd line symbol->setSym(SymId::gClef15ma); yoff = 3.0 * curLineDist; break; case ClefType::G3: // G clef 8vb on 2nd line symbol->setSym(SymId::gClef8vb); yoff = 3.0 * curLineDist; break; case ClefType::F: // F clef on penultimate line symbol->setSym(SymId::fClef); yoff = 1.0 * curLineDist; break; case ClefType::F8: // F clef 8va bassa on penultimate line symbol->setSym(SymId::fClef8vb); yoff = 1.0 * curLineDist; break; case ClefType::F15: // F clef 15ma bassa on penultimate line symbol->setSym(SymId::fClef15mb); yoff = 1.0 * curLineDist; break; case ClefType::F_B: // baritone clef symbol->setSym(SymId::fClef); yoff = 2.0 * curLineDist; break; case ClefType::F_C: // subbass clef symbol->setSym(SymId::fClef); yoff = 0.0; break; case ClefType::C1: // C clef in 1st line symbol->setSym(SymId::cClef); yoff = 4.0 * curLineDist; break; case ClefType::C2: // C clef on 2nd line symbol->setSym(SymId::cClef); yoff = 3.0 * curLineDist; break; case ClefType::C3: // C clef in 3rd line symbol->setSym(SymId::cClef); yoff = 2.0 * curLineDist; break; case ClefType::C4: // C clef on 4th line symbol->setSym(SymId::cClef); yoff = 1.0 * curLineDist; break; case ClefType::C5: // C clef on 5th line symbol->setSym(SymId::cClef); yoff = 0.0; break; case ClefType::TAB: // TAB clef symbol->setSym(SymId::sixStringTabClef); // on tablature, position clef at half the number of spaces * line distance yoff = curLineDist * (curLines - 1) * .5; break; case ClefType::TAB2: // TAB clef alternate style symbol->setSym(SymId::sixStringTabClefSerif); // on tablature, position clef at half the number of spaces * line distance yoff = curLineDist * (curLines - 1) * .5; break; case ClefType::PERC: // percussion clefs case ClefType::PERC2: // no longer supported: fall back to same glyph as PERC symbol->setSym(SymId::unpitchedPercussionClef1); yoff = curLineDist * (curLines - 1) * 0.5; break; case ClefType::G4: // G clef in 1st line symbol->setSym(SymId::gClef); yoff = 4.0 * curLineDist; break; case ClefType::F_8VA: // F clef 8va on penultimate line symbol->setSym(SymId::fClef8va); yoff = 1.0 * curLineDist; break; case ClefType::F_15MA: // F clef 15ma on penultimate line symbol->setSym(SymId::fClef15ma); yoff = 1.0 * curLineDist; break; case ClefType::INVALID: case ClefType::MAX: return; } symbol->setMag(smag); symbol->layout(); addElement(symbol, .0, yoff * _spatium); setbbox(QRectF()); for (auto i = elements.begin(); i != elements.end(); ++i) { Element* e = *i; e->setColor(curColor()); addbbox(e->bbox().translated(e->pos())); e->setSelected(selected()); } } //--------------------------------------------------------- // draw //--------------------------------------------------------- void Clef::draw(QPainter* painter) const { if (staff() && !staff()->staffType()->genClef()) return; QColor color(curColor()); foreach(Element* e, elements) { e->setColor(color); QPointF pt(e->pos()); painter->translate(pt); e->draw(painter); painter->translate(-pt); } }
void Configuration::modify() { static_cast<KConfigDialog*>(parent())->enableButtonApply(true); }
void Configuration::save() { KConfigGroup configuration = m_applet->config(); QStringList controls; if (m_controlsUi.openCheckBox->isChecked()) { controls.append("open"); } if (m_controlsUi.playPauseCheckBox->isChecked()) { controls.append("playPause"); } if (m_controlsUi.stopCheckBox->isChecked()) { controls.append("stop"); } if (m_controlsUi.playPreviousCheckBox->isChecked()) { controls.append("playPrevious"); } if (m_controlsUi.playNextCheckBox->isChecked()) { controls.append("playNext"); } if (m_controlsUi.positionCheckBox->isChecked()) { controls.append("position"); } if (m_controlsUi.volumeCheckBox->isChecked()) { controls.append("volume"); } if (m_controlsUi.muteCheckBox->isChecked()) { controls.append("mute"); } if (m_controlsUi.playlistCheckBox->isChecked()) { controls.append("playlist"); } if (m_controlsUi.fullScreenCheckBox->isChecked()) { controls.append("fullScreen"); } configuration.writeEntry("controls", controls); configuration.writeEntry("playOnStartup", m_generalUi.startPlaybackCheckBox->isChecked()); configuration.writeEntry("enableDBus", m_generalUi.dbusCheckBox->isChecked()); configuration.writeEntry("inhibitNotifications", m_generalUi.inhibitNotificationsCheckBox->isChecked()); configuration.writeEntry("showToolTipOnTrackChange", m_generalUi.showTooltipOnTrackChange->value()); static_cast<KConfigDialog*>(parent())->enableButtonApply(false); emit accepted(); }
CuteReport::BaseItemInterface * DummyBand::clone() { Q_D(DummyBand); return new DummyBand(*d, parent()); }
void UmlComponent::write(FileOut & out) { const char * k = (parent()->kind() == anUseCase) ? "ownedUseCase" : ((_uml_20) ? "ownedMember" : "packagedElement"); out.indent(); out << "<" << k << " xmi:type=\"uml:Component\""; out.id(this); out << " name=\""; out.quote((const char *)name()); //[jasa] ambiguous call out << "\">\n"; out.indent(+1); write_description_properties(out); const QVector<UmlItem*> ch = children(); unsigned n = ch.size(); unsigned index; for (index = 0; index != n; index += 1) ch[index]->write(out); // provided const QVector< UmlClass* > & prov = providedClasses(); n = prov.size(); for (index = 0; index != n; index += 1) { UmlClass * cl = prov[index]; out.indent(); out << "<interfaceRealization xmi:type=\"uml:InterfaceRealization\""; out.id_prefix(this, "PROV_", index); out.ref(cl, "supplier"); out.ref(this, "client"); out.ref(cl, "contract"); out << "/>\n"; } // realizing const QVector< UmlClass* > & rea = realizingClasses(); n = rea.size(); for (index = 0; index != n; index += 1) { UmlClass * cl = rea[index]; out.indent(); out << "<realization xmi:type=\"uml:ComponentRealization\""; out.id_prefix(this, "REA_", index); out.ref(cl, "supplier"); out.ref(this, "client"); out.ref(cl, "realizingClassifier"); out << "/>\n"; } out.indent(-1); out.indent(); out << "</" << k << ">\n"; // required const QVector< UmlClass* > & req = requiredClasses(); n = req.size(); for (index = 0; index != n; index += 1) { UmlClass * cl = req[index]; out.indent(); out << "<" << k << " xmi:type=\"uml:Usage\""; out.id_prefix(this, "REQ_", index); out.ref(cl, "supplier"); out.ref(this, "client"); out << "/>\n"; } unload(); }
QAction *ShortcutHandler::shortcutConfigAction() { Q_ASSERT_X(!m_shortcutConfigWidget, "ShortcutHandler", "a shortcut configuration dialog and a shortcut configuration widget cannot exist at the same time in one application"); if (!m_shortcutConfigAction) { m_shortcutConfigAction = new QAction(tr("Configure S&hortcuts..."), qobject_cast<QWidget*>(parent())); QObject::connect(m_shortcutConfigAction, SIGNAL(triggered()), this, SLOT(openShortcutConfigDialog())); } return m_shortcutConfigAction; }
KisNodeSP KisNode::nextSibling() const { if (!parent()) return 0; return parent()->at(parent()->index(const_cast<KisNode*>(this)) + 1); }
/*! This function is designed to be run by a different thread than Draw(), so we lock a mutex before changing the current images displayed. */ void ImageView::UpdateImage(BaseImgPtr imgPtr, ImageType type, const std::string& imageInfo, vpl::DisplaySpecs& specs) { m_mutex.Lock(); // We update either curImage or curRGBImage m_curByteImage.clear(); m_curRGBImage.clear(); m_curImgInfo = imageInfo; m_dispSpecs = specs; if (type == RGB_IMAGE) { m_curRGBImage.deep_copy(imgPtr); } else if (type == BYTE_IMAGE) { // We could more efficient and only copy the // image if its memory is borrowed (same for RGB). However, // it could happen that we need to redraw while the data is being changed // but before UpdateImage is called, and that may lead to strange outputs m_curByteImage.deep_copy(imgPtr); } else if (type == FLOAT_IMAGE) { FloatImg floatImg; floatImg.deep_copy(imgPtr); /*float min_b,max_b; vil_math_value_range(floatImg, min_b, max_b); DBG_PRINT2(min_b, max_b)*/ vil_convert_stretch_range(floatImg, m_curByteImage); } else if (type == INT_IMAGE) { IntImg intImg; intImg.deep_copy(imgPtr); vil_convert_stretch_range(intImg, m_curByteImage); } else if (type == VOID_IMAGE) { //ShowError("The component has no image output"); } else { ASSERT(false); } m_mutex.Release(); parent()->label(m_curImgInfo.c_str()); redraw(); }
void SourceFileModel::moveSourceFilesUpOrDown(QList<SourceFile *> files, bool up) { sortSourceFiles(files, !up); // qDebug() << "move up?" << up << "files" << files; auto couldNotBeMoved = QHash<SourceFile *, bool>{}; auto isSelected = QHash<SourceFile *, bool>{}; auto const direction = up ? -1 : +1; auto const topRows = rowCount(); for (auto const &file : files) { isSelected[file] = true; if (!file->isRegular() && isSelected[file->m_appendedTo]) continue; auto idx = indexFromSourceFile(file); Q_ASSERT(idx.isValid()); auto targetRow = idx.row() + direction; if (couldNotBeMoved[fromIndex(idx.sibling(targetRow, 0)).get()]) { couldNotBeMoved[file] = true; continue; } if (file->isRegular()) { if (!((0 <= targetRow) && (targetRow < topRows))) { couldNotBeMoved[file] = true; continue; } // qDebug() << "top level: would like to move" << idx.row() << "to" << targetRow; insertRow(targetRow, takeRow(idx.row())); continue; } auto parentItem = itemFromIndex(idx.parent()); auto const appendedAdditionalRows = countAppendedAndAdditionalParts(parentItem); auto const additionalPartsRows = appendedAdditionalRows.first; auto const appendedRows = appendedAdditionalRows.second; auto const lowerLimit = (file->isAdditionalPart() ? 0 : additionalPartsRows); auto const upperLimit = (file->isAdditionalPart() ? 0 : appendedRows) + additionalPartsRows; if ((lowerLimit <= targetRow) && (targetRow < upperLimit)) { // qDebug() << "appended level normal: would like to move" << idx.row() << "to" << targetRow; parentItem->insertRow(targetRow, parentItem->takeRow(idx.row())); continue; } auto parentIdx = parentItem->index(); Q_ASSERT(parentIdx.isValid()); auto newParentRow = parentIdx.row() + direction; if ((0 > newParentRow) || (rowCount() <= newParentRow)) { // qDebug() << "appended, cannot move further"; couldNotBeMoved[file] = true; continue; } auto newParent = fromIndex(index(newParentRow, 0)); auto newParentItem = itemFromIndex(index(newParentRow, 0)); auto rowItems = parentItem->takeRow(idx.row()); auto newParentNumbers = countAppendedAndAdditionalParts(newParentItem); targetRow = up && file->isAdditionalPart() ? newParentNumbers.first : up ? newParentNumbers.first + newParentNumbers.second : !up && file->isAdditionalPart() ? 0 : newParentNumbers.first; Q_ASSERT(!!newParent); // qDebug() << "appended level cross: would like to move" << idx.row() << "from" << file->m_appendedTo << "to" << newParent.get() << "as" << targetRow; newParentItem->insertRow(targetRow, rowItems); file->m_appendedTo = newParent.get(); } updateSourceFileLists(); }
bool HBox::isMovable() const { return parent() && (parent()->type() == HBOX || parent()->type() == VBOX); }
void UmlItem::memo_ac_uc_assoc(UmlUseCaseDiagram * d) { parent()->memo_ac_uc_assoc(d); }
void SVGInlineTextBox::paintSelectionBackground(PaintInfo& paintInfo) { ASSERT(paintInfo.shouldPaintWithinRoot(renderer())); ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection); ASSERT(truncation() == cNoTruncation); if (renderer()->style()->visibility() != VISIBLE) return; RenderObject* parentRenderer = parent()->renderer(); ASSERT(parentRenderer); ASSERT(!parentRenderer->document()->printing()); // Determine whether or not we're selected. bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection; bool hasSelection = selectionState() != RenderObject::SelectionNone; if (!hasSelection || paintSelectedTextOnly) return; Color backgroundColor = renderer()->selectionBackgroundColor(); if (!backgroundColor.isValid() || !backgroundColor.alpha()) return; RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer()); ASSERT(textRenderer); if (!textShouldBePainted(textRenderer)) return; RenderStyle* style = parentRenderer->style(); ASSERT(style); RenderStyle* selectionStyle = style; if (hasSelection) { selectionStyle = parentRenderer->getCachedPseudoStyle(SELECTION); if (!selectionStyle) selectionStyle = style; } int startPosition, endPosition; selectionStartEnd(startPosition, endPosition); int fragmentStartPosition = 0; int fragmentEndPosition = 0; AffineTransform fragmentTransform; unsigned textFragmentsSize = m_textFragments.size(); for (unsigned i = 0; i < textFragmentsSize; ++i) { SVGTextFragment& fragment = m_textFragments.at(i); ASSERT(!m_paintingResource); fragmentStartPosition = startPosition; fragmentEndPosition = endPosition; if (!mapStartEndPositionsIntoFragmentCoordinates(fragment, fragmentStartPosition, fragmentEndPosition)) continue; GraphicsContextStateSaver stateSaver(*paintInfo.context); fragment.buildFragmentTransform(fragmentTransform); if (!fragmentTransform.isIdentity()) paintInfo.context->concatCTM(fragmentTransform); paintInfo.context->setFillColor(backgroundColor, style->colorSpace()); paintInfo.context->fillRect(selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, style), backgroundColor, style->colorSpace()); m_paintingResourceMode = ApplyToDefaultMode; } ASSERT(!m_paintingResource); }
void qt_dbtreemodel_impl::_find_updated_rows( list_row* it, const string& sql ) { if ( !( _dbconn.get() && _dbconn->valid() && _root && _parent && it ) ) return; auto_ptr<list_row> clone( new list_row( _dbconn.get(), it->rowkeyfield(), it->level(), it->parent() ) ); clone->exec( sql.c_str() ); size_t num = 0; list_row::iterator unit = clone->begin(); bool setparent = false; QModelIndex unit_parent; while( unit != clone->end() ) { if( !setparent ) { // определяем родителя один раз unit_parent = parent(*unit); setparent = true; } list_row::iterator upd = find_if( it->begin(), it->end(), prow_eq(*unit) ); if( upd != it->end() ) { // найден строка -- проверить на предмет изменений bool for_update = false; for( int i = 0; i < (*upd)->size(); ++i ) { if( (**upd)[i] != (**unit)[i] ) { for_update = true; break; } } list_row *children = (*upd)->children(); if (children) { _find_updated_rows( children, children->sql() ); } if (for_update) { tree_element element( upd - it->begin(), *unit, unit_parent ); _updated[it].push_back( element ); unit = clone->erase( unit ); ++num; continue; } } else { tree_element element( num, *unit, unit_parent ); tree_elements :: iterator p = find( _inserted[it].begin(), _inserted[it].end(), element ); if( p == _inserted[it].end() ) { _inserted[it].push_back( element ); unit = clone->erase( unit ); ++num; continue; } } ++num; ++unit; } std::sort( _updated[it].begin(), _updated[it].end() ); std::sort( _inserted[it].begin(), _inserted[it].end() ); }
void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint&, LayoutUnit, LayoutUnit) { ASSERT(paintInfo.shouldPaintWithinRoot(renderer())); ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection); ASSERT(truncation() == cNoTruncation); if (renderer()->style()->visibility() != VISIBLE) return; // Note: We're explicitely not supporting composition & custom underlines and custom highlighters - unlike InlineTextBox. // If we ever need that for SVG, it's very easy to refactor and reuse the code. RenderObject* parentRenderer = parent()->renderer(); ASSERT(parentRenderer); bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection; bool hasSelection = !parentRenderer->document()->printing() && selectionState() != RenderObject::SelectionNone; if (!hasSelection && paintSelectedTextOnly) return; RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer()); ASSERT(textRenderer); if (!textShouldBePainted(textRenderer)) return; RenderStyle* style = parentRenderer->style(); ASSERT(style); const SVGRenderStyle* svgStyle = style->svgStyle(); ASSERT(svgStyle); bool hasFill = svgStyle->hasFill(); bool hasVisibleStroke = svgStyle->hasVisibleStroke(); RenderStyle* selectionStyle = style; if (hasSelection) { selectionStyle = parentRenderer->getCachedPseudoStyle(SELECTION); if (selectionStyle) { const SVGRenderStyle* svgSelectionStyle = selectionStyle->svgStyle(); ASSERT(svgSelectionStyle); if (!hasFill) hasFill = svgSelectionStyle->hasFill(); if (!hasVisibleStroke) hasVisibleStroke = svgSelectionStyle->hasVisibleStroke(); } else selectionStyle = style; } if (textRenderer->frame() && textRenderer->frame()->view() && textRenderer->frame()->view()->paintBehavior() & PaintBehaviorRenderingSVGMask) { hasFill = true; hasVisibleStroke = false; } AffineTransform fragmentTransform; unsigned textFragmentsSize = m_textFragments.size(); for (unsigned i = 0; i < textFragmentsSize; ++i) { SVGTextFragment& fragment = m_textFragments.at(i); ASSERT(!m_paintingResource); GraphicsContextStateSaver stateSaver(*paintInfo.context); fragment.buildFragmentTransform(fragmentTransform); if (!fragmentTransform.isIdentity()) paintInfo.context->concatCTM(fragmentTransform); // Spec: All text decorations except line-through should be drawn before the text is filled and stroked; thus, the text is rendered on top of these decorations. int decorations = style->textDecorationsInEffect(); if (decorations & TextDecorationUnderline) paintDecoration(paintInfo.context, TextDecorationUnderline, fragment); if (decorations & TextDecorationOverline) paintDecoration(paintInfo.context, TextDecorationOverline, fragment); // Fill text if (hasFill) { m_paintingResourceMode = ApplyToFillMode | ApplyToTextMode; paintText(paintInfo.context, style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly); } // Stroke text if (hasVisibleStroke) { m_paintingResourceMode = ApplyToStrokeMode | ApplyToTextMode; paintText(paintInfo.context, style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly); } // Spec: Line-through should be drawn after the text is filled and stroked; thus, the line-through is rendered on top of the text. if (decorations & TextDecorationLineThrough) paintDecoration(paintInfo.context, TextDecorationLineThrough, fragment); m_paintingResourceMode = ApplyToDefaultMode; } ASSERT(!m_paintingResource); }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool Comment::detachFrom(PublicObject* object) { if ( object == NULL ) return false; // check all possible parents MomentTensor* momentTensor = MomentTensor::Cast(object); if ( momentTensor != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return momentTensor->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = momentTensor->comment(index()); if ( child != NULL ) return momentTensor->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(MomentTensor): comment has not been found"); return false; } } } FocalMechanism* focalMechanism = FocalMechanism::Cast(object); if ( focalMechanism != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return focalMechanism->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = focalMechanism->comment(index()); if ( child != NULL ) return focalMechanism->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(FocalMechanism): comment has not been found"); return false; } } } Amplitude* amplitude = Amplitude::Cast(object); if ( amplitude != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return amplitude->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = amplitude->comment(index()); if ( child != NULL ) return amplitude->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Amplitude): comment has not been found"); return false; } } } Magnitude* magnitude = Magnitude::Cast(object); if ( magnitude != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return magnitude->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = magnitude->comment(index()); if ( child != NULL ) return magnitude->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Magnitude): comment has not been found"); return false; } } } StationMagnitude* stationMagnitude = StationMagnitude::Cast(object); if ( stationMagnitude != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return stationMagnitude->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = stationMagnitude->comment(index()); if ( child != NULL ) return stationMagnitude->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(StationMagnitude): comment has not been found"); return false; } } } Pick* pick = Pick::Cast(object); if ( pick != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return pick->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = pick->comment(index()); if ( child != NULL ) return pick->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Pick): comment has not been found"); return false; } } } Event* event = Event::Cast(object); if ( event != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return event->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = event->comment(index()); if ( child != NULL ) return event->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Event): comment has not been found"); return false; } } } Origin* origin = Origin::Cast(object); if ( origin != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return origin->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = origin->comment(index()); if ( child != NULL ) return origin->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Origin): comment has not been found"); return false; } } } Parameter* parameter = Parameter::Cast(object); if ( parameter != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return parameter->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = parameter->comment(index()); if ( child != NULL ) return parameter->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Parameter): comment has not been found"); return false; } } } ParameterSet* parameterSet = ParameterSet::Cast(object); if ( parameterSet != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return parameterSet->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = parameterSet->comment(index()); if ( child != NULL ) return parameterSet->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(ParameterSet): comment has not been found"); return false; } } } SEISCOMP_ERROR("Comment::detachFrom(%s) -> wrong class type", object->className()); return false; }
void DatasetPropertyWidget::changeDataSet(bool isGUI) { QString dir = this->path->currentText(); if(dir.isNull() || dir.isEmpty()) { if (isGUI) { QMessageBox info; info.setWindowFlags(Qt::WindowStaysOnTopHint); info.setIcon(QMessageBox::Information); info.setWindowTitle("Information"); info.setText("No directory specified!"); info.addButton(QMessageBox::Ok); info.exec(); } return; } QString conf = QString(dir).append("/knossos.conf"); QFile confFile(conf); if(!confFile.exists()) { if (isGUI) { QMessageBox info; info.setWindowFlags(Qt::WindowStaysOnTopHint); info.setIcon(QMessageBox::Information); info.setWindowTitle("Information"); info.setText("There is no knossos.conf"); info.addButton(QMessageBox::Ok); info.exec(); } return; } int dirRecentIndex = this->getRecentDirsItems().indexOf(dir); if (-1 != dirRecentIndex) { this->path->removeItem(dirRecentIndex); } this->path->insertItem(0, dir); this->path->setCurrentIndex(0); // Note: // We clear the skeleton *before* reading the new config. In case we fail later, the skeleton would be nevertheless be gone. // This is a gamble we take, in order to not have possible bugs where the skeleton depends on old configuration values. if (isGUI) { emit clearSkeletonSignalGUI(); } else { emit clearSkeletonSignalNoGUI(); } // BUG BUG BUG // The following code, combined with the way loader::run in currently implemented // (revision 966) contains a minor timing issue that may result in a crash, namely // since loader::loadCubes begins executing in LM_LOCAL mode and ends in LM_FTP, // if at this point in the code we're in LM_LOCAL, and are about an FTP dataset // BUG BUG BUG state->loaderDummy = true; // Stupid userMove hack-around. In order to move somewhere, you have to currently be at another supercube. state->viewerState->currentPosition.x = state->viewerState->currentPosition.y = state->viewerState->currentPosition.z = 0; emit userMoveSignal(state->cubeEdgeLength, state->cubeEdgeLength, state->cubeEdgeLength); this->waitForLoader(); strcpy(state->path, dir.toStdString().c_str()); if(false == Knossos::readConfigFile(conf.toStdString().c_str())) { QMessageBox info; info.setWindowFlags(Qt::WindowStaysOnTopHint); info.setIcon(QMessageBox::Information); info.setWindowTitle("Information"); info.setText(QString("Failed to read config from %s").arg(conf)); info.addButton(QMessageBox::Ok); info.exec(); return; } knossos->commonInitStates(); if (isGUI && state->M != supercubeEdgeSpin->value()) { auto text = QString("You chose to change the data cache cube edge length. \n") +QString("\nKnossos needs to restart to apply this.\n\n") +QString("You will loose your skeleton if you didn’t save or already cleared it."); if (QMessageBox::question(this, "Knossos restart", text, QMessageBox::Ok | QMessageBox::Abort) == QMessageBox::Ok) { //ideally one would use qApp->quit(), but the cleanup steps are not connected to this static_cast<MainWindow*>(parent())->close();//call Knossos cleanup func auto args = qApp->arguments(); args.append(QString("--supercube-edge=%0").arg(supercubeEdgeSpin->value()));//change M via cmdline so it is not saved on a crash/kill qDebug() << args; QProcess::startDetached(qApp->arguments()[0], args); } } this->waitForLoader(); emit changeDatasetMagSignal(DATA_SET); // Back to usual... state->loaderDummy = false; // ...beginning with loading the middle of dataset, as upon startup SET_COORDINATE(state->viewerState->currentPosition, state->boundary.x / 2 - state->cubeEdgeLength, state->boundary.y / 2 - state->cubeEdgeLength, state->boundary.z / 2 - state->cubeEdgeLength); emit userMoveSignal( state->cubeEdgeLength, state->cubeEdgeLength, state->cubeEdgeLength); // reset skeleton viewport if(state->skeletonState->rotationcounter == 0) { state->skeletonState->definedSkeletonVpView = SKELVP_RESET; } //Viewer::changeDatasetMag cannot be used when ther’re no other mags available //sets viewport settings according to current mag for(size_t i = 0; i < state->viewerState->numberViewports; i++) { if(state->viewerState->vpConfigs[i].type != VIEWPORT_SKELETON) { state->viewerState->vpConfigs[i].texture.zoomLevel = VPZOOMMIN; state->viewerState->vpConfigs[i].texture.texUnitsPerDataPx = 1. / TEXTURE_EDGE_LEN / state->magnification; } } emit datasetSwitchZoomDefaults(); this->hide(); }
void FFT::fftCurve() { int n2 = d_n/2; double *amp = (double *)malloc(d_n*sizeof(double)); double *result = (double *)malloc(2*d_n*sizeof(double)); if(!amp || !result){ memoryErrorMessage(); return; } double df = 1.0/(double)(d_n*d_sampling);//frequency sampling double aMax = 0.0;//max amplitude if(!d_inverse){ gsl_fft_real_workspace *work = gsl_fft_real_workspace_alloc(d_n); gsl_fft_real_wavetable *real = gsl_fft_real_wavetable_alloc(d_n); if(!work || !real){ memoryErrorMessage(); return; } gsl_fft_real_transform(d_y, 1, d_n, real, work); gsl_fft_halfcomplex_unpack (d_y, result, 1, d_n); gsl_fft_real_wavetable_free(real); gsl_fft_real_workspace_free(work); } else { gsl_fft_real_unpack (d_y, result, 1, d_n); gsl_fft_complex_wavetable *wavetable = gsl_fft_complex_wavetable_alloc (d_n); gsl_fft_complex_workspace *workspace = gsl_fft_complex_workspace_alloc (d_n); if(!workspace || !wavetable){ memoryErrorMessage(); return; } gsl_fft_complex_inverse (result, 1, d_n, wavetable, workspace); gsl_fft_complex_wavetable_free (wavetable); gsl_fft_complex_workspace_free (workspace); } if (d_shift_order){ for(int i = 0; i < d_n; i++){ d_x[i] = (i - n2)*df; int j = i + d_n; double aux = result[i]; result[i] = result[j]; result[j] = aux; } } else { for(int i = 0; i < d_n; i++) d_x[i] = i*df; } for(int i = 0; i < d_n; i++) { int i2 = 2*i; double real_part = result[i2]; double im_part = result[i2+1]; double a = sqrt(real_part*real_part + im_part*im_part); amp[i]= a; if (a > aMax) aMax = a; } ApplicationWindow *app = (ApplicationWindow *)parent(); QLocale locale = app->locale(); int prec = app->d_decimal_digits; for (int i = 0; i < d_n; i++){ int i2 = 2*i; d_result_table->setText(i, 0, locale.toString(d_x[i], 'g', prec)); d_result_table->setText(i, 1, locale.toString(result[i2], 'g', prec)); d_result_table->setText(i, 2, locale.toString(result[i2 + 1], 'g', prec)); if (d_normalize) d_result_table->setText(i, 3, locale.toString(amp[i]/aMax, 'g', prec)); else d_result_table->setText(i, 3, locale.toString(amp[i], 'g', prec)); d_result_table->setText(i, 4, locale.toString(atan(result[i2 + 1]/result[i2]), 'g', prec)); } free(amp); free(result); }
void EFX::arm() { class Scene* startScene = NULL; class Scene* stopScene = NULL; int serialNumber = 0; Doc* doc = qobject_cast <Doc*> (parent()); Q_ASSERT(doc != NULL); /* Initialization scene */ if (m_startSceneID != Function::invalidId() && m_startSceneEnabled == true) { startScene = static_cast <class Scene*> (doc->function(m_startSceneID)); } /* De-initialization scene */ if (m_stopSceneID != Function::invalidId() && m_stopSceneEnabled == true) { stopScene = static_cast <class Scene*> (doc->function(m_stopSceneID)); } QListIterator <EFXFixture*> it(m_fixtures); while (it.hasNext() == true) { EFXFixture* ef = it.next(); Q_ASSERT(ef != NULL); ef->setSerialNumber(serialNumber++); ef->setStartScene(startScene); ef->setStopScene(stopScene); /* If fxi == NULL, the fixture has been destroyed */ Fixture* fxi = doc->fixture(ef->fixture()); if (fxi == NULL) continue; /* If this fixture has no mode, it's a generic dimmer that can't do pan&tilt anyway. */ const QLCFixtureMode* mode = fxi->fixtureMode(); if (mode == NULL) continue; /* Find exact channel numbers for MSB/LSB pan and tilt */ for (t_channel i = 0; i < mode->channels().size(); i++) { QLCChannel* ch = mode->channel(i); Q_ASSERT(ch != NULL); if (ch->group() == KQLCChannelGroupPan) { if (ch->controlByte() == 0) { ef->setMsbPanChannel( fxi->universeAddress() + i); } else if (ch->controlByte() == 1) { ef->setLsbPanChannel( fxi->universeAddress() + i); } } else if (ch->group() == KQLCChannelGroupTilt) { if (ch->controlByte() == 0) { ef->setMsbTiltChannel( fxi->universeAddress() + i); } else if (ch->controlByte() == 1) { ef->setLsbTiltChannel( fxi->universeAddress() + i); } } } } /* Choose a point calculation function depending on the algorithm */ if (m_algorithm == KCircleAlgorithmName) pointFunc = circlePoint; else if (m_algorithm == KEightAlgorithmName) pointFunc = eightPoint; else if (m_algorithm == KLineAlgorithmName) pointFunc = linePoint; else if (m_algorithm == KTriangleAlgorithmName) pointFunc = trianglePoint; else if (m_algorithm == KDiamondAlgorithmName) pointFunc = diamondPoint; else if (m_algorithm == KLissajousAlgorithmName) pointFunc = lissajousPoint; else pointFunc = circlePoint; // Fallback resetElapsed(); }
void WEXPORT WBoolSwitch::setCheck( bool check ) { /************************************************/ GUISetChecked( parent()->handle(), controlId(), check ); }
KisBaseNodeSP KisNode::parentCallback() const { return parent(); }
void GraphicsLayer::dumpProperties(TextStream& ts, int indent, LayerTreeAsTextBehavior behavior) const { if (m_position != FloatPoint()) { writeIndent(ts, indent + 1); ts << "(position " << m_position.x() << " " << m_position.y() << ")\n"; } if (m_boundsOrigin != FloatPoint()) { writeIndent(ts, indent + 1); ts << "(bounds origin " << m_boundsOrigin.x() << " " << m_boundsOrigin.y() << ")\n"; } if (m_anchorPoint != FloatPoint3D(0.5f, 0.5f, 0)) { writeIndent(ts, indent + 1); ts << "(anchor " << m_anchorPoint.x() << " " << m_anchorPoint.y() << ")\n"; } if (m_size != IntSize()) { writeIndent(ts, indent + 1); ts << "(bounds " << m_size.width() << " " << m_size.height() << ")\n"; } if (m_opacity != 1) { writeIndent(ts, indent + 1); ts << "(opacity " << m_opacity << ")\n"; } if (m_usingTiledLayer) { writeIndent(ts, indent + 1); ts << "(usingTiledLayer " << m_usingTiledLayer << ")\n"; } if (m_preserves3D) { writeIndent(ts, indent + 1); ts << "(preserves3D " << m_preserves3D << ")\n"; } if (m_drawsContent) { writeIndent(ts, indent + 1); ts << "(drawsContent " << m_drawsContent << ")\n"; } if (!m_contentsVisible) { writeIndent(ts, indent + 1); ts << "(contentsVisible " << m_contentsVisible << ")\n"; } if (!m_backfaceVisibility) { writeIndent(ts, indent + 1); ts << "(backfaceVisibility " << (m_backfaceVisibility ? "visible" : "hidden") << ")\n"; } if (behavior & LayerTreeAsTextDebug) { writeIndent(ts, indent + 1); ts << "("; if (m_client) ts << "client " << static_cast<void*>(m_client); else ts << "no client"; ts << ")\n"; } if (m_backgroundColorSet) { writeIndent(ts, indent + 1); ts << "(backgroundColor " << m_backgroundColor.nameForRenderTreeAsText() << ")\n"; } if (!m_transform.isIdentity()) { writeIndent(ts, indent + 1); ts << "(transform "; ts << "[" << m_transform.m11() << " " << m_transform.m12() << " " << m_transform.m13() << " " << m_transform.m14() << "] "; ts << "[" << m_transform.m21() << " " << m_transform.m22() << " " << m_transform.m23() << " " << m_transform.m24() << "] "; ts << "[" << m_transform.m31() << " " << m_transform.m32() << " " << m_transform.m33() << " " << m_transform.m34() << "] "; ts << "[" << m_transform.m41() << " " << m_transform.m42() << " " << m_transform.m43() << " " << m_transform.m44() << "])\n"; } // Avoid dumping the sublayer transform on the root layer, because it's used for geometry flipping, whose behavior // differs between platforms. if (parent() && !m_childrenTransform.isIdentity()) { writeIndent(ts, indent + 1); ts << "(childrenTransform "; ts << "[" << m_childrenTransform.m11() << " " << m_childrenTransform.m12() << " " << m_childrenTransform.m13() << " " << m_childrenTransform.m14() << "] "; ts << "[" << m_childrenTransform.m21() << " " << m_childrenTransform.m22() << " " << m_childrenTransform.m23() << " " << m_childrenTransform.m24() << "] "; ts << "[" << m_childrenTransform.m31() << " " << m_childrenTransform.m32() << " " << m_childrenTransform.m33() << " " << m_childrenTransform.m34() << "] "; ts << "[" << m_childrenTransform.m41() << " " << m_childrenTransform.m42() << " " << m_childrenTransform.m43() << " " << m_childrenTransform.m44() << "])\n"; } if (m_replicaLayer) { writeIndent(ts, indent + 1); ts << "(replica layer"; if (behavior & LayerTreeAsTextDebug) ts << " " << m_replicaLayer; ts << ")\n"; m_replicaLayer->dumpLayer(ts, indent + 2, behavior); } if (m_replicatedLayer) { writeIndent(ts, indent + 1); ts << "(replicated layer"; if (behavior & LayerTreeAsTextDebug) ts << " " << m_replicatedLayer;; ts << ")\n"; } if (m_children.size()) { writeIndent(ts, indent + 1); ts << "(children " << m_children.size() << "\n"; unsigned i; for (i = 0; i < m_children.size(); i++) m_children[i]->dumpLayer(ts, indent + 2, behavior); writeIndent(ts, indent + 1); ts << ")\n"; } }
QgsLayerTreeModel* QgsLayerTreeModelLegendNode::model() const { return qobject_cast<QgsLayerTreeModel*>( parent() ); }