summaryrefslogtreecommitdiffstats
path: root/quanta/project/project.h
blob: b6775da791fa311a96da9e4ef15ede1703483de5 (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
/***********************************************************************
                          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 <qobject.h>

#include "projecturl.h"

class QDom;
class ProjectPrivate;
class ProjectList;
namespace KTextEditor{
  class MarkInterface;
  class ViewCursorInterface;
}
struct EventAction;
typedef  QMap<QString, QValueList<EventAction> > EventActions;

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

class KConfig;
class KMainWindow;

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

struct SubProject {
  QString name;
  QString location;
};

class Project : public QObject  {
   Q_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(KMainWindow *parent = 0L)
  {
    static Project *m_ref;
    if (!m_ref) m_ref = new Project(parent);
    return m_ref;
  }

  ~Project();

  bool hasProject();
  QString projectName();

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

  void insertFile( const KURL& nameURL, bool repaint );
  void readConfig(KConfig *);
  /** 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 QString defaultDTD. */
  const QString& defaultDTD();
  const QString& 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 QString& entry, const QString& passwd, bool store);
  /** Returns the saved password for entry */
  QString password(const QString &entry);
  bool passwordSaved(const QString &entry);
  QDomDocument *dom();
  QDomDocument *sessionDom();
  QString debuggerClient();
  bool debuggerPersistentBreakpoints();
  bool debuggerPersistentWatches();
  bool keepPasswd;
  QString email();
  KURL templateURL();
  KURL toolbarURL();
  EventActions* events();
  /**
   * Get the nickname of the current user (you)
   * @return the nickname
   */
  QString 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)
   */
  QStringList yourRoles();
  TeamMember teamLeader();
  TeamMember subprojectLeader(const QString &name);
  TeamMember taskLeader(const QString &name);
  QValueList<TeamMember> simpleMembers();
  QString mailingList();
  QValueList<SubProject>* subprojects();
  QStringList tasks();
  QMap<QString, 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 QString &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 QString&);

  void slotRescanPrjDir();
  void slotFileDescChanged(const KURL& url, const QString& 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 QString& );
  void openFiles( const KURL::List&, const QString& );
  void closeFile( const KURL&);
  void closeFiles();

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

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

  void newStatus();
  void statusMsg(const QString &);
  /** No descriptions */
  void newProjectLoaded(const QString &, 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(QStringList *);
  void eventHappened(const QString&, const QString&, const QString& );

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

  ProjectPrivate *d;
  bool m_projectToolbarVisible;
};

#endif