Scribus
Open source desktop publishing at your fingertips
stylecontext.h
1 /*
2  For general Scribus (>=1.3.2) copyright and licensing information please refer
3  to the COPYING file provided with the program. Following this notice may exist
4  a copyright and/or license notice that predates the release of Scribus 1.3.2
5  for which a new license (GPL+exception) is in place.
6  */
7 /***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15 
16 
17 #ifndef STYLECONTEXT_H
18 #define STYLECONTEXT_H
19 
20 #include <cassert>
21 #include <QString>
22 #include <QList>
23 #include "scribusapi.h"
24 #include "observable.h"
25 
26 class Style;
27 
28 
35 class SCRIBUS_API StyleContext : public Observable<StyleContext> {
36 
37 public:
38  StyleContext()
39  : m_version(0), m_cnt(0)
40  {
41 // qDebug() << QString("constr. %1 /%2").arg(reinterpret_cast<uint>(this),16).arg(m_level);
42  }
43 
44  StyleContext(const StyleContext& o)
45  : m_version(o.m_version), m_cnt(0)
46  {
47 // qDebug() << QString("constr. cp %1 /%2").arg(reinterpret_cast<uint>(this),16).arg(m_level);
48  }
49 
50 
51  StyleContext& operator= (const StyleContext& o)
52  {
53  m_version = o.m_version;
54  m_cnt = 0;
55  return *this;
56  }
57 
58 
59  int version() const { return m_version; }
60 
61  virtual bool contextContained(const StyleContext* context) const { return context == this; }
62  virtual bool checkConsistency() const { return true; }
63  virtual const Style* resolve(const QString& name) const = 0;
64  virtual ~StyleContext()
65  {
66 // qDebug(QString("destr. %1").arg(reinterpret_cast<uint>(this),16));
67  }
68 
69  void invalidate();
70 
71  bool connect(QObject* receiver, const char *member ) const;
72  bool disconnect(QObject* receiver, const char *member=0 ) const;
73 
74 
75 protected:
76  int m_version;
77  mutable int m_cnt;
78 };
79 
80 Q_DECLARE_METATYPE(StyleContext*);
81 
82 #endif
Definition: stylecontext.h:35
Definition: style.h:37
Definition: observable.h:206