Updates Qt trace logger with new debug symbol window.

This commit is contained in:
mjbudd77 2020-12-20 22:14:47 -05:00
parent 8ccf6fe37f
commit 9f6463c0b8
4 changed files with 49 additions and 115 deletions

View File

@ -1313,13 +1313,16 @@ void SymbolEditWindow::setAddr( int addrIn )
addrEntry->setText( tr(stmp) );
if ( addr < 0x8000 )
if ( bank < 0 )
{
bank = -1;
}
else
{
bank = getBank( addr );
if ( addr < 0x8000 )
{
bank = -1;
}
else
{
bank = getBank( addr );
}
}
generateNLFilenameForAddress( addr, stmp );
@ -1328,6 +1331,11 @@ void SymbolEditWindow::setAddr( int addrIn )
filepath->setMinimumWidth( charWidth * (filepath->text().size() + 4) );
}
//--------------------------------------------------------------
void SymbolEditWindow::setBank( int bankIn )
{
bank = bankIn;
}
//--------------------------------------------------------------
void SymbolEditWindow::setSym( debugSymbol_t *symIn )
{
sym = symIn;
@ -1401,9 +1409,7 @@ int SymbolEditWindow::exec(void)
isNew = true;
}
sym->ofs = a;
//sym->name = nameEntry->text().toStdString();
//sym->comment = commentEntry->toPlainText().toStdString();
sym->ofs = a;
if ( (i == 0) || isNew || arrayNameOverWrite->isChecked() )
{

View File

@ -133,6 +133,7 @@ class SymbolEditWindow : public QDialog
~SymbolEditWindow(void);
void setAddr( int addrIn );
void setBank( int bankIn );
void setSym( debugSymbol_t *symIn );
protected:

View File

@ -1105,6 +1105,7 @@ QTraceLogView::QTraceLogView(QWidget *parent)
this->setPalette(pal);
this->setMouseTracking(true);
this->setFocusPolicy(Qt::StrongFocus);
calcFontData();
@ -1331,6 +1332,28 @@ void QTraceLogView::loadClipboard( const char *txt )
}
}
//----------------------------------------------------
void QTraceLogView::keyPressEvent(QKeyEvent *event)
{
//printf("Key Press: %i \n", event->key() );
if ( !textIsHighlighted() )
{
if ( selAddrIdx >= 0 )
{
if ( event->key() == Qt::Key_B )
{
ctxMenuAddBP();
event->accept();
}
else if ( event->key() == Qt::Key_S )
{
ctxMenuAddSym();
event->accept();
}
}
}
}
//----------------------------------------------------
void QTraceLogView::mouseMoveEvent(QMouseEvent * event)
{
QPoint c = convPixToCursor( event->pos() );
@ -1741,118 +1764,21 @@ void QTraceLogView::ctxMenuAddBP(void)
//----------------------------------------------------------------------------
void QTraceLogView::openDebugSymbolEditWindow( int addr, int bank )
{
int ret, charWidth;
QDialog dialog(this);
QHBoxLayout *hbox;
QVBoxLayout *mainLayout;
QLabel *lbl;
QLineEdit *filepath, *addrEntry, *nameEntry, *commentEntry;
QPushButton *okButton, *cancelButton;
char stmp[512];
int ret;
debugSymbol_t *sym;
QFontMetrics fm(font);
SymbolEditWindow win(this);
#if QT_VERSION > QT_VERSION_CHECK(5, 11, 0)
charWidth = fm.horizontalAdvance(QLatin1Char('2'));
#else
charWidth = fm.width(QLatin1Char('2'));
#endif
sym = debugSymbolTable.getSymbolAtBankOffset( bank, addr );
sym = debugSymbolTable.getSymbolAtBankOffset( bank, addr );
win.setAddr( addr );
win.setBank( bank );
generateNLFilenameForAddress( addr, stmp );
win.setSym( sym );
dialog.setWindowTitle( tr("Symbolic Debug Naming") );
hbox = new QHBoxLayout();
mainLayout = new QVBoxLayout();
lbl = new QLabel( tr("File") );
filepath = new QLineEdit();
filepath->setFont( font );
filepath->setText( tr(stmp) );
filepath->setReadOnly( true );
filepath->setMinimumWidth( charWidth * (filepath->text().size() + 4) );
hbox->addWidget( lbl );
hbox->addWidget( filepath );
mainLayout->addLayout( hbox );
sprintf( stmp, "%04X", addr );
hbox = new QHBoxLayout();
lbl = new QLabel( tr("Address") );
addrEntry = new QLineEdit();
addrEntry->setFont( font );
addrEntry->setText( tr(stmp) );
addrEntry->setReadOnly( true );
addrEntry->setAlignment(Qt::AlignCenter);
addrEntry->setMaximumWidth( charWidth * 6 );
hbox->addWidget( lbl );
hbox->addWidget( addrEntry );
lbl = new QLabel( tr("Name") );
nameEntry = new QLineEdit();
hbox->addWidget( lbl );
hbox->addWidget( nameEntry );
mainLayout->addLayout( hbox );
hbox = new QHBoxLayout();
lbl = new QLabel( tr("Comment") );
commentEntry = new QLineEdit();
hbox->addWidget( lbl );
hbox->addWidget( commentEntry );
mainLayout->addLayout( hbox );
hbox = new QHBoxLayout();
okButton = new QPushButton( tr("OK") );
cancelButton = new QPushButton( tr("Cancel") );
mainLayout->addLayout( hbox );
hbox->addWidget( cancelButton );
hbox->addWidget( okButton );
connect( okButton, SIGNAL(clicked(void)), &dialog, SLOT(accept(void)) );
connect( cancelButton, SIGNAL(clicked(void)), &dialog, SLOT(reject(void)) );
okButton->setDefault(true);
if ( sym != NULL )
{
nameEntry->setText( tr(sym->name.c_str()) );
commentEntry->setText( tr(sym->comment.c_str()) );
}
dialog.setLayout( mainLayout );
ret = dialog.exec();
ret = win.exec();
if ( ret == QDialog::Accepted )
{
fceuWrapperLock();
if ( sym == NULL )
{
sym = new debugSymbol_t();
sym->ofs = addr;
sym->name = nameEntry->text().toStdString();
sym->comment = commentEntry->text().toStdString();
debugSymbolTable.addSymbolAtBankOffset( bank, addr, sym );
}
else
{
sym->name = nameEntry->text().toStdString();
sym->comment = commentEntry->text().toStdString();
}
sym->trimTrailingSpaces();
fceuWrapperUnLock();
updateAllDebuggerWindows();
}
}
@ -1909,12 +1835,12 @@ void QTraceLogView::contextMenuEvent(QContextMenuEvent *event)
{
act = new QAction(tr("Add Symbolic Debug Marker"), &menu);
menu.addAction(act);
//act->setShortcut( QKeySequence(tr("S")));
act->setShortcut( QKeySequence(tr("S")));
connect( act, SIGNAL(triggered(void)), this, SLOT(ctxMenuAddSym(void)) );
act = new QAction(tr("Add Breakpoint"), &menu);
menu.addAction(act);
//act->setShortcut( QKeySequence(tr("B")));
act->setShortcut( QKeySequence(tr("B")));
connect( act, SIGNAL(triggered(void)), this, SLOT(ctxMenuAddBP(void)) );
menu.exec(event->globalPos());

View File

@ -73,6 +73,7 @@ class QTraceLogView : public QWidget
void mousePressEvent(QMouseEvent * event);
void mouseReleaseEvent(QMouseEvent * event);
void mouseMoveEvent(QMouseEvent * event);
void keyPressEvent(QKeyEvent *event);
void calcFontData(void);
QPoint convPixToCursor( QPoint p );