|
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 #include "fbdriveview.h" |
|
19 #include "fbsettingsview.h" |
|
20 #include "fbeditorview.h" |
|
21 #include "fbsearchview.h" |
|
22 #include "enginewrapper.h" |
|
23 #include "notifications.h" |
|
24 #include "fbdrivemodel.h" |
|
25 #include "filebrowsersortfilterproxymodel.h" |
|
26 #include "fbdrivelistviewitem.h" |
|
27 #include "fbpropertiesdialog.h" |
|
28 |
|
29 #include <HbMenu> |
|
30 #include <HbPopup> |
|
31 #include <HbView> |
|
32 #include <HbMessageBox> |
|
33 #include <HbAction> |
|
34 #include <HbLabel> |
|
35 #include <HbListView> |
|
36 #include <HbListViewItem> |
|
37 #include <HbListWidget> |
|
38 #include <HbLineEdit> |
|
39 #include <HbAbstractViewItem> |
|
40 #include <HbSelectionDialog> |
|
41 #include <HbValidator> |
|
42 #include <HbInputDialog> |
|
43 |
|
44 #include <QString> |
|
45 #include <QGraphicsLinearLayout> |
|
46 #include <QItemSelection> |
|
47 #include <QDebug> |
|
48 //TODO check if needed to do this way |
|
49 #include <FB.hrh> |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 |
|
53 FbDriveView::FbDriveView() : |
|
54 mEngineWrapper(0), |
|
55 mListView(0), |
|
56 mNaviPane(0), |
|
57 mMainLayout(0), |
|
58 mFbDriveModel(0), |
|
59 mOptionMenuActions(), |
|
60 mContextMenuActions(), |
|
61 mContextMenu(0), |
|
62 mLocationChanged(false), |
|
63 mRemoveFileAfterCopied(false), |
|
64 // mClipBoardInUse(false), |
|
65 mFolderContentChanged(false), |
|
66 mCurrentIndex(), |
|
67 mOldPassword(), |
|
68 mPanicCategory(), |
|
69 mAbsoluteFilePath(), |
|
70 mOverwriteOptions(), |
|
71 mModelIndex(), |
|
72 mNewFileName(), |
|
73 mProceed(false), |
|
74 mEraseMBR(false) |
|
75 { |
|
76 setTitle("File Browser"); |
|
77 |
|
78 createMenu(); |
|
79 createContextMenu(); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 |
|
84 void FbDriveView::init(EngineWrapper *engineWrapper) |
|
85 { |
|
86 mEngineWrapper = engineWrapper; |
|
87 |
|
88 mListView = new HbListView(this); |
|
89 mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape); |
|
90 |
|
91 mListView->setItemPrototype(new FbDriveListViewItem(mListView)); |
|
92 |
|
93 mFbDriveModel = new FbDriveModel(mEngineWrapper); |
|
94 if (!mListView->model()) { |
|
95 mEngineWrapper->refreshView(); |
|
96 mListView->setModel(mFbDriveModel); |
|
97 } |
|
98 |
|
99 //mListView->setRootIndex(mFileSystemModel->index(startPath)); |
|
100 //mListView->setRootIndex(model->index()); |
|
101 |
|
102 // mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); |
|
103 |
|
104 connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); |
|
105 connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), |
|
106 this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF))); |
|
107 |
|
108 mNaviPane = new HbLabel(this); |
|
109 mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default |
|
110 //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); |
|
111 HbFontSpec fontSpec(HbFontSpec::PrimarySmall); |
|
112 mNaviPane->setFontSpec(fontSpec); |
|
113 |
|
114 // Create layout and add list view and naviPane into layout: |
|
115 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
116 mMainLayout->addItem(mNaviPane); |
|
117 mMainLayout->addItem(mListView); |
|
118 setLayout(mMainLayout); |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 |
|
123 FbDriveView::~FbDriveView() |
|
124 { |
|
125 // if (mEngineWrapper) { |
|
126 // delete mEngineWrapper; |
|
127 // } |
|
128 if (mContextMenu) { |
|
129 mContextMenu->deleteLater(); |
|
130 } |
|
131 |
|
132 delete mFbDriveModel; |
|
133 delete mListView; |
|
134 } |
|
135 |
|
136 /** |
|
137 Initial setup for options menu. |
|
138 Dynamic menu update during the runtime is performed by updateOptionMenu() which |
|
139 to menu's aboutToShow() signal. |
|
140 */ |
|
141 void FbDriveView::createMenu() |
|
142 { |
|
143 createFileMenu(); |
|
144 createEditMenu(); |
|
145 createViewMenu(); |
|
146 createToolsMenu(); |
|
147 |
|
148 createSettingsMenuItem(); |
|
149 createAboutMenuItem(); |
|
150 createExitMenuItem(); |
|
151 |
|
152 // menu dynamic update |
|
153 connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateOptionMenu())); |
|
154 } |
|
155 |
|
156 /** |
|
157 Initial setup for File submenu |
|
158 */ |
|
159 void FbDriveView::createFileMenu() |
|
160 { |
|
161 mOptionMenuActions.mFileMenu = menu()->addMenu("File"); |
|
162 |
|
163 mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); |
|
164 } |
|
165 |
|
166 /** |
|
167 Initial setup for Edit submenu |
|
168 */ |
|
169 void FbDriveView::createEditMenu() |
|
170 { |
|
171 mOptionMenuActions.mEditMenu = menu()->addMenu("Edit"); |
|
172 |
|
173 mOptionMenuActions.mEditSnapShotToE = mOptionMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); |
|
174 mOptionMenuActions.mEditSnapShotToE->setVisible(false); |
|
175 } |
|
176 |
|
177 /** |
|
178 Initial setup for View submenu |
|
179 */ |
|
180 void FbDriveView::createViewMenu() |
|
181 { |
|
182 mOptionMenuActions.mViewMenu = menu()->addMenu("View"); |
|
183 //mOptionMenuActions.mViewMenu->menuAction()->setVisible(false); |
|
184 |
|
185 //mOptionMenuActions.mViewFilterEntries = mOptionMenuActions.mViewMenu->addAction("Filter entries", this, SLOT(viewFilterEntries())); |
|
186 mOptionMenuActions.mViewRefresh = mOptionMenuActions.mViewMenu->addAction("Refresh", this, SLOT(viewRefresh())); |
|
187 } |
|
188 |
|
189 /** |
|
190 Initial setup for Tools submenu |
|
191 */ |
|
192 void FbDriveView::createToolsMenu() |
|
193 { |
|
194 mOptionMenuActions.mToolsMenu = menu()->addMenu("Tools"); |
|
195 |
|
196 mOptionMenuActions.mToolsAllAppsToTextFile = mOptionMenuActions.mToolsMenu->addAction("All apps to a text file", this, SLOT(toolsAllAppsToTextFile())); |
|
197 mOptionMenuActions.mToolsAllAppsToTextFile->setVisible(false); |
|
198 mOptionMenuActions.mToolsAllFilesToTextFile = mOptionMenuActions.mToolsMenu->addAction("All files to a text file", this, SLOT(toolsAllFilesToTextFile())); |
|
199 //mOptionMenuActions.mToolsAllFilesToTextFile->setVisible(false); |
|
200 |
|
201 // mOptionMenuActions.mToolsAvkonIconCacheMenu = mOptionMenuActions.mToolsMenu->addMenu("Avkon icon cache"); |
|
202 // mOptionMenuActions.mToolsAvkonIconCacheMenu->menuAction()->setVisible(false); |
|
203 // mOptionMenuActions.mToolsAvkonIconCacheEnable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Enable", this, SLOT(toolsAvkonIconCacheEnable())); |
|
204 // mOptionMenuActions.mToolsAvkonIconCacheDisable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Clear and disable", this, SLOT(toolsAvkonIconCacheDisable())); |
|
205 |
|
206 mOptionMenuActions.mToolsDisableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Disable extended errors", this, SLOT(toolsDisableExtendedErrors())); |
|
207 mOptionMenuActions.mToolsDumpMsgStoreWalk = mOptionMenuActions.mToolsMenu->addAction("Dump msg. store walk", this, SLOT(toolsDumpMsgStoreWalk())); |
|
208 mOptionMenuActions.mToolsDumpMsgStoreWalk->setVisible(false); |
|
209 mOptionMenuActions.mToolsEditDataTypes = mOptionMenuActions.mToolsMenu->addAction("Edit data types", this, SLOT(toolsEditDataTypes())); |
|
210 mOptionMenuActions.mToolsEditDataTypes->setVisible(false); |
|
211 mOptionMenuActions.mToolsEnableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Enable extended errors", this, SLOT(toolsEnableExtendedErrors())); |
|
212 |
|
213 mOptionMenuActions.mToolsErrorSimulateMenu = mOptionMenuActions.mToolsMenu->addMenu("Error simulate"); |
|
214 mOptionMenuActions.mToolsErrorSimulateLeave = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Leave", this, SLOT(toolsErrorSimulateLeave())); |
|
215 mOptionMenuActions.mToolsErrorSimulatePanic = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Panic", this, SLOT(toolsErrorSimulatePanic())); |
|
216 mOptionMenuActions.mToolsErrorSimulatePanic->setVisible(false); |
|
217 mOptionMenuActions.mToolsErrorSimulateException = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Exception", this, SLOT(toolsErrorSimulateException())); |
|
218 |
|
219 // mOptionMenuActions.mLocalConnectivityMenu = mOptionMenuActions.mToolsMenu->addMenu("Local connectivity"); |
|
220 // mOptionMenuActions.mToolsLocalConnectivityActivateInfrared = mOptionMenuActions.mLocalConnectivityMenu->addAction("Activate infrared", this, SLOT(toolsLocalConnectivityActivateInfrared())); |
|
221 // mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch BT UI", this, SLOT(toolsLocalConnectivityLaunchBTUI())); |
|
222 // mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch USB UI", this, SLOT(toolsLocalConnectivityLaunchUSBUI())); |
|
223 |
|
224 mOptionMenuActions.mToolsMessageAttachmentsMenu = mOptionMenuActions.mToolsMenu->addMenu("Message attachments"); |
|
225 mOptionMenuActions.mToolsMessageAttachmentsMenu->menuAction()->setVisible(false); |
|
226 mOptionMenuActions.mToolsMessageInbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Inbox", this, SLOT(toolsMessageInbox())); |
|
227 mOptionMenuActions.mToolsMessageDrafts = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Drafts", this, SLOT(toolsMessageDrafts())); |
|
228 mOptionMenuActions.mToolsMessageSentItems = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Sent items", this, SLOT(toolsMessageSentItems())); |
|
229 mOptionMenuActions.mToolsMessageOutbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Outbox", this, SLOT(toolsMessageOutbox())); |
|
230 |
|
231 mOptionMenuActions.mToolsMemoryInfo = mOptionMenuActions.mToolsMenu->addAction("Memory info", this, SLOT(toolsMemoryInfo())); |
|
232 mOptionMenuActions.mToolsMemoryInfo->setVisible(false); |
|
233 |
|
234 mOptionMenuActions.mToolsSecureBackupMenu = mOptionMenuActions.mToolsMenu->addMenu("Secure backup"); |
|
235 mOptionMenuActions.mToolsSecureBackupMenu->menuAction()->setVisible(false); |
|
236 mOptionMenuActions.mToolsSecureBackStart = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start backup", this, SLOT(toolsSecureBackStart())); |
|
237 mOptionMenuActions.mToolsSecureBackRestore = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start restore", this, SLOT(toolsSecureBackRestore())); |
|
238 mOptionMenuActions.mToolsSecureBackStop = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Stop", this, SLOT(toolsSecureBackStop())); |
|
239 |
|
240 mOptionMenuActions.mToolsSetDebugMask = mOptionMenuActions.mToolsMenu->addAction("Set debug mask", this, SLOT(toolsSetDebugMaskQuestion())); |
|
241 mOptionMenuActions.mToolsShowOpenFilesHere = mOptionMenuActions.mToolsMenu->addAction("Show open files here", this, SLOT(toolsShowOpenFilesHere())); |
|
242 mOptionMenuActions.mToolsShowOpenFilesHere->setVisible(false); |
|
243 } |
|
244 |
|
245 /** |
|
246 Creates Setting menu item in option menu |
|
247 */ |
|
248 void FbDriveView::createSettingsMenuItem() |
|
249 { |
|
250 mOptionMenuActions.mSetting = menu()->addAction("Settings..."); |
|
251 connect(mOptionMenuActions.mSetting, SIGNAL(triggered()), this, SIGNAL(aboutToShowSettingsView())); |
|
252 } |
|
253 |
|
254 |
|
255 /** |
|
256 Creates About menu item in option menu |
|
257 */ |
|
258 void FbDriveView::createAboutMenuItem() |
|
259 { |
|
260 // about note |
|
261 mOptionMenuActions.mAbout = menu()->addAction("About"); |
|
262 connect(mOptionMenuActions.mAbout, SIGNAL(triggered()), this, SLOT(about())); |
|
263 } |
|
264 |
|
265 /** |
|
266 Creates Exit menu item in option menu |
|
267 */ |
|
268 void FbDriveView::createExitMenuItem() |
|
269 { |
|
270 // application exit |
|
271 mOptionMenuActions.mExit = menu()->addAction("Exit"); |
|
272 connect(mOptionMenuActions.mExit, SIGNAL(triggered()), qApp, SLOT(quit())); |
|
273 } |
|
274 |
|
275 /** |
|
276 update menu: disk admin available only in device root view. edit available only in folder view |
|
277 when file or folder content exist in current folder, or clipboard has copied item. |
|
278 file and view menus updated every time regarding the folder content. |
|
279 tools, settings, about, exit always available. |
|
280 If there's remove and add operations at same time, always remove first |
|
281 to keep to the correct menu items order. |
|
282 */ |
|
283 void FbDriveView::updateOptionMenu() |
|
284 { |
|
285 bool isFileItemListEmpty = mFbDriveModel->rowCount() == 0; |
|
286 // bool isDriveListViewActive = true; //mEngineWrapper->isDriveListViewActive(); |
|
287 bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); |
|
288 // bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); //iModel->FileUtils()->IsCurrentDriveReadOnly(); |
|
289 // bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir(); |
|
290 // bool currentSelected = true; //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex()); |
|
291 // bool isAllSelected = mListView->selectionModel()->selection().count() == mFbDriveModel->rowCount(); |
|
292 //bool isNoneSelected = mListView->selectionModel()->selection().count() != 0; |
|
293 // bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0; |
|
294 //bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); |
|
295 bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse(); |
|
296 bool showSnapShot = false; //iModel->FileUtils()->DriveSnapShotPossible(); |
|
297 |
|
298 bool showEditMenu(true); |
|
299 if (!showSnapShot || isFileItemListEmpty && isClipBoardEmpty) |
|
300 showEditMenu = false; |
|
301 else |
|
302 showEditMenu = true; |
|
303 |
|
304 mOptionMenuActions.mEditMenu->menuAction()->setVisible(showEditMenu); |
|
305 |
|
306 //aMenuPane->SetItemDimmed(EFileBrowserCmdFileOpen, isFileItemListEmpty || isDriveListViewActive || isCurrentItemDirectory); |
|
307 |
|
308 //aMenuPane->SetItemDimmed(EFileBrowserCmdFileView, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive); |
|
309 //aMenuPane->SetItemDimmed(EFileBrowserCmdFileEdit, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive); |
|
310 //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || isCurrentItemDirectory); |
|
311 |
|
312 // TODO mOptionMenuActions.mFileCompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive)); |
|
313 // TODO mOptionMenuActions.mFileDecompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive)); |
|
314 |
|
315 // TODO mOptionMenuActions.mEditSnapShotToE->setVisible(isDriveListViewActive); |
|
316 |
|
317 // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isDriveListViewActive || isFileItemListEmpty)); |
|
318 // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive || isDriveListViewActive || isFileItemListEmpty)); |
|
319 mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive); |
|
320 //mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty); |
|
321 |
|
322 // TODO R_FILEBROWSER_VIEW_SORT_SUBMENU |
|
323 // aMenuPane->SetItemButtonState(iModel->FileUtils()->SortMode(), EEikMenuItemSymbolOn); |
|
324 |
|
325 // TODO R_FILEBROWSER_VIEW_ORDER_SUBMENU |
|
326 // aMenuPane->SetItemButtonState(iModel->FileUtils()->OrderMode(), EEikMenuItemSymbolOn); |
|
327 |
|
328 // aResourceId == R_FILEBROWSER_TOOLS_SUBMENU |
|
329 bool noExtendedErrorsAllowed = mEngineWrapper->ErrRdFileExists(); |
|
330 mOptionMenuActions.mToolsDisableExtendedErrors->setVisible(noExtendedErrorsAllowed); |
|
331 mOptionMenuActions.mToolsEnableExtendedErrors->setVisible(!noExtendedErrorsAllowed); |
|
332 |
|
333 // bool infraRedAllowed = mEngineWrapper->FileExists(KIRAppPath); |
|
334 // bool bluetoothAllowed = mEngineWrapper->FileExists(KBTAppPath); |
|
335 // bool usbAllowed = mEngineWrapper->FileExists(KUSBAppPath); |
|
336 // |
|
337 // bool noLocalCon = !infraRedAllowed && !bluetoothAllowed && !usbAllowed; |
|
338 // mOptionMenuActions.mToolsLocalConnectivityMenu->menuAction()->setVisible(!noLocalCon); |
|
339 // |
|
340 // mOptionMenuActions.mToolsLocalConnectivityActivateInfrared->setVisible(infraRedAllowed); |
|
341 // mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI->setVisible(bluetoothAllowed); |
|
342 // mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI->setVisible(usbAllowed); |
|
343 } |
|
344 |
|
345 void FbDriveView::createContextMenu() |
|
346 { |
|
347 mContextMenu = new HbMenu(); |
|
348 connect(mContextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu())); |
|
349 |
|
350 createFileContextMenu(); |
|
351 createEditContextMenu(); |
|
352 createViewContextMenu(); |
|
353 createDiskAdminContextMenu(); |
|
354 } |
|
355 |
|
356 |
|
357 void FbDriveView::createFileContextMenu() |
|
358 { |
|
359 mContextMenuActions.mFileProperties = mContextMenu->addAction("Properties", this, SLOT(fileProperties())); |
|
360 mContextMenuActions.mFileSearch = mContextMenu->addAction("Search...", this, SLOT(fileSearch())); |
|
361 } |
|
362 |
|
363 void FbDriveView::createEditContextMenu() |
|
364 { |
|
365 // mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit"); |
|
366 |
|
367 //mContextMenuActions.mEditSnapShotToE = mContextMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); |
|
368 // mContextMenuActions.mEditSnapShotToE->setVisible(false); |
|
369 // mContextMenuActions.mEditCut = mContextMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); |
|
370 // mContextMenuActions.mEditCopy = mContextMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); |
|
371 // mContextMenuActions.mEditPaste = mContextMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); |
|
372 // mContextMenuActions.mEditCopyToFolder = mContextMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); |
|
373 // mContextMenuActions.mEditMoveToFolder = mContextMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); |
|
374 } |
|
375 |
|
376 void FbDriveView::createViewContextMenu() |
|
377 { |
|
378 |
|
379 } |
|
380 |
|
381 /** |
|
382 Initial setup for Disk Admin submenu |
|
383 */ |
|
384 void FbDriveView::createDiskAdminContextMenu() |
|
385 { |
|
386 mContextMenuActions.mDiskAdminMenu = mContextMenu->addMenu("Disk admin"); |
|
387 //mContextMenuActions.mDiskAdminMenu->menuAction()->setVisible(false); |
|
388 |
|
389 mContextMenuActions.mDiskAdminSetDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Set drive password", this, SLOT(diskAdminSetDrivePassword())); |
|
390 mContextMenuActions.mDiskAdminUnlockDrive = mContextMenuActions.mDiskAdminMenu->addAction("Unlock drive", this, SLOT(diskAdminUnlockDrive())); |
|
391 mContextMenuActions.mDiskAdminClearDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Clear drive password", this, SLOT(diskAdminClearDrivePassword())); |
|
392 mContextMenuActions.mDiskAdminEraseDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Erase drive password", this, SLOT(diskAdminEraseDrivePassword())); |
|
393 |
|
394 mContextMenuActions.mDiskAdminFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Format drive", this, SLOT(diskAdminFormatDrive())); |
|
395 mContextMenuActions.mDiskAdminFormatDrive->setVisible(false); |
|
396 mContextMenuActions.mDiskAdminQuickFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Quick format drive", this, SLOT(diskAdminQuickFormatDrive())); |
|
397 mContextMenuActions.mDiskAdminQuickFormatDrive->setVisible(false); |
|
398 |
|
399 mContextMenuActions.mDiskAdminCheckDisk = mContextMenuActions.mDiskAdminMenu->addAction("Check disk", this, SLOT(diskAdminCheckDisk())); |
|
400 mContextMenuActions.mDiskAdminScanDrive = mContextMenuActions.mDiskAdminMenu->addAction("Scan drive", this, SLOT(diskAdminScanDrive())); |
|
401 mContextMenuActions.mDiskAdminSetDriveName = mContextMenuActions.mDiskAdminMenu->addAction("Set drive name", this, SLOT(diskAdminSetDriveName())); |
|
402 mContextMenuActions.mDiskAdminSetDriveVolumeLabel = mContextMenuActions.mDiskAdminMenu->addAction("Set drive volume label", this, SLOT(diskAdminSetDriveVolumeLabel())); |
|
403 mContextMenuActions.mDiskAdminEjectDrive = mContextMenuActions.mDiskAdminMenu->addAction("Eject drive", this, SLOT(diskAdminEjectDrive())); |
|
404 mContextMenuActions.mDiskAdminDismountDrive = mContextMenuActions.mDiskAdminMenu->addAction("Dismount drive", this, SLOT(diskAdminDismountDrive())); |
|
405 mContextMenuActions.mDiskAdminEraseMBR = mContextMenuActions.mDiskAdminMenu->addAction("Erase MBR", this, SLOT(diskAdminEraseMBR())); |
|
406 mContextMenuActions.mDiskAdminPartitionDrive = mContextMenuActions.mDiskAdminMenu->addAction("Partition drive", this, SLOT(diskAdminPartitionDrive())); |
|
407 } |
|
408 |
|
409 void FbDriveView::updateContextMenu() |
|
410 { |
|
411 bool isFileItemListEmpty = mFbDriveModel->rowCount() == 0; |
|
412 mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty); |
|
413 } |
|
414 |
|
415 // --------------------------------------------------------------------------- |
|
416 |
|
417 void FbDriveView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords) |
|
418 { |
|
419 mCurrentIndex = listViewItem->modelIndex(); |
|
420 |
|
421 mContextMenu->setPreferredPos(coords); |
|
422 mContextMenu->show(); |
|
423 } |
|
424 |
|
425 /** |
|
426 Refresh FileBrowser view |
|
427 */ |
|
428 void FbDriveView::refreshList() |
|
429 { |
|
430 mEngineWrapper->refreshView(); |
|
431 mListView->reset(); |
|
432 |
|
433 TListingMode listingMode = mEngineWrapper->listingMode(); |
|
434 if (listingMode == ENormalEntries) |
|
435 mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); |
|
436 else if (listingMode == ESearchResults) |
|
437 mNaviPane->setPlainText(QString(tr("Search results"))); |
|
438 else if (listingMode == EOpenFiles) |
|
439 mNaviPane->setPlainText(QString(tr("Open files"))); |
|
440 else if (listingMode == EMsgAttachmentsInbox) |
|
441 mNaviPane->setPlainText(QString(tr("Attachments in Inbox"))); |
|
442 else if (listingMode == EMsgAttachmentsDrafts) |
|
443 mNaviPane->setPlainText(QString(tr("Attachments in Drafts"))); |
|
444 else if (listingMode == EMsgAttachmentsSentItems) |
|
445 mNaviPane->setPlainText(QString(tr("Attachments in Sent Items"))); |
|
446 else if (listingMode == EMsgAttachmentsOutbox) |
|
447 mNaviPane->setPlainText(QString(tr("Attachments in Outbox"))); |
|
448 } |
|
449 |
|
450 // --------------------------------------------------------------------------- |
|
451 /** |
|
452 Show a list dialog |
|
453 \param List aList of item to select item from. |
|
454 \param Title text titleText of a dialog heading widget |
|
455 \return None |
|
456 */ |
|
457 void FbDriveView::openListDialog(const QStringList& items, const QString &titleText, QObject* receiver, const char* member) |
|
458 { |
|
459 // Create a list and some simple content for it |
|
460 HbSelectionDialog *dlg = new HbSelectionDialog(); |
|
461 dlg->setAttribute(Qt::WA_DeleteOnClose); |
|
462 // Set items to be popup's content |
|
463 dlg->setStringItems(items); |
|
464 dlg->setSelectionMode(HbAbstractItemView::SingleSelection); |
|
465 |
|
466 HbLabel *title = new HbLabel(dlg); |
|
467 title->setPlainText(titleText); |
|
468 dlg->setHeadingWidget(title); |
|
469 |
|
470 // Launch popup and handle the user response: |
|
471 dlg->open(receiver, member); |
|
472 } |
|
473 |
|
474 void FbDriveView::storeSelectedItemsOrCurrentItem() |
|
475 { |
|
476 QItemSelectionModel *selectionIndexes = mListView->selectionModel(); |
|
477 |
|
478 // by default use selected items |
|
479 if (selectionIndexes) { |
|
480 if (selectionIndexes->hasSelection()) { |
|
481 mSelectionIndexes = mListView->selectionModel()->selectedIndexes(); |
|
482 } else { // or if none selected, use the current item index |
|
483 mSelectionIndexes.clear(); |
|
484 mSelectionIndexes.append(mCurrentIndex); |
|
485 // QModelIndex currentIndex = currentItemIndex(); |
|
486 // if (mFbDriveModel->rowCount(currentItemIndex) > currentItemIndex && currentItemIndex >= 0) |
|
487 // { |
|
488 // modelIndexList.append(currentIndex); |
|
489 // } |
|
490 } |
|
491 } |
|
492 // mClipBoardInUse = true; |
|
493 } |
|
494 |
|
495 // --------------------------------------------------------------------------- |
|
496 |
|
497 QModelIndex FbDriveView::currentItemIndex() |
|
498 { |
|
499 return mCurrentIndex;//mListView->selectionModel()->currentIndex(); |
|
500 } |
|
501 |
|
502 // --------------------------------------------------------------------------- |
|
503 // operations in File Menu |
|
504 // --------------------------------------------------------------------------- |
|
505 |
|
506 void FbDriveView::fileOpenDrive() |
|
507 { |
|
508 // TODO make a separate function to be called from here and fileOpenDirectory() |
|
509 mLocationChanged = true; |
|
510 // get selected drive or directory from list view model and open it: |
|
511 //if (mListView->selectionModel()->hasSelection()) { |
|
512 // if (mListView->selectionModel()->selection().count() != 0) { |
|
513 // QModelIndex currentIndex = currentItemIndex(); |
|
514 mEngineWrapper->moveDownToDirectory(mCurrentIndex); |
|
515 mListView->setRootIndex(mCurrentIndex); |
|
516 refreshList(); |
|
517 // } else { |
|
518 // Notifications::showErrorNote("not selected item!"); |
|
519 // } |
|
520 } |
|
521 |
|
522 void FbDriveView::fileSearch() |
|
523 { |
|
524 QString searchPath; |
|
525 HbAction *contextrMenuAction = static_cast<HbAction *>(sender()); |
|
526 if (contextrMenuAction |
|
527 && contextrMenuAction->text().compare(QString("Search..."), Qt::CaseInsensitive) == 0 |
|
528 && contextrMenuAction == mContextMenuActions.mFileSearch) { |
|
529 FbDriveEntry driveEntry(mEngineWrapper->getDriveEntry(currentItemIndex())); |
|
530 searchPath = driveEntry.driveLetter() + QString(":\\"); |
|
531 } else { |
|
532 searchPath = mEngineWrapper->currentPath(); |
|
533 } |
|
534 emit aboutToShowSearchView(searchPath); |
|
535 } |
|
536 |
|
537 /** |
|
538 Show file properties |
|
539 */ |
|
540 void FbDriveView::fileProperties() |
|
541 { |
|
542 const QString MediaTypeText("Media"); |
|
543 const QString AttributesText("Atts"); |
|
544 const QString VolumeNameText("Name"); |
|
545 const QString UniqueIdText("ID"); |
|
546 const QString NumberOfFilesText("Files"); |
|
547 const QString UsedText("Used"); |
|
548 const QString FreeText("Free"); |
|
549 const QString SizeText("Size"); |
|
550 |
|
551 QModelIndex currentIndex = currentItemIndex(); |
|
552 QVector<QPair<QString, QString> > properties; |
|
553 QString titleText; |
|
554 bool showDialog(false); |
|
555 |
|
556 if (currentIndex.row() >= 0 && currentIndex.row() < mEngineWrapper->itemCount()) { |
|
557 // it is a drive entry |
|
558 FbDriveEntry driveEntry(mEngineWrapper->getDriveEntry(currentIndex)); |
|
559 |
|
560 // set title |
|
561 titleText = driveEntry.driveLetter() + (QString(":\\")); |
|
562 |
|
563 // media type |
|
564 properties.append(qMakePair(MediaTypeText, driveEntry.mediaTypeString())); |
|
565 |
|
566 // attributes |
|
567 QString attributes = driveEntry.attributesString(); // TODO should return QStringList |
|
568 QStringList attributesList = attributes.split(" + "); |
|
569 for(int i(0), ie(attributesList.count()); i < ie; ++i) { |
|
570 properties.append(qMakePair(AttributesText, attributesList[i])); |
|
571 } |
|
572 |
|
573 // volume name |
|
574 if (driveEntry.volumeInfoNameString().length()) { |
|
575 properties.append(qMakePair(VolumeNameText, driveEntry.volumeInfoNameString())); |
|
576 } |
|
577 |
|
578 // unique id |
|
579 QString uniqueId("0x"); |
|
580 uniqueId.append(QString::number(driveEntry.volumeInfoUniqueId(), 16).toUpper()); |
|
581 properties.append(qMakePair(UniqueIdText, uniqueId)); |
|
582 |
|
583 // number of files |
|
584 if (mEngineWrapper->settings().showSubDirectoryInfo()) { |
|
585 QString driveRoot = driveEntry.driveLetter() + (QString(":\\")); |
|
586 int allFilesCount = mEngineWrapper->getFilesCount(driveRoot); |
|
587 properties.append(qMakePair(NumberOfFilesText, QString::number(allFilesCount))); |
|
588 } |
|
589 |
|
590 // used |
|
591 QLocale loc; |
|
592 qint64 used = driveEntry.volumeInfoSize() - driveEntry.volumeInfoFree(); |
|
593 QString usedSize = loc.toString(used).append(QString(" B")); |
|
594 properties.append(qMakePair(UsedText, usedSize)); |
|
595 |
|
596 // free |
|
597 QString freeSize = loc.toString(driveEntry.volumeInfoFree()).append(QString(" B")); |
|
598 properties.append(qMakePair(FreeText, freeSize)); |
|
599 |
|
600 // size |
|
601 QString totalSize = loc.toString(driveEntry.volumeInfoSize()).append(QString(" B")); |
|
602 properties.append(qMakePair(SizeText, totalSize)); |
|
603 |
|
604 showDialog = true; |
|
605 } |
|
606 |
|
607 if (showDialog) { |
|
608 FbPropertiesDialog *dialog = new FbPropertiesDialog(); |
|
609 dialog->setTitle(titleText); |
|
610 |
|
611 // Set listwidget to be popup's content |
|
612 dialog->setProperties(properties); |
|
613 // Launch popup and handle the user response: |
|
614 dialog->open(); |
|
615 } |
|
616 } |
|
617 |
|
618 // edit menu |
|
619 void FbDriveView::editSnapShotToE() |
|
620 { |
|
621 |
|
622 } |
|
623 |
|
624 // --------------------------------------------------------------------------- |
|
625 // view menu |
|
626 // --------------------------------------------------------------------------- |
|
627 |
|
628 /** |
|
629 Refresh view |
|
630 */ |
|
631 void FbDriveView::viewRefresh() |
|
632 { |
|
633 refreshList(); |
|
634 } |
|
635 |
|
636 // --------------------------------------------------------------------------- |
|
637 // disk admin menu |
|
638 // --------------------------------------------------------------------------- |
|
639 |
|
640 /** |
|
641 Open old password for the selected drive dialog. |
|
642 */ |
|
643 void FbDriveView::diskAdminSetDrivePassword() |
|
644 { |
|
645 QModelIndex currentIndex = currentItemIndex(); |
|
646 // check if the drive has a password |
|
647 if (mEngineWrapper->hasDrivePassword(currentIndex)) { |
|
648 QString heading = QString("Existing password"); |
|
649 HbInputDialog::queryText(heading, this, SLOT(diskAdminSetDrivePasswordNew(HbAction*)), QString(), scene()); |
|
650 } else { |
|
651 QString heading = QString("New password"); |
|
652 HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDrivePassword(HbAction*)), mOldPassword, scene()); |
|
653 } |
|
654 } |
|
655 |
|
656 /** |
|
657 Open new password for the selected drive dialog. |
|
658 */ |
|
659 void FbDriveView::diskAdminSetDrivePasswordNew(HbAction *action) |
|
660 { |
|
661 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
662 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
663 mOldPassword = dlg->value().toString(); |
|
664 QString heading = QString("New password"); |
|
665 HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDrivePassword(HbAction*)), mOldPassword, scene()); |
|
666 } |
|
667 } |
|
668 |
|
669 /** |
|
670 Set password for the selected drive. |
|
671 */ |
|
672 void FbDriveView::doDiskAdminSetDrivePassword(HbAction *action) |
|
673 { |
|
674 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
675 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
676 QString newPassword = dlg->value().toString(); |
|
677 QModelIndex currentIndex = currentItemIndex(); |
|
678 mEngineWrapper->DiskAdminSetDrivePassword(currentIndex, mOldPassword, newPassword); |
|
679 refreshList(); |
|
680 mOldPassword = QString(); |
|
681 newPassword = QString(); |
|
682 } |
|
683 } |
|
684 |
|
685 /** |
|
686 Open Unlock the selected drive dialog. |
|
687 */ |
|
688 void FbDriveView::diskAdminUnlockDrive() |
|
689 { |
|
690 QModelIndex currentIndex = currentItemIndex(); |
|
691 // check if the drive is locked |
|
692 if (mEngineWrapper->isDriveLocked(currentIndex)) { |
|
693 QString heading = QString("Existing password"); |
|
694 HbInputDialog::queryText(heading, this, SLOT(doDiskAdminUnlockDrive(HbAction*)), QString(), scene()); |
|
695 } else { |
|
696 Notifications::showInformationNote(QString("This drive is not locked")); |
|
697 } |
|
698 } |
|
699 |
|
700 /** |
|
701 Unlock the selected drive. |
|
702 */ |
|
703 void FbDriveView::doDiskAdminUnlockDrive(HbAction *action) |
|
704 { |
|
705 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
706 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
707 QString oldPassword = dlg->value().toString(); |
|
708 QModelIndex currentIndex = currentItemIndex(); |
|
709 mEngineWrapper->DiskAdminUnlockDrive(currentIndex, oldPassword); |
|
710 refreshList(); |
|
711 } |
|
712 } |
|
713 |
|
714 /** |
|
715 Open clear password of the selected drive dialog. |
|
716 */ |
|
717 void FbDriveView::diskAdminClearDrivePassword() |
|
718 { |
|
719 QModelIndex currentIndex = currentItemIndex(); |
|
720 // check if the drive has a password |
|
721 if (mEngineWrapper->hasDrivePassword(currentIndex)) { |
|
722 QString heading = QString("Existing password"); |
|
723 HbInputDialog::queryText(heading, this, SLOT(doDiskAdminClearDrivePassword(HbAction*)), QString(), scene()); |
|
724 } else { |
|
725 Notifications::showInformationNote(QString("This drive has no password")); |
|
726 } |
|
727 } |
|
728 |
|
729 /** |
|
730 Clear password of the selected drive. |
|
731 */ |
|
732 void FbDriveView::doDiskAdminClearDrivePassword(HbAction *action) |
|
733 { |
|
734 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
735 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
736 QString oldPassword = dlg->value().toString(); |
|
737 QModelIndex currentIndex = currentItemIndex(); |
|
738 mEngineWrapper->DiskAdminClearDrivePassword(currentIndex, oldPassword); |
|
739 refreshList(); |
|
740 } |
|
741 } |
|
742 |
|
743 |
|
744 /** |
|
745 Question for erase password of the selected drive |
|
746 */ |
|
747 void FbDriveView::diskAdminEraseDrivePassword() |
|
748 { |
|
749 // check if the drive has a password |
|
750 QModelIndex currentIndex = currentItemIndex(); |
|
751 if (mEngineWrapper->hasDrivePassword(currentIndex)) { |
|
752 HbMessageBox::question(QString("Are you sure? All data can be lost!"), |
|
753 this, |
|
754 SLOT(doDiskAdminEraseDrivePassword(int)), |
|
755 HbMessageBox::Yes | HbMessageBox::No); |
|
756 } else { |
|
757 Notifications::showInformationNote(QString("This drive has no password")); |
|
758 } |
|
759 } |
|
760 |
|
761 /** |
|
762 Erase password of the selected drive |
|
763 */ |
|
764 void FbDriveView::doDiskAdminEraseDrivePassword(int action) |
|
765 { |
|
766 if (action == HbMessageBox::Yes) { |
|
767 QModelIndex currentIndex = currentItemIndex(); |
|
768 mEngineWrapper->DiskAdminEraseDrivePassword(currentIndex); |
|
769 refreshList(); |
|
770 } |
|
771 } |
|
772 |
|
773 /** |
|
774 Performs format on the selected drive |
|
775 */ |
|
776 void FbDriveView::diskAdminFormatDrive() |
|
777 { |
|
778 HbMessageBox::question(QString("Are you sure? All data will be lost!"), |
|
779 this, |
|
780 SLOT(doDiskAdminFormatDrive(int)), |
|
781 HbMessageBox::Yes | HbMessageBox::No); |
|
782 } |
|
783 |
|
784 /** |
|
785 Performs format on the selected drive |
|
786 */ |
|
787 void FbDriveView::doDiskAdminFormatDrive(int action) |
|
788 { |
|
789 if (action == HbMessageBox::Yes) { |
|
790 QModelIndex currentIndex = currentItemIndex(); |
|
791 mEngineWrapper->DiskAdminFormatDrive(currentIndex, false); |
|
792 } |
|
793 } |
|
794 |
|
795 /** |
|
796 Performs quick format on the selected drive |
|
797 */ |
|
798 void FbDriveView::diskAdminQuickFormatDrive() |
|
799 { |
|
800 HbMessageBox::question(QString("Are you sure? All data will be lost!"), |
|
801 this, |
|
802 SLOT(doDiskAdminQuickFormatDrive(int)), |
|
803 HbMessageBox::Yes | HbMessageBox::No); |
|
804 } |
|
805 |
|
806 /** |
|
807 Performs quick format on the selected drive |
|
808 */ |
|
809 void FbDriveView::doDiskAdminQuickFormatDrive(int action) |
|
810 { |
|
811 if (action == HbMessageBox::Yes) { |
|
812 QModelIndex currentIndex = currentItemIndex(); |
|
813 mEngineWrapper->DiskAdminFormatDrive(currentIndex, true); |
|
814 } |
|
815 } |
|
816 |
|
817 /** |
|
818 Checks the disk integrity on the selected drive |
|
819 */ |
|
820 void FbDriveView::diskAdminCheckDisk() |
|
821 { |
|
822 QModelIndex currentIndex = currentItemIndex(); |
|
823 mEngineWrapper->DiskAdminCheckDisk(currentIndex); |
|
824 } |
|
825 |
|
826 /** |
|
827 Checks the selected drive for errors and corrects them |
|
828 */ |
|
829 void FbDriveView::diskAdminScanDrive() |
|
830 { |
|
831 HbMessageBox::question(QString("This finds errors on disk and corrects them. Proceed?"), |
|
832 this, |
|
833 SLOT(doDiskAdminScanDrive(int)), |
|
834 HbMessageBox::Yes | HbMessageBox::No); |
|
835 } |
|
836 |
|
837 /** |
|
838 Checks the selected drive for errors and corrects them |
|
839 */ |
|
840 void FbDriveView::doDiskAdminScanDrive(int action) |
|
841 { |
|
842 if (action == HbMessageBox::Yes) { |
|
843 QModelIndex currentIndex = currentItemIndex(); |
|
844 mEngineWrapper->DiskAdminScanDrive(currentIndex); |
|
845 refreshList(); |
|
846 } |
|
847 } |
|
848 |
|
849 /** |
|
850 Open drive name dialog |
|
851 */ |
|
852 void FbDriveView::diskAdminSetDriveName() |
|
853 { |
|
854 QString driveName; |
|
855 |
|
856 // get existing drive name |
|
857 QModelIndex currentIndex = currentItemIndex(); |
|
858 mEngineWrapper->GetDriveName(currentIndex, driveName); |
|
859 |
|
860 QString heading = QString("New name"); |
|
861 HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDriveName(HbAction*)), driveName, scene()); |
|
862 } |
|
863 |
|
864 /** |
|
865 Set drive name. |
|
866 */ |
|
867 void FbDriveView::doDiskAdminSetDriveName(HbAction *action) |
|
868 { |
|
869 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
870 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
871 QString driveName = dlg->value().toString(); |
|
872 |
|
873 QModelIndex currentIndex = currentItemIndex(); |
|
874 mEngineWrapper->DiskAdminSetDriveName(currentIndex, driveName); |
|
875 |
|
876 refreshList(); |
|
877 } |
|
878 } |
|
879 |
|
880 /** |
|
881 Open drive volume label dialog |
|
882 */ |
|
883 void FbDriveView::diskAdminSetDriveVolumeLabel() |
|
884 { |
|
885 QString volumeLabel; |
|
886 |
|
887 // get existing drive name |
|
888 QModelIndex currentIndex = currentItemIndex(); |
|
889 mEngineWrapper->GetDriveVolumeLabel(currentIndex, volumeLabel); |
|
890 |
|
891 QString heading = QString("New volume label"); |
|
892 HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDriveVolumeLabel(HbAction*)), volumeLabel, scene()); |
|
893 } |
|
894 |
|
895 /** |
|
896 Set drive volume label. |
|
897 */ |
|
898 void FbDriveView::doDiskAdminSetDriveVolumeLabel(HbAction *action) |
|
899 { |
|
900 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
901 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
902 QString volumeLabel = dlg->value().toString(); |
|
903 |
|
904 QModelIndex currentIndex = currentItemIndex(); |
|
905 mEngineWrapper->DiskAdminSetDriveVolumeLabel(currentIndex, volumeLabel); |
|
906 |
|
907 refreshList(); |
|
908 } |
|
909 } |
|
910 |
|
911 /** |
|
912 Eject the selected drive |
|
913 */ |
|
914 void FbDriveView::diskAdminEjectDrive() |
|
915 { |
|
916 QModelIndex currentIndex = currentItemIndex(); |
|
917 mEngineWrapper->DiskAdminEjectDrive(currentIndex); |
|
918 refreshList(); |
|
919 } |
|
920 |
|
921 /** |
|
922 Dismount the selected drive |
|
923 */ |
|
924 void FbDriveView::diskAdminDismountDrive() |
|
925 { |
|
926 HbMessageBox::question(QString("Are you sure you know what are you doing?"), |
|
927 this, |
|
928 SLOT(doDiskAdminDismountDrive(int)), |
|
929 HbMessageBox::Yes | HbMessageBox::No); |
|
930 } |
|
931 |
|
932 void FbDriveView::doDiskAdminDismountDrive(int action) |
|
933 { |
|
934 if (action == HbMessageBox::Yes) { |
|
935 QModelIndex currentIndex = currentItemIndex(); |
|
936 mEngineWrapper->DiskAdminDismountDrive(currentIndex); |
|
937 refreshList(); |
|
938 } |
|
939 } |
|
940 |
|
941 /** |
|
942 Erase Master Boot Record of the selected drive |
|
943 */ |
|
944 void FbDriveView::diskAdminEraseMBR() |
|
945 { |
|
946 // TODO What to do with FB LITE macros? |
|
947 HbMessageBox::question(QString("Are you sure? Your media driver must support this!"), |
|
948 this, |
|
949 SLOT(doDiskAdminEraseMBR(int)), |
|
950 HbMessageBox::Yes | HbMessageBox::No); |
|
951 } |
|
952 |
|
953 void FbDriveView::doDiskAdminEraseMBR(int action) |
|
954 { |
|
955 // TODO What to do with FB LITE macros? |
|
956 if (action == HbMessageBox::Yes) { |
|
957 HbMessageBox::question(QString("Are you really sure you know what are you doing ?!?"), |
|
958 this, |
|
959 SLOT(doDiskAdminReallyEraseMBR(int)), |
|
960 HbMessageBox::Yes | HbMessageBox::No); |
|
961 } |
|
962 } |
|
963 |
|
964 void FbDriveView::doDiskAdminReallyEraseMBR(int action) |
|
965 { |
|
966 if (action == HbMessageBox::Yes) { |
|
967 QModelIndex currentIndex = currentItemIndex(); |
|
968 // warn if the selected drive is not detected as removable |
|
969 if (mEngineWrapper->isDriveRemovable(currentIndex)) { |
|
970 mEngineWrapper->DiskAdminEraseMBR(currentIndex); |
|
971 refreshList(); |
|
972 } else { |
|
973 HbMessageBox::question(QString("Selected drive is not removable, really continue?"), |
|
974 this, |
|
975 SLOT(doDiskAdminNotRemovableReallyEraseMBR(int)), |
|
976 HbMessageBox::Yes | HbMessageBox::No); |
|
977 } |
|
978 } |
|
979 } |
|
980 |
|
981 void FbDriveView::doDiskAdminNotRemovableReallyEraseMBR(int action) |
|
982 { |
|
983 if (action == HbMessageBox::Yes) { |
|
984 QModelIndex currentIndex = currentItemIndex(); |
|
985 mEngineWrapper->DiskAdminEraseMBR(currentIndex); |
|
986 refreshList(); |
|
987 } |
|
988 |
|
989 } |
|
990 |
|
991 /** |
|
992 Partition the selected drive |
|
993 */ |
|
994 void FbDriveView::diskAdminPartitionDrive() |
|
995 { |
|
996 HbMessageBox::question(QString("Are you sure? Your media driver must support this!"), |
|
997 this, |
|
998 SLOT(diskAdminPartitionDriveProceed(int)), |
|
999 HbMessageBox::Yes | HbMessageBox::No); |
|
1000 } |
|
1001 |
|
1002 /** |
|
1003 Partition the selected drive if user is sure |
|
1004 */ |
|
1005 void FbDriveView::diskAdminPartitionDriveProceed(int action) |
|
1006 { |
|
1007 if (action == HbMessageBox::Yes) { |
|
1008 HbMessageBox::question(QString("Are you really sure you know what are you doing ?!?"), |
|
1009 this, |
|
1010 SLOT(diskAdminPartitionDriveReallyProceed(int)), |
|
1011 HbMessageBox::Yes | HbMessageBox::No); |
|
1012 } |
|
1013 } |
|
1014 |
|
1015 /** |
|
1016 Partition the selected drive if user is really sure |
|
1017 */ |
|
1018 void FbDriveView::diskAdminPartitionDriveReallyProceed(int action) |
|
1019 { |
|
1020 if (action == HbMessageBox::Yes) { |
|
1021 QModelIndex currentIndex = currentItemIndex(); |
|
1022 mEraseMBR = false; |
|
1023 // warn if the selected drive is not detected as removable |
|
1024 mProceed = false; |
|
1025 if (mEngineWrapper->isDriveRemovable(currentIndex)) { |
|
1026 mProceed = true; |
|
1027 } else { |
|
1028 HbMessageBox::question(QString("Selected drive is not removable, really continue?"), |
|
1029 this, |
|
1030 SLOT(diskAdminPartitionDriveIsNotRemovable(int)), |
|
1031 HbMessageBox::Yes | HbMessageBox::No); |
|
1032 } |
|
1033 |
|
1034 if (mProceed) { |
|
1035 // query if erase mbr |
|
1036 mEraseMBR = false; |
|
1037 |
|
1038 HbMessageBox::question(QString("Erase MBR first (normally needed)?"), |
|
1039 this, |
|
1040 SLOT(diskAdminPartitionDriveEraseMbr(int)), |
|
1041 HbMessageBox::Yes | HbMessageBox::No); |
|
1042 |
|
1043 // TODO use HbListDialog |
|
1044 QStringList list; |
|
1045 list << "1" << "2" << "3" << "4"; |
|
1046 openListDialog(list, QString("Partitions?"), this, SLOT(diskAdminPartitionDriveGetCount(HbAction*))); |
|
1047 } |
|
1048 } |
|
1049 } |
|
1050 |
|
1051 /** |
|
1052 Store result of user query about proceeding when drive is not removable. |
|
1053 */ |
|
1054 void FbDriveView::diskAdminPartitionDriveIsNotRemovable(int action) |
|
1055 { |
|
1056 if (action == HbMessageBox::Yes) { |
|
1057 mProceed = true; |
|
1058 } else { |
|
1059 mProceed = false; |
|
1060 } |
|
1061 } |
|
1062 |
|
1063 /** |
|
1064 Store result of user query about erase MBR |
|
1065 */ |
|
1066 void FbDriveView::diskAdminPartitionDriveEraseMbr(int action) |
|
1067 { |
|
1068 if (action == HbMessageBox::Yes) { |
|
1069 mEraseMBR = true; |
|
1070 } |
|
1071 } |
|
1072 |
|
1073 /** |
|
1074 Partition the selected drive |
|
1075 */ |
|
1076 void FbDriveView::diskAdminPartitionDriveGetCount(HbAction* action) |
|
1077 { |
|
1078 HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender()); |
|
1079 if(!action && dlg && dlg->selectedItems().count()){ |
|
1080 int selectionIndex = dlg->selectedItems().at(0).toInt(); |
|
1081 QModelIndex currentIndex = currentItemIndex(); |
|
1082 int amountOfPartitions = selectionIndex + 1; |
|
1083 mEngineWrapper->DiskAdminPartitionDrive(currentIndex, mEraseMBR, amountOfPartitions); |
|
1084 refreshList(); |
|
1085 } |
|
1086 } |
|
1087 |
|
1088 // --------------------------------------------------------------------------- |
|
1089 // tools menu |
|
1090 // --------------------------------------------------------------------------- |
|
1091 void FbDriveView::toolsAllAppsToTextFile() |
|
1092 { |
|
1093 |
|
1094 } |
|
1095 |
|
1096 /** |
|
1097 Write all files to text file |
|
1098 */ |
|
1099 void FbDriveView::toolsAllFilesToTextFile() |
|
1100 { |
|
1101 mEngineWrapper->toolsWriteAllFiles(); |
|
1102 } |
|
1103 |
|
1104 //void FbDriveView::toolsAvkonIconCacheEnable() |
|
1105 //{ |
|
1106 // |
|
1107 //} |
|
1108 //void FbDriveView::toolsAvkonIconCacheDisable() |
|
1109 //{ |
|
1110 // |
|
1111 //} |
|
1112 |
|
1113 /** |
|
1114 Disable extended errors |
|
1115 */ |
|
1116 void FbDriveView::toolsDisableExtendedErrors() |
|
1117 { |
|
1118 mEngineWrapper->ToolsSetErrRd(false); |
|
1119 } |
|
1120 |
|
1121 void FbDriveView::toolsDumpMsgStoreWalk() |
|
1122 { |
|
1123 |
|
1124 } |
|
1125 void FbDriveView::toolsEditDataTypes() |
|
1126 { |
|
1127 |
|
1128 } |
|
1129 |
|
1130 /** |
|
1131 Enable extended errors |
|
1132 */ |
|
1133 void FbDriveView::toolsEnableExtendedErrors() |
|
1134 { |
|
1135 mEngineWrapper->ToolsSetErrRd(true); |
|
1136 } |
|
1137 |
|
1138 /** |
|
1139 Open simulate leave dialog |
|
1140 */ |
|
1141 void FbDriveView::toolsErrorSimulateLeave() |
|
1142 { |
|
1143 int leaveCode = -6; |
|
1144 QString heading = QString("Leave code"); |
|
1145 HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene()); |
|
1146 } |
|
1147 |
|
1148 |
|
1149 /** |
|
1150 Simulate leave. |
|
1151 */ |
|
1152 void FbDriveView::doToolsErrorSimulateLeave(HbAction *action) |
|
1153 { |
|
1154 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
1155 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
1156 bool ok; |
|
1157 int leaveCode = dlg->value().toString().toInt(&ok); |
|
1158 if (leaveCode != 0 || ok) { |
|
1159 mEngineWrapper->ToolsErrorSimulateLeave(leaveCode); |
|
1160 } |
|
1161 } |
|
1162 } |
|
1163 |
|
1164 /** |
|
1165 Open simulate panic dialog. |
|
1166 */ |
|
1167 void FbDriveView::toolsErrorSimulatePanic() |
|
1168 { |
|
1169 mPanicCategory = QString ("Test Category"); |
|
1170 QString heading = QString("Panic category"); |
|
1171 HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene()); |
|
1172 } |
|
1173 |
|
1174 /** |
|
1175 Simulate panic. |
|
1176 */ |
|
1177 void FbDriveView::doToolsErrorSimulatePanicCode(HbAction *action) |
|
1178 { |
|
1179 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
1180 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
1181 mPanicCategory = dlg->value().toString(); |
|
1182 int panicCode(555); |
|
1183 QString heading = QString("Panic code"); |
|
1184 HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene()); |
|
1185 } |
|
1186 } |
|
1187 |
|
1188 /** |
|
1189 Simulate panic. |
|
1190 */ |
|
1191 void FbDriveView::doToolsErrorSimulatePanic(HbAction *action) |
|
1192 { |
|
1193 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
1194 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
1195 bool ok; |
|
1196 int panicCode = dlg->value().toInt(&ok); |
|
1197 if (panicCode != 0 || ok) { |
|
1198 mEngineWrapper->ToolsErrorSimulatePanic(mPanicCategory, panicCode); |
|
1199 } |
|
1200 } |
|
1201 } |
|
1202 |
|
1203 /** |
|
1204 Open simulate exception dialog. |
|
1205 */ |
|
1206 void FbDriveView::toolsErrorSimulateException() |
|
1207 { |
|
1208 int exceptionCode = 0; |
|
1209 QString heading = QString("Exception code"); |
|
1210 HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene()); |
|
1211 } |
|
1212 |
|
1213 /** |
|
1214 Simulate exception. |
|
1215 */ |
|
1216 void FbDriveView::doToolsErrorSimulateException(HbAction *action) |
|
1217 { |
|
1218 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
1219 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
1220 bool ok; |
|
1221 int exceptionCode = dlg->value().toInt(&ok); |
|
1222 if (exceptionCode != 0 || ok) { |
|
1223 mEngineWrapper->ToolsErrorSimulateException(exceptionCode); |
|
1224 } |
|
1225 } |
|
1226 } |
|
1227 |
|
1228 // void FbDriveView::toolsLocalConnectivityActivateInfrared() |
|
1229 //{ |
|
1230 // |
|
1231 //} |
|
1232 // void FbDriveView::toolsLocalConnectivityLaunchBTUI() |
|
1233 //{ |
|
1234 // |
|
1235 //} |
|
1236 // void FbDriveView::toolsLocalConnectivityLaunchUSBUI() |
|
1237 //{ |
|
1238 // |
|
1239 //} |
|
1240 void FbDriveView::toolsMessageInbox() |
|
1241 { |
|
1242 |
|
1243 } |
|
1244 void FbDriveView::toolsMessageDrafts() |
|
1245 { |
|
1246 |
|
1247 } |
|
1248 void FbDriveView::toolsMessageSentItems() |
|
1249 { |
|
1250 |
|
1251 } |
|
1252 void FbDriveView::toolsMessageOutbox() |
|
1253 { |
|
1254 |
|
1255 } |
|
1256 void FbDriveView::toolsMemoryInfo() |
|
1257 { |
|
1258 |
|
1259 } |
|
1260 void FbDriveView::toolsSecureBackStart() |
|
1261 { |
|
1262 |
|
1263 } |
|
1264 void FbDriveView::toolsSecureBackRestore() |
|
1265 { |
|
1266 |
|
1267 } |
|
1268 void FbDriveView::toolsSecureBackStop() |
|
1269 { |
|
1270 |
|
1271 } |
|
1272 |
|
1273 /** |
|
1274 Open debug mask dialog |
|
1275 */ |
|
1276 void FbDriveView::toolsSetDebugMaskQuestion() |
|
1277 { |
|
1278 quint32 dbgMask = mEngineWrapper->getDebugMask(); |
|
1279 QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16)); |
|
1280 QString heading = QString("Kernel debug mask in hex format"); |
|
1281 HbInputDialog::queryText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene()); |
|
1282 } |
|
1283 |
|
1284 /** |
|
1285 Set debug mask |
|
1286 */ |
|
1287 void FbDriveView::toolsSetDebugMask(HbAction *action) |
|
1288 { |
|
1289 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
1290 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
1291 QString dbgMaskText = dlg->value().toString(); |
|
1292 if (dbgMaskText.length() > 2 && dbgMaskText[0]=='0' && dbgMaskText[1]=='x') { |
|
1293 bool ok; |
|
1294 quint32 dbgMask = dbgMaskText.toUInt(&ok, 16); |
|
1295 if (dbgMask != 0 || ok) { |
|
1296 mEngineWrapper->toolsSetDebugMask(dbgMask); |
|
1297 Notifications::showConfirmationNote(QString("Changed")); |
|
1298 } else { |
|
1299 Notifications::showErrorNote(QString("Cannot convert value")); |
|
1300 } |
|
1301 } else { |
|
1302 Notifications::showErrorNote(QString("Not in hex format")); |
|
1303 } |
|
1304 } |
|
1305 } |
|
1306 |
|
1307 void FbDriveView::toolsShowOpenFilesHere() |
|
1308 { |
|
1309 |
|
1310 } |
|
1311 |
|
1312 // --------------------------------------------------------------------------- |
|
1313 // main menu items |
|
1314 // --------------------------------------------------------------------------- |
|
1315 |
|
1316 /** |
|
1317 Show about note |
|
1318 */ |
|
1319 void FbDriveView::about() |
|
1320 { |
|
1321 Notifications::showAboutNote(); |
|
1322 } |
|
1323 |
|
1324 // --------------------------------------------------------------------------- |
|
1325 // End of operations |
|
1326 // --------------------------------------------------------------------------- |
|
1327 |
|
1328 // --------------------------------------------------------------------------- |
|
1329 |
|
1330 /** |
|
1331 Item is selected from list when selection mode is activated from menu |
|
1332 */ |
|
1333 void FbDriveView::selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/) |
|
1334 { |
|
1335 //QItemSelectionModel *selectionModel = mListView->selectionModel(); |
|
1336 } |
|
1337 |
|
1338 /** |
|
1339 An item is clicked from navigation item list. Navigation item list contains |
|
1340 drive-, folder- or file items. Opens selected drive, folder or file popup menu |
|
1341 */ |
|
1342 void FbDriveView::activated(const QModelIndex& index) |
|
1343 { |
|
1344 if (mFbDriveModel) { |
|
1345 // if (mEngineWrapper->isDriveListViewActive()) { |
|
1346 mEngineWrapper->moveDownToDirectory(index); |
|
1347 //emit aboutToShowFileView(QString(mEngineWrapper->currentPath())); |
|
1348 emit aboutToShowFileView(); |
|
1349 //refreshList(); |
|
1350 // } |
|
1351 } |
|
1352 } |
|
1353 |
|
1354 // --------------------------------------------------------------------------- |