KMFolderDir* KMFolder::createChildFolder() { if ( mChild ) { return mChild; } QString childName = '.' + fileName() + ".directory"; QString childDir = path() + '/' + childName; if ( access( QFile::encodeName( childDir ), W_OK ) != 0 ) { // childDir does not exist or is not writable, so create it. if ( KDE_mkdir( QFile::encodeName(childDir), S_IRWXU ) != 0 && chmod( QFile::encodeName(childDir), S_IRWXU) != 0 ) { QString wmsg = QString( " '%1': %2" ).arg( childDir ).arg( strerror( errno ) ); KMessageBox::information( 0, i18n( "Failed to create folder" ) + wmsg ); return 0; } } KMFolderDirType newType = KMStandardDir; if ( folderType() == KMFolderTypeCachedImap ) { newType = KMDImapDir; } else if ( folderType() == KMFolderTypeImap ) { newType = KMImapDir; } mChild = new KMFolderDir( this, parent(), childName, newType ); if( !mChild ) return 0; mChild->reload(); parent()->append( mChild ); return mChild; }
void KMFolder::setUserWhoField( const QString& whoField, bool writeConfig ) { if ( mUserWhoField == whoField && !whoField.isEmpty() ) return; if ( whoField.isEmpty() ) { // default setting const KPIMIdentities::Identity & identity = kmkernel->identityManager()->identityForUoidOrDefault( mIdentity ); QString identityfcc, identitydrafts, identitytemplates; { /* KPIMIdentities::Identity::fcc(), KPIMIdentities::Identity::drafts() and KPIMIdentities::Identity::templates() using akonadi, so read values from config file directly */ const KConfig config( "emailidentities" ); const QStringList identities = config.groupList().filter( QRegExp( "^Identity #\\d+$" ) ); for ( QStringList::const_iterator group = identities.constBegin(); group != identities.constEnd(); ++group ) { const KConfigGroup configGroup( &config, *group ); if ( configGroup.readEntry( "uoid", 0U ) == identity.uoid() ) { identityfcc = configGroup.readEntry( "Fcc2", QString() ); identitydrafts = configGroup.readEntry( "Drafts2", QString() ); identitytemplates = configGroup.readEntry( "Templates2", QString() ); break; } } } if ( isSystemFolder() && folderType() != KMFolderTypeImap ) { // local system folders if ( this == kmkernel->inboxFolder() || this == kmkernel->trashFolder() ) mWhoField = "From"; if ( this == kmkernel->outboxFolder() || this == kmkernel->sentFolder() || this == kmkernel->templatesFolder() || this == kmkernel->draftsFolder() ) mWhoField = "To"; } else if ( identitydrafts == idString() || identitytemplates == idString() || identityfcc == idString() ) // drafts, templates or sent of the identity mWhoField = "To"; else mWhoField = "From"; } else if ( whoField == "From" || whoField == "To" ) // set the whoField according to the user-setting mWhoField = whoField; else { // this should not happen... kDebug() << "Illegal setting" << whoField << "for userWhoField!"; return; // don't use the value } mUserWhoField = whoField; if ( writeConfig ) { mStorage->writeConfig(); emit viewConfigChanged(); } }
void FolderListModel::setCurrentFolderIdx(int folderIdx) { if (folderIdx >= m_folderList.count()) { qCWarning(lcGeneral) << Q_FUNC_INFO << " Can't set Invalid Index: " << folderIdx; } if (folderIdx != m_currentFolderIdx) { m_currentFolderIdx = folderIdx; m_currentFolderType = static_cast<FolderListModel::FolderStandardType>(folderType(m_currentFolderIdx).toInt()); m_currentFolderUnreadCount = folderUnreadCount(m_currentFolderIdx); m_currentFolderId = QMailFolderId(folderId(m_currentFolderIdx)); emit currentFolderIdxChanged(); emit currentFolderUnreadCountChanged(); } }
/** * Create an Umbrello object from a PetalNode of the UseCase, Component, * or Deployment View. * * @return True for success. * Given a PetalNode for which the mapping to Umbrello is not yet * implemented umbrellify() is a no-op but also returns true. */ bool umbrellify(PetalNode *node, const QString& modelsName, UMLListViewItem *parent) { if (node == NULL) { uError() << "umbrellify(" << modelsName << "): node is NULL"; return false; } QStringList args = node->initialArgs(); QString objType = args[0]; QString name = clean(args[1]); Uml::IDType id = quid(node); UMLObject *obj = NULL; UMLListViewItem *item = NULL; if (objType == "Class_Category") { UMLListViewItem::ListViewType lvType = folderType(parent); item = new UMLListViewItem( parent, name, lvType, id ); } else if (objType == "Class") { QString stereotype = clean(node->findAttribute("stereotype").string); if (stereotype == "Actor") { UMLActor *act = new UMLActor(name, id); item = new UMLListViewItem(parent, name, UMLListViewItem::lvt_Actor, act); obj = act; } else { uDebug() << "umbrellify(" << name << "): handling of Class stereotype " << stereotype << " is not yet implemented"; } } else if (objType == "UseCase") { UMLUseCase *uc = new UMLUseCase(name, id); item = new UMLListViewItem(parent, name, UMLListViewItem::lvt_UseCase, uc); obj = uc; } else if (objType == "SubSystem") { UMLComponent *comp = new UMLComponent(name, id); item = new UMLListViewItem(parent, name, UMLListViewItem::lvt_Component, comp); obj = comp; } else if (objType == "Processor" || objType == "Device") { UMLNode *un = new UMLNode(name, id); un->setStereotype(objType.toLower()); item = new UMLListViewItem(parent, name, UMLListViewItem::lvt_Node, un); obj = un; } else { uDebug() << "umbrellify: object type " << objType << " is not yet implemented"; return true; } PetalNode *models = node->findAttribute(modelsName).node; if (models) { PetalNode::NameValueList atts = models->attributes(); for (int i = 0; i < atts.count(); ++i) { if (! umbrellify(atts[i].second.node, modelsName, item)) return false; } } if (obj) { QString doc = node->findAttribute("documentation").string; if (! doc.isEmpty()) obj->setDoc(doc); UMLDoc *theDocument = UMLApp::app()->document(); theDocument->addUMLObject(obj); } return true; }