QAction *ShortcutsHandler::addAction( const QString &id, const QString &text, const KShortcut &shortcut ) { #ifdef KHOTKEYS_TRACE kDebug() << id << text << shortcut; #endif QString realId(id); // HACK: Do this correctly. Remove uuid on importing / exporting // On import it can happen that id is already taken. Create it under a // different name then. if (_actions->action(id)) { qDebug() << id << " already present. Using new id!"; realId = QUuid::createUuid().toString(); } // Create the action QAction *newAction = _actions->addAction(realId); if (!newAction) { return 0; } // If our HandlerType is configuration we have to tell kdedglobalaccel // that this action is only for configuration purposes. // see KAction::~KAction if (_type==Configuration) { newAction->setProperty("isConfigurationAction", QVariant(true)); } newAction->setText(text); KGlobalAccel::self()->setDefaultShortcut(newAction, QList<QKeySequence>() << shortcut.primary()); // Enable global shortcut. If that fails there is no sense in proceeding if (!KGlobalAccel::self()->hasShortcut(newAction)) { kWarning() << "Failed to enable global shortcut for '" << text << "' " << id; _actions->removeAction(newAction); return 0; } Q_ASSERT(newAction->isEnabled()); return newAction; }
void CSyncTestStep::WriteContactToICCL(TContactICCEntry& aIccEntry, TRequestStatus& aStatus) /** * This method writes the phonebook data passed in the aIccEntry parameter to the ICC. */ { CContactDatabase *ContactsDb=NULL; TRAPD(err,ContactsDb=CContactDatabase::OpenL()); // First try to open existing database if (err != KErrNone) { TRAP(err,CContactDatabase::CreateL()); // There is no existing database, so create default one if (err == KErrNone) ContactsDb=CContactDatabase::OpenL(); // Open new database } CleanupStack::PushL(ContactsDb); TContactItemId id = ContactsDb->ICCTemplateIdL(); CContactItem* iccTemplate = ContactsDb->ReadContactL(id); CleanupStack::PushL(iccTemplate); CContactICCEntry* item; // If an overwrite is being attempted then ensure an entry with relevant UID is used if (aIccEntry.iContactUID > 0) { TContactItemId realId(GetValidUIDFromContactsDbL()); item = static_cast<CContactICCEntry*> (ContactsDb->ReadContactL(realId)); } else { item = CContactICCEntry::NewL(*iccTemplate); // Create an ICC entry } CleanupStack::PopAndDestroy(iccTemplate); CleanupStack::PushL(item); // Create phone number field TBuf<RMobilePhone::KMaxMobileTelNumberSize> number; if(aIccEntry.iTON==RMobilePhone::EInternationalNumber) number.Append(KInternationalPrefix); // Append '+' prefix if International Number number.Append(aIccEntry.iNumber); AddTextFieldToIccContactL(KStorageTypeText, KUidContactFieldPhoneNumber, KUidContactFieldVCardMapTEL, number, item); // Create name field TBuf<TContactICCEntry::KMaxPhBkNameSize> name; name.Copy(aIccEntry.iName); AddTextFieldToIccContactL(KStorageTypeText, KUidContactFieldFamilyName, KUidContactFieldVCardMapUnusedN, name, item); if(aIccEntry.iSlotNum!=KSyncIndexNotSupplied) // it is not a new entry so slot number is supplied { // Create slot number field HBufC* buf = HBufC::NewL(5); TPtr indexPtr(buf->Des()); indexPtr.AppendNum(aIccEntry.iSlotNum); TPtrC indexPtrC = indexPtr.Mid(0); AddTextFieldToIccContactL(KStorageTypeText, KUidContactFieldICCSlot, KUidContactFieldVCardMapNotRequired, indexPtrC, item); delete buf; } // Send a Write-Contact-ICC request TRequestStatus status; iSession.WriteContact(status, *item, aIccEntry.iSlotNum); User::WaitForRequest(status); aStatus = status; CleanupStack::PopAndDestroy(2); // item and ContactsDb }