diff options
| author | abcd <qt-info@nokia.com> | 2010-07-01 14:29:27 +1000 |
|---|---|---|
| committer | abcd <qt-info@nokia.com> | 2010-07-01 14:29:27 +1000 |
| commit | e22faf8d534d2c6edebd9fdd9377cf7ec9e5db9b (patch) | |
| tree | 16ce6d9b345909642042495113df397a3e92bdb9 /doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp | |
| parent | 45dbd90d41dff1315d1bdf6178a2e18deb0fd78e (diff) | |
| parent | d342c087d0219e7e1a7283332778785ba9825367 (diff) | |
Merge remote branch 'remotes/qtmobility-master/master'
Diffstat (limited to 'doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp')
| -rw-r--r-- | doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp b/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp index 5dee651f9c..9ddd6775c2 100644 --- a/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp +++ b/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp @@ -55,6 +55,7 @@ static void queryManagerCapabilities(); static void contactDetailManipulation(); static void contactManipulation(); static void addContact(QContactManager*); +static void callContact(QContactManager*); static void matchCall(QContactManager*, const QString&); static void viewSpecificDetail(QContactManager*); static void viewDetails(QContactManager*); @@ -73,6 +74,7 @@ int stopCompilerWarnings() // synchronous API examples QContactManager* cm = new QContactManager(); addContact(cm); + callContact(cm); matchCall(cm, "111-222-333"); // unknown number. matchCall(cm, "12345678"); // alice's number. viewSpecificDetail(cm); @@ -291,6 +293,7 @@ void addContact(QContactManager* cm) number.setSubTypes(QContactPhoneNumber::SubTypeMobile); number.setNumber("12345678"); alice.saveDetail(&number); + alice.setPreferredDetail("DialAction", number); /* Add a second phone number */ QContactPhoneNumber number2; @@ -306,6 +309,30 @@ void addContact(QContactManager* cm) } //! [Creating a new contact] +void callContact(QContactManager* cm) +{ + QList<QContactLocalId> contactIds = cm->contactIds(); + QContact a = cm->contact(contactIds.first()); + + /* Get this contact's first phone number */ + QContact contact; + + //! [Details with action] + // Get the first "Call" action + QContactAction* action = QContactAction::action(QContactAction::actionDescriptors("Call").value(0)); + QList<QContactDetail> details = contact.detailsWithAction(action); + + if (details.count() == 0) { + // Can't call this contact + } else if (details.count() == 1) { + // Just call this specific detail + action->invokeAction(contact, details.first()); + } else { + // Offer the user the choice of details to call + // ... + } + //! [Details with action] +} //! [Filtering by definition and value] void matchCall(QContactManager* cm, const QString& incomingCallNbr) |
