34 #include <QtCore/QFile>
35 #include <QtXml/QDomDocument>
38 using namespace Core::Internal;
50 : m_filename(filename)
59 QMap<QString, QKeySequence> result;
61 QFile
file(m_filename);
62 if (!file.open(QIODevice::ReadOnly))
65 QDomDocument doc(
"KeyboardMappingScheme");
66 if (!doc.setContent(&file))
69 QDomElement root = doc.documentElement();
70 if (root.nodeName() != QLatin1String(
"mapping"))
73 QDomElement ks = root.firstChildElement();
74 for (; !ks.isNull(); ks = ks.nextSiblingElement()) {
75 if (ks.nodeName() == QLatin1String(
"shortcut")) {
76 QString
id = ks.attribute(QLatin1String(
"id"));
77 QKeySequence shortcutkey;
78 QDomElement keyelem = ks.firstChildElement(
"key");
79 if (!keyelem.isNull())
80 shortcutkey = QKeySequence(keyelem.attribute(
"value"));
81 result.insert(
id, shortcutkey);
96 QFile
file(m_filename);
97 if (!file.open(QIODevice::WriteOnly))
100 QDomDocument doc(
"KeyboardMappingScheme");
101 QDomElement root = doc.createElement(
"mapping");
102 doc.appendChild(root);
105 QDomElement ctag = doc.createElement(
"shortcut");
106 ctag.setAttribute(QLatin1String(
"id"),
108 root.appendChild(ctag);
110 QDomElement ktag = doc.createElement(
"key");
111 ktag.setAttribute(QLatin1String(
"value"), item->
m_key.toString());
112 ctag.appendChild(ktag);
115 file.write(doc.toByteArray());
static UniqueIDManager * instance()
QMap< QString, QKeySequence > importCommands() const
QString stringForUniqueIdentifier(int uid)
CommandsFile(const QString &filename)
virtual int id() const =0
bool exportCommands(const QList< ShortcutItem * > &items)