1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QSignalMapper> |
|
19 #include <QGraphicsLinearLayout> |
|
20 #include <QDebug> |
|
21 #include <HbMenu> |
|
22 #include <HbAction> |
|
23 #include <HbToolBar> |
|
24 #include <HbApplication> |
|
25 #include <HbMessageBox> |
|
26 #include <HbMainWindow> |
|
27 #include <HbLabel> |
|
28 |
|
29 #include "memspyview.h" |
|
30 #include "enginewrapper.h" |
|
31 |
|
32 #include "memspysettingsview.h" |
|
33 |
|
34 MemSpyView::MemSpyView(EngineWrapper &engine, ViewManager &viewManager) : |
|
35 HbView(), |
|
36 mEngine(engine), |
|
37 mViewManager(viewManager), |
|
38 mOutputMenu(0), |
|
39 mOutputGenInfoMenu(0), |
|
40 mOutputHeapInfoMenu(0), |
|
41 mOutputStackInfoMenu(0), |
|
42 mToolBar(0), |
|
43 mBreadCrumb(0) |
|
44 { |
|
45 } |
|
46 |
|
47 MemSpyView::~MemSpyView() |
|
48 { |
|
49 delete mBreadCrumb; |
|
50 delete mToolBar; |
|
51 delete mOutputStackInfoMenu; |
|
52 delete mOutputHeapInfoMenu; |
|
53 delete mOutputGenInfoMenu; |
|
54 delete mOutputMenu; |
|
55 } |
|
56 |
|
57 void MemSpyView::initialize(const QVariantMap& params) |
|
58 { |
|
59 Q_UNUSED(params); |
|
60 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, this); |
|
61 |
|
62 if (isBreadCrumbVisible()) { |
|
63 mBreadCrumb = new HbLabel(this); |
|
64 mBreadCrumb->setTextWrapping(Hb::TextWordWrap); |
|
65 mBreadCrumb->setElideMode(Qt::ElideLeft); |
|
66 mBreadCrumb->setPlainText(getBreadCrumbText()); |
|
67 HbFontSpec spec(HbFontSpec::PrimarySmall); |
|
68 mBreadCrumb->setFontSpec(spec); |
|
69 layout->addItem(mBreadCrumb); |
|
70 } |
|
71 layout->addItem(createCentralWidget()); |
|
72 setLayout(layout); |
|
73 |
|
74 if (isRefreshable()) |
|
75 menu()->addAction(tr("Refresh"), this, SLOT(refresh())); |
|
76 |
|
77 HbMenu* toolMenu = createToolMenu(); |
|
78 if (toolMenu) |
|
79 menu()->addMenu(toolMenu); |
|
80 |
|
81 menu()->addAction(tr("Settings ..."), this, SLOT(showSettings())); |
|
82 menu()->addAction(tr("About ..."), this, SLOT(showAbout())); |
|
83 menu()->addAction(tr("Exit"), qApp, SLOT(quit())); |
|
84 |
|
85 mToolBar = createToolBar(); |
|
86 if (mToolBar) |
|
87 setToolBar(mToolBar); |
|
88 } |
|
89 |
|
90 QList<QAction*> MemSpyView::createOutputActions() |
|
91 { |
|
92 return QList<QAction*>(); |
|
93 } |
|
94 |
|
95 HbMenu* MemSpyView::createToolMenu() |
|
96 { |
|
97 return 0; |
|
98 } |
|
99 |
|
100 HbToolBar* MemSpyView::createToolBar() |
|
101 { |
|
102 return 0; |
|
103 } |
|
104 |
|
105 bool MemSpyView::isRefreshable() const |
|
106 { |
|
107 return false; |
|
108 } |
|
109 |
|
110 bool MemSpyView::isBreadCrumbVisible() const |
|
111 { |
|
112 return false; |
|
113 } |
|
114 |
|
115 QString MemSpyView::getBreadCrumbText() const |
|
116 { |
|
117 QStringList views; |
|
118 for (int i=1; i<mainWindow()->views().count() - 1; i++) { |
|
119 const HbView *view = mainWindow()->views().at(i); |
|
120 if (view == this) |
|
121 break; |
|
122 views.append(view->title()); |
|
123 } |
|
124 views.append(title()); |
|
125 |
|
126 return views.join(" > "); |
|
127 } |
|
128 |
|
129 void MemSpyView::refresh() |
|
130 { |
|
131 // Empty default implementation |
|
132 } |
|
133 |
|
134 void MemSpyView::showSettings() |
|
135 { |
|
136 MemSpySettingsView* settings = new MemSpySettingsView(mEngine); |
|
137 connect(settings, SIGNAL(finished(bool)), this, SLOT(closeSettings())); |
|
138 mainWindow()->addView(settings); |
|
139 mainWindow()->setCurrentView(settings); |
|
140 } |
|
141 |
|
142 void MemSpyView::showAbout() |
|
143 { |
|
144 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
|
145 messageBox->setText("Version 2.1.0 - 15th June 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0."); |
|
146 HbLabel *header = new HbLabel("About MemSpy", messageBox); |
|
147 messageBox->setHeadingWidget(header); |
|
148 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
|
149 messageBox->setTimeout(HbPopup::NoTimeout); |
|
150 messageBox->open(); |
|
151 } |
|
152 |
|
153 void MemSpyView::closeSettings() |
|
154 { |
|
155 sender()->deleteLater(); |
|
156 mainWindow()->setCurrentView(this); |
|
157 } |
|