예제 #1
0
//-------------------------------------------------------------------------
void GMapDialog::selectionChangedX (const QItemSelection &sel,  const QItemSelection &desel)
{
    int k=0;
    foreach (QStandardItem*w, wptList) {
        QModelIndex idx = model->indexFromItem(w);
        if (desel.contains(idx))
            mapWidget->setWaypointColorBlue(k);
        if (sel.contains(idx))
            mapWidget->setWaypointColorRed(k);
        k++;
    }
예제 #2
0
void ItemViewCategorized::awayFromSelection()
{
    QItemSelection selection = selectionModel()->selection();

    if (selection.isEmpty())
    {
        return;
    }

    const QModelIndex first = model()->index(0, 0);
    const QModelIndex last  = model()->index(model()->rowCount() - 1, 0);

    if (selection.contains(first) && selection.contains(last))
    {
        QItemSelection remaining(first, last);
        remaining.merge(selection, QItemSelectionModel::Toggle);
        QList<QModelIndex> indexes = remaining.indexes();

        if (indexes.isEmpty())
        {
            clearSelection();
            setCurrentIndex(QModelIndex());
        }
        else
        {
            toIndex(remaining.indexes().first());
        }
    }
    else if (selection.contains(last))
    {
        setCurrentIndex(selection.indexes().first());
        toPreviousIndex();
    }
    else
    {
        setCurrentIndex(selection.indexes().last());
        toNextIndex();
    }
}