summaryrefslogtreecommitdiffstats
path: root/buildtools/custommakefiles/customprojectpart.h
blob: f3fb9ec4f1583ca547198aadf8b348f8929bc397 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/***************************************************************************
 *   Copyright (C) 2001-2002 by Bernd Gehrmann                             *
 *   [email protected]                                                    *
 *   Copyright (C) 2007 by Andreas Pakulat                                 *
 *   [email protected]                                                          *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _CUSTOMPROJECTPART_H_
#define _CUSTOMPROJECTPART_H_

#include <qdict.h>
#include <qguardedptr.h>
#include <qmap.h>
#include <qdatetime.h>
#include <qvaluestack.h>

#include <kdevbuildtool.h>

class QListViewItem;
class QPopupMenu;
class QStringList;
class KDialogBase;
class CustomProjectWidget;
class Context;
class KSelectAction;

class CustomProjectPart : public KDevBuildTool
{
    Q_OBJECT

public:
    CustomProjectPart( QObject *parent, const char *name, const QStringList & );
    ~CustomProjectPart();

    QStringList allMakeEnvironments() const;
    QString currentMakeEnvironment() const;

    bool isDirty();
    QStringList distFiles() const;

    virtual void openProject( const QString &dirName, const QString &projectName );
    virtual void closeProject();

    virtual QString projectDirectory() const;
    virtual QString projectName() const;
    virtual QString mainProgram() const;
    virtual QString activeDirectory() const;
    virtual QStringList allFiles() const;
    virtual void addFile( const QString &fileName );
    virtual void addFiles( const QStringList& fileList );
    virtual void removeFile( const QString &fileName );
    virtual void removeFiles( const QStringList &fileList );
    virtual QString buildDirectory() const;
    virtual QString runDirectory() const;
    virtual QString debugArguments() const;
    virtual QString runArguments() const;
    virtual DomUtil::PairList runEnvironmentVars() const;
    QString relativeToProject( const QString& ) const;


private slots:
    void populateProject();
    void projectConfigWidget( KDialogBase *dlg );
    void contextMenu( QPopupMenu *popup, const Context *context );
    void slotAddToProject();
    void slotRemoveFromProject();
    void slotAddToProjectRecursive();
    void slotRemoveFromProjectRecursive();
    void addNewFilesToProject( const QStringList& );
    void slotChangeBlacklist();
    void slotChooseActiveDirectory();
    void slotBuild();
    void slotBuildActiveDir();
    void slotCompileFile();
    void slotInstall();
    void slotInstallActiveDir();
    void slotInstallWithKdesu();
    void slotClean();
    void slotExecute();
    void updateTargetMenu();
    void targetMenuActivated( int id );
    void targetObjectFilesMenuActivated( int id );
    void targetOtherFilesMenuActivated( int id );
    void updateMakeEnvironmentsMenu();
    void makeEnvironmentsMenuActivated( int id );
    void slotCommandFinished( const QString& command );
    void slotCommandFailed( const QString& command );

private:
    bool containsNonProjectFiles( const QString& url );
    QStringList projectFilesInDir( const QString& dir );
    bool containsProjectFiles( const QString& url );
    bool isProjectFileType( const QString& absFile ) const;
    bool isInBlacklist( const QString& ) const;
    void cleanFileList();
    void setFiletypes( const QStringList& );
    void findNewFiles( const QString& dir, QStringList& list) const;

    QStringList filetypes() const;
    QStringList blacklist() const;
    void updateBlacklist( const QStringList& );
    void saveProject();
    void startMakeCommand( const QString &dir, const QString &target, bool withKdesu = false );
    void parseMakefile( const QString& file );
    QString makeEnvironment() const;
    void putEnvVarsInVarMap();
    void switchBlacklistEntry(const QString& );

    bool isInProject( const QString& fileName ) const;
    void addToProject( const QString& fileName );
    void removeFromProject( const QString& fileName );

    /**
     * @brief Set of all the project's files.
     *
     * @bug
     * Due to deficiency in QT3,
     * we have to use a map with next-to-useless element value,
     * keyed by the file name,
     * as a set-container replacement.
     */
    typedef QMap<QString, bool> ProjectFilesSet;

    QString m_projectDirectory;
    QString m_projectName;
    QString m_filelistDir;
    /** All the sources (files and directories) of this project. */
    ProjectFilesSet m_sourceFilesSet;
    QPopupMenu *m_targetMenu;
    QPopupMenu *m_targetObjectFilesMenu;
    QPopupMenu *m_targetOtherFilesMenu;
    KSelectAction *m_makeEnvironmentsSelector;
    QStringList m_targets;
    QStringList m_targetsObjectFiles;
    QStringList m_targetsOtherFiles;
    QStringList m_contextAddFiles;
    QStringList m_contextRemoveFiles;
    QString m_contextDirName;

    QMap<QString, QDateTime> m_timestamp;
    bool m_executeAfterBuild;
    QString m_buildCommand;
    bool m_lastCompilationFailed;
    QMap<QString, int> m_parsedMakefiles;
    QValueStack<QString> m_makefilesToParse;
    QMap<QString, QString> m_makefileVars;
    bool m_recursive;
    bool m_first_recursive;
};

#endif
// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on