00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __PROJECT_H__
00019 #define __PROJECT_H__
00020
00021 #include <qobject.h>
00022 #include <qdom.h>
00023 #include <qstring.h>
00024 #include <qstringlist.h>
00025 #include <qptrlist.h>
00026 #include <qfileinfo.h>
00027
00028 #include "bookmark.h"
00029
00030 struct ProjectFile
00031 {
00032 ProjectFile(QString f, int l, int i, int z=0, bool ld=false, QString _lang="") :
00033 fileName(f), line(l), index(i), zoom(z), load(ld), lang(_lang) {}
00034 int line, index;
00035 QString fileName;
00036 int zoom;
00037 bool load;
00038 QString lang;
00039 };
00040
00041 class Project : public QObject
00042 {
00043 Q_OBJECT
00044 public:
00045 Project();
00046 Project( QString fileName );
00047 bool open( const char *filename );
00048 bool save( const char *filename = 0 );
00049 void setName( const char *filename ) { __file = QString(filename); }
00050 QString name() { return __file; }
00051 Project &operator=(Project &);
00052 void print() { qDebug(doc.toString()); }
00053 QString projectDir() const { return QFileInfo(__file).dirPath(true); }
00054
00055 const QString currentDirPath() const;
00056 const QString currentConfig() const;
00057 const QString currentFile() const;
00058 const QString buildCommand(QString config) const;
00059 const QString compileCommand(QString config) const;
00060 const QString goCommand(QString config) const;
00061 const QStringList tagsFiles() const;
00062 const QStringList configs() const;
00063 const QPtrList<ProjectBookmark> bookmarks() const;
00064 const QPtrList<ProjectFile> files() const;
00065 const QPtrList<ProjectFile> loadedFiles(bool clearLoadAttr=false) const;
00066 const QStringList envVars(QString config) const;
00067 ProjectFile *file( QFile &f) const;
00068 bool hasFile(QFile &f) const;
00069
00070 bool setBuildCommand(QString config, QString command);
00071 bool setCompileCommand(QString config, QString command);
00072 bool setGoCommand(QString config, QString command);
00073 bool addEnvVar( QString config, QString var );
00074 bool modifyFile( QFile &file, ProjectFile proFile );
00075 public slots:
00076 void setCurrentDirPath(QString dirPath);
00077 void setCurrentConfig(QString current);
00079 void setCurrentFile(QString current);
00080 void addTagsFile(QString fileName);
00081 void removeTagsFile(QString tagsFile);
00082 void addConfig(QString config);
00083 void removeConfig(QString config);
00084 void addBookmark( Bookmark *b );
00085 void addBookmark( QString name, QString file, int line ) {addBookmark( new ProjectBookmark(name, file, line));}
00086 void removeBookmarks();
00087 void addFile( QString file, int line, int index, int zoom=0) {addFile(ProjectFile(file, line, index, zoom)); }
00088 void addFile( ProjectFile file );
00089 void removeFile( QString file );
00090 void removeEnvVar( QString config, QString var );
00091 protected:
00092 void createRoot();
00093 const QString command(QString config, QString cmd) const;
00094 bool setCommand(QString config, QString command_type, QString command);
00095 private:
00096 QDomDocument doc;
00097 QString __file;
00098 };
00099
00100 #endif