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

📄 contact.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    // business address    if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||	 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {	text += "<br>";	text += qApp->translate( "Contact",  "<b>Work Address:</b>" );	text +=  "<br>";    }    if ( !(value = businessStreet()).isEmpty() )	text += Qtopia::escapeString(value) + "<br>";    state =  businessState();    if ( !(value = businessCity()).isEmpty() ) {	text += Qtopia::escapeString(value);	if ( state )	    text += ", " + Qtopia::escapeString(state);	text += "<br>";    } else if ( !state.isEmpty() )	text += Qtopia::escapeString(state) + "<br>";    if ( !(value = businessZip()).isEmpty() )	text += Qtopia::escapeString(value) + "<br>";    if ( !(value = businessCountry()).isEmpty() )	text += Qtopia::escapeString(value) + "<br>";    // home address    if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||	 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {	text += "<br>";	text += qApp->translate( "Contact",  "<b>Home Address:</b>" );	text +=  "<br>";    }    if ( !(value = homeStreet()).isEmpty() )	text += Qtopia::escapeString(value) + "<br>";    state =  homeState();    if ( !(value = homeCity()).isEmpty() ) {	text += Qtopia::escapeString(value);	if ( !state.isEmpty() )	    text += ", " + Qtopia::escapeString(state);	text += "<br>";    } else if (!state.isEmpty())	text += Qtopia::escapeString(state) + "<br>";    if ( !(value = homeZip()).isEmpty() )	text += Qtopia::escapeString(value) + "<br>";    if ( !(value = homeCountry()).isEmpty() )	text += Qtopia::escapeString(value) + "<br>";    // the others...    QString str;    str = emails();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Email Addresses: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = homePhone();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Home Phone: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = homeFax();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Home Fax: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = homeMobile();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Home Mobile: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = homeWebpage();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Home Web Page: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = businessWebpage();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Business Web Page: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = office();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Office: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = businessPhone();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Business Phone: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = businessFax();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Business Fax: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = businessMobile();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Business Mobile: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = businessPager();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Business Pager: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = profession();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Profession: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = assistant();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Assistant: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = manager();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Manager: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = gender();    if ( !str.isEmpty() && str.toInt() != 0 ) {	if ( str.toInt() == 1 )	    str = qApp->translate( "Contact",  "Male" );	else if ( str.toInt() == 2 )	    str = qApp->translate( "Contact",  "Female" );	text += "<b>" + qApp->translate( "Contact", "Gender: ") + "</b>" + str + "<br>";    }    str = spouse();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Spouse: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = birthday();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Birthday: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = anniversary();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Anniversary: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    str = nickname();    if ( !str.isEmpty() )	text += "<b>" + qApp->translate( "Contact", "Nickname: ") + "</b>"		+ Qtopia::escapeString(str) + "<br>";    // notes last XXX change 113673 was evil.    // but as escape string isn't good for notes either, and since    // this function should only be used to show owner information    // from the password dialog... just don't show the notes.    // doesn't make sense if just showing who owns the device.    // every other place showing contact info should use qpepim.    /*    if ( (value = notes()) ) {	text += "<br>" + Qtopia::escapeString(value) + "<br>";    }    */    return text;}/*  \internal*/void Contact::insert( int key, const QString &v ){    QString value = v.stripWhiteSpace();    if ( value.isEmpty() )	mMap.remove( key );    else	mMap.insert( key, value );}/*  \internal*/void Contact::replace( int key, const QString & v ){    QString value = v.stripWhiteSpace();    if ( value.isEmpty() )	mMap.remove( key );    else	mMap.replace( key, value );}/*  \internal*/QString Contact::find( int key ) const{    return mMap[key];}/*  \internal*/QString Contact::displayAddress( const QString &street,				 const QString &city,				 const QString &state,				 const QString &zip,				 const QString &country ) const{    QString s = street;    if ( !street.isEmpty() )	s+= "\n";    s += city;    if ( !city.isEmpty() && !state.isEmpty() )	s += ", ";    s += state;    if ( !state.isEmpty() && !zip.isEmpty() )	s += "  ";    s += zip;    if ( !country.isEmpty() && !s.isEmpty() )	s += "\n";    s += country;    return s;}/*  \internal*/QString Contact::displayBusinessAddress() const{    return displayAddress( businessStreet(), businessCity(),			   businessState(), businessZip(),			   businessCountry() );}/*  \internal*/QString Contact::displayHomeAddress() const{    return displayAddress( homeStreet(), homeCity(),			   homeState(), homeZip(),			   homeCountry() );}/*  Returns the full name of the contact*/QString Contact::fullName() const{    QString title = find( Qtopia::Title );    QString firstName = find( Qtopia::FirstName );    QString middleName = find( Qtopia::MiddleName );    QString lastName = find( Qtopia::LastName );    QString suffix = find( Qtopia::Suffix );    QString name = title;    if ( !firstName.isEmpty() ) {	if ( !name.isEmpty() )	    name += " ";	name += firstName;    }    if ( !middleName.isEmpty() ) {	if ( !name.isEmpty() )	    name += " ";	name += middleName;    }    if ( !lastName.isEmpty() ) {	if ( !name.isEmpty() )	    name += " ";	name += lastName;    }    if ( !suffix.isEmpty() ) {	if ( !name.isEmpty() )	    name += " ";	name += suffix;    }    return name.simplifyWhiteSpace();}/*  Returns a list of the names of the children of the contact.*/QStringList Contact::childrenList() const{    return QStringList::split( " ", find( Qtopia::Children ) );}/* \fn void Contact::insertEmail( const QString &email )  Insert \a email into the email list. Ensures \a email can only be added  once. If there is no default email address set, it sets it to the \a email.*//* \fn void Contact::removeEmail( const QString &email )  Removes the \a email from the email list. If the default email was \a email,  then the default email address is assigned to the first email in the  email list*//* \fn void Contact::clearEmails()  Clears the email list. *//* \fn void Contact::insertEmails( const QStringList &emailList )  Appends the \a emailList to the exiting email list *//*  Returns a list of email addresses belonging to the contact, including  the default email address.*/QStringList Contact::emailList() const{    QString emailStr = emails();    QStringList r;    if ( !emailStr.isEmpty() ) {	qDebug(" emailstr ");	QStringList l = QStringList::split( emailSeparator(), emailStr );	for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )	    r += (*it).simplifyWhiteSpace();    }    return r;}/*  \overload  Generates the string for the contact to be filed as from the first,  middle and last name of the contact.*/void Contact::setFileAs(){    QString lastName, firstName, middleName, fileas;    lastName = find( Qtopia::LastName );    firstName = find( Qtopia::FirstName );    middleName = find( Qtopia::MiddleName );    if ( !lastName.isEmpty() && !firstName.isEmpty()	 && !middleName.isEmpty() )	fileas = lastName + ", " + firstName + " " + middleName;    else if ( !lastName.isEmpty() && !firstName.isEmpty() )	fileas = lastName + ", " + firstName;    else if ( !lastName.isEmpty() || !firstName.isEmpty() ||	      !middleName.isEmpty() )	fileas = firstName + ( firstName.isEmpty() ? "" : " " )		 + middleName + ( middleName.isEmpty() ? "" : " " )		 + lastName;    replace( Qtopia::FileAs, fileas );}/*  \internal  Appends the contact information to \a buf.*/void Contact::save( QString &buf ) const{    static const QStringList SLFIELDS = fields();    // I'm expecting "<Contact " in front of this...    for ( QMap<int, QString>::ConstIterator it = mMap.begin();	  it != mMap.end(); ++it ) {	const QString &value = it.data();	int key = it.key();	if ( !value.isEmpty() ) {	    if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)		continue;	    key -= Qtopia::AddressCategory+1;	    buf += SLFIELDS[key];	    buf += "=\"" + Qtopia::escapeString(value) + "\" ";	}    }    buf += customToXml();    if ( categories().count() > 0 )	buf += "Categories=\"" + idsToString( categories() ) + "\" "; // No tr    buf += "Uid=\"" + QString::number( uid() ) + "\" ";    // You need to close this yourself}/*  \internal  Returns the list of fields belonging to a contact*/QStringList Contact::fields(){    QStringList list;    list.append( "Title" );  // No tr; Not Used!    list.append( "FirstName" );    list.append( "MiddleName" );    list.append( "LastName" );    list.append( "Suffix" ); // No tr    list.append( "FileAs" );    list.append( "JobTitle" );    list.append( "Department" ); // No tr    list.append( "Company" ); // No tr    list.append( "BusinessPhone" );    list.append( "BusinessFax" );    list.append( "BusinessMobile" );    list.append( "DefaultEmail" );    list.append( "Emails" );    list.append( "HomePhone" );    list.append( "HomeFax" );    list.append( "HomeMobile" );    list.append( "BusinessStreet" );    list.append( "BusinessCity" );    list.append( "BusinessState" );    list.append( "BusinessZip" );    list.append( "BusinessCountry" );    list.append( "BusinessPager" );    list.append( "BusinessWebPage" );    list.append( "Office" ); // No tr    list.append( "Profession" ); // No tr    list.append( "Assistant" ); // No tr    list.append( "Manager" ); // No tr    list.append( "HomeStreet" );    list.append( "HomeCity" );    list.append( "HomeState" );    list.append( "HomeZip" );    list.append( "HomeCountry" );    list.append( "HomeWebPage" );    list.append( "Spouse" ); // No tr    list.append( "Gender" ); // No tr    list.append( "Birthday" ); // No tr    list.append( "Anniversary" ); // No tr    list.append( "Nickname" ); // No tr    list.append( "Children" ); // No tr    list.append( "Notes" ); // No tr    list.append( "Groups" ); // No tr    return list;}/*  \internal  Returns a translated list of field names for a contact.*/QStringList Contact::trfields(){    QStringList list;    list.append( qApp->translate( "Contact",  "Name Title") );    list.append( qApp->translate( "Contact",  "First Name" ) );    list.append( qApp->translate( "Contact",  "Middle Name" ) );    list.append( qApp->translate( "Contact",  "Last Name" ) );    list.append( qApp->translate( "Contact",  "Suffix" ) );    list.append( qApp->translate( "Contact",  "File As" ) );    list.append( qApp->translate( "Contact",  "Job Title" ) );    list.append( qApp->translate( "Contact",  "Department" ) );    list.append( qApp->translate( "Contact",  "Company" ) );    list.append( qApp->translate( "Contact",  "Business Phone" ) );    list.append( qApp->translate( "Contact",  "Business Fax" ) );    list.append( qApp->translate( "Contact",  "Business Mobile" ) );    list.append( qApp->translate( "Contact",  "Default Email" ) );    list.append( qApp->translate( "Contact",  "Emails" ) );    list.append( qApp->translate( "Contact",  "Home Phone" ) );    list.append( qApp->translate( "Contact",  "Home Fax" ) );    list.append( qApp->translate( "Contact",  "Home Mobile" ) );    list.append( qApp->translate( "Contact",  "Business Street" ) );    list.append( qApp->translate( "Contact",  "Business City" ) );    list.append( qApp->translate( "Contact",  "Business State" ) );    list.append( qApp->translate( "Contact",  "Business Zip" ) );    list.append( qApp->translate( "Contact",  "Business Country" ) );    list.append( qApp->translate( "Contact",  "Business Pager" ) );    list.append( qApp->translate( "Contact",  "Business WebPage" ) );    list.append( qApp->translate( "Contact",  "Office" ) );    list.append( qApp->translate( "Contact",  "Profession" ) );    list.append( qApp->translate( "Contact",  "Assistant" ) );    list.append( qApp->translate( "Contact",  "Manager" ) );    list.append( qApp->translate( "Contact",  "Home Street" ) );    list.append( qApp->translate( "Contact",  "Home City" ) );    list.append( qApp->translate( "Contact",  "Home State" ) );    list.append( qApp->translate( "Contact",  "Home Zip" ) );    list.append( qApp->translate( "Contact",  "Home Country" ) );    list.append( qApp->translate( "Contact",  "Home Web Page" ) );    list.append( qApp->translate( "Contact",  "Spouse" ) );    list.append( qApp->translate( "Contact",  "Gender" ) );    list.append( qApp->translate( "Contact",  "Birthday" ) );    list.append( qApp->translate( "Contact",  "Anniversary" ) );    list.append( qApp->translate( "Contact",  "Nickname" ) );    list.append( qApp->translate( "Contact",  "Children" ) );    list.append( qApp->translate( "Contact",  "Notes" ) );    list.append( qApp->translate( "Contact",  "Groups" ) );    return list;}/*  Sets the list of email address for contact to those contained in \a str.

⌨️ 快捷键说明

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