{
public:
Net2TableCell
( const QString
& text,
int type
= NET2_TABLECELL_TYPE
) : QTableWidgetItem( text, type
) {
setTextAlignment( Qt::AlignCenter );
}
// For sorting non-alpha table columns (IP Address & case insensitive name).
bool operator<( const QTableWidgetItem& item ) const;
};
bool Net2TableCell::operator<( const QTableWidgetItem& item ) const
{
bool bReturn = false;
switch ( this->column() )
{
case COL1_Name:
if ( !this->text().isNull() && !item.text().isNull() &&
this->text().compare( item.text(), Qt::CaseInsensitive ) < 0 )
bReturn = true;
break;
case COL2_IP:
{
if ( CIPAddr::StringToAddr( this->text().toAscii() ).GetV4Address() <
CIPAddr::StringToAddr( item.text().toAscii() ).GetV4Address() )
bReturn = true;
break;
}
default:
}
return bReturn;
}
class Net2TableCell : public QTableWidgetItem
{
public:
Net2TableCell( const QString& text, int type = NET2_TABLECELL_TYPE ) : QTableWidgetItem( text, type )
{
setTextAlignment( Qt::AlignCenter );
}
// For sorting non-alpha table columns (IP Address & case insensitive name).
bool operator<( const QTableWidgetItem& item ) const;
};
bool Net2TableCell::operator<( const QTableWidgetItem& item ) const
{
bool bReturn = false;
switch ( this->column() )
{
case COL1_Name:
if ( !this->text().isNull() && !item.text().isNull() &&
this->text().compare( item.text(), Qt::CaseInsensitive ) < 0 )
bReturn = true;
break;
case COL2_IP:
{
if ( CIPAddr::StringToAddr( this->text().toAscii() ).GetV4Address() <
CIPAddr::StringToAddr( item.text().toAscii() ).GetV4Address() )
bReturn = true;
break;
}
default:
bReturn = QTableWidgetItem::operator <( item );
}
return bReturn;
}
To copy to clipboard, switch view to plain text mode
void MainWin::versionModeSwitch( void )
{
IPv4* pNetIPList = new IPv4[ m_pController->m_nSelectedIfaces ];
if ( pNetIPList == NULL )
return;
for ( int i = 0; i < m_pController->m_nSelectedIfaces; i++ )
pNetIPList[i] = CIPAddr::StringToAddr( m_pController->m_sCurrNetIPLst.at( i ).toAscii() ).GetV4Address();
// Create the lists in advance (from the Online table)
QStringList sNameLst, sTypeLst, sIPLst, sVerLst, sCIDLst;
// Disable sorting while the table is populated, otherwise sorting
// may interfere with the insertion order.
m_pAllOlnTable->setSortingEnabled( false );
for ( int i = 0; i < m_pAllOlnTable->rowCount(); i++ )
{
if ( !m_pAllOlnTable->item( i, COL_Status )->text().compare( OLN_ONLINE ) )
{
sNameLst.append( m_pAllOlnTable->item( i, COL_Name )->text() );
sTypeLst.append( m_pAllOlnTable->item( i, COL_DevType )->text() );
sIPLst.append( m_pAllOlnTable->item( i, COL_IPAddr )->text() );
sVerLst.append( m_pAllOlnTable->GetSWVer( i ) );
sCIDLst.append( m_pAllOlnTable->item( i, COL_CID )->text() );
}
}
m_pAllOlnTable->setSortingEnabled( true );
// Display all ACN and Net2 devices
Net2Detect verModeSwitchDlg( this );
verModeSwitchDlg.Initialize( sNameLst, sTypeLst, sIPLst, sVerLst, sCIDLst,
pNetIPList, m_pController->m_nSelectedIfaces );
verModeSwitchDlg.exec();
if ( pNetIPList != NULL )
delete [] pNetIPList;
}
void MainWin::versionModeSwitch( void )
{
IPv4* pNetIPList = new IPv4[ m_pController->m_nSelectedIfaces ];
if ( pNetIPList == NULL )
return;
for ( int i = 0; i < m_pController->m_nSelectedIfaces; i++ )
pNetIPList[i] = CIPAddr::StringToAddr( m_pController->m_sCurrNetIPLst.at( i ).toAscii() ).GetV4Address();
// Create the lists in advance (from the Online table)
QStringList sNameLst, sTypeLst, sIPLst, sVerLst, sCIDLst;
// Disable sorting while the table is populated, otherwise sorting
// may interfere with the insertion order.
m_pAllOlnTable->setSortingEnabled( false );
for ( int i = 0; i < m_pAllOlnTable->rowCount(); i++ )
{
if ( !m_pAllOlnTable->item( i, COL_Status )->text().compare( OLN_ONLINE ) )
{
sNameLst.append( m_pAllOlnTable->item( i, COL_Name )->text() );
sTypeLst.append( m_pAllOlnTable->item( i, COL_DevType )->text() );
sIPLst.append( m_pAllOlnTable->item( i, COL_IPAddr )->text() );
sVerLst.append( m_pAllOlnTable->GetSWVer( i ) );
sCIDLst.append( m_pAllOlnTable->item( i, COL_CID )->text() );
}
}
m_pAllOlnTable->setSortingEnabled( true );
// Display all ACN and Net2 devices
Net2Detect verModeSwitchDlg( this );
verModeSwitchDlg.Initialize( sNameLst, sTypeLst, sIPLst, sVerLst, sCIDLst,
pNetIPList, m_pController->m_nSelectedIfaces );
verModeSwitchDlg.exec();
if ( pNetIPList != NULL )
delete [] pNetIPList;
}
To copy to clipboard, switch view to plain text mode
Bookmarks