summaryrefslogtreecommitdiffstats
path: root/src/projectsession.h
blob: 60c0b73228666f115686e41e18da2d18bc6d4452 (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
/***************************************************************************
                          projectsession.h  -  description
                             -------------------
    begin                : 30 Nov 2002
    copyright            : (C) 2002 by Falk Brettschneider
    email                : [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 _PROJECTSESSION_H_
#define _PROJECTSESSION_H_

#include <qobject.h>
#include <qdom.h>
#include <qdict.h>
#include <qvaluelist.h>

class QWidget;
class KURL;
class KDevPlugin;

/**
 * This class stores and restores the last situation before the certain project
 * was closed.
 * Session stuff that is not related to a certain project doesn't belong to here;
 * it must be saved in a program session which likely is "kdeveloprc".
 **/
class ProjectSession : public QObject
{
  Q_OBJECT
// methods
public:
  ProjectSession();
  virtual ~ProjectSession();

  /** Opens the .kdevses file and saves the project session in XML format to it. */
  bool saveToFile(const QString& fileName, const QValueList<KDevPlugin*> plugins );

  /** Opens the .kdevses file and loads the project session from it. */
  bool restoreFromFile(const QString& fileName, const QValueList<KDevPlugin*> plugins );

signals:
  void sig_restoreMainWindowProperties(const QDomElement* el);
  void sig_saveMainWindowProperties(QDomElement* el);

  void sig_restoreAdditionalViewProperties(const QString& viewName, const QDomElement* el);
  void sig_saveAdditionalViewProperties(const QString& viewName, QDomElement* el);

private slots:
  /**
   * This slot loads one document from _docDataList and sets a timer to load the next
   */
  void loadDocument();

private:
  /** Restores the part of the project session that concerns to the documents (files). */
  void recreateDocs(QDomElement& el);
  /** recreates views and their properties of a certain document. */
  void recreateViews(KURL& url, QDomElement docEl, bool activate);
  /** setup a valid XML file. */
  void initXMLTree();

// attributes
private:
  /** the XML document object controlling the XML tree. */
  QDomDocument domdoc;

  struct DocumentData
  {
    DocumentData() : line(0) {}
    KURL url;
    int line;
    QString type;
    bool activate;
    QString encoding;
  };

  QValueList<DocumentData> _docDataList;

};

#endif // _PROJECTSESSION_H_