示例#1
0
void LinkDialogGraphicsScene::keyPressEvent(QKeyEvent* keyEvent) {
    if (keyEvent->key() == Qt::Key_Delete) {
        keyEvent->accept();
        QList<QGraphicsItem*> selectedGraphicsItems = selectedItems();

        for (auto& selectedGraphicsItem : selectedGraphicsItems) {
            if (auto item =
                    qgraphicsitem_cast<DialogConnectionGraphicsItem*>(selectedGraphicsItem)) {
                removePropertyLink(item);
                removePropertyLinkRepresentation(item->getPropertyLink());
            }
        }
    } else if (keyEvent->key() == Qt::Key_Escape) {
        emit closeDialog();    
    }

    QGraphicsScene::keyPressEvent(keyEvent);
}
QList<QgsComposerItem*> QgsComposition::selectedComposerItems()
{
  QList<QgsComposerItem*> composerItemList;

  QList<QGraphicsItem *> graphicsItemList = selectedItems();
  QList<QGraphicsItem *>::iterator itemIter = graphicsItemList.begin();

  for ( ; itemIter != graphicsItemList.end(); ++itemIter )
  {
    QgsComposerItem* composerItem = dynamic_cast<QgsComposerItem *>( *itemIter );
    if ( composerItem )
    {
      composerItemList.push_back( composerItem );
    }
  }

  return composerItemList;
}
示例#3
0
void KfindWindow::deleteFiles()
{
    QString tmp =
        i18n("Do you really want to delete the selected file?", "Do you really want to delete the %n selected files?", selectedItems().count());
    if(KMessageBox::warningContinueCancel(parentWidget(), tmp, "", KGuiItem(i18n("&Delete"), "editdelete")) == KMessageBox::Cancel)
        return;

    // Iterate on all selected elements
    QPtrList< QListViewItem > selected = selectedItems();
    for(uint i = 0; i < selected.count(); i++)
    {
        KfFileLVI *item = (KfFileLVI *)selected.at(i);
        KFileItem file = item->fileitem;

        KIO::NetAccess::del(file.url(), this);
    }
    selected.setAutoDelete(true);
}
void BackupListWidget::keyReleaseEvent(QKeyEvent *event)
{
    switch(event->key())
    {
    case Qt::Key_Delete:
    case Qt::Key_Backspace:
        removeItems();
        break;
    case Qt::Key_Escape:
        if(!selectedItems().isEmpty())
            clearSelection();
        else
            QListWidget::keyReleaseEvent(event);
        break;
    default:
        QListWidget::keyReleaseEvent(event);
    }
}
示例#5
0
QDragObject* K3bDataFileView::dragObject()
{
  QPtrList<QListViewItem> selectedViewItems = selectedItems();
  KURL::List urls;
  for( QPtrListIterator<QListViewItem> it( selectedViewItems ); it.current(); ++it ) {
    K3bDataViewItem* dataViewItem = dynamic_cast<K3bDataViewItem*>( it.current() );
    if( dataViewItem ) {
      urls.append( KURL::fromPathOrURL(dataViewItem->dataItem()->localPath()) );
    }
    else
      kdDebug() << "no dataviewitem" << endl;
  }

  if( urls.isEmpty() )
    return 0;

  return KURLDrag::newDrag( urls, viewport() );
}
示例#6
0
void DiagramScene::setLineColor(const QColor &color)
{
    myLineColor = color;

    //Lists of items
    QList<Arrow *> Arrows;
    QList<lineItem *> lineItems;
    foreach(QGraphicsItem *item, selectedItems()){
        if(item->type() == lineItem::Type)
            lineItems.append(qgraphicsitem_cast<lineItem *>(item));
        else if(item->type() == Arrow::Type)
            Arrows.append(qgraphicsitem_cast<Arrow *>(item));
    }

    foreach(Arrow *arrow, Arrows){
        saveUndoState();
        arrow->setColor(myLineColor);
    }
示例#7
0
void NNotebookView::renameRequested() {
    editor = new TreeWidgetEditor(this);
    connect(editor, SIGNAL(editComplete()), this, SLOT(editComplete()));
    QList<QTreeWidgetItem*> items = selectedItems();
    editor->setText(items[0]->text(NAME_POSITION));
    if (items[0]->data(NAME_POSITION, Qt::UserRole).toString() != "STACK") {
        editor->lid = items[0]->data(NAME_POSITION, Qt::UserRole).toInt();
    } else {
        editor->lid = -1;
        editor->stackName = items[0]->data(NAME_POSITION, Qt::DisplayRole).toString();
    }
    editor->setTreeWidgetItem(items[0], NAME_POSITION);
    QFontMetrics m(font());
    editor->setMinimumHeight(m.height()+4);
    editor->setMaximumHeight(m.height()+4);
    setItemWidget(items[0], NAME_POSITION, editor);
    editor->setFocus();
}
示例#8
0
void SampleList::keyPressEvent(QKeyEvent* event)
{
	auto clip = QApplication::clipboard();

	//allow copy-paste without going to edit mode of cell
	QList<QTableWidgetItem*> items = selectedItems();
	if (items.count()==1)
	{
		if(event->matches(QKeySequence::Copy))
		{
			clip->setText(items[0]->text());
			event->accept();
			return;
		}
		if(event->matches(QKeySequence::Paste))
		{
			items[0]->setText(clip->text());
			event->accept();
			return;
		}
		if(event->matches(QKeySequence::Cut))
		{
			clip->setText(items[0]->text());
			items[0]->setText("");
			event->accept();
			return;
		}
		if(event->matches(QKeySequence::Delete))
		{
			items[0]->setText("");
			event->accept();
			return;
		}
	}

	//allow pasting from Excel
	if (items.count()==0 && event->matches(QKeySequence::Paste))
	{
		appendSamplesFromText(clip->text());
	}

	//default key-press event
	QTableWidget::keyPressEvent(event);
}
示例#9
0
  std::vector<resultsviewer::ResultsViewerPlotData> TableView::generateResultsViewerPlotData()
  {
    std::vector<resultsviewer::ResultsViewerPlotData> resultsViewerPlotDataVec;
    std::vector<int> selectedRows;


    for (QTableWidgetItem *item : selectedItems())
    {
      int row = item->row();
      if ( std::find(selectedRows.begin(), selectedRows.end(), row) == selectedRows.end() )
      {
        selectedRows.push_back(row);
        resultsviewer::ResultsViewerPlotData resultsViewerPlotData = resultsViewerPlotDataFromTableItem(item);
        resultsViewerPlotDataVec.push_back(resultsViewerPlotData);
      }
    } // foreach

    return resultsViewerPlotDataVec;
  }
示例#10
0
//-----------------------------------------------------------------------------
void KMMimePartTree::saveSelectedBodyParts( bool encoded )
{
  QPtrList<QListViewItem> selected = selectedItems();

  Q_ASSERT( !selected.isEmpty() );
  if ( selected.isEmpty() )
    return;

  QPtrListIterator<QListViewItem> it( selected );
  QPtrList<partNode> parts;
  while ( it.current() ) {
    parts.append( static_cast<KMMimePartTreeItem *>(it.current())->node() );
    ++it;
  }
  mReaderWin->setUpdateAttachment();
  KMSaveAttachmentsCommand *command =
    new KMSaveAttachmentsCommand( this, parts, mReaderWin->message(), encoded );
  command->start();
}
示例#11
0
文件: patchscene.cpp 项目: 87maxi/oom
void PatchScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
    if (fake_selection)
    {
        QList<QGraphicsItem*> items_list = items();
        if (items_list.count() > 0)
        {
            for (int i=0; i < items_list.count(); i++)
            {
                if (items_list[i]->isVisible() && items_list[i]->type() == CanvasBoxType)
                {
                    QRectF item_rect = items_list[i]->sceneBoundingRect();
                    if ( fake_rubberband->contains(QPointF(item_rect.x(), item_rect.y())) &&
                         fake_rubberband->contains(QPointF(item_rect.x()+item_rect.width(), item_rect.y()+item_rect.height())) )
                        items_list[i]->setSelected(true);
                }
            }

            fake_rubberband->hide();
            fake_rubberband->setRect(0, 0, 0, 0);
            fake_selection = false;
        }
    }
    else
    {
        QList<QGraphicsItem*> items_list = selectedItems();

        for (int i=0; i < items_list.count(); i++)
        {
            if (items_list[i]->isVisible() && items_list[i]->type() == CanvasBoxType)
            {
                CanvasBox* cbox = (CanvasBox*)items_list[i];
                cbox->checkItemPos();
                //emit(SIGNAL(sceneGroupMoved(int, PortMode, QPointF)), cbox->getGroupId(), cbox->getSplittedMode(), cbox->scenePos());
            }
        }
    }

    mouse_down_init = false;
    mouse_rubberband = false;
    QGraphicsScene::mouseReleaseEvent(event);
}
示例#12
0
// Delete an item from the tree.  We really just hide it.
void NTagView::mergeRequested() {
    QList<QTreeWidgetItem*> items = selectedItems();

    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Question);
    msgBox.setText(tr("Are you sure you want to merge these tags?"));
    msgBox.setWindowTitle(tr("Verify Merge"));
    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    msgBox.setDefaultButton(QMessageBox::No);
    int ret = msgBox.exec();
    if (ret == QMessageBox::No)
        return;

    qint32 lid = items[0]->data(NAME_POSITION, Qt::UserRole).toInt();
    NoteTable ntable(global.db);
    QList<qint32> notes;
    for (int j=1; j<items.size(); j++) {
        ntable.findNotesByTag(notes, items[j]->data(NAME_POSITION, Qt::UserRole).toInt());
        for (int i=0; i<notes.size(); i++) {
            if (!ntable.hasTag(notes[i], lid)) {
                ntable.addTag(notes[i], lid, true);
                QString tagString = ntable.getNoteListTags(notes[i]);
                emit(updateNoteList(notes[i], NOTE_TABLE_TAGS_POSITION, tagString));
//                qint64 dt = QDateTime::currentMSecsSinceEpoch();
//                ntable.updateDate(notes[i],  dt, NOTE_UPDATED_DATE, true);
//                emit(updateNoteList(notes[i], NOTE_TABLE_DATE_UPDATED_POSITION, dt));
            }
        }
    }

    // Now delete the old tags.
    for (int i=1; i<items.size(); i++) {
        qint32 lid = items[i]->data(NAME_POSITION, Qt::UserRole).toInt();
        TagTable table(global.db);
        table.deleteTag(lid);

        // Now remove it in the datastore
        NTagViewItem *ptr = dataStore.take(items[i]->data(NAME_POSITION, Qt::UserRole).toInt());
        emit(tagDeleted(lid, ptr->data(NAME_POSITION, Qt::DisplayRole).toString()));
        delete ptr;
    }
}
bool GridSceneCombinationLock::selectNextGridShape()
{
    auto shapes = getSelectedGridShapes();

    if(shapes.size() != 1)
    {
        return false;
    }

    auto current = shapes.at(0)->getItem().getCoordinate();
    VectorMath::Vec3i next(0, 0, 0);
    auto state = getCrosswordInterface();

    switch(m_TypingDirection)
    {
    case DIAMETRIC:
        next = state->getNextCoordinateForDirection(Crossword::Formats::Direction::DIAMETRIC, current);
        break;
    case ANTICLOCKWISE:
        next = state->getNextCoordinateForDirection(Crossword::Formats::Direction::ANTICLOCKWISE, current);
        break;
    case CLOCKWISE:
        // Since (0,0) is at the upper left of a grid, pressing "towards" the front of the puzzle actually goes "down" the page
        next = state->getNextCoordinateForDirection(Crossword::Formats::Direction::CLOCKWISE, current);
        break;
    case UP:
        next = state->getNextCoordinateForDirection(Crossword::Formats::Direction::UP, current);
        break;
    case DOWN:
        next = state->getNextCoordinateForDirection(Crossword::Formats::Direction::DOWN, current);
        break;
    }

    auto shape = getGridShapeForCoordinate(next);

    beginCommandMacro("Select next grid shape");
    addCommand(new ClearSelectionCommand(selectedItems()));
    addCommand(new SelectItemCommand(shape));
    endCommandMacro();

    return true;
}
示例#14
0
/**
	Exporte le schema vers une image
	@return Une QImage representant le schema
*/
bool Diagram::toPaintDevice(QPaintDevice &pix, int width, int height, Qt::AspectRatioMode aspectRatioMode) {
	// determine la zone source =  contenu du schema + marges
	QRectF source_area;
	if (!use_border_) {
		source_area = itemsBoundingRect();
		source_area.translate(-margin, -margin);
		source_area.setWidth (source_area.width () + 2.0 * margin);
		source_area.setHeight(source_area.height() + 2.0 * margin);
	} else {
		source_area = QRectF(
			0.0,
			0.0,
			border_and_titleblock.borderWidth () + 2.0 * margin,
			border_and_titleblock.borderHeight() + 2.0 * margin
		);
	}
	
	// si les dimensions ne sont pas precisees, l'image est exportee a l'echelle 1:1
	QSize image_size = (width == -1 && height == -1) ? source_area.size().toSize() : QSize(width, height);
	
	// prepare le rendu
	QPainter p;
	if (!p.begin(&pix)) return(false);
	
	// rendu antialiase
	p.setRenderHint(QPainter::Antialiasing, true);
	p.setRenderHint(QPainter::TextAntialiasing, true);
	p.setRenderHint(QPainter::SmoothPixmapTransform, true);
	
	// deselectionne tous les elements
	QList<QGraphicsItem *> selected_elmts = selectedItems();
	foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(false);
	
	// effectue le rendu lui-meme
	render(&p, QRect(QPoint(0, 0), image_size), source_area, aspectRatioMode);
	p.end();
	
	// restaure les elements selectionnes
	foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(true);
	
	return(true);
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void FilterLibraryTreeWidget::dropEvent(QDropEvent* event)
{
    QList<QTreeWidgetItem*> parents = selectedItems();

    if (parents.size() == 1)
    {
        QTreeWidgetItem* parent = parents[0];
        if (parent->flags().testFlag(Qt::ItemIsDropEnabled) == true && parent != m_ItemBeingDragged)
        {
            if (NULL != m_TopLevelItemPlaceholder)
            {
                parent = invisibleRootItem();
                delete m_TopLevelItemPlaceholder;
                m_TopLevelItemPlaceholder = NULL;
            }

            // Get information needed
            QString title = m_ItemBeingDragged->data(0, Qt::UserRole).toString();
            QString path = m_ItemBeingDragged->data(1, Qt::UserRole).toString();
            bool isExpanding = m_ItemBeingDragged->isExpanded();
            FilterLibraryTreeWidget::ItemType type = FilterLibraryTreeWidget::ItemType(m_ItemBeingDragged->type());

            // Remove the old tree widget item
            delete m_ItemBeingDragged;

            QIcon icon;
            // If the dragged item is a folder
            if (type == FilterLibraryTreeWidget::Node_Item_Type)
            {
                icon = QIcon(":/folder_blue.png");
            }
            // The dragged item is a pipeline
            else
            {
                icon = QIcon(":/text.png");
            }

            emit itemWasDropped(parent, title, icon, type, path, true, false, isExpanding);
            parent->setExpanded(true);
        }
    }
}
示例#16
0
void TTreeWidget::dropEvent(QDropEvent *event)
{
    QTreeWidgetItem * pItem = itemAt( event->pos() );

    if( ! pItem )
    {
        event->setDropAction( Qt::IgnoreAction );
        event->ignore();
    }

    if( pItem == topLevelItem(0) )
    {
        if( (dropIndicatorPosition() == QAbstractItemView::AboveItem )
         || (dropIndicatorPosition() == QAbstractItemView::BelowItem ) )
        {
            event->setDropAction( Qt::IgnoreAction );
            event->ignore();
        }
    }

    if ( mIsVarTree )
    {
        LuaInterface * lI = mpHost->getLuaInterface();        
        if ( ! lI->validMove( pItem ) )
        {
            event->setDropAction( Qt::IgnoreAction );
            event->ignore();
        }
        QTreeWidgetItem * newpItem = pItem;
        QTreeWidgetItem * cItem = selectedItems().first();
        QTreeWidgetItem * oldpItem = cItem->parent();
        if ( ! lI->reparentVariable( newpItem, cItem, oldpItem ) )
        {
            qDebug()<<"reparent failed";
            event->setDropAction( Qt::IgnoreAction );
            event->ignore();
        }
    }
    mIsDropAction = true;
    QTreeWidget::dropEvent( event );
    return;
}
void UBDocumentThumbnailWidget::mouseMoveEvent(QMouseEvent *event)
{
    if (!dragEnabled())
    {
        event->ignore();
        return;
    }

    if (!(event->buttons() & Qt::LeftButton))
        return;

    if ((event->pos() - mMousePressPos).manhattanLength()
             < QApplication::startDragDistance())
             return;

    QList<QGraphicsItem*> graphicsItems = items(mMousePressPos);

    UBSceneThumbnailPixmap* sceneItem = 0;

    while (!graphicsItems.isEmpty() && !sceneItem)
    {
        sceneItem = dynamic_cast<UBSceneThumbnailPixmap*>(graphicsItems.takeFirst());
    }

    if (sceneItem)
    {
        QDrag *drag = new QDrag(this);
        QList<UBMimeDataItem> mimeDataItems;
        foreach (QGraphicsItem *item, selectedItems())
            mimeDataItems.append(UBMimeDataItem(sceneItem->proxy(), mGraphicItems.indexOf(item)));
        UBMimeData *mime = new UBMimeData(mimeDataItems);
        drag->setMimeData(mime);

        drag->setPixmap(sceneItem->pixmap().scaledToWidth(100));
        drag->setHotSpot(QPoint(drag->pixmap().width()/2,
                                     drag->pixmap().height() / 2));

        drag->exec(Qt::MoveAction);
    }

    UBThumbnailWidget::mouseMoveEvent(event);
}
示例#18
0
        void startDrag(Qt::DropActions supportedDropActions)
        {
            QList<QListWidgetItem *> items = selectedItems();
            int count = items.size();
            if (count < 1 || !m_pictureService)
                return;

            // make the drag pixmap and the indices data
            QStringList indices;
            QPixmap dragPixmap(50 + 10 * (count - 1), 50 + 10 * (count - 1));
            dragPixmap.fill(Qt::transparent);
            QPainter dragPainter(&dragPixmap);
            int i = 0;
            foreach (QListWidgetItem * item, items) {
                int idx = row(item);
                m_pictureService->startPrefetch(idx);
                dragPainter.drawPixmap(i * 10, i * 10, item->icon().pixmap(50, 50));
                indices.append(QString::number(idx));
                i++;
            }
示例#19
0
void K3bDataFileView::slotProperties()
{
  K3bDataItem* dataItem = 0;

  // get selected item
  if( K3bDataViewItem* viewItem = dynamic_cast<K3bDataViewItem*>( selectedItems().first() ) ) {
    dataItem = viewItem->dataItem();
  }
  else {
    // default to current dir
    dataItem = currentDir();
  }

  if( dataItem ) {
    K3bDataPropertiesDialog d( dataItem, this );
    d.exec();
  }
  else
    m_view->slotProperties();
}
示例#20
0
void K3bDataFileView::slotOpen()
{
  if( K3bDataViewItem* viewItem = dynamic_cast<K3bDataViewItem*>( selectedItems().first() ) ) {
    K3bDataItem* item = viewItem->dataItem();
    if( item->isFile() ) {
      K3bDataFileViewItem* fvi = static_cast<K3bDataFileViewItem*>( viewItem );
      if( fvi->mimeType() &&
#if KDE_IS_VERSION(3,3,0)
	  !KRun::isExecutableFile( KURL::fromPathOrURL(item->localPath()), 
				   fvi->mimeType()->name() )
#else
	  !QFileInfo( item->localPath() ).isExecutable()
#endif
	  )
	KRun::runURL( KURL::fromPathOrURL(item->localPath()), 
		      fvi->mimeType()->name() );
      else
	KRun::displayOpenWithDialog( KURL::fromPathOrURL(item->localPath()) );
    }
  }
}
示例#21
0
void NNotebookView::deleteRequested() {
    QList<QTreeWidgetItem*> items = selectedItems();

    qint32 lid = items[0]->data(NAME_POSITION, Qt::UserRole).toInt();
    if (global.confirmDeletes()) {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Question);
        msgBox.setText(tr("Are you sure you want to delete this notebook?"));
        msgBox.setWindowTitle(tr("Verify Delete"));
        msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
        msgBox.setDefaultButton(QMessageBox::No);
        int ret = msgBox.exec();
        if (ret == QMessageBox::No)
            return;
    }
    NotebookTable table(global.db);
    table.deleteNotebook(lid);
    items[0]->setHidden(true);
    dataStore.remove(lid);
    emit(notebookDeleted(lid, items[0]->data(NAME_POSITION, Qt::UserRole).toString()));
}
/**
 * @brief ChordTableWidget::delete_selected_row
 *
 * Supprime les lignes dont les cases sélectionnées sont membres.
 */
void ChordTableWidget::deleteSelectedRow() {

	QList<QTableWidgetItem*> listItems = selectedItems();
	//Suppression des doublons
	for(int i=0; i<listItems.size(); i++) {
		for(int j=i+1; j<listItems.size(); j++) {
			if(listItems.value(i)->row() == listItems.value(j)->row()) {
				listItems.removeAt(j);
				j--;
			}
		}
	}

	if(listItems.count() == 1) {
		removeRow(listItems.first()->row());
	}
	else if(listItems.count() > 1)
	{
		QString listRow;
		listRow.append(tr("Are you sure you want to delete lines "));

		for(QList<QTableWidgetItem*>::Iterator i = listItems.begin(); i != listItems.end() ; i++) {
			listRow.append(QString::number((**i).row()+1));
			listRow.append(", ");
		}
		listRow.remove(listRow.length()-2, 1);
		listRow.append("?");

		int answer = QMessageBox::question(this, tr("Deleting lines"), listRow, QMessageBox::Yes | QMessageBox::No);

		if(answer == QMessageBox::Yes) {
			for(QList<QTableWidgetItem*>::Iterator i = listItems.begin(); i != listItems.end() ; i++) {
				if(rowCount() > 1) {
					removeRow((**i).row());
				}
			}
		}
	}
	emit somethingChanged();
}
示例#23
0
//*************************************************************
// This function is called from the main NixNote class.
// it will reset the items which are selected based upon
// what the user did somewhere else (outside this widget).
//*************************************************************
void NNotebookView::updateSelection() {
    blockSignals(true);

    FilterCriteria *criteria = global.filterCriteria[global.filterPosition];
    if (global.filterPosition != filterPosition) {
        QList<QTreeWidgetItem*> selectedItems = this->selectedItems();
        for (int i=0; i<selectedItems.size() && criteria->resetNotebook; i++) {
            selectedItems[i]->setSelected(false);
        }


        if (criteria->isNotebookSet()) {
            criteria->getNotebook()->setSelected(true);
        }
    }
    filterPosition = global.filterPosition;

    if (selectedItems().size() == 0)
        root->setSelected(false);

    blockSignals(false);
}
void KReportDesignerSectionScene::mousePressEvent(QGraphicsSceneMouseEvent * e)
{
    // clear the selection if Shift Key has not been pressed and it's a left mouse button   and
    // if the right mouse button has been pressed over an item which is not part of selected items
    if (((e->modifiers() & Qt::ShiftModifier) == 0 && e->button() == Qt::LeftButton)   ||
            (!(selectedItems().contains(itemAt(e->scenePos(), QTransform()))) && e->button() == Qt::RightButton))
        clearSelection();

    //This will be caught by the section to display its properties, if an item is under the cursor then they will display their properties
    QGraphicsItem* itemUnderCursor = itemAt(e->scenePos(), QTransform());
    if (!itemUnderCursor) {
        emit clicked();
    }

    KReportDesignerItemRectBase *rectUnderCursor = qgraphicsitem_cast< KReportDesignerItemRectBase* >(itemUnderCursor);
    if (itemUnderCursor && !rectUnderCursor) {
        rectUnderCursor = qgraphicsitem_cast< KReportDesignerItemRectBase* >(itemUnderCursor->parentItem());
    }
    exitInlineEditingModeInItems(rectUnderCursor);

    QGraphicsScene::mousePressEvent(e);
}
示例#25
0
// Display the properties dialog
void NTagView::propertiesRequested() {
    TagProperties dialog;
    QList<QTreeWidgetItem*> items = selectedItems();

    qint32 lid = items[0]->data(NAME_POSITION, Qt::UserRole).toInt();
    QString oldName = items[0]->data(NAME_POSITION, Qt::DisplayRole).toString();
    dialog.setLid(lid);

    dialog.exec();
    if (!dialog.okPressed)
        return;

    QString newName = dialog.name.text().trimmed();
    if (newName != oldName) {
        items[0]->setData(NAME_POSITION, Qt::DisplayRole, dialog.name.text().trimmed());

        this->sortItems(NAME_POSITION, Qt::AscendingOrder);
        resetSize();
        this->sortByColumn(NAME_POSITION);
        emit(tagRenamed(lid, oldName, newName));
    }
}
示例#26
0
void GraphBase::SearchNextLayer()
{
    for (QGraphicsItem *selectedNode:selectedItems())
    {
        NodeBase * node = qgraphicsitem_cast<NodeBase *>(selectedNode);
        for (EdgeBase *edge: node->mConnectedEdges)
        {
            int *index = edge->GetNodeIndex();
            int other = (index[0] == node->mNodeIndex) ? index[1] : index[0];
            if (!mNodes[other]->isVisible())
            {
                mNodes[other]->setEnabled(true);
                mNodes[other]->setVisible(true);
                NodeVisibleChangeFeedBack(mNodes[other]);
            }
            if (!mNodes[other]->isSelected())
            {
                mNodes[other]->setSelected(true);
            }
        }
    }
}
void ObjectInspectorTable::dropEvent(QDropEvent *event) {
    if ( event->source() == this ) {

        QTreeWidgetItem *target = itemAt(event->pos());

        if ( target ) {
            if ( m_objectMap[target] ) { // on est pas sur un layout !
                target = target->parent();
            }

            foreach (QTreeWidgetItem *it, selectedItems()) {

                if ( m_objectMap[it] ) { // on est pas sur un layout !

                    // re retrouve le layout source
                    QTreeWidgetItem *source = it;
                    if ( m_objectMap[source] ) { // on est pas sur un layout !
                        source = source->parent();
                    }

                    // source != target ?
                    if (source != target) {
                        source->removeChild(it);
                        target->addChild(it);
                        m_objectMap[it]->setZValue(-indexOfTopLevelItem(target) - 1);
                        Log::d("ObjectInspectorTable") << "dropEvent, zIndex = " << -indexOfTopLevelItem(target) - 1;
                        m_objectMap[it]->setVisible( target->checkState(0) == Qt::Checked );
                        target->setExpanded(true);
                    } else {
                        Log::w("ObjectInspectorTable") << "drop event, source == target";
                    }
                }
            }

            Log::d("ObjectInspectorTable") << "drop event, target = " << target->data(0, Qt::DisplayRole).toString();
        }

        event->accept();
    } else { // mauvais format mine
示例#28
0
void EntityAndAssetTreeWidget::keyPressEvent(QKeyEvent *event)
{
    switch (event->key())
    {
        case Qt::Key_Space:
        {
            event->accept();
            SelectedItemsList selected = selectedItems();
            if (selected.isEmpty())
                return;

            Qt::CheckState checkedState;
            bool isMixedSelection = false;

            if (selected.size() == 1)
                selected.at(0)->setCheckState(0, (Qt::CheckState)(Qt::Checked - selected.at(0)->checkState(0)));
            else
            {
                checkedState = selected.at(0)->checkState(0);
                for (SelectedItemsList::const_iterator i = selected.constBegin() + 1; i != selected.constEnd(); ++i)
                    if ((*i)->checkState(0) != checkedState)
                    {
                        isMixedSelection = true;
                        break;
                    }

                ToggleCheckedState(isMixedSelection);
            }

            break;
        }
        default:
        {
            QTreeWidget::keyPressEvent(event);
            break;
        }
    }
}
示例#29
0
void KfindWindow::slotContextMenu(KListView *, QListViewItem *item, const QPoint &p)
{
    if(!item)
        return;
    int count = selectedItems().count();

    if(count == 0)
    {
        return;
    };

    if(m_menu == 0)
        m_menu = new KPopupMenu(this);
    else
        m_menu->clear();

    if(count == 1)
    {
        // menu = new KPopupMenu(item->text(0), this);
        m_menu->insertTitle(item->text(0));
        m_menu->insertItem(SmallIcon("fileopen"), i18n("Menu item", "Open"), this, SLOT(openBinding()));
        m_menu->insertItem(SmallIcon("window_new"), i18n("Open Folder"), this, SLOT(openFolder()));
        m_menu->insertSeparator();
        m_menu->insertItem(SmallIcon("editcopy"), i18n("Copy"), this, SLOT(copySelection()));
        m_menu->insertItem(SmallIcon("editdelete"), i18n("Delete"), this, SLOT(deleteFiles()));
        m_menu->insertSeparator();
        m_menu->insertItem(i18n("Open With..."), this, SLOT(slotOpenWith()));
        m_menu->insertSeparator();
        m_menu->insertItem(i18n("Properties"), this, SLOT(fileProperties()));
    }
    else
    {
        m_menu->insertTitle(i18n("Selected Files"));
        m_menu->insertItem(SmallIcon("editcopy"), i18n("Copy"), this, SLOT(copySelection()));
        m_menu->insertItem(SmallIcon("editdelete"), i18n("Delete"), this, SLOT(deleteFiles()));
    }
    m_menu->popup(p, 1);
}
示例#30
0
void
QueueList::moveSelectedUp() // SLOT
{
    QPtrList<QListViewItem> selected = selectedItems();

    // Whilst it would be substantially faster to do this: ((*it)->itemAbove())->move( *it ),
    // this would only work for sequentially ordered items
    for( QListViewItem *item = selected.first(); item; item = selected.next() )
    {
        if( item == itemAtIndex(0) )
            continue;

        QListViewItem *after;

        item == itemAtIndex(1) ?
        after = 0:
                after = ( item->itemAbove() )->itemAbove();

        moveItem( item, 0, after );
    }

    ensureItemVisible( selected.first() );
}