]> Shamusworld >> Repos - architektonas/blob - src/base/dialogfactory.cpp
Bugfixes related to removing Snapper class.
[architektonas] / src / base / dialogfactory.cpp
1 // 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 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  05/28/2010  Added this text. :-)
15 //
16
17 #include "dialogfactory.h"
18
19 #include "debug.h"
20
21 DialogFactory * DialogFactory::uniqueInstance = NULL;
22
23 /**
24  * Private constructor.
25  */
26 DialogFactory::DialogFactory()
27 {
28         DEBUG->print("DialogFacgory::DialogFactory");
29         factoryObject = NULL;
30         DEBUG->print("DialogFacgory::DialogFactory: OK");
31 }
32
33 /*virtual*/ DialogFactory::~DialogFactory()
34 {
35 }
36
37 /**
38  * @return Instance to the unique font list.
39  */
40 DialogFactory * DialogFactory::instance()
41 {
42         DEBUG->print("DialogFactory::instance()");
43
44         if (uniqueInstance == NULL)
45                 uniqueInstance = new DialogFactory();
46
47         DEBUG->print("DialogFactory::instance(): OK");
48
49         return uniqueInstance;
50 }
51
52 /**
53  * Sets the real factory object that can create and show dialogs.
54  */
55 void DialogFactory::setFactoryObject(DialogFactoryInterface * fo)
56 {
57         DEBUG->print("DialogFactory::setFactoryObject");
58         factoryObject = fo;
59         DEBUG->print("DialogFactory::setFactoryObject: OK");
60 }
61
62 /**
63  * @return Factory object. This is never NULL. If no factory
64  * object was set, the default adapter will be returned.
65  */
66 DialogFactoryInterface * DialogFactory::getFactoryObject()
67 {
68         DEBUG->print("DialogFactory::getFactoryObject");
69
70         if (factoryObject != NULL)
71         {
72                 DEBUG->print("DialogFactory::getFactoryObject: returning factory object");
73                 return factoryObject;
74         }
75         else
76         {
77                 DEBUG->print("DialogFactory::getFactoryObject: returning adapter");
78                 return &factoryAdapter;
79         }
80 }
81
82 void DialogFactory::commandMessage(const QString & m)
83 {
84         DEBUG->print("DialogFactory::commandMessage");
85
86         if (factoryObject != NULL)
87                 factoryObject->commandMessage(m);
88 }