QModelIndex TagFilterModel::index(const QString &tag) const { const int row = findRow(tag); if (!isValidRow(row)) return {}; return index(row, 0, QModelIndex()); }
void TabSwitcherWidget::showEvent(QShowEvent *event) { setFocus(); MainWindowSessionItem *mainWindowItem(SessionsManager::getModel()->getMainWindowItem(m_mainWindow)); if (mainWindowItem) { const bool useSorting(SettingsManager::getOption(SettingsManager::Interface_TabSwitchingModeOption).toString() != QLatin1String("noSort")); for (int i = 0; i < mainWindowItem->rowCount(); ++i) { WindowSessionItem *windowItem(static_cast<WindowSessionItem*>(mainWindowItem->child(i, 0))); if (windowItem) { m_model->appendRow(createRow(windowItem->getActiveWindow(), (useSorting ? QVariant(windowItem->getActiveWindow()->getLastActivity()) : QVariant(i)))); } } } m_model->sort(0, ((SettingsManager::getOption(SettingsManager::Interface_TabSwitchingModeOption).toString() == QLatin1String("noSort")) ? Qt::AscendingOrder : Qt::DescendingOrder)); Window *activeWindow(m_mainWindow->getActiveWindow()); const int contentsHeight(m_model->rowCount() * 22); m_tabsView->setCurrentIndex(m_model->index((activeWindow ? findRow(activeWindow->getIdentifier()) : 0), 0)); m_tabsView->setMinimumHeight(qMin(contentsHeight, int(height() * 0.9))); QWidget::showEvent(event); connect(m_mainWindow, SIGNAL(windowAdded(quint64)), this, SLOT(handleWindowAdded(quint64))); connect(m_mainWindow, SIGNAL(windowRemoved(quint64)), this, SLOT(handleWindowRemoved(quint64))); }
TagModelItem *TagFilterModel::findItem(const QString &tag) { const int row = findRow(tag); if (!isValidRow(row)) return nullptr; return &m_tagItems[row]; }
void TabSwitcherWidget::showEvent(QShowEvent *event) { setFocus(); const MainWindowSessionItem *mainWindowItem(SessionsManager::getModel()->getMainWindowItem(m_mainWindow)); if (mainWindowItem) { const bool useSorting(SettingsManager::getOption(SettingsManager::TabSwitcher_OrderByLastActivityOption).toBool()); for (int i = 0; i < mainWindowItem->rowCount(); ++i) { const WindowSessionItem *windowItem(static_cast<WindowSessionItem*>(mainWindowItem->child(i, 0))); if (windowItem && (!m_isIgnoringMinimizedTabs || (windowItem->getActiveWindow() && windowItem->getActiveWindow()->getWindowState().state != Qt::WindowMinimized))) { m_model->appendRow(createRow(windowItem->getActiveWindow(), (useSorting ? QVariant(windowItem->getActiveWindow()->getLastActivity()) : QVariant(i)))); } } } m_model->sort(0, (SettingsManager::getOption(SettingsManager::TabSwitcher_OrderByLastActivityOption).toBool() ? Qt::DescendingOrder : Qt::AscendingOrder)); const Window *activeWindow(m_mainWindow->getActiveWindow()); const int contentsHeight(m_model->rowCount() * 22); m_tabsView->setCurrentIndex(m_model->index((activeWindow ? findRow(activeWindow->getIdentifier()) : 0), 0)); m_tabsView->setMinimumHeight(qMin(contentsHeight, int(height() * 0.9))); QWidget::showEvent(event); connect(m_mainWindow, &MainWindow::windowAdded, this, &TabSwitcherWidget::handleWindowAdded); connect(m_mainWindow, &MainWindow::windowRemoved, this, &TabSwitcherWidget::handleWindowRemoved); }
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); }
ICell* Column::cellAt(const RowId & rowId) const { int row = findRow(rowId); if (row >= 0) return m_cells[row]; return nullptr; }
void TabSwitcherWidget::tabRemoved(qint64 identifier) { const int row = findRow(identifier); if (row >= 0) { m_model->removeRow(row); } }
void KFinderWin::mousePressEvent( QMouseEvent *_ev ) { int row = findRow( _ev->pos().y() ); if ( row == -1 ) return; QPoint p( _ev->pos().x() + xOffset(), _ev->pos().y() ); QPoint p2( mapToGlobal( _ev->pos() ) ); QMouseEvent ev( Event_MouseButtonPress, p, _ev->button(), _ev->state() ); itemList.at( row )->mousePressEvent( &ev, p2 ); }
void TagFilterModel::torrentTagAdded(BitTorrent::TorrentHandle *const torrent, const QString &tag) { if (torrent->tags().count() == 1) untaggedItem()->decreaseTorrentsCount(); const int row = findRow(tag); Q_ASSERT(isValidRow(row)); TagModelItem &item = m_tagItems[row]; item.increaseTorrentsCount(); const QModelIndex i = index(row, 0, QModelIndex()); emit dataChanged(i, i); }
void MarkListTable::mouseMoveEvent ( QMouseEvent *e ) { if (e->state() != MidButton) return; int i = findRow( e->pos().y() ); if ( i == drag || i == -1 ) return; do { drag += i > drag ? 1 : -1; items.at( drag )->setMark( !items.at( drag )->mark() ); updateCell( drag, 0 ); } while ( i != drag ); }
void KFinderWin::slotDropEvent( KDNDDropZone *_zone ) { QPoint p = QPoint( _zone->getMouseX(), _zone->getMouseY() ); QPoint p2 = mapFromGlobal( p ); int row = findRow( p2.y() ); if ( row == -1 ) { finder->emitDrop( _zone->getURLList(), p ); return; } itemList.at( row )->dropEvent( _zone->getURLList(), p ); }
void TableBody::mouseMoveEvent(QMouseEvent *e) { if (numRows() == 0) return; // *** prevent out of range // DRAFT CODE ! // Signal : find row, col(field name) emit flyOnEvent Signal int row = findRow(e->y()); int col = findCol(e->x()); if (row < 0 or col < 0) { emit htable->outOfCell(); // if... return; } emit htable->flyOnCell(row, col); if (e->buttons() == Qt::NoButton) return; if (e->buttons() == Qt::RightButton) return; if (e->buttons() & Qt::ControlModifier || gadget_click) return; if (row != prev_drag_row) { if (row == -1) { if (!autoscrolling) { // dragging outside table, cause scrolling scrolldir = (e->y() < 0) ? UP : DOWN; // killTimers(); // startTimer(scroll_delay); autoscrolling = true; } } else { ////killTimers(); autoscrolling = false; dragSelectTo(row); } } // repaintRow(row); // view->update(); repaintChanged(); }
void TabSwitcherWidget::setTitle(const QString &title) { Window *window = qobject_cast<Window*>(sender()); if (window) { const int row = findRow(window->getIdentifier()); if (row >= 0) { m_model->setData(m_model->index(row, 0), title, Qt::DisplayRole); } } }
void TabSwitcherWidget::setIcon(const QIcon &icon) { Window *window = qobject_cast<Window*>(sender()); if (window) { const int row = findRow(window->getIdentifier()); if (row >= 0) { m_model->setData(m_model->index(row, 0), icon, Qt::DecorationRole); } } }
// TESt void TableBody::checkProfile() { htable->checkTableModel(); // important QRect viewR = viewRect(); if (viewR.y() != 0) printf(" qps: ooooophss....\n"); int maxViewRow = findRow(viewR.height()); if (maxViewRow < 0) maxViewRow = numRows(); int maxViewCol = findCol(viewR.width()); if (maxViewCol < 0) maxViewCol = numCols(); tablecache.setCol(maxViewCol); tablecache.setRow(maxViewRow); }
QModelIndex SimpleFSModel::parent(const QModelIndex& child) const { if (!child.isValid()) { return QModelIndex(); } NodeInfo* childInfo = static_cast<NodeInfo*>(child.internalPointer()); Q_ASSERT(childInfo != 0); NodeInfo* parentInfo = childInfo->parent; if (parentInfo != 0) return createIndex(findRow(parentInfo), RamificationColumn, parentInfo); else return QModelIndex(); }
void Sheet::deleteRow(const RowId& rowId) { const int index = findRow(rowId); Q_ASSERT(index >= 0); if (index >= 0) { m_rows.erase(m_rows.begin() + index); //destroy row Column* pColumn = NULL; foreach(pColumn, m_columns) pColumn->deleteRow(index); } }
void TableBody::mouseDoubleClickEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton) { int row = findRow(e->y()); if (row != -1) { if (htable->options & HTBL_ROW_SELECTION && !htable->isSelected(row)) htable->selectOnlyOne(row); // htable->selectionNotify(); emit htable->selectionChanged(); // htable->emit_double_click_signal(row); emit htable->doubleClicked(row); } } }
void MarkListTable::mousePressEvent ( QMouseEvent *e ) { int i = findRow( e->pos().y() ); if ( i == -1 ) return; MarkListTableItem *it = items.at( i ); if ( e->button() == LeftButton ) select( i ); else if ( e->button() == RightButton ) pup->popup( mapToGlobal( e->pos() ) ); else if ( e->button() == MidButton ) { it->setMark( !it->mark() ); updateCell( i, 0 ); drag = i; } }
void Sheet::insertRow(const RowId& newRowId /*= RowId()*/, const RowId& rowId /*= RowId()*/) { const RowId theIdForTheNewRow = newRowId.isNull() ? RowId(QUuid::createUuid()) : newRowId; Q_ASSERT(!theIdForTheNewRow.isNull()); const int index = rowId == RowId() ? m_rows.size() : findRow(rowId); Q_ASSERT(index >= 0); if (index >= 0) { m_rows.insert(index, theIdForTheNewRow); //initialize row Column* pColumn = NULL; foreach(pColumn, m_columns) pColumn->insertRow(theIdForTheNewRow, index); } }
void KFinderWin::setBranchVisible( KFinderItem* startItem ) { KFinderItem* curItem; int i1 = -1, i2 = -1; int branchLevel = -1; bool bFound = false; QListIterator<KFinderItem> it( itemList ); //for ( ; it.current(); ++it ) for ( curItem = finder->first(); curItem != 0; curItem = finder->next() ) { if( bFound ){ i2++; if( curItem->getLevel() <= branchLevel ) break; } else { i1++; if( curItem == startItem ) { branchLevel = curItem->getLevel(); i2 = i1; bFound = true; } } } int lastRow = lastRowVisible(); if( (i2 - i1) > lastRow - topCell() - 2 ) setTopCell( i1 ? (i1 - 1) : i1 ); else if( i2 > lastRow ) { int newTopCell = topCell() + ( i2 - lastRow ); if( findRow(minViewY() + cellHeight() - 1) != topCell()) newTopCell++; setTopCell( newTopCell ); } else if( i1 < topCell() ) { int newTopCell = topCell() - ( topCell() - i1 ); if( newTopCell ) newTopCell--; setTopCell( newTopCell ); } }
void KIconEditGrid::mousePressEvent( QMouseEvent *e ) { if(!e || (e->button() != LeftButton)) return; int row = findRow( e->pos().y() ); int col = findCol( e->pos().x() ); //int cell = row * numCols() + col; if(!img->valid(col, row)) return; btndown = true; start.setX(col); start.setY(row); if(ispasting) { ispasting = false; editPaste(true); } if(isselecting) { QPointArray a(pntarray.copy()); pntarray.resize(0); drawPointArray(a, Mark); emit selecteddata(false); } switch( tool ) { case SelectRect: case SelectCircle: isselecting = true; break; default: break; } }
void TabSwitcherWidget::setLoadingState(WebWidget::LoadingState state) { Window *window(qobject_cast<Window*>(sender())); if (window) { const int row(findRow(window->getIdentifier())); if (row >= 0) { QColor color(palette().color(QPalette::Text)); if (state == WebWidget::DelayedLoadingState) { color.setAlpha(150); } m_model->setData(m_model->index(row, 0), color, Qt::TextColorRole); } } }
void TodoView::doMouseEvent(QMouseEvent *e) { editor->hide(); priList->hide(); editingFlag = FALSE; int c, r; c = findCol(e->x()); if (count()==0) r=-1; else r = findRow(e->y()); // BL: workaround a bug in KTabListBox -- no !!! if (e->button() == RightButton) doPopup(r,c); else { //if ((y >= 0) && (x >= 0)) // updateItem(y,x); ; } }
void pushStudent(void) { int i; int j; char str[100]; j = findRow(); if (j == -1) { printf("No memory!"); return 0; } printf("New name: "); scanf("%s", &listStudent[j].name); printf("New surname: "); scanf("%s", &listStudent[j].surname); printf("New age: "); scanf("%s", &str); listStudent[j].age = atoi(str); printf("Enter exception (+ or -): "); scanf("%s", &listStudent[j].exception); printf("Enter group (KP-51 or KP-52): "); scanf("%s", &listStudent[j].ownGroup.nameG); }
void TableBody::mousePressEvent(QMouseEvent *e) { if (numRows() == 0) return; // *** prevent out of range // printf("mousePressEvent() 1\n"); static int last_row = -1; int row = findRow(e->y()); if (row == -1) { // printf("mousePressEvent\n"); htable->clearAllSelections(); if (e->y() >= 0) row = numRows(); // if SHIFT+click outside ~ first_drag_row = prev_drag_row = row; return; } if (!(htable->options & HTBL_ROW_SELECTION)) return; if (e->button() == Qt::LeftButton) { // folding if (htable->treemode && htable->folding && e->x() < htable->gadget_space + htable->treestep * htable->rowDepth(row) && htable->folded(row) != HeadedTable::Leaf) { emit htable->foldSubTree(row); gadget_click = true; last_row = row; // clearCache(); // dont use cache return; } if (e->modifiers() & Qt::ShiftModifier) { if (row < last_row) for (int i = row; i < last_row; i++) htable->setSelected(i, true); // virtual else for (int i = last_row; i <= row; i++) htable->setSelected(i, true); // virtual } else if (e->modifiers() & Qt::ControlModifier) { htable->setSelected(row, !htable->isSelected(row)); } else htable->selectOnlyOne(row); first_drag_row = prev_drag_row = row; emit htable->selectionChanged(); } else if (e->button() == Qt::RightButton) { if (!htable->isSelected(row)) htable->selectOnlyOne(row); emit htable->selectionChanged(); // better? emit htable->rightClicked(e->globalPos()); } last_row = row; // htable->repaint_changed(); repaintChanged(); // repaint // view->update(); // fast but use more CPU }
void PiecesTable::mousePressEvent(QMouseEvent* e) { QTableView::mousePressEvent(e); if (e->button() == RightButton) { // setup RMB pupup menu if(!_menu) { _menu = new QPopupMenu(this); _menu->insertItem(tr("R&andomize Pieces"), mRandomize); _menu->insertItem(tr("&Reset Pieces"), mReset); _menu->adjustSize(); } // execute RMB popup and check result switch(_menu->exec(mapToGlobal(e->pos()))) { case mRandomize: randomizeMap(); break; case mReset: initMap(); repaint(); break; default: break; } } else { // GAME LOGIC int cols = numCols(); int rows = numRows(); int item = cols*rows -1; // find the free position int pos = _map.find(item); if(pos < 0) return; int frow = pos / cols; int fcol = pos - frow * cols; // find click position int row = findRow(e->y()); int col = findCol(e->x()); // sanity check if (row < 0 || row >= rows) return; if (col < 0 || col >= cols) return; if ( row != frow && col != fcol ) return; // valid move? if(row != frow && col != fcol) return; // rows match -> shift pieces if(row == frow) { if (col < fcol) { for(int c = fcol; c > col; c--) { _map[c + row * cols] = _map[ c-1 + row *cols]; updateCell(row, c, false); } } else if (col > fcol) { for(int c = fcol; c < col; c++) { _map[c + row * cols] = _map[ c+1 + row *cols]; updateCell(row, c, false); } } } // cols match -> shift pieces else if (col == fcol) { if (row < frow) { for(int r = frow; r > row; r--) { _map[col + r * cols] = _map[ col + (r-1) *cols]; updateCell(r, col, false); } } else if (row > frow) { for(int r = frow; r < row; r++) { _map[col + r * cols] = _map[ col + (r+1) *cols]; updateCell(r, col, false); } } } // move free cell to click position _map[col + row * cols] = item; updateCell(row, col, false); // check if the player wins with this move checkwin(); } }
void KIconEditGrid::mouseMoveEvent( QMouseEvent *e ) { if(!e) return; int row = findRow( e->pos().y() ); int col = findCol( e->pos().x() ); int cell = row * numCols() + col; QPoint tmpp(col, row); if(tmpp == end) return; if(img->valid(col, row)) { //debug("%d X %d", col, row); emit poschanged(col, row); emit xposchanged((col*scaling())+scaling()/2); // for the rulers emit yposchanged((row*scaling())+scaling()/2); } if(ispasting && !btndown && img->valid(col, row)) { if( (col + cbsize.width()) > (numCols()-1) ) insrect.setX(numCols()-insrect.width()); else insrect.setX(col); if( (row + cbsize.height()) > (numRows()-1) ) insrect.setY(numRows()-insrect.height()); else insrect.setY(row); insrect.setSize(cbsize); //debug("Moving: %d x %d", insrect.width(), insrect.height()); start = insrect.topLeft(); end = insrect.bottomRight(); drawRect(false); return; } if(!img->valid(col, row) || !btndown) return; end.setX(col); end.setY(row); if(isselecting) { if(tool == SelectRect) drawRect(false); else drawEllipse(false); return; } switch( tool ) { case Eraser: currentcolor = TRANSPARENT; case Freehand: { setColor( cell, currentcolor ); //img.setPixel(col, row, currentcolor.pixel()); if ( selected != cell ) { modified = true; int prevSel = selected; selected = cell; repaint((prevSel%numCols())*cellsize,(prevSel/numCols())*cellsize, cellsize, cellsize, false); repaint(col*cellsize,row*cellsize, cellsize, cellsize, false); //updateCell( prevSel/numCols(), prevSel%numCols(), FALSE ); //updateCell( row, col, FALSE ); *((uint*)img->scanLine(row) + col) = (colorAt(cell)); } break; } case Find: { iconcolors.closestMatch(colorAt(cell)); if ( selected != cell ) { int prevSel = selected; selected = cell; repaint((prevSel%numCols())*cellsize,(prevSel/numCols())*cellsize, cellsize, cellsize, false); repaint(col*cellsize,row*cellsize, cellsize, cellsize, false); //updateCell( prevSel/numCols(), prevSel%numCols(), FALSE ); //updateCell( row, col, FALSE ); } break; } case Ellipse: case Circle: case FilledEllipse: case FilledCircle: { drawEllipse(false); break; } //case Select: case FilledRect: case Rect: { drawRect(false); break; } case Line: { drawLine(false); break; } case Spray: { drawSpray(QPoint(col, row)); modified = true; break; } default: break; } p = *img; emit changed(QPixmap(p)); //emit colorschanged(numColors(), data()); }
void KIconEditGrid::mouseReleaseEvent( QMouseEvent *e ) { if(!e || (e->button() != LeftButton)) return; int row = findRow( e->pos().y() ); int col = findCol( e->pos().x() ); btndown = false; end.setX(col); end.setY(row); int cell = row * numCols() + col; switch( tool ) { case Eraser: currentcolor = TRANSPARENT; case Freehand: { if(!img->valid(col, row)) return; setColor( cell, currentcolor ); //if ( selected != cell ) //{ //modified = true; int prevSel = selected; selected = cell; repaint((prevSel%numCols())*cellsize,(prevSel/numCols())*cellsize, cellsize, cellsize, false); repaint(col*cellsize,row*cellsize, cellsize, cellsize, false); //updateCell( prevSel/numCols(), prevSel%numCols(), FALSE ); //updateCell( row, col, FALSE ); *((uint*)img->scanLine(row) + col) = colorAt(cell); p = *img; //} break; } case Ellipse: case Circle: case FilledEllipse: case FilledCircle: { drawEllipse(true); break; } case FilledRect: case Rect: { drawRect(true); break; } case Line: { drawLine(true); break; } case Spray: { drawSpray(QPoint(col, row)); break; } case FloodFill: { QApplication::setOverrideCursor(waitCursor); drawFlood(col, row, colorAt(cell)); QApplication::restoreOverrideCursor(); updateColors(); emit needPainting(); p = *img; break; } case Find: { currentcolor = colorAt(cell); if ( selected != cell ) { int prevSel = selected; selected = cell; repaint((prevSel%numCols())*cellsize,(prevSel/numCols())*cellsize, cellsize, cellsize, false); repaint(col*cellsize,row*cellsize, cellsize, cellsize, false); //updateCell( prevSel/numCols(), prevSel%numCols(), FALSE ); //updateCell( row, col, FALSE ); } break; } default: break; } emit changed(QPixmap(p)); //emit colorschanged(numColors(), data()); }
void PiecesTable::mousePressEvent(TQMouseEvent* e) { QtTableView::mousePressEvent(e); if (e->button() == Qt::RightButton) { // execute RMB popup and check result _menu->exec(mapToGlobal(e->pos())); e->accept(); return; } else { // GAME LOGIC // find the free position int pos = _map.find(15); if(pos < 0) return; int frow = pos / numCols(); int fcol = pos - frow * numCols(); // find click position int row = findRow(e->y()); int col = findCol(e->x()); // sanity check if (row < 0 || row >= numRows()) return; if (col < 0 || col >= numCols()) return; // valid move? if(row != frow && col != fcol) return; // rows match -> shift pieces if(row == frow) { if (col < fcol) { for(int c = fcol; c > col; c--) { _map[c + row * numCols()] = _map[ c-1 + row *numCols()]; updateCell(row, c, false); } } else if (col > fcol) { for(int c = fcol; c < col; c++) { _map[c + row * numCols()] = _map[ c+1 + row *numCols()]; updateCell(row, c, false); } } } // cols match -> shift pieces else if (col == fcol) { if (row < frow) { for(int r = frow; r > row; r--) { _map[col + r * numCols()] = _map[ col + (r-1) *numCols()]; updateCell(r, col, false); } } else if (row > frow) { for(int r = frow; r < row; r++) { _map[col + r * numCols()] = _map[ col + (r+1) *numCols()]; updateCell(r, col, false); } } } // move free cell to click position _map[col + row * numCols()] = 15; updateCell(row, col, false); // check if the player wins with this move chectwin(); } }