Subversion Repositories Scribus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12850 pierre 1
//
2
// C++ Implementation: pageitempointer
3
//
4
// Description: 
5
//
6
//
7
// Author: Pierre Marchand <pierremarc@oep-h.com>, (C) 2008
8
//
9
// Copyright: See COPYING file that comes with this distribution
10
//
11
//
12
 
13
#include "pageitempointer.h"
14
 
15
#include "pageitem.h"
16
 
17
void PageItemPointerDB::addToDB(const QString & key, PageItem * value)
18
{
19
        insert(key,value);
20
        connect ( value,SIGNAL( destroyed ( QObject* ) ),this,SLOT( removeFromDB ( QObject* ) ) );
21
}
22
 
23
void PageItemPointerDB::removeFromDB ( QObject * obj )
24
{
25
        if ( obj )
26
        {
27
                QString k ( obj->objectName() );
28
                remove ( k );
29
        }
30
}
31
 
32
/// PageItemPointer
33
PageItemPointerDB PageItemPointer::PIdb;
34
PageItemPointer::PageItemPointer ( PageItem * pi ) :QPointer<PageItem> ( pi )
35
{
36
        if ( !isNull() )
37
        {
38
                PIdb.addToDB( pi->objectName(), pi);
39
 
40
        }
41
}
42
 
43
PageItemPointer::PageItemPointer ( const PageItemPointer & pip ) :QPointer<PageItem> (PIdb[ pip->objectName() ])
44
{
45
}
46
 
47
PageItemPointer::PageItemPointer(const QString & objname):QPointer<PageItem>(PIdb[objname])
48
{
49
}
50
 
51
PageItemPointer::~PageItemPointer()
52
{
53
 
54
}
55
 
56
QDataStream &operator << ( QDataStream & out , const PageItemPointer& pip )
57
{
58
        out << pip->objectName();
59
        return out;
60
}
61
 
62
QDataStream &operator >> ( QDataStream & in , PageItemPointer& pip )
63
{
64
        QString piName;
65
        in >>  piName;
66
        pip = PageItemPointer(piName);
67
        return in;
68
}
69
 
70
 
71