Commit edf118a1 authored by Sergio Luis Martins's avatar Sergio Luis Martins

SVN_SILENT:

SVN_MERGE:

Part of r1132719 merge from e35 to trunk.

Ported stuff from Qt3 to Qt4. And to KCalCore.

Only action manager remaining.

svn path=/branches/work/kdepim_kcalcore/korganizer/; revision=1158313
parent 93ec60f4
......@@ -223,6 +223,7 @@ set(korganizerprivate_LIB_SRCS
printing/calprinter.cpp
printing/calprintpluginbase.cpp
printing/calprintdefaultplugins.cpp
previewdialog.cpp
)
kde4_add_kcfg_files(korganizerprivate_LIB_SRCS htmlexportsettings.kcfgc )
......
......@@ -27,38 +27,42 @@
*/
#include "previewdialog.h"
#include "kolistview.h"
#include "koprefs.h"
#include "stdcalendar.h"
#include <klocale.h>
#include "views/listview/kolistview.h"
#include <libkcal/calendarlocal.h>
#include <KCalCore/FileStorage>
#include <KCalCore/ICalFormat>
#include <kstandarddirs.h>
#include <kfiledialog.h>
#include <kmessagebox.h>
#include <KLocale>
#include <KStandardDirs>
#include <KFileDialog>
#include <KMessageBox>
#include <kio/netaccess.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qradiobutton.h>
#include <qpushbutton.h>
#include <qdialog.h>
#include <QLabel>
#include <QLayout>
#include <QRadioButton>
#include <QPushButton>
#include <QDialog>
using namespace KCal;
using namespace KCalCore;
PreviewDialog::PreviewDialog( const KURL &url, QWidget *parent )
: KDialogBase( Plain, i18n("Import Calendar/Event"), User1 | User2 | Cancel, User1, parent,
0, true, true, KGuiItem( i18n("&Merge into existing calendar"), "merge" ) ),
mOriginalUrl( url )
PreviewDialog::PreviewDialog( const KUrl &url, QWidget *parent )
: KDialog( parent ), mOriginalUrl( url ), mFileStorage( 0 )
{
QFrame *topFrame = plainPage();
QVBoxLayout *topLayout = new QVBoxLayout( topFrame, 0, spacingHint() );
setCaption( i18n("Import Calendar/Event") );
// KGuiItem( i18n("&Merge into existing calendar"), "merge" )
setButtons( User1 | User2 | Cancel );
setDefaultButton( User1 );
QFrame *topFrame = new QFrame( this );
QVBoxLayout *topLayout = new QVBoxLayout( topFrame );
topLayout->setSpacing( spacingHint() );
topLayout->setMargin( 0 );
mCalendar = new CalendarLocal( KOPrefs::instance()->mTimeZoneId );
mListView = new KOListView( mCalendar, topFrame, "PreviewDialog::ListView", true );
mCalendar = MemoryCalendar::Ptr( new MemoryCalendar(
KOPrefs::instance()->mTimeZoneId ) );
mListView = new KOListView( this, true );
topLayout->addWidget( mListView );
topLayout->setSpacing( spacingHint() );
......@@ -85,7 +89,7 @@ PreviewDialog::~PreviewDialog()
delete mLocalUrl;
}
delete mCalendar;
delete mFileStorage;
}
bool PreviewDialog::loadCalendar()
......@@ -100,7 +104,7 @@ bool PreviewDialog::loadCalendar()
QString tmpFile;
if ( KIO::NetAccess::download( mOriginalUrl, tmpFile, 0 ) ) {
mLocalUrl = new KURL( tmpFile );
mLocalUrl = new KUrl( tmpFile );
} else {
mLocalUrl = 0;
}
......@@ -109,7 +113,11 @@ bool PreviewDialog::loadCalendar()
}
if ( mLocalUrl ) {
const bool success = mCalendar->load( mLocalUrl->path() );
mFileStorage = new KCalCore::FileStorage( mCalendar,
mLocalUrl->path(),
new KCalCore::ICalFormat() );
const bool success = mFileStorage->load();
if ( !success && !mOriginalUrl.isLocalFile() ) {
KIO::NetAccess::removeTempFile( mLocalUrl->path() );
......@@ -133,16 +141,17 @@ void PreviewDialog::slotMerge()
void PreviewDialog::slotAdd()
{
KURL finalUrl = mOriginalUrl;
KUrl finalUrl = mOriginalUrl;
if ( isTempFile() ) {
const QString fileName =
KFileDialog::getSaveFileName( locateLocal( "data","korganizer/" ),
KFileDialog::getSaveFileName( KStandardDirs::locateLocal( "data","korganizer/" ),
i18n( "*.vcs *.ics|Calendar Files" ),
this, i18n( "Select path for new calendar" ) );
finalUrl = KURL( fileName );
finalUrl = KUrl( fileName );
if ( !KIO::NetAccess::copy( mOriginalUrl, finalUrl, this ) && KIO::NetAccess::lastError() ) {
if ( !KIO::NetAccess::file_copy( mOriginalUrl, finalUrl, this )
&& KIO::NetAccess::lastError() ) {
KMessageBox::error( this, KIO::NetAccess::lastErrorString() );
return;
}
......@@ -157,7 +166,7 @@ void PreviewDialog::slotAdd()
bool PreviewDialog::isTempFile() const
{
return mOriginalUrl.path().startsWith( locateLocal( "tmp", "" ) );
return mOriginalUrl.path().startsWith( KStandardDirs::locateLocal( "tmp", "" ) );
}
#include "previewdialog.moc"
......@@ -29,20 +29,23 @@
#ifndef PREVIEWDIALOG_H
#define PREVIEWDIALOG_H
#include <kdialogbase.h>
#include <kurl.h>
#include <KDialog>
#include <KUrl>
#include <KCalCore/MemoryCalendar>
class KOListView;
namespace KCal {
class CalendarLocal;
namespace KCalCore {
class MemoryCalendar;
class FileStorage;
}
class PreviewDialog : public KDialogBase
class PreviewDialog : public KDialog
{
Q_OBJECT
public:
PreviewDialog( const KURL &url, QWidget *parent );
PreviewDialog( const KUrl &url, QWidget *parent );
~PreviewDialog();
bool loadCalendar();
......@@ -52,18 +55,19 @@ class PreviewDialog : public KDialogBase
signals:
void dialogFinished( PreviewDialog * );
void openURL( const KURL &, bool );
void addResource( const KURL & );
void openURL( const KUrl &, bool );
void addResource( const KUrl & );
private:
// Checks if mOriginalUrl is a temp file, if it is we ask the user a place to
// Checks if mOriginalUrl is a temp file, if it is we ask the user a place to
// keep the calendar file
bool isTempFile() const;
private:
KURL mOriginalUrl;
KURL *mLocalUrl;
KUrl mOriginalUrl;
KUrl *mLocalUrl;
KOListView *mListView;
KCal::CalendarLocal *mCalendar;
KCalCore::MemoryCalendar::Ptr mCalendar;
KCalCore::FileStorage *mFileStorage;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment