/** * Insert a new widget * @param widget :: An MdiSubWindow to add. * @param row :: A row index at which to place the new tile. * @param col :: A column index at which to place the new tile. */ void TiledWindow::insertWidget(MdiSubWindow *widget, int row, int col) { int index = calcFlatIndex( row, col ); int lastRow = rowCount() - 1; int lastCol = columnCount() - 1; // if the last tile has a widget append a row if ( getWidget( lastRow, lastCol ) != NULL ) { ++lastRow; Tile *tile = getOrAddTile( lastRow, lastCol ); (void) tile; } // shift widgets towards the bottom int lastIndex = calcFlatIndex( lastRow, lastCol ); int rowTo(0), colTo(0), rowFrom(0), colFrom(0); for(int i = lastIndex; i > index; --i) { calcTilePosition( i, rowTo, colTo ); calcTilePosition( i - 1, rowFrom, colFrom ); if ( hasWidget( rowFrom, colFrom ) ) { MdiSubWindow *w = removeTile( rowFrom, colFrom ); addWidget( w, rowTo, colTo ); } } addWidget( widget, row, col ); }
/** * Add a range of tiles to the selection. One of the ends of tha range * is given by an already selected tile with the lowest flat index (see * calcFlatIndex). * The other end is the tile in the argument. * @param tile :: A new end tile of the range. */ void TiledWindow::addRangeToSelection(Tile *tile) { if (m_selection.isEmpty()) { addToSelection(tile, false); return; } int ifirst = rowCount() * columnCount(); int ilast = 0; foreach (Tile *selected, m_selection) { int index = calcFlatIndex(selected); if (index < ifirst) ifirst = index; if (index > ilast) ilast = index; }
if (m_selection.isEmpty()) { addToSelection(tile, false); return; } int ifirst = rowCount() * columnCount(); int ilast = 0; foreach (Tile *selected, m_selection) { int index = calcFlatIndex(selected); if (index < ifirst) ifirst = index; if (index > ilast) ilast = index; } int index = calcFlatIndex(tile); if (index == ilast) return; if (index < ifirst) { ilast = ifirst; ifirst = index; } else { ilast = index; } clearSelection(); for (int i = ifirst; i <= ilast; ++i) { int row(0), col(0); calcTilePosition(i, row, col); Tile *tile = getTile(row, col);