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
QMap< QString, QString > action_attributes_
QVector< QMap< QString, QString > > groups_
const QString & pluginId() const
PluginDescriptor(const QString &plugin_id, const QMap< QString, QString > &attributes=(QMap< QString, QString >()))
QMap< QString, QString > attributes_
const QMap< QString, QString > & attributes() const
QMap< QString, QString > group(int index) const
void addGroupAttributes(const QString &label, const QString &statustip=QString(), const QString &icon=QString(), const QString &icontype=QString())
QMap< QString, QString > toDictionary() const
void setActionAttributes(const QString &label, const QString &statustip=QString(), const QString &icon=QString(), const QString &icontype=QString())
const QMap< QString, QString > & actionAttributes() const


qt_gui_cpp
Author(s): Dirk Thomas
autogenerated on Tue Apr 13 2021 03:03:14