|
| 1 | +/*============================================================================== |
| 2 | +
|
| 3 | +Copyright (c) Laboratory for Percutaneous Surgery (PerkLab) |
| 4 | +Queen's University, Kingston, ON, Canada. All Rights Reserved. |
| 5 | +
|
| 6 | +See COPYRIGHT.txt |
| 7 | +or http://www.slicer.org/copyright/copyright.txt for details. |
| 8 | +
|
| 9 | +Unless required by applicable law or agreed to in writing, software |
| 10 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +See the License for the specific language governing permissions and |
| 13 | +limitations under the License. |
| 14 | +
|
| 15 | +This file was originally developed by Kyle Sunderland, PerkLab, Queen's University |
| 16 | +and was supported through CANARIE's Research Software Program, and Cancer |
| 17 | +Care Ontario. |
| 18 | +
|
| 19 | +==============================================================================*/ |
| 20 | + |
| 21 | +// QtGUI includes |
| 22 | +#include "qSlicerSingletonViewFactory.h" |
| 23 | + |
| 24 | +#include <QDebug> |
| 25 | +#include <QMap> |
| 26 | +#include <QSharedPointer> |
| 27 | +#include <QWidget> |
| 28 | + |
| 29 | +//----------------------------------------------------------------------------- |
| 30 | +class qSlicerSingletonViewFactoryPrivate |
| 31 | +{ |
| 32 | + Q_DECLARE_PUBLIC(qSlicerSingletonViewFactory); |
| 33 | +public: |
| 34 | + qSlicerSingletonViewFactoryPrivate(qSlicerSingletonViewFactory& object); |
| 35 | + virtual ~qSlicerSingletonViewFactoryPrivate(); |
| 36 | + |
| 37 | + virtual void init(); |
| 38 | + |
| 39 | + QSharedPointer<QWidget> Widget; |
| 40 | + QString TagName; |
| 41 | + |
| 42 | +protected: |
| 43 | + qSlicerSingletonViewFactory* q_ptr; |
| 44 | +}; |
| 45 | + |
| 46 | +//----------------------------------------------------------------------------- |
| 47 | +// qSlicerSingletonViewFactoryPrivate methods |
| 48 | + |
| 49 | +qSlicerSingletonViewFactoryPrivate |
| 50 | +::qSlicerSingletonViewFactoryPrivate(qSlicerSingletonViewFactory& object) |
| 51 | + : q_ptr(&object) |
| 52 | + , Widget(NULL) |
| 53 | +{ |
| 54 | +} |
| 55 | + |
| 56 | +//----------------------------------------------------------------------------- |
| 57 | +qSlicerSingletonViewFactoryPrivate::~qSlicerSingletonViewFactoryPrivate() |
| 58 | +{ |
| 59 | +} |
| 60 | + |
| 61 | +//----------------------------------------------------------------------------- |
| 62 | +void qSlicerSingletonViewFactoryPrivate::init() |
| 63 | +{ |
| 64 | +} |
| 65 | + |
| 66 | +//----------------------------------------------------------------------------- |
| 67 | +// qSlicerSingletonViewFactory methods |
| 68 | + |
| 69 | +//----------------------------------------------------------------------------- |
| 70 | +qSlicerSingletonViewFactory::qSlicerSingletonViewFactory(QObject* parent) |
| 71 | + : Superclass(parent) |
| 72 | + , d_ptr(new qSlicerSingletonViewFactoryPrivate(*this)) |
| 73 | +{ |
| 74 | + Q_D(qSlicerSingletonViewFactory); |
| 75 | + d->init(); |
| 76 | + this->setUseCachedViews(false); |
| 77 | +} |
| 78 | + |
| 79 | +//----------------------------------------------------------------------------- |
| 80 | +qSlicerSingletonViewFactory::~qSlicerSingletonViewFactory() |
| 81 | +{ |
| 82 | +} |
| 83 | + |
| 84 | + |
| 85 | +//----------------------------------------------------------------------------- |
| 86 | +QWidget* qSlicerSingletonViewFactory::widget() |
| 87 | +{ |
| 88 | + Q_D(qSlicerSingletonViewFactory); |
| 89 | + return d->Widget.data(); |
| 90 | +} |
| 91 | + |
| 92 | +//----------------------------------------------------------------------------- |
| 93 | +void qSlicerSingletonViewFactory::setWidget(QWidget* widget) |
| 94 | +{ |
| 95 | + Q_D(qSlicerSingletonViewFactory); |
| 96 | + d->Widget = QSharedPointer<QWidget>(widget); |
| 97 | +} |
| 98 | + |
| 99 | +//----------------------------------------------------------------------------- |
| 100 | +QString qSlicerSingletonViewFactory::tagName() |
| 101 | +{ |
| 102 | + Q_D(qSlicerSingletonViewFactory); |
| 103 | + return d->TagName; |
| 104 | +} |
| 105 | + |
| 106 | +//----------------------------------------------------------------------------- |
| 107 | +void qSlicerSingletonViewFactory::setTagName(QString tagName) |
| 108 | +{ |
| 109 | + Q_D(qSlicerSingletonViewFactory); |
| 110 | + d->TagName = tagName; |
| 111 | +} |
| 112 | + |
| 113 | +//----------------------------------------------------------------------------- |
| 114 | +QStringList qSlicerSingletonViewFactory::supportedElementNames() const |
| 115 | +{ |
| 116 | + Q_D(const qSlicerSingletonViewFactory); |
| 117 | + return QStringList() << d->TagName; |
| 118 | +} |
| 119 | + |
| 120 | +//--------------------------------------------------------------------------- |
| 121 | +QWidget* qSlicerSingletonViewFactory::createViewFromXML(QDomElement layoutElement) |
| 122 | +{ |
| 123 | + Q_D(qSlicerSingletonViewFactory); |
| 124 | + if (this->widget()->isVisible()) |
| 125 | + { |
| 126 | + qCritical() << "qSlicerSingletonViewFactory::createViewFromXML - Widget for view \"" << d->TagName << "\" is already in use within the current layout!"; |
| 127 | + } |
| 128 | + |
| 129 | + return this->widget(); |
| 130 | +} |
0 commit comments