Switching between decimal and hex watch-display
rgruber at users.sourceforge.net
rgruber at users.sourceforge.net
Fri Feb 6 00:20:10 UTC 2004
Hello,
I\'ve done a lot of debugging last week and I was very confused about the fact that KDevelop still has no possibility to switch between decimal and hex watch-display. So I\'ve decided to hack a bit and here it is!
I\'ve added an entry to the popup menu which opens if you righ-click a variable that is already in the watch-list. Everytime you select that entry, the selected watch toggles between no formating and hex-value formating. The converting is done by adding \"/x\" infront of the variablename. I\'ve tested it pretty hard and for me it workes very well.
If you\'re interested in adding this to KDevelop, you can download variablewidget.[cpp,h] from http://kmp3indexer.sf.net/misc/ or alternatively I\'ve appended the cvs diffs for the two files.
Best regards,
Robert Gruber
BTW: This will close the bug #60670 from bugs.kde.org
---
Robert Gruber -=- rgruber at users.sourceforge.net
CVS Diffs:
----------
Index: variablewidget.cpp
===================================================================
RCS file: /home/kde/kdevelop/languages/cpp/debugger/variablewidget.cpp,v
retrieving revision 1.34
diff -r1.34 variablewidget.cpp
78a79
>
132a134
>
154a157
> connect( this, SIGNAL(toggleRadix(QListViewItem*)), SLOT(slotToggleRadix(QListViewItem*)) );
187a191
> int idToggleRadix = popup.insertItem( i18n(\"Toggle Hex/Decimal\") );
192a197,198
> if (res == idToggleRadix)
> emit toggleRadix(item);
378a385,412
> /* rgruber:
> * this it the slot which is connected to the toggleRadix() signal
> * it removes the given watch variable an replaces it by another
> * watch that includes a format modifier
> */
> void VariableTree::slotToggleRadix(QListViewItem * item)
> {
> if (item==NULL) //no item->nothing to do
> return;
>
> VarItem *pOldItem = dynamic_cast<VarItem*>(item);
> VarItem *pNewItem = NULL;
>
> QString strName = pOldItem->text(VarNameCol);
> if (strName.left(3) == \"/x \") //are we already in hex-view ???
> strName = strName.right(strName.length()-3); //stripe the hex-formater
> else
> strName = QString(\"/x \")+strName; //add the hex-formater
>
> pNewItem = new VarItem((TrimmableItem *) item->parent(), strName, typeUnknown);
> emit expandItem(pNewItem);
>
> pNewItem->moveItem(pOldItem); //move the new item up right under the old one
>
> delete item; //remove the old one so that is seam as if it was replaced by the new item
> pOldItem=NULL;
> }
>
453a488,491
> bool bRenew=false; //this indicates if the current item needs to be replaced by a new one.
> //the problem is, that the debugger always replaces already
> //format-modified local item with non-mofified ones. So with every
> //run we need to newly modify the outcome of the debugger
457c495,501
< if (child->text(VarNameCol) == match) {
---
> QString strMatch = child->text(VarNameCol);
> bRenew=false;
> if (strMatch.left(3) == \"/x \") { //is the current item format modified?
> strMatch = strMatch.right(strMatch.length()-3);
> bRenew=true;
> }
> if (strMatch == match) {
459,460c503,514
< if (item->getDataType() == type)
< return item;
---
> if (item->getDataType() == type) {
> if (bRenew && dynamic_cast<VarItem*>(item)) { //do we need to replace?
> VarItem* pNewItem = new VarItem((TrimmableItem *) item->parent(),
> child->text(VarNameCol), typeUnknown);
> emit ((VariableTree*)pNewItem->listView())->expandItem(pNewItem);
> pNewItem->moveItem(item);
> delete item;
> item=NULL;
> item=pNewItem;
> }
> return item;
> }
594a649,650
> QString strData=data;
>
604a661
>
607c664
< QListViewItem::setText(column, data);
---
> QListViewItem::setText(column, strData);
919a977
>
920a979,980
>
>
Index: variablewidget.h
===================================================================
RCS file: /home/kde/kdevelop/languages/cpp/debugger/variablewidget.h,v
retrieving revision 1.12
diff -r1.12 variablewidget.h
72a73,74
> //rgruber: we need this to be able to emit expandItem() from within TrimmableItem
> friend class TrimmableItem;
106a109,110
> //rgruber
> void toggleRadix(QListViewItem *item);
108a113
> void slotToggleRadix(QListViewItem * item);
More information about the KDevelop-devel
mailing list