KDevelop API Documentation

kdevcustomimporter.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002 *   Copyright (C) 2003 by Alexander Dymo                                  *
00003 *   cloudtemple@mksat.net                                                 *
00004 *                                                                         *
00005 *   This program is free software; you can redistribute it and/or modify  *
00006 *   it under the terms of the GNU General Public License as published by  *
00007 *   the Free Software Foundation; either version 2 of the License, or     *
00008 *   (at your option) any later version.                                   *
00009 ***************************************************************************/
00010 #include "kdevcustomimporter.h"
00011 
00012 #include "settingsdialog.h"
00013 
00014 #include <qvaluestack.h>
00015 #include <qdir.h>
00016 
00017 #include <kdebug.h>
00018 #include <kgenericfactory.h>
00019 
00020 K_EXPORT_COMPONENT_FACTORY( libkdevcustomimporter, KGenericFactory<KDevCustomImporter>( "kdevcustomimporter" ) )
00021 
00022 KDevCustomImporter::KDevCustomImporter(QObject* parent, const char* name, const QStringList &args)
00023     : KDevPCSImporter(parent, name)
00024 {
00025 }
00026 
00027 
00028 KDevCustomImporter::~KDevCustomImporter()
00029 {
00030 }
00031 
00032 
00033 QString KDevCustomImporter::dbName() const
00034 {
00035     return m_settings->dbName();
00036 }
00037 
00038 QStringList KDevCustomImporter::fileList( const QString& path )
00039 {
00040     QDir dir( path );
00041     if (!dir.exists())
00042         return QStringList();
00043     QStringList lst = dir.entryList( "*.h;*.H;*.hh;*.hxx;*.hpp;*.tlh" );
00044     QStringList fileList;
00045     for( QStringList::Iterator it=lst.begin(); it!=lst.end(); ++it )
00046     {
00047         fileList.push_back( dir.absPath() + "/" + (*it) );
00048     }
00049     return fileList;
00050 }
00051 
00052 QStringList KDevCustomImporter::fileList()
00053 {
00054     if( !m_settings )
00055         return QStringList();
00056 
00057     QStringList lst = m_settings->dirs();
00058     QStringList files;
00059     for( QStringList::Iterator it=lst.begin(); it!=lst.end(); ++it )
00060     {
00061         if (!m_settings->recursive())
00062             files += fileList(*it);
00063         else
00064             processDir(*it, files);
00065     }
00066 
00067     return files;
00068 }
00069 
00070 QStringList KDevCustomImporter::includePaths()
00071 {
00072     if( !m_settings )
00073         return QStringList();
00074 
00075     return m_settings->dirs();
00076 }
00077 
00078 QWidget* KDevCustomImporter::createSettingsPage(QWidget* parent, const char* name)
00079 {
00080     m_settings = new SettingsDialog( parent, name );
00081     return m_settings;
00082 }
00083 
00084 void KDevCustomImporter::processDir( const QString path, QStringList & files )
00085 {
00086     QValueStack<QString> s;
00087     s.push(path);
00088     files += fileList(path);
00089 
00090     QDir dir;
00091     do {
00092         dir.setPath(s.pop());
00093         kdDebug(9015) << "Examining: " << dir.path() << endl;
00094         const QFileInfoList *dirEntries = dir.entryInfoList();
00095         QPtrListIterator<QFileInfo> it(*dirEntries);
00096         for (; it.current(); ++it) {
00097             QString fileName = it.current()->fileName();
00098             if (fileName == "." || fileName == "..")
00099                 continue;
00100             QString path = it.current()->absFilePath();
00101             if (it.current()->isDir()) {
00102                 kdDebug(9015) << "Pushing: " << path << endl;
00103                 s.push(path);
00104                 files += fileList(path);
00105             }
00106         }
00107     } while (!s.isEmpty());
00108 }
00109 
00110 #include "kdevcustomimporter.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:30 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003