mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-11-26 15:20:29 +01:00
2016-05-24 Fred Gleason <fredg@paravelsystems.com>
* Removed all CVS tags. * Removed 'const char *name' parameter from all QObject contructors.
This commit is contained in:
@@ -2,9 +2,7 @@
|
||||
//
|
||||
// An Abstract of the rdhotkeylist
|
||||
//
|
||||
// (C) Copyright 2002-2004,2010 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// $Id: rdhotkeylist.cpp,v 1.2.6.1 2012/12/13 22:33:44 cvs Exp $
|
||||
// (C) Copyright 2002-2004,2010,2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@@ -28,110 +26,110 @@
|
||||
|
||||
RDHotKeyList::RDHotKeyList( )
|
||||
{
|
||||
|
||||
hotkeylist.resize(0);
|
||||
BuildKeyList();
|
||||
hotkeylist.resize(0);
|
||||
BuildKeyList();
|
||||
}
|
||||
|
||||
RDHotKeyList::~RDHotKeyList()
|
||||
{
|
||||
hotkeylist.clear();
|
||||
hotkeylist.clear();
|
||||
}
|
||||
|
||||
void RDHotKeyList::BuildKeyList( )
|
||||
{
|
||||
char qtpath[256];
|
||||
char keyfile[256];
|
||||
char line[256];
|
||||
FILE *hkeyfile;
|
||||
char qtpath[256];
|
||||
char keyfile[256];
|
||||
char line[256];
|
||||
FILE *hkeyfile;
|
||||
|
||||
char enumstring[11] = "enum Key {";
|
||||
QString KeyString;
|
||||
QString KeyHex;
|
||||
QString Filestring;
|
||||
keyList CurKey;
|
||||
char *p = {0};
|
||||
char enumstring[11] = "enum Key {";
|
||||
QString KeyString;
|
||||
QString KeyHex;
|
||||
QString Filestring;
|
||||
keyList CurKey;
|
||||
char *p = {0};
|
||||
|
||||
if(getenv("QTDIR")==NULL) {
|
||||
return;
|
||||
if(getenv("QTDIR")==NULL) {
|
||||
return;
|
||||
}
|
||||
strcpy(qtpath, (const char *) getenv("QTDIR"));
|
||||
strcpy(keyfile,qtpath);
|
||||
strcat(keyfile,"/include/qnamespace.h");
|
||||
hkeyfile = fopen(keyfile,"r");
|
||||
if (hkeyfile==NULL) {
|
||||
return;
|
||||
}
|
||||
if (fgets(line,256,hkeyfile) !=NULL) {
|
||||
while ((p = strstr(line,enumstring))== NULL ) {
|
||||
if (fgets(line,256,hkeyfile) == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
strcpy(qtpath, (const char *) getenv("QTDIR"));
|
||||
strcpy(keyfile,qtpath);
|
||||
strcat(keyfile,"/include/qnamespace.h");
|
||||
hkeyfile = fopen(keyfile,"r");
|
||||
if (hkeyfile==NULL) {
|
||||
return;
|
||||
if (p != NULL) {
|
||||
while ( ( fgets(line,256,hkeyfile) != NULL) && (!(strstr(line,"}")) ) ) {
|
||||
QString buf = cleanStrings(QString().sprintf("%s",line));
|
||||
int acomment = buf.find("//");
|
||||
int eqsign = buf.find("=");
|
||||
if ((eqsign != -1) && (acomment != 0) ) {
|
||||
KeyString = buf.left((eqsign ));
|
||||
KeyString = KeyString.mid(4); // Remove 'Key_'
|
||||
int comma = buf.find(",");
|
||||
if (comma != -1) {
|
||||
KeyHex = buf.mid((eqsign + 1),
|
||||
(comma - eqsign)-1 );
|
||||
}
|
||||
else {
|
||||
int comment = buf.find("//");
|
||||
if (comment != -1) {
|
||||
KeyHex = buf.mid( (eqsign+1),
|
||||
(comment - eqsign) );
|
||||
}
|
||||
else {
|
||||
KeyHex = buf.mid( (eqsign+1),
|
||||
(buf.length() - eqsign) );
|
||||
}
|
||||
}
|
||||
bool ok;
|
||||
int hotkey_int = KeyHex.toInt(&ok,16); //Convert to decimal
|
||||
if (ok) {
|
||||
CurKey.decvalue = hotkey_int;
|
||||
CurKey.stringvalue = KeyString;
|
||||
hotkeylist.push_back(CurKey) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fgets(line,256,hkeyfile) !=NULL) {
|
||||
while ((p = strstr(line,enumstring))== NULL ) {
|
||||
if (fgets(line,256,hkeyfile) == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (p != NULL) {
|
||||
while ( ( fgets(line,256,hkeyfile) != NULL) && (!(strstr(line,"}")) ) ) {
|
||||
QString buf = cleanStrings(QString().sprintf("%s",line));
|
||||
int acomment = buf.find("//");
|
||||
int eqsign = buf.find("=");
|
||||
if ((eqsign != -1) && (acomment != 0) ) {
|
||||
KeyString = buf.left((eqsign ));
|
||||
KeyString = KeyString.mid(4); // Remove 'Key_'
|
||||
int comma = buf.find(",");
|
||||
if (comma != -1) {
|
||||
KeyHex = buf.mid((eqsign + 1),
|
||||
(comma - eqsign)-1 );
|
||||
}
|
||||
else {
|
||||
int comment = buf.find("//");
|
||||
if (comment != -1) {
|
||||
KeyHex = buf.mid( (eqsign+1),
|
||||
(comment - eqsign) );
|
||||
}
|
||||
else {
|
||||
KeyHex = buf.mid( (eqsign+1),
|
||||
(buf.length() - eqsign) );
|
||||
}
|
||||
}
|
||||
bool ok;
|
||||
int hotkey_int = KeyHex.toInt(&ok,16); //Convert to decimal
|
||||
if (ok) {
|
||||
CurKey.decvalue = hotkey_int;
|
||||
CurKey.stringvalue = KeyString;
|
||||
hotkeylist.push_back(CurKey) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(hkeyfile);
|
||||
}
|
||||
fclose(hkeyfile);
|
||||
}
|
||||
|
||||
|
||||
QString RDHotKeyList::cleanStrings( const QString sent)
|
||||
{
|
||||
QString cleanstring;
|
||||
for (unsigned i=0 ; i<sent.length(); i++) {
|
||||
switch(((const char *)sent)[i]) {
|
||||
case '\n':
|
||||
break;
|
||||
case '\t':
|
||||
break;
|
||||
case ' ':
|
||||
break;
|
||||
default:
|
||||
cleanstring+=((const char *)sent)[i];
|
||||
break;
|
||||
}
|
||||
QString cleanstring;
|
||||
for (unsigned i=0 ; i<sent.length(); i++) {
|
||||
switch(((const char *)sent)[i]) {
|
||||
case '\n':
|
||||
break;
|
||||
case '\t':
|
||||
break;
|
||||
case ' ':
|
||||
break;
|
||||
default:
|
||||
cleanstring+=((const char *)sent)[i];
|
||||
break;
|
||||
}
|
||||
return cleanstring;
|
||||
}
|
||||
return cleanstring;
|
||||
}
|
||||
|
||||
|
||||
QString RDHotKeyList::GetKeyCode(int number)
|
||||
{
|
||||
for (unsigned i = 0; i < hotkeylist.size(); i++) {
|
||||
if ((hotkeylist.at(i).decvalue) == number){
|
||||
return hotkeylist.at(i).stringvalue;
|
||||
}
|
||||
}
|
||||
return (QString(""));
|
||||
for (unsigned i = 0; i < hotkeylist.size(); i++) {
|
||||
if ((hotkeylist.at(i).decvalue) == number){
|
||||
return hotkeylist.at(i).stringvalue;
|
||||
}
|
||||
}
|
||||
return (QString(""));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user