Пример #1
0
bool CommandTable::keyPressed(const KeyPress& k) {
  if (k.isKeyCode(KeyPress::deleteKey) && getSelectedRow() != -1) {
    bool last = getSelectedRow() == getNumRows() - 1;
    ((CommandTableModel*)getModel())->removeRow(static_cast<size_t>(getSelectedRow()));
    updateContent();
    if (last) {
      // keep selection at the end
      selectRow(getNumRows() - 1);
    }
    return true;
  }
  if (k.isKeyCode(KeyPress::downKey) && getSelectedRow() != -1 && getSelectedRow() < getNumRows() - 1) {
    selectRow(getSelectedRow() + 1);
    return true;
  }
  if (k.isKeyCode(KeyPress::upKey) && getSelectedRow() > 0 && getNumRows() > 1) {
    selectRow(getSelectedRow() - 1);
    return true;
  }
  if (k.isKeyCode(KeyPress::pageUpKey) && getNumRows() > 0) {
    selectRow(0);
    return true;
  }
  if (k.isKeyCode(KeyPress::pageDownKey) && getNumRows() > 0) {
    selectRow(getNumRows() - 1);
    return true;
  }
  return false;
}
Пример #2
0
void ModBox::shift_item_next()
{
    const bool are_rows_selected = getNumSelectedRows() > 0 ?  true : false;
    const int num_rows = display_list.size();
    const int end_of_list = num_rows - 1;
    
    if (are_rows_selected == true) {
        const int selected_row = getSelectedRow();
        const bool all_good = selected_row != end_of_list ? true : false;
        if (all_good) {
            StringArray holding_array(display_list);
            holding_array.move(selected_row, selected_row + 1);
            display_list.clear();
            display_list.addArray(holding_array);
            selectRow(selected_row + 1);
            updateContent();
            on_off();
            selectRow(selected_row + 1);
        } else {
            StringArray holding_array(display_list);
            holding_array.move(selected_row, 0);
            display_list.clear();
            display_list.addArray(holding_array);
            selectRow(0);
            updateContent();
            on_off();
            selectRow(0);
        }
    }
    qk_save();
}
Пример #3
0
void WLibraryTableView::moveSelection(int delta) {
    QAbstractItemModel* pModel = model();

    if (pModel == nullptr) {
        return;
    }

    while(delta != 0) {
        // TODO(rryan) what happens if there is nothing selected?
        QModelIndex current = currentIndex();
        if(delta > 0) {
            // i is positive, so we want to move the highlight down
            int row = current.row();
            if (row + 1 < pModel->rowCount()) {
                selectRow(row + 1);
            }

            delta--;
        } else {
            // i is negative, so we want to move the highlight up
            int row = current.row();
            if (row - 1 >= 0) {
                selectRow(row - 1);
            }

            delta++;
        }
    }
}
Пример #4
0
void
FWTestTableManager::rowClicked(Int_t row, Int_t btn, Int_t keyMod)
{
    if(btn==kButton1) {
        if(row==m_selectedRow) {
            if(keyMod & kKeyShiftMask) {
                selectRow(-1);
            }
        } else {
            selectRow(row);
        }
    }
}
    void listBoxItemClicked (int row, const MouseEvent& e) override
    {
        selectRow (row);

        if (e.x < getTickX())
            flipEnablement (row);
    }
Пример #6
0
void QtHighlightEditor::moveRowFromTo(int fromRow, int toRow) {
	int verticalScrollAreaPosition = ui_.scrollArea->verticalScrollBar()->value();
	highlightManager_->swapRules(fromRow, toRow);
	populateList();
	selectRow(toRow);
	ui_.scrollArea->verticalScrollBar()->setValue(verticalScrollAreaPosition);
}
Пример #7
0
void Sbrowse::configureView()
{
	setSelectionBehavior(QAbstractItemView::SelectRows);
	resizeColumnsToContents();
	horizontalHeader()->setStretchLastSection(true);
	selectRow(0);
}
Пример #8
0
QgsAttributeTableView::QgsAttributeTableView( QWidget *parent )
  : QTableView( parent )
  , mFilterModel( nullptr )
  , mFeatureSelectionModel( nullptr )
  , mFeatureSelectionManager( nullptr )
  , mActionPopup( nullptr )
  , mRowSectionAnchor( 0 )
  , mCtrlDragSelectionFlag( QItemSelectionModel::Select )
{
  QgsSettings settings;
  restoreGeometry( settings.value( QStringLiteral( "BetterAttributeTable/geometry" ) ).toByteArray() );

  //verticalHeader()->setDefaultSectionSize( 20 );
  horizontalHeader()->setHighlightSections( false );

  // We need mouse move events to create the action button on hover
  mTableDelegate = new QgsAttributeTableDelegate( this );
  setItemDelegate( mTableDelegate );

  setEditTriggers( QAbstractItemView::AllEditTriggers );

  setSelectionBehavior( QAbstractItemView::SelectRows );
  setSelectionMode( QAbstractItemView::ExtendedSelection );
  setSortingEnabled( true ); // At this point no data is in the model yet, so actually nothing is sorted.
  horizontalHeader()->setSortIndicatorShown( false ); // So hide the indicator to avoid confusion.

  verticalHeader()->viewport()->installEventFilter( this );

  connect( verticalHeader(), &QHeaderView::sectionPressed, this, [ = ]( int row ) { selectRow( row, true ); } );
  connect( verticalHeader(), &QHeaderView::sectionEntered, this, &QgsAttributeTableView::_q_selectRow );
  connect( horizontalHeader(), &QHeaderView::sectionResized, this, &QgsAttributeTableView::columnSizeChanged );
  connect( horizontalHeader(), &QHeaderView::sortIndicatorChanged, this, &QgsAttributeTableView::showHorizontalSortIndicator );
  connect( QgsGui::mapLayerActionRegistry(), &QgsMapLayerActionRegistry::changed, this, &QgsAttributeTableView::recreateActionWidgets );
}
Пример #9
0
void MailListView::keyPressEvent( QKeyEvent *e ) // sharp and phone
{
    switch( e->key() ) {
        case Qt::Key_Space:
        case Qt::Key_Return:
        case Qt::Key_Select:
        case Qt::Key_Enter:
        {
            emit clicked(currentIndex());
        }
        break;
        case Qt::Key_No:
        case Qt::Key_Back:
        case Qt::Key_Backspace:
        {
            //if (!Qtopia::mousePreferred())
                emit backPressed();
            //else
            //    e->ignore();
        }
        break;
        default:  QTableWidget::keyPressEvent( e );
    }
    if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down) {
        clearSelection();
        selectRow( currentRow() );
    }
}
Пример #10
0
void QtHighlightEditor::onDownButtonClicked() {
	const size_t moveFrom = ui_.listWidget->currentRow();
	const size_t moveTo = moveFrom + 1;
	highlightManager_->swapRules(moveFrom, moveTo);
	populateList();
	selectRow(moveTo);
}
Пример #11
0
void DatabaseView::setModel(QSortFilterProxyModel *model)
{
    QTableView::setModel( model );
    connect( model->sourceModel(), &Database::rowsInserted, [this](QModelIndex, int last) {
        selectRow( last );
    });
}
Пример #12
0
void QgsFeatureListView::mousePressEvent( QMouseEvent *event )
{
  if ( mModel )
  {
    QPoint pos = event->pos();

    QModelIndex index = indexAt( pos );

    if ( QgsFeatureListViewDelegate::EditElement == mItemDelegate->positionToElement( event->pos() ) )
    {
      mEditSelectionDrag = true;
      setEditSelection( mModel->mapToMaster( index ), QItemSelectionModel::ClearAndSelect );
    }
    else
    {
      mFeatureSelectionModel->enableSync( false );
      selectRow( index, true );
      repaintRequested();
    }
  }
  else
  {
    QgsDebugMsg( QStringLiteral( "No model assigned to this view" ) );
  }
}
Пример #13
0
void Sbrowse::mousePressEvent(QMouseEvent * event)
{
	if (event->type() == QEvent::MouseButtonPress)
	{
		event->accept();

		int row = this->rowAt(event->y());
		if (row != -1)
		{
			selectRow(row);
		}

		emit rowChanged(this);

		int id = this->getQuery().record().field("id").value().toInt();
#ifdef DEBUG
        qDebug("SIGNAL rowChanged emitted Click (QEvent::MouseButtonPress) row [%d] id [%d] %s %d",
               row, id, __FILE__, __LINE__);
#endif

	}
	else
	{
		event->ignore();
	}
}
Пример #14
0
void ListBox::mouseMove (const MouseEvent& e)
{
    if (mouseMoveSelects)
    {
        const MouseEvent e2 (e.getEventRelativeTo (this));
        selectRow (getRowContainingPosition (e2.x, e2.y), true);
    }
}
Пример #15
0
    Value Connection::selectValue(const std::string& query)
    {
      Row t = selectRow(query);
      if (t.empty())
        throw NotFound();

      return t.getValue(0);
    }
Пример #16
0
void ModBox::on_off()
{
    for (auto i : display_list) {
        const int x = display_list.indexOf(i);
        selectRow(x);
        deselectRow(x);
    }
}
Пример #17
0
void XTreeView::insert()
{ 
  int row=_model->rowCount();
  _model->insertRows(row,1);
  //Set default values for foreign keys
  for (int i = 0; i < _idx.count(); ++i)
    _model->setData(_model->index(row,i),_idx.value(i));
  selectRow(row);
}
Пример #18
0
void QtHighlightEditor::onDeleteButtonClicked()
{
	int selectedRow = getSelectedRow();
	assert(selectedRow>=0 && selectedRow<ui_.listWidget->count());
	delete ui_.listWidget->takeItem(selectedRow);
	highlightManager_->removeRule(selectedRow);

	if (!ui_.listWidget->count()) {
		disableDialog();
		ui_.deleteButton->setEnabled(false);
	} else {
		if (selectedRow == ui_.listWidget->count()) {
			selectRow(ui_.listWidget->count() - 1);
		} else {
			selectRow(selectedRow);
		}
	}
}
Пример #19
0
void ViewTable::SetFocus(int row, bool em)
{
	setFocus( Qt::OtherFocusReason );
	if( rowCount() <= 0 )
		return;

	if( row < rowCount() )
		selectRow( row, em );
}
Пример #20
0
    Value Connection::selectValue(const std::string& query)
    {
      log_debug("selectValue(\"" << query << "\")");
      Row t = selectRow(query);
      if (t.empty())
        throw NotFound();

      return t.getValue(0);
    }
Пример #21
0
void CommitTableWidget::setBranch(QString branch)
// ----------------------------------------------------------------------------
//    Choose the branch to display. Select latest commit.
// ----------------------------------------------------------------------------
{
    table->setBranch(branch);
    refresh();
    selectRow(0);
}
Пример #22
0
void ContactsTable::onSavedNewContact(int idxNewContact)
  {
  QModelIndex idx;

  idx = _addressbook_model->index (idxNewContact, 0);
  QModelIndex mapped_index = _sorted_addressbook_model->mapFromSource(idx);
  selectRow(mapped_index.row());

  ui->contact_table->show ();
  }
void PropertyTreeModel::setSelection(const Selection& selection)
{
	deselectAll();
	Selection::const_iterator it;
	for(it = selection.begin(); it != selection.end(); ++it){
		const TreePath& path = *it;
		PropertyRow* row = rowFromPath(path);
		if(row)
			selectRow(row, true, false);
	}
}
Пример #24
0
void ModBox::select_prev_item()
{
    const bool are_rows_selected = getNumSelectedRows() > 0 ?  true : false;
    const int num_rows = display_list.size();
    const int end_of_list = num_rows - 1;
    
    if (are_rows_selected == true) {
        const int selected_row = getSelectedRow();
        const bool all_good = selected_row != 0 ? true : false;
        if (all_good == true) {
            deselectRow(selected_row);
            selectRow(selected_row - 1);
        } else {
            deselectRow(selected_row);
            selectRow(end_of_list);
        }
    } else {
        selectRow(0);
    }
}
Пример #25
0
void IssuesTableView::currentChanged(const QModelIndex& current,
                                     const QModelIndex& previous) {
  Q_UNUSED(previous);

#if 0
  selectRow(current.row());

  storeCurrentSelection();
  m_selectedRow = current.row();
#endif  // 0
}
Пример #26
0
/*!
    Submits all pending changes and returns \c true on success.
    Returns \c false on error, detailed error information can be
    obtained with lastError().

    In OnManualSubmit, on success the model will be repopulated.
    Any views presenting it will lose their selections.

    Note: In OnManualSubmit mode, already submitted changes won't
    be cleared from the cache when submitAll() fails. This allows
    transactions to be rolled back and resubmitted without
    losing data.

    \sa revertAll(), lastError()
*/
bool QSqlTableModel::submitAll()
{
    Q_D(QSqlTableModel);

    bool success = true;

    foreach (int row, d->cache.keys()) {
        // be sure cache *still* contains the row since overridden selectRow() could have called select()
        QSqlTableModelPrivate::CacheMap::iterator it = d->cache.find(row);
        if (it == d->cache.end())
            continue;

        QSqlTableModelPrivate::ModifiedRow &mrow = it.value();
        if (mrow.submitted())
            continue;

        switch (mrow.op()) {
        case QSqlTableModelPrivate::Insert:
            success = insertRowIntoTable(mrow.rec());
            break;
        case QSqlTableModelPrivate::Update:
            success = updateRowInTable(row, mrow.rec());
            break;
        case QSqlTableModelPrivate::Delete:
            success = deleteRowFromTable(row);
            break;
        case QSqlTableModelPrivate::None:
            Q_ASSERT_X(false, "QSqlTableModel::submitAll()", "Invalid cache operation");
            break;
        }

        if (success) {
            if (d->strategy != OnManualSubmit && mrow.op() == QSqlTableModelPrivate::Insert) {
                int c = mrow.rec().indexOf(d->autoColumn);
                if (c != -1 && !mrow.rec().isGenerated(c))
                    mrow.setValue(c, d->editQuery.lastInsertId());
            }
            mrow.setSubmitted();
            if (d->strategy != OnManualSubmit)
                success = selectRow(row);
        }

        if (!success)
            break;
    }

    if (success) {
        if (d->strategy == OnManualSubmit)
            success = select();
    }

    return success;
}
void FileListComponent::setSelectedFile (const File& f)
{
    for (int i = fileList.getNumFiles(); --i >= 0;)
    {
        if (fileList.getFile(i) == f)
        {
            selectRow (i);
            return;
        }
    }

    deselectAllRows();
}
Пример #28
0
void CAPickerView::reloadComponent(unsigned int _row,unsigned int component, bool bReloadData)
{
    // reload component
    int row = m_dataSource->numberOfRowsInComponent(this, component);
    int head = m_displayRow[component]/2;
    int foot = m_displayRow[component]/2;
    if (row <= m_displayRow[component])
    {
        row += (head + foot);
        m_componentsIndex[component].resize(row);
        for (int i=0; i<row; i++)
        {
            if (i < head)
            {
                m_componentsIndex[component][i] = -1;
            }
            else if (i >= row - foot)
            {
                m_componentsIndex[component][i] = -1;
            }
            else
            {
                m_componentsIndex[component][i] = i - head;
            }
        }
    }
    else
    {
        int cycle = 3;
        m_componentsIndex[component].resize(row*3);
        while (cycle--)
        {
            for (int i=0; i<row; i++)
            {
                m_componentsIndex[component][i + cycle*row] = i;
            }
        }
    }
        
    // reset selected index
    selectRow(_row, component, false);
    
    if (bReloadData)
    {
        // reload table view
		CATableView* view = m_tableViews.at(component);

        view->reloadData();   
        view->stopDeaccelerateScroll();
    }
}
Пример #29
0
void WndSets::actTop()
{
    QModelIndexList rows = view->selectionModel()->selectedRows();
    if(rows.empty())
        return;

    QModelIndex selectedRow = rows.first();
    int oldRow = selectedRow.row();
    int newRow = 0;
    if(oldRow <= 0)
        return;

    model->swapRows(oldRow, newRow);
    selectRow(newRow);
}
Пример #30
0
void WndSets::actBottom()
{
    QModelIndexList rows = view->selectionModel()->selectedRows();
    if(rows.empty())
        return;

    QModelIndex selectedRow = rows.first();
    int oldRow = selectedRow.row();
    int newRow = model->rowCount() - 1;
    if(oldRow >= newRow)
        return;

    model->swapRows(oldRow, newRow);
    selectRow(newRow);
}