kexi

kexicsv_importexportpart.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "kexicsv_importexportpart.h"
00021 #include "kexicsvimportdialog.h"
00022 #include "kexicsvexportwizard.h"
00023 #include <core/keximainwindow.h>
00024 
00025 #include <kgenericfactory.h>
00026 
00027 KexiCSVImportExportPart::KexiCSVImportExportPart(QObject *parent, const char *name, const QStringList &args)
00028  : KexiInternalPart(parent, name, args)
00029 {
00030 }
00031 
00032 KexiCSVImportExportPart::~KexiCSVImportExportPart()
00033 {
00034 }
00035 
00036 QWidget *KexiCSVImportExportPart::createWidget(const char* widgetClass, KexiMainWindow* mainWin, 
00037  QWidget *parent, const char *objName, QMap<QString,QString>* args )
00038 {
00039     if (0==qstrcmp(widgetClass, "KexiCSVImportDialog")) {
00040         KexiCSVImportDialog::Mode mode = (args && (*args)["sourceType"]=="file")
00041             ? KexiCSVImportDialog::File : KexiCSVImportDialog::Clipboard;
00042         KexiCSVImportDialog *dlg = new KexiCSVImportDialog( mode, mainWin, parent, objName );
00043         m_cancelled = dlg->cancelled();
00044         if (m_cancelled) {
00045             delete dlg;
00046             return 0;
00047         }
00048         return dlg;
00049     }
00050     else if (0==qstrcmp(widgetClass, "KexiCSVExportWizard")) {
00051         if (!args)
00052             return 0;
00053         KexiCSVExportWizard::Options options;
00054         options.mode = (args && (*args)["destinationType"]=="file")
00055             ? KexiCSVExportWizard::File : KexiCSVExportWizard::Clipboard;
00056         bool ok;
00057         options.itemId = (*args)["itemId"].toInt(&ok);
00058         if (!ok || options.itemId<=0)
00059             return 0;
00060         if (args && args->contains("forceDelimiter")) {
00061             options.forceDelimiter = (*args)["forceDelimiter"];
00062         }
00063         KexiCSVExportWizard *dlg = new KexiCSVExportWizard( options, mainWin, parent, objName);
00064         m_cancelled = dlg->cancelled();
00065         if (m_cancelled) {
00066             delete dlg;
00067             return 0;
00068         }
00069         return dlg;
00070     }
00071     return 0;
00072 }
00073 
00074 K_EXPORT_COMPONENT_FACTORY( kexihandler_csv_importexport, 
00075     KGenericFactory<KexiCSVImportExportPart>("kexihandler_csv_importexport") )
KDE Home | KDE Accessibility Home | Description of Access Keys