Merged revisions 964931 via svnmerge from

svn+ssh://tmcguire@svn.kde.org/home/kde/branches/kdepim/enterprise4/kdepim

................
  r964931 | tmcguire | 2009-05-07 19:08:04 +0200 (Thu, 07 May 2009) | 12 lines
  
  Merged revisions 964916 via svnmerge from 
  svn+ssh://tmcguire@svn.kde.org/home/kde/branches/kdepim/enterprise/kdepim
  
  ........
    r964916 | tmcguire | 2009-05-07 18:33:52 +0200 (Thu, 07 May 2009) | 5 lines
    
    When there is a folder dir without an associated folder, recreate the folder so that the subfolders
    don't get lost.
    
    Fixes kolab/issue2972.
  ........
................

svn path=/trunk/KDE/kdepim/; revision=967423
wilder-work
Thomas McGuire 17 years ago
parent 24efb48fa5
commit 42c9130c2b
  1. 4
      kmfoldercachedimap.cpp
  2. 59
      kmfolderdir.cpp
  3. 5
      kmfolderdir.h

@ -144,7 +144,7 @@ DImapTroubleShootDialog::DImapTroubleShootDialog( QWidget *parent )
mIndexButton = new QRadioButton( page );
mIndexButton->setText( i18n( "Rebuild &index" ) );
mButtonGroup->addButton( mIndexButton );
mButtonGroup->addButton( mIndexButton, 1 );
topLayout->addWidget( mIndexButton );
KHBox *hbox = new KHBox( page );
@ -160,7 +160,7 @@ DImapTroubleShootDialog::DImapTroubleShootDialog( QWidget *parent )
mCacheButton = new QRadioButton( page );
mCacheButton->setText( i18n( "Refresh &Cache" ) );
mButtonGroup->addButton( mCacheButton );
mButtonGroup->addButton( mCacheButton, 2 );
topLayout->addWidget( mCacheButton );
connect ( mIndexButton, SIGNAL( toggled( bool ) ),

@ -168,6 +168,31 @@ QString KMFolderDir::prettyUrl() const
return label();
}
//-----------------------------------------------------------------------------
void KMFolderDir::addDirToParent( const QString &dirName, KMFolder *parentFolder )
{
KMFolderDir* folderDir = new KMFolderDir( parentFolder, this, dirName, mDirType);
folderDir->reload();
append( folderDir );
parentFolder->setChild( folderDir );
}
// Get the default folder type of the given dir type. This function should only be used when
// needing to find out what the folder type of a missing folder is.
KMFolderType dirTypeToFolderType( KMFolderDirType dirType )
{
switch( dirType ) {
// Use maildir for normal folder dirs, as this function is only called when finding a dir
// without a parent folder, which can only happen with maildir-like folders
case KMStandardDir: return KMFolderTypeMaildir;
case KMImapDir: return KMFolderTypeImap;
case KMDImapDir: return KMFolderTypeCachedImap;
case KMSearchDir: return KMFolderTypeSearch;
default: Q_ASSERT( false ); return KMFolderTypeMaildir;
}
}
//-----------------------------------------------------------------------------
bool KMFolderDir::reload(void)
@ -291,20 +316,42 @@ bool KMFolderDir::reload(void)
}
}
QSet<QString> dirsWithoutFolder = dirs;
foreach ( KMFolder* folder, folderList )
{
if ( dirs.contains( '.' + folder->fileName() + ".directory" ) )
const QString dirName = '.' + folder->fileName() + ".directory";
if ( dirs.contains( dirName ) )
{
KMFolderDir* folderDir = new KMFolderDir( folder, this, '.' + folder->fileName() + ".directory", mDirType );
folderDir->reload();
append(folderDir);
folder->setChild(folderDir);
dirsWithoutFolder.remove( dirName );
addDirToParent( dirName, folder );
}
}
// Check if the are any dirs without an associated folder. This can happen if the user messes
// with the on-disk folder structure, see kolab issue 2972. In that case, we don't want to loose
// the subfolders as well, so we recreate the folder so the folder/dir hierachy is OK again.
foreach ( const QString &dirName, dirsWithoutFolder ) {
// .foo.directory => foo
QString folderName = dirName;
int right = folderName.indexOf( ".directory" );
int left = folderName.indexOf( "." );
Q_ASSERT( left != -1 && right != -1 );
folderName = folderName.mid( left + 1, right - 1 );
kWarning() << "Found dir without associated folder:" << dirName << ", recreating the folder"
<< folderName;
// Recreate the missing folder
KMFolder *folder = new KMFolder( this, folderName, KMFolderTypeCachedImap );
append( folder );
folderList.append( folder );
addDirToParent( dirName, folder );
}
return true;
}
//-----------------------------------------------------------------------------
KMFolderNode* KMFolderDir::hasNamedFolder(const QString& aName)
{

@ -25,6 +25,11 @@ public:
virtual bool isDir() const { return true; }
/**
* Adds the given subdirectory of this directory to the associated folder.
*/
void addDirToParent( const QString &dirName, KMFolder *parentFolder );
/** Read contents of directory. */
virtual bool reload();

Loading…
Cancel
Save