summaryrefslogtreecommitdiffstats
path: root/libk3b/projects/k3bdoc.h
blob: 9d7474a155abf1a6b5a01bfc48bc867ed80f41ae (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
/*
 *
 * $Id: k3bdoc.h 619556 2007-01-03 17:38:12Z trueg $
 * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
 *
 * This file is part of the K3b project.
 * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.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.
 * See the file "COPYING" for the exact licensing terms.
 */


#ifndef K3BDOC_H
#define K3BDOC_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

// include files for QT
#include <tqobject.h>
#include <tqstring.h>
#include <tqptrlist.h>


// include files for KDE
#include <kurl.h>
#include <kio/global.h>
#include "k3b_export.h"

// forward declaration of the K3b classes
class TQTimer;
class KTempFile;
class K3bBurnJob;
class TQDomDocument;
class TQDomElement;
class TDEConfig;
class KActionCollection;
class K3bJobHandler;


namespace K3bDevice {
  class Device;
}
namespace K3b {
  class Msf;
}

/**
 * K3bDoc is the base document class.
 * It handles some general settings.
 */
class LIBK3B_EXPORT K3bDoc : public TQObject
{
  Q_OBJECT
  

 public:
  K3bDoc( TQObject* = 0 );
  virtual ~K3bDoc();

  enum DocType { 
    AUDIO = 1, 
    DATA, 
    MIXED, 
    VCD, 
    MOVIX,
    MOVIX_DVD,
    DVD,
    VIDEODVD 
  };

  virtual int type() const { return m_docType; }

  /**
   * \return A name for the project which might for example be used as a suggestion for a file name
   *         when saving. The default implementation extracts a name from the URL.
   */
  virtual TQString name() const;

  /**
   * \return A string representation of the document type.
   */
  virtual TQString typeString() const = 0;

  /** 
   * returns the view widget set with setView() or null if none has been set.
   */
  TQWidget* view() const { return m_view; }

  /**
   * Just for convenience to make an easy mapping from doc to GUI possible.
   */
  void setView( TQWidget* v ) { m_view = v; }

  /** 
   * sets the modified flag for the document after a modifying action on the view connected to the document.
   */
  virtual void setModified( bool m = true );

  /** 
   * returns if the document is modified or not. Use this to determine 
   * if your document needs saving by the user on closing.
   */
  virtual bool isModified() const { return m_modified; }

  /**
   * Subclasses should call this when reimplementing.
   * Sets some defaults.
   */
  virtual bool newDocument();

  /**
   * Load a project from an xml stream.
   *
   * This is used to load/save k3b projects. 
   */
  virtual bool loadDocumentData( TQDomElement* root ) = 0;

  /**
   * Save a project to an xml stream.
   *
   * This is used to load/save k3b projects. 
   */
  virtual bool saveDocumentData( TQDomElement* docElem ) = 0;

  /** returns the KURL of the document */
  const KURL& URL() const;
  /** sets the URL of the document */
  virtual void setURL( const KURL& url );

  int writingMode() const { return m_writingMode; }
  bool dummy() const { return m_dummy; }
  bool onTheFly() const { return m_onTheFly; }
  bool removeImages() const { return m_removeImages; }
  bool onlyCreateImages() const { return m_onlyCreateImages; }
  int copies() const { return m_copies; }
  int speed() const { return m_speed; }
  K3bDevice::Device* burner() const { return m_burner; }
  virtual TDEIO::filesize_t size() const = 0;
  virtual K3b::Msf length() const = 0;

  // FIXME: rename this to something like imagePath
  const TQString& tempDir() const { return m_tempDir; }

  virtual int numOfTracks() const { return 1; }

  /**
   * Create a new BurnJob to burn this project. It is not mandatory to use this
   * method. You may also just create the BurnJob you need manually. It is just 
   * easier this way since you don't need to distinguish between the different
   * project types.
   */
  virtual K3bBurnJob* newBurnJob( K3bJobHandler*, TQObject* parent = 0 ) = 0;

  int writingApp() const { return m_writingApp; }
  void setWritingApp( int a ) { m_writingApp = a; }

  /**
   * @return true if the document has successfully been saved to a file
   */
  bool isSaved() const { return m_saved; }

  /**
   * Used for session management. Use with care.
   */
  void setSaved( bool s ) { m_saved = s; }

 signals:
  void changed();
  void changed( K3bDoc* );

 public slots:
  void setDummy( bool d );
  void setWritingMode( int m ) { m_writingMode = m; }
  void setOnTheFly( bool b ) { m_onTheFly = b; }
  void setSpeed( int speed );
  void setBurner( K3bDevice::Device* dev );
  void setTempDir( const TQString& dir ) { m_tempDir = dir; }
  void setRemoveImages( bool b ) { m_removeImages = b; }
  void setOnlyCreateImages( bool b ) { m_onlyCreateImages = b; }
  void setCopies( int c ) { m_copies = c; }

  /**
   * the default implementation just calls addUrls with
   * list containing the url
   */
  virtual void addUrl( const KURL& url );
  virtual void addUrls( const KURL::List& urls ) = 0;

 protected:
  int m_docType;

  bool saveGeneralDocumentData( TQDomElement* );

  bool readGeneralDocumentData( const TQDomElement& );

 private slots:
  void slotChanged();

 private:
  /** the modified flag of the current document */
  bool m_modified;
  KURL doc_url;

  TQWidget* m_view;

  TQString m_tempDir;
  K3bDevice::Device* m_burner;
  bool m_dummy;
  bool m_onTheFly;
  bool m_removeImages;
  bool m_onlyCreateImages;
  int  m_speed;

  /** see k3bglobals.h */
  int m_writingApp;

  int m_writingMode;

  int m_copies;

  bool m_saved;
};

#endif // K3BDOC_H