summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/codeimport/classimport.cpp
blob: 9a7cbae9a59d7fe83a3f955d5b7614b1187e60e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/***************************************************************************
 *                                                                         *
 *   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) any later version.                                   *
 *                                                                         *
 *  copyright (C) 2006                                                     *
 *  Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                   *
 ***************************************************************************/

// own header
#include "classimport.h"
// qt/kde includes
#include <tqregexp.h>
#include <klocale.h>
// app includes
#include "../umldoc.h"
#include "../uml.h"
#include "idlimport.h"
#include "pythonimport.h"
#include "javaimport.h"
#include "adaimport.h"
#include "pascalimport.h"
#include "cppimport.h"

void ClassImport::importFiles(const TQStringList &fileList) {
    initialize();
    UMLDoc *umldoc = UMLApp::app()->getDocument();
    uint processedFilesCount = 0;
    for (TQStringList::const_iterator fileIT = fileList.begin();
            fileIT != fileList.end(); ++fileIT) {
        TQString fileName = (*fileIT);
        umldoc->writeToStatusBar(i18n("Importing file: %1 Progress: %2/%3").
                                 tqarg(fileName).tqarg(processedFilesCount).tqarg(fileList.size()));
        parseFile(fileName);
        processedFilesCount++;
    }
    umldoc->writeToStatusBar(i18n("Ready."));
}

ClassImport *ClassImport::createImporterByFileExt(const TQString &filename) {
    ClassImport *classImporter;
    if (filename.endsWith(".idl"))
        classImporter = new IDLImport();
    else if (filename.endsWith(".py"))
        classImporter = new PythonImport();
    else if (filename.endsWith(".java"))
        classImporter = new JavaImport();
    else if (filename.tqcontains( TQRegExp("\\.ad[sba]$") ))
        classImporter = new AdaImport();
    else if (filename.endsWith(".pas"))
        classImporter = new PascalImport();
    else
        classImporter = new CppImport();  // the default.
    return classImporter;
}