Sayonara Player
RawShortcutMap.h
1 /* RawShortcutMap.h */
2 
3 /* Copyright (C) 2011-2017 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 
42  for(const QString& key : this->keys()){
43  QString shortcut_name = key;
44  QStringList shortcuts = this->value(key);
45 
46  entries << shortcut_name + ":" + shortcuts.join(", ");
47  }
48 
49  return entries.join(";-;");
50  }
51 
52  static RawShortcutMap fromString(const QString& setting){
53  RawShortcutMap rsc;
54 
55  QStringList entries = setting.split(";-;");
56  for(const QString& entry : entries){
57  QStringList sc_pair = entry.split(":");
58  QString key = sc_pair[0];
59  QString shortcut;
60  if(sc_pair.size() > 1){
61  shortcut = sc_pair[1];
62  }
63 
64  rsc.insert(key, shortcut.split(", "));
65  }
66 
67  return rsc;
68  }
69 };
70 
71 #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