diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
commit | cc29364f06178f8f6b457384f2ec37a042bd9d43 (patch) | |
tree | 7c77a3184c698bbf9d98cef09fb1ba8124daceba /kmail/importarchivedialog.cpp | |
parent | 4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff) | |
download | tdepim-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/importarchivedialog.cpp')
-rw-r--r-- | kmail/importarchivedialog.cpp | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/kmail/importarchivedialog.cpp b/kmail/importarchivedialog.cpp new file mode 100644 index 000000000..bdae8054d --- /dev/null +++ b/kmail/importarchivedialog.cpp @@ -0,0 +1,107 @@ +/* Copyright 2009 Klarälvdalens Datakonsult AB + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License or (at your option) version 3 or any later version + accepted by the membership of KDE e.V. (or its successor approved + by the membership of KDE e.V.), which shall act as a proxy + defined in Section 14 of version 3 of the license. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#include "importarchivedialog.h" + +#include "kmfolder.h" +#include "folderrequester.h" +#include "kmmainwidget.h" +#include "importjob.h" + +#include <kurlrequester.h> +#include <klocale.h> +#include <kmessagebox.h> + +#include <tqlayout.h> +#include <tqlabel.h> + +using namespace KMail; + +ImportArchiveDialog::ImportArchiveDialog( TQWidget *parent, TQt::WidgetFlags flags ) + : KDialogBase( parent, "import_archive_dialog", false, i18n( "Import Archive" ), + KDialogBase::Ok | KDialogBase::Cancel, + KDialogBase::Ok, true ), + mParentWidget( parent ) +{ + setWFlags( flags ); + TQWidget *mainWidget = new TQWidget( this ); + TQGridLayout *mainLayout = new TQGridLayout( mainWidget ); + mainLayout->setSpacing( KDialog::spacingHint() ); + mainLayout->setMargin( KDialog::marginHint() ); + setMainWidget( mainWidget ); + + int row = 0; + + // TODO: Explaination label + // TODO: Use QFormLayout in KDE4 + // TODO: better label for "Ok" button + + TQLabel *folderLabel = new TQLabel( i18n( "&Folder:" ), mainWidget ); + mainLayout->addWidget( folderLabel, row, 0 ); + mFolderRequester = new FolderRequester( mainWidget, kmkernel->getKMMainWidget()->folderTree() ); + folderLabel->setBuddy( mFolderRequester ); + mainLayout->addWidget( mFolderRequester, row, 1 ); + row++; + + TQLabel *fileNameLabel = new TQLabel( i18n( "&Archive File:" ), mainWidget ); + mainLayout->addWidget( fileNameLabel, row, 0 ); + mUrlRequester = new KURLRequester( mainWidget ); + mUrlRequester->setMode( KFile::LocalOnly ); + mUrlRequester->setFilter( "*.tar *.zip *.tar.gz *.tar.bz2" ); + fileNameLabel->setBuddy( mUrlRequester ); + mainLayout->addWidget( mUrlRequester, row, 1 ); + row++; + + // TODO: what's this, tooltips + + mainLayout->setColStretch( 1, 1 ); + mainLayout->addItem( new TQSpacerItem( 1, 1, TQSizePolicy::Expanding, TQSizePolicy::Expanding ), row, 0 ); + + // Make it a bit bigger, else the folder requester cuts off the text too early + resize( 500, minimumSize().height() ); +} + +void ImportArchiveDialog::setFolder( KMFolder *defaultFolder ) +{ + mFolderRequester->setFolder( defaultFolder ); +} + +void ImportArchiveDialog::slotOk() +{ + if ( !TQFile::exists( mUrlRequester->url() ) ) { + KMessageBox::information( this, i18n( "Please select an archive file that should be imported." ), + i18n( "No archive file selected" ) ); + return; + } + + if ( !mFolderRequester->folder() ) { + KMessageBox::information( this, i18n( "Please select the folder where the archive should be imported to." ), + i18n( "No target folder selected" ) ); + return; + } + + // TODO: check if url is empty. or better yet, disable ok button until file is chosen + + ImportJob *importJob = new KMail::ImportJob( mParentWidget ); + importJob->setFile( mUrlRequester->url() ); + importJob->setRootFolder( mFolderRequester->folder() ); + importJob->start(); + accept(); +} + +#include "importarchivedialog.moc" |