/** * Constructeur de PauseMenu */ PauseMenu::PauseMenu(Core* core) : GUIPage(core) { setId(IN_PAUSE_MENU); }
void TiledObject::initialize() { if(!m_componentCompleted) { m_componentCompleted = true; return; } // Extract properties from layer TiledLayer *tiledLayer = qobject_cast<TiledLayer *>(parent()); if(!tiledLayer && !tiledLayer->layer()) return; if(!tiledLayer->layer()->isObjectLayer()) return; m_layerName = tiledLayer->name(); if(m_objectGroup) m_objectGroup->deleteLater(); m_objectGroup = new TMXObjectGroup(*tiledLayer->layer(), this); if(!m_objectGroup) return; int collisions = 0; m_collisionIndex = -1; foreach(const TMXMapObject &object, m_objectGroup->objects()) { if(object.name() == m_name && object.type() == m_type) { if(!static_cast<TiledScene *>(tiledLayer->parentItem())) return; //if(!collisions) { setProperties(object.properties()); setX(object.x()); setY(object.y()); setWidth(object.width()); setHeight(object.height()); setRotation(object.rotation()); setVisible(object.isVisible()); setId(object.id()); //} CollisionItem *item = new CollisionItem(tiledLayer->parentItem()); item->setX(object.x()); item->setY(object.y()); item->setWidth(object.width()); item->setHeight(object.height()); item->setRotation(object.rotation()); item->setVisible(object.isVisible()); item->setId(object.id()); item->setProperties(object.properties()); item->setCollisionIndex(collisions); m_collisionItems.append(item); switch(object.shape()) { case TMXMapObject::Rectangle: createRectangularFixture(object, item); break; case TMXMapObject::Ellipse: createEllipseFixture(object, item); break; case TMXMapObject::Polygon: createPolygonFixture(object, item); break; case TMXMapObject::Polyline: createPolylineFixture(object, item); break; default: qWarning() << "Unhandled object group: " << object.name(); break; } setBody(item->body()); collisions++; } } }
void CurrDisplay::reset() { clear(); setId(_baseId); setEffective(QDate().currentDate()); }
void GccToolChain::updateId() { QString i = id(); i = i.left(i.indexOf(QLatin1Char(':'))); setId(QString::fromLatin1("%1:%2.%3").arg(i).arg(m_compilerPath).arg(m_forcedTo32Bit)); }
void SoLineEdit::clear() { setId(-1); }
EditorDocument::EditorDocument() { setId(Constants::EditorId); }
SysRootKitInformation::SysRootKitInformation() { setObjectName(QLatin1String("SysRootInformation")); setId(SysRootKitInformation::id()); setPriority(31000); }
void Documents::setCurrentDocument(int strNum) { setId(strNum); currentDocument->setDocId(strNum); }
ProgramBank::ProgramBank(int id) : d(new Private) { setId(id); }
inline void setPosition(long p) { setId(p); }
Gene(std::string sym, std::string chr, uint_64 st_, uint_64 sp_, size_t h, int lv, long ps) : symbol(sym), chrom(chr), start_p(st_), stop_p(sp_), entrez_ID(-1), hs(h), intr(0), cis(-1), trans(-1), nexp(0) { setLevel(lv); setId(ps); }
ChallengeData::ChallengeData(const std::string& filename) { m_filename = filename; m_mode = CM_SINGLE_RACE; m_minor = RaceManager::MINOR_MODE_NORMAL_RACE; m_num_laps = -1; m_track_id = ""; m_gp_id = ""; m_version = 0; m_num_trophies = 0; for (int d=0; d<RaceManager::DIFFICULTY_COUNT; d++) { m_num_karts[d] = -1; m_position[d] = -1; m_time[d] = -1.0f; m_energy[d] = -1; m_ai_superpower[d] = RaceManager::SUPERPOWER_NONE; } // we are using auto_ptr to make sure the XML node is released when leaving // the scope std::auto_ptr<XMLNode> root(new XMLNode( filename )); if(root.get() == NULL || root->getName()!="challenge") { std::ostringstream msg; msg << "Couldn't load challenge '" << filename << "': no challenge node."; throw std::runtime_error(msg.str()); } setId(StringUtils::removeExtension(StringUtils::getBasename(filename))); root->get("version", &m_version); // No need to get the rest of the data if this challenge // is not supported anyway (id is needed for warning message) if(!unlock_manager->isSupportedVersion(*this)) { Log::warn("ChallengeData", "Challenge <%s> is older " "or newer than this version of STK, will be ignored.\n", filename.c_str()); return; } const XMLNode* mode_node = root->getNode("mode"); if (mode_node == NULL) { throw std::runtime_error("Challenge file " + filename + " has no <mode> node!"); } std::string mode; mode_node->get("major", &mode); if(mode=="grandprix") m_mode = CM_GRAND_PRIX; else if(mode=="single") m_mode = CM_SINGLE_RACE; else if(mode=="any") m_mode = CM_ANY; else error("major"); mode_node->get("minor", &mode); if(mode=="timetrial") m_minor = RaceManager::MINOR_MODE_TIME_TRIAL; else if(mode=="quickrace") m_minor = RaceManager::MINOR_MODE_NORMAL_RACE; else if(mode=="followtheleader") m_minor = RaceManager::MINOR_MODE_FOLLOW_LEADER; else error("minor"); const XMLNode* track_node = root->getNode("track"); const XMLNode* gp_node = root->getNode("grandprix"); if (m_mode == CM_SINGLE_RACE && track_node == NULL) { throw std::runtime_error("Challenge file " + filename + " has no <track> node!"); } if (m_mode == CM_GRAND_PRIX && gp_node == NULL) { throw std::runtime_error("Challenge file " + filename + " has no <grandprix> node!"); } if (track_node != NULL) { if (!track_node->get("id", &m_track_id )) { error("track"); } if (track_manager->getTrack(m_track_id) == NULL) { error("track"); } if (!track_node->get("laps", &m_num_laps) && m_minor != RaceManager::MINOR_MODE_FOLLOW_LEADER) { error("laps"); } } else if (gp_node != NULL) { if (!gp_node->get("id", &m_gp_id )) { error("grandprix"); } } const XMLNode* requirements_node = root->getNode("requirements"); if (requirements_node == NULL) { throw std::runtime_error("Challenge file " + filename + " has no <requirements> node!"); } requirements_node->get("trophies", &m_num_trophies); const XMLNode* difficulties[RaceManager::DIFFICULTY_COUNT]; difficulties[0] = root->getNode("easy"); difficulties[1] = root->getNode("medium"); difficulties[2] = root->getNode("hard"); // Note that the challenges can only be done in three difficulties if (difficulties[0] == NULL || difficulties[1] == NULL || difficulties[2] == NULL) { error("<easy> or <medium> or <hard>"); } for (int d=0; d<=RaceManager::DIFFICULTY_HARD; d++) { const XMLNode* karts_node = difficulties[d]->getNode("karts"); if (karts_node == NULL) error("<karts .../>"); int num_karts = -1; if (!karts_node->get("number", &num_karts)) error("karts"); m_num_karts[d] = num_karts; std::string ai_kart_ident; if (karts_node->get("aiIdent", &ai_kart_ident)) m_ai_kart_ident[d] = ai_kart_ident; std::string superPower; if (karts_node->get("superPower", &superPower)) { if (superPower == "nolokBoss") { m_ai_superpower[d] = RaceManager::SUPERPOWER_NOLOK_BOSS; } else { Log::warn("ChallengeData", "Unknown superpower '%s'", superPower.c_str()); } } const XMLNode* requirements_node = difficulties[d]->getNode("requirements"); if (requirements_node == NULL) error("<requirements .../>"); int position = -1; if (!requirements_node->get("position", &position) && (m_minor == RaceManager::MINOR_MODE_FOLLOW_LEADER || m_mode == CM_GRAND_PRIX)) { error("position"); } else { m_position[d] = position; } int time = -1; if (requirements_node->get("time", &time)) m_time[d] = (float)time; if (m_time[d] < 0 && m_position[d] < 0) error("position/time"); // This is optional int energy = -1; if (requirements_node->get("energy", &energy)) m_energy[d] = energy; } std::vector<XMLNode*> unlocks; root->getNodes("unlock", unlocks); for(unsigned int i=0; i<unlocks.size(); i++) { std::string s; if(unlocks[i]->get("kart", &s)) setUnlocks(s, ChallengeData::UNLOCK_KART); else if(unlocks[i]->get("track", &s)) addUnlockTrackReward(s); else if(unlocks[i]->get("gp", &s)) setUnlocks(s, ChallengeData::UNLOCK_GP); else if(unlocks[i]->get("mode", &s)) setUnlocks(s, ChallengeData::UNLOCK_MODE); else if(unlocks[i]->get("difficulty", &s)) setUnlocks(s, ChallengeData::UNLOCK_DIFFICULTY); else { Log::warn("ChallengeData", "Unknown unlock entry. Must be one of kart, track, gp, mode, difficulty."); throw std::runtime_error("Unknown unlock entry"); } } core::stringw description; if (track_node != NULL) { //I18N: number of laps to race in a challenge description += _("Laps : %i", m_num_laps); description += core::stringw(L"\n"); } m_challenge_description = description; } // ChallengeData
DomElement *WPaintedWidget::createDomElement(WApplication *app) { if (isInLayout()) { setLayoutSizeAware(true); setJavaScriptMember(WT_RESIZE_JS, "function(self, w, h) {" """var u = $(self).find('canvas, img');" """if (w >= 0) " "" "u.width(w);" """if (h >= 0) " "" "u.height(h);" "}"); } createPainter(); DomElement *result = DomElement::createNew(domElementType()); setId(result, app); DomElement *wrap = result; if (width().isAuto() && height().isAuto()) { result->setProperty(PropertyStylePosition, "relative"); wrap = DomElement::createNew(DomElement_DIV); wrap->setProperty(PropertyStylePosition, "absolute"); wrap->setProperty(PropertyStyleLeft, "0"); wrap->setProperty(PropertyStyleRight, "0"); } DomElement *canvas = DomElement::createNew(DomElement_DIV); if (!app->environment().agentIsSpiderBot()) canvas->setId('p' + id()); WPaintDevice *device = painter_->getPaintDevice(false); //handle the widget correctly when inline and using VML if (painter_->renderType() == WWidgetPainter::InlineVml && isInline()) { result->setProperty(PropertyStyle, "zoom: 1;"); canvas->setProperty(PropertyStyleDisplay, "inline"); canvas->setProperty(PropertyStyle, "zoom: 1;"); } if (renderWidth_ != 0 && renderHeight_ != 0) { paintEvent(device); #ifdef WT_TARGET_JAVA if (device->painter()) device->painter()->end(); #endif // WT_TARGET_JAVA } painter_->createContents(canvas, device); needRepaint_ = false; wrap->addChild(canvas); if (wrap != result) result->addChild(wrap); updateDom(*result, true); return result; }
TestNavigationWidgetFactory::TestNavigationWidgetFactory() { setDisplayName(tr("Tests")); setId(Autotest::Constants::AUTOTEST_ID); setPriority(666); }
bool QgsComposerItem::_readXML( const QDomElement& itemElem, const QDomDocument& doc ) { Q_UNUSED( doc ); if ( itemElem.isNull() ) { return false; } //rotation setItemRotation( itemElem.attribute( "itemRotation", "0" ).toDouble() ); //uuid mUuid = itemElem.attribute( "uuid", QUuid::createUuid().toString() ); // temporary for groups imported from templates mTemplateUuid = itemElem.attribute( "templateUuid" ); //id QString id = itemElem.attribute( "id", "" ); setId( id ); //frame QString frame = itemElem.attribute( "frame" ); if ( frame.compare( "true", Qt::CaseInsensitive ) == 0 ) { mFrame = true; } else { mFrame = false; } //frame QString background = itemElem.attribute( "background" ); if ( background.compare( "true", Qt::CaseInsensitive ) == 0 ) { mBackground = true; } else { mBackground = false; } //position lock for mouse moves/resizes QString positionLock = itemElem.attribute( "positionLock" ); if ( positionLock.compare( "true", Qt::CaseInsensitive ) == 0 ) { setPositionLock( true ); } else { setPositionLock( false ); } //position double x, y, width, height; bool xOk, yOk, widthOk, heightOk, positionModeOK; x = itemElem.attribute( "x" ).toDouble( &xOk ); y = itemElem.attribute( "y" ).toDouble( &yOk ); width = itemElem.attribute( "width" ).toDouble( &widthOk ); height = itemElem.attribute( "height" ).toDouble( &heightOk ); mLastUsedPositionMode = ( ItemPositionMode )itemElem.attribute( "positionMode" ).toInt( &positionModeOK ); if ( !positionModeOK ) { mLastUsedPositionMode = UpperLeft; } if ( !xOk || !yOk || !widthOk || !heightOk ) { return false; } mLastValidViewScaleFactor = itemElem.attribute( "lastValidViewScaleFactor", "-1" ).toDouble(); setSceneRect( QRectF( x, y, width, height ) ); setZValue( itemElem.attribute( "zValue" ).toDouble() ); //pen QDomNodeList frameColorList = itemElem.elementsByTagName( "FrameColor" ); if ( frameColorList.size() > 0 ) { QDomElement frameColorElem = frameColorList.at( 0 ).toElement(); bool redOk, greenOk, blueOk, alphaOk, widthOk; int penRed, penGreen, penBlue, penAlpha; double penWidth; penWidth = itemElem.attribute( "outlineWidth" ).toDouble( &widthOk ); penRed = frameColorElem.attribute( "red" ).toDouble( &redOk ); penGreen = frameColorElem.attribute( "green" ).toDouble( &greenOk ); penBlue = frameColorElem.attribute( "blue" ).toDouble( &blueOk ); penAlpha = frameColorElem.attribute( "alpha" ).toDouble( &alphaOk ); mFrameJoinStyle = QgsSymbolLayerV2Utils::decodePenJoinStyle( itemElem.attribute( "frameJoinStyle", "miter" ) ); if ( redOk && greenOk && blueOk && alphaOk && widthOk ) { QPen framePen( QColor( penRed, penGreen, penBlue, penAlpha ) ); framePen.setWidthF( penWidth ); framePen.setJoinStyle( mFrameJoinStyle ); setPen( framePen ); } } //brush QDomNodeList bgColorList = itemElem.elementsByTagName( "BackgroundColor" ); if ( bgColorList.size() > 0 ) { QDomElement bgColorElem = bgColorList.at( 0 ).toElement(); bool redOk, greenOk, blueOk, alphaOk; int bgRed, bgGreen, bgBlue, bgAlpha; bgRed = bgColorElem.attribute( "red" ).toDouble( &redOk ); bgGreen = bgColorElem.attribute( "green" ).toDouble( &greenOk ); bgBlue = bgColorElem.attribute( "blue" ).toDouble( &blueOk ); bgAlpha = bgColorElem.attribute( "alpha" ).toDouble( &alphaOk ); if ( redOk && greenOk && blueOk && alphaOk ) { QColor brushColor( bgRed, bgGreen, bgBlue, bgAlpha ); setBackgroundColor( brushColor ); } } //blend mode setBlendMode( QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode ) itemElem.attribute( "blendMode", "0" ).toUInt() ) ); //transparency setTransparency( itemElem.attribute( "transparency" , "0" ).toInt() ); return true; }
EnvironmentAspect::EnvironmentAspect(RunConfiguration *runConfig) : IRunConfigurationAspect(runConfig), m_base(-1) { setDisplayName(tr("Run Environment")); setId("EnvironmentAspect"); }
RenderTargetDescs loadRTDesc( const QString& path ) { /**/ QByteArray tmpByteArray = path.toLocal8Bit(); const int numRT = GetPrivateProfileIntA( "RT", "NUM_RT", 0, tmpByteArray.data() ); /**/ RenderTargetDescs descs = {0}; descs.numRT = numRT; /* RTは0番がバックバッファで、1番から別のRTを作る点に注意 */ for(int i=1;i<numRT+1;++i) { /**/ RenderTargetDesc& desc = descs.rtDescs[i]; /**/ char formatStr[MAX_PATH+1] = {'\0'}; char keyStr[MAX_PATH+1] = {'\0'}; /**/ sprintf(keyStr, "name%d", i ); GetPrivateProfileStringA( "RT", keyStr, "", formatStr, MAX_PATH, tmpByteArray.data() ); if( strcmp( formatStr, "" ) ) { setId("RT_NAME", formatStr ); } /* フォーマット取得 */ sprintf(keyStr, "format%d", i ); GetPrivateProfileStringA( "RT", keyStr, "", formatStr, MAX_PATH, tmpByteArray.data() ); if( !strcmp( formatStr, "B8G8R8A8" )) { desc.format = DXGI_FORMAT_B8G8R8A8_UNORM; } else if( !strcmp( formatStr, "R32G32B32A32_FLOAT" )) { desc.format = DXGI_FORMAT_R32G32B32A32_FLOAT; } else if( !strcmp( formatStr, "R16G16B16A16_FLOAT" )) { desc.format = DXGI_FORMAT_R16G16B16A16_FLOAT; } else if( !strcmp( formatStr, "R16G16_FLOAT" )) { desc.format = DXGI_FORMAT_R16G16_FLOAT; } else if( !strcmp( formatStr, "R32_FLOAT" )) { desc.format = DXGI_FORMAT_R32_FLOAT; } else if( !strcmp( formatStr, "R32G32_FLOAT" )) { desc.format = DXGI_FORMAT_R32G32_FLOAT; } else { NL_ERR( ERR_015, formatStr ); desc.format = DXGI_FORMAT_B8G8R8A8_UNORM; } /* サイズ */ sprintf(keyStr, "size%d", i ); GetPrivateProfileStringA( "RT", keyStr, "normal", formatStr, MAX_PATH, tmpByteArray.data() ); if( !strcmp(formatStr,"normal") ) { desc.scaleByBackbuffer = 0; } else if( !strcmp(formatStr,"half") ) { desc.scaleByBackbuffer = 1; } else if( !strcmp(formatStr,"quarter") ) { desc.scaleByBackbuffer = 2; } else { NL_ERR( ERR_016, formatStr ); desc.scaleByBackbuffer = 0; } } /**/ descs.numDS = GetPrivateProfileIntA( "DS", "NUM_DS", 0, tmpByteArray.data() ); /* DSは0番がバックバッファ用で、1番から別のDSを作る点に注意 */ for(int i=1;i<descs.numDS+1;++i) { /**/ RenderTargetDesc& desc = descs.dsDescs[i]; /**/ char formatStr[MAX_PATH+1] = {'\0'}; char keyStr[MAX_PATH+1] = {'\0'}; /**/ sprintf(keyStr, "name%d", i ); GetPrivateProfileStringA( "DS", keyStr, "", formatStr, MAX_PATH, tmpByteArray.data() ); if( strcmp( formatStr, "" ) ) { setId("DS_NAME", formatStr ); } /* フォーマットは固定 */ desc.format = DXGI_FORMAT_D24_UNORM_S8_UINT; /* サイズ */ sprintf(keyStr, "size%d", i ); GetPrivateProfileStringA( "DS", keyStr, "normal", formatStr, MAX_PATH, tmpByteArray.data() ); if( !strcmp(formatStr,"normal") ) { desc.scaleByBackbuffer = 0; } else if( !strcmp(formatStr,"half") ) { desc.scaleByBackbuffer = 1; } else if( !strcmp(formatStr,"quarter") ) { desc.scaleByBackbuffer = 2; } else { NL_ERR( ERR_016, formatStr ); desc.scaleByBackbuffer = 0; } } /**/ return descs; }
ParticleState::ParticleState(int id, double E, Vector3d pos, Vector3d dir) { setId(id); setEnergy(E); setPosition(pos); setDirection(dir); }
void UsernameLineEdit::clear() { setId(-1); _username = ""; setText(QString()); }
UpDownFrame::UpDownFrame(Frame* parent, int id, int style) : WindowFrame(parent) { create(UPDOWN_CLASS, L"", WS_CHILD | style, 0); setId(id); }
Container::Container(unsigned id, const char *cfg) { m_bInit = false; m_bInSize = false; m_bStatusSize = false; m_bBarChanged = false; m_bReceived = false; m_bNoSwitch = false; m_bNoRead = false; m_wnds = NULL; m_tabBar = NULL; SET_WNDPROC("container") setWFlags(WDestructiveClose); if (cfg && *cfg){ Buffer config; config << "[Title]\n" << cfg; config.setWritePos(0); config.getSection(); load_data(containerData, &data, &config); }else{ load_data(containerData, &data, NULL); } bool bPos = true; if (cfg == NULL){ setId(id); memcpy(data.barState, CorePlugin::m_plugin->data.containerBar, sizeof(data.barState)); memcpy(data.geometry, CorePlugin::m_plugin->data.containerGeo, sizeof(data.geometry)); if ((data.geometry[WIDTH].value == (unsigned long)-1) || (data.geometry[HEIGHT].value == (unsigned long)-1)){ QWidget *desktop = QApplication::desktop(); data.geometry[WIDTH].value = desktop->width() / 3; data.geometry[HEIGHT].value = desktop->height() / 3; } bPos = false; if ((data.geometry[TOP].value != (unsigned long)-1) || (data.geometry[LEFT].value != (unsigned long)-1)){ bPos = true; QWidgetList *list = QApplication::topLevelWidgets(); for (int i = 0; i < 2; i++){ bool bOK = true; QWidgetListIt it(*list); QWidget * w; while ((w = it.current()) != NULL){ if (w == this){ ++it; continue; } if (w->inherits("Container")){ int dw = w->pos().x() - data.geometry[LEFT].value; int dh = w->pos().y() - data.geometry[TOP].value; if (dw < 0) dw = -dw; if (dh < 0) dh = -dh; if ((dw < 3) && (dh < 3)){ int nl = data.geometry[LEFT].value; int nt = data.geometry[TOP].value; nl += 21; nt += 20; QWidget *desktop = QApplication::desktop(); if (nl + (int)data.geometry[WIDTH].value > desktop->width()) nl = 0; if (nt + (int)data.geometry[WIDTH].value > desktop->width()) nt = 0; if ((nl != (int)data.geometry[LEFT].value) && (nt != (int)data.geometry[TOP].value)){ data.geometry[LEFT].value = nl; data.geometry[TOP].value = nt; bOK = false; } } } ++it; } if (bOK) break; } delete list; } setStatusSize(CorePlugin::m_plugin->getContainerStatusSize()); } m_bInSize = true; restoreGeometry(this, data.geometry, bPos, true); m_bInSize = false; }
/* copied from virtualCluster.cpp but with one important difference: if a not-strict flag is set then warn the user but don't clear the lotserial field */ void LotserialLineEdit::sParse() { if (_x_metrics) if (_x_metrics->boolean("LotSerialControl")) { if (! _parsed) { QString stripped = text().trimmed().toUpper(); if (stripped.length() == 0) { _parsed = true; setId(-1); } else { XSqlQuery numQ; numQ.prepare(_query + _numClause + (_extraClause.isEmpty() ? "" : " AND " + _extraClause) + QString("ORDER BY %1 LIMIT 1;").arg(_numColName)); numQ.bindValue(":number", "^" + stripped); numQ.exec(); if (numQ.first()) { _valid = true; setId(numQ.value("id").toInt()); _name = (numQ.value("name").toString()); _itemid = (numQ.value("item_id").toInt()); } else if (numQ.lastError().type() != QSqlError::NoError) { QMessageBox::critical(this, tr("A System Error Occurred at %1::%2.") .arg(__FILE__) .arg(__LINE__), numQ.lastError().databaseText()); return; } else if (_strict || _itemid == -1) VirtualClusterLineEdit::clear(); else if (isVisible() && QMessageBox::question(this, tr("Lot/Serial # Not Found"), (_itemid > 0 ? tr("This Lot/Serial # was not found for this item.") : tr("This Lot/Serial # was not found.")) + tr(" Are you sure it is correct?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) { VirtualClusterLineEdit::clear(); return; } else { int lsid=-1; numQ.exec("SELECT nextval('ls_ls_id_seq') AS ls_id;"); if (numQ.first()) lsid= numQ.value("ls_id").toInt(); else if (numQ.lastError().type() != QSqlError::NoError) { QMessageBox::critical(this, tr("A System Error Occurred at %1::%2.") .arg(__FILE__) .arg(__LINE__), numQ.lastError().databaseText()); return; } numQ.prepare("INSERT INTO ls (ls_id,ls_item_id,ls_number) " "VALUES (:ls_id,:item_id,:number)"); numQ.bindValue(":ls_id", lsid); numQ.bindValue(":item_id", _itemid); numQ.bindValue(":number", stripped); numQ.exec(); if (numQ.lastError().type() != QSqlError::NoError) { QMessageBox::critical(this, tr("A System Error Occurred at %1::%2.") .arg(__FILE__) .arg(__LINE__), numQ.lastError().databaseText()); return; } setId(lsid); } } } _parsed = TRUE; emit parsed(); } }
void RomInfo::fillData() { if (m_gamename == "") { return; } MSqlQuery query(MSqlQuery::InitCon()); QString systemtype; if (m_system != "") { systemtype += " AND system = :SYSTEM "; } QString thequery = "SELECT system,gamename,genre,year,romname,favorite," "rompath,country,crc_value,diskcount,gametype,plot,publisher," "version,screenshot,fanart,boxart,inetref,intid FROM gamemetadata " "WHERE gamename = :GAMENAME " + systemtype + " ORDER BY diskcount DESC"; query.prepare(thequery); query.bindValue(":SYSTEM", m_system); query.bindValue(":GAMENAME", m_gamename); if (query.exec() && query.next()) { setSystem(query.value(0).toString()); setGamename(query.value(1).toString()); setGenre(query.value(2).toString()); setYear(query.value(3).toString()); setRomname(query.value(4).toString()); setField("favorite",query.value(5).toString()); setRompath(query.value(6).toString()); setCountry(query.value(7).toString()); setCRC_VALUE(query.value(8).toString()); setDiskCount(query.value(9).toInt()); setGameType(query.value(10).toString()); setPlot(query.value(11).toString()); setPublisher(query.value(12).toString()); setVersion(query.value(13).toString()); setScreenshot(query.value(14).toString()); setFanart(query.value(15).toString()); setBoxart(query.value(16).toString()); setInetref(query.value(17).toString()); setId(query.value(18).toInt()); } setRomCount(romInDB(m_romname,m_gametype)); // If we have more than one instance of this rom in the DB fill in all // systems available to play it. if (RomCount() > 1) { query.prepare("SELECT DISTINCT system FROM gamemetadata " "WHERE romname = :ROMNAME"); query.bindValue(":ROMNAME", Romname()); if (!query.exec()) MythDB::DBError("RomInfo::fillData - selecting systems", query); while (query.next()) { if (m_allsystems.isEmpty()) m_allsystems = query.value(0).toString(); else m_allsystems += "," + query.value(0).toString(); } } else { m_allsystems = m_system; } }
ProFileDocument::ProFileDocument() { setId(Constants::PROFILE_EDITOR_ID); setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE)); }
void SoLineEdit::setId(int pId) { if (pId == _id) return; if ((_x_preferences) && (pId != -1) && (_sitePrivs)) { if (_x_preferences->boolean("selectedSites")) { QString sql("SELECT coitem_id " "FROM coitem, itemsite " "WHERE ((coitem_cohead_id=<? value(\"sohead_id\") ?>) " " AND (coitem_itemsite_id=itemsite_id) " " AND (itemsite_warehous_id NOT IN (" " SELECT usrsite_warehous_id " " FROM usrsite " " WHERE (usrsite_username=current_user)))) " "UNION " "SELECT cohead_warehous_id " "FROM cohead " "WHERE ((cohead_id=<? value(\"sohead_id\") ?>) " " AND (cohead_warehous_id NOT IN (" " SELECT usrsite_warehous_id " " FROM usrsite " " WHERE (usrsite_username=current_user))));"); MetaSQLQuery mql(sql); ParameterList params; params.append("sohead_id", pId); XSqlQuery chk = mql.toQuery(params); if (chk.first()) { QMessageBox::critical(this, tr("Access Denied"), tr("You may not view or edit this Sales Order as it references " "a warehouse for which you have not been granted privileges.")) ; setId(-1); return; } } } XSqlQuery sohead; sohead.prepare( "SELECT cohead_number, cohead_cust_id, cohead_billtoname " "FROM cohead, cust " "WHERE ( (cohead_cust_id=cust_id)" " AND (cohead_id=:sohead_id) );" ); sohead.bindValue(":sohead_id", pId); sohead.exec(); if (sohead.first()) { _id = pId; _number = sohead.value("cohead_number").toInt(); _custid = sohead.value("cohead_cust_id").toInt(); _valid = TRUE; emit numberChanged(sohead.value("cohead_number").toString()); emit custNameChanged(sohead.value("cohead_billtoname").toString()); setText(sohead.value("cohead_number").toString()); if (_mapper->model() && _mapper->model()->data(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(this))).toString() != text()) _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(this)), text()); } else { _id = -1; _number = -1; _custid = -1; _valid = FALSE; emit numberChanged(""); emit custNameChanged(""); setText(""); } emit newId(_id); emit custidChanged(_custid); emit numberChanged(_number); emit valid(_valid); _parsed = TRUE; }
void WoLineEdit::sParse() { if (!_parsed) { if (text().trimmed().length() == 0) setId(-1); else if (_useQuery) { XSqlQuery wo; wo.prepare(_sql); wo.exec(); if (wo.findFirst("wonumber", text().trimmed().toUpper()) != -1) { setId(wo.value("wo_id").toInt()); return; } } else if (text().contains('-')) { int soNumber = text().left(text().find('-')).toInt(); int subNumber = text().right(text().length() - text().find('-') - 1).toInt(); // bool statusCheck = FALSE; QString sql = QString( "SELECT wo_id " "FROM wo,itemsite,site() " "WHERE ((wo_number=%1)" " AND (wo_subnumber=%2) " " AND (wo_itemsite_id=itemsite_id) " " AND (itemsite_warehous_id=warehous_id)" ) .arg(soNumber) .arg(subNumber); // Add in the Status checks QStringList statuses; if (_woType & cWoOpen) statuses << "(wo_status='O')"; if (_woType & cWoExploded) statuses << "(wo_status='E')"; if (_woType & cWoReleased) statuses << "(wo_status='R')"; if (_woType & cWoIssued) statuses << "(wo_status='I')"; if (_woType & cWoClosed) statuses << "(wo_status='C')"; if(!statuses.isEmpty()) sql += " AND (" + statuses.join(" OR ") + ")"; sql += ")"; XSqlQuery wo(sql); if (wo.first()) setId(wo.value("wo_id").toInt()); else setId(-1); } else { bool statusCheck = FALSE; QString sql = QString( "SELECT wo_id, wo_number " "FROM wo,itemsite,site() " "WHERE ((wo_number=%1) " " AND (wo_itemsite_id=itemsite_id)" " AND (itemsite_warehous_id=warehous_id)") .arg(text().toInt()); // Add in the Status checks if (_woType) { sql += " AND ("; if (_woType & cWoOpen) { sql += "(wo_status='O')"; statusCheck = TRUE; } if (_woType & cWoExploded) { if (statusCheck) sql += " OR "; sql += "(wo_status='E')"; statusCheck = TRUE; } if (_woType & cWoReleased) { if (statusCheck) sql += " OR "; sql += "(wo_status='R')"; statusCheck = TRUE; } if (_woType & cWoIssued) { if (statusCheck) sql += " OR "; sql += "(wo_status='I')"; statusCheck = TRUE; } if (_woType & cWoClosed) { if (statusCheck) sql += " OR "; sql += "(wo_status='C')"; } sql += ")"; } sql += ");"; XSqlQuery wo(sql); if (wo.first()) { if (wo.size() == 1) setId(wo.value("wo_id").toInt()); else { setId(-1); setText(wo.value("wo_number").toString() + "-"); focusNextPrevChild(FALSE); home(FALSE); end(FALSE); } } else setId(-1); } } }
QSharedPointer<VKContainerDialog> VKContainerDialog::fromJson(VKStorage *storage, QJsonObject obj, const QJsonArray users) { auto dialog = QSharedPointer<VKContainerDialog>(new VKContainerDialog(storage)); dialog->beginObjectChange(); dialog->setUnreadCount(obj.value("unread").toInt()); QJsonObject message; if (obj.contains("message")) { message = obj.value("message").toObject(); } else if (obj.contains("body") && obj.contains("id")) { message = obj; dialog->setUnreadCount(1); } else { qDebug()<<"Unknown object for VKContainerDialog"; qDebug()<<"Keys:"; for (auto it = message.begin();it != message.end(); ++it) { qDebug()<<it.key(); } Q_ASSERT(0); } if (message.contains("chat_id")) { dialog->setIsChat(true); dialog->setId(message.value("chat_id").toInt()); } else { dialog->setIsChat(false); dialog->setId(message.value("user_id").toInt()); } if (message.value("title").toString() != " ... ") { dialog->setChatName(message.value("title").toString()); } else { int user_id = message.value("user_id").toInt(); bool b = false; for (auto e : users) { auto el = e.toObject(); if (el.value("id").toInt() == user_id) { dialog->setChatName(QString("%1 %2") .arg(el.value("first_name").toString()) .arg(el.value("last_name").toString())); b = true; break; } } if (!b) { dialog->setChatName(message.value("title").toString()); } } auto chatIcon = QSharedPointer<VKContainerChatIcon>(new VKContainerChatIcon(storage)); if (message.value("photo_100").isString()) { chatIcon->add(message.value("photo_100").toString()); } else { for (int i=0;i<4 && i<users.count();i++) { auto user = users.at(i).toObject(); chatIcon->add(user.value("photo_100").toString()); } } dialog->setChatIcon(chatIcon); auto containerMessage = VKContainerMessage::fromJson(storage, message, users); storage->addMessage(containerMessage); dialog->endObjectChange(); dialog->setValid(); return dialog; }
void UsernameLineEdit::clear() { setId(-1); }
User::User(DataBase *db, int id) : db(db) { setId(id); }
Object::~Object() { if (m_id) setId(0); }