~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kexi/filters/import/csv/kexicsvimport.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of the KDE project
2
 
   Copyright (C) 2003   Lucijan Busch <lucijan@gmx.at>
3
 
 
4
 
   This program is free software; you can redistribute it and/or
5
 
   modify it under the terms of the GNU Library General Public
6
 
   License as published by the Free Software Foundation; either
7
 
   version 2 of the License, or (at your option) any later version.
8
 
 
9
 
   This program is distributed in the hope that it will be useful,
10
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 
   Library General Public License for more details.
13
 
 
14
 
   You should have received a copy of the GNU Library General Public License
15
 
   along with this program; see the file COPYING.  If not, write to
16
 
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 
   Boston, MA 02111-1307, USA.
18
 
*/
19
 
 
20
 
#include <klocale.h>
21
 
#include <kgenericfactory.h>
22
 
#include <kfiledialog.h>
23
 
#include <kmessagebox.h>
24
 
#include <kdebug.h>
25
 
#include <kio/netaccess.h>
26
 
#include <ktempfile.h>
27
 
 
28
 
#include "kexiDB/kexidb.h"
29
 
#include "kexiDB/kexidbtable.h"
30
 
#include "kexiDB/kexidbfield.h"
31
 
#include "kexiDB/kexidbrecordset.h"
32
 
 
33
 
#include "kexicsvimport.h"
34
 
#include "kexicsvsource.h"
35
 
 
36
 
#include "core/filters/kexifiltermanager.h"
37
 
#include "core/filters/kexifilterwizardbase.h"
38
 
#include "core/kexiproject.h"
39
 
 
40
 
 
41
 
KexiCSVImport::KexiCSVImport(QObject *parent, const char *name, const QStringList &l)
42
 
 : KexiFilter(KEXIFILTERWIZARDBASE(parent), name,l)
43
 
{
44
 
        m_srcWidget=0;
45
 
        m_file="";
46
 
}
47
 
 
48
 
QString
49
 
KexiCSVImport::name()
50
 
{
51
 
        return i18n("csv file");
52
 
}
53
 
 
54
 
 
55
 
bool KexiCSVImport::prepareImport(unsigned long type, const KURL& url)
56
 
{
57
 
 
58
 
        bool result=false;
59
 
        if(  KIO::NetAccess::download( url, m_file) ) {
60
 
                result=true;
61
 
        } else {
62
 
#warning display error
63
 
                m_file="";
64
 
        }
65
 
 
66
 
        return result;
67
 
}
68
 
 
69
 
 
70
 
KexiDBTable KexiCSVImport::tableStructure() {
71
 
        return m_srcWidget->tableStructure();
72
 
}
73
 
 
74
 
bool KexiCSVImport::firstTableRow() {
75
 
        return m_srcWidget->firstTableRow();
76
 
}
77
 
 
78
 
 
79
 
bool KexiCSVImport::nextTableRow() {
80
 
        return m_srcWidget->nextTableRow();
81
 
}
82
 
 
83
 
QVariant KexiCSVImport::tableValue(int field) {
84
 
        return m_srcWidget->tableValue(field);
85
 
}
86
 
 
87
 
QPtrList<QWidget> KexiCSVImport::sourceWidgets(QWidget *parent) {
88
 
        filterWizard()->setMode(KexiFilterManager::Data);
89
 
        m_srcWidget=new KexiCSVSource(parent);
90
 
        m_srcWidget->setFile(m_file);
91
 
        QPtrList<QWidget> tmp;
92
 
        tmp.append(m_srcWidget);
93
 
        return tmp;
94
 
}
95
 
 
96
 
 
97
 
 
98
 
KexiCSVImport::~KexiCSVImport()
99
 
{
100
 
        delete m_srcWidget;
101
 
        if (m_file.isEmpty()) {
102
 
                KIO::NetAccess::removeTempFile(m_file);
103
 
        }
104
 
}
105
 
 
106
 
K_EXPORT_COMPONENT_FACTORY(kexicsvimport, KGenericFactory<KexiCSVImport>("kexicsvimport"))
107
 
 
108
 
#include "kexicsvimport.moc"