OpenStructure
Loading...
Searching...
No Matches
widget_pool.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// This file is part of the OpenStructure project <www.openstructure.org>
3//
4// Copyright (C) 2008-2020 by the OpenStructure authors
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License as published by the Free
8// Software Foundation; either version 3.0 of the License, or (at your option)
9// any later version.
10// This library is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this library; if not, write to the Free Software Foundation, Inc.,
17// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18//------------------------------------------------------------------------------
19#ifndef OST_GUI_WIDGET_POOL_HH
20#define OST_GUI_WIDGET_POOL_HH
21
22#include <ost/gui/widget.hh>
23#include <QSettings>
24/*
25 Author: Marco Biasini, Stefan Scheuber
26 */
27namespace ost { namespace gui {
28
30{
32 name(""), available(-1)
33 { }
34
35 PooledWidget(const QString& n, int lim=-1):
36 name(n), available(lim), limit(lim)
37 { }
38 QString name;
40 int limit;
41};
42
45class DLLEXPORT_OST_GUI WidgetPool : public QObject {
46 Q_OBJECT
47public:
48 WidgetPool(QObject* parent=NULL);
49
55 void Add(const QString& name, int limit=-1);
56
60 bool IsAvailable(const QString& name);
61
66 Widget* Create(const QString& name);
67
72 bool Take(const QString& name);
73
78 bool Give(const QString& name);
79
82 QList<QString> GetAvailableWidgets();
83
84private:
85 QMap<QString, PooledWidget> pool_;
86};
87
88}}
89#endif /* OST_GUI_WIDGET_POOL_HH */
Base class for widgets.
Definition widget.hh:40
This Widget pool manages instances of widgets Widgets can be added to this pool by simply passing the...
QList< QString > GetAvailableWidgets()
Get a List with all available Widgets.
Widget * Create(const QString &name)
returns a instance of the given class name It does not WidgetPool::Take(const QString& name) a instan...
bool Give(const QString &name)
Returns a instance of a class into the pool This method returns one instance back into the pool....
bool IsAvailable(const QString &name)
returns whether this class has available instances or not
void Add(const QString &name, int limit=-1)
add a Widget to the WidgetPool This method adds a class to this widget pool. It does NOT add the give...
WidgetPool(QObject *parent=NULL)
bool Take(const QString &name)
Takes a instance of a class out of the pool This method takes one available instances out of the pool...
#define DLLEXPORT_OST_GUI
Definition base.dox:1
PooledWidget(const QString &n, int lim=-1)