GotoDialog.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "GotoDialog.h"
  2. #include "DebugSession.h"
  3. #include "Convert.h"
  4. #include <QCompleter>
  5. GotoDialog::GotoDialog(const MemoryLayout& ml, DebugSession *session, QWidget* parent)
  6. : QDialog(parent), memLayout(ml), currentSymbol(0)
  7. {
  8. setupUi(this);
  9. debugSession = session;
  10. if( session ) {
  11. // create address completer
  12. QCompleter *completer = new QCompleter(session->symbolTable().labelList(true, &ml), this);
  13. completer->setCaseSensitivity(Qt::CaseInsensitive);
  14. edtAddress->setCompleter(completer);
  15. connect(completer, SIGNAL(activated(const QString&)), this, SLOT(addressChanged(const QString&)));
  16. }
  17. connect(edtAddress, SIGNAL(textEdited(const QString&)), this, SLOT(addressChanged(const QString&)));
  18. }
  19. int GotoDialog::address()
  20. {
  21. if(currentSymbol)
  22. return currentSymbol->value();
  23. else
  24. return stringToValue(edtAddress->text());
  25. }
  26. void GotoDialog::addressChanged(const QString& text)
  27. {
  28. int addr = stringToValue(text);
  29. if (addr == -1 && debugSession) {
  30. // try finding a label
  31. currentSymbol = debugSession->symbolTable().getAddressSymbol(text);
  32. if (!currentSymbol) currentSymbol = debugSession->symbolTable().getAddressSymbol(text, Qt::CaseInsensitive);
  33. if (currentSymbol) addr = currentSymbol->value();
  34. }
  35. QPalette pal;
  36. pal.setColor(QPalette::Text, addr==-1 ? Qt::red : Qt::black);
  37. edtAddress->setPalette(pal);
  38. }