/** * @brief triggers refresh of view for item that has changed */ void VirtnosisWindow::selectedDataChanged() { QModelIndex index = currentIndex(); ui->domainView->dataChanged(index, index); }
/** * @brief slot to be called when data in the view changes */ void VirtnosisWindow::dataChanged() { selectionChanged(currentIndex(), currentIndex()); }
void KoResourceItemView::mousePressEvent(QMouseEvent *event) { m_beforeClickIndex = currentIndex(); KoTableView::mousePressEvent(event); }
void KateFileTree::slotDocumentNext() { // kDebug(debugArea()) << "BEGIN"; KateFileTreeProxyModel *ftpm = static_cast<KateFileTreeProxyModel*>(model()); QModelIndex current_index = currentIndex(); int parent_row_count = ftpm->rowCount( ftpm->parent(current_index) ); QModelIndex next; // scan down the tree skipping any dir nodes while(current_index.isValid()) { if(current_index.row() < parent_row_count-1) { current_index = ftpm->sibling(current_index.row()+1, current_index.column(), current_index); if(!current_index.isValid()) { break; } if(ftpm->isDir(current_index)) { // we have a dir node while(ftpm->isDir(current_index)) { current_index = ftpm->index(0, 0, current_index); } parent_row_count = ftpm->rowCount( ftpm->parent(current_index) ); if(!ftpm->isDir(current_index)) { next = current_index; break; } } else { // found document item next = current_index; break; } } else { // select the parent's next sibling QModelIndex parent_index = ftpm->parent(current_index); int grandparent_row_count = ftpm->rowCount( ftpm->parent(parent_index) ); current_index = parent_index; parent_row_count = grandparent_row_count; // at least if we're not past the last node if(!current_index.isValid()) { // paste the root node here, try and wrap around QModelIndex last_index = ftpm->index(0, 0, QModelIndex()); if(!last_index.isValid()) { break; } if(ftpm->isDir(last_index)) { // last node is a dir, select first child row while(ftpm->isDir(last_index)) { if(ftpm->rowCount(last_index)) { // has children, select first last_index = ftpm->index(0, 0, last_index); } } next = last_index; break; } else { // got first file node next = last_index; break; } } } } if(next.isValid()) { //kDebug(debugArea()) << "got next node:" << next; //kDebug(debugArea()) << "doc:" << ftpm->data(next, Qt::DisplayRole).value<QString>(); KTextEditor::Document *doc = model()->data(next, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>(); emit activateDocument(doc); } else { // kDebug(debugArea()) << "didn't get next node :("; } // kDebug(debugArea()) << "END"; }
QVariant QValueComboBox::value() const { return itemData(currentIndex(), role); }
void PieView::paintEvent(QPaintEvent *event) { QItemSelectionModel *selections = selectionModel(); QStyleOptionViewItem option = viewOptions(); QStyle::State state = option.state; QBrush background = option.palette.base(); QPen foreground(option.palette.color(QPalette::WindowText)); QPen textPen(option.palette.color(QPalette::Text)); QPen highlightedPen(option.palette.color(QPalette::HighlightedText)); QPainter painter(viewport()); painter.setRenderHint(QPainter::Antialiasing); painter.fillRect(event->rect(), background); painter.setPen(foreground); // Viewport rectangles QRect pieRect = QRect(margin, margin, pieSize, pieSize); QPoint keyPoint = QPoint(totalSize - horizontalScrollBar()->value(), margin - verticalScrollBar()->value()); if (validItems > 0) { painter.save(); painter.translate(pieRect.x() - horizontalScrollBar()->value(), pieRect.y() - verticalScrollBar()->value()); painter.drawEllipse(0, 0, pieSize, pieSize); double startAngle = 0.0; int row; for (row = 0; row < model()->rowCount(rootIndex()); ++row) { QModelIndex index = model()->index(row, 1, rootIndex()); double value = model()->data(index).toDouble(); if (value > 0.0) { double angle = 360*value/totalValue; QModelIndex colorIndex = model()->index(row, 0, rootIndex()); QColor color = QColor(model()->data(colorIndex, Qt::DecorationRole).toString()); if (currentIndex() == index) painter.setBrush(QBrush(color, Qt::Dense4Pattern)); else if (selections->isSelected(index)) painter.setBrush(QBrush(color, Qt::Dense3Pattern)); else painter.setBrush(QBrush(color)); painter.drawPie(0, 0, pieSize, pieSize, int(startAngle*16), int(angle*16)); startAngle += angle; } } painter.restore(); int keyNumber = 0; for (row = 0; row < model()->rowCount(rootIndex()); ++row) { QModelIndex index = model()->index(row, 1, rootIndex()); double value = model()->data(index).toDouble(); if (value > 0.0) { QModelIndex labelIndex = model()->index(row, 0, rootIndex()); QStyleOptionViewItem option = viewOptions(); option.rect = visualRect(labelIndex); if (selections->isSelected(labelIndex)) option.state |= QStyle::State_Selected; if (currentIndex() == labelIndex) option.state |= QStyle::State_HasFocus; itemDelegate()->paint(&painter, option, labelIndex); keyNumber++; } } } }
Qt::PenStyle AMPenStyleComboBox::selectedPenStyle() const { int currentPenStyleIndex = itemData(currentIndex()).toInt(); return (Qt::PenStyle)currentPenStyleIndex; }
QSize TabBar::tabSizeHint(int index, bool fast) const { if (!isVisible() || !mApp->proxyStyle()) { // Don't calculate it when tabbar is not visible // It produces invalid size anyway // // We also need ProxyStyle to be set before calculating minimum sizes for tabs return QSize(-1, -1); } static int PINNED_TAB_WIDTH = comboTabBarPixelMetric(ComboTabBar::PinnedTabWidth); static int MINIMUM_ACTIVE_TAB_WIDTH = comboTabBarPixelMetric(ComboTabBar::ActiveTabMinimumWidth); static int MAXIMUM_TAB_WIDTH = comboTabBarPixelMetric(ComboTabBar::NormalTabMaximumWidth); static int MINIMUM_TAB_WIDTH = comboTabBarPixelMetric(ComboTabBar::NormalTabMinimumWidth); QSize size = ComboTabBar::tabSizeHint(index); // The overflowed tabs have same size and we can use this fast method if (fast) { size.setWidth(index >= pinnedTabsCount() ? MINIMUM_TAB_WIDTH : PINNED_TAB_WIDTH); return size; } WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); TabBar* tabBar = const_cast <TabBar*>(this); if (webTab && webTab->isPinned()) { size.setWidth(PINNED_TAB_WIDTH); } else { int availableWidth = mainTabBarWidth() - comboTabBarPixelMetric(ExtraReservedWidth); if (availableWidth < 0) { return QSize(-1, -1); } const int normalTabsCount = ComboTabBar::normalTabsCount(); if (availableWidth >= MAXIMUM_TAB_WIDTH * normalTabsCount) { m_normalTabWidth = MAXIMUM_TAB_WIDTH; size.setWidth(m_normalTabWidth); } else if (normalTabsCount > 0) { int maxWidthForTab = availableWidth / normalTabsCount; int realTabWidth = maxWidthForTab; bool adjustingActiveTab = false; if (realTabWidth < MINIMUM_ACTIVE_TAB_WIDTH) { maxWidthForTab = normalTabsCount > 1 ? (availableWidth - MINIMUM_ACTIVE_TAB_WIDTH) / (normalTabsCount - 1) : 0; realTabWidth = MINIMUM_ACTIVE_TAB_WIDTH; adjustingActiveTab = true; } bool tryAdjusting = availableWidth >= MINIMUM_TAB_WIDTH * normalTabsCount; if (m_showCloseOnInactive != 1 && tabsClosable() && availableWidth < (MINIMUM_TAB_WIDTH + 25) * normalTabsCount) { // Hiding close buttons to save some space tabBar->setTabsClosable(false); tabBar->showCloseButton(currentIndex()); } if (m_showCloseOnInactive == 1) { // Always showing close buttons tabBar->setTabsClosable(true); tabBar->showCloseButton(currentIndex()); } if (tryAdjusting) { m_normalTabWidth = maxWidthForTab; // Fill any empty space (we've got from rounding) with active tab if (index == mainTabBarCurrentIndex()) { if (adjustingActiveTab) { m_activeTabWidth = (availableWidth - MINIMUM_ACTIVE_TAB_WIDTH - maxWidthForTab * (normalTabsCount - 1)) + realTabWidth; } else { m_activeTabWidth = (availableWidth - maxWidthForTab * normalTabsCount) + maxWidthForTab; } size.setWidth(m_activeTabWidth); } else { size.setWidth(m_normalTabWidth); } } } // Restore close buttons according to preferences if (m_showCloseOnInactive != 2 && !tabsClosable() && availableWidth >= (MINIMUM_TAB_WIDTH + 25) * normalTabsCount) { tabBar->setTabsClosable(true); // Hide close buttons on pinned tabs for (int i = 0; i < count(); ++i) { tabBar->updatePinnedTabCloseButton(i); } } } if (index == count() - 1) { WebTab* lastMainActiveTab = qobject_cast<WebTab*>(m_tabWidget->widget(mainTabBarCurrentIndex())); int xForAddTabButton = cornerWidth(Qt::TopLeftCorner) + pinTabBarWidth() + normalTabsCount() * m_normalTabWidth; if (lastMainActiveTab && m_activeTabWidth > m_normalTabWidth) { xForAddTabButton += m_activeTabWidth - m_normalTabWidth; } if (QApplication::layoutDirection() == Qt::RightToLeft) { xForAddTabButton = width() - xForAddTabButton; } emit tabBar->moveAddTabButton(xForAddTabButton); } return size; }
int QWmpPlaylistControl::nextIndex(int steps) const { return currentIndex() + steps; }
int QWmpPlaylistControl::previousIndex(int steps) const { return currentIndex() - steps; }
void ComposerAttachmentsList::slotToggledContentDispositionInline(bool checked) { m_composer->setAttachmentContentDisposition(currentIndex(), checked ? Composer::CDN_INLINE : Composer::CDN_ATTACHMENT); }
void ComposerAttachmentsList::slotRemoveAttachment() { m_composer->removeAttachment(currentIndex()); }
void CTabWidget::update(int c) { if(_visible) { move_panel(_panel, _pos.y(), _pos.x()); //top_panel(_panel); wclear(_window); if(_listenKeys) { if(c == KEY_LEFT) { if(currentIndex() - 1 >= 0) setCurrentIndex(currentIndex() - 1); else setCurrentIndex(count() - 1); } else if(c == KEY_RIGHT) { if(currentIndex() + 1 < int(count())) setCurrentIndex(currentIndex() + 1); else setCurrentIndex(0); } } uint tw = _size.width() - _leftMargin - _rightMargin; // Is left mouse button pressed? #ifdef __PDCURSES__ bool leftClick = focused() && Mouse_status.button[0] == BUTTON_PRESSED; #else bool leftClick = false; MEVENT event; if(getmouse(&event) == OK) leftClick = focused() && (event.bstate & BUTTON1_PRESSED); #endif int k = 0; for(uint i = 0; i < _widgets.size(); ++i) { if(leftClick) { if(_mousePos.x() >= _pos.x() + _leftMargin + k && _mousePos.x() < _pos.x() + _leftMargin + k + _widgets[i]->name().size() && _mousePos.y() == (_bottom ? _pos.y() + _size.height() - 1 : _pos.y())) { // select tab setCurrentIndex(i); } } if(currentIndex() == i) wattr_on(_window, A_BOLD, 0); mvwaddstr(_window, _bottom ? _size.height() - 1 : 0, _leftMargin + k, _widgets[i]->name().c_str()); if(_currentIndex == i) wattr_off(_window, A_BOLD, 0); k += _widgets[i]->name().size() + 1; } if(_layout) { if(_changed) { DEBUG_ui("CTabWidget::update, 0"); _layout->setSize(_size.width(), _size.height() - 1); _layout->setPosition(_pos.x(), _bottom ? _pos.y() : _pos.y() + 1); _changed = false; DEBUG_ui("CTabWidget::update, 1"); } _layout->update(c); } } }
void ResultList::enter() { if (currentIndex().isValid()) emit clicked(currentIndex()); }
/** * @brief slot that is called when Hypervisor is to be connected * * When this slot is called, the currently selected hypervisor is connected */ void VirtnosisWindow::on_menuHypervisorActionConnect_triggered() { connectHypervisor(currentIndex()); }
PAlbum* AlbumTreeView::currentAlbum() const { return dynamic_cast<PAlbum*> (m_albumFilterModel->albumForIndex(currentIndex())); }
/** * @brief slot that is called when Hypervisor is to be disconnected * * When this slot is called, the currently selected hypervisor is disconnected */ void VirtnosisWindow::on_menuHypervisorActionDisconnect_triggered() { model()->disconnectHypervisor(currentIndex()); }
void TabBar::closeCurrentTab() { m_tabWidget->closeTab(currentIndex()); }
/** * @brief slot that is called when Hypervisor is to be deleted * * When this slot is called, the currently selected hypervisor is deleted */ void VirtnosisWindow::on_menuHypervisorActionRemove_triggered() { model()->removeRow(currentIndex().row()); writeHypervisorSettings(); }
bool QBooleanComboBox::value() const { return (currentIndex() == 1); }
/** * @brief provides the selected domain * @return selected domain object */ Domain VirtnosisWindow::selectedDomain() { QModelIndex index = currentIndex(); return qvariant_cast<Domain>(index.data(DomainViewModel::domainDomainRole)); }
void Workspace::refreshActiveWorksheet() { WorkSheet* currentSheet = mSheetList.at(currentIndex()); currentSheet->refreshSheet(); }
/** * @brief provides the selected hypervisor * @return selected hypervisor object */ Hypervisor VirtnosisWindow::selectedHypervisor() { QModelIndex index = currentIndex(); return qvariant_cast<Hypervisor>(index.data(DomainViewModel::domainHypervisorRole)); }
Qt::PenCapStyle QgsPenCapStyleComboBox::penCapStyle() const { return ( Qt::PenCapStyle ) itemData( currentIndex() ).toInt(); }
void KateFileTree::slotDocumentPrev() { // kDebug(debugArea()) << "BEGIN"; KateFileTreeProxyModel *ftpm = static_cast<KateFileTreeProxyModel*>(model()); QModelIndex current_index = currentIndex(); QModelIndex prev; // scan up the tree skipping any dir nodes //kDebug(debugArea()) << "cur" << ftpm->data(current_index, Qt::DisplayRole); while(current_index.isValid()) { if(current_index.row() > 0) { current_index = ftpm->sibling(current_index.row()-1, current_index.column(), current_index); //kDebug(debugArea()) << "get prev" << ftpm->data(current_index, Qt::DisplayRole); if(!current_index.isValid()) { //kDebug(debugArea()) << "somehow getting prev index from sibling didn't work :("; break; } if(ftpm->isDir(current_index)) { // try and select the last child in this parent //kDebug(debugArea()) << "is a dir"; int children = ftpm->rowCount(current_index); current_index = ftpm->index(children-1, 0, current_index); //kDebug(debugArea()) << "child" << ftpm->data(current_index, Qt::DisplayRole); if(ftpm->isDir(current_index)) { // since we're a dir, keep going //kDebug(debugArea()) << "child is a dir"; while(ftpm->isDir(current_index)) { children = ftpm->rowCount(current_index); current_index = ftpm->index(children-1, 0, current_index); } if(!ftpm->isDir(current_index)) { prev = current_index; break; } continue; } else { // we're the previous file, set prev //kDebug(debugArea()) << "got doc 1"; prev = current_index; break; } } else { // found document item //kDebug(debugArea()) << "got doc 2"; prev = current_index; break; } } else { //kDebug(debugArea()) << "get parent"; // just select the parent, the logic above will handle the rest current_index = ftpm->parent(current_index); //kDebug(debugArea()) << "got parent" << ftpm->data(current_index, Qt::DisplayRole); if(!current_index.isValid()) { // paste the root node here, try and wrap around //kDebug(debugArea()) << "parent invalid"; int children = ftpm->rowCount(current_index); QModelIndex last_index = ftpm->index(children-1, 0, current_index); //kDebug(debugArea()) << "last" << ftpm->data(last_index, Qt::DisplayRole); if(!last_index.isValid()) break; if(ftpm->isDir(last_index)) { // last node is a dir, select last child row //kDebug(debugArea()) << "last root is a dir, select child"; int last_children = ftpm->rowCount(last_index); prev = ftpm->index(last_children-1, 0, last_index); //kDebug(debugArea()) << "last child" << ftpm->data(current_index, Qt::DisplayRole); // bug here? break; } else { // got last file node //kDebug(debugArea()) << "got doc"; prev = last_index; break; } } } } if(prev.isValid()) { //kDebug(debugArea()) << "got prev node:" << prev; //kDebug(debugArea()) << "doc:" << ftpm->data(prev, Qt::DisplayRole).value<QString>(); KTextEditor::Document *doc = model()->data(prev, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>(); emit activateDocument(doc); } else { // kDebug(debugArea()) << "didn't get prev node :("; } // kDebug(debugArea()) << "END"; }