]> Shamusworld >> Repos - architektonas/blob - src/base/rs_dialogfactory.cpp
Changed RS_Graphic to Drawing; this is less confusing as a drawing is
[architektonas] / src / base / rs_dialogfactory.cpp
1 // rs_dialogfactory.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  05/28/2010  Added this text. :-)
13 //
14
15 #include "rs_dialogfactory.h"
16
17 #include "rs_debug.h"
18
19 RS_DialogFactory * RS_DialogFactory::uniqueInstance = NULL;
20
21 /**
22  * Private constructor.
23  */
24 RS_DialogFactory::RS_DialogFactory()
25 {
26         RS_DEBUG->print("RS_DialogFacgory::RS_DialogFactory");
27         factoryObject = NULL;
28         RS_DEBUG->print("RS_DialogFacgory::RS_DialogFactory: OK");
29 }
30
31 /**
32  * @return Instance to the unique font list.
33  */
34 RS_DialogFactory * RS_DialogFactory::instance()
35 {
36         RS_DEBUG->print("RS_DialogFactory::instance()");
37
38         if (uniqueInstance == NULL)
39                 uniqueInstance = new RS_DialogFactory();
40
41         RS_DEBUG->print("RS_DialogFactory::instance(): OK");
42
43         return uniqueInstance;
44 }
45
46 /**
47  * Sets the real factory object that can create and show dialogs.
48  */
49 void RS_DialogFactory::setFactoryObject(RS_DialogFactoryInterface * fo)
50 {
51         RS_DEBUG->print("RS_DialogFactory::setFactoryObject");
52         factoryObject = fo;
53         RS_DEBUG->print("RS_DialogFactory::setFactoryObject: OK");
54 }
55
56 /**
57  * @return Factory object. This is never NULL. If no factory
58  * object was set, the default adapter will be returned.
59  */
60 RS_DialogFactoryInterface * RS_DialogFactory::getFactoryObject()
61 {
62         RS_DEBUG->print("RS_DialogFactory::getFactoryObject");
63
64         if (factoryObject != NULL)
65         {
66                 RS_DEBUG->print("RS_DialogFactory::getFactoryObject: returning factory object");
67                 return factoryObject;
68         }
69         else
70         {
71                 RS_DEBUG->print("RS_DialogFactory::getFactoryObject: returning adapter");
72                 return &factoryAdapter;
73         }
74 }
75
76 void RS_DialogFactory::commandMessage(const QString & m)
77 {
78         RS_DEBUG->print("RS_DialogFactory::commandMessage");
79
80         if (factoryObject != NULL)
81                 factoryObject->commandMessage(m);
82 }