📄 memcheck_view.cpp
字号:
connect( loadlogButton, SIGNAL( clicked() ), this, SLOT( openLogFile() ) ); QToolTip::add( loadlogButton, "Load log file" ); ContextHelp::add( loadlogButton, urlValkyrie::loadLogButton ); /* merge-log(s) button ------------------------------------------------ */ mrglogButton = new QToolButton( mcToolBar, "tb_merge_log" ); mrglogButton->setIconSet( QPixmap( tool_run_xpm ) ); mrglogButton->setTextLabel( "&Merge Logs" ); mrglogButton->setAccel( ALT+Key_M );#if (QT_VERSION-0 >= 0x030200) mrglogButton->setTextPosition( QToolButton::BesideIcon );#else // QT_VERSION < 3.2 mrglogButton->setTextPosition( QToolButton::Right );#endif mrglogButton->setUsesTextLabel( show_text ); mrglogButton->setAutoRaise( true ); connect( mrglogButton, SIGNAL( clicked() ), this, SLOT( openMergeFile() ) ); QToolTip::add( mrglogButton, "Merge multiple log files" ); ContextHelp::add( mrglogButton, urlValkyrie::mrgLogButton ); /* save-log button --------------------------------------------------- */ savelogButton = new QToolButton( mcToolBar, "tb_save_log" ); savelogButton->setIconSet( QPixmap( save_log_xpm ) ); savelogButton->setTextLabel( "&Save Log" ); savelogButton->setAccel( ALT+Key_S );#if (QT_VERSION-0 >= 0x030200) savelogButton->setTextPosition( QToolButton::BesideIcon );#else // QT_VERSION < 3.2 savelogButton->setTextPosition( QToolButton::Right );#endif savelogButton->setUsesTextLabel( show_text ); savelogButton->setAutoRaise( true ); connect( savelogButton, SIGNAL( clicked() ), this, SIGNAL( saveLogFile() ) ); QToolTip::add( savelogButton, "Save output to a log file" ); ContextHelp::add( savelogButton, urlValkyrie::saveLogButton ); /* suppressions editor button ---------------------------------------- */ suppedButton = new QToolButton( mcToolBar, "tb_supp_ed" ); suppedButton->setIconSet( QPixmap( supp_editor_xpm ) ); suppedButton->setTextLabel( "Supp'n Editor" );#if (QT_VERSION-0 >= 0x030200) suppedButton->setTextPosition( QToolButton::BesideIcon );#else // QT_VERSION < 3.2 suppedButton->setTextPosition( QToolButton::Right );#endif suppedButton->setUsesTextLabel( show_text ); suppedButton->setAutoRaise( true ); connect( suppedButton, SIGNAL( clicked() ), this, SLOT( showSuppEditor() ) ); QToolTip::add( suppedButton, "Open the Suppressions Editor" ); ContextHelp::add( suppedButton, urlValkyrie::suppEdButton ); // suppedButton->setEnabled( false ); suppedButton->hide(); // TODO: implement suppressionsEditor}/* --------------------------------------------------------------------- * All functions below are related to interacting with the listView * --------------------------------------------------------------------- *//* checks if itemType() == SRC. if true, and item isReadable or isWriteable, launches an editor with the source file loaded */void MemcheckView::launchEditor( QListViewItem* lv_item, const QPoint&, int ){ if ( !lv_item || !lv_item->parent() ) return; VgOutputItem* curr_item = (VgOutputItem*)lv_item; if ( curr_item->elemType() != VgElement::LINE || curr_item->parent()->elemType() != VgElement::FRAME ) return; /* get the path to the source file */ if ( curr_item->isReadable || curr_item->isWriteable ) { /* check editor is set: may be empty if none found on installation... */ QString editor = vkConfig->rdEntry( "src-editor","valkyrie" ); if (editor.isEmpty()) { vkError( this, "Editor Launch", "<p>Source editor not set - this can be updated via Options::Valkyrie.</p>" ); return; } /* get path,line for this frame */ FrameItem* frame = (FrameItem*)curr_item->parent(); QDomNodeList frame_details = frame->elem.childNodes(); vk_assert( frame_details.count() >= 1 ); /* only ip guaranteed */ QDomElement dir = frame_details.item( 3 ).toElement(); QDomElement srcloc = frame_details.item( 4 ).toElement(); QDomElement line = frame_details.item( 5 ).toElement(); if (dir.isNull() || srcloc.isNull()) { VK_DEBUG( "MemcheckView::launchEditor(): Not enough path information." ); vkError( this, "Editor Launch", "<p>Not enough path information.</p>" ); return; } QString path( dir.text() + '/' + srcloc.text() ); vk_assert( !path.isEmpty() ); QString lineno = !line.isNull() ? line.text() : ""; /* setup args to editor */ QStringList args; if (lineno.isEmpty()) { /* remove any arg with "%n" in it */ args = QStringList::split(" ", editor); QStringList lineargs = args.grep("%n"); QStringList::iterator it = lineargs.begin(); for (; it != lineargs.end(); ++it ) args.remove( *it ); } else { editor.replace("%n", lineno); args = QStringList::split(" ", editor); } args << path; /* launch editor */ VKProcess ed_proc( args, this ); if (!ed_proc.start()) { VK_DEBUG("MemcheckView::launchEditor(): Failed to launch editor: %s", args.join(" ").latin1()); vkError( this, "Editor Launch", "<p>Failed to launch editor:<br>%s</p>", args.join("<br>").latin1() ); } }}/* opens all error items plus their children. ignores the status, preamble, et al. items. */void MemcheckView::openAllItems( bool open ){ if (!lView->firstChild()) /* listview populated at all? */ return; VgOutputItem* op_item = (VgOutputItem*)lView->firstChild()->firstChild(); vk_assert(op_item); /* move down till we get to the first error */ while ( op_item && op_item->elemType() != VgElement::ERROR ) { op_item = op_item->nextSibling(); } QListViewItemIterator it( op_item ); while ( it.current() ) { if ( ((VgOutputItem*)it.current())->elemType() == VgElement::SUPPCOUNTS ) break; /* stop when we hit suppressions */ it.current()->setOpen( open ); ++it; }}/* opens/closes the current item. when opening, all its children are also set open. when closing, only the selected item is closed */void MemcheckView::openOneItem(){ QListViewItem* lv_item = lView->currentItem(); if ( !lv_item ) return; if ( lv_item->isOpen() ) lv_item->setOpen( false ); else { QListViewItem* sib_item = lv_item->nextSibling(); if ( sib_item == 0 ) { /* this item hath no brethren */ sib_item = lv_item->itemBelow(); } QListViewItemIterator it( lv_item ); while ( it.current() ) { it.current()->setOpen( true ); ++it; if ( it.current() == sib_item ) { break; } } }} /* shows the file paths for all frames under current item */void MemcheckView::showSrcPath(){ QListViewItem* lv_item = lView->currentItem(); if ( !lv_item ) return; VgOutputItem* curr_item = (VgOutputItem*)lv_item; if (curr_item->parent() && curr_item->parent()->elemType() == VgElement::FRAME) curr_item = curr_item->parent(); /* iterate over items up to nextSibling */ QListViewItem* sibling = curr_item->nextSibling(); VgOutputItem* item; QListViewItemIterator it( curr_item ); for(; (item = (VgOutputItem*)it.current()); ++it ) { if (item == sibling) break; if ( item->elemType() == VgElement::FRAME ) { /* show path in this frame */ FrameItem* frame = (FrameItem*)item; frame->setText( ((VgFrame*)&frame->elem)->describe_IP(true) ); } }}void MemcheckView::itemSelected(){ QListViewItem* lv_item = lView->currentItem(); if ( !lv_item ) { openOneButton->setEnabled( false ); } else { /* if item openable and within an error: enable openOneButton */ bool isOpenable = (lv_item->firstChild() != 0); bool withinError = false; VgOutputItem* curr_item = (VgOutputItem*)lv_item; for (; curr_item; curr_item = curr_item->parent() ) { if ( curr_item->elemType() == VgElement::ERROR ) { withinError = true; break; } } openOneButton->setEnabled( isOpenable && withinError ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -