summaryrefslogtreecommitdiffstats
path: root/src/projectsession.h
blob: ef8ac2df0b72df755d0f39945e402ef90ad6cdcb (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                : falk@kdevelop.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 _PROJECTSESSION_H_
#define _PROJECTSESSION_H_

#include <tqobject.h>
#include <tqdom.h>
#include <tqdict.h>
#include <tqvaluelist.h>

class TQWidget;
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 TQString& fileName, const TQValueList<KDevPlugin*> plugins );

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

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

  void sig_restoreAdditionalViewProperties(const TQString& viewName, const TQDomElement* el);
  void sig_saveAdditionalViewProperties(const TQString& viewName, TQDomElement* 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(TQDomElement& el);
  /** recreates views and their properties of a certain document. */
  void recreateViews(KURL& url, TQDomElement docEl, bool activate);
  /** setup a valid XML file. */
  void initXMLTree();

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

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

  TQValueList<DocumentData> _docDataList;

};

#endif // _PROJECTSESSION_H_