summaryrefslogtreecommitdiffstats
path: root/kplato/kptpart.h
blob: 25ba542e50cf36a146ae2ed4e485a89c40c93106 (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
/* This file is part of the KDE project
   Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
   Copyright (C) 2004, 2005 Dag Andersen <danders@get2net.dk>
   Copyright (C) 2006 Raphael Langerhorst <raphael.langerhorst@kdemail.net>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef KPLATO_PART_H
#define KPLATO_PART_H

#include "kpttask.h"
#include "kptconfig.h"
#include "kptwbsdefinition.h"
#include "kptxmlloaderobject.h"

#include <KoDocument.h>
#include <KoTextZoomHandler.h>

class KoView;
class KoCommandHistory;
class KCommand;

namespace KPlato
{

class View;
class Project;
class ProjectDialog;
class ResourceGroup;
class Context;
class GanttView;

class Part : public KoDocument, public KoTextZoomHandler {
    Q_OBJECT
  TQ_OBJECT

public:
    Part(TQWidget *parentWidget = 0, const char *widgetName = 0,
	    TQObject* tqparent = 0, const char* name = 0,
	    bool singleViewMode = false);
    ~Part();

    virtual void paintContent(TQPainter& painter, const TQRect& rect,
			      bool transparent = FALSE,
			      double zoomX = 1.0, double zoomY = 1.0);

    virtual bool initDoc(InitDocFlags flags, TQWidget* parentWidget=0);

    /**
     * Edit the settings of the project
     */
    void editProject();

    Project &getProject() { return *m_project; }
    const Project &getProject() const { return *m_project; }

    // The load and save functions. Look in the file kplato.dtd for info
    virtual bool loadXML(TQIODevice *, const TQDomDocument &document);
    virtual TQDomDocument saveXML();

    bool saveOasis(KoStore*, KoXmlWriter*) { return false; }
    bool loadOasis(const TQDomDocument &, KoOasisStyles &, const TQDomDocument&, KoStore *) { return false; }

    void addCommand(KCommand * cmd, bool execute=true);
    
    void setCommandType(int type);
    
    Config &config() { return m_config; }
    
    void generateWBS();
    WBSDefinition &wbsDefinition() { return m_wbsDefinition; }
    
    const XMLLoaderObject &xmlLoader() const { return m_xmlLoader; }
protected:
    virtual KoView* createViewInstance(TQWidget* tqparent, const char* name);

protected slots:
    void slotDocumentRestored();
    void slotCommandExecuted();
    void slotCopyContextFromView();
    void slotViewDestroyed();

private:
    Project *m_project;
    ProjectDialog *m_projectDialog;
    TQWidget* m_parentWidget;
    View *m_view;
    
    /**
     * Used for drawing the project when embedded into another koffice app.
     * @see paintContent()
     */
    GanttView* m_embeddedGanttView;
    Context* m_embeddedContext;
    bool m_embeddedContextInitialized;
    
    KoCommandHistory *m_commandHistory;
    bool m_update, m_calculate, m_baseline;
    
    Config m_config;
    Context *m_context;
    
    WBSDefinition m_wbsDefinition;
    
    XMLLoaderObject m_xmlLoader;
};

}  //KPlato namespace

#endif