本文整理汇总了C++中QContact::availableActions方法的典型用法代码示例。如果您正苦于以下问题:C++ QContact::availableActions方法的具体用法?C++ QContact::availableActions怎么用?C++ QContact::availableActions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContact
的用法示例。
在下文中一共展示了QContact::availableActions方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emptyContactNoActionSupport
void TestCntActions::emptyContactNoActionSupport()
{
QContact contact;
m_manager->saveContact(&contact);
//expected no actions found
QList<QContactActionDescriptor> actions = contact.availableActions();
QVERIFY(actions.count() == 0);
}
示例2: noUrlSupport
void TestCntActions::noUrlSupport()
{
QContact contact;
m_manager->saveContact(&contact);
//expected no actions found
QList<QContactActionDescriptor> actionDescriptors = contact.availableActions();
QStringList actions;
for (int i = 0;i < actionDescriptors.count();i++)
{
QString action = actionDescriptors.at(i).actionName();
actions << action;
}
QVERIFY(actions.contains("url", Qt::CaseInsensitive) == false);
}
示例3: phonenumberCallSupport
void TestCntActions::phonenumberCallSupport()
{
QContact contact;
//Add phonenumber to contact
QContactPhoneNumber number;
number.setSubTypes(QContactPhoneNumber::SubTypeMobile);
number.setNumber("555111222");
contact.saveDetail(&number);
m_manager->saveContact(&contact);
//verify that the contact has a phonenumber
QList<QContactPhoneNumber> numberList = contact.details<QContactPhoneNumber>();
QVERIFY(numberList.count() > 0);
//get the actions
QList<QContactActionDescriptor> actionDescriptors = contact.availableActions();
QStringList actions;
for (int i = 0;i < actionDescriptors.count();i++)
{
QString action = actionDescriptors.at(i).actionName();
actions << action;
}
//verify that it includes the actiosn
QVERIFY(actions.contains("call", Qt::CaseInsensitive));
//verify that the action works
QList<QContactActionDescriptor> callActionDescriptors = QContactAction::actionDescriptors("call", "symbian");
QVERIFY(callActionDescriptors.count() == 1);
QContactAction *callAction = QContactAction::action(callActionDescriptors.at(0));
QVERIFY(callAction != 0);
QContactAction::State state = callAction->state();
QVERIFY(state != QContactAction::InactiveState);
QVERIFY(callAction->isDetailSupported(numberList.at(0)) == true);
QList<QContactDetail> supportedDetails = callAction->supportedDetails(contact);
QVERIFY(supportedDetails.count() != 0);
QVariantMap variantMap = callAction->metaData();
QVERIFY(variantMap.count() == 0);
variantMap = callAction->results();
QVERIFY(variantMap.count() == 0);
QSignalSpy spyCallAction(callAction, SIGNAL(stateChanged(QContactAction::State)));
callAction->invokeAction(contact, numberList.at(0));
callAction->invokeAction(contact);
QTRY_COMPARE(spyCallAction.count(), 2); // make sure the signal was emitted exactly one time
delete callAction;
}
示例4: urlSupport
void TestCntActions::urlSupport()
{
QContact contact;
QContactUrl url;
url.setUrl("www.test.com");
contact.saveDetail(&url);
m_manager->saveContact(&contact);
//one number exist in contact
QList<QContactUrl> urlList = contact.details<QContactUrl>();
QVERIFY(urlList.count() == 1);
//no actions expected
QList<QContactActionDescriptor> actionDescriptors = contact.availableActions();
QStringList actions;
for (int i = 0;i < actionDescriptors.count();i++)
{
QString action = actionDescriptors.at(i).actionName();
actions << action;
}
QVERIFY(actions.count() == 1);
QVERIFY(actions.contains("url", Qt::CaseInsensitive));
//pick first number for the actions
QContactUrl urlAddress = contact.detail<QContactUrl>();
//Test Email action
QList<QContactActionDescriptor> urlActionDescriptors = QContactAction::actionDescriptors("url", "symbian");
QVERIFY(urlActionDescriptors.count() == 1);
QContactAction *urlAction = QContactAction::action(urlActionDescriptors.at(0));
QVERIFY(urlAction != 0);
QVERIFY(urlAction->isDetailSupported(urlList.at(0)) == true);
QList<QContactDetail> supportedDetails = urlAction->supportedDetails(contact);
QVERIFY(supportedDetails.count() != 0);
QVariantMap variantMap = urlAction->metaData();
QVERIFY(variantMap.count() == 0);
variantMap = urlAction->results();
QVERIFY(variantMap.count() == 0);
QSignalSpy spyUrlAction(urlAction, SIGNAL(stateChanged(QContactAction::State)));
urlAction->invokeAction(contact, urlAddress);
urlAction->invokeAction(contact);
QTRY_COMPARE(spyUrlAction.count(), 2); // make sure the signal was emitted exactly once each time
delete urlAction;
}
示例5: testDescriptor
void tst_QContactActions::testDescriptor()
{
// first, test retrieving an invalid action
QContactAction* invalidAction = QContactAction::action(QContactActionDescriptor());
QVERIFY(invalidAction == 0); // should be null.
QContact c;
QContactEmailAddress e;
e.setEmailAddress("[email protected]");
c.saveDetail(&e);
QContactPhoneNumber p;
p.setNumber("12345");
c.saveDetail(&p);
QVERIFY(QContactAction::availableActions().contains("SendEmail"));
QVERIFY(QContactAction::availableActions("tst_qcontactactions:sendemailaction").contains("SendEmail"));
QContactActionDescriptor sendEmailDescriptor;
QContactActionDescriptor multiActionOneDescriptor;
QContactActionDescriptor multiActionTwoDescriptor;
QList<QContactActionDescriptor> descrs = QContactAction::actionDescriptors();
QContactAction* sendEmailAction = 0;
for (int i = 0; i < descrs.size(); i++) {
QContactActionDescriptor temp = descrs.at(i);
if (temp.actionName() == QString("SendEmail")) {
sendEmailAction = QContactAction::action(temp);
QVERIFY(c.availableActions().contains(temp)); // has an email address, so should be available
QVERIFY(temp.supportsContact(c));
sendEmailDescriptor = temp;
} else if (temp.actionName() == QString("call")) {
if (temp.metaData(QString(QLatin1String("Provider"))) == QString(QLatin1String("sip"))) {
multiActionOneDescriptor = temp;
} else {
multiActionTwoDescriptor = temp;
}
}
}
QVERIFY(sendEmailDescriptor.isValid());
QVERIFY(multiActionOneDescriptor.isValid());
QVERIFY(multiActionTwoDescriptor.isValid());
QVERIFY(sendEmailAction != 0);
delete sendEmailAction;
// now test equivalence. The send email action descriptor should
// have a different action name to both multi action one and two.
QVERIFY(sendEmailDescriptor.actionName() != multiActionOneDescriptor.actionName());
QVERIFY(sendEmailDescriptor.actionName() != multiActionTwoDescriptor.actionName());
QVERIFY(sendEmailDescriptor != multiActionOneDescriptor);
QVERIFY(sendEmailDescriptor != multiActionTwoDescriptor);
// multi action one and two should have the same action name, service
// name and implementation (minor) version. BUT they have different
// implementations (Provider is different) so they should NOT be equal.
QVERIFY(multiActionOneDescriptor.actionName() == multiActionTwoDescriptor.actionName());
QVERIFY(multiActionOneDescriptor.serviceName() == multiActionTwoDescriptor.serviceName());
QVERIFY(multiActionOneDescriptor.implementationVersion() == multiActionTwoDescriptor.implementationVersion());
QVERIFY(multiActionOneDescriptor != multiActionTwoDescriptor);
// verify that the meta data is reported correctly
QVERIFY(multiActionOneDescriptor.metaData("Provider") != multiActionTwoDescriptor.metaData("Provider"));
}
示例6: contactFunctions
void tst_QContactActions::contactFunctions()
{
QContact c; // empty contact.
QContact c2; // contact with email saved.
QContact c3; // two emails
QContact c4; // two emails, plus a preference
QContact c5; // two emails, plus a preference for an unsupported detail
QContactEmailAddress e2;
QContactEmailAddress e;
e.setEmailAddress("[email protected]");
c2.saveDetail(&e);
e2.setEmailAddress("[email protected]");
c3.saveDetail(&e);
c3.saveDetail(&e2);
c4.saveDetail(&e);
c4.saveDetail(&e2);
c5.saveDetail(&e2); // reverse order for c5
c5.saveDetail(&e);
c4.setPreferredDetail("SendEmail", e2);
c5.setPreferredDetail("SendEmail", c5.detail<QContactDisplayLabel>());
// Get our descriptor
QContactActionDescriptor descriptor = QContactAction::actionDescriptors("SendEmail").value(0);
QVERIFY(descriptor.actionName() == "SendEmail");
// available actions:
// empty contact
QList<QContactActionDescriptor> availableActions = c.availableActions(QString());
QVERIFY(availableActions.isEmpty()); // should not contain SendEmail
// contact with email
availableActions = c2.availableActions(QString());
QVERIFY(!availableActions.isEmpty()); // should contain SendEmail
QVERIFY(availableActions.contains(descriptor));
// try various combinations of version and name
availableActions = c2.availableActions();
QVERIFY(!availableActions.isEmpty()); // should contain SendEmail
QVERIFY(availableActions.contains(descriptor));
availableActions = c2.availableActions("tst_qcontactactions:sendemailaction");
QVERIFY(!availableActions.isEmpty()); // should contain SendEmail
availableActions = c2.availableActions(QString());
QVERIFY(!availableActions.isEmpty()); // should contain SendEmail
QVERIFY(availableActions.contains(descriptor));
// Again with c3
availableActions = c3.availableActions(QString());
QVERIFY(!availableActions.isEmpty()); // should contain SendEmail
QVERIFY(availableActions.contains(descriptor));
// try various combinations of version and name
availableActions = c3.availableActions();
QVERIFY(!availableActions.isEmpty()); // should contain SendEmail
QVERIFY(availableActions.contains(descriptor));
availableActions = c3.availableActions("tst_qcontactactions:sendemailaction");
QVERIFY(!availableActions.isEmpty()); // should contain SendEmail
QVERIFY(availableActions.contains(descriptor));
availableActions = c3.availableActions(QString());
QVERIFY(!availableActions.isEmpty()); // should contain SendEmail
QVERIFY(availableActions.contains(descriptor));
}