~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to languages/cpp/pcsimporter/customimporter/kdevcustomimporter.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
*   Copyright (C) 2003 by Alexander Dymo                                  *
 
3
*   cloudtemple@mksat.net                                                 *
 
4
*                                                                         *
 
5
*   This program is free software; you can redistribute it and/or modify  *
 
6
*   it under the terms of the GNU General Public License as published by  *
 
7
*   the Free Software Foundation; either version 2 of the License, or     *
 
8
*   (at your option) any later version.                                   *
 
9
***************************************************************************/
 
10
#include "kdevcustomimporter.h"
 
11
 
 
12
#include "settingsdialog.h"
 
13
 
 
14
#include <qvaluestack.h>
 
15
#include <qdir.h>
 
16
 
 
17
#include <kdebug.h>
 
18
#include <kgenericfactory.h>
 
19
 
 
20
K_EXPORT_COMPONENT_FACTORY( libkdevcustompcsimporter, KGenericFactory<KDevCustomImporter>( "kdevcustompcsimporter" ) )
 
21
 
 
22
KDevCustomImporter::KDevCustomImporter( QObject* parent, const char* name, const QStringList & // args
 
23
                                      )
 
24
                : KDevPCSImporter( parent, name )
 
25
{}
 
26
 
 
27
 
 
28
KDevCustomImporter::~KDevCustomImporter()
 
29
{}
 
30
 
 
31
 
 
32
QString KDevCustomImporter::dbName() const
 
33
{
 
34
        return m_settings->dbName();
 
35
}
 
36
 
 
37
QStringList KDevCustomImporter::fileList( const QString& path )
 
38
{
 
39
        QDir dir( path );
 
40
        if ( !dir.exists() )
 
41
                return QStringList();
 
42
        QStringList lst = dir.entryList( "*.h;*.H;*.hh;*.hxx;*.hpp;*.tlh" );
 
43
        QStringList fileList;
 
44
        for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it )
 
45
        {
 
46
                fileList.push_back( dir.absPath() + "/" + ( *it ) );
 
47
        }
 
48
        return fileList;
 
49
}
 
50
 
 
51
QStringList KDevCustomImporter::fileList()
 
52
{
 
53
        if ( !m_settings )
 
54
                return QStringList();
 
55
 
 
56
        QStringList lst = m_settings->dirs();
 
57
        QStringList files;
 
58
        for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it )
 
59
        {
 
60
                if ( !m_settings->recursive() )
 
61
                        files += fileList( *it );
 
62
                else
 
63
                        processDir( *it, files );
 
64
        }
 
65
 
 
66
        return files;
 
67
}
 
68
 
 
69
QStringList KDevCustomImporter::includePaths()
 
70
{
 
71
        if ( !m_settings )
 
72
                return QStringList();
 
73
 
 
74
        return m_settings->dirs();
 
75
}
 
76
 
 
77
QWidget* KDevCustomImporter::createSettingsPage( QWidget* parent, const char* name )
 
78
{
 
79
        m_settings = new SettingsDialog( parent, name );
 
80
        return m_settings;
 
81
}
 
82
 
 
83
void KDevCustomImporter::processDir( const QString path, QStringList & files )
 
84
{
 
85
        QValueStack<QString> s;
 
86
        s.push( path );
 
87
        files += fileList( path );
 
88
 
 
89
        QDir dir;
 
90
        do
 
91
        {
 
92
                dir.setPath( s.pop() );
 
93
                kdDebug( 9015 ) << "Examining: " << dir.path() << endl;
 
94
                const QFileInfoList *dirEntries = dir.entryInfoList();
 
95
                QPtrListIterator<QFileInfo> it( *dirEntries );
 
96
                for ( ; dirEntries && it.current(); ++it )
 
97
                {
 
98
                        QString fileName = it.current() ->fileName();
 
99
                        if ( fileName == "." || fileName == ".." )
 
100
                                continue;
 
101
                        if ( it.current() ->isDir() )
 
102
                        {
 
103
                                QString tmpPath = it.current() ->absFilePath();
 
104
                                kdDebug( 9015 ) << "Pushing: " << tmpPath << endl;
 
105
                                s.push( tmpPath );
 
106
                                files += fileList( tmpPath );
 
107
                        }
 
108
                }
 
109
        }
 
110
        while ( !s.isEmpty() );
 
111
}
 
112
 
 
113
#include "kdevcustomimporter.moc" 
 
114
//kate: indent-mode csands; tab-width 4; space-indent off;