summaryrefslogtreecommitdiffstats
path: root/src/libgui/breakpoint_view.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
commitf508189682b6fba62e08feeb1596f682bad5fff9 (patch)
tree28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /src/libgui/breakpoint_view.cpp
downloadpiklab-f508189682b6fba62e08feeb1596f682bad5fff9.tar.gz
piklab-f508189682b6fba62e08feeb1596f682bad5fff9.zip
Added KDE3 version of PikLab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/libgui/breakpoint_view.cpp')
-rw-r--r--src/libgui/breakpoint_view.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/libgui/breakpoint_view.cpp b/src/libgui/breakpoint_view.cpp
new file mode 100644
index 0000000..6f49aac
--- /dev/null
+++ b/src/libgui/breakpoint_view.cpp
@@ -0,0 +1,94 @@
+/***************************************************************************
+ * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "breakpoint_view.h"
+
+#include <qlayout.h>
+#include <klocale.h>
+#include <qpopupmenu.h>
+
+#include "main_global.h"
+#include "editor_manager.h"
+#include "coff/base/text_coff.h"
+#include "gui_debug_manager.h"
+
+//----------------------------------------------------------------------------
+void Breakpoint::updateActions(const Data *data)
+{
+ bool hasBreakpoint = (data ? Breakpoint::list().contains(*data) : false);
+ Main::action("toggle_breakpoint")->setText(hasBreakpoint ? i18n("Remove breakpoint") : i18n("Set breakpoint"));
+ Main::action("toggle_breakpoint")->setEnabled(data);
+ bool isActive = (hasBreakpoint ? Breakpoint::list().state(*data)==Breakpoint::Active : false);
+ Main::action("enable_breakpoint")->setText(!isActive ? i18n("Enable breakpoint") : i18n("Disable breakpoint"));
+ Main::action("enable_breakpoint")->setEnabled(Debugger::manager->coff() && hasBreakpoint);
+}
+
+//----------------------------------------------------------------------------
+Breakpoint::ListViewItem::ListViewItem(ListView *parent, const Data &data)
+ : KListViewItem(parent), _data(data)
+{}
+
+//----------------------------------------------------------------------------
+Breakpoint::View::View(QWidget *parent)
+ : QWidget(parent, "breakpoints_view"), GenericView(Breakpoint::list()),
+ _currentData(0)
+{
+ QVBoxLayout *top = new QVBoxLayout(this);
+ _listview = new ListView(this);
+ connect(_listview, SIGNAL(clicked(QListViewItem *)), SLOT(itemClicked(QListViewItem *)));
+ connect(_listview, SIGNAL(contextMenuRequested(QListViewItem *, const QPoint &, int)),
+ SLOT(contextMenu(QListViewItem *, const QPoint &, int)));
+ _listview->setAllColumnsShowFocus(true);
+ _listview->addColumn(i18n("Status"));
+ _listview->addColumn(i18n("Location"));
+ _listview->addColumn(i18n("Address"));
+ top->addWidget(_listview);
+}
+
+void Breakpoint::View::updateView()
+{
+ // #### flickering...
+ _listview->clear();
+ for (uint i=0; i<Breakpoint::list().count(); i++) {
+ const Data &data = Breakpoint::list().data(i);
+ KListViewItem *item = new ListViewItem(_listview, data);
+ item->setPixmap(0, TextEditor::pixmap(Debugger::manager->breakpointType(data)));
+ item->setText(1, data.url.filename() + ":" + QString::number(data.line));
+ Address address = Breakpoint::list().address(data);
+ if ( address.isValid() ) item->setText(2, toHexLabelAbs(address));
+ else if ( Debugger::manager->coff() ) item->setText(2, i18n("Non-code breakpoint"));
+ else item->setText(2, "---");
+ }
+}
+
+void Breakpoint::View::itemClicked(QListViewItem *item)
+{
+ if ( item==0 ) return;
+ const Data &data = static_cast<ListViewItem *>(item)->data();
+ Address address = Breakpoint::list().address(data);
+ TextEditor *editor = ::qt_cast<TextEditor *>(Main::currentEditor());
+ const Coff::TextObject *coff = Debugger::manager->coff();
+ int line = -1;
+ if ( coff && editor && editor->fileType()==PURL::Coff && address.isValid() )
+ line = coff->lineForAddress(editor->url(), address);
+ if ( line==-1 ) {
+ editor = ::qt_cast<TextEditor *>(Main::editorManager().openEditor(data.url));
+ line = data.line;
+ }
+ if ( editor==0 ) return;
+ editor->show();
+ editor->setCursor(line, 0);
+}
+
+void Breakpoint::View::contextMenu(QListViewItem *item, const QPoint &pos, int)
+{
+ _currentData = (item ? &static_cast<ListViewItem *>(item)->data() : 0);
+ updateActions(_currentData);
+ Main::popup("breakpoint_context_menu").exec(pos);
+ _currentData = 0;
+}