plugin_descriptor.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, Dirk Thomas, TU Darmstadt
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following
13  * disclaimer in the documentation and/or other materials provided
14  * with the distribution.
15  * * Neither the name of the TU Darmstadt nor the names of its
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
34 
35 namespace qt_gui_cpp {
36 
37 PluginDescriptor::PluginDescriptor(const QString& plugin_id, const QMap<QString, QString>& attributes)
38 {
39  plugin_id_ = plugin_id;
41 }
42 
43 const QString& PluginDescriptor::pluginId() const
44 {
45  return plugin_id_;
46 }
47 
48 const QMap<QString, QString>& PluginDescriptor::attributes() const
49 {
50  return attributes_;
51 }
52 
53 QMap<QString, QString>& PluginDescriptor::attributes()
54 {
55  return attributes_;
56 }
57 
58 const QMap<QString, QString>& PluginDescriptor::actionAttributes() const
59 {
60  return action_attributes_;
61 }
62 
63 void PluginDescriptor::setActionAttributes(const QString& label, const QString& statustip, const QString& icon, const QString& icontype)
64 {
65  action_attributes_["label"] = label;
66  action_attributes_["statustip"] = statustip;
67  action_attributes_["icon"] = icon;
68  action_attributes_["icontype"] = icontype;
69 }
70 
72 {
73  return groups_.size();
74 }
75 
76 QMap<QString, QString> PluginDescriptor::group(int index) const
77 {
78  return groups_[index];
79 }
80 
81 void PluginDescriptor::addGroupAttributes(const QString& label, const QString& statustip, const QString& icon, const QString& icontype)
82 {
83  QMap<QString, QString> attributes;
84  attributes["label"] = label;
85  attributes["statustip"] = statustip;
86  attributes["icon"] = icon;
87  attributes["icontype"] = icontype;
88  groups_.append(attributes);
89 }
90 
91 QMap<QString, QString> PluginDescriptor::toDictionary() const
92 {
93  QMap<QString, QString> dict;
94  QString plugin_prefix = plugin_id_ + ".";
95  dict[plugin_prefix + "plugin_id"] = plugin_id_;
96  for (QMap<QString, QString>::const_iterator it = attributes_.constBegin(); it != attributes_.constEnd(); it++)
97  {
98  dict[plugin_prefix + QString("attributes.") + it.key()] = it.value();
99  }
100  for (QMap<QString, QString>::const_iterator it = action_attributes_.constBegin(); it != action_attributes_.constEnd(); it++)
101  {
102  dict[plugin_prefix + QString("action.") + it.key()] = it.value();
103  }
104  int group_index = 1;
105  for (QVector<QMap<QString, QString> >::const_iterator it = groups_.constBegin(); it != groups_.constEnd(); it++)
106  {
107  QString prefix = QString("groups.") + QString::number(group_index) + QString(".");
108  for (QMap<QString, QString>::const_iterator jt = it->constBegin(); jt != it->constEnd(); jt++)
109  {
110  dict[plugin_prefix + prefix + jt.key()] = jt.value();
111  }
112  group_index++;
113  }
114  return dict;
115 }
116 
117 } // namespace
qt_gui_cpp::PluginDescriptor::plugin_id_
QString plugin_id_
Definition: plugin_descriptor.h:70
plugin_descriptor.h
qt_gui_cpp::PluginDescriptor::groups_
QVector< QMap< QString, QString > > groups_
Definition: plugin_descriptor.h:76
qt_gui_cpp::PluginDescriptor::action_attributes_
QMap< QString, QString > action_attributes_
Definition: plugin_descriptor.h:74
qt_gui_cpp::PluginDescriptor::PluginDescriptor
PluginDescriptor(const QString &plugin_id, const QMap< QString, QString > &attributes=(QMap< QString, QString >()))
Definition: plugin_descriptor.cpp:37
qt_gui_cpp::PluginDescriptor::pluginId
const QString & pluginId() const
Definition: plugin_descriptor.cpp:43
qt_gui_cpp::PluginDescriptor::actionAttributes
const QMap< QString, QString > & actionAttributes() const
Definition: plugin_descriptor.cpp:58
qt_gui_cpp::PluginDescriptor::attributes_
QMap< QString, QString > attributes_
Definition: plugin_descriptor.h:72
qt_gui_cpp::PluginDescriptor::group
QMap< QString, QString > group(int index) const
Definition: plugin_descriptor.cpp:76
qt_gui_cpp::PluginDescriptor::countGroups
int countGroups() const
Definition: plugin_descriptor.cpp:71
qt_gui_cpp::PluginDescriptor::toDictionary
QMap< QString, QString > toDictionary() const
Definition: plugin_descriptor.cpp:91
qt_gui_cpp
Definition: composite_plugin_provider.h:44
qt_gui_cpp::PluginDescriptor::setActionAttributes
void setActionAttributes(const QString &label, const QString &statustip=QString(), const QString &icon=QString(), const QString &icontype=QString())
Definition: plugin_descriptor.cpp:63
qt_gui_cpp::PluginDescriptor::addGroupAttributes
void addGroupAttributes(const QString &label, const QString &statustip=QString(), const QString &icon=QString(), const QString &icontype=QString())
Definition: plugin_descriptor.cpp:81
qt_gui_cpp::PluginDescriptor::attributes
const QMap< QString, QString > & attributes() const
Definition: plugin_descriptor.cpp:48


qt_gui_cpp
Author(s): Dirk Thomas
autogenerated on Sat Jun 25 2022 02:15:07