QMap<QString,QString> databaseFile::searchMax(QString table, QString field) { QList<QString> dbGet = getDbStructure(table); QList< QMap<QString,QString> > listInfo = getDbBrowse(table); // find if that field is exist in table bool isExist = isItemExist(dbGet,field ); int maxValue = 0; int indexMax = 0; // exist --> find the max if(isExist == true) { int numRow = listInfo.count(); // check if number QMap<QString,QString> tempInfo = listInfo.at(0); QString tempValue = tempInfo[field]; if(isNumber(tempValue) == true) { for(int j=0; j<numRow; j++) { QMap<QString,QString> itemInfo = listInfo.at(j); QString itemValue = itemInfo[field]; int itemValueInt = itemValue.toInt(); if(itemValueInt > maxValue) { maxValue = itemValueInt; indexMax = j; } } } } return listInfo.at(indexMax); }
void ChessBoard_TeamFight::addItem(ChessBoardItem_TeamFight* item,int index) { CCAssert(item->currentIndex == -1,""); CCAssert(item->hero->getXSize() == 1,"目前只支持占一格的"); if (isItemExist(item)) { // 这个人已经添加了 CCAssert(false,""); return; } if (!isPosOK(index)) { CCAssert(false,""); return; } if (getActorItemByIndex(index) != NULL) { // 这个位置有人了 CCAssert(false,""); return; } item->currentIndex = index; currentItems.push_back(item); }
void CMenu::addItem(std::string _sIdItem, std::wstring _sName) { if(isItemExist(_sIdItem)) { Log::w("addItem error '"+_sIdItem+"' exists"); } else { CMenuItem* rNewItem = new CMenuItem(_sIdItem, _sName); vMenuItems.push_back(rNewItem); setVisible(isVisible()); } }