summaryrefslogtreecommitdiffstats
path: root/quanta/src/quantaview.h
blob: e3688d93e7e771cc60cd2e7a098208148400f04b (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
222
223
224
225
226
227
228
229
230
231
232
233
/***************************************************************************
                          quantaview.h  -  description
                             -------------------
    begin                : ���� 9 13:29:57 EEST 2000
    copyright            : (C) 2000 by Dmitry Poplavsky & Alexander Yakovlev & Eric Laffoon <pdima@users.sourceforge.net,yshurik@linuxfan.com,sequitur@easystreet.com>
                           (C) 2001-2005 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 QUANTAVIEW_H
#define QUANTAVIEW_H

// include files for Qt
#include <tqguardedptr.h>
#include <tqwidget.h>
#include <tqptrlist.h>
#include <tqvaluelist.h>
#include <tqtimer.h>

//kde includes
#include <kmdichildview.h>

#include <dom/dom_node.h>

class QuantaDoc;
class Document;
class ToolbarTabWidget;
class KafkaDocument;
class QuantaPlugin;

class TQSplitter;
class KURL;
class TQGridLayout;

namespace DOM
{
  class Node;
}

namespace KTextEditor
{
  class Mark;
}
class TQSplitter;
class Node;

/** The QuantaView class provides the view widget for the QuantaApp
 * instance.  The View instance inherits TQWidget as a base class and
 * represents the view object of a KTMainWindow. As QuantaView is part
 * of the docuement-view model, it needs a reference to the document
 * object connected with it by the QuantaApp class to manipulate and
 * display the document structure provided by the QuantaDoc class.
 *
 * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
 * @version KDevelop version 0.4 code generation */
class QuantaView : public KMdiChildView
{
  Q_OBJECT

public:

  QuantaView(TQWidget *parent = 0, const char *name=0, const TQString &caption = TQString::null);
  ~QuantaView();

  /** returns true if the view can be removed, false otherwise */
  bool mayRemove();

  /**Adds a Document object to the view. Also creates the VPL widget for the document. */
  void addDocument(Document *document);

  /** Adds a custom widget to the view. */
  void addCustomWidget(TQWidget *widget, const TQString &label);

  /** returns the Document object associated with this view. Returns 0L if the view holds
  a non-Document object */
  Document *document() {return m_document;};

  /**Adds a QuantaPlugin object to the view.*/
  void addPlugin(QuantaPlugin *plugin);

  TQWidget* documentArea() {return m_documentArea;}

   bool saveDocument(const KURL&);
  /** Saves the document if it's modified. Ask the user if their
   @param ask is true. */
  bool saveModified(bool ask = true);
  /** Returns the baseURL of the document. */
  KURL baseURL();

  /** Tells which widget had the focus the more recently */
  int hadLastFocus() {return m_currentFocus;}
  /** Reloads both views ONLY when changes have been made to the Node tree ONLY.
    * Set force to true if you want to reload even if not necessary.*/
  void reloadBothViews(bool force = false);
  /** reload the Kafka view from the Node Tree. Set force to true if you want to reload even if not necessary. */
  void reloadVPLView(bool force = false);
  /** reload the Quanta view from the Node Tree. Set force to true if you want to reload even if not necessary. */
  void reloadSourceView(bool force = false);
  /** Return the curren views layout*/
  int currentViewsLayout() {return m_currentViewsLayout;}

  void reloadLayout();

 /** Called when this view become the active one */
  void activated();
 /** Called when this view lost the active status */
  void deactivated();

  void resizeEvent(TQResizeEvent* e);
 /** Resize the current view */
  void resize(int width, int height);
  /** Redraws the view, resizes the components to their correct size */
  void refreshWindow();

 /** Updates the icon at the name on the view tab */
  void updateTab();

  /** Returns the tab name associated with this view */
  TQString tabName();

  void insertTag( const char *tag);

  /** Insert a new tag by bringing up the TagDialog. */
  void insertNewTag(const TQString &tag, const TQString &attr = TQString::null, bool insertInLine = true);
  /**
    * This function take the output of the TagAction, parse it into Nodes and insert it
    * in the Node tree. Then kafka will take care of updating itself from the Node Tree.
    */
  void insertOutputInTheNodeTree(const TQString &str1, const TQString &str2 = TQString::null, Node *node = 0L);

  enum ViewFocus {
    SourceFocus = 0,
    VPLFocus
  };

  enum ViewLayout {
    SourceOnly = 0,
    SourceAndVPL,
    VPLOnly
  };


public slots:
  void slotSetSourceLayout();
  void slotSetSourceAndVPLLayout();
  void slotSetVPLOnlyLayout();

  /**
   * Called whenever the KafkaWidget widget get/lost the focus.
   */
  void slotVPLGetFocus(bool focus);

  /**
   * Called whenever the KTextEditor::View widget get the focus.
   */
  void slotSourceGetFocus();

  /**
   * Called when we want to set the Quanta cursor.
   * Record the position until Quanta get the focus again.
   * Useful when we want to set it when quanta doesn't have the focus.
   */
  void slotSetCursorPositionInSource(int col, int line);
 /**
   * Called when an error occured when loading kafka.
   * Pop up the Error reporter dialog.
   */
  void slotVPLLoadingError(Node *node);

  /** Restarts the update timers according to the current settings */
  void reloadUpdateTimers();

private slots:
  void slotSavingCompleted();
  void slotSavingFailed(const TQString& error);

  /**
   * Called to update VPL.
   */
  void VPLUpdateTimerTimeout();

  /**
   * Called to update the source.
   */
  void sourceUpdateTimerTimeout();

signals:
  /** emitted when a file from the template view is dropped on the view */
  void dragInsert(TQDropEvent *);
  /** asks for hiding the preview widget */
  void hidePreview();
  void showProblemsView();
  void cursorPositionChanged();
  void title(const TQString &);
  /** emitted if this view contained an editor and it is closed */
  void documentClosed(const KURL&);

  void eventHappened(const TQString&, const TQString&, const TQString& );

private:
/** Kafka stuff */
  TQValueList<int> m_splitterSizes;
  int m_curCol, m_curLine, m_curOffset;
  DOM::Node curNode;
  bool m_kafkaReloadingEnabled, m_quantaReloadingEnabled;
  TQTimer m_sourceUpdateTimer, m_VPLUpdateTimer;

  TQWidget *m_documentArea;///< the area of the view which can be used to show the source/VPL
  Document *m_document;
  QuantaPlugin *m_plugin;
  TQWidget *m_customWidget; ///<view holds a custom widget, eg. a documentation
  TQGuardedPtr<KafkaDocument> m_kafkaDocument;
  TQSplitter *m_splitter;
  TQGridLayout *m_viewLayout;
  int m_currentViewsLayout; ///< holds the current layout, which can be SourceOnly, VPLOnly or SourceAndVPL
  int m_currentFocus;
  bool m_saveResult;
  bool m_eventLoopStarted;

protected:
  virtual void dropEvent(TQDropEvent *e);
  virtual void dragEnterEvent(TQDragEnterEvent *e);
};

#endif // QUANTAVIEW_H