本文整理汇总了C++中parent函数的典型用法代码示例。如果您正苦于以下问题:C++ parent函数的具体用法?C++ parent怎么用?C++ parent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parent函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: database
Database* DataType::database() const {
return dynamic_cast<Database*>(parent());
}
开发者ID:gitcommit,项目名称:simpleorm,代码行数:3,代码来源:datatype.cpp
示例2: lastInternal
//最后一个内部节点(即末节点的父亲)
Rank lastInternal(Rank n)
{
return parent(n-1);
}
开发者ID:ty14,项目名称:opencourse,代码行数:5,代码来源:schedule.cpp
示例3: return
bool WEXPORT WBoolSwitch::checked() {
/***********************************/
return( GUIIsChecked( parent()->handle(), controlId() ) != 0 );
}
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:5,代码来源:wboolsw.cpp
示例4: LOG
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;
}
开发者ID:Cpaniyadi,项目名称:selenium,代码行数:77,代码来源:ElementFinder.cpp
示例5: detachFrom
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool Comment::detach() {
if ( parent() == NULL )
return false;
return detachFrom(parent());
}
开发者ID:ovsm-dev,项目名称:seiscomp3,代码行数:7,代码来源:comment.cpp
示例6: list_row
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;
}
}
开发者ID:sblab,项目名称:libeast,代码行数:79,代码来源:qt_dbtreemodel_impl.cpp
示例7: detachFrom
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool ConfigModule::detach() {
if ( parent() == NULL )
return false;
return detachFrom(parent());
}
开发者ID:salichon,项目名称:seiscomp3,代码行数:7,代码来源:configmodule.cpp
示例8: staff
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;
//.........这里部分代码省略.........
开发者ID:WeiChou,项目名称:MuseScore,代码行数:101,代码来源:clef.cpp
示例9: modify
void Configuration::modify()
{
static_cast<KConfigDialog*>(parent())->enableButtonApply(true);
}
开发者ID:Emdek,项目名称:plasmoid-mini-player,代码行数:4,代码来源:Configuration.cpp
示例10: save
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();
}
开发者ID:Emdek,项目名称:plasmoid-mini-player,代码行数:65,代码来源:Configuration.cpp
示例11: Q_D
CuteReport::BaseItemInterface * DummyBand::clone()
{
Q_D(DummyBand);
return new DummyBand(*d, parent());
}
开发者ID:navrocky,项目名称:CuteReport,代码行数:5,代码来源:dummyband.cpp
示例12: write
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();
}
开发者ID:DoUML,项目名称:douml,代码行数:82,代码来源:UmlComponent.cpp
示例13: Q_ASSERT_X
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;
}
开发者ID:damoguyan,项目名称:pdfviewer,代码行数:10,代码来源:shortcuthandler.cpp
示例14: parent
KisNodeSP KisNode::nextSibling() const
{
if (!parent()) return 0;
return parent()->at(parent()->index(const_cast<KisNode*>(this)) + 1);
}
开发者ID:KDE,项目名称:calligra-history,代码行数:6,代码来源:kis_node.cpp
示例15: Draw
/*!
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();
}
开发者ID:ChrisWhiten,项目名称:VideoParser,代码行数:66,代码来源:ImageView.cpp
示例16: sortSourceFiles
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();
}
开发者ID:scmp99,项目名称:mkvtoolnix,代码行数:83,代码来源:source_file_model.cpp
示例17: parent
bool HBox::isMovable() const
{
return parent() && (parent()->type() == HBOX || parent()->type() == VBOX);
}
开发者ID:BlueMockingbird,项目名称:MuseScore,代码行数:4,代码来源:box.cpp
示例18: ASSERT
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);
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:67,代码来源:SVGInlineTextBox.cpp
示例19: clone
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() );
}
开发者ID:sblab,项目名称:libeast,代码行数:66,代码来源:qt_dbtreemodel_impl.cpp
示例20: SEISCOMP_DEBUG
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
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 )
//.........这里部分代码省略.........
开发者ID:ovsm-dev,项目名称:seiscomp3,代码行数:101,代码来源:comment.cpp
注:本文中的parent函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论