filebrowser/ui/src/fbmainwindow.cpp
branchRCL_3
changeset 22 fad26422216a
parent 21 b3cee849fa46
child 23 f8280f3bfeb7
equal deleted inserted replaced
21:b3cee849fa46 22:fad26422216a
     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 #include <HbApplication>
       
    18 #include <HbMainWindow>
       
    19 
       
    20 #include "fbmainwindow.h"
       
    21 #include "enginewrapper.h"
       
    22 #include "fbfileview.h"
       
    23 #include "fbdriveview.h"
       
    24 #include "settingsview.h"
       
    25 #include "editorview.h"
       
    26 #include "searchview.h"
       
    27 
       
    28 FbMainWindow::FbMainWindow(QWidget *parent)
       
    29     : HbMainWindow(parent),
       
    30     mEngineWrapper(0),
       
    31     mDriveView(0),
       
    32     mFileView(0),
       
    33     mSettingsView(0),
       
    34     mEditorView(0),
       
    35     mSearchView(0),
       
    36     mPreviousView(0)
       
    37 {
       
    38 }
       
    39 
       
    40 FbMainWindow::~FbMainWindow ()
       
    41 {
       
    42     if (mEngineWrapper) {
       
    43         delete mEngineWrapper;
       
    44     }
       
    45 }
       
    46 
       
    47 void FbMainWindow::init()
       
    48 {
       
    49     // Create Engine Wrapper and initialize it
       
    50     mEngineWrapper = new EngineWrapper();
       
    51     int error = mEngineWrapper->init();
       
    52     Q_ASSERT_X(error == 1, "FileBrowser", "Engine initialization failed");
       
    53 
       
    54     // Create drive view
       
    55     mDriveView = new FbDriveView();
       
    56     connect(mDriveView, SIGNAL(aboutToShowSettingsView()), this, SLOT(openSettingsView()));
       
    57     connect(mDriveView, SIGNAL(aboutToShowFileView()), this, SLOT(openFileView()));
       
    58     mDriveView->init(mEngineWrapper);
       
    59     addView(mDriveView);
       
    60 
       
    61     // Create file view
       
    62     mFileView = new FbFileView();
       
    63     connect(mFileView, SIGNAL(aboutToShowSettingsView()), this, SLOT(openSettingsView()));
       
    64     connect(mFileView, SIGNAL(aboutToShowDriveView()), this, SLOT(openDriveView()));
       
    65     mFileView->init(mEngineWrapper);
       
    66     addView(mFileView);
       
    67 
       
    68     // Create settings view
       
    69     mSettingsView = new SettingsView(*mEngineWrapper);
       
    70     connect(mSettingsView, SIGNAL(finished(bool)), this, SLOT(openPreviousBrowserView()));
       
    71     addView(mSettingsView);
       
    72 
       
    73     // Create editor view
       
    74     mEditorView = new EditorView();
       
    75     connect(mFileView, SIGNAL(aboutToShowEditorView(const QString &, bool)), this, SLOT(openEditorView(const QString &, bool)));
       
    76     connect(mEditorView, SIGNAL(finished(bool)), this, SLOT(openFileView()));
       
    77     addView(mEditorView);
       
    78 
       
    79     // Create Search view
       
    80     mSearchView = new SearchView(*mEngineWrapper);
       
    81     connect(mDriveView, SIGNAL(aboutToShowSearchView(QString)), this, SLOT(openSearchView(QString)));
       
    82     connect(mFileView, SIGNAL(aboutToShowSearchView(QString)), this, SLOT(openSearchView(QString)));
       
    83     connect(mSearchView, SIGNAL(finished(bool)), this, SLOT(openFileBrowserView(bool)));
       
    84     addView(mSearchView);
       
    85 
       
    86     // Show ApplicationView at startup
       
    87     setCurrentView(mDriveView);
       
    88     mPreviousView = mDriveView;
       
    89 
       
    90     // Show HbMainWindow
       
    91     show();
       
    92 }
       
    93 
       
    94 
       
    95 void FbMainWindow::openPreviousBrowserView()
       
    96 {
       
    97     mDriveView->refreshList();
       
    98     mFileView->refreshList();
       
    99     setCurrentView(mPreviousView);
       
   100 }
       
   101 
       
   102 void FbMainWindow::openFileBrowserView(bool accepted)
       
   103 {
       
   104     mDriveView->refreshList();
       
   105     mFileView->refreshList();
       
   106     if (accepted) {
       
   107         setCurrentView(mFileView);
       
   108     } else {
       
   109         setCurrentView(mPreviousView);
       
   110     }
       
   111 }
       
   112 
       
   113 void FbMainWindow::openDriveView()
       
   114 {
       
   115     mDriveView->refreshList();
       
   116     setCurrentView(mDriveView);
       
   117     mPreviousView = mDriveView;
       
   118 }
       
   119 
       
   120 void FbMainWindow::openFileView()
       
   121 {
       
   122     mDriveView->refreshList();
       
   123 //    mFileView->setCurrentpath(path);
       
   124     mFileView->refreshList();
       
   125     setCurrentView(mFileView);
       
   126     mPreviousView = mFileView;
       
   127 }
       
   128 
       
   129 void FbMainWindow::openSettingsView()
       
   130 {
       
   131     mSettingsView->initDataForm();
       
   132     setCurrentView(mSettingsView);
       
   133 }
       
   134 
       
   135 void FbMainWindow::openEditorView(const QString &fileName, bool flagReadOnly)
       
   136 {
       
   137     mEditorView->open(fileName, flagReadOnly);
       
   138     setCurrentView(mEditorView);
       
   139 }
       
   140 
       
   141 void FbMainWindow::openSearchView(const QString &path)
       
   142 {
       
   143     mSearchView->open(path);
       
   144     setCurrentView(mSearchView);
       
   145 }