Back to index

scribus-ng  1.3.4.dfsg+svn20071115
stylecontext.h
Go to the documentation of this file.
00001 /*
00002  For general Scribus (>=1.3.2) copyright and licensing information please refer
00003  to the COPYING file provided with the program. Following this notice may exist
00004  a copyright and/or license notice that predates the release of Scribus 1.3.2
00005  for which a new license (GPL+exception) is in place.
00006  */
00007 /***************************************************************************
00008 *                                                                         *
00009 *   This program is free software; you can redistribute it and/or modify  *
00010 *   it under the terms of the GNU General Public License as published by  *
00011 *   the Free Software Foundation; either version 2 of the License, or     *
00012 *   (at your option) any later version.                                   *
00013 *                                                                         *
00014 ***************************************************************************/
00015 
00016 
00017 #ifndef STYLECONTEXT_H
00018 #define STYLECONTEXT_H
00019 
00020 #include <cassert>
00021 #include <qsignal.h>
00022 #include <qstring.h>
00023 #include <qvaluelist.h>
00024 #include "scribusapi.h"
00025 
00026 
00027 class Style;
00028 
00029 
00036 class SCRIBUS_API StyleContext {
00037        
00038 public:
00039        StyleContext() 
00040        : m_version(0), m_sig(NULL), m_cnt(0)
00041        {
00042 //            qDebug(QString("constr. %1 /%2").arg(reinterpret_cast<uint>(this),16).arg(m_level));
00043        }
00044 
00045        StyleContext(const StyleContext& o) 
00046        : m_version(o.m_version), m_sig(NULL), m_cnt(0)
00047        {
00048 //            qDebug(QString("constr. cp %1 /%2").arg(reinterpret_cast<uint>(this),16).arg(m_level));
00049        }
00050 
00051 
00052        StyleContext& operator= (const StyleContext& o)
00053        {
00054               m_version = o.m_version;
00055               m_cnt = 0;
00056               return *this;
00057        }
00058 
00059 
00060        int version() const  { return m_version; }
00061        
00062        virtual bool contextContained(const StyleContext* context) const { return context == this; }
00063        virtual bool checkConsistency() const { return true; }
00064        virtual const Style* resolve(const QString& name) const = 0;
00065        
00066        virtual ~StyleContext() 
00067        {
00068 //            qDebug(QString("destr. %1").arg(reinterpret_cast<uint>(this),16));
00069               if (m_sig)
00070                      delete m_sig;
00071        }
00072 
00073        void invalidate(); 
00074        
00075        bool connect(const QObject* receiver, const char *member ) const;
00076        bool disconnect(const QObject* receiver, const char *member=0 ) const;
00077        
00078        
00079 protected:
00080        int m_version;
00081        mutable QSignal* m_sig;
00082        mutable int m_cnt;
00083 };
00084 
00085 #endif