Sayonara Player
RawShortcutMap.h
1 /* RawShortcutMap.h */
2 
3 /* Copyright (C) 2011-2019 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef RAWSHORTCUTMAP_H
22 #define RAWSHORTCUTMAP_H
23 
24 
25 #include <QStringList>
26 #include <QMap>
27 
28 //this class has to be inline because we need this in the settings registry
29 
36  public QMap<QString, QStringList>
37 {
38  QString toString() const
39  {
40  QStringList entries;
41  const QList<QString> l_keys = this->keys();
42 
43  for(const QString& key : l_keys)
44  {
45  QString shortcut_name = key;
46  QStringList shortcuts = this->value(key);
47 
48  entries << shortcut_name + ":" + shortcuts.join(", ");
49  }
50 
51  return entries.join(";-;");
52  }
53 
54  static RawShortcutMap fromString(const QString& setting)
55  {
56  RawShortcutMap rsc;
57 
58  QStringList entries = setting.split(";-;");
59  for(const QString& entry : entries){
60  QStringList sc_pair = entry.split(":");
61  QString key = sc_pair[0];
62  QString shortcut;
63  if(sc_pair.size() > 1){
64  shortcut = sc_pair[1];
65  }
66 
67  rsc.insert(key, shortcut.split(", "));
68  }
69 
70  return rsc;
71  }
72 };
73 
74 #endif // RAWSHORTCUTMAP_H
The RawShortcutMap struct consisting of a specifier writable into database and a shortcut. This class is used for converting a shortcut map into its database representation.
Definition: RawShortcutMap.h:35
Definition: org_mpris_media_player2_adaptor.h:21
Definition: EngineUtils.h:33