void Net2Detect::Online( const notifystruct* pNotify )
{
// The mutex will always be unlocked when the QMutexLocker object is
// destroyed (when the function returns since locker is an auto variable)
if ( !m_bNotifierStarted )
return;
if ( !pNotify->type.empty() )
sType.sprintf( "%s", pNotify->type.c_str() );
if ( (sType != sDevice1) && (sType != sDevice2) && (sType != sDevice3))
return;
m_pNodeTable->setSortingEnabled( false );
Net2Notify( pNotify );
m_pNodeTable->setSortingEnabled( true );
}
void Net2Detect::Net2Notify( const notifystruct* pNotify )
{
CIPAddr addr;
addr.SetV4Address( pNotify->addr );
char str[CIPAddr::ADDRSTRINGBYTES];
CIPAddr::AddrIntoString( addr, str, false, false );
QString sIP
( reinterpret_cast<const
char*>
(str
) );
int nRow = m_pNodeTable->rowCount();
m_pNodeTable->insertRow( nRow ); // Add a row to the table
// Fill in Mode
Net2TableCell* pCell = new Net2TableCell( "Net2" );
if ( pCell == NULL )
return;
m_pNodeTable->setItem( nRow, COL0_Mode, pCell );
// Fill in Name
if ( !pNotify->name.empty() )
sName.sprintf( "%s", pNotify->name.c_str() );
if ( (pCell = new Net2TableCell( sName )) == NULL )
return;
m_pNodeTable->setItem( nRow, COL1_Name, pCell );
.
.
.
// Set the table cells as read-only
Qt::ItemFlags flags = m_pNodeTable->item( nRow, COL0_Mode )->flags();
flags ^= Qt::ItemIsEditable;
m_pNodeTable->item( nRow, COL0_Mode )->setFlags( flags );
m_pNodeTable->item( nRow, COL1_Name )->setFlags( flags );
m_pNodeTable->item( nRow, COL2_IP )->setFlags( flags );
m_pNodeTable->item( nRow, COL3_Type )->setFlags( flags );
m_pNodeTable->item( nRow, COL4_Ver )->setFlags( flags );
m_pNodeTable->item( nRow, COL5_CID )->setFlags( flags );
}
void Net2Detect::Online( const notifystruct* pNotify )
{
// The mutex will always be unlocked when the QMutexLocker object is
// destroyed (when the function returns since locker is an auto variable)
QMutexLocker locker( &m_NotifyMutex );
if ( !m_bNotifierStarted )
return;
QString sType( "" );
if ( !pNotify->type.empty() )
sType.sprintf( "%s", pNotify->type.c_str() );
if ( (sType != sDevice1) && (sType != sDevice2) && (sType != sDevice3))
return;
m_pNodeTable->setSortingEnabled( false );
Net2Notify( pNotify );
m_pNodeTable->setSortingEnabled( true );
}
void Net2Detect::Net2Notify( const notifystruct* pNotify )
{
CIPAddr addr;
addr.SetV4Address( pNotify->addr );
char str[CIPAddr::ADDRSTRINGBYTES];
CIPAddr::AddrIntoString( addr, str, false, false );
QString sIP( reinterpret_cast<const char*>(str) );
int nRow = m_pNodeTable->rowCount();
m_pNodeTable->insertRow( nRow ); // Add a row to the table
// Fill in Mode
Net2TableCell* pCell = new Net2TableCell( "Net2" );
if ( pCell == NULL )
return;
m_pNodeTable->setItem( nRow, COL0_Mode, pCell );
// Fill in Name
QString sName( "" );
if ( !pNotify->name.empty() )
sName.sprintf( "%s", pNotify->name.c_str() );
if ( (pCell = new Net2TableCell( sName )) == NULL )
return;
m_pNodeTable->setItem( nRow, COL1_Name, pCell );
.
.
.
// Set the table cells as read-only
Qt::ItemFlags flags = m_pNodeTable->item( nRow, COL0_Mode )->flags();
flags ^= Qt::ItemIsEditable;
m_pNodeTable->item( nRow, COL0_Mode )->setFlags( flags );
m_pNodeTable->item( nRow, COL1_Name )->setFlags( flags );
m_pNodeTable->item( nRow, COL2_IP )->setFlags( flags );
m_pNodeTable->item( nRow, COL3_Type )->setFlags( flags );
m_pNodeTable->item( nRow, COL4_Ver )->setFlags( flags );
m_pNodeTable->item( nRow, COL5_CID )->setFlags( flags );
}
To copy to clipboard, switch view to plain text mode
Bookmarks