コード例 #1
0
void MList::selectItem(const QModelIndex &index)
{
    QItemSelectionModel *sModel = selectionModel();

    if (index.isValid() && sModel->model() != index.model()) {
        qWarning("MList::selectItem() failed: "
                 "Trying to select an item that is for"
                 " a different model than the view ");
        return;
    }

    if (sModel != NULL) {
        if (selectionMode() == MList::MultiSelection) {
            if (sModel->isSelected(index)) {
                sModel->select(index, QItemSelectionModel::Deselect);
            } else {
                sModel->select(index, QItemSelectionModel::Select);
            }
        } else if (selectionMode() == MList::SingleSelection) {
            sModel->select(index, QItemSelectionModel::ClearAndSelect);
        }
    }

    emit itemClicked(index);
}
コード例 #2
0
void
PartitionLabelsView::drawLabels( QPainter* painter,
                                 const QRect& rect,
                                 const QModelIndex& parent )
{
    PartitionModel* modl = qobject_cast< PartitionModel* >( model() );
    if ( !modl )
        return;

    QModelIndexList indexesToDraw = getIndexesToDraw( parent );

    int label_x = rect.x();
    int label_y = rect.y();
    foreach ( const QModelIndex& index, indexesToDraw )
    {
        QStringList texts = buildTexts( index );

        QSize labelSize = sizeForLabel( texts );

        QColor labelColor = index.data( Qt::DecorationRole ).value< QColor >();

        if ( label_x + labelSize.width() > rect.width() ) //wrap to new line if overflow
        {
            label_x = rect.x();
            label_y += labelSize.height() + labelSize.height() / 4;
        }

        // Draw hover
        if ( selectionMode() != QAbstractItemView::NoSelection && // no hover without selection
             m_hoveredIndex.isValid() &&
             index == m_hoveredIndex )
        {
            painter->save();
            QRect labelRect( QPoint( label_x, label_y ), labelSize );
            labelRect.adjust( 0, -LAYOUT_MARGIN, 0, -2*LAYOUT_MARGIN );
            painter->translate( 0.5, 0.5 );
            QRect hoverRect = labelRect.adjusted( 0, 0, -1, -1 );
            painter->setBrush( QPalette().background().color().lighter( 102 ) );
            painter->setPen( Qt::NoPen );
            painter->drawRoundedRect( hoverRect, CORNER_RADIUS, CORNER_RADIUS );

            painter->translate( -0.5, -0.5 );
            painter->restore();
        }

        // Is this element the selected one?
        bool sel = selectionMode() != QAbstractItemView::NoSelection &&
                   index.isValid() &&
                   selectionModel() &&
                   !selectionModel()->selectedIndexes().isEmpty() &&
                   selectionModel()->selectedIndexes().first() == index;

        drawLabel( painter, texts, labelColor, QPoint( label_x, label_y ), sel );

        label_x += labelSize.width() + LABELS_MARGIN;
    }
コード例 #3
0
void toListView::displayMenu(const QPoint &pos)
{
    toTreeWidgetItem *item = itemAt(pos);

    if (!item)
        return;

    if (!Menu)
    {
        Menu = new QMenu(this);
        displayAct = Menu->addAction(tr("Display in editor..."));

        QMenu *just = new QMenu(tr("Alignment"), this);
        leftAct   = just->addAction(tr("Left"));
        centerAct = just->addAction(tr("Center"));
        rightAct  = just->addAction(tr("Right"));
        connect(just,
                SIGNAL(triggered(QAction *)),
                this,
                SLOT(menuCallback(QAction *)));

        Menu->addSeparator();

        copyAct = Menu->addAction(tr("&Copy field"));
//        if (selectionMode() == Multi || selectionMode() == Extended)
//        {
//            copySelAct  = Menu->addAction(tr("Copy selection"));
//            copyHeadAct = Menu->addAction(tr("Copy selection with header"));
//        }
        copyTransAct = Menu->addAction(tr("Copy transposed"));
        if (selectionMode() == Multi || selectionMode() == Extended)
        {
            Menu->addSeparator();
            selectAllAct = Menu->addAction(tr("Select all"));
        }

        Menu->addSeparator();

        exportAct = Menu->addAction(tr("Export to file..."));
        if (!Name.isEmpty())
        {
            Menu->addSeparator();
            editAct = Menu->addAction(tr("Edit SQL..."));
        }

        connect(Menu,
                SIGNAL(triggered(QAction *)),
                this,
                SLOT(menuCallback(QAction *)));
        addMenues(Menu);
        emit displayMenu(Menu);
    }
コード例 #4
0
QString ChatItem::selection() const
{
    if (selectionMode() == FullSelection)
        return data(MessageModel::DisplayRole).toString();
    if (selectionMode() == PartialSelection) {
        int start = qMin(selectionStart(), selectionEnd());
        int end   = start + qAbs(selectionStart() - selectionEnd());

        QTextCursor cSelect(document());
        cSelect.setPosition(start);
        cSelect.setPosition(end, QTextCursor::KeepAnchor);
        return cSelect.selectedText();
    }
    return QString();
}
コード例 #5
0
ファイル: rdlistview.cpp プロジェクト: WMTH/rivendell
void RDListView::mouseButtonClickedData(int button,QListViewItem *item,
					const QPoint &pt,int col)
{
  QListViewItem *l;
  bool contiguous;

  if((selectionMode()!=QListView::Extended)||(item==NULL)||(button!=1)) {
    return;
  }

  //
  // Get Selected Range
  //
  l=item;
  contiguous=true;
  while((l=l->itemAbove())!=NULL) {
    if(!l->isSelected()) {
      contiguous=false;
    }
    if(!contiguous) {
      setSelected(l,false);
    }
  }
  l=item;
  contiguous=true;
  while((l=l->itemBelow())!=NULL) {
    if(!l->isSelected()) {
      contiguous=false;
    }
    if(!contiguous) {
      setSelected(l,false);
    }
  }
}
コード例 #6
0
ファイル: kcolordialog.cpp プロジェクト: Geekking/lima
void KColorCells::mouseReleaseEvent(QMouseEvent *e)
{
    if (selectionMode() != QAbstractItemView::NoSelection) {
        int cell = positionToCell(d->mousePos);
        int currentCell = positionToCell(e->pos());

        // If we release the mouse in another cell and we don't have
        // a drag we should ignore this event.
        if (currentCell != cell)
            cell = -1;

        if ((cell != -1) && (d->selected != cell)) {
            d->selected = cell;

            const int newRow = cell / columnCount();
            const int newColumn = cell % columnCount();

            clearSelection(); // we do not want old violet selected cells

            item(newRow, newColumn)->setSelected(true);
        }

        d->inMouse = false;
        if (cell != -1)
            emit colorSelected(cell , color(cell));
    }

    QTableWidget::mouseReleaseEvent(e);
}
コード例 #7
0
ファイル: qgsfeaturelistview.cpp プロジェクト: dmarteau/QGIS
void QgsFeatureListView::selectRow( const QModelIndex &index, bool anchor )
{
  QItemSelectionModel::SelectionFlags command = selectionCommand( index );
  int row = index.row();

  if ( anchor )
    mRowAnchor = row;

  if ( selectionMode() != QListView::SingleSelection
       && command.testFlag( QItemSelectionModel::Toggle ) )
  {
    if ( anchor )
      mCtrlDragSelectionFlag = mFeatureSelectionModel->isSelected( index )
                               ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
    command &= ~QItemSelectionModel::Toggle;
    command |= mCtrlDragSelectionFlag;
    if ( !anchor )
      command |= QItemSelectionModel::Current;
  }

  QModelIndex tl = model()->index( std::min( mRowAnchor, row ), 0 );
  QModelIndex br = model()->index( std::max( mRowAnchor, row ), model()->columnCount() - 1 );

  mFeatureSelectionModel->selectFeatures( QItemSelection( tl, br ), command );
}
コード例 #8
0
void KisSelectionToolConfigWidgetHelper::createOptionWidget(KisCanvas2 *canvas, const QString &toolId)
{
    m_optionsWidget = new KisSelectionOptions(canvas);
    Q_CHECK_PTR(m_optionsWidget);

    // slotCanvasResourceChanged... yuck
    m_resourceProvider = canvas->viewManager()->resourceProvider();
    // connect(m_resourceProvider->resourceManager(), &KisCanvasResourceManager::canvasResourceChanged,
    //         this, KisSelectionToolConfigWidgetHelper::slotCanvasResourceChanged);

    m_optionsWidget->setObjectName(toolId + "option widget");
    m_optionsWidget->setWindowTitle(m_windowTitle);
    m_optionsWidget->setAction(selectionAction());
    m_optionsWidget->setMode(selectionMode());

    // See https://bugs.kde.org/show_bug.cgi?id=316896
    QWidget *specialSpacer = new QWidget(m_optionsWidget);
    specialSpacer->setObjectName("SpecialSpacer");
    specialSpacer->setFixedSize(0, 0);
    m_optionsWidget->layout()->addWidget(specialSpacer);

    connect(m_optionsWidget, &KisSelectionOptions::actionChanged,
            this, &KisSelectionToolConfigWidgetHelper::slotWidgetActionChanged);
    connect(m_optionsWidget, &KisSelectionOptions::modeChanged,
            this, &KisSelectionToolConfigWidgetHelper::slotWidgetModeChanged);
    connect(m_resourceProvider, &KisCanvasResourceProvider::sigSelectionActionChanged,
            this, &KisSelectionToolConfigWidgetHelper::slotGlobalActionChanged);
    connect(m_resourceProvider, &KisCanvasResourceProvider::sigSelectionModeChanged,
            this, &KisSelectionToolConfigWidgetHelper::slotGlobalModeChanged);

    m_optionsWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    m_optionsWidget->adjustSize();
}
コード例 #9
0
QAbstractTextDocumentLayout::Selection ChatItem::selectionLayout() const
{
        QAbstractTextDocumentLayout::Selection selection;

        if (!hasSelection())
            return selection;

        int start;
        int end;

        if (selectionMode() == FullSelection) {
            start = 0;
            end = document()->characterCount()-1;
        }
        else {
            start = selectionStart();
            end   = selectionEnd();
        }

        QTextCursor c(document());
        c.setPosition(start);
        c.setPosition(end, QTextCursor::KeepAnchor);
        selection.cursor = c;

        return selection;
}
コード例 #10
0
    QMimeData *mimeData()
    {
      // create a list of the URL:s that we want to drag
      KUrl::List urls;
      QStringList labels;
      for ( Q3IconViewItem *it = firstItem(); it; it = it->nextItem() ) {
        if ( it->isSelected() ) {
          AttachmentIconItem *item = static_cast<AttachmentIconItem *>( it );
          if ( item->isBinary() ) {
            urls.append( tempFileForAttachment( item->attachment() ) );
          } else {
            urls.append( item->uri() );
          }
          labels.append( KUrl::toPercentEncoding( item->label() ) );
        }
      }
      if ( selectionMode() == Q3IconView::NoSelection ) {
        AttachmentIconItem *item = static_cast<AttachmentIconItem *>( currentItem() );
        if ( item ) {
          urls.append( item->uri() );
          labels.append( KUrl::toPercentEncoding( item->label() ) );
        }
      }

      QMap<QString, QString> metadata;
      metadata["labels"] = labels.join( ":" );

      QMimeData *mimeData = new QMimeData;
      urls.populateMimeData( mimeData, metadata );
      return mimeData;
    }
コード例 #11
0
UserInputValidator &IndirectSpectrumSelectionView::validateSpectraString(
    UserInputValidator &uiv) const {
  if (selectionMode() == SpectrumSelectionMode::STRING)
    uiv.checkFieldIsValid("Spectra", m_selector->leSpectra,
                          m_selector->lbSpectraError);
  return uiv;
}
コード例 #12
0
void TimelineSelectionTool::mousePressEvent(TimelineMovableAbstractItem *item,
                                            QGraphicsSceneMouseEvent *event)
{
    Q_UNUSED(item);
    Q_UNUSED(event);

    if (event->buttons() == Qt::LeftButton && selectionMode(event) == SelectionMode::New)
        deselect();
}
コード例 #13
0
int Q3Table::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = Q3ScrollView::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 58)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 58;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = numRows(); break;
        case 1: *reinterpret_cast< int*>(_v) = numCols(); break;
        case 2: *reinterpret_cast< bool*>(_v) = showGrid(); break;
        case 3: *reinterpret_cast< bool*>(_v) = rowMovingEnabled(); break;
        case 4: *reinterpret_cast< bool*>(_v) = columnMovingEnabled(); break;
        case 5: *reinterpret_cast< bool*>(_v) = isReadOnly(); break;
        case 6: *reinterpret_cast< bool*>(_v) = sorting(); break;
        case 7: *reinterpret_cast< SelectionMode*>(_v) = selectionMode(); break;
        case 8: *reinterpret_cast< FocusStyle*>(_v) = focusStyle(); break;
        case 9: *reinterpret_cast< int*>(_v) = numSelections(); break;
        }
        _id -= 10;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setNumRows(*reinterpret_cast< int*>(_v)); break;
        case 1: setNumCols(*reinterpret_cast< int*>(_v)); break;
        case 2: setShowGrid(*reinterpret_cast< bool*>(_v)); break;
        case 3: setRowMovingEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 4: setColumnMovingEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 5: setReadOnly(*reinterpret_cast< bool*>(_v)); break;
        case 6: setSorting(*reinterpret_cast< bool*>(_v)); break;
        case 7: setSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break;
        case 8: setFocusStyle(*reinterpret_cast< FocusStyle*>(_v)); break;
        }
        _id -= 10;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 10;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
コード例 #14
0
void TimelineSelectionTool::mouseReleaseEvent(TimelineMovableAbstractItem *item,
                                              QGraphicsSceneMouseEvent *event)
{
    Q_UNUSED(item);
    Q_UNUSED(event);

    commitSelection(selectionMode(event));

    reset();
}
コード例 #15
0
QString ContentsChatItem::selection() const
{
    if (selectionMode() == FullSelection)
        return data(MessageModel::DisplayRole).toString();
    if (selectionMode() == PartialSelection) {
        int start = qMin(selectionStart(), selectionEnd());
        int end   = start + qAbs(selectionStart() - selectionEnd());
        int offset = 0;

        for (const Smiley &s : privateData()->smileys) {
            if(s.smileyfiedStart() >= start && s.smileyfiedStart()+1 <= end) {
                offset += s.text().count() - ((s.type() == Smiley::Emoji) ? s.graphics().count() : 1);
            }
        }

        return data(MessageModel::DisplayRole).toString().mid(start, end-start+offset);;
    }
    return QString();
}
コード例 #16
0
void CCopasiSimpleSelectionTree::selectObjects(std::vector< const CCopasiObject * > * objects)
{
  // clear selection on tree and select new objects
  clearSelection();
  unsigned int i;
  unsigned int iMax = objects->size();

  if ((selectionMode() == Q3ListView::Single || selectionMode() == Q3ListView::NoSelection) && iMax > 1)
    {
      iMax = 1;
    }

  for (i = 0; i < iMax; ++i)
    {
      const CCopasiObject * object = objects->at(i);
      Q3ListViewItem* item = findListViewItem(object);

      if (!item && mpExpertSubtree)
        {
          // add the item to the expert branch
          item = new Q3ListViewItem(mpExpertSubtree,
                                    FROM_UTF8(object->getObjectDisplayName()));
          treeItems[item] = object;
        }

      // open the whole branch that contains item.
      Q3ListViewItem* parent = item->parent();

      if (parent && !(parent->isOpen()))
        {
          while (parent)
            {
              parent->setOpen(true);
              parent = parent->parent();
            }
        }

      setSelected(item, true);
    }

  removeEmptySubTree(&mpExpertSubtree);
}
コード例 #17
0
void K3bTempDirSelectionWidget::fixTempPath( bool forceNewImageName )
{
    // if in file selection mode and no image file is specified or
    // forceNewImageName is true set the default image file name
    if ( selectionMode() == FILE ) {
        if ( forceNewImageName ||
             QFileInfo( plainTempPath() ).isDir() ) {
            setTempPath( tempDirectory() + m_defaultImageFileName );
        }
    }
}
コード例 #18
0
ファイル: historyview.cpp プロジェクト: Jose41/qupzilla
void HistoryView::itemPressed(const QModelIndex &index)
{
    if (!index.isValid() || index.data(HistoryModel::IsTopLevelRole).toBool()) {
        return;
    }

    if ((selectionMode() == QAbstractItemView::SingleSelection && QApplication::keyboardModifiers() & Qt::ControlModifier) ||
            QApplication::mouseButtons() & Qt::MiddleButton
       ) {
        emit openLink(index.data(HistoryModel::UrlRole).toUrl(), OpenInNewTab);
    }
}
コード例 #19
0
ファイル: iconlistwidget.cpp プロジェクト: CmdrMoozy/cutesync
/*!
 * This function returns the index of the currently selected row. If no
 * selection is currently active, or if multiple selection is enabled, this
 * function will fail and returns -1 instead.
 *
 * \return The currently selected row.
 */
int CSIconListWidget::getSelectedRow() const
{
	if(selectionMode() == QAbstractItemView::SingleSelection)
	{
		QModelIndexList idx = selectedIndexes();

		if(!idx.isEmpty())
			return idx.first().row();
	}

	return -1;
}
コード例 #20
0
void PeriodsListView::populate(int pCalheadid)
{
  XSqlQuery caltype( QString( "SELECT calhead_type "
                              "FROM calhead "
                              "WHERE (calhead_id=%1);" )
                     .arg(pCalheadid) );
  if (caltype.first())
  {
    QString sql;

    _calheadid = pCalheadid;
    clear();

    if (caltype.value("calhead_type").toString() == "A")
      sql = QString( "SELECT acalitem_id, periodstart, periodend, acalitem_name AS periodname,"
                     "       (formatDate(periodstart) || ' - ' || formatDate(periodend)) AS periodrange "
                     "FROM ( SELECT acalitem_id, acalitem_name,"
                     "              findPeriodStart(acalitem_id) AS periodstart,"
                     "              findPeriodEnd(acalitem_id) AS periodend "
                     "       FROM acalitem "
                     "       WHERE (acalitem_calhead_id=%1) ) AS data "
                     "ORDER BY periodstart;" )
              .arg(pCalheadid);

    else if (caltype.value("calhead_type").toString() == "R")
      sql = QString( "SELECT rcalitem_id, periodstart, periodend, rcalitem_name AS periodname,"
                     "       (formatDate(periodstart) || ' - ' || formatDate(periodend)) AS periodrange "
                     "FROM ( SELECT rcalitem_id, rcalitem_name,"
                     "              findPeriodStart(rcalitem_id) AS periodstart,"
                     "              findPeriodEnd(rcalitem_id) AS periodend "
                     "       FROM rcalitem "
                     "       WHERE (rcalitem_calhead_id=%1) ) AS data "
                     "ORDER BY periodstart;" )
              .arg(pCalheadid);

    XSqlQuery query(sql);
    XTreeWidgetItem *last = 0;
    QAbstractItemView::SelectionMode tmp = selectionMode();
    setSelectionMode(QAbstractItemView::MultiSelection);
    while (query.next())
    {
      last = new PeriodListViewItem(this, last, query.value(0).toInt(),
                                    query.value(1).toDate(), query.value(2).toDate(),
                                    query.value(3).toString(), query.value(4).toString() );
      setCurrentItem(last);
    }
    setSelectionMode(tmp);
  }
  else
    _calheadid = -1;
}
コード例 #21
0
ファイル: viewitems.cpp プロジェクト: RISEFX/cgru
void ViewItems::keyPressEvent( QKeyEvent * event)
{
	// Clear selection on Escape:
	if(( selectionMode() != QAbstractItemView::NoSelection ) && ( event->key() == Qt::Key_Escape ))
		clearSelection();

	// Process List view keys:
	QListView::keyPressEvent( event);

	// Process dialog keys (for admin mode):
	Watch::keyPressEvent( event);

	// Process parent (ListItems class) keys (panel buttons):
	m_listitems->keyPressEvent( event);
}
コード例 #22
0
/******************************************************************************
*  Fetch the single selected item.
*  This method works in both Single and Multi selection mode, unlike
*  QListView::selectedItem().
*  Reply = null if no items are selected, or if multiple items are selected.
*/
EventListViewItemBase* EventListViewBase::selectedItem() const
{
    if (selectionMode() == QListView::Single)
        return (EventListViewItemBase*)KListView::selectedItem();

    QListViewItem* item = 0;
    for (QListViewItem* it = firstChild();  it;  it = it->nextSibling())
    {
        if (isSelected(it))
        {
            if (item)
                return 0;
            item = it;
        }
    }
    return (EventListViewItemBase*)item;
}
コード例 #23
0
void K3bTempDirSelectionWidget::setDefaultImageFileName( const QString& name )
{
    if ( !name.isEmpty() ) {
        bool changeImageName = false;
        if ( selectionMode() == FILE ) {
            if ( plainTempPath().section( '/', -1 ) == m_defaultImageFileName ) {
                changeImageName = true;
            }
        }

        m_defaultImageFileName = name;
        if ( !m_defaultImageFileName.contains( '.' ) ) {
            m_defaultImageFileName += ".iso";
        }
        fixTempPath( changeImageName );
    }
}
コード例 #24
0
ファイル: sidepane.cpp プロジェクト: tsujan/FeatherPad
void ListWidget::mousePressEvent (QMouseEvent *event)
{
    if (selectionMode() == QAbstractItemView::SingleSelection)
    {
        if (event->button() == Qt::MidButton)
        {
            QModelIndex index = indexAt (event->pos());
            if (QListWidgetItem *item = itemFromIndex (index)) // index is checked for its validity in QListWidget::itemFromIndex()
                emit closeItem (item);
            else
                emit closeSidePane();
            return;
        }
        else if (event->button() == Qt::RightButton)
            return;
    }
    QListWidget::mousePressEvent (event);
}
コード例 #25
0
void TimelineSelectionTool::mouseMoveEvent(TimelineMovableAbstractItem *item,
                                           QGraphicsSceneMouseEvent *event)
{
    Q_UNUSED(item);

    if (event->buttons() == Qt::LeftButton) {
        auto endPoint = event->scenePos();
        if (endPoint.x() < 0)
            endPoint.rx() = 0;
        if (endPoint.y() < 0)
            endPoint.ry() = 0;
        m_selectionRect->setRect(QRectF(startPosition(), endPoint).normalized());
        m_selectionRect->show();

        aboutToSelect(selectionMode(event),
                      scene()->items(m_selectionRect->rect(), Qt::ContainsItemShape));
    }
}
コード例 #26
0
ファイル: sidepane.cpp プロジェクト: tsujan/FeatherPad
// See "qabstractitemview.cpp".
QItemSelectionModel::SelectionFlags ListWidget::selectionCommand (const QModelIndex &index, const QEvent *event) const
{
    Qt::KeyboardModifiers keyModifiers = Qt::NoModifier;
    if (event)
    {
        switch (event->type()) {
            case QEvent::MouseButtonDblClick:
            case QEvent::MouseButtonPress:
            case QEvent::MouseButtonRelease:
            case QEvent::MouseMove:
            case QEvent::KeyPress:
            case QEvent::KeyRelease:
                keyModifiers = (static_cast<const QInputEvent*>(event))->modifiers();
                break;
            default:
                keyModifiers = QApplication::keyboardModifiers();
        }
    }
    if (selectionMode() == QAbstractItemView::SingleSelection && (keyModifiers & Qt::ControlModifier) && selectionModel()->isSelected (index))
        return QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows;
    else
        return QListWidget::selectionCommand (index, event);
}
コード例 #27
0
ファイル: dirtree_view.cpp プロジェクト: descent/qtermwidget
void FOListView::rename_item()
{
  qDebug("in FOLostView");
  SelectionMode sm=selectionMode();
  if (sm==QListView::Single) // in dirtreeview
  {
    rename_item(selectedItem());
  }
  if (sm==QListView::Multi) // in dircontentview
  {
    FOListViewItem *i=(FOListViewItem *)firstChild();
    for (; i ; i=(FOListViewItem *)(i->nextSibling()) )
    {
      if(isSelected(i))
      {
        qDebug("select: %s", i->basename().c_str());
        rename_item(i);
      }
    }
  }


}
コード例 #28
0
void PeriodsListView::load(ParameterList &pParams)
{
  clearSelection();
  QAbstractItemView::SelectionMode oldSelMode = selectionMode();
  setSelectionMode(QAbstractItemView::MultiSelection);

  if (topLevelItemCount() > 0)
  {
    QVariant param;
    bool     valid = TRUE;
    for (unsigned int counter = 0; valid; counter++)
    {
      param = pParams.value(QString("calitem_id(%1)").arg(counter), &valid);
      if (valid)
      {
        for (int i = 0; i < topLevelItemCount(); i++)
          if (((XTreeWidgetItem*)topLevelItem(i))->id() == param.toInt())
            setCurrentItem(topLevelItem(i));
      }
    }
  }

  setSelectionMode(oldSelMode);
}
コード例 #29
0
int QAbstractItemView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractScrollArea::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: pressed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 1: clicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 2: doubleClicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 3: activated((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 4: entered((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 5: viewportEntered(); break;
        case 6: reset(); break;
        case 7: setRootIndex((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 8: doItemsLayout(); break;
        case 9: selectAll(); break;
        case 10: edit((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 11: clearSelection(); break;
        case 12: setCurrentIndex((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 13: scrollToTop(); break;
        case 14: scrollToBottom(); break;
        case 15: update((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 16: dataChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break;
        case 17: rowsInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 18: rowsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 19: selectionChanged((*reinterpret_cast< const QItemSelection(*)>(_a[1])),(*reinterpret_cast< const QItemSelection(*)>(_a[2]))); break;
        case 20: currentChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break;
        case 21: updateEditorData(); break;
        case 22: updateEditorGeometries(); break;
        case 23: updateGeometries(); break;
        case 24: verticalScrollbarAction((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 25: horizontalScrollbarAction((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 26: verticalScrollbarValueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 27: horizontalScrollbarValueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 28: closeEditor((*reinterpret_cast< QWidget*(*)>(_a[1])),(*reinterpret_cast< QAbstractItemDelegate::EndEditHint(*)>(_a[2]))); break;
        case 29: commitData((*reinterpret_cast< QWidget*(*)>(_a[1]))); break;
        case 30: editorDestroyed((*reinterpret_cast< QObject*(*)>(_a[1]))); break;
        case 31: d_func()->_q_columnsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 32: d_func()->_q_columnsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 33: d_func()->_q_rowsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 34: d_func()->_q_modelDestroyed(); break;
        case 35: d_func()->_q_layoutChanged(); break;
        case 36: d_func()->_q_fetchMore(); break;
        }
        _id -= 37;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = hasAutoScroll(); break;
        case 1: *reinterpret_cast< int*>(_v) = autoScrollMargin(); break;
        case 2: *reinterpret_cast<int*>(_v) = QFlag(editTriggers()); break;
        case 3: *reinterpret_cast< bool*>(_v) = tabKeyNavigation(); break;
        case 4: *reinterpret_cast< bool*>(_v) = showDropIndicator(); break;
        case 5: *reinterpret_cast< bool*>(_v) = dragEnabled(); break;
        case 6: *reinterpret_cast< bool*>(_v) = dragDropOverwriteMode(); break;
        case 7: *reinterpret_cast< DragDropMode*>(_v) = dragDropMode(); break;
        case 8: *reinterpret_cast< bool*>(_v) = alternatingRowColors(); break;
        case 9: *reinterpret_cast< SelectionMode*>(_v) = selectionMode(); break;
        case 10: *reinterpret_cast< SelectionBehavior*>(_v) = selectionBehavior(); break;
        case 11: *reinterpret_cast< QSize*>(_v) = iconSize(); break;
        case 12: *reinterpret_cast< Qt::TextElideMode*>(_v) = textElideMode(); break;
        case 13: *reinterpret_cast< ScrollMode*>(_v) = verticalScrollMode(); break;
        case 14: *reinterpret_cast< ScrollMode*>(_v) = horizontalScrollMode(); break;
        }
        _id -= 15;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setAutoScroll(*reinterpret_cast< bool*>(_v)); break;
        case 1: setAutoScrollMargin(*reinterpret_cast< int*>(_v)); break;
        case 2: setEditTriggers(QFlag(*reinterpret_cast<int*>(_v))); break;
        case 3: setTabKeyNavigation(*reinterpret_cast< bool*>(_v)); break;
        case 4: setDropIndicatorShown(*reinterpret_cast< bool*>(_v)); break;
        case 5: setDragEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 6: setDragDropOverwriteMode(*reinterpret_cast< bool*>(_v)); break;
        case 7: setDragDropMode(*reinterpret_cast< DragDropMode*>(_v)); break;
        case 8: setAlternatingRowColors(*reinterpret_cast< bool*>(_v)); break;
        case 9: setSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break;
        case 10: setSelectionBehavior(*reinterpret_cast< SelectionBehavior*>(_v)); break;
        case 11: setIconSize(*reinterpret_cast< QSize*>(_v)); break;
        case 12: setTextElideMode(*reinterpret_cast< Qt::TextElideMode*>(_v)); break;
        case 13: setVerticalScrollMode(*reinterpret_cast< ScrollMode*>(_v)); break;
        case 14: setHorizontalScrollMode(*reinterpret_cast< ScrollMode*>(_v)); break;
        }
        _id -= 15;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 15;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
コード例 #30
0
/******************************************************************************
*  Called when the Select All action is selected.
*  Select all items in the list.
*/
void EventListViewBase::slotSelectAll()
{
    if (selectionMode() == QListView::Multi  ||  selectionMode() == QListView::Extended)
        selectAll(true);
}