Пример #1
0
void ProfileWidget::s_buttonClicked(int row, int col) {
    if(col == 4) {
        s_accept(row);
        ClearTable();
        populateTable();
    }else if(col == 5) {
        s_decline(row);
        ClearTable();
        populateTable();
    }
}
Пример #2
0
void MainWindow::CloseContest(bool isExit)
{
    Global::g_is_contest_closed = true;
    StopJudging();
    splitter->hide();
    ClearTable();
    Global::g_contest.Clear();

    if (isExit) return;

    UpdateRecentContest(true);
    ui->label_top->show();
    ui->label_bottom->show();
    ui->listWidget_recent->show();
    close_button->hide();

    this->setWindowTitle("CCR Plus 测评器");
    ui->action_close->setEnabled(false);
    ui->action_configure->setEnabled(false);
    ui->action_set_list->setEnabled(false);
    ui->action_export->setEnabled(false);
    ui->action_refresh->setEnabled(false);
    ui->action_judge_selected->setEnabled(false);
    ui->action_judge_unjudged->setEnabled(false);
    ui->action_judge_all->setEnabled(false);
    ui->action_stop->setEnabled(false);
}
Пример #3
0
//---------------------------------------------------------------------------
void __fastcall TFormInsertVoc::ComboBoxKeyChange(TObject *Sender)
{
  ClearTable();
  AnsiString vkey;
  vkey=(ComboBoxKey->ItemIndex==0)? AnsiString("WHERE deleted=0") : AnsiString("WHERE vkey=\'"+GetKeyForHint(ComboBoxKey->Text)+"\' AND deleted=0");
  if (SortIndex==DEFAULT_INDEX_SORT) SortIndex=1;
  AnsiString Order=VocKeys[SortIndex];
  if (!flagSortUp) // По убыванию
     Order=Order+" DESC";
  InitTable(vkey,Order);
  AnsiString arrowStr;
  if (flagSortUp) arrowStr="\\/";else arrowStr="/\\";
  InitTitlesGrid(StrGridVoc,3,0,0,titles);
  InitTitleGrid(StrGridVoc,SortIndex,0,titles[SortIndex]+"  "+arrowStr);
  StrGridVoc->OnClick(StrGridVoc);
  if (ComboBoxKey->ItemIndex==0)
  {
    Edittitle->Enabled=false;
    BtnAdd->Enabled=false;
    //BtnDel->Enabled=false;
    BtnEdit->Enabled=false;
  }
  else
  {
    Edittitle->Enabled=true;
    BtnAdd->Enabled=true;
    //BtnDel->Enabled=true;
    BtnEdit->Enabled=true;
  }
}
Пример #4
0
void CGnuRouting::Insert(GUID &Guid, int NodeID)
{
	DWORD key = CreateKey(Guid);

	m_AccessTable.Lock();

		// Check to see if table is full
		if(m_Table[m_nCurrent][key].size() >= MAX_REHASH || m_nHashEntries >= TABLE_SIZE * 4)  
		{
			// Time to clean out the old and switch
			ClearTable(m_nOld);

			int temp   = m_nCurrent;
			m_nCurrent = m_nOld;
			m_nOld     = temp;
		}
		
		key_Value new_val;
		new_val.Guid     = Guid;
		new_val.OriginID = NodeID;


		m_Table[m_nCurrent][key].push_back(new_val);

		m_nHashEntries++;

		//if(m_nHashEntries % 50 == 0)
		//	TRACE0( "Hash " + NumtoStr(m_nHashEntries) + "\n");

	m_AccessTable.Unlock();
}
Пример #5
0
void ProfileWidget::populateTable()
{

    ClearTable();
    //TODO: maybe change this table to the following columns:
    //DOC Title
    //Asking Price  //getPending().value(10)
    //Counter Offer //if (column named 'approved' == 1) counterOffer = getPending.value(11) else counterOffer = null
    //Accept
    //Decline
    QSqlQuery getPending = m_user->getPendingDocuments();
    while(getPending.next())
    {
        int rowIndex = m_counterofferTable->rowCount();
        m_counterofferTable->insertRow(rowIndex);
        QString Ask_price(getPending.value(MainDB::ASKINGPRICE).toString());
        QString offer(getPending.value(MainDB::COUNTEROFFER).toString());
        QString title(getPending.value(MainDB::TITLE).toString());
        QString id(getPending.value(MainDB::UID).toString());

        m_counterofferTable->setItem(rowIndex, UID, new QTableWidgetItem(id));
        m_counterofferTable->setItem(rowIndex, TITLE, new QTableWidgetItem(title));
        m_counterofferTable->setItem(rowIndex, ASKINGPRC, new QTableWidgetItem(Ask_price));
        m_counterofferTable->setItem(rowIndex, CO, new QTableWidgetItem(offer));
        m_counterofferTable->setCellWidget(rowIndex, ACCEPT, new QLabel(tr("Accept")));
        m_counterofferTable->setCellWidget(rowIndex, DECLINE, new QLabel(tr("Decline")));
    }
}
Пример #6
0
//---------------------------------------------------------------------------
void __fastcall TFormDisciplines::UpdateTable(TStringGrid* pTab)
{
  ClearTable(pTab);
  delete_data();

  MYSQL_RES *result;
  MYSQL_ROW row;

  AnsiString query="SELECT id,fulltitle,shorttitle,idspec,idclass,num_hours,scan_number,sem_hours FROM "+opts.DBDisciplines+" WHERE deleted=0 AND idspec="+WCGetNumForKeyTitle(SPECS,ComboBoxSpec->Text)+" ORDER BY idclass,fulltitle";
  mysql_query(mysql,query.c_str());

  if (mysql_field_count(mysql))
  {
    result=mysql_store_result(mysql);
    int numCurRow;

    if (result && mysql_num_rows(result))
    {
      numCurRow=0;
      listIDs->Clear();
      listIDs->Add("NULL");
      audhoursdiscip.push_back(NULL);

      while (row = mysql_fetch_row(result))
      {
        numCurRow++;
        pTab->RowCount=numCurRow+1;

        listIDs->Add(AnsiString(row[0]));
        pTab->Cells[0][numCurRow]=numCurRow;
        pTab->Cells[1][numCurRow]=row[1];
        pTab->Cells[2][numCurRow]=row[2];
        pTab->Cells[3][numCurRow]=AnsiString(row[5]);
        pTab->Cells[4][numCurRow]=WCGetTitleForKeyNum(DISCIPCLASSIFIC,AnsiString(row[4]).ToInt());
        pTab->Cells[5][numCurRow]=AnsiString(row[6]);

        AudHours *data = new AudHours;
        StringToAudHours(data, AnsiString(row[7]));
        audhoursdiscip.push_back(data);

        pTab->Refresh();
      }
    }
    mysql_free_result(result);
  }
  StrGridDiscipClick(StrGridDiscip);
}
Пример #7
0
GameTable::~GameTable()
{
    // Cleaning textures
    delete backgroundTexture;
    delete blockTexture;
    delete bombTexture;
    delete blockTextureHighlighted;
    delete textTexture;
    delete btnAddFaceTexture;
    backgroundTexture = nullptr;
    blockTexture = nullptr;
    blockTextureHighlighted = nullptr;
    bombTexture = nullptr;
    textTexture = nullptr;
    btnAddFaceTexture = nullptr;

    // Clear the font
    TTF_CloseFont(gameFont);
    gameFont = nullptr;

    // Clean the upper left position
    delete ulPos;
    ulPos = nullptr;

    // Clean timer
    delete timer;
    timer = nullptr;

    // Clean the Link pointer helper
    delete newLink;
    newLink = nullptr;

    // Destroy buttons
    delete btnAddColumn;
    delete btnPauseGame;
    btnAddColumn = nullptr;
    btnPauseGame = nullptr;

    // Clean table
    ClearTable();
    delete table;
    table = nullptr;
}
Пример #8
0
void MainWindow::LoadTable()
{
    if (is_locked) return;

    if (!QDir(Global::g_contest.path).exists())
    {
        QString path = QDir(Global::g_contest.path).path();
        QMessageBox::critical(this, "无法打开竞赛", QString("%1\n路径不存在或已被移除。").arg(path));
        QSettings set("ccr.ini", QSettings::IniFormat);
        QStringList list = set.value("RecentContestList").toStringList();
        list.removeAll(path);
        set.setValue("RecentContestList", list);
        on_action_close_triggered();
        return;
    }

    Global::g_contest.ReadContestInfo();
    Global::g_contest.SaveResultCache();

    // 显示 boardTable
    ClearTable();
    board_table->ShowResult();
    splitter->show();

    // 读取 .list 文件
    QFile file(Global::g_contest.path + ".list");
    if (file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        Global::g_contest.is_list_used = true;
        ui->action_set_list->setChecked(true);
        Global::g_contest.ReadPlayerList(file);
        file.close();
    }
    else
    {
        Global::g_contest.is_list_used = false;
        ui->action_set_list->setChecked(false);
    }

    board_table->ResizePlayerLabel();
}
Пример #9
0
void GameTable::Init()
{
    ClearTable();

    score = 0;
    experience = 0;
    level = 0;
    expToLevelUp = baseExpToLevelUp;
    ended = false;
    
    // It will be on a Running state
    state = GameTableState::Running;
    
    // Generate the table
    GenerateTable();
    //UpdateTable();

    // Calculate all linked blocks
    CalcLinkedBlocks();

    // Reset timer
    timer->start();
}
Пример #10
0
void GameTable::RemoveBlocksAndUpdateTable(Uint32 linkNr)
{
    // Let's check if we should level up
    if (experience > expToLevelUp)
    {
        LevelUp();
        ClearTable();
    }
    else
    {
        // Let's stop the timer
        timer->stop();

        for (auto blockPos : blockLinks[linkNr - 1])
        {
            auto col = table->at(blockPos->x);
            col->erase(blockPos->y);

            if (col->size() == 0)
            {
                table->erase(blockPos->x);
                delete col;
            }

            delete blockPos;
        }

        UpdateTable();

        ClearBlocks(true);
        CalcLinkedBlocks();

        // Begin destruction animation
        animTimer->start();
        state = GameTableState::InputDisabled;
    }
}
void main(int argc, char ** argv)
{
	SQLHANDLE	henv;
	SQLHANDLE	hdbc;
	SQLHANDLE	hstmt;

	char	username[256];
	char	password[256];
	char	datasource[256];
	unsigned int		i,
		j;
  
	char	TableName[50];

	strcpy(datasource, "SQLServer Express");
	//strcpy(datasource, "Microsoft SQL Server");
	strcpy(username, "test");
	strcpy(password, "test");
	strcpy(TableName, "EMPLOYEES_PERFTEST");


  
/*	if (argc < 2) {
		fprintf (stderr, "Usage: ODBCBatchUpdates username/password@datasource\n\n");
		exit(255);
	}
*/

/*	if (getLoginInfo(argv[1], username, password, datasource) != SQL_SUCCESS) {
		fprintf (stderr, "Error: ' %s ' invalid login\n", argv[1]);
		fprintf (stderr, "Usage: ODBCBatchInserts username/password@datasource\n\n");
		exit(255);
	}
*/  
	printf("ODBC BATCH UPDATE TEST\n\n");

	InitODBCEnv(&henv);
	ODBCConnect(henv, &hdbc, username, password, datasource);
	InitODBCStmt(hdbc, &hstmt);

	printf("\nSETTING UP ENVIRONMENT\n");
	printf("Dropping table: %s\n", TableName);
	DropTable(hstmt, TableName);

	printf("Creating table: %s\n", TableName);
	CreateTable(hstmt, TableName);

	printf("Filling table: %s\n", TableName);
	BatchInsert(hdbc, hstmt, TableName, 100, 5000);

	/*	printf("\n\n");
	printf ("Deleting contents of table");
	ClearTable(hstmt, TableName);
	*/
	printf("\n\n");
	PrintTableHeader();

	for (i = 0; i < BatchSizeLen; i++) {
		for (j = 0; j < NumRecUpdatedLen; j++) {
            BatchUpdate(hdbc, hstmt, TableName, BatchSize[i], NumRecUpdated[j]);
			printf("	resetting test...");
			ClearTable(hstmt, TableName);
			BatchInsert(hdbc, hstmt, TableName, 100, 5000);
			printf("done\n");
		}
		printf ("\n");
	}

    Terminate(henv, hdbc, hstmt);

	printf("ODBC BATCH UPDATE TEST COMPLETED.\n\n");
	printf("===========================================================\n");
	printf("Press ENTER to end program...");
	getchar();

}
Пример #12
0
//---------------------------------------------------------------------------
void __fastcall TFormOptsOplata::UpdateTable(TStringGrid* pTab)
{
  ClearTable(pTab);

  int i,j;
  TStringList* listIDStud = new TStringList;
  TStringList* listIDOpts = new TStringList;
  listIDOpts->Clear();
  listIDStud->Clear();

  ZMySqlQuery->SQL->Clear();
  ZMySqlQuery->SQL->Add("SELECT id FROM "+opts.DBStudTable+" WHERE deleted=0 AND grpid="+ToStr(AnsiString(IDGroup)));
  ZMySqlQuery->Active=true;
  for (i=1;i<=ZMySqlQuery->RecordCount;i++)
  {
    ZMySqlQuery->RecNo=i;
    listIDStud->Add(AnsiString(ZMySqlQuery->Fields->FieldByNumber(1)->AsString.ToInt()));
  }

  AnsiString IDOptsStr;
  for (i=0; i<listIDStud->Count; i++)
  {
    ZMySqlQuery->SQL->Clear();
    ZMySqlQuery->SQL->Add("SELECT idopts FROM "+opts.DBPayFacts+" WHERE deleted=0 AND idstud="+ToStr(listIDStud->Strings[i]));
    ZMySqlQuery->Active=true;

    for (j=1; j<=ZMySqlQuery->RecordCount;j++)
    {
      ZMySqlQuery->RecNo=j;
      IDOptsStr = ZMySqlQuery->Fields->FieldByNumber(1)->AsString;
      if (listIDOpts->IndexOf(IDOptsStr)==-1)
        listIDOpts->Add(IDOptsStr);
    }
  }


  int numCurRow=0;
  listIDs->Clear();
  listIDs->Add("NULL");
  listRealIDs->Clear();
  listRealIDs->Add("NULL");

for (j=0; j<listIDOpts->Count; j++)
{
  ZMySqlQuery->SQL->Clear();
  ZMySqlQuery->SQL->Add("SELECT id,idgroup,datestart,dateend,commoncountmoney FROM "+opts.DBPayOpts+" WHERE deleted=0 AND id="+ToStr(listIDOpts->Strings[j])+" ORDER BY datestart");
  ZMySqlQuery->Active=true;

  for (i=1;i<=ZMySqlQuery->RecordCount;i++)
  {
    ZMySqlQuery->RecNo=i;
    numCurRow++;
    pTab->RowCount=numCurRow+1;

    listIDs->Add(AnsiString(ZMySqlQuery->Fields->FieldByNumber(1)->AsString.ToInt()));
    pTab->Cells[0][numCurRow]=numCurRow;
    pTab->Cells[1][numCurRow]=WCGetTitleForKeyNum(GROUPS,ZMySqlQuery->Fields->FieldByNumber(2)->AsString.ToInt());
    pTab->Cells[2][numCurRow]=GetPeriodStr(ZMySqlQuery->Fields->FieldByNumber(3)->AsString,ZMySqlQuery->Fields->FieldByNumber(4)->AsString);
    pTab->Cells[3][numCurRow]=ZMySqlQuery->Fields->FieldByNumber(5)->AsString;

    pTab->Refresh();
  }
}
  delete listIDOpts;
  delete listIDStud;

  StrGridOptsClick(StrGridOpts);
}
Пример #13
0
int Graph::Member_only( int Snode,int *Dnodes,int Mem_number)//muticast routing algorithm
{
	int V,U, W;
    BinaryHeap<link> PQ(link(Snode, 0));
    link Pnext;    // Stores the result of a DeleteMin
	list<Edge> ::iterator P;
    ClearTable(0);
    Table[Snode].Dist = 0;
    //PQ.Insert(link(Snode, 0));
	int Tree_number=0
	int Mem_included=0;
    while (Mem_included<Mem_number)
    {
        do
        {
            if( PQ.IsEmpty( ) )		
			{		
				Tree_number=Tree_number+1;
				ClearTable(1);
				Table[Snode].Dist = 0;
				PQ.Insert(link(Snode, 0));
				// return 1;
			}
               
            PQ.DeleteMin(Pnext);
        } while(Table[Pnext.Dest].Mark);

        V = Pnext.Dest;
        Table[V].Mark = 1;     // Mark vertex as being seen
		if (Dnodes[V]==0)	// V is not a Member
			for (P = Gmap[V].Adj.begin(); P != Gmap[V].Adj.end(); ++P)
			{
				W = (*P).Dest;
				float Cvw =(*P).Cost;
				if( Cvw < 0 )
				{	std::cerr << "Graph has negative edges" << endl; 
					return 0;
				}
				// update the dist of v's neighbour v
				if( Table[W].Dist > Table[V].Dist + Cvw )
				{
					Table[W].Dist = Table[V].Dist + Cvw;
					Table[W].Prev = V;
					PQ.Insert( link( W, Table[W].Dist ) );
				}
			}
		else //V is not a Member
		{	Mem_included=Mem_included+1;
			U=V;
			PQ.MakeEmpty( );
			do
			{	Table[U].Ontree=1;
				Table[U].Onforest=1;
				Table[U].degree=Table[U].degree-1;//u->v then u--;
				U=Table[U].Prev;
				Table[U].degree=Table[U].degree-1;//U<-u; then v--
			}while(U!=Snode);

			for( int i = 0; i < N_node; i++ )
			{
				if (Table[i].Ontree==0)
				{	Table[i].Dist = Inf;
					Table[i].Prev = -1;
					Table[i].Mark = 0;
				}
				else 
					if (Table[i].degree>0)
						for (P = Gmap[i].Adj.begin(); P != Gmap[i].Adj.end(); ++P)
						{
							W = (*P).Dest;
							float Cvw =(*P).Cost;
							if (Table[W].Ontree==0)
							{	if( Cvw < 0 )
							{	std::cerr << "Graph has negative edges" << endl;
									return 0;
								}
								if( Table[W].Ontree)
									PQ.Insert(link(W, Cvw));									
							}
						}				

			}

		}
    }
	return 1;
}
Пример #14
0
SourceMatchController::SourceMatchController(Instance &aInstance)
    : InstanceLocator(aInstance)
    , mEnabled(false)
{
    ClearTable();
}
Пример #15
0
//Main update function for this game state. Returns true if the game is still running
//and false if the user quits the game
bool Table::Update()
{
	bool gameRunning = true;	

	m_keyboard = Keyboard::Keyboard::NONE;
	GetKeyboardInput();
	
	if(m_keyboard == Keyboard::ESCAPE)
	{
		m_prevState = m_state;
		m_state = State::State::EXIT;
	}

	//This is the main switch statement for the FSM for this game state. Based on the state the
	//game is currently in only the code relevant to that state will get used
	switch( m_state )
	{
		if(m_keyboard != Keyboard::NONE)
		{
			//Gets number of players playing at the table. Creates players for the vector
			//of players and then changes to next state
			case State::GET_PLAYERS:
				{					
					switch(m_keyboard)
					{
						case Keyboard::ONE: m_numPlayers = 1;
							break;
						case Keyboard::TWO: m_numPlayers = 2;
							break;
						case Keyboard::THREE: m_numPlayers = 3;
							break;
						case Keyboard::FOUR: m_numPlayers = 4;
							break;
						case Keyboard::ESCAPE: m_state = State::State::EXIT;
							break;
					}

					if( m_numPlayers != 0 )
					{
						m_state = State::State::GET_BETS;
					
						for(int i = 0; i < m_numPlayers; i++)
						{
							m_players.push_back(Player());
						}
					}
				}
				break;

				//Gets bets for each player. Once one player chooses their bet automatically
				//moves on to the next player. Once all players have bets hand is dealer and
				//state is changed to next state
			case State::GET_BETS:
				{
					if(m_players.at(m_activePlayer).Update(m_state, m_keyboard, &m_shoe))
						m_activePlayer++;
					

					if(m_activePlayer >= m_players.size())
					{
						DealNewHand();
						
						//If the dealer has Blackjack the hand automatically ends. If the player has
						//BJ as well this gets picked up in the DISPLAY_RESULTS state and will get their
						//bet returned there
						if(m_dealer.GetHandValue() == 21)
						{
							m_state = State::State::DEALER_PLAYING;
						}	

						//Checks players for BJ - if BJ then hand gets paid and hand status is set to not live
						else
						{
							for(int i = 0; i < m_numPlayers; i++)
							{
								if(m_players.at(i).GetHandValue() == 21)
								{
									m_players.at(i).Blackjack();
								}
							}

							m_state = State::State::PLAYING_HAND;
							m_activePlayer = 0;
						}				
					}		
				}
				break;

				//Gets player input for hand decision. For each choice it performs the necessary action and
				//returns if the player's turn is over. If it is play automatically moves on to the next player.
				//If there are no more players the state is changed and the dealer plays their hand
			case State::PLAYING_HAND:
				{
					if(m_players.at(m_activePlayer).Update(m_state, m_keyboard, &m_shoe))
						m_activePlayer++;

					if(m_activePlayer >= m_numPlayers)
						m_state = State::State::DEALER_PLAYING;
				}
				break;

			case State::DISPLAY_RESULTS:
				{
					if(m_players.at(0).Update(m_state, m_keyboard, &m_shoe))
						m_state = State::State::END_HAND;
				}
				break;
				//If player chooses exit above this prompts to confirm they wish to exit
				//If they do state changes to menu - if not play resumes
			case State::EXIT:
				{
					switch(m_keyboard)
					{
						case Keyboard::Y:
							{
								m_stateManager->ChangeState(new Menu(m_stateManager));
							}
							break;
						case Keyboard::N:
							{
								m_state = m_prevState;
							}
							break;
					}
				}
				break;
				
			}
			//Checks if it's time for the dealer to play. If it is their hand is revealed. If the dealer's hand is under
			//17 they draw a card. If hand is not under 17 then play ends and state is changed to the next one
			case State::DEALER_PLAYING:
				{
					bool playersActive = false;

					//Checks if any players are still active. Only plays their hand if their are players still in the hand
					for(int i = 0; i < m_numPlayers; i++)
					{
						if(m_players.at(i).IsHandLive())
							playersActive = true;
					}

					if(playersActive)
					{				
						if(m_dealer.Update(&m_shoe))
						{
							m_state = State::State::DISPLAY_RESULTS;

							for(unsigned int i = 0; i < m_numPlayers; i++)
							{
								m_players.at(i).CheckForWin(m_dealer.IsBust(), m_dealer.GetHandValue());
							}
						}
					}

					else
					{
						m_state = State::State::DISPLAY_RESULTS;
						m_dealer.SetVisible(true);

						for(unsigned int i = 0; i < m_numPlayers; i++)
						{
							m_players.at(i).CheckForWin(m_dealer.IsBust(), m_dealer.GetHandValue());
						}
					}
				}
				break;
				//Checks if each player has won. Cycles though all player hands and checks if they won. If they did their chips
				//are adjusted, the table is cleared and a new hand starts
			case State::END_HAND:
				{
					ClearTable();
					m_state = State::State::GET_BETS;
				}
				break;		
	}
	
	return gameRunning;
}