bool ProgramMemoryWindow
::eventFilter(QObject *target,
QEvent *event
) {
if (target == m_pProgamWindow)
{
if (event
->type
() == QEvent::KeyPress) {
QKeyEvent *keyEvent
= static_cast<QKeyEvent
*>
(event
);
if ((keyEvent->key() == Qt::Key_unknown)||(keyEvent->key() == 0))
{
return true;
}
if (str1)
{
char ch = *(str1.ascii());
bool res = true;
if (((ch <= '9' && ch >= '0') | (ch <= 'F' && ch >= 'A') |
(ch <= 'f' && ch >= 'a')))
{
int para,index;
static char chcnt=0;
chcnt++;
m_pProgamWindow->getCursorPosition(¶,&index);
if ((index % 3 == 0))
{
m_pProgamWindow->setCursorPosition(para,index+1);
chcnt = 0;
}
if ((index == 54) && (para == 15))
{
return true;
}
m_pProgamWindow->getCursorPosition(¶,&index);
char value;
getAddressFromPosition(para,index,ch,&value);
char str[4];
if ((value<0x7f)&&(value>0x1F))
str[0]= value;
else
str[0] = 0x2e;
str[1]= '\0';
unsigned int asciipos = ((index - 7)/3)+55;
m_pProgamWindow->setSelection(para,asciipos,para,asciipos+1,0);
m_pProgamWindow->removeSelectedText(0);
m_pProgamWindow
->setColor
(QColor(255,
0,
0));
m_pProgamWindow->insertAt(str,para,asciipos);
m_pProgamWindow->selectAll(false);
m_pProgamWindow->setCursorPosition(para,index);
m_pProgamWindow->setSelection(para,index,para,index+1,0);
m_pProgamWindow
->setColor
(QColor(255,
0,
0));
return QWidget::eventFilter(target, event
);
}
}
if ((keyEvent->key() == Qt::Key_Left )||(keyEvent->key() == Qt::Key_Up )||
(keyEvent->key()==Qt::Key_Right )||(keyEvent->key()==Qt::Key_Down ))
{
return QWidget::eventFilter(target, event
);
}
if ((keyEvent->key()==Qt::Key_Enter)||(keyEvent->key()==Qt::Key_Return))
{
saveContents();
return true;
}
if ((keyEvent->key()==Qt::Key_Escape))
{
revertData();
return true;
}
if ((keyEvent->key()==Qt::Key_PageDown))
{
onDownScrollClicked();
return true;
}
if ((keyEvent->key()==Qt::Key_PageUp))
{
onUpScrollClicked();
return true;
}
return true;
}
if ((event
->type
()== QEvent::Wheel)) {
return true;
}
if(!((event->type()== 10)||(event->type()== 11)||(event->type()== 24)||(event->type()== 25)||(event->type()== 12)))
return QWidget::eventFilter(target, event
);
}
return QWidget::eventFilter(target, event
);
}
bool ProgramMemoryWindow::eventFilter(QObject *target, QEvent *event)
{
if (target == m_pProgamWindow)
{
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if ((keyEvent->key() == Qt::Key_unknown)||(keyEvent->key() == 0))
{
return true;
}
QString str1 = keyEvent->text();
if (str1)
{
char ch = *(str1.ascii());
bool res = true;
if (((ch <= '9' && ch >= '0') | (ch <= 'F' && ch >= 'A') |
(ch <= 'f' && ch >= 'a')))
{
int para,index;
static char chcnt=0;
chcnt++;
m_pProgamWindow->getCursorPosition(¶,&index);
if ((index % 3 == 0))
{
m_pProgamWindow->setCursorPosition(para,index+1);
chcnt = 0;
}
if ((index == 54) && (para == 15))
{
return true;
}
m_pProgamWindow->getCursorPosition(¶,&index);
char value;
getAddressFromPosition(para,index,ch,&value);
char str[4];
if ((value<0x7f)&&(value>0x1F))
str[0]= value;
else
str[0] = 0x2e;
str[1]= '\0';
unsigned int asciipos = ((index - 7)/3)+55;
m_pProgamWindow->setSelection(para,asciipos,para,asciipos+1,0);
m_pProgamWindow->removeSelectedText(0);
m_pProgamWindow->setColor(QColor(255,0,0));
m_pProgamWindow->insertAt(str,para,asciipos);
m_pProgamWindow->selectAll(false);
m_pProgamWindow->setCursorPosition(para,index);
m_pProgamWindow->setSelection(para,index,para,index+1,0);
m_pProgamWindow->setColor(QColor(255,0,0));
return QWidget::eventFilter(target, event);
}
}
if ((keyEvent->key() == Qt::Key_Left )||(keyEvent->key() == Qt::Key_Up )||
(keyEvent->key()==Qt::Key_Right )||(keyEvent->key()==Qt::Key_Down ))
{
return QWidget::eventFilter(target, event);
}
if ((keyEvent->key()==Qt::Key_Enter)||(keyEvent->key()==Qt::Key_Return))
{
saveContents();
return true;
}
if ((keyEvent->key()==Qt::Key_Escape))
{
revertData();
return true;
}
if ((keyEvent->key()==Qt::Key_PageDown))
{
onDownScrollClicked();
return true;
}
if ((keyEvent->key()==Qt::Key_PageUp))
{
onUpScrollClicked();
return true;
}
return true;
}
if ((event->type()== QEvent::Wheel))
{
return true;
}
if(!((event->type()== 10)||(event->type()== 11)||(event->type()== 24)||(event->type()== 25)||(event->type()== 12)))
return QWidget::eventFilter(target, event);
}
return QWidget::eventFilter(target, event);
}
To copy to clipboard, switch view to plain text mode
Bookmarks