void VDirectoryTree::mousePressEvent(QMouseEvent *event) { QTreeWidgetItem *item = itemAt(event->pos()); if (!item) { setCurrentItem(NULL); } VTreeWidget::mousePressEvent(event); }
void XmlTreeWidget::slotFindPrev() { int iCur, iPrev; iCur = m_foundItems.indexOf(currentItem()); if(iCur != -1 && iCur > 0) { iPrev = iCur-1; setCurrentItem(m_foundItems.at(iPrev)); } }
void ScanGallery::slotSelectImage(const KUrl &url) { FileTreeViewItem *found = findItemByUrl(url); if (found==NULL) found = m_defaultBranch->root(); scrollToItem(found); setCurrentItem(found); slotItemActivated(found); }
void DualEditableTree::itemClicked(QListViewItem *item, const QPoint &, int column) { if(item) { curCol = column; if(item == currentItem()) setCurrentItem(item); } }
void PropertyWidget_PathText::handleSelectionChanged() { if (!m_doc || !m_ScMW || m_ScMW->scriptIsRunning()) return; PageItem* currItem = currentItemFromSelection(); setCurrentItem(currItem); updateGeometry(); }
void KURLBar::slotContextMenuRequested(QListBoxItem *_item, const QPoint &pos) { if(m_isImmutable) return; KURLBarItem *item = dynamic_cast< KURLBarItem * >(_item); static const int IconSize = 10; static const int AddItem = 20; static const int EditItem = 30; static const int RemoveItem = 40; KURL lastURL = m_activeItem ? m_activeItem->url() : KURL(); bool smallIcons = m_iconSize < KIcon::SizeMedium; QPopupMenu *popup = new QPopupMenu(); popup->insertItem(smallIcons ? i18n("&Large Icons") : i18n("&Small Icons"), IconSize); popup->insertSeparator(); if(item != 0L && item->isPersistent()) { popup->insertItem(SmallIconSet("edit"), i18n("&Edit Entry..."), EditItem); popup->insertSeparator(); } popup->insertItem(SmallIconSet("filenew"), i18n("&Add Entry..."), AddItem); if(item != 0L && item->isPersistent()) { popup->insertItem(SmallIconSet("editdelete"), i18n("&Remove Entry"), RemoveItem); } int result = popup->exec(pos); switch(result) { case IconSize: setIconSize(smallIcons ? KIcon::SizeMedium : KIcon::SizeSmallMedium); m_listBox->triggerUpdate(true); break; case AddItem: addNewItem(); break; case EditItem: editItem(static_cast< KURLBarItem * >(item)); break; case RemoveItem: delete item; m_isModified = true; break; default: // abort break; } // reset current item m_activeItem = 0L; setCurrentItem(lastURL); }
void PropertiesPalette_Group::handleSelectionChanged() { if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning()) return; PageItem* currItem = currentItemFromSelection(); if (m_doc->m_Selection->count() > 1) { bool widgetEnabled = false; if (m_haveItem && m_item) { if ((m_item->isGroup()) && (!m_item->isSingleSel)) widgetEnabled = true; } setEnabled(widgetEnabled); } else { int itemType = currItem ? (int) currItem->itemType() : -1; m_haveItem = (itemType != -1); switch (itemType) { case -1: setEnabled(false); break; case PageItem::ImageFrame: case PageItem::LatexFrame: case PageItem::OSGFrame: if (currItem->asOSGFrame()) { setEnabled(false); } break; case PageItem::Arc: case PageItem::TextFrame: case PageItem::Line: case PageItem::ItemType1: case PageItem::ItemType3: case PageItem::Polygon: case PageItem::PolyLine: case PageItem::PathText: case PageItem::RegularPolygon: setEnabled(false); break; case PageItem::Symbol: setEnabled(true); break; } } if (currItem) { setCurrentItem(currItem); } updateGeometry(); repaint(); }
void KCombo::setText( const char *text) { setCurrentItem(0); if (!set_text_called) { set_text_called = true; insertItem(text, 0); } changeItem(text, 0); }
void XmlTreeWidget::slotFindNext() { int iCur, iNext; iCur = m_foundItems.indexOf(currentItem()); if(iCur != -1 && iCur < m_foundItems.count()-1) { iNext = iCur+1; setCurrentItem(m_foundItems.at(iNext)); } }
void NotesWidget::selectNoteWithGuid(QString guid) { ListItem *item = getNoteWithGuid(guid); if (item == NULL) return; setCurrentItem(item); }
/* 构造函数实现 */ _CategoriesTree::_CategoriesTree(QWidget *_Parent) : QTreeWidget(_Parent) { /* "评分" */ m_RatingRootItem = new QTreeWidgetItem(this, QStringList() << wxNote::g_RatingListName); m_RatingRootItem->setIcon(0, QIcon(":/wxNote_Icons/rating.png")); m_RatingRootItem->setExpanded(true); m_ExcellentItem = new QTreeWidgetItem( m_RatingRootItem, QStringList() << wxNote::g_ExcellentName); m_ExcellentItem->setIcon(0, QIcon(":/wxNote_Icons/excellent.png")); m_GoodItem = new QTreeWidgetItem( m_RatingRootItem, QStringList() << wxNote::g_GoodName); m_GoodItem->setIcon(0, QIcon(":/wxNote_Icons/good.png")); m_AverageItem = new QTreeWidgetItem( m_RatingRootItem, QStringList() << wxNote::g_AverageName); m_AverageItem->setIcon(0, QIcon(":/wxNote_Icons/average.png")); m_FairItem = new QTreeWidgetItem( m_RatingRootItem, QStringList() << wxNote::g_FairName); m_FairItem->setIcon(0, QIcon(":/wxNote_Icons/fair.png")); m_PoorItem = new QTreeWidgetItem( m_RatingRootItem, QStringList() << ("差")); m_PoorItem->setIcon(0, QIcon(":/wxNote_Icons/poor.png")); /* "颜色标签" */ m_ColorLabelRootItem = new QTreeWidgetItem( this, QStringList() << wxNote::g_ColorLabelListName); m_ColorLabelRootItem->setIcon(0, QIcon(":/wxNote_Icons/colorLabel.png")); m_ColorLabelRootItem->setExpanded(true); m_ImportantItem = new QTreeWidgetItem(m_ColorLabelRootItem, QStringList() << wxNote::g_ImportantName); m_ImportantItem->setIcon(0, QIcon(":/wxNote_Icons/important.png")); m_WorkItem = new QTreeWidgetItem(m_ColorLabelRootItem, QStringList() << wxNote::g_WorkName); m_WorkItem->setIcon(0, QIcon(":/wxNote_Icons/work.png")); m_PersonalItem = new QTreeWidgetItem(m_ColorLabelRootItem, QStringList() << wxNote::g_PersonalName); m_PersonalItem->setIcon(0, QIcon(":/wxNote_Icons/personal.png")); m_ToDoItem = new QTreeWidgetItem(m_ColorLabelRootItem, QStringList() << wxNote::g_ToDoName); m_ToDoItem->setIcon(0, QIcon(":/wxNote_Icons/toDo.png")); m_LaterItem = new QTreeWidgetItem(m_ColorLabelRootItem, QStringList() << wxNote::g_LaterName); m_LaterItem->setIcon(0, QIcon(":/wxNote_Icons/later.png")); setCurrentItem(m_RatingRootItem); setHeaderHidden(true); }
void ScTreeWidget::handleMousePress(QTreeWidgetItem *item) { if (item == 0) return; if (item->parent() == 0) { if (item->isDisabled()) { setItemExpanded(item, false); return; } int wide = 0; int tops = topLevelItemCount(); if (m_toolbox_mode) { for (int t = 0; t < tops; t++) { setItemExpanded(topLevelItem(t), false); } setCurrentItem(item); setItemExpanded(item, true); if (item->childCount() != 0) { QTreeWidgetItem *child = item->child(0); if (child != 0) wide = itemWidget(child, 0)->minimumSizeHint().width()+5; } if (wide != 0) setColumnWidth(0, wide); else resizeColumnToContents(0); } else { setItemExpanded(item, !isItemExpanded(item)); for (int t = 0; t < tops; t++) { QTreeWidgetItem *top = topLevelItem(t); if (isItemExpanded(top)) { if (top->childCount() != 0) { QTreeWidgetItem *child = top->child(0); if (child != 0) wide = qMax(wide, itemWidget(child, 0)->minimumSizeHint().width()+5); } } } } if (wide != 0) setColumnWidth(0, wide); else resizeColumnToContents(0); emit currentChanged2(indexOfTopLevelItem(item)); } }
void XComboBox::setCode(QString pString) { if (DEBUG) qDebug("%s::setCode(%d %d %s) with _codes.count %d and _ids.count %d", objectName().toAscii().data(), pString.isNull(), pString.isEmpty(), pString.toAscii().data(), _codes.count(), _ids.count()); if (pString.isEmpty()) { setId(-1); setCurrentText(pString); } else if (count() == _codes.count()) { for (int counter = ((allowNull()) ? 1 : 0); counter < count(); counter++) { if (_codes.at(counter) == pString) { if (DEBUG) qDebug("%s::setCode(%s) found at %d with _ids.count %d & _lastId %d", objectName().toAscii().data(), pString.toAscii().data(), counter, _ids.count(), _lastId); setCurrentIndex(counter); if (_ids.count() && _lastId!=_ids.at(counter)) setId(_ids.at(counter)); return; } else if (DEBUG) qDebug("%s::setCode(%s) not found (%s)", qPrintable(objectName()), qPrintable(pString), qPrintable(_codes.at(counter))); } } else // this is an ad-hoc combobox without a query behind it? { setCurrentItem(findText(pString)); if (DEBUG) qDebug("%s::setCode(%s) set current item to %d using findData()", objectName().toAscii().data(), pString.toAscii().data(), currentItem()); if (_ids.count() > currentItem()) setId(_ids.at(currentItem())); if (DEBUG) qDebug("%s::setCode(%s) current item is %d after setId", objectName().toAscii().data(), pString.toAscii().data(), currentItem()); } if (editable()) { setId(-1); setCurrentText(pString); } }
void ButtonWithMenu::addItem(const Item &item) { m_items.append(item); if (m_items.count() == 1) { setCurrentItem(item); } emit itemAdded(item); }
void FeedListWidget::handleItemAboutToBeRemoved(RSS::Item *rssItem) { rssItem->disconnect(this); delete m_rssToTreeItemMapping.take(rssItem); // RSS Item is still valid in this slot so if it is the last // item we should prevent Unread list populating if (m_rssToTreeItemMapping.size() == 1) setCurrentItem(nullptr); }
void TreeWidget::collapseCurrentConnection() { QTreeWidgetItem* item = currentItem(); if (item && item->parent()) item = item->parent(); if (item) { collapseItem(item); setCurrentItem(item); } }
void StatusPicker::setStatusId( int statusid ) { QMap<int,int>::Iterator it; for ( it = index2id.begin(); it != index2id.end(); ++it ) { if ( it.data() == statusid ) { setCurrentItem( it.key() ); break; } } }
void PropertiesPalette_Shadow::handleSelectionChanged() { if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning()) return; PageItem* currItem = currentItemFromSelection(); if (currItem) setCurrentItem(currItem); updateGeometry(); }
void SummaryTree::deleteTask() { if (QMessageBox::warning(this, tr("Lemon"), tr("Are you sure to delete this task?"), QMessageBox::Yes, QMessageBox::Cancel) == QMessageBox::Cancel) return; QTreeWidgetItem *curItem = currentItem(); if (indexOfTopLevelItem(curItem) == -1) curItem = curItem->parent(); int index = indexOfTopLevelItem(curItem); if (index + 1 < topLevelItemCount()) setCurrentItem(topLevelItem(index + 1)); else if (index - 1 >= 0) setCurrentItem(topLevelItem(index - 1)); else setCurrentItem(0); delete curItem; curContest->deleteTask(index); }
PassRefPtr<HistoryItem> HistoryController::createItem() { RefPtr<HistoryItem> item = HistoryItem::create(); initializeItem(item.get()); // Set the item for which we will save document state setCurrentItem(item.get()); return item.release(); }
Ref<HistoryItem> HistoryController::createItem() { Ref<HistoryItem> item = HistoryItem::create(); initializeItem(item); // Set the item for which we will save document state setCurrentItem(item.ptr()); return item; }
void RListWidget::contextMenuEvent(QContextMenuEvent* e) { if (e != NULL) { QListWidgetItem* item = itemAt(e->pos()); if (item != NULL) { setCurrentItem(item); emit itemClicked(item); } } e->ignore(); }
ComboVisibility::ComboVisibility(QWidget * parent, UmlVisibility v, bool nodefault) : Q3ComboBox(FALSE, parent) { // the last value MUST be default for (int i = 0; i != (int) UmlDefaultVisibility; i += 1) insertItem(stringify((UmlVisibility) i)); if (!nodefault) insertItem(stringify(UmlDefaultVisibility)); setCurrentItem(v); }
void MailListView::setSelectedItem(QTableWidgetItem* item) { // Replace any existing selection with this item clearSelection(); item->setSelected(true); // Make this item the current item, also setCurrentItem(item); scrollToItem(item); }
void KoResourceItemChooser::slotButtonClicked( int button ) { if (button == Button_Import ) { QString extensions = d->model->extensions(); QString filter = QString("%1 (%2)") .arg(d->model->serverType()) .arg(extensions.replace(QString(":"), QString(" "))); KoFileDialog dialog(0, KoFileDialog::OpenFile, "OpenDocument"); dialog.setNameFilter(filter); dialog.setCaption(i18nc("@title:window", "Choose File to Add")); QString filename = dialog.url(); d->model->importResourceFile(filename); } else if( button == Button_Remove ) { QModelIndex index = d->view->currentIndex(); int row = index.row(); int column = index.column(); if( index.isValid() ) { KoResource * resource = resourceFromModelIndex(index); if( resource ) { d->model->removeResource(resource); } } if (column == 0) { int rowMin = --row; row = qBound(0, rowMin, row); } int columnMin = --column; column = qBound(0, columnMin, column); setCurrentItem(row, column); activated(d->model->index(row, column)); } #ifdef GHNS else if (button == Button_GhnsDownload) { KNS3::DownloadDialog dialog(d->knsrcFile, this); dialog.exec(); foreach (const KNS3::Entry& e, dialog.changedEntries()) { foreach(const QString &file, e.installedFiles()) { QFileInfo fi(file); d->model->importResourceFile( fi.absolutePath()+'/'+fi.fileName() , false ); } foreach(const QString &file, e.uninstalledFiles()) { QFileInfo fi(file); d->model->removeResourceFile(fi.absolutePath()+'/'+fi.fileName()); } } }
void TreeView::selectMenu(const QString &menu) { closeAllItems(firstChild()); if (menu.length() <= 1) { setCurrentItem(firstChild()); clearSelection(); return; // Root menu } QString restMenu = menu.mid(1); if (!restMenu.endsWith('/')) restMenu += '/'; TreeItem *item = 0; do { int i = restMenu.indexOf("/"); QString subMenu = restMenu.left(i+1); restMenu = restMenu.mid(i+1); item = (TreeItem*)(item ? item->firstChild() : firstChild()); while(item) { MenuFolderInfo *folderInfo = item->folderInfo(); if (folderInfo && (folderInfo->id == subMenu)) { item->setOpen(true); break; } item = (TreeItem*) item->nextSibling(); } } while( item && !restMenu.isEmpty()); if (item) { setCurrentItem(item); ensureItemVisible(item); } }
void UserMenuTree::insertMenuItemAbove(QTreeWidgetItem *current, UserMenuData::MenuType type, const QString &menulabel) { QTreeWidgetItem *parent = ( current ) ? current->parent() : NULL; int index = itemIndex(parent,current); UserMenuItem *item = new UserMenuItem(type,menulabel); insertItem(parent,index,item); item->setText(0,menulabel); setCurrentItem(item); }
void MIPSmemview::updateList(void) { unsigned int i; int top=topItem(); for(i=0;i<mem.size();i+=4) { changeItem(MemItem(i),i/4); } setCurrentItem(current()); setTopItem(top); }
void KDPluginsListBox::dragMoveEvent( QDragMoveEvent *e ) { if( KColorDrag::canDecode(e) && isEnabled() ) { KDPluginsListBoxItem *item = (KDPluginsListBoxItem*)itemAt( e->pos() ); if( item != 0 ) { setCurrentItem ( item ); } } }
/** * Creates a new list item showing a history record. * @param sFunc The name of the function * @param sFile The file path * @param sLine The line number in the above file * @param sText The line's text */ void HistoryView::addRecord(const QString& sFunc, const QString& sFile, const QString& sLine, const QString& sText, QTreeWidgetItem*) { HistoryItem* pItem; QStringList s; s << sFunc << sFile << sLine << sText; pItem = new HistoryItem(this, s); setCurrentItem(pItem); }