summaryrefslogtreecommitdiffstats
path: root/kmail/newfolderdialog.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-01 00:37:02 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-01 00:37:02 +0000
commitcc29364f06178f8f6b457384f2ec37a042bd9d43 (patch)
tree7c77a3184c698bbf9d98cef09fb1ba8124daceba /kmail/newfolderdialog.cpp
parent4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff)
downloadtdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz
tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip
* Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch
* Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed * Added journal read support to the CalDAV resource * Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmail/newfolderdialog.cpp')
-rw-r--r--kmail/newfolderdialog.cpp102
1 files changed, 22 insertions, 80 deletions
diff --git a/kmail/newfolderdialog.cpp b/kmail/newfolderdialog.cpp
index 78294e5f9..99051222e 100644
--- a/kmail/newfolderdialog.cpp
+++ b/kmail/newfolderdialog.cpp
@@ -40,6 +40,7 @@
#include <kdialogbase.h>
#include <kmessagebox.h>
+#include "folderutil.h"
#include "newfolderdialog.h"
#include "kmfolder.h"
#include "folderstorage.h"
@@ -58,6 +59,9 @@ NewFolderDialog::NewFolderDialog( TQWidget* parent, KMFolder *folder )
: KDialogBase( parent, "new_folder_dialog", false, i18n( "New Folder" ),
KDialogBase::Ok|KDialogBase::Cancel,
KDialogBase::Ok, true ),
+ mFormatComboBox( 0 ),
+ mContentsComboBox( 0 ),
+ mNamespacesComboBox( 0 ),
mFolder( folder )
{
setWFlags( getWFlags() | WDestructiveClose );
@@ -112,7 +116,8 @@ NewFolderDialog::NewFolderDialog( TQWidget* parent, KMFolder *folder )
}
// --- contents -----
- if ( kmkernel->iCalIface().isEnabled() ) {
+ if ( kmkernel->iCalIface().isEnabled() &&
+ mFolder && mFolder->folderType() != KMFolderTypeImap ) {
mContentsHBox = new TQHBoxLayout( 0, 0, 6, "mContentsHBox");
mContentsLabel = new TQLabel( privateLayoutWidget, "mContentsLabel" );
@@ -190,41 +195,12 @@ void NewFolderDialog::slotOk()
return;
}
- // names of local folders must not contain a '/'
- if ( fldName.find( '/' ) != -1 &&
- ( !mFolder ||
- ( mFolder->folderType() != KMFolderTypeImap &&
- mFolder->folderType() != KMFolderTypeCachedImap ) ) ) {
- KMessageBox::error( this, i18n( "Folder names cannot contain the / (slash) character; please choose another folder name." ) );
+ TQString msg;
+ if ( mFolder && !mFolder->isValidName( fldName, msg ) ) {
+ KMessageBox::error( this, msg );
return;
}
- // folder names must not start with a '.'
- if ( fldName.startsWith( "." ) ) {
- KMessageBox::error( this, i18n( "Folder names cannot start with a . (dot) character; please choose another folder name." ) );
- return;
- }
-
- // names of IMAP folders must not contain the folder delimiter
- if ( mFolder &&
- ( mFolder->folderType() == KMFolderTypeImap ||
- mFolder->folderType() == KMFolderTypeCachedImap ) ) {
- TQString delimiter;
- if ( mFolder->folderType() == KMFolderTypeImap ) {
- KMAcctImap* ai = static_cast<KMFolderImap*>( mFolder->storage() )->account();
- if ( ai )
- delimiter = ai->delimiterForFolder( mFolder->storage() );
- } else {
- KMAcctCachedImap* ai = static_cast<KMFolderCachedImap*>( mFolder->storage() )->account();
- if ( ai )
- delimiter = ai->delimiterForFolder( mFolder->storage() );
- }
- if ( !delimiter.isEmpty() && fldName.find( delimiter ) != -1 ) {
- KMessageBox::error( this, i18n( "Your IMAP server does not allow the character '%1'; please choose another folder name." ).arg( delimiter ) );
- return;
- }
- }
-
// default parent is Top Level local folders
KMFolderDir * selectedFolderDir = &(kmkernel->folderMgr()->dir());
// we got a parent, let's use that
@@ -245,55 +221,21 @@ void NewFolderDialog::slotOk()
/* Ok, obvious errors caught, let's try creating it for real. */
const TQString message = i18n( "<qt>Failed to create folder <b>%1</b>."
"</qt> " ).arg(fldName);
- bool success = false;
- KMFolder *newFolder = 0;
- if ( mFolder && mFolder->folderType() == KMFolderTypeImap ) {
- KMFolderImap* selectedStorage = static_cast<KMFolderImap*>( mFolder->storage() );
- KMAcctImap *anAccount = selectedStorage->account();
- // check if a connection is available BEFORE creating the folder
- if (anAccount->makeConnection() == ImapAccountBase::Connected) {
- newFolder = kmkernel->imapFolderMgr()->createFolder( fldName, false, KMFolderTypeImap, selectedFolderDir );
- if ( newFolder ) {
- TQString imapPath, parent;
- if ( mNamespacesComboBox ) {
- // create folder with namespace
- parent = anAccount->addPathToNamespace( mNamespacesComboBox->currentText() );
- imapPath = anAccount->createImapPath( parent, fldName );
- } else {
- imapPath = anAccount->createImapPath( selectedStorage->imapPath(), fldName );
- }
- KMFolderImap* newStorage = static_cast<KMFolderImap*>( newFolder->storage() );
- selectedStorage->createFolder(fldName, parent); // create it on the server
- newStorage->initializeFrom( selectedStorage, imapPath, TQString::null );
- static_cast<KMFolderImap*>(mFolder->storage())->setAccount( selectedStorage->account() );
- success = true;
- }
- }
- } else if ( mFolder && mFolder->folderType() == KMFolderTypeCachedImap ) {
- newFolder = kmkernel->dimapFolderMgr()->createFolder( fldName, false, KMFolderTypeCachedImap, selectedFolderDir );
- if ( newFolder ) {
- KMFolderCachedImap* selectedStorage = static_cast<KMFolderCachedImap*>( mFolder->storage() );
- KMFolderCachedImap* newStorage = static_cast<KMFolderCachedImap*>( newFolder->storage() );
- newStorage->initializeFrom( selectedStorage );
- if ( mNamespacesComboBox ) {
- // create folder with namespace
- TQString path = selectedStorage->account()->createImapPath(
- mNamespacesComboBox->currentText(), fldName );
- newStorage->setImapPathForCreation( path );
- }
- success = true;
- }
- } else {
- // local folder
- if (mFormatComboBox->currentItem() == 1)
- newFolder = kmkernel->folderMgr()->createFolder(fldName, false, KMFolderTypeMaildir, selectedFolderDir );
- else
- newFolder = kmkernel->folderMgr()->createFolder(fldName, false, KMFolderTypeMbox, selectedFolderDir );
- if ( newFolder )
- success = true;
+ TQString namespaceName;
+ if ( mNamespacesComboBox ) {
+ namespaceName = mNamespacesComboBox->currentText();
}
- if ( !success ) {
+
+ KMFolderType folderType = KMFolderTypeUnknown;
+ if ( mFormatComboBox && mFormatComboBox->currentItem() == 1 )
+ folderType = KMFolderTypeMaildir;
+ else if ( mFormatComboBox )
+ folderType = KMFolderTypeMbox;
+
+ KMFolder *newFolder = KMail::FolderUtil::createSubFolder( mFolder, selectedFolderDir, fldName,
+ namespaceName, folderType );
+ if ( !newFolder ) {
KMessageBox::error( this, message );
return;
}