connect( this, SIGNAL( clicked( int, int, int, const QPoint& ) ), this, SLOT( changeSelection( int, int, int, const QPoint& ) ) );
void Table
::changeSelection( int row,
int col,
int button,
const QPoint &mousePos
) {
if( button == Qt::LeftButton )
{
bool selected;
// Check if the current row is supposed to be selected
if( mpTableData->isEventSelected( row ) )
{
selected = false;
}
else
{
selected = true;
}
int selectedValue = mpTableData->getEventData( row );
// Loop through all the data elements checking if there are duplicates event data
for( int event = 0; event < mpTableData->getTotalNumEvents( ); event++ )
{
if( selectedValue == mpTableData->getEventData( row ) )
{
// If the events match, select/deselect both events
mpTableData->selectEvent( event, select ); // Sets the flag in the Data Model
}
}
updateSelections( );
}
}
void Table::updateSelections( )
{
blockSignals( );
clearSelection( );
for( int event = 0; event < mpTableData->getTotalNumEvents( ); event++ )
{
if( !mpTableData->isEventHidden( event )
if( mpTableData->isEventSelected( event ) )
addSelection( QTableSelection( row, 0, row, numCols( ) - 1 ) );
row = row + 1;
}
blockSignals( false );
}
connect( this, SIGNAL( clicked( int, int, int, const QPoint& ) ), this, SLOT( changeSelection( int, int, int, const QPoint& ) ) );
void Table::changeSelection( int row, int col, int button, const QPoint &mousePos )
{
if( button == Qt::LeftButton )
{
bool selected;
// Check if the current row is supposed to be selected
if( mpTableData->isEventSelected( row ) )
{
selected = false;
}
else
{
selected = true;
}
int selectedValue = mpTableData->getEventData( row );
// Loop through all the data elements checking if there are duplicates event data
for( int event = 0; event < mpTableData->getTotalNumEvents( ); event++ )
{
if( selectedValue == mpTableData->getEventData( row ) )
{
// If the events match, select/deselect both events
mpTableData->selectEvent( event, select ); // Sets the flag in the Data Model
}
}
updateSelections( );
}
}
void Table::updateSelections( )
{
blockSignals( );
clearSelection( );
for( int event = 0; event < mpTableData->getTotalNumEvents( ); event++ )
{
if( !mpTableData->isEventHidden( event )
if( mpTableData->isEventSelected( event ) )
addSelection( QTableSelection( row, 0, row, numCols( ) - 1 ) );
row = row + 1;
}
blockSignals( false );
}
To copy to clipboard, switch view to plain text mode
Bookmarks