⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kphonebook.cpp

📁 KphoneSI (kpsi) is a SIP (Session Initiation Protocol) user agent for Linux, with which you can in
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include <stdio.h>#include <qstring.h>#include <qregexp.h>#include <qlistview.h>#include <qfile.h>#include <qxml.h>#include <qwindowdefs.h>#include <qmessagebox.h>#include <qsplitter.h>#include <qvbox.h>#include <qlabel.h>#include <qlayout.h>#include <qdom.h>#include <qurloperator.h>#include <menulistview.h>#include "kphonebook.h"IncomingCall::IncomingCall( QString s, QDateTime time ){	contact = s;	dt = time;}IncomingCall::~IncomingCall( void ){}PhoneBookAddIdentity::PhoneBookAddIdentity( QWidget *parent, const char *name )	: QDialog( parent, name, true ){	setCaption( QString( name ) );	QVBox *vbox = new QVBox( this );	vbox->setMargin( 3 );	vbox->setSpacing( 3 );	QVBoxLayout *vboxl = new QVBoxLayout( this, 5 );	vboxl->addWidget( vbox );	(void) new QLabel( "Person:", vbox );	person = new QLineEdit( vbox );	(void) new QLabel( "Identity:", vbox );	identity = new QLineEdit( vbox );	(void) new QLabel( "Description:", vbox );	description = new QLineEdit( vbox );	contact = new QCheckBox( "Add Identity to Contacts List", vbox );	description->setMinimumWidth( fontMetrics().maxWidth() * 20 );	QHBoxLayout *buttonBox;	buttonBox = new QHBoxLayout( vboxl, 6 );	QSpacerItem *spacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );	buttonBox->addItem( spacer );	okPushButton = new QPushButton( this, "ok button" );	okPushButton->setText( "OK" );	okPushButton->setDefault( TRUE );	buttonBox->addWidget( okPushButton );	cancelPushButton = new QPushButton( this, "cancel button" );	cancelPushButton->setText( "Cancel" );	cancelPushButton->setAccel( Key_Escape );	buttonBox->addWidget( cancelPushButton );	connect( okPushButton, SIGNAL( clicked() ), this, SLOT( slotOk() ) );	connect( cancelPushButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) );}void PhoneBookAddIdentity::clean( void ){	person->setText("");	identity->setText("");	description->setText("");	contact->setChecked( false );}void PhoneBookAddIdentity::setPerson( QString newPerson ){	person->setText( newPerson );}void PhoneBookAddIdentity::setIdentity( QString newIdentity ){	identity->setText( newIdentity );}void PhoneBookAddIdentity::setDescription( QString newDescription ){	description->setText( newDescription );}void PhoneBookAddIdentity::setContact( bool yesno ){	contact->setChecked( yesno );}QString PhoneBookAddIdentity::getPerson( void ){	return person->text();}QString PhoneBookAddIdentity::getIdentity( void ){	return identity->text();}QString PhoneBookAddIdentity::getDescription( void ){	return description->text();}QString PhoneBookAddIdentity::getContact( void ){	if( contact->isChecked() ){		return "Yes";	} else {		return "No";	}}void PhoneBookAddIdentity::slotOk( void ){	QDialog::accept();}void PhoneBookAddIdentity::slotCancel( void ){	QDialog::reject();}PhoneBookEditIdentity::PhoneBookEditIdentity( QWidget *parent, const char *name )		: QDialog( parent, name, true ){	setCaption( QString( name ) );	QVBox *vbox = new QVBox( this );	vbox->setMargin( 3 );	vbox->setSpacing( 3 );	QVBoxLayout *vboxl = new QVBoxLayout( this, 5 );	vboxl->addWidget( vbox );	(void) new QLabel( "Identity:", vbox );	identity = new QLineEdit( vbox );	identity->setMinimumWidth( fontMetrics().maxWidth() * 20 );	(void) new QLabel( "Description:", vbox );	description = new QLineEdit( vbox );	contact = new QCheckBox( "Add Identity to Contacts List", vbox );// OK, Cancel	QHBoxLayout *buttonBox;	buttonBox = new QHBoxLayout( vboxl, 6 );	QSpacerItem *spacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );	buttonBox->addItem( spacer );	okPushButton = new QPushButton( this, "ok button" );	okPushButton->setText( "OK" );	okPushButton->setDefault( TRUE );	buttonBox->addWidget( okPushButton );	cancelPushButton = new QPushButton( this, "cancel button" );	cancelPushButton->setText( "Cancel" );	cancelPushButton->setAccel( Key_Escape );	buttonBox->addWidget( cancelPushButton );	connect( okPushButton, SIGNAL( clicked() ), this, SLOT( slotOk() ) );	connect( cancelPushButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) );}PhoneBookEditIdentity::~PhoneBookEditIdentity( void ){}QString PhoneBookEditIdentity::getIdentity( void ){	return identity->text();}QString PhoneBookEditIdentity::getDescription( void ){	return description->text();}void PhoneBookEditIdentity::setIdentity( QString newIdentity ){	identity->setText( newIdentity );}void PhoneBookEditIdentity::setDescription( QString newDescription ){	description->setText( newDescription );}QString PhoneBookEditIdentity::getContact( void ){	if( contact->isChecked() ){		return "Yes";	} else {		return "No";	}}void PhoneBookEditIdentity::setContact( QString newContact ){	if( newContact.lower() == "yes" ) {		contact->setChecked( true );	} else {		contact->setChecked( false );	}}void PhoneBookEditIdentity::slotOk( void ){	QDialog::accept();}void PhoneBookEditIdentity::slotCancel( void ){	QDialog::reject();}PhoneBookEditPerson::PhoneBookEditPerson( QWidget *parent, const char *name )	: QDialog( parent, name, true ){	setCaption( QString( name ) );	QVBox *vbox = new QVBox( this );	vbox->setMargin( 3 );	vbox->setSpacing( 3 );	QVBoxLayout *vboxl = new QVBoxLayout( this, 5 );	vboxl->addWidget( vbox );	(void) new QLabel( "Name:", vbox );	person = new QLineEdit( vbox );	person->setMinimumWidth( fontMetrics().maxWidth() * 20 );// OK, Cancel	QHBoxLayout *buttonBox;	buttonBox = new QHBoxLayout( vboxl, 6 );	QSpacerItem *spacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );	buttonBox->addItem( spacer );	okPushButton = new QPushButton( this, "ok button" );	okPushButton->setText( "OK" );	okPushButton->setDefault( TRUE );	buttonBox->addWidget( okPushButton );	cancelPushButton = new QPushButton( this, "cancel button" );	cancelPushButton->setText( "Cancel" );	cancelPushButton->setAccel( Key_Escape );	buttonBox->addWidget( cancelPushButton );	connect( okPushButton, SIGNAL( clicked() ), this, SLOT( slotOk() ) );	connect( cancelPushButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) );}PhoneBookEditPerson::~PhoneBookEditPerson( void ){}QString PhoneBookEditPerson::getPerson( void ){	return person->text();}void PhoneBookEditPerson::setPerson( QString newPerson ){	person->setText( newPerson );}void PhoneBookEditPerson::slotOk( void ){	QDialog::accept();}void PhoneBookEditPerson::slotCancel( void ){	QDialog::reject();}PhoneBookParser::PhoneBookParser( QListView * t, bool CallRegister, bool rejectedContact )	: QXmlDefaultHandler(){	rejected = 0;	listReceivedCalls = 0;	listMissedCalls = 0;	listDialledCalls = 0;	if( rejectedContact ) 		{		    rejected = new QListViewItem( t, "Permanently rejected contacts", "" );		    rejected->setOpen( TRUE );		}	if( CallRegister ) {		QListViewItem *item;		item = new QListViewItem( t, "Call Register", "" );		item->setOpen( TRUE );		listReceivedCalls = new QListViewItem( item, "Received calls", "" );		listMissedCalls = new QListViewItem( item, "Missed calls", "" );		listDialledCalls = new QListViewItem( item, "Dialled calls", "" );		}	listPhoneBook = new QListViewItem( t, "PhoneBook", "" );	listPhoneBook->setOpen( TRUE );}bool PhoneBookParser::startDocument(){	return TRUE;}bool PhoneBookParser::startElement( const QString&, const QString&,		const QString& qName,		const QXmlAttributes& attributes){	QListViewItem *element = 0;	if( qName == "person" ) {		element = new QListViewItem( listPhoneBook, attributes.value( "Name" ), "" );	}	if( element != 0 ) {		stack.push( element );	}	if( qName == "identity" ) {		QString uri = attributes.value( "uri" );		QString description = attributes.value( "description" );		if( uri.left( 4 ).lower() != "sip:" ) {			uri = "sip:" + uri;		}		QString contact = attributes.value( "contact" );		if( contact.isEmpty() ) {			contact = "No";		}		if( !stack.isEmpty() ) {			new QListViewItem( stack.top(), uri, contact, description );		}	}	return TRUE;}bool PhoneBookParser::endElement( const QString&, const QString&, const QString &qName ){	if ( qName == "person" ){		stack.pop();	}	return TRUE;}PhoneBook::PhoneBook(QString fileUserInfo, QWidget *parent, const char *name,		QList<IncomingCall> &receivedCalls, QList<IncomingCall> &missedCalls, QList<IncomingCall> &dialledCalls,		QStringList &rejectedContacts )	: QDialog( parent, name, TRUE ){	filePhoneBook = fileUserInfo;	QFile xmlFile( fileUserInfo );	QXmlInputSource source( xmlFile );	QXmlSimpleReader reader;	resize( 400, 200 );	caption = QString( name );	setCaption( QString( caption ) );	QVBoxLayout *vbox = new QVBoxLayout( this );	QGridLayout *headergrid = new QGridLayout( 3, 1 );	vbox->insertLayout( 0, headergrid );	phoneBook = new MenuListView( this );	phoneBook->addMenuItem( "Add", this, SLOT( clickAddButton() ) );	phoneBook->addMenuItem( "Edit", this, SLOT( clickEditButton() ) );	phoneBook->addMenuItem( "Remove", this, SLOT( clickRemoveButton() ) );	phoneBook->setMinimumWidth( fontMetrics().maxWidth() * 15 );	vbox->insertWidget( 1, phoneBook );	connect( phoneBook, SIGNAL( clicked( QListViewItem * ) ),		this, SLOT( setIdentity( QListViewItem * ) ) );	connect( phoneBook, SIGNAL( doubleClicked( QListViewItem * ) ),		this, SLOT( setIdentityAndDone( QListViewItem * ) ) );	phoneBook->setSorting( 0 );	phoneBook->addColumn( "Identity" );	phoneBook->addColumn( "Contact" );	phoneBook->addColumn( "Description" );	if( receivedCalls.count() == 0 && missedCalls.count() == 0  && dialledCalls.count() == 0) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -