1
/* ---------------------------------------------------------------------
2
* Implementation of class ToolView tool_view.cpp
3
* Base class for all tool views
4
* ---------------------------------------------------------------------
5
* This file is part of Valkyrie, a front-end for Valgrind
6
* Copyright (C) 2000-2008, OpenWorks LLP <info@open-works.co.uk>
7
* This program is released under the terms of the GNU GPL v.2
8
* See the file COPYING for the full license details.
11
#include "tool_view.h"
13
#include "vk_config.h"
18
ToolView::~ToolView() { }
20
ToolView::ToolView( QWidget* parent, const char* name )
21
: QMainWindow( parent, name, WDestructiveClose )
23
QString caption = QString(name);
24
if (caption.length() > 0)
25
caption[0] = caption[0].upper();
26
setCaption( caption );
28
central = new QWidget( this );
29
setCentralWidget( central );
31
setToolFont( vkConfig->rdFont( "font-tool-user", "valkyrie" ) );
34
void ToolView::setToolFont( QFont font )
36
font.setStyleHint( QFont::TypeWriter );
37
central->setFont( font );
43
/* Stack of ToolViews */
45
ToolViewStack::~ToolViewStack() { }
47
ToolViewStack::ToolViewStack( QWidget* parent/*=0*/, const char * name/*=0*/ )
48
: QWidgetStack( parent, name ) { }
50
ToolViewStack::ToolViewStack( QWidget* parent, const char * name, WFlags f )
51
: QWidgetStack( parent, name, f ) { }
53
int ToolViewStack::addView( ToolView* tv, int id )
54
{ return addWidget(tv, id); }
56
void ToolViewStack::removeView( QWidget* w )
57
{ removeWidget( w ); }
59
ToolView* ToolViewStack::view( int id ) const
60
{ return (ToolView*)widget(id); }
63
/* returns a list of ToolViews */
64
const ToolViewList* ToolViewStack::viewList()
65
{ return (ToolViewList*)queryList( "ToolView", 0, false, false); }
67
/* iterate over the views to find one != lastView
68
returns 0 if none found */
69
ToolView* ToolViewStack::ToolViewStack::nextView( ToolView* lastView/*=0*/ )
71
const ToolViewList* views = viewList();
72
ToolViewListIter it( *views );
74
for (; ((view = it.current()) != 0); ++it ) {
81
/* return currently-visible view
83
ToolView* ToolViewStack::visible()
84
{ return (ToolView*)QWidgetStack::visibleWidget(); }
86
/* return id of currently-visible view
88
int ToolViewStack::visibleId()
89
{ return id( visible() ); }
91
void ToolViewStack::listViews()
93
vkPrint("=============");
94
const ToolViewList* views = viewList();
95
ToolViewListIter it( *views ); // iterate over the views
97
for (; ((view = it.current()) != 0); ++it ) {
98
vkPrint("ToolView: id(%d), name(%s)", id(view), view->name());
103
/* Bring new ToolView to front
104
- Hide any previous ToolView widgets
106
- Show any current ToolView widgets */
107
void ToolViewStack::raiseView( int id )
111
void ToolViewStack::raiseView( ToolView* tv )