int32_t select_call(int32_t socket_num, int32_t seconds, int32_t microseconds, int32_t set_null) { fd_set fdvar; struct timeval *timeout = NULL; if (set_null == NOT_NULL) { timeout = (struct timeval *) malloc(sizeof(struct timeval)); timeout->tv_sec = seconds; //set timeout to 1 second timeout->tv_usec = microseconds; //set timeout (in microseconds) } FD_ZERO(&fdvar); //reset variables FD_SET(socket_num, &fdvar); if (selectMod(socket_num + 1, (fd_set *)&fdvar, (fd_set *) 0, (fd_set *) 0, timeout) < 0) { perror("in select_call, selectMod"); exit(-1); } if (FD_ISSET(socket_num, &fdvar)) return 1; else return 0; }
void CModListView::setupModsView() { ui->allModsView->setModel(filterModel); // input data is not sorted - sort it before display ui->allModsView->sortByColumn(ModFields::TYPE, Qt::AscendingOrder); ui->allModsView->setColumnWidth(ModFields::STATUS_ENABLED, 30); ui->allModsView->setColumnWidth(ModFields::STATUS_UPDATE, 30); ui->allModsView->setColumnWidth(ModFields::TYPE, 80); ui->allModsView->setColumnWidth(ModFields::NAME, 180); ui->allModsView->setColumnWidth(ModFields::SIZE, 80); ui->allModsView->setColumnWidth(ModFields::VERSION, 60); connect( ui->allModsView->selectionModel(), SIGNAL( currentRowChanged( const QModelIndex &, const QModelIndex & )), this, SLOT( modSelected( const QModelIndex &, const QModelIndex & ))); connect( filterModel, SIGNAL( modelReset()), this, SLOT( modelReset())); selectMod(filterModel->rowCount() > 0 ? 0 : -1); }
void CModListView::modelReset() { if (ui->modInfoWidget->isVisible()) selectMod(filterModel->rowCount() > 0 ? filterModel->index(0,0) : QModelIndex()); }
void CModListView::on_allModsView_activated(const QModelIndex &index) { showModInfo(); selectMod(index); }
void CModListView::modSelected(const QModelIndex & current, const QModelIndex & ) { selectMod(current); }
void CModListView::dataChanged(const QModelIndex & topleft, const QModelIndex & bottomRight) { selectMod(ui->allModsView->currentIndex()); }
void CModListView::modelReset() { //selectMod(filterModel->mapToSource(ui->allModsView->currentIndex()).row()); selectMod(filterModel->rowCount() > 0 ? 0 : -1); }
void CModListView::on_allModsView_doubleClicked(const QModelIndex &index) { showModInfo(); selectMod(filterModel->mapToSource(index).row()); }
void CModListView::modSelected(const QModelIndex & current, const QModelIndex & ) { selectMod(filterModel->mapToSource(current).row()); }