本文整理汇总了C++中RowCount函数的典型用法代码示例。如果您正苦于以下问题:C++ RowCount函数的具体用法?C++ RowCount怎么用?C++ RowCount使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RowCount函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectionModel
void MyStringTable::keyPressEvent(QKeyEvent* event)
{
QTableView::keyPressEvent(event);
QItemSelectionModel *sel = selectionModel();
if(!sel->hasSelection()) return;
// QModelIndexList list = sel->selectedRows();
// if(list.count()<1) return ;
// int row = list.at(0).row();
int key = event->key();
if(key==Qt::Key_Enter || key==Qt::Key_Return)
{
int r = currentIndex().row();
int c = currentIndex().column();
if(ColEdit(c))
{
if(this->state()!=QAbstractItemView::EditingState)
{
edit(currentIndex());
}
}
else
{
emit rowEvent(r, 2);
}
}
else if(key==Qt::Key_Home)
{
QApplication::beep();
QModelIndex index = _model->index(0,0, QModelIndex());
sel->clearSelection();
setCurrentIndex(index);
}
else if(key==Qt::Key_End)
{
QModelIndex index = _model->index(RowCount()-1,0, QModelIndex());
sel->clearSelection();
setCurrentIndex(index);
}
}
示例2: StringFormat
//AndMetal: this may now be obsolete since we have Zone::GetTotalAALevels()
uint8 ZoneDatabase::GetTotalAALevels(uint32 skill_id) {
std::string query = StringFormat("SELECT count(slot) FROM aa_effects WHERE aaid = %i", skill_id);
auto results = QueryDatabase(query);
if (!results.Success()) {
return 0;
}
if (results.RowCount() != 1)
return 0;
auto row = results.begin();
return atoi(row[0]);
}
示例3: StringFormat
int ZoneDatabase::GetHighestGrid(uint32 zoneid) {
std::string query = StringFormat("SELECT COALESCE(MAX(id), 0) FROM grid WHERE zoneid = %i", zoneid);
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEMuLog::Error, "Error in GetHighestGrid query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return 0;
}
if (results.RowCount() != 1)
return 0;
auto row = results.begin();
return atoi(row[0]);
}
示例4: count
uint32 ZoneDatabase::CountAAs(){
const std::string query = "SELECT count(title_sid) FROM altadv_vars";
auto results = QueryDatabase(query);
if (!results.Success()) {
return 0;
}
if (results.RowCount() != 1)
return 0;
auto row = results.begin();
return atoi(row[0]);;
}
示例5: StringFormat
int ZoneDatabase::GetHighestWaypoint(uint32 zoneid, uint32 gridid) {
std::string query = StringFormat("SELECT COALESCE(MAX(number), 0) FROM grid_entries "
"WHERE zoneid = %i AND gridid = %i", zoneid, gridid);
auto results = QueryDatabase(query);
if (!results.Success()) {
return 0;
}
if (results.RowCount() != 1)
return 0;
auto row = results.begin();
return atoi(row[0]);
}
示例6: GetSkill
int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) {
std::string query = StringFormat("SELECT cap FROM skill_caps WHERE class=%d AND skillID=%d AND level=%d",
class_id, skill_id, level);
auto results = db->QueryDatabase(query);
if (!results.Success()) {
return 0;
}
if (results.RowCount() == 0)
return 0;
auto row = results.begin();
return atoi(row[0]);
}
示例7: Cell
QString MyStringTable::Cell(int r, int c)
{
if(r<0 || r>=RowCount()) return "";
if(c<0 || c>=ColCount()) return "";
int rc = receivers(SIGNAL(cellDataRequest(int, int, QString&)));
if(rc<1) return _rows[r].cells[c].text;
QString v;
emit cellDataRequest(r,c,v);
return v;
}
示例8: StringFormat
bool ZoneDatabase::CheckGuildDoor(uint8 doorid, uint16 guild_id, const char* zone) {
std::string query = StringFormat("SELECT guild FROM doors WHERE doorid = %i AND zone = '%s'",
doorid-128, zone);
auto results = QueryDatabase(query);
if (!results.Success()) {
return false;
}
if (results.RowCount() != 1)
return false;
auto row = results.begin();
return atoi(row[0]) == guild_id;
}
示例9: StringFormat
bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc,bool isTitanium)
{
// SoF doesn't send the player_choice field in character creation, it now sends the real zoneID instead.
//
// For SoF, search for an entry in start_zones with a matching zone_id, class, race and deity.
//
// For now, if no row matching row is found, send them to Crescent Reach, as that is probably the most likely
// reason for no match being found.
//
if(!in_pp || !in_cc)
return false;
in_pp->x = in_pp->y = in_pp->z = in_pp->heading = in_pp->zone_id = 0;
in_pp->binds[0].x = in_pp->binds[0].y = in_pp->binds[0].z = in_pp->binds[0].zoneId = in_pp->binds[0].instance_id = 0;
// see if we have an entry for start_zone. We can support both titanium & SOF+ by having two entries per class/race/deity combo with different zone_ids
std::string query = StringFormat("SELECT x, y, z, heading, start_zone, bind_id FROM start_zones WHERE zone_id = %i "
"AND player_class = %i AND player_deity = %i AND player_race = %i",
in_cc->start_zone, in_cc->class_, in_cc->deity, in_cc->race);
auto results = QueryDatabase(query);
if(!results.Success()) {
return false;
}
Log.Out(Logs::General, Logs::Status, "SoF Start zone query: %s\n", query.c_str());
if (results.RowCount() == 0) {
printf("No start_zones entry in database, using defaults\n");
isTitanium ? SetTitaniumDefaultStartZone(in_pp, in_cc) : SetSoFDefaultStartZone(in_pp, in_cc);
}
else {
Log.Out(Logs::General, Logs::Status, "Found starting location in start_zones");
auto row = results.begin();
in_pp->x = atof(row[0]);
in_pp->y = atof(row[1]);
in_pp->z = atof(row[2]);
in_pp->heading = atof(row[3]);
in_pp->zone_id = atoi(row[4]);
in_pp->binds[0].zoneId = atoi(row[5]);
}
if(in_pp->x == 0 && in_pp->y == 0 && in_pp->z == 0)
database.GetSafePoints(in_pp->zone_id, 0, &in_pp->x, &in_pp->y, &in_pp->z);
if(in_pp->binds[0].x == 0 && in_pp->binds[0].y == 0 && in_pp->binds[0].z == 0)
database.GetSafePoints(in_pp->binds[0].zoneId, 0, &in_pp->binds[0].x, &in_pp->binds[0].y, &in_pp->binds[0].z);
return true;
}
示例10: StringFormat
const NPCType *Horse::BuildHorseType(uint16 spell_id) {
const char* fileName = spells[spell_id].teleport_zone;
std::string query = StringFormat("SELECT race, gender, texture, mountspeed FROM horses WHERE filename = '%s'", fileName);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return nullptr;
}
if (results.RowCount() != 1) {
Log.Out(Logs::General, Logs::Error, "No Database entry for mount: %s, check the horses table", fileName);
return nullptr;
}
auto row = results.begin();
NPCType* npc_type = new NPCType;
memset(npc_type, 0, sizeof(NPCType));
strcpy(npc_type->name,"Unclaimed_Mount"); //this should never get used
strcpy(npc_type->special_abilities, "19,1^20,1^24,1");
npc_type->cur_hp = 1;
npc_type->max_hp = 1;
npc_type->race = atoi(row[0]);
npc_type->gender = atoi(row[1]); // Drogmor's are female horses. Yuck.
npc_type->class_ = 1;
npc_type->deity= 1;
npc_type->level = 1;
npc_type->npc_id = 0;
npc_type->loottable_id = 0;
npc_type->texture = atoi(row[2]); // mount color
npc_type->helmtexture = atoi(row[2]); // mount color
npc_type->runspeed = atof(row[3]);
npc_type->light = 0;
npc_type->STR = 75;
npc_type->STA = 75;
npc_type->DEX = 75;
npc_type->AGI = 75;
npc_type->INT = 75;
npc_type->WIS = 75;
npc_type->CHA = 75;
npc_type->trackable = 1;
horses_auto_delete.Insert(npc_type);
return npc_type;
}
示例11: StringFormat
std::string RuleManager::GetRulesetName(Database *db, int id) {
std::string query = StringFormat("SELECT name FROM rule_sets WHERE ruleset_id=%d", id);
auto results = db->QueryDatabase(query);
if (!results.Success())
{
return "";
}
if (results.RowCount() == 0)
return "";
auto row = results.begin();
return row[0];
}
示例12: FindCharacter
void Database::SendBody(Client *client, int messageNumber) {
int characterID = FindCharacter(client->MailBoxName().c_str());
_log(UCS__TRACE, "SendBody: MsgID %i, to %s, CharID is %i", messageNumber, client->MailBoxName().c_str(), characterID);
if(characterID <= 0)
return;
std::string query = StringFormat("SELECT `msgid`, `body`, `to` FROM `mail` "
"WHERE `charid`=%i AND `msgid`=%i", characterID, messageNumber);
auto results = QueryDatabase(query);
if (!results.Success())
return;
if (results.RowCount() != 1)
return;
auto row = results.begin();
_log(UCS__TRACE, "Message: %i body (%i bytes)", messageNumber, strlen(row[1]));
int packetLength = 12 + strlen(row[0]) + strlen(row[1]) + strlen(row[2]);
EQApplicationPacket *outapp = new EQApplicationPacket(OP_MailSendBody,packetLength);
char *packetBuffer = (char *)outapp->pBuffer;
VARSTRUCT_ENCODE_INTSTRING(packetBuffer, client->GetMailBoxNumber());
VARSTRUCT_ENCODE_STRING(packetBuffer,row[0]);
VARSTRUCT_ENCODE_STRING(packetBuffer,row[1]);
VARSTRUCT_ENCODE_STRING(packetBuffer,"1");
VARSTRUCT_ENCODE_TYPE(uint8, packetBuffer, 0);
VARSTRUCT_ENCODE_TYPE(uint8, packetBuffer, 0x0a);
VARSTRUCT_ENCODE_STRING(packetBuffer, "TO:");
packetBuffer--;
VARSTRUCT_ENCODE_STRING(packetBuffer, row[2]);
packetBuffer--; // Overwrite the null terminator
VARSTRUCT_ENCODE_TYPE(uint8, packetBuffer, 0x0a);
_pkt(UCS__PACKETS, outapp);
client->QueuePacket(outapp);
safe_delete(outapp);
}
示例13: StringFormat
bool Database::DBSetup_SetEmailDefault()
{
std::string check_query = StringFormat("SHOW COLUMNS FROM `tblloginserveraccounts` LIKE 'AccountEmail'");
auto results = QueryDatabase(check_query);
if (results.RowCount() != 0)
{
std::string create_query = StringFormat("ALTER TABLE `tblloginserveraccounts` CHANGE `AccountEmail` `AccountEmail` varchar(100) not null default '0'");
auto create_results = QueryDatabase(create_query);
if (!create_results.Success())
{
server_log->Log(log_database_error, "Error adjusting AccountEmail column.");
return false;
}
}
server_log->Log(log_database, "Adjusted AccountEmail column.");
return true;
}
示例14: StringFormat
std::string RuleManager::GetRulesetName(Database *db, int id) {
std::string query = StringFormat("SELECT name FROM rule_sets WHERE ruleset_id=%d", id);
auto results = db->QueryDatabase(query);
if (!results.Success())
{
LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query.c_str(), results.ErrorMessage().c_str());
return "";
}
if (results.RowCount() == 0)
return "";
auto row = results.begin();
return row[0];
}
示例15: TradeskillSearchResults
void Client::TradeskillSearchResults(const std::string query, unsigned long objtype, unsigned long someid) {
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return;
}
if(results.RowCount() < 1)
return; //search gave no results... not an error
if(results.ColumnCount() != 6) {
Log.Out(Logs::General, Logs::Error, "Error in TradeskillSearchResults query '%s': Invalid column count in result", query.c_str());
return;
}
for(auto row = results.begin(); row != results.end(); ++row) {
if(row == nullptr || row[0] == nullptr || row[1] == nullptr || row[2] == nullptr || row[3] == nullptr || row[5] == nullptr)
continue;
uint32 recipe = (uint32)atoi(row[0]);
const char *name = row[1];
uint32 trivial = (uint32) atoi(row[2]);
uint32 comp_count = (uint32) atoi(row[3]);
uint32 tradeskill = (uint16) atoi(row[5]);
// Skip the recipes that exceed the threshold in skill difference
// Recipes that have either been made before or were
// explicitly learned are excempt from that limit
if (RuleB(Skills, UseLimitTradeskillSearchSkillDiff)
&& ((int32)trivial - (int32)GetSkill((SkillUseTypes)tradeskill)) > RuleI(Skills, MaxTradeskillSearchSkillDiff)
&& row[4] == nullptr)
continue;
EQApplicationPacket* outapp = new EQApplicationPacket(OP_RecipeReply, sizeof(RecipeReply_Struct));
RecipeReply_Struct *reply = (RecipeReply_Struct *) outapp->pBuffer;
reply->object_type = objtype;
reply->some_id = someid;
reply->component_count = comp_count;
reply->recipe_id = recipe;
reply->trivial = trivial;
strn0cpy(reply->recipe_name, name, sizeof(reply->recipe_name));
FastQueuePacket(&outapp);
}
}