void VSCDeviceTree::SiteRefreshClick() { QTreeWidgetItem *item = NULL; item = currentItem(); VDC_DEBUG( "%s \n",__FUNCTION__); if(item != NULL) { VSCVmsZb *pVms = dynamic_cast<VSCVmsZb * >(item); if (pVms) { VDC_DEBUG( "%s \n",__FUNCTION__); pVms->Refresh(); } } return; }
/** * Create new attribute. */ void RefactoringAssistant::createAttribute() { QTreeWidgetItem *item = currentItem(); if (!item) { uWarning() << "Called with no item selected."; return; } UMLClassifier *c = dynamic_cast<UMLClassifier*>(findUMLObject(item)); if (!c) { // find parent QTreeWidgetItem *parent = item->parent(); c = dynamic_cast<UMLClassifier*>(findUMLObject(parent)); if (!c) { uWarning() << "No classifier - cannot create!"; return; } } c->createAttribute(); }
void TodoView::newTodo() { QString tmpStr; KDPEvent *newEvent; newEvent = new KDPEvent; newEvent->setStatus(QString("NEEDS ACTION")); newEvent->setPriority(1); calendar->addTodo(newEvent); tmpStr.sprintf("%i\n",newEvent->getEventId()); tmpStr += "EMPTY\n0\n \n "; appendItem(tmpStr.data()); repaint(); setCurrentItem(numRows()-1); updateItem(currentItem(), 3); }
void query_listview::context_menu(const QPoint& pos) { query_lvitem* item = dynamic_cast<query_lvitem*>(itemAt(pos)); if (item && item != currentItem()) setCurrentItem(item); if (item && item->m_type==query_lvitem::user_defined) { // contextual menu QMenu qmenu(this); qmenu.setTitle(item->text(0)); QAction* action_run = qmenu.addAction(tr("Run query")); QAction* action_edit = qmenu.addAction(tr("Edit")); QAction* action_remove = qmenu.addAction(tr("Remove")); QAction* selected=qmenu.exec(QCursor::pos()); // user action if (selected==action_remove) { // remove this user query int r=QMessageBox::warning(this, tr("Please confirm"), tr("Delete user query?"), tr("OK"), tr("Cancel"), QString::null); if (r==0) { if (user_queries_repository::remove_query(item->text(0))) { delete item; } } } else if (selected==action_edit) { // edit the user query extern void save_filter_query(msgs_filter*, int, const QString); // FIXME msgs_filter f; f.set_user_query(item->m_sql); save_filter_query(&f, 1, item->text(0)); reload_user_queries(); } else if (selected==action_run) { // run the query msgs_filter f; f.m_sql_stmt = item->m_sql; emit run_selection_filter(f); } return; } }
void CFileList::Delete() { #ifdef QT_V4LAYOUT Q3ListViewItem *pListViewItem; #else QListViewItem *pListViewItem; #endif char szINI[FILENAME_MAX+1]; char *pDataSourceName; QString qsError; DWORD nErrorCode; char szErrorMsg[FILENAME_MAX+1]; // GET SELECT DATA SOURCE NAME pListViewItem = currentItem(); if ( pListViewItem ) { pDataSourceName = (char *)pListViewItem->text( 0 ).ascii(); } else { QMessageBox::information( this, "ODBC Config", "Please select a Data Source from the list first" ); return; } char dir[ 256 ]; sprintf( dir, "%s/%s", cwd.ascii(), pDataSourceName ); // DELETE ENTIRE SECTION IF IT EXISTS (given NULL entry) if ( unlink( dir )) { QString msg; msg.sprintf( "Unable to unlink %s", dir ); QMessageBox::information( this, "ODBC Config", msg ); } else { QMessageBox::information( this, "ODBC Config", "Done!" ); } // RELOAD (slow but safe) Load(); }
void VSCDeviceTree::CameraStopRecordClick() { QTreeWidgetItem *item = NULL; item = currentItem(); VDC_DEBUG( "%s Stop Record\n",__FUNCTION__); if(item != NULL) { VSCDeviceIPC *pIpc = dynamic_cast<VSCDeviceIPC * >(item); if (pIpc) { VDC_DEBUG( "%s Stop Record\n",__FUNCTION__); u32 nId = pIpc->GetDeviceId(); gFactory->StopRecord(nId); } } return; }
void VSCDeviceTree::CameraDeleteClick() { QTreeWidgetItem *item = NULL; item = currentItem(); VDC_DEBUG( "%s \n",__FUNCTION__); if(item != NULL) { VSCDeviceIPC *pIpc = dynamic_cast<VSCDeviceIPC * >(item); if (pIpc) { VDC_DEBUG( "%s \n",__FUNCTION__); u32 nId = pIpc->GetDeviceId(); emit CameraDeleteClicked(nId); } } return; }
/** Checks if the drop occured on a child of the item * that got dragged. */ bool SafeListView::isTargetChild(QDropEvent *event, SafeListViewItem *target) { // prevent incest if(event->source() == viewport()) { DBGOUT("\tWarning!!"); Q3ListViewItem *item = currentItem(); // make sure this isn't a child of item Q3ListViewItem *p = target; for(; p != NULL; p = p->parent()) { if(p == item) { DBGOUT("\tThe dragged item is a parent"); return true; } } } return false; }
void SummaryTree::selectionChanged() { if (! isEnabled()) return; QTreeWidgetItem *curItem = currentItem(); if (! curItem) { deleteTaskKeyAction->setEnabled(false); deleteTestCaseKeyAction->setEnabled(false); return; } int index = indexOfTopLevelItem(curItem); if (index != -1) { deleteTaskKeyAction->setEnabled(true); deleteTestCaseKeyAction->setEnabled(false); } else { deleteTaskKeyAction->setEnabled(false); deleteTestCaseKeyAction->setEnabled(true); } }
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); }
void IPProcessList::startDrag(Qt::DropActions) { QListWidgetItem* item = currentItem(); QMimeData* mimeData = new QMimeData; QByteArray processID; processID.append(item->toolTip()); mimeData->setData("application/x-imageplay", processID); QPixmap dragPixmap = item->icon().pixmap(32,32); QDrag *drag = new QDrag(this); drag->setMimeData(mimeData); drag->setPixmap(dragPixmap); drag->setHotSpot(QPoint(16,16)); drag->exec(Qt::MoveAction); //QListWidget::startDrag(supportedActions); }
void PopupMenuEditor::enterEditMode( QKeyEvent * e ) { PopupMenuEditorItem * i = currentItem(); if ( i == &addSeparator ) { i = createItem( new QSeparatorAction( 0 ) ); } else if ( i->isSeparator() ) { return; } else if ( currentField == 0 ) { choosePixmap(); } else if ( currentField == 1 ) { showLineEdit(); return; } else {// currentField == 2 setAccelerator( e->key(), e->state() ); } showSubMenu(); return; }
/** * Initialisation (called from constructor or manually but only * once). * * @param showByLayer true: Show attributes ByLayer, ByBlock */ void QG_WidthBox::init(bool showByLayer, bool showUnchanged) { this->showByLayer = showByLayer; this->showUnchanged = showUnchanged; if (showUnchanged) { insertItem(QPixmap(":ui/width00.png"), tr("- Unchanged -")); } if (showByLayer) { insertItem(QPixmap(":ui/width00.png"), tr("By Layer")); insertItem(QPixmap(":ui/width00.png"), tr("By Block")); } insertItem(QPixmap(":ui/width01.png"), tr("Default")); insertItem(QPixmap(":ui/width01.png"), tr("0.00mm")); insertItem(QPixmap(":ui/width01.png"), tr("0.05mm")); insertItem(QPixmap(":ui/width01.png"), tr("0.09mm")); insertItem(QPixmap(":ui/width01.png"), tr("0.13mm (ISO)")); insertItem(QPixmap(":ui/width01.png"), tr("0.15mm")); insertItem(QPixmap(":ui/width01.png"), tr("0.18mm (ISO)")); insertItem(QPixmap(":ui/width01.png"), tr("0.20mm")); insertItem(QPixmap(":ui/width01.png"), tr("0.25mm (ISO)")); insertItem(QPixmap(":ui/width01.png"), tr("0.30mm")); insertItem(QPixmap(":ui/width03.png"), tr("0.35mm (ISO)")); insertItem(QPixmap(":ui/width03.png"), tr("0.40mm")); insertItem(QPixmap(":ui/width04.png"), tr("0.50mm (ISO)")); insertItem(QPixmap(":ui/width05.png"), tr("0.53mm")); insertItem(QPixmap(":ui/width05.png"), tr("0.60mm")); insertItem(QPixmap(":ui/width06.png"), tr("0.70mm (ISO)")); insertItem(QPixmap(":ui/width07.png"), tr("0.80mm")); insertItem(QPixmap(":ui/width08.png"), tr("0.90mm")); insertItem(QPixmap(":ui/width09.png"), tr("1.00mm (ISO)")); insertItem(QPixmap(":ui/width10.png"), tr("1.06mm")); insertItem(QPixmap(":ui/width10.png"), tr("1.20mm")); insertItem(QPixmap(":ui/width12.png"), tr("1.40mm (ISO)")); insertItem(QPixmap(":ui/width12.png"), tr("1.58mm")); insertItem(QPixmap(":ui/width12.png"), tr("2.00mm (ISO)")); insertItem(QPixmap(":ui/width12.png"), tr("2.11mm")); connect(this, SIGNAL(activated(int)), this, SLOT(slotWidthChanged(int))); setCurrentItem(0); slotWidthChanged(currentItem()); }
void VSCDeviceTree::SiteDeleteClick() { QTreeWidgetItem *item = NULL; item = currentItem(); VDC_DEBUG( "%s \n",__FUNCTION__); if(item != NULL) { VSCVmsZb *pVms = dynamic_cast<VSCVmsZb * >(item); if (pVms) { VDC_DEBUG( "%s \n",__FUNCTION__); u32 nId = pVms->GetDeviceId(); emit SiteDeleteClicked(nId); } } return; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FilterListWidget::performDrag() { QListWidgetItem* item = currentItem(); if(item) { QJsonObject obj; obj[item->text()] = item->data(Qt::UserRole).toString(); QJsonDocument doc(obj); QByteArray jsonArray = doc.toJson(); QMimeData* mimeData = new QMimeData; mimeData->setData(SIMPL::DragAndDrop::FilterItem, jsonArray); QDrag* drag = new QDrag(this); drag->setMimeData(mimeData); drag->exec(Qt::CopyAction); } }
void PrinterSettings::setCurrentPrinter(Printer *printer) { mPrinter = printer; setWindowTitle(tr("Preferences of \"%1\"").arg(mPrinter->name())); ui->duplexTypeComboBox->setEnabled(printer->canChangeDuplexType()); ui->profilesList->clear(); foreach (const PrinterProfile &profile, *(mPrinter->profiles())) { ui->profilesList->addItem(new ProfileItem(profile)); } ui->profilesList->setCurrentRow(mPrinter->currentProfile()); currentItem()->setIsCurrent(true); updateWidgets(); }
QDragObject *ActionListView::dragObject() { ActionItem *i = (ActionItem*)currentItem(); if ( !i ) return 0; QStoredDrag *drag = 0; if ( i->action() ) { drag = new QStoredDrag( "application/x-designer-actions", viewport() ); QString s = QString::number( (long)i->action() ); // #### huha, that is evil drag->setEncodedData( QCString( s.latin1() ) ); drag->setPixmap( i->action()->iconSet().pixmap() ); } else { drag = new QStoredDrag( "application/x-designer-actiongroup", viewport() ); QString s = QString::number( (long)i->actionGroup() ); // #### huha, that is evil drag->setEncodedData( QCString( s.latin1() ) ); drag->setPixmap( i->actionGroup()->iconSet().pixmap() ); } return drag; }
void TrackList::contentsMousePressEvent(QMouseEvent *e) { Q3ListView::contentsMousePressEvent(e); if (e->button() == Qt::RightButton) { QWidget *tmpWidget = 0; tmpWidget = xmlGUIClient->factory()->container("tracklistpopup", xmlGUIClient); if (!tmpWidget || !tmpWidget->inherits("KPopupMenu")) { kdDebug() << "TrackList::contentsMousePressEvent => wrong container widget" << endl; return; } KMenu *menu(static_cast<KMenu*>(tmpWidget)); menu->popup(QCursor::pos()); } setSelected(currentItem(), TRUE); }
void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev) { QMenu menu; // Open current item const QModelIndex current = currentItem(); const bool hasCurrentItem = current.isValid(); QAction *actionOpen = menu.addAction(actionOpenText(m_fileSystemModel, current)); actionOpen->setEnabled(hasCurrentItem); // we need dummy DocumentModel::Entry with absolute file path in it // to get EditorManager::addNativeDirAndOpenWithActions() working Core::DocumentModel::Entry fakeEntry; Core::IDocument document; document.setFilePath(Utils::FileName::fromString(m_fileSystemModel->filePath(current))); fakeEntry.document = &document; Core::EditorManager::addNativeDirAndOpenWithActions(&menu, &fakeEntry); const bool isDirectory = hasCurrentItem && m_fileSystemModel->isDir(current); QAction *actionOpenDirectoryAsProject = 0; if (isDirectory && m_fileSystemModel->fileName(current) != QLatin1String("..")) { actionOpenDirectoryAsProject = menu.addAction(tr("Open Project in \"%1\"") .arg(m_fileSystemModel->fileName(current))); } // Open file dialog to choose a path starting from current QAction *actionChooseFolder = menu.addAction(tr("Choose Folder...")); QAction *action = menu.exec(ev->globalPos()); if (!action) return; ev->accept(); if (action == actionOpen) { // Handle open file. openItem(current); } else if (action == actionOpenDirectoryAsProject) { openItem(current, true); } else if (action == actionChooseFolder) { // Open file dialog const QString newPath = QFileDialog::getExistingDirectory(this, tr("Choose Folder"), currentDirectory()); if (!newPath.isEmpty()) setCurrentDirectory(newPath); } }
/*! \fn SnippetWidget::slotEdit() Opens the dialog of editing the selected snippet */ void SnippetWidget::slotEdit() { //get current data QListViewItem * item = currentItem(); SnippetGroup *pGroup = dynamic_cast<SnippetGroup*>(item); SnippetItem *pSnippet = dynamic_cast<SnippetItem*>( item ); if (!pSnippet || pGroup) /*selected item must be a SnippetItem but MUST not be a SnippetGroup*/ return; //init the dialog SnippetDlg dlg(this, "SnippetDlg", true); dlg.snippetName->setText(pSnippet->getName()); dlg.snippetText->setText(pSnippet->getText()); dlg.btnAdd->setText(i18n("&Apply")); dlg.setCaption(i18n("Edit Snippet")); /*fill the combobox with the names of all SnippetGroup entries*/ for (SnippetItem *it=_list.first(); it; it=_list.next()) { if (dynamic_cast<SnippetGroup*>(it)) { dlg.cbGroup->insertItem(it->getName()); } } dlg.cbGroup->setCurrentText(SnippetItem::findGroupById(pSnippet->getParent(), _list)->getName()); if (dlg.exec() == QDialog::Accepted) { //update the KListView and the SnippetItem item->setText( 0, dlg.snippetName->text() ); pSnippet->setName( dlg.snippetName->text() ); pSnippet->setText( dlg.snippetText->text() ); /* if the user changed the parent we need to move the snippet */ if ( SnippetItem::findGroupById(pSnippet->getParent(), _list)->getName() != dlg.cbGroup->currentText() ) { SnippetGroup * newGroup = dynamic_cast<SnippetGroup*>(SnippetItem::findItemByName(dlg.cbGroup->currentText(), _list)); pSnippet->parent()->takeItem(pSnippet); newGroup->insertItem(pSnippet); pSnippet->resetParent(); } setSelected(item, TRUE); } }
void JobListWidget::selectJob(JobPtr job) { if(!job) { DEBUG << "Null JobPtr passed."; return; } for(int i = 0; i < count(); ++i) { JobListWidgetItem *jobItem = static_cast<JobListWidgetItem *>(item(i)); if(jobItem && (jobItem->job()->objectKey() == job->objectKey())) { clearSelection(); setCurrentItem(jobItem); scrollToItem(currentItem(), QAbstractItemView::EnsureVisible); break; } } }
void QDoubleListWidget::contextMenuEvent(QContextMenuEvent* evt) { QMenu menu(this); QAction* addObjItem = menu.addAction(tr("Add Item")); QAction* delObjItem = menu.addAction(tr("Remove Item")); if (currentItem() == NULL) delObjItem->setEnabled(false); QAction* sel = menu.exec(evt->globalPos()); if (sel == addObjItem) { bool ok; double val = QInputDialog::getDouble(this, tr("Add Item"), tr("Enter a value"), 0.0, 0.0, 2147483647.0, 3, &ok); if (ok) addValue(val); } else if (sel == delObjItem) { delValue(currentRow()); } }
void BreakpointListView::keyPressEvent(QKeyEvent* e) { if(e->key() == Qt::Key_Delete) { BreakpointListViewItem* item = dynamic_cast<BreakpointListViewItem*>(currentItem()); if(item) { takeItem(item); emit sigBreakpointRemoved(item->breakpoint()); delete item; } } else { KListView::keyPressEvent(e); } }
void QStringListWidget::contextMenuEvent(QContextMenuEvent* evt) { QMenu menu(this); QAction* addObjItem = menu.addAction(tr("Add Item")); QAction* delObjItem = menu.addAction(tr("Remove Item")); if (currentItem() == NULL) delObjItem->setEnabled(false); QAction* sel = menu.exec(evt->globalPos()); if (sel == addObjItem) { bool ok; QString str = QInputDialog::getText(this, tr("Add Item"), tr("Enter a string"), QLineEdit::Normal, QString(), &ok); if (ok) addString(str); } else if (sel == delObjItem) { delString(currentRow()); } }
void VDirectoryTree::newSubDirectory() { if (!m_notebook) { return; } QTreeWidgetItem *curItem = currentItem(); if (!curItem) { return; } VDirectory *curDir = getVDirectory(curItem); QString info = tr("Create a subfolder in <span style=\"%1\">%2</span>.") .arg(g_config->c_dataTextStyle) .arg(curDir->getName()); QString defaultName("new_folder"); defaultName = VUtils::getDirNameWithSequence(curDir->fetchPath(), defaultName); VNewDirDialog dialog(tr("Create Folder"), info, defaultName, curDir, this); if (dialog.exec() == QDialog::Accepted) { QString name = dialog.getNameInput(); QString msg; VDirectory *subDir = curDir->createSubDirectory(name, &msg); if (!subDir) { VUtils::showMessage(QMessageBox::Warning, tr("Warning"), tr("Fail to create subfolder <span style=\"%1\">%2</span>.") .arg(g_config->c_dataTextStyle) .arg(name), msg, QMessageBox::Ok, QMessageBox::Ok, this); return; } updateItemDirectChildren(curItem); locateDirectory(subDir); } }
/** * Slot for adding a base classifier. */ void RefactoringAssistant::addBaseClassifier() { QTreeWidgetItem *item = currentItem(); if (!item) { uWarning() << "Called with no item selected"; return; } UMLObject *obj = findUMLObject(item); if (!dynamic_cast<UMLClassifier*>(obj)) { uWarning() << "Called for a non-classifier object."; return; } //classes have classes and interfaces interfaces as super/derived classifiers UMLObject::ObjectType t = obj->baseType(); UMLClassifier *super = static_cast<UMLClassifier*>(Object_Factory::createUMLObject(t)); if (!super) { return; } m_doc->createUMLAssociation(obj, super, Uml::AssociationType::Generalization); ////////////////////// Manually add the classifier to the assitant - would be nicer to do it with ///////////////////// a signal, like operations and attributes QTreeWidgetItem *baseFolder = 0; for (int i = 0; i < item->childCount(); ++i) { baseFolder = item->child(i); if (!baseFolder) { uWarning() << "Cannot find base folder!"; return; } if (baseFolder->text(0) == i18n("Base Classifiers")) { item = new QTreeWidgetItem(baseFolder, QStringList(super->name())); item->setIcon(0, Icon_Utils::SmallIcon(Icon_Utils::it_Generalisation)); item->setExpanded(true); m_umlObjectMap[item] = super; addClassifier(super, item, true, false, true); break; } } ///////////////////////// }
void ResourceView::removeResource() { ResourceItem *item = currentItem(); if ( !item ) { return; } int km = KMessageBox::warningContinueCancel( this, i18n( "<qt>Do you really want to remove the calendar <b>%1</b>?</qt>", item->text( 0 ) ), "", KStandardGuiItem::remove() ); if ( km == KMessageBox::Cancel ) { return; } // Don't be so restricitve #if 1 if ( item->resource() == mCalendar->resourceManager()->standardResource() ) { KMessageBox::sorry( this, i18n( "You cannot remove your standard calendar." ) ); return; } #endif if ( item->isSubresource() ) { if ( !item->resource()->removeSubresource( item->resourceIdentifier() ) ) { KMessageBox::sorry( this, i18n ( "<qt>Failed to remove the calendar folder <b>%1</b>. " "Perhaps it is a built-in folder which cannot be removed, or " "maybe the removal of the underlying storage folder failed.</qt>", item->text( 0 ) ) ); } return; } else { mCalendar->resourceManager()->remove( item->resource() ); delete item; } updateResourceList(); emit resourcesChanged(); }
DocPosition TemplKatalogListView::itemToDocPosition( QTreeWidgetItem *it ) { DocPosition pos; if ( ! it ) { it = currentItem(); } if ( ! it ) return pos; FloskelTemplate *flos = it->data(0, Qt::UserRole).value<FloskelTemplate*>(); if ( flos ) { pos.setText( flos->getText() ); pos.setUnit( flos->unit() ); pos.setUnitPrice( flos->unitPrice() ); } else { kDebug() << "Can not find a template for the item" << endl; } return pos; }
void KTagComboBox::keyPressEvent( QKeyEvent *e ) { int c; if ( ( e->key() == Key_F4 && e->state() == 0 ) || ( e->key() == Key_Down && (e->state() & AltButton) ) || ( e->key() == Key_Space ) ) { if ( count() ) { popup->setActiveItem( current ); popupMenu(); } return; } else { e->ignore(); return; } c = currentItem(); emit highlighted( c ); emit activated( c ); }
DocPosition TemplKatalogListView::itemToDocPosition( QTreeWidgetItem *it ) { DocPosition pos; if ( ! it ) { it = currentItem(); } if ( ! it ) return pos; FloskelTemplate *flos = static_cast<FloskelTemplate*>( m_dataDict[ it ] ); if ( flos ) { pos.setText( flos->getText() ); pos.setUnit( flos->unit() ); pos.setUnitPrice( flos->unitPrice() ); } else { // qDebug () << "Can not find a template for the item" << endl; } return pos; }