void ScheduleDialog::swapRows(int index1, int index2) { Q_ASSERT(index1 != index2); Q_ASSERT(index1 >= 0); Q_ASSERT(index1 < (int)blocks_.size()); Q_ASSERT(index2 >= 0); Q_ASSERT(index2 < (int)blocks_.size()); Q_ASSERT((int)blocks_.size() == timingTable->numRows()); BlockNode *node = blocks_[index1]; blocks_[index1] = blocks_[index2]; blocks_[index2] = node; timingTable->swapRows(index1, index2); timingTable->clearSelection(); timingTable->updateContents(); // set row selection // doesnt work with qt 3.0.6: // timingTable->selectRow(index2); // workaround: QTableSelection selection; selection.init(index2, 0); selection.expandTo(index2, timingTable->numCols() -1); timingTable->addSelection(selection); // redraw canvas clearCanvas(); initCanvas(); // sync selection updateHighlighter(index2, 0); }
void DayView::dateChanged( int y, int m, int d ) { QDate date( y, m, d ); if ( currDate == date ) return; currDate.setYMD( y, m, d ); reschedule(); dayViewWidget()->clearSelection(); QTableSelection ts; if (jumpToCurTime && this->date() == QDate::currentDate()) { ts.init( QTime::currentTime().hour(), 0); ts.expandTo( QTime::currentTime().hour(), 0); } else { ts.init( startTime, 0 ); ts.expandTo( startTime, 0 ); } dayViewWidget()->addSelection( ts ); selectedWidget = 0; }
QString CQueryTable::copy_data(int row, int col) { #ifdef DEBUG qDebug("CQueryTable::copy_data(int, int)"); #endif if (!query()) return QString::null; if (query()->isResultNull() || isBlocked()) return QString::null; if (currentSelection() == -1 && !forceCopyAll()) return copy_current_selection_func(row, col); else { QTableSelection sel; if (currentSelection() == -1 || forceCopyAll()) { sel.init(0, 0); sel.expandTo(numRows() -1, numCols() - 1); } else sel = selection(currentSelection()); if (sel.topRow() == sel.bottomRow() && sel.leftCol() == sel.rightCol() && !forceCopyAll()) return copy_current_selection_func(row, col); setBlocked(true); QString cpy; QString separator = "+"; int current_col; uint length; QMap<uint, ulong> max_length_map; QString tmp; for (current_col = sel.leftCol(); current_col <= sel.rightCol(); current_col++) { if (horizontalHeader()->sectionSize(current_col) <= 0) continue; length = strlen(query()->fields(current_col).name); length = max(length, query()->fields(current_col).max_length); if (length < strlen(NULL_TEXT) && !IS_NOT_NULL(query()->fields(current_col).flags)) length = strlen(NULL_TEXT); max_length_map.insert(current_col, length + 1); for (uint i = 0; i < min(max_length_map[current_col] - 1, MAX_COLUMN_LENGTH) + 2; i++) separator += "-"; separator += "+"; } separator += "\n"; cpy = separator + "|"; for (current_col = sel.leftCol(); current_col <= sel.rightCol(); current_col++) { if (horizontalHeader()->sectionSize(current_col) <= 0) continue; tmp.sprintf(" %-*s|",min((int) max_length_map[current_col], MAX_COLUMN_LENGTH), query()->fields(current_col).name); cpy += tmp; } cpy += "\n" + separator; copy_data_func(&cpy, query(), &sel, &max_length_map); setBlocked(false); return cpy + separator; } }