void KUserTable::setCurrentItem(int item) { int old = current; current = item; updateCell(old, 0); updateCell(current, 0, FALSE); emit highlighted(current, 0); }
void CustomPalette::slotAddColor( const QColor &new_color, int alpha ) { if ( cur_row == numRows() - 1 && cur_col == numCols() - 1 ) { //do nothing } else if ( cur_col == numCols() - 1 ) { color_matrix[cur_row][cur_col] = new_color; alpha_matrix[cur_row][cur_col] = alpha; int old_sel_row = sel_row; int old_sel_col = sel_col; sel_row = cur_row; sel_col = cur_col; if ( old_sel_row != -1 && old_sel_col != -1 ) updateCell( old_sel_row, old_sel_col ); updateCell( cur_row, cur_col ); cur_col = 0; cur_row++; QPtrList<Color> cl = k_toon -> document() -> getPalette() -> getColors(); Color *n_color = new Color( ( float )new_color.red() / 255.0, ( float )new_color.green() / 255.0, ( float )new_color.blue() / 255.0, ( float )alpha / 100.0 ); try { cl.append( n_color ); k_toon -> document() -> getPalette() -> setColors( cl ); } catch(...) { delete n_color; throw; } } else { color_matrix[cur_row][cur_col] = new_color; alpha_matrix[cur_row][cur_col] = alpha; int old_sel_row = sel_row; int old_sel_col = sel_col; sel_row = cur_row; sel_col = cur_col; if ( old_sel_row != -1 && old_sel_col != -1 ) updateCell( old_sel_row, old_sel_col ); updateCell( cur_row, cur_col ); cur_col++; QPtrList<Color> cl = k_toon -> document() -> getPalette() -> getColors(); Color *n_color = new Color( ( float )new_color.red() / 255.0, ( float )new_color.green() / 255.0, ( float )new_color.blue() / 255.0, ( float )alpha / 100.0 ); try { cl.append( n_color ); k_toon -> document() -> getPalette() -> setColors( cl ); } catch(...) { delete n_color; throw; } } }
// repaint cells that have been changed from previous generation void Pstable::repaint_changed() { int rows = procview->procs.size(); int cols = procview->cats.size(); int left = leftCell(), right = lastColVisible(); int top = topCell(), bottom = lastRowVisible(); if(right >= cols) right = cols - 1; if(bottom >= rows) bottom = rows - 1; int far_right = right; if(leftmostchanged != -1 && right >= leftmostchanged) right = leftmostchanged - 1; for(int c = right + 1; c <= far_right; c++) updateHeading(c); for(int r = top; r <= bottom; r++) { for(int c = left; c <= right; c++) { Category *cat = procview->cats[c]; Procinfo *p = procview->procs[r], *op = 0; if(r >= procview->old_procs.size() || (op = procview->old_procs[r], cat->compare(p, op) != 0) || p->selected != op->selected) { updateCell(r, c); } } // update all cells that have moved or changed width for(int c = right + 1; c <= far_right; c++) updateCell(r, c); } if(leftmostchanged != -1) clearRight(); }
void tableTemplateWidget::setClickedCell(int row, int col) { QTableWidgetItem *cell = this->item(row, col); if (cell) { if ( cell->data(Qt::UserRole).toInt() ) updateCell(cell, 0); else updateCell(cell, 1); } if (symetricalMode) { QTableWidgetItem *mirrorCell = this->item(row, numCol-col-1); if (mirrorCell) { if ( mirrorCell->data(Qt::UserRole).toInt() ) updateCell(mirrorCell, 0); else updateCell(mirrorCell, 1); } } isDirty = true; }
void CustomPalette::mousePressEvent( QMouseEvent *mouse_event ) { int row_clicked, col_clicked; mapPointToCell( mouse_event -> pos(), &row_clicked, &col_clicked ); //Out of bounds if ( row_clicked > 11 || col_clicked > 18 || row_clicked < 0 || col_clicked < 0 ) { mouse_event -> ignore(); return; } int old_sel_row, old_sel_col; old_sel_row = sel_row; old_sel_col = sel_col; QColor color_selected = color_matrix[row_clicked][col_clicked]; if ( color_selected.isValid() ) { sel_row = row_clicked; sel_col = col_clicked; if ( old_sel_row != -1 && old_sel_col != -1 ) updateCell( old_sel_row, old_sel_col ); updateCell( sel_row, sel_col ); emit colorNameChanged( color_names[sel_row][sel_col] ); emit colorSelected( color_selected ); emit colorAlphaChanged( alpha_matrix[sel_row][sel_col] ); mouse_event -> accept(); } }
void PiecesTable::mouseMoveEvent(TQMouseEvent* e) { QtTableView::mouseMoveEvent(e); // highlight on mouse over int row = findRow(e->y()); int col = findCol(e->x()); int oldrow = _activeRow; int oldcol = _activeCol; if(row >= numRows() || col >= numCols() || row < 0 || col < 0) { _activeRow = -1; _activeCol = -1; } else { _activeRow = row; _activeCol = col; } updateCell(oldrow, oldcol, false); updateCell(row, col, false); }
void MarkListTable::select( int i ) { if ( i < 0 || i >= (signed) items.count() || i == sel ) return ; MarkListTableItem *it = items.at( i ); if ( sel != -1 ) { items.at( sel )->setSelect( FALSE ); updateCell( sel, 0 ); updateCell( sel, 1 ); //updateCell( sel, 2 ); } it->setSelect( TRUE ); sel = i; updateCell( i, 0 ); updateCell( i, 1 ); //updateCell( i, 2 ); emit selected( i ); emit selected( it->text() ); if ( ( i<=0 || rowIsVisible( i-1 ) ) && ( i>= (signed) items.count()-1 || rowIsVisible( i+1 ) ) ) return; setTopCell( QMAX( 0, i - viewHeight()/cellHeight()/2 ) ); }
void Grid::update() { Cell * i = cells, *e = cells+numCols*numRows; for (;i!=e; ++i){ updateCell( *i ); } updateCell( unallocated ); }
void Cell::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_UNUSED(event); if(status) { //cell_color = Qt::lightGray; status = false; updateCell(status); } else { //cell_color = Qt::darkGray; status = true; updateCell(status); } update(); }
void KVocTrainTable::keyPressEvent(QKeyEvent * e) { delayTimer->stop(); switch(e->key()) { case Key_Right: { int topCell = rowAt(0); int lastRowVisible = QMIN(numRows(), rowAt(contentsHeight())); if (numCols() > 2) for (int i = topCell; i <= lastRowVisible; i++) updateCell(i, KV_COL_ORG); } // fallthrough case Key_Up: case Key_Down: case Key_Next: case Key_Prior: QTable::keyPressEvent(e); break; case Key_Left: { QTable::keyPressEvent(e); int topCell = rowAt(0); int lastRowVisible = QMIN(numRows(), rowAt(contentsHeight())); if (numCols() > 2) for (int i = topCell; i <= lastRowVisible; i++) updateCell(i, KV_COL_ORG); } break; case Key_Shift: case Key_Alt: case Key_Control: // fallthrough QTable::keyPressEvent(e); emit forwardKeyPressEvent(e); break; case Key_Minus: case Key_Plus: case Key_Tab: case Key_Backtab: // fallthrough emit forwardKeyPressEvent(e); break; default: QTable::keyPressEvent(e); break; } }
void PlanarGridOccupancyMap::update(const PlanarObservation& cells) { for(PlanarObservation::ContainerConstIter it = cells.begin(), iend = cells.end(); it != iend; ++it) { updateCell(it->first, it->second); } }
/** * 从文件读取数据 */ void readFile() { FILE *fp = _wfopen(FILE_PATH, L"r,ccs=UNICODE"); if(!fp) return; for (int courseIndex = 0; courseIndex < Course_LENGTH; ++courseIndex) { if(feof(fp)) break; Char buffer[16]; for (int dayIndex = 0; dayIndex < DAY_LENGTH; ++dayIndex) { Course* &course = courses[courseIndex][dayIndex]; fwscanf(fp, L"%s", buffer); if (*buffer != Course::Null) { if(!course) course = new Course; course->setTitle(buffer); fwscanf(fp, L"%s%s%d%d", course->classRoom, course->teacher, &course->startWeek, &course->endWeek); updateCell(course, courseIndex, dayIndex); } } } fclose(fp); }
void updateSCell(Cell *cell, USER_OBJECT_ cellRef, MStyle *style) { Sheet *sheet; sheet = RGnumeric_resolveSheetReference(VECTOR_ELT(cellRef, 1)); updateCell(cell, sheet, style); }
void KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) { if(!isEnabled() || e->button() != LeftButton) { KNotifyClient::beep(); return; } // ----- int row, col; QPoint mouseCoord; // ----- mouseCoord = e->pos(); row=rowAt(mouseCoord.y()); col=columnAt(mouseCoord.x()); if(row<0 || col<0) { // the user clicked on the frame of the table activeCol = -1; activeRow = -1; } else { activeCol = col; activeRow = row; updateCell( row, col /*, false */ ); } }
/* Sets the currently selected cell to \a row, \a column. If \a row or \a column are less than zero, the current cell is unselected. Does not set the position of the focus indicator. */ void WellArray::setSelected(int row, int col) { int oldRow = selRow; int oldCol = selCol; if (row < 0 || col < 0) row = col = -1; selCol = col; selRow = row; updateCell(oldRow, oldCol); updateCell(selRow, selCol); if (row >= 0) Q_EMIT selected(row, col); }
/*! * @brief Gives a new or recycled MContentItem cell for MList. * * @param index Model index of the new cell * @param recycler Widget recycler for cell widgets */ MWidget* createCell(const QModelIndex& index, MWidgetRecycler& recycler) const { MWidget *newItem = qobject_cast<MWidget *>(recycler.take(MWidget::staticMetaObject.className())); if(newItem == NULL) newItem = qobject_cast<MWidget*>(new MContentItem(MContentItem::TwoTextLabels)); updateCell(index, newItem); return qobject_cast<MWidget*>(newItem); }
void MarkListTable::markSelected() { if ( sel == -1 ) return; MarkListTableItem *it = items.at( sel ); it->setMark( ! it->mark() ); updateCell( sel, 0 ); }
void WellArray::setCurrent(int row, int col) { if ((curRow == row) && (curCol == col)) return; if (row < 0 || col < 0) row = col = -1; int oldRow = curRow; int oldCol = curCol; curRow = row; curCol = col; updateCell(oldRow, oldCol); updateCell(curRow, curCol); }
void MainScene::onCellMoved(const Index &startIndex, const Index &endIndex) { auto cellDistance = (startIndex.first == endIndex.first) ? (std::abs(startIndex.second - endIndex.second)) : (std::abs(startIndex.first - endIndex.first)); const auto cellSpeed = 16.0; //4 cells per second auto actionMove = MoveTo::create(cellDistance / cellSpeed, cells_[endIndex.first][endIndex.second].color->getPosition()); auto actionUpdate = CallFunc::create( [this, startIndex, endIndex, oldPos = cells_[startIndex.first][startIndex.second].color->getPosition()](){ cells_[startIndex.first][startIndex.second].color->setPosition(oldPos); updateCell(startIndex); updateCell(endIndex); }); cells_[startIndex.first][startIndex.second].color->runAction( Sequence::create(actionMove, actionUpdate, NULL)); }
/*删除课程*/ void deleteCourse(int courseIndex, int dayIndex) { Course* &course = courses[courseIndex][dayIndex]; if (course) { delete course; course = nullptr; updateCell(course, courseIndex, dayIndex); } }
void KDateTable::contentsMousePressEvent(QMouseEvent *e) { if(e->type()!=QEvent::MouseButtonPress) { // the KDatePicker only reacts on mouse press events: return; } if(!isEnabled()) { KNotifyClient::beep(); return; } int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; // ----- int row, col, pos, temp; QPoint mouseCoord; // ----- mouseCoord = e->pos(); row=rowAt(mouseCoord.y()); col=columnAt(mouseCoord.x()); if(row<0 || col<0) { // the user clicked on the frame of the table return; } pos=7*(row-1)+col+1; if(pos+dayoff<=firstday) { // this day is in the previous month KNotifyClient::beep(); return; } if(firstday+numdays<pos+dayoff) { // this date is in the next month KNotifyClient::beep(); return; } temp=firstday+date.day()-dayoff-1; setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); updateCell(temp/7+1, temp%7); // Update the previously selected cell updateCell(row, col); // Update the selected cell // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); emit(tableClicked()); }
void MyTable::setText(int row, int col, const QString & text) { QTableItem * itm = item(row, col); if (itm != 0) { itm->setText(text); updateCell(row, col); } else setItem(row, col, new TableItem(this, QTableItem::OnTyping, text)); }
void CostMap2D::updateDynamicObstacles(double ts, double wx, double wy, const std_msgs::PointCloudFloat32& cloud, std::vector<unsigned int>& newObstacles, std::vector<unsigned int>& deletedObstacles) { //std::cout << "Updating for time: " << ts << std::endl; newObstacles.clear(); // Small clearance for what is 'in contact' which is a centimeter double FILTERING_RADIUS = inflationRadius_ + 0.01; for(size_t i = 0; i < cloud.get_pts_size(); i++) { // Filter out points too high if(cloud.pts[i].z > maxZ_) continue; // Filter points in our contact space. Should be unnecessary if lasers working correctly if(sqrt(pow(wx-cloud.pts[i].x, 2) + pow(wy-cloud.pts[i].y, 2)) < FILTERING_RADIUS){ continue; } unsigned int ind = WC_IND(cloud.pts[i].x, cloud.pts[i].y); updateCell(ind, LETHAL_OBSTACLE, newObstacles); // Compute inflation set std::vector<unsigned int> inflation; computeInflation(ind, inflation); for(unsigned int i = 0; i<inflation.size(); i++) updateCell(inflation[i], INFLATED_OBSTACLE, newObstacles); } // We always process deletions too removeStaleObstacles(ts, deletedObstacles); if(!newObstacles.empty() || !deletedObstacles.empty()){ std::cout << newObstacles.size() << " insertions, " << deletedObstacles.size() << " deletions: " << dynamicObstacles_.size() << " dynamic obstacles\n"; } }
void LifeOrganism::updateAll() { //Call the updateCell function for all cells for (int i = 0; i < height; ++i) { for (int k = 0; k < width; ++k) { updateCell(k, i); } } //Notify the object that all cells have been updated and are ready to be advanced to the next time step allUpdated = true; }
virtual MWidget *createCell(const QModelIndex &index, MWidgetRecycler &recycler) const { MWidget *cell = NULL; MediaType m = index.data(Qt::DisplayRole).value<MediaType>(); if (m.type == MediaType::Image) { cell = MListCellCreatorHelper<OpenDialogImageWidget>::createCell(recycler, "", ""); updateCell(index, cell); } return cell; }
/* Sets the currently selected cell to \a row, \a column. If \a row or \a column are less than zero, the current cell is unselected. Does not set the position of the focus indicator. */ void QWellArray::setSelected(int row, int col) { int oldRow = selRow; int oldCol = selCol; if (row < 0 || col < 0) row = col = -1; selCol = col; selRow = row; updateCell(oldRow, oldCol); updateCell(selRow, selCol); if (row >= 0) emit selected(row, col); #ifndef QT_NO_MENU if (isVisible() && qobject_cast<QMenu*>(parentWidget())) parentWidget()->close(); #endif }
void KColorCells::mouseReleaseEvent( TQMouseEvent *e ) { int cell = posToCell(mPos); int currentCell = posToCell(e->pos()); // If we release the mouse in another cell and we don't have // a drag we should ignore this event. if (currentCell != cell) cell = -1; if ( (cell != -1) && (selected != cell) ) { int prevSel = selected; selected = cell; updateCell( prevSel/numCols(), prevSel%numCols() ); updateCell( cell/numCols(), cell%numCols() ); } inMouse = false; if (cell != -1) emit colorSelected( cell ); }
void tableTemplateWidget::newCell(int row, int col, int value) { QTableWidgetItem *cell = new QTableWidgetItem(); if (cell) { cell->setFont(font); cell->setTextAlignment(Qt::AlignCenter); updateCell(cell, value); setItem(row, col, cell); } }
void ColMsgTable::edit_msg(int row) { ColMsg * msg = flat_msg_list[row]; CodChangeMsgDialog d(this, msg); if (d.exec() == QDialog::Accepted) { QString def = msg->def(FALSE, TRUE, UmlView, DefaultShowContextMode); msg->in->update_msgs(); item(row, MSG_COL)->setText(def.mid(def.find(' ') + 1)); updateCell(row, MSG_COL); } }
void KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) { if (e->state() & LeftButton) { int row, col; QPoint mouseCoord; // ----- mouseCoord = e->pos(); row=rowAt(mouseCoord.y()); col=columnAt(mouseCoord.x()); int tmpRow = -1, tmpCol = -1; if(row<0 || col<0) { // the user clicked on the frame of the table if ( activeCol > -1 ) { tmpRow = activeRow; tmpCol = activeCol; } activeCol = -1; activeRow = -1; } else { bool differentCell = (activeRow != row || activeCol != col); if ( activeCol > -1 && differentCell) { tmpRow = activeRow; tmpCol = activeCol; } if ( differentCell) { activeRow = row; activeCol = col; updateCell( row, col /*, false */ ); // mark the new active cell } } if ( tmpRow > -1 ) // repaint the former active cell updateCell( tmpRow, tmpCol /*, true */ ); } }