void LLPanelClassifiedEdit::onOpen(const LLSD& key) { mIsNew = key.isUndefined(); scrollToTop(); // classified is not created yet bool is_new = isNew() || isNewWithErrors(); if(is_new) { resetData(); resetControls(); fillIn(key); if(isNew()) { LLAvatarPropertiesProcessor::getInstance()->addObserver(getAvatarId(), this); } } else { LLPanelClassifiedInfo::onOpen(key); } std::string save_btn_label = is_new ? getString("publish_label") : getString("save_label"); getChild<LLUICtrl>("save_changes_btn")->setLabelArg("[LABEL]", save_btn_label); enableVerbs(is_new); enableEditing(is_new); showEditing(!is_new); resetDirty(); setInfoLoaded(false); }
CFTypeRef SecCFObject::handle(bool retain) throw() { CFTypeRef cfType = *this; if (retain && !isNew()) CFRetain(cfType); return cfType; }
void KeyframeAnimation::animate(CompositeAnimation*, RenderObject*, const RenderStyle*, RenderStyle* targetStyle, RefPtr<RenderStyle>& animatedStyle) { // Fire the start timeout if needed fireAnimationEventsIfNeeded(); // If we have not yet started, we will not have a valid start time, so just start the animation if needed. if (isNew() && m_animation->playState() == AnimPlayStatePlaying) updateStateMachine(AnimationStateInputStartAnimation, -1); // If we get this far and the animation is done, it means we are cleaning up a just finished animation. // If so, we need to send back the targetStyle. if (postActive()) { if (!animatedStyle) animatedStyle = const_cast<RenderStyle*>(targetStyle); return; } // If we are waiting for the start timer, we don't want to change the style yet. // Special case 1 - if the delay time is 0, then we do want to set the first frame of the // animation right away. This avoids a flash when the animation starts. // Special case 2 - if there is a backwards fill mode, then we want to continue // through to the style blend so that we get the fromStyle. if (waitingToStart() && m_animation->delay() > 0 && !m_animation->fillsBackwards()) return; // FIXME: we need to be more efficient about determining which keyframes we are animating between. // We should cache the last pair or something. // Get the from/to styles and progress between const RenderStyle* fromStyle = 0; const RenderStyle* toStyle = 0; double progress; getKeyframeAnimationInterval(fromStyle, toStyle, progress); // If either style is 0 we have an invalid case, just stop the animation. if (!fromStyle || !toStyle) { updateStateMachine(AnimationStateInputEndAnimation, -1); return; } // Run a cycle of animation. // We know we will need a new render style, so make one if needed. if (!animatedStyle) animatedStyle = RenderStyle::clone(targetStyle); HashSet<int>::const_iterator endProperties = m_keyframes.endProperties(); for (HashSet<int>::const_iterator it = m_keyframes.beginProperties(); it != endProperties; ++it) { bool needsAnim = blendProperties(this, *it, animatedStyle.get(), fromStyle, toStyle, progress); if (needsAnim) setAnimating(); else { #if USE(ACCELERATED_COMPOSITING) // If we are running an accelerated animation, set a flag in the style // to indicate it. This can be used to make sure we get an updated // style for hit testing, etc. animatedStyle->setIsRunningAcceleratedAnimation(); #endif } } }
void ImplicitAnimation::animate(CompositeAnimation*, RenderObject*, const RenderStyle*, RenderStyle* targetStyle, RefPtr<RenderStyle>& animatedStyle) { // If we get this far and the animation is done, it means we are cleaning up a just finished animation. // So just return. Everything is already all cleaned up. if (postActive()) return; // Reset to start the transition if we are new if (isNew()) reset(targetStyle); // Run a cycle of animation. // We know we will need a new render style, so make one if needed if (!animatedStyle) animatedStyle = RenderStyle::clone(targetStyle); bool needsAnim = CSSPropertyAnimation::blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress(1, 0, 0)); // FIXME: we also need to detect cases where we have to software animate for other reasons, // such as a child using inheriting the transform. https://bugs.webkit.org/show_bug.cgi?id=23902 if (needsAnim) setAnimating(); else { #if USE(ACCELERATED_COMPOSITING) // If we are running an accelerated animation, set a flag in the style which causes the style // to compare as different to any other style. This ensures that changes to the property // that is animating are correctly detected during the animation (e.g. when a transition // gets interrupted). animatedStyle->setIsRunningAcceleratedAnimation(); #endif } // Fire the start timeout if needed fireAnimationEventsIfNeeded(); }
double AnimationBase::timeToNextService() { // Returns the time at which next service is required. -1 means no service is required. 0 means // service is required now, and > 0 means service is required that many seconds in the future. if (paused() || isNew() || m_animationState == AnimationState::FillingForwards) return -1; if (m_animationState == AnimationState::StartWaitTimer) { #if ENABLE(CSS_ANIMATIONS_LEVEL_2) if (m_animation->trigger()->isScrollAnimationTrigger()) { if (m_object) { float currentScrollOffset = m_object->view().frameView().scrollOffsetForFixedPosition().height().toFloat(); ScrollAnimationTrigger& scrollTrigger = downcast<ScrollAnimationTrigger>(*m_animation->trigger().get()); if (currentScrollOffset >= scrollTrigger.startValue().value() && (!scrollTrigger.hasEndValue() || currentScrollOffset <= scrollTrigger.endValue().value())) return 0; } return -1; } #endif double timeFromNow = m_animation->delay() - (beginAnimationUpdateTime() - m_requestedStartTime); return std::max(timeFromNow, 0.0); } fireAnimationEventsIfNeeded(); // In all other cases, we need service right away. return 0; }
GtkWidget * AP_UnixDialog_Styles::_constructModifyDialog(void) { GtkWidget *modifyDialog; GtkWidget *dialog_action_area; const XAP_StringSet * pSS = m_pApp->getStringSet(); UT_UTF8String title; if(!isNew()) pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_ModifyTitle,title); else pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_NewTitle,title); modifyDialog = abiDialogNew("modify style dialog", TRUE, title.utf8_str()); gtk_container_set_border_width (GTK_CONTAINER (modifyDialog), 5); _constructModifyDialogContents(gtk_dialog_get_content_area(GTK_DIALOG (modifyDialog))); dialog_action_area = gtk_dialog_get_action_area(GTK_DIALOG (modifyDialog)); gtk_widget_show (dialog_action_area); m_wModifyDialog = modifyDialog; // // Gnome buttons // _constructGnomeModifyButtons(dialog_action_area); // // Connect signals // _connectModifySignals(); return modifyDialog; }
void TabView::emitTabChanged(int index) { Q_UNUSED(index); if (count() == 0) { m_pLastTab = nullptr; emit tabTitleChanged(""); emit tabModified(false); emit tabChanged(nullptr, nullptr); return; } auto pCurrentTab = qobject_cast<Tab *>(currentWidget()); if (m_pLastTab != pCurrentTab) { if (pCurrentTab != nullptr) { if (m_pLastTab != nullptr) disconnectTab(m_pLastTab); connectTab(pCurrentTab); emit tabTitleChanged(pCurrentTab->title()); emit tabModified(pCurrentTab->isModified() || pCurrentTab->isNew()); emit tabChanged(m_pLastTab, pCurrentTab); } m_pLastTab = pCurrentTab; } }
bool KraftDoc::saveDocument( ) { bool result = false; DocumentSaverBase *saver = getSaver(); if( saver ) { result = saver->saveDocument( this ); if ( isNew() ) { setLastModified( QDate::currentDate() ); } // We go through the whole document and remove the positions // that are to delete because they now were deleted in the // database. DocPositionListIterator it( mPositions ); while( it.hasNext() ) { DocPositionBase *dp = it.next(); if( dp->toDelete() ) { kDebug() << "Removing pos " << dp->dbId().toString() << " from document object" << endl; mPositions.removeAll( dp ); } } modified = false; } return result; }
void LLPanelClassifiedEdit::sendUpdate() { LLAvatarClassifiedInfo c_data; if(getClassifiedId().isNull()) { setClassifiedId(LLUUID::generateNewID()); } c_data.agent_id = gAgent.getID(); c_data.classified_id = getClassifiedId(); // *HACK // Categories on server start with 1 while combo-box index starts with 0 c_data.category = getCategory() + 1; c_data.name = getClassifiedName(); c_data.description = getDescription(); c_data.parcel_id = getParcelId(); c_data.snapshot_id = getSnapshotId(); c_data.pos_global = getPosGlobal(); c_data.flags = getFlags(); c_data.price_for_listing = getPriceForListing(); LLAvatarPropertiesProcessor::getInstance()->sendClassifiedInfoUpdate(&c_data); if(isNew()) { // Lets assume there will be some error. // Successful sendClassifiedInfoUpdate will trigger processProperties and // let us know there was no error. mIsNewWithErrors = true; } }
void devEthernet::dumpBasicInfo() { ACE_TRACE("devEthernet::dumpBasicInfo"); if ( isNew() ) { return; } ND_DEBUG("Iface name: %s, Index: %d, Up: %s, MAC: %s, Protected: %s\n", getIfaceName().c_str(), index(), isUp()? "true" : "false", getMacStr().c_str(), isProtected()? "true" : "false" ); }
bool KeyframeAnimation::animate(CompositeAnimation* compositeAnimation, RenderElement*, const RenderStyle*, RenderStyle* targetStyle, RefPtr<RenderStyle>& animatedStyle) { // Fire the start timeout if needed fireAnimationEventsIfNeeded(); // If we have not yet started, we will not have a valid start time, so just start the animation if needed. if (isNew() && m_animation->playState() == AnimPlayStatePlaying && !compositeAnimation->isSuspended()) updateStateMachine(AnimationStateInput::StartAnimation, -1); // If we get this far and the animation is done, it means we are cleaning up a just finished animation. // If so, we need to send back the targetStyle. if (postActive()) { if (!animatedStyle) animatedStyle = const_cast<RenderStyle*>(targetStyle); return false; } // If we are waiting for the start timer, we don't want to change the style yet. // Special case 1 - if the delay time is 0, then we do want to set the first frame of the // animation right away. This avoids a flash when the animation starts. // Special case 2 - if there is a backwards fill mode, then we want to continue // through to the style blend so that we get the fromStyle. if (waitingToStart() && m_animation->delay() > 0 && !m_animation->fillsBackwards()) return false; // If we have no keyframes, don't animate. if (!m_keyframes.size()) { updateStateMachine(AnimationStateInput::EndAnimation, -1); return false; } AnimationState oldState = state(); // Run a cycle of animation. // We know we will need a new render style, so make one if needed. if (!animatedStyle) animatedStyle = RenderStyle::clone(targetStyle); // FIXME: we need to be more efficient about determining which keyframes we are animating between. // We should cache the last pair or something. for (auto propertyID : m_keyframes.properties()) { // Get the from/to styles and progress between const RenderStyle* fromStyle = nullptr; const RenderStyle* toStyle = nullptr; double progress = 0; fetchIntervalEndpointsForProperty(propertyID, fromStyle, toStyle, progress); bool needsAnim = CSSPropertyAnimation::blendProperties(this, propertyID, animatedStyle.get(), fromStyle, toStyle, progress); if (!needsAnim) // If we are running an accelerated animation, set a flag in the style // to indicate it. This can be used to make sure we get an updated // style for hit testing, etc. // FIXME: still need this? animatedStyle->setIsRunningAcceleratedAnimation(); } return state() != oldState; }
void FpS::print() { if (isNew()) { cout << "FPS: "; cout.precision(4); cout << fps << "\n"; } }
bool DocumentEditor::stillExist() const { if(isNew()) return true; if(QFile(_fullPath).exists()) return true; else { return false; } }
bool SaveFile::loadGame(SBTProcess *game, HwCommon *hw) { if (isNew()) { game->exec(); } else { if (!read(&hw->fs)) { return false; } game->exec("99"); } return true; }
void AnimationBase::updatePlayState(EAnimPlayState playState) { if (!m_compAnim) return; // When we get here, we can have one of 4 desired states: running, paused, suspended, paused & suspended. // The state machine can be in one of two states: running, paused. // Set the state machine to the desired state. bool pause = playState == AnimPlayStatePaused || m_compAnim->isSuspended(); if (pause == paused() && !isNew()) return; updateStateMachine(pause ? AnimationStateInputPlayStatePaused : AnimationStateInputPlayStateRunning, -1); }
bool DocumentEditor::needBOM() { switch (_bomMode) { case BomLeaveAsIs: return _hasBom; case BomLeaveAsIsAddToNewFile: if(isNew()) return true; return _hasBom; case BomAlwaysAdd: return true; case BomAlwaysRemove: return false; default: return false; } }
/*! Returns true if the values of the properties differ with the record on the database; otherwise returns false. */ bool TSqlObject::isModified() const { if (isNew()) return false; for (int i = 0; i < QSqlRecord::count(); ++i) { QString name = field(i).name(); int index = metaObject()->indexOfProperty(name.toLatin1().constData()); if (index >= 0) { if (value(name) != property(name.toLatin1().constData())) { return true; } } } return false; }
double AnimationBase::timeToNextService() { // Returns the time at which next service is required. -1 means no service is required. 0 means // service is required now, and > 0 means service is required that many seconds in the future. if (paused() || isNew() || m_animState == AnimationStateFillingForwards) return -1; if (m_animState == AnimationStateStartWaitTimer) { double timeFromNow = m_animation->delay() - (beginAnimationUpdateTime() - m_requestedStartTime); return max(timeFromNow, 0.0); } fireAnimationEventsIfNeeded(); // In all other cases, we need service right away. return 0; }
bool DocumentEditor::setCodec(const QString& codec_) { if(_codec != codec_) { ///@todo it would be nice to change the charset on the fly without reloading the file if (isModified()) { int ret = QMessageBox::question(this , tr("Reload ?"), tr("%1\nThis file has been modified.\nDo you want to reload it with %2 charset\nand loose the change?").arg(getFullPath()).arg(codec_), QMessageBox::Yes | QMessageBox::No); if (ret == QMessageBox::No) return false; } _codec = codec_; if(isNew()) return false; return load(getFullPath()); } return false; }
void LLPanelClassifiedEdit::processProperties(void* data, EAvatarProcessorType type) { if(APT_CLASSIFIED_INFO == type) { LLAvatarClassifiedInfo* c_info = static_cast<LLAvatarClassifiedInfo*>(data); if(c_info && getClassifiedId() == c_info->classified_id) { // see LLPanelClassifiedEdit::sendUpdate() for notes mIsNewWithErrors = false; // for just created classified - panel will probably be closed when we get here. if(!getVisible()) { return; } enableEditing(true); setClassifiedName(c_info->name); setDescription(c_info->description); setSnapshotId(c_info->snapshot_id); setPosGlobal(c_info->pos_global); setClassifiedLocation(createLocationText(c_info->parcel_name, c_info->sim_name, c_info->pos_global)); // *HACK see LLPanelClassifiedEdit::sendUpdate() setCategory(c_info->category - 1); bool mature = is_cf_mature(c_info->flags); bool auto_renew = is_cf_auto_renew(c_info->flags); setContentType(mature ? CB_ITEM_MATURE : CB_ITEM_PG); getChild<LLUICtrl>("auto_renew")->setValue(auto_renew); getChild<LLUICtrl>("price_for_listing")->setValue(c_info->price_for_listing); getChildView("price_for_listing")->setEnabled(isNew()); resetDirty(); setInfoLoaded(true); enableVerbs(false); // for just created classified - in case user opened edit panel before processProperties() callback getChild<LLUICtrl>("save_changes_btn")->setLabelArg("[LABEL]", getString("save_label")); } } }
void LLPanelClassifiedEdit::onSaveClick() { mCanClose = false; if(!isValidName()) { notifyInvalidName(); return; } if(isNew() || isNewWithErrors()) { if(gStatusBar->getBalance() < getPriceForListing()) { LLNotificationsUtil::add("ClassifiedInsufficientFunds"); return; } mPublishFloater = LLFloaterReg::findTypedInstance<LLPublishClassifiedFloater>( "publish_classified", LLSD()); if(!mPublishFloater) { mPublishFloater = LLFloaterReg::getTypedInstance<LLPublishClassifiedFloater>( "publish_classified", LLSD()); mPublishFloater->setPublishClickedCallback(boost::bind (&LLPanelClassifiedEdit::onPublishFloaterPublishClicked, this)); } // set spinner value before it has focus or value wont be set mPublishFloater->setPrice(getPriceForListing()); mPublishFloater->openFloater(mPublishFloater->getKey()); mPublishFloater->center(); } else { doSave(); } }
void ImplicitAnimation::animate(CompositeAnimation*, RenderObject*, RenderStyle*, RenderStyle* targetStyle, RefPtr<RenderStyle>& animatedStyle) { // If we get this far and the animation is done, it means we are cleaning up a just finished animation. // So just return. Everything is already all cleaned up. if (postActive()) return; // Reset to start the transition if we are new if (isNew()) reset(targetStyle); // Run a cycle of animation. // We know we will need a new render style, so make one if needed if (!animatedStyle) animatedStyle = RenderStyle::clone(targetStyle); if (blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress(1, 0, 0))) setAnimating(); // Fire the start timeout if needed fireAnimationEventsIfNeeded(); }
bool FxSend::getFromSampler() { #if CONFIG_FXSEND m_bModified = false; // in case this is a new, actually not yet existing FX send, ignore update if (isNew()) return true; MainForm *pMainForm = MainForm::getInstance(); if (!pMainForm || !pMainForm->client()) return false; lscp_fxsend_info_t* pFxSendInfo = ::lscp_get_fxsend_info( pMainForm->client(), m_iSamplerChannelID, m_iFxSendID); if (!pFxSendInfo) { pMainForm->appendMessagesClient("lscp_get_fxsend_info"); return false; } m_FxSendName = qsamplerUtilities::lscpEscapedTextToRaw(pFxSendInfo->name); m_MidiCtrl = pFxSendInfo->midi_controller; m_Depth = pFxSendInfo->level; m_AudioRouting.clear(); if (pFxSendInfo->audio_routing) for (int i = 0; pFxSendInfo->audio_routing[i] != -1; ++i) m_AudioRouting[i] = pFxSendInfo->audio_routing[i]; return true; #else // CONFIG_FXSEND return false; #endif // CONFIG_FXSEND }
/*! \brief Altera o identificador de uma regra de análise. Deve ser utilizado apenas em regras novas que ainda não tinham sido salvas, para setar seu novo Id. */ void RemoteWeatherServerData::setId(int id) { assert(id >= 0); assert(isNew()); _data.id = id; }
const Value& Value::newPlacementArg() const { assert(isNew()); return impl_->value0; }
SharedPtr<Character> CharacterFactory::make(const String& pCharacterName, SharedPtr<Account> pAccount) { if (!pAccount) return false; auto character = std::make_shared<Character>(); // Associate Account. character->setAccount(pAccount); // Associate Experience::Controller. auto expController = new Experience::Controller(); character->setExperienceController(expController); if (!mDataStore->characterLoad(pCharacterName, character.get())) { mLog->error("Failed to load Character: " + pCharacterName); return nullptr; } //// Check: Data::Character loaded. ////auto characterData = new Data::Character(); //if (!mDataStore->characterLoad(pCharacterName, characterData)) { // mLog->error("Failed to load data for Character: " + pCharacterName); // delete characterData; // return nullptr; //} // Create and initialise Inventory. auto inventory = std::make_shared<Inventory>(); character->setInventory(inventory); // Load Inventory. auto taskController = std::make_shared<TaskController>(); character->setTaskController(taskController); // Load Tasks. // Load Buffs. // Load Skills // Load Languages // Load Spell Book // Load Spell Bar // Load Disciplines // Load AA //if (!inventory->initialise(&characterData->mInventory, mItemFactory, mLogFactory, pCharacterName)) { // mLog->error("Failed to initialise Inventory for Character: " + pCharacterName); // return nullptr; //} // Create and initialise Experience::Controller. //auto experienceController = new Experience::Controller(); //if (!experienceController->onLoad(&characterData->mExperience)) { // mLog->error("Failed to initialise Experience::Controller for Character: " + pCharacterName); // delete inventory; // delete characterData; // delete experienceController; // return nullptr; //} //auto character = new Character(characterData); //// Create and initialise TaskController. //auto taskController = new TaskController(); //if (!taskController->initialise(character, mTaskDataStore, mLogFactory)) { // // TODO: Delete // return false; //} //if (!taskController->onLoad(characterData->mCompletedTasks)) { // // TODO: Delete. // return false; //} //// Initialise Character. //if (!character->initialise(pAccount, inventory, experienceController, taskController)) { // mLog->error("Failed to initialise Character: " + pCharacterName); // delete inventory; // delete characterData; // delete experienceController; // delete character; // return nullptr; //} // Check: Is this the first time the Character has logged in. if (character->isNew()) { //mLog->info("") } return character; }
/*! Deletes the record with this primary key from the database. */ bool TSqlObject::remove() { if (isNew()) { sqlError = QSqlError(QLatin1String("No record to remove"), QString(), QSqlError::UnknownError); tWarn("Unable to remove the '%s' object. Create it before!", metaObject()->className()); return false; } QSqlDatabase &database = Tf::currentSqlDatabase(databaseId()); QString del = database.driver()->sqlStatement(QSqlDriver::DeleteStatement, tableName(), *static_cast<QSqlRecord *>(this), false); if (del.isEmpty()) { sqlError = QSqlError(QLatin1String("Unable to delete row"), QString(), QSqlError::StatementError); return false; } del.append(" WHERE "); int revIndex = -1; for (int i = metaObject()->propertyOffset(); i < metaObject()->propertyCount(); ++i) { const char *propName = metaObject()->property(i).name(); QByteArray prop = QByteArray(propName).toLower(); if (prop == LockRevision) { bool ok; int revision = property(propName).toInt(&ok); if (!ok || revision <= 0) { sqlError = QSqlError(QLatin1String("Unable to convert the 'revision' property to an int"), QString(), QSqlError::UnknownError); tError("Unable to convert the 'revision' property to an int, %s", qPrintable(objectName())); return false; } del.append(QLatin1String(propName)); del.append("=").append(TSqlQuery::formatValue(revision, database)); del.append(" AND "); revIndex = i; break; } } const char *pkName = metaObject()->property(metaObject()->propertyOffset() + primaryKeyIndex()).name(); if (primaryKeyIndex() < 0 || !pkName) { QString msg = QString("Primary key not found for table ") + tableName() + QLatin1String(". Create a primary key!"); sqlError = QSqlError(msg, QString(), QSqlError::StatementError); tError("%s", qPrintable(msg)); return false; } del.append(QLatin1String(pkName)); del.append("=").append(TSqlQuery::formatValue(value(pkName), database)); TSqlQuery query(database); bool ret = query.exec(del); sqlError = query.lastError(); if (ret) { // Optimistic lock check if (query.numRowsAffected() != 1) { if (revIndex >= 0) { QString msg = QString("Row was updated or deleted from table ") + tableName() + QLatin1String(" by another transaction"); sqlError = QSqlError(msg, QString(), QSqlError::UnknownError); throw SqlException(msg, __FILE__, __LINE__); } tWarn("Row was deleted by another transaction, %s", qPrintable(tableName())); } clear(); } return ret; }
/*! Updates the corresponding record with the properties of the object. */ bool TSqlObject::update() { if (isNew()) { sqlError = QSqlError(QLatin1String("No record to update"), QString(), QSqlError::UnknownError); tWarn("Unable to update the '%s' object. Create it before!", metaObject()->className()); return false; } QSqlDatabase &database = Tf::currentSqlDatabase(databaseId()); QString where(" WHERE "); // Updates the value of 'updated_at' or 'modified_at' property bool updflag = false; int revIndex = -1; for (int i = metaObject()->propertyOffset(); i < metaObject()->propertyCount(); ++i) { const char *propName = metaObject()->property(i).name(); QByteArray prop = QByteArray(propName).toLower(); if (!updflag && (prop == UpdatedAt || prop == ModifiedAt)) { setProperty(propName, QDateTime::currentDateTime()); updflag = true; } else if (revIndex < 0 && prop == LockRevision) { bool ok; int oldRevision = property(propName).toInt(&ok); if (!ok || oldRevision <= 0) { sqlError = QSqlError(QLatin1String("Unable to convert the 'revision' property to an int"), QString(), QSqlError::UnknownError); tError("Unable to convert the 'revision' property to an int, %s", qPrintable(objectName())); return false; } setProperty(propName, oldRevision + 1); revIndex = i; where.append(QLatin1String(propName)); where.append("=").append(TSqlQuery::formatValue(oldRevision, database)); where.append(" AND "); } else { // continue } } QString upd; // UPDATE Statement upd.reserve(255); upd.append(QLatin1String("UPDATE ")).append(tableName()).append(QLatin1String(" SET ")); int pkidx = metaObject()->propertyOffset() + primaryKeyIndex(); const char *pkName = metaObject()->property(pkidx).name(); if (primaryKeyIndex() < 0 || !pkName) { QString msg = QString("Primary key not found for table ") + tableName() + QLatin1String(". Create a primary key!"); sqlError = QSqlError(msg, QString(), QSqlError::StatementError); tError("%s", qPrintable(msg)); return false; } QVariant origpkval = value(pkName); where.append(QLatin1String(pkName)); where.append("=").append(TSqlQuery::formatValue(origpkval, database)); // Restore the value of primary key QObject::setProperty(pkName, origpkval); for (int i = metaObject()->propertyOffset(); i < metaObject()->propertyCount(); ++i) { const char *propName = metaObject()->property(i).name(); QVariant newval = QObject::property(propName); QVariant recval = QSqlRecord::value(QLatin1String(propName)); if (i != pkidx && recval.isValid() && recval != newval) { upd.append(QLatin1String(propName)); upd.append(QLatin1Char('=')); upd.append(TSqlQuery::formatValue(newval, database)); upd.append(QLatin1String(", ")); } } if (!upd.endsWith(QLatin1String(", "))) { tSystemDebug("SQL UPDATE: Same values as that of the record. No need to update."); return true; } upd.chop(2); syncToSqlRecord(); upd.append(where); TSqlQuery query(database); bool ret = query.exec(upd); sqlError = query.lastError(); if (ret) { // Optimistic lock check if (revIndex >= 0 && query.numRowsAffected() != 1) { QString msg = QString("Row was updated or deleted from table ") + tableName() + QLatin1String(" by another transaction"); sqlError = QSqlError(msg, QString(), QSqlError::UnknownError); throw SqlException(msg, __FILE__, __LINE__); } } return ret; }
const Value& Value::newOperand() const { assert(isNew()); return impl_->value1; }
/*! \brief Altera o identificador de um grid com dados climáticos Deve ser utilizado apenas em grids novos que ainda não tenham sido salvos, para setar seu novo Id. */ void WeatherGrid::setId(int id) { assert(id >= 0); assert(isNew()); _data.id = id; }