void AccountWidget::setupConnections( const QPersistentModelIndex& idx, int accountIdx ) { m_myFactoryIdx = idx; m_myAccountIdx = accountIdx; Tomahawk::Accounts::Account* account = idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole ) .value< QList< Tomahawk::Accounts::Account* > >().at( accountIdx ); if ( account ) { connect( m_statusToggle, SIGNAL( toggled( bool ) ), this, SLOT( changeAccountConnectionState( bool ) ) ); connect( m_inviteButton, SIGNAL( clicked() ), this, SLOT( sendInvite() ) ); connect( m_inviteEdit, SIGNAL( returnPressed() ), this, SLOT( sendInvite() ) ); if ( account->sipPlugin() ) { m_inviteEdit->setPlaceholderText( account->sipPlugin()->inviteString() ); connect( account->sipPlugin(), SIGNAL( inviteSentSuccess( QString ) ), SLOT( onInviteSentSuccess( QString ) ) ); connect( account->sipPlugin(), SIGNAL( inviteSentFailure( QString ) ), SLOT( onInviteSentFailure( QString ) ) ); } } }
void AccountWidget::sendInvite() { Tomahawk::Accounts::Account* account = m_myFactoryIdx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole ) .value< QList< Tomahawk::Accounts::Account* > >().at( m_myAccountIdx ); if ( account ) { if ( !m_inviteEdit->text().isEmpty() ) account->sipPlugin()->addContact( m_inviteEdit->text() ); m_inviteButton->setEnabled( false ); m_inviteEdit->setEnabled( false ); QTimer::singleShot( 500, this, SLOT( clearInviteWidgets() ) ); } }