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; }
// My own version of the table's actions // In principle it does the same as QTable, but // deletes selected cells // closes application on ESCAPE bool MTable::eventFilter( QObject *o, QEvent *e ) { if ( !o || !e ) return QScrollView::eventFilter( o, e ); //QWidget *editorWidget = cellWidget( currentRow(), currentColumn() ); switch ( e->type() ) { case QEvent::KeyPress: if ( !isEditing() ) { QKeyEvent *ke = (QKeyEvent*)e; if ( ke->key() == Key_Escape ) { QApplication::sendEvent( parentWidget ( FALSE ) , e ); return TRUE; } if ( ke->key() == Key_Return || ke->key() == Key_Enter ) { if ( currentRow() >= numRows() - 1 ){ setUpdatesEnabled( false ); setNumRows( numRows() + 10 ); setUpdatesEnabled( true ); } activateNextCell(); ensureCellVisible ( currentRow(), currentColumn() ); return TRUE; } if ( ke->key() == Key_Delete ) { if (numSelections() > 0) { QTableSelection ts = selection( currentSelection() ); for ( int icol = ts.leftCol(); icol <= ts.rightCol(); icol++){ for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){ clearCell( irow, icol ); } } setCurrentCell ( ts.anchorRow(), ts.anchorCol() ); clearSelection ( TRUE ); } else { clearCell( currentRow(), currentColumn() ); } return TRUE; } if ( ke->key() == Key_C && ( ke->state() & ControlButton ) == ControlButton ) { QString cellText; itemCopy.clear(); if (numSelections() > 0) { QTableSelection ts; ts = selection( currentSelection() ); for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){ for ( int icol = ts.leftCol(); icol <= ts.rightCol(); icol++){ cellText = text( irow, icol ); if ( !cellText.isEmpty() ) itemCopy.push_back( cellText.latin1() ); else itemCopy.push_back( "" ); } } } else { cellText = text( currentRow(), currentColumn() ); if ( !cellText.isEmpty() ) itemCopy.push_back( cellText.latin1() ); else itemCopy.push_back( "" ); } return TRUE; } if ( ke->key() == Key_V && ( ke->state() & ControlButton ) == ControlButton ) { if ( numSelections() > 0 && itemCopy.size() > 0 ) { QTableSelection ts = selection( currentSelection() ); uint icount; for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){ for ( int icol = ts.leftCol(); icol <= ts.rightCol(); icol++){ //icount = (icol - ts.leftCol())*(ts.bottomRow() - ts.topRow()+1) + irow-ts.topRow(); icount = (irow - ts.topRow())*(ts.rightCol() - ts.leftCol()+1) + icol-ts.leftCol(); if ( icount < itemCopy.size() ) setText( irow, icol, (itemCopy[icount]).c_str() ); } } } else { if ( itemCopy.size() > 0 ) // there was not selection, copy first item only setText( currentRow(), currentColumn(), (itemCopy[0]).c_str() ); } return TRUE; } if ( ke->key() == Key_X && ( ke->state() & ControlButton ) == ControlButton ) { QString cellText; if (numSelections() > 0) { itemCopy.clear(); QTableSelection ts; ts = selection( currentSelection() ); for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){ for ( int icol = ts.leftCol(); icol <= ts.rightCol(); icol++){ cellText = text( irow, icol ); if ( !cellText.isEmpty() ) itemCopy.push_back( cellText.latin1() ); else itemCopy.push_back( "" ); clearCell( irow, icol ); } } setCurrentCell ( ts.anchorRow(), ts.anchorCol() ); clearSelection ( TRUE ); } else { cellText = text( currentRow(), currentColumn() ); if ( !cellText.isEmpty() ) itemCopy.push_back( cellText.latin1() ); else itemCopy.push_back( "" ); clearCell( currentRow(), currentColumn() ); } return TRUE; } if ( currentColumn() == 0 && ctype == ComboBox && ke->key() != Key_Left && ke->key() != Key_Right && ke->key() != Key_Up && ke->key() != Key_Down && ke->key() != Key_Control && ke->key() != Key_Alt && ke->key() != Key_Shift ) { //QApplication::beep (); keyPressEvent( (QKeyEvent*)e ); return true; } } else{ QKeyEvent *ke = (QKeyEvent*)e; if ( ke->key() == Key_Return || ke->key() == Key_Enter ) { stopEditing(); if ( currentRow() >= numRows() - 1 ){ setUpdatesEnabled( false ); setNumRows( numRows() + 10 ); setUpdatesEnabled( true ); } //else {stopEditing();} activateNextCell(); return true; } } break; default: break; } return QTable::eventFilter( o, e ) ; }