Menu

[c54480]: / shortcuts.cpp  Maximize  Restore  History

Download this file

114 lines (103 with data), 3.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include <QDebug>
#include <QMultiMap>
#include <iostream>
using namespace std;
#include "shortcuts.h"
/////////////////////////////////////////////////////////////////
// KeySwitch
/////////////////////////////////////////////////////////////////
KeySwitch::KeySwitch (
const QString &kIdentifier,
const QString &kName,
const QString &kGroup,
const QString &kTag,
const QKeySequence &kseq)
{
identifier = kIdentifier;
name = kName;
group = kGroup;
tag = kTag;
keySequence = kseq;
}
/////////////////////////////////////////////////////////////////
// Switchboard
/////////////////////////////////////////////////////////////////
Switchboard::Switchboard ()
{
}
void Switchboard::addGroup( QString gIdentifier, QString gName)
{
if (groups.contains(gIdentifier))
{
qDebug() << "Warning switchboard: Shortcut group " << gIdentifier << " already exists";
return;
}
groups.insert(gIdentifier, gName);
}
void Switchboard::addSwitch( QString identifier, QString scope, QAction *action, QString tag)
{
if (!switches.contains(identifier))
{
KeySwitch ksw(identifier, action->text(), scope, tag, action->shortcut());
switches.insert(scope, ksw);
} else
qDebug() << "Warning switchboard::addSwitch warning: Existing idenifier " << identifier;
}
QString Switchboard::getASCII()
{
QString s;
QString g;
foreach (g, switches.uniqueKeys())
{
s += "Scope " + g +":\n";
QList <KeySwitch> values=switches.values(g);
for (int i=0; i<values.size(); ++i)
{
QString desc=values.at(i).name;
QString sc=values.at(i).keySequence.toString();
desc=desc.remove('&');
desc=desc.remove("...");
s += QString(" %1: %2\n").arg(sc,12).arg(desc);
}
s += "\n";
}
/*
foreach (g, actions.uniqueKeys())
{
s += g +"\n";
QList <QAction*> values=actions.values(g);
for (int i=0;i<values.size();++i)
{
QString desc=values.at(i)->text();
QString sc=values.at(i)->shortcut().toString();
desc=desc.remove('&');
desc=desc.remove("...");
s+= QString(" %1: %2\n").arg(sc,12).arg(desc);
}
}
*/
return s;
}
void Switchboard::printASCII ()
{
cout <<qPrintable(getASCII() );
}
void Switchboard::printLaTeX ()
{
QString g;
foreach (g,actions.uniqueKeys())
{
cout <<"Group: "<<qPrintable(g)<<"\\\\ \\hline"<<endl;
QList <QAction*> values=actions.values(g);
for (int i=0;i<values.size();++i)
if (!values.at(i)->shortcut().toString().isEmpty())
{
QString desc=values.at(i)->text();
QString sc=values.at(i)->shortcut().toString();
desc=desc.remove('&');
desc=desc.remove("...");
cout << qPrintable( QString(" %1& %2").arg(sc,12).arg(desc) )<<endl;
}
cout <<endl;
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.