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 #include "searchview.h" |
|
28 |
|
29 FileBrowserMainWindow::FileBrowserMainWindow(QWidget *parent) |
|
30 : HbMainWindow(parent), |
|
31 mEngineWrapper(0), |
|
32 mFileBrowserView(0), |
|
33 mSettingsView(0), |
|
34 mEditorView(0), |
|
35 mSearchView(0) |
|
36 { |
|
37 } |
|
38 |
|
39 FileBrowserMainWindow::~FileBrowserMainWindow () |
|
40 { |
|
41 if (mEngineWrapper) { |
|
42 delete mEngineWrapper; |
|
43 } |
|
44 } |
|
45 |
|
46 void FileBrowserMainWindow::init() |
|
47 { |
|
48 // Create Engine Wrapper and initialize it |
|
49 mEngineWrapper = new EngineWrapper(); |
|
50 int error = mEngineWrapper->init(); |
|
51 Q_ASSERT_X(error == 1, "FileBrowser", "Engine initialization failed"); |
|
52 |
|
53 // Create file browser view |
|
54 mFileBrowserView = new FileBrowserView(*this); |
|
55 connect(mFileBrowserView, SIGNAL(aboutToShowSettingsView()), this, SLOT(openSettingsView())); |
|
56 mFileBrowserView->init(mEngineWrapper); |
|
57 addView(mFileBrowserView); |
|
58 |
|
59 // Create settings view |
|
60 mSettingsView = new SettingsView(*this, *mEngineWrapper); |
|
61 connect(mSettingsView, SIGNAL(finished(bool)), this, SLOT(openFileBrowserView())); |
|
62 addView(mSettingsView); |
|
63 |
|
64 // Create settings view |
|
65 mEditorView = new EditorView(*this); |
|
66 connect(mFileBrowserView, SIGNAL(aboutToShowEditorView(const QString &, bool)), this, SLOT(openEditorView(const QString &, bool))); |
|
67 connect(mEditorView, SIGNAL(finished(bool)), this, SLOT(openFileBrowserView())); |
|
68 addView(mEditorView); |
|
69 |
|
70 // Create Search view |
|
71 mSearchView = new SearchView(*mEngineWrapper); |
|
72 connect(mFileBrowserView, SIGNAL(aboutToShowSearchView(QString)), this, SLOT(openSearchView(QString))); |
|
73 connect(mSearchView, SIGNAL(finished(bool)), this, SLOT(openFileBrowserView())); |
|
74 addView(mSearchView); |
|
75 |
|
76 // Show ApplicationView at startup |
|
77 setCurrentView(mFileBrowserView); |
|
78 |
|
79 // Show HbMainWindow |
|
80 show(); |
|
81 } |
|
82 |
|
83 void FileBrowserMainWindow::openFileBrowserView() |
|
84 { |
|
85 mFileBrowserView->refreshList(); |
|
86 setCurrentView(mFileBrowserView); |
|
87 } |
|
88 |
|
89 void FileBrowserMainWindow::openSettingsView() |
|
90 { |
|
91 setCurrentView(mSettingsView); |
|
92 } |
|
93 |
|
94 void FileBrowserMainWindow::openEditorView(const QString &fileName, bool flagReadOnly) |
|
95 { |
|
96 mEditorView->open(fileName, flagReadOnly); |
|
97 setCurrentView(mEditorView); |
|
98 } |
|
99 |
|
100 void FileBrowserMainWindow::openSearchView(const QString &path) |
|
101 { |
|
102 mSearchView->open(path); |
|
103 setCurrentView(mSearchView); |
|
104 } |
|