void CActiveMemberGrid::RedrawAllActiveMembers() { RemoveAll(); CActiveMember ActiveMember; CSingleLock lock(&m_lpActiveMemberList->ActiveMemberListLock, TRUE); m_lpActiveMemberList->StartEnumActiveMember(); while (m_lpActiveMemberList->GetEachActiveMember(ActiveMember)) { AddNewRow(ActiveMember); } }
//function to execute SELECT * query wyInt32 TableView::ExecuteTableData() { wyString query; wyInt32 ret; MySQLDataEx* pdata; query.Sprintf("select * from `%s`.`%s`", m_mydata->m_db.GetString(), m_mydata->m_table.GetString()); //get filter info GetFilterInfo(query); //get sort info GetSortInfo(query); //get limits GetLimits(query); //execut query m_mydata->m_datares = ExecuteQuery(query); //is thread stopped if(ThreadStopStatus()) { return TE_STOPPED; } //any error? show error dialog if(!m_mydata->m_datares) { return HandleErrors(query); } //allocate row array, if the thread is stopped, delete them if((ret = AllocateRowsExArray()) != TE_SUCCESS || (ret = GetTableDetails()) != TE_SUCCESS) { pdata = ResetData(m_data); delete pdata; return ret; } //add new row in the end AddNewRow(); return TE_SUCCESS; }
void CActiveMemberGrid::RedrawUpdateActiveMembers() { while (TRUE) { UINT nMemberId = m_lpActiveMemberList->GetUpdateActiveMemberId(); if (nMemberId > 0) { CActiveMember ActiveMember; if (m_lpActiveMemberList->GetActiveMember(nMemberId, ActiveMember)) { CBCGPGridRow* pRow = FindRowByData(ActiveMember.GetMemberID(), FALSE); if (pRow != NULL)//已经存在的 { UpdateRowData(pRow, ActiveMember); } else //新增加的 { AddNewRow(ActiveMember); } } else { //已经删除了 CBCGPGridRow* pRow = FindRowByData(nMemberId, FALSE); if (pRow != NULL) { RemoveRow(pRow->GetRowId()); } } } else { //更新完毕了 break; } } }
/// <summary> /// Insert or update a row by the given cell values. /// </summary> bool CustomDrawListControl::InsertOrUpdateRow(PCWSTR cells[], int length, bool isDirectlyInsert) { assert(length >= 1); assert(length == m_nColumns); bool hasInserted = false; int index = GetRowIndex(cells[0]); if (index < 0 || isDirectlyInsert) { // If the row does not exist, create a new one index = AddNewRow(); hasInserted = true; } for (int i = 0; i < length; ++i) { LVITEM lvitem = CreateListViewItem(index, i, cells[i]); ListView_SetItem(m_hWnd, &lvitem); } return hasInserted; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), client(new KelnetClient(this)), Map(NULL) { ui->setupUi(this); connect(client,SIGNAL(Connected()),this,SLOT(Connected())); connect(client,SIGNAL(Disconnected()),this,SLOT(Disconnected())); connect(client,SIGNAL(CoreStatus(QString&)),this,SLOT(NewCoreStatus(QString&))); CoreStatus = new QLabel(this); statusBar()->addPermanentWidget(CoreStatus); Led = new HLed(this); Led->turnOff(); statusBar()->addPermanentWidget(Led); Timer = new QTimer(this); Timer->setInterval(500); connect(this,SIGNAL(TimerStart()),Timer,SLOT(start())); connect(this,SIGNAL(TimerStop()),Timer,SLOT(stop())); connect(Timer,SIGNAL(timeout()),this,SLOT(Timeout())); MapFile = new QLabel(this); MapFile->setText("No map file"); ui->mainToolBar->addSeparator(); ui->mainToolBar->addWidget(MapFile); QStringList header; header << "Name" << "Type" << "Address" << "Period" << "Value" << "Float" << "Modify"; ui->Table->setHorizontalHeaderLabels(header); connect(ui->Table,SIGNAL(AddNewRow()),this,SLOT(AddNewRow())); connect(ui->Table,SIGNAL(EditRow(int)),this,SLOT(EditRow(int))); connect(ui->Table,SIGNAL(DeleteRow(int)),this,SLOT(RemoveRow(int))); connect(ui->Table,SIGNAL(cellDoubleClicked(int,int)),this,SLOT(CellDoubleClicked(int,int))); connect(ui->Table,SIGNAL(cellChanged(int,int)),this,SLOT(CellActivated(int,int))); MapFilePath = "/home/kubanec/workspace/ARMCM4-STM32F407-DISCOVERY/build/test.map"; Map = new MapFileClass(MapFilePath, variables,this); //upper part with plots GraphSplitter = new QSplitter(); ui->verticalLayout_2->addWidget(GraphSplitter); GraphSplitter->setOrientation(Qt::Vertical); GraphSplitter->setContextMenuPolicy(Qt::ActionsContextMenu); GraphSplitter->addAction(ui->actionAdd_new_plot); plotMenu = new QMenu(this); plotMenu->addAction(ui->actionAdd_new_plot); plotMenu->addSeparator(); plotMenu->addAction(ui->actionEdit_plot); plotMenu->addAction(ui->actionRemove_plot); connect(ui->actionRefresh,SIGNAL(triggered()),Map,SLOT(FileChanged())); ui->mainToolBar->insertWidget(ui->actionConnect,ui->toolOpen); ui->mainToolBar->insertSeparator(ui->actionConnect); ui->mainToolBar->insertWidget(ui->actionRefresh,ui->toolMap); connect(ui->toolOpen,SIGNAL(clicked()),this,SLOT(on_actionOpen_triggered())); connect(ui->toolMap,SIGNAL(clicked()),this,SLOT(on_actionMapFile_triggered())); for (int i = 0 ; i < recentHistorySize; i++) { QAction * a = new QAction(ui->toolOpen); ui->toolOpen->addAction(a); connect(a,SIGNAL(triggered()),this,SLOT(action_openFile())); a->setVisible(false); a = new QAction(ui->toolMap); ui->toolMap->addAction(a); connect(a,SIGNAL(triggered()),this,SLOT(action_loadMapFile())); a->setVisible(false); } loadIni(); clearWorkspace(); }
//function to execute SELECT * query wyInt32 TableView::ExecuteTableData() { wyString query; wyInt32 ret,extraindex,j=0,no_row; MySQLDataEx* pdata; MYSQL_ROW fieldrow; query.Sprintf("select * from `%s`.`%s`", m_mydata->m_db.GetString(), m_mydata->m_table.GetString()); //get filter info GetFilterInfo(query); //get sort info GetSortInfo(query); //get limits GetLimits(query); //execut query m_mydata->m_datares = ExecuteQuery(query); //is thread stopped if(ThreadStopStatus()) { return TE_STOPPED; } //any error? show error dialog if(!m_mydata->m_datares) { return HandleErrors(query); } //allocate row array, if the thread is stopped, delete them if((ret = AllocateRowsExArray()) != TE_SUCCESS || (ret = GetTableDetails()) != TE_SUCCESS) { pdata = ResetData(m_data); delete pdata; return ret; } extraindex = GetFieldIndex(m_wnd->m_tunnel, m_data->m_fieldres, "Extra"); no_row = m_wnd->m_tunnel->mysql_num_rows(m_data->m_fieldres); m_data->m_colvirtual = (wyInt32*)calloc(no_row, sizeof(wyInt32)); while(fieldrow = m_wnd->m_tunnel->mysql_fetch_row(m_data->m_fieldres)){ if(!strstr(fieldrow[extraindex], "VIRTUAL") && !strstr(fieldrow[extraindex], "PERSISTENT") && !strstr(fieldrow[extraindex], "STORED")) { m_data->m_colvirtual[j++] = 0; } else { m_data->m_colvirtual[j++] = 1; } } //add new row in the end AddNewRow(); return TE_SUCCESS; }