📄 memcheck_view.cpp
字号:
/* --------------------------------------------------------------------- * Implementation of MemcheckView memcheck_view.cpp * Memcheck's personal window * --------------------------------------------------------------------- * This file is part of Valkyrie, a front-end for Valgrind * Copyright (c) 2000-2006, OpenWorks LLP <info@open-works.co.uk> * This program is released under the terms of the GNU GPL v.2 * See the file LICENSE.GPL for the full license details. */#include "memcheck_view.h"#include "vk_config.h"#include "memcheck_icons.h"#include "async_process.h"#include "vk_messages.h"#include "vk_file_utils.h"#include "context_help.h"#include "html_urls.h"#include "tool_object.h" // VkRunState#include "vk_utils.h"#include "vk_process.h"#include <qcursor.h>#include <qfiledialog.h>#include <qheader.h>#include <qtoolbar.h>#include <qtoolbutton.h>#include <qtooltip.h>#include <qpopupmenu.h>#include <qlayout.h>#include <qtabwidget.h>void MemcheckView::showSuppEditor(){ vkPrint("TODO: Memcheck::showSuppEditor()"); }/* class MemcheckView -------------------------------------------------- */MemcheckView::~MemcheckView(){ if (logview != 0) { delete logview; logview = 0; }}MemcheckView::MemcheckView( QWidget* parent, const char* name ) : ToolView( parent, name ){ mkToolBar(); QVBoxLayout* vLayout = new QVBoxLayout( central, 0, -1, "vLayout" ); vLayout->setResizeMode( QLayout::FreeResize );#if 0 /* create a tabwidget */ QTabWidget* tabwidget = new QTabWidget( central, "mc_tabwidget" ); vLayout->addWidget( tabwidget ); /* some tweaks to prettify the tabwidget */ tabwidget->setTabPosition( QTabWidget::Bottom ); QFont fnt = tabwidget->font(); fnt.setPointSize( fnt.pointSize() - 2 ); tabwidget->setFont( fnt ); /* first tab: the listview */ lView = new QListView( tabwidget, "lview" ); tabwidget->addTab( lView, "valgrind output" );#endif lView = new QListView( central, "lview" ); vLayout->addWidget( lView ); logview = new VgLogView( lView ); lView->setShowToolTips( false ); lView->setSorting( -1 ); lView->setMargin( 5 ); lView->addColumn( "" ); lView->header()->setStretchEnabled( true, 0 ); lView->header()->hide(); savelogButton->setEnabled( false ); openOneButton->setEnabled( false ); openAllButton->setEnabled( true ); /* TODO: enable only if lview populated */ srcPathButton->setEnabled( true ); /* TODO: enable only if lview populated */ /* enable | disable show*Item buttons */ connect( lView, SIGNAL(selectionChanged()), this, SLOT(itemSelected()) ); /* launch editor with src file loaded */ connect( lView, SIGNAL(doubleClicked(QListViewItem*, const QPoint&, int)), this, SLOT(launchEditor(QListViewItem*, const QPoint&, int)) );//zz QFont clientout_fnt( "Adobe Courier", 9, QFont::Normal, false );//zz clientout_fnt.setStyleHint( QFont::TypeWriter ); /* other tabs: - suppression editor? */}/* called by memcheck: set state for buttons; set cursor state */void MemcheckView::setState( bool run ){ loadlogButton->setEnabled( !run ); mrglogButton->setEnabled( !run ); // TODO: suppedButton->setEnabled( !run ); if ( run ) { /* startup */ savelogButton->setEnabled( false ); setCursor( QCursor( Qt::WaitCursor ) ); lView->clear(); } else { /* finished */ unsetCursor(); savelogButton->setEnabled( lView->childCount() != 0 ); }}/* slot: connected to MainWindow::toggleToolbarLabels(). called when user toggles 'show-butt-text' in Options page */void MemcheckView::toggleToolbarLabels( bool state ){ loadlogButton->setUsesTextLabel( state ); mrglogButton->setUsesTextLabel( state ); savelogButton->setUsesTextLabel( state ); suppedButton->setUsesTextLabel( state );}/* slot: called from logMenu. parse and load a single logfile. setting the open-file-dialog's 'start-with' dir to null causes it to start up in whatever the user's current dir happens to be. */void MemcheckView::openLogFile(){ #if 0 /* testing new file dialog stuff */ QString fname = ""; FileDialog* fd = new FileDialog( this, "log_file_fd" ); fd->exec();#else QString log_file; QFileDialog dlg; dlg.setShowHiddenFiles( true ); log_file = dlg.getOpenFileName( QString::null, "XML Files (*.xml);;Log Files (*.log.*);;All Files (*)", this, "fdlg", "Select Log File" ); /* user might have clicked Cancel */ if ( log_file.isEmpty() ) return; vkConfig->wrEntry( log_file, "view-log", "valkyrie" ); emit run( VkRunState::TOOL1 );#endif}/* slot: called from logMenu. Open a file which contains a list of logfiles-to-be-merged, each on a separate line, with a minimum of two logfiles. */void MemcheckView::openMergeFile(){ QString merge_file; /* TODO: Multiple xml files instead of single list file QStringList files = QFileDialog::getOpenFileNames() */ merge_file = QFileDialog::getOpenFileName( QString::null, "XML Log Lists (*.loglst);;All Files (*)", this, "fdlg", "Select Log File" ); /* user might have clicked Cancel */ if ( merge_file.isEmpty() ) return; vkConfig->wrEntry( merge_file, "merge", "valkyrie" ); /* returns the filename the merge has been saved to */ emit run( VkRunState::TOOL2 );}void MemcheckView::mkToolBar(){ mcToolBar = new QToolBar( this, "mc_toolbar" ); mcToolBar->setLabel( "Memcheck ToolBar" ); bool show_text = vkConfig->rdBool( "show-butt-text", "valkyrie" ); /* open-all items button --------------------------------------------- */ openAllButton = new QToolButton( mcToolBar, "tb_open_all" ); openAllButton->setIconSet( QPixmap( open_all_items_xpm ) ); openAllButton->setAutoRaise( true ); openAllButton->setToggleButton( true ); connect( openAllButton, SIGNAL( toggled(bool) ), this, SLOT( openAllItems(bool) ) ); QToolTip::add( openAllButton, "Open / Close all errors" ); ContextHelp::add( openAllButton, urlValkyrie::openAllButton ); /* open-one item button ---------------------------------------------- */ openOneButton = new QToolButton( mcToolBar, "tb_open_one" ); openOneButton->setIconSet( QPixmap( open_one_item_xpm ) ); openOneButton->setAutoRaise( true ); connect( openOneButton, SIGNAL( clicked() ), this, SLOT( openOneItem() ) ); QToolTip::add( openOneButton, "Open / Close the selected item" ); ContextHelp::add( openOneButton, urlValkyrie::openOneButton ); /* show src path button ---------------------------------------------- */ srcPathButton = new QToolButton( mcToolBar, "tb_src_path" ); srcPathButton->setIconSet( QPixmap( src_path_xpm ) ); srcPathButton->setAutoRaise( true ); connect( srcPathButton, SIGNAL( clicked() ), this, SLOT( showSrcPath() ) ); QToolTip::add( srcPathButton, "Show source paths" ); ContextHelp::add( srcPathButton, urlValkyrie::srcPathButton ); /* fake motif-style separator ---------------------------------------- */ QLabel* sep_lbl = new QLabel( mcToolBar, "lbl_sep" ); mcToolBar->setStretchableWidget( sep_lbl ); /* load-log(s) button ------------------------------------------------ */ loadlogButton = new QToolButton( mcToolBar, "tb_load_log" ); loadlogButton->setIconSet( QPixmap( open_log_xpm ) ); loadlogButton->setTextLabel( "&Load Log" ); loadlogButton->setAccel( ALT+Key_L );#if (QT_VERSION-0 >= 0x030200) loadlogButton->setTextPosition( QToolButton::BesideIcon );#else // QT_VERSION < 3.2 loadlogButton->setTextPosition( QToolButton::Right );#endif loadlogButton->setUsesTextLabel( show_text ); loadlogButton->setAutoRaise( true );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -