summaryrefslogtreecommitdiffstats
path: root/quanta/project/project.h
blob: 7c55cfef745dbf7d8720814259f828259330cd71 (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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/***********************************************************************
                          project.h  -  description
                             -------------------
    begin                : Thu Mar 16 2000
    copyright            : (C) 2000 by Yacovlev Alexander & Dmitry Poplavsky <pdima@mail.univ.kiev.ua>
                           (C) 2001-2005 by Andras Mantia <amantia@kde.org>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 PROJECT_H
#define PROJECT_H

#include <tqobject.h>

#include "projecturl.h"

class TQDom;
class ProjectPrivate;
class ProjectList;
namespace KTextEditor{
  class MarkInterface;
  class ViewCursorInterface;
}
struct EventAction;
typedef  TQMap<TQString, TQValueList<EventAction> > EventActions;

/**project
  *@author Yacovlev Alexander & Dmitry Poplavsky & Andras Mantia & Jens Herden
  */

class TDEConfig;
class TDEMainWindow;

struct TeamMember {
  TQString name;
  TQString email;
  TQString nickName;
  TQString task;
};

struct SubProject {
  TQString name;
  TQString location;
};

class Project : public TQObject  {
   TQ_OBJECT
  
   friend class ProjectPrivate;  // need this because I use the signals

public:

  /**
   *  since this class is a singleton you must use this function to access it
   *
   *  the parameter is only used at the first call to create the class
   *
   */
  static Project* const ref(TDEMainWindow *parent = 0L)
  {
    static Project *m_ref;
    if (!m_ref) m_ref = new Project(parent);
    return m_ref;
  }

  ~Project();

  bool hasProject();
  TQString projectName();

  TQStringList fileNameList();
  KURL::List files();

  void insertFile( const KURL& nameURL, bool repaint );
  void readConfig(TDEConfig *);
  /** loads the last project again if reload == true
      but checks in any case if there is a left over project from a crash
  */
  void loadLastProject(bool reload);
  /** Returns the relative url with the prefix inserted. */
  KURL urlWithPrefix(const KURL& url);
  bool contains(const KURL &url);
  /** Read property of TQString defaultDTD. */
  const TQString& defaultDTD();
  const TQString& defaultEncoding();

  /** Returns the project's base URL if it exists,
   * the HOME dir if there is no project and no opened document
   * (or the current  opened document was not saved yet),
   * and the base URL of the opened document, if it is saved somewhere.
   */
  KURL projectBaseURL();
  KURL documentFolderForURL(const KURL &url);

  /** Saves the password for entry into a list. Stores on disc if store == true */
  void savePassword(const TQString& entry, const TQString& passwd, bool store);
  /** Returns the saved password for entry */
  TQString password(const TQString &entry);
  bool passwordSaved(const TQString &entry);
  TQDomDocument *dom();
  TQDomDocument *sessionDom();
  TQString debuggerClient();
  bool debuggerPersistentBreakpoints();
  bool debuggerPersistentWatches();
  bool keepPasswd;
  TQString email();
  KURL templateURL();
  KURL toolbarURL();
  EventActions* events();
  /**
   * Get the nickname of the current user (you)
   * @return the nickname
   */
  TQString yourself();
  /**
   * Get the roles of the current user in the form "role:task".
   * Examples: "team leader", "project leader:subprojectname", "task leader:taskname".
   * @return the roles (in lowercase)
   */
  TQStringList yourRoles();
  TeamMember teamLeader();
  TeamMember subprojectLeader(const TQString &name);
  TeamMember taskLeader(const TQString &name);
  TQValueList<TeamMember> simpleMembers();
  TQString mailingList();
  TQValueList<SubProject>* subprojects();
  TQStringList tasks();
  TQMap<TQString, TeamMember> allMembers();
  bool eventsEnabled();
  void setProjectToolbarVisible(bool visible) {m_projectToolbarVisible = visible;}

  /** Called when an url was moved inside the project with drag &drop */
  void urlMoved(const KURL& srcURL, const KURL &destURL);
  /**
       test if application can close

       @return true if close is possible
  */
  bool queryClose();

  /** Saves the bookmarks for the url into the project file */
  void saveBookmarks(const KURL &url, KTextEditor::MarkInterface *markIf);
  /** Loads the bookmarks for the url from the project file and sets them in the view*/
  void loadBookmarks(const KURL &url, KTextEditor::MarkInterface *markIf);
  void saveCursorPosition(const KURL &url, KTextEditor::ViewCursorInterface *viewCursorIf);
  void loadCursorPosition(const KURL &url, KTextEditor::ViewCursorInterface *viewCursorIf);

public slots:

  void slotOpenProject(const KURL&);
  void slotOptions();
  void slotUpload();
  void slotUploadURL(const KURL &urlToUpload, const TQString &profileName, bool quickUpload, bool markOnly);

  void slotAddDirectory(const KURL& dirURL, bool showDlg = true);
  void slotInsertFile(const KURL& url);
  void slotInsertFilesAfterCopying(const KURL::List& a_url);

  /** if somewhere something was renamed */
  void slotRenamed(const KURL& oldURL, const KURL& newURL);
  void slotRemove(const KURL& urlToRemove);


  void slotGetMessages(const TQString&);

  void slotRescanPrjDir();
  void slotFileDescChanged(const KURL& url, const TQString& desc);
  void slotUploadStatusChanged(const KURL& url, int status);
  void slotChangeDocumentFolderStatus(const KURL& url, bool status);

  void slotReloadProjectDocs();

  void slotShowProjectToolbar(bool show);

  void setModified(bool b = true);

signals:

  void openFile( const KURL&, const TQString& );
  void openFiles( const KURL::List&, const TQString& );
  void closeFile( const KURL&);
  void closeFiles();

  void reloadTree(ProjectList *, bool, const TQStringList &);

  void messages(const TQString& );
  void enableMessageWidget();

  void newStatus();
  void statusMsg(const TQString &);
  /** No descriptions */
  void newProjectLoaded(const TQString &, const KURL &, const KURL &);
  void reloadProjectDocs();
  void hideSplash();
  void addProjectDoc(const KURL &);
  void getUserToolbarFiles(KURL::List *);
  void loadToolbarFile(const KURL &);
  /** ask for the tree status for saving in project */
  void getTreeStatus(TQStringList *);
  void eventHappened(const TQString&, const TQString&, const TQString& );

private:
  /** The constructor is privat because we use singleton patter.
   *  If you need the class use Project::ref() for
   *  construction and reference
   */
  Project(TDEMainWindow *parent);

  ProjectPrivate *d;
  bool m_projectToolbarVisible;
};

#endif