1 /* |
|
2 * Copyright (c) 2010 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 |
|
19 #include <HbApplication> |
|
20 #include <HbMainWindow> |
|
21 |
|
22 #include "filebrowsermainwindow.h" |
|
23 #include "enginewrapper.h" |
|
24 #include "filebrowserview.h" |
|
25 #include "settingsview.h" |
|
26 #include "editorview.h" |
|
27 |
|
28 FileBrowserMainWindow::FileBrowserMainWindow(QWidget *parent) : |
|
29 HbMainWindow( parent ) |
|
30 ,mEngineWrapper(0) |
|
31 ,mFileBrowserView(0) |
|
32 ,mSettingsView(0) |
|
33 ,mEditorView(0) |
|
34 { |
|
35 } |
|
36 |
|
37 FileBrowserMainWindow::~FileBrowserMainWindow () |
|
38 { |
|
39 if (mEngineWrapper) { |
|
40 delete mEngineWrapper; |
|
41 } |
|
42 } |
|
43 |
|
44 void FileBrowserMainWindow::init() |
|
45 { |
|
46 // Create Engine Wrapper and initialize it |
|
47 mEngineWrapper = new EngineWrapper(); |
|
48 int error = mEngineWrapper->init(); |
|
49 Q_ASSERT_X(error == 1, "FileBrowser", "Engine initialization failed"); |
|
50 |
|
51 // Create file browser view |
|
52 mFileBrowserView = new FileBrowserView(*this); |
|
53 connect(mFileBrowserView, SIGNAL(aboutToShowSettingsView()), this, SLOT(openSettingsView())); |
|
54 mFileBrowserView->init(mEngineWrapper); |
|
55 addView(mFileBrowserView); |
|
56 |
|
57 // Create settings view |
|
58 mSettingsView = new SettingsView(*this, *mEngineWrapper); |
|
59 connect(mSettingsView, SIGNAL(finished(bool)), this, SLOT(openFileBrowserView())); |
|
60 addView(mSettingsView); |
|
61 |
|
62 // Create settings view |
|
63 mEditorView = new EditorView(*this); |
|
64 connect(mFileBrowserView, SIGNAL(aboutToShowEditorView(const QString &, bool)), this, SLOT(openEditorView(const QString &, bool))); |
|
65 connect(mEditorView, SIGNAL(finished(bool)), this, SLOT(openFileBrowserView())); |
|
66 addView(mEditorView); |
|
67 |
|
68 // Show ApplicationView at startup |
|
69 setCurrentView(mFileBrowserView); |
|
70 // Show HbMainWindow |
|
71 show(); |
|
72 } |
|
73 |
|
74 void FileBrowserMainWindow::openFileBrowserView() |
|
75 { |
|
76 setCurrentView(mFileBrowserView); |
|
77 } |
|
78 |
|
79 void FileBrowserMainWindow::openSettingsView() |
|
80 { |
|
81 setCurrentView(mSettingsView); |
|
82 } |
|
83 |
|
84 void FileBrowserMainWindow::openEditorView(const QString &fileName, bool flagReadOnly) |
|
85 { |
|
86 mEditorView->open(fileName, flagReadOnly); |
|
87 setCurrentView(mEditorView); |
|
88 } |
|