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 "fbfileview.h" |
|
19 #include "fbsettingsview.h" |
|
20 #include "fbeditorview.h" |
|
21 #include "fbsearchview.h" |
|
22 #include "enginewrapper.h" |
|
23 #include "notifications.h" |
|
24 #include "fbfolderselectiondialog.h" |
|
25 #include "fbfilemodel.h" |
|
26 #include "filebrowsersortfilterproxymodel.h" |
|
27 //#include "fbfilelistviewitem.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 #include <HbToolBar> |
|
44 #include <HbToolBarExtension> |
|
45 #include <HbSearchPanel> |
|
46 |
|
47 #include <QString> |
|
48 #include <QGraphicsLinearLayout> |
|
49 #include <QItemSelection> |
|
50 #include <QDebug> |
|
51 //TODO check if needed to do this way |
|
52 #include <FB.hrh> |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 |
|
56 FbFileView::FbFileView() : |
|
57 mEngineWrapper(0), |
|
58 mListView(0), |
|
59 mToolBar(0), |
|
60 mNaviPane(0), |
|
61 mSearchPanel(0), |
|
62 mMainLayout(0), |
|
63 mFbFileModel(0), |
|
64 mSortFilterProxyModel(0), |
|
65 mOptionMenuActions(), |
|
66 mContextMenuActions(), |
|
67 mContextMenu(0), |
|
68 mToolbarBackAction(0), |
|
69 mToolbarFilterAction(0), |
|
70 mToolbarPasteAction(0), |
|
71 mItemHighlighted(false), |
|
72 mLocationChanged(false), |
|
73 mRemoveFileAfterCopied(false), |
|
74 // mClipBoardInUse(false), |
|
75 mFolderContentChanged(false), |
|
76 mCurrentIndex(), |
|
77 mOldPassword(), |
|
78 mPanicCategory(), |
|
79 mAbsoluteFilePath(), |
|
80 mOverwriteOptions(), |
|
81 mModelIndex(), |
|
82 mNewFileName(), |
|
83 mProceed(false), |
|
84 mEraseMBR(false) |
|
85 { |
|
86 setTitle("File Browser"); |
|
87 |
|
88 createMenu(); |
|
89 createContextMenu(); |
|
90 createToolBar(); |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 |
|
95 void FbFileView::init(EngineWrapper *engineWrapper) |
|
96 { |
|
97 mEngineWrapper = engineWrapper; |
|
98 |
|
99 mListView = new HbListView(this); |
|
100 mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape); |
|
101 |
|
102 // mListView->setItemPrototype(new FbDiskListViewItem(mListView)); |
|
103 |
|
104 mFbFileModel = new FbFileModel(mEngineWrapper); |
|
105 if (!mListView->model()) { |
|
106 |
|
107 mEngineWrapper->refreshView(); |
|
108 |
|
109 mSortFilterProxyModel = new FileBrowserSortFilterProxyModel(this); |
|
110 mSortFilterProxyModel->setSourceModel(mFbFileModel); |
|
111 mSortFilterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); |
|
112 mSearchPanel->setPlaceholderText(QString("Type filter criteria")); |
|
113 |
|
114 mListView->setModel(mSortFilterProxyModel); |
|
115 } |
|
116 |
|
117 //mListView->setRootIndex(mFileSystemModel->index(startPath)); |
|
118 //mListView->setRootIndex(model->index()); |
|
119 |
|
120 //setItemVisible(Hb::ToolBarItem, !mEngineWrapper->isDriveListViewActive()); |
|
121 // mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); |
|
122 |
|
123 connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); |
|
124 connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), |
|
125 this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF))); |
|
126 connect(mEngineWrapper, SIGNAL(fileSystemDataChanged()), this, SLOT(refreshList())); |
|
127 |
|
128 mNaviPane = new HbLabel(this); |
|
129 mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default |
|
130 //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); |
|
131 HbFontSpec fontSpec(HbFontSpec::PrimarySmall); |
|
132 mNaviPane->setFontSpec(fontSpec); |
|
133 |
|
134 // Create layout and add list view and toolbar into layout: |
|
135 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
136 mMainLayout->addItem(mNaviPane); |
|
137 mMainLayout->addItem(mListView); |
|
138 setLayout(mMainLayout); |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 |
|
143 FbFileView::~FbFileView() |
|
144 { |
|
145 // if (mEngineWrapper) { |
|
146 // delete mEngineWrapper; |
|
147 // } |
|
148 if (mContextMenu) { |
|
149 mContextMenu->deleteLater(); |
|
150 } |
|
151 |
|
152 delete mSortFilterProxyModel; |
|
153 delete mFbFileModel; |
|
154 delete mListView; |
|
155 delete mToolBar; |
|
156 } |
|
157 |
|
158 /** |
|
159 Initial setup for options menu. |
|
160 Dynamic menu update during the runtime is performed by updateOptionMenu() which |
|
161 to menu's aboutToShow() signal. |
|
162 */ |
|
163 void FbFileView::createMenu() |
|
164 { |
|
165 createFileMenu(); |
|
166 createEditMenu(); |
|
167 createViewMenu(); |
|
168 createToolsMenu(); |
|
169 |
|
170 createSelectionMenuItem(); |
|
171 createSettingsMenuItem(); |
|
172 createAboutMenuItem(); |
|
173 createExitMenuItem(); |
|
174 |
|
175 // menu dynamic update |
|
176 connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateOptionMenu())); |
|
177 } |
|
178 |
|
179 /** |
|
180 Initial setup for File submenu |
|
181 */ |
|
182 void FbFileView::createFileMenu() |
|
183 { |
|
184 mOptionMenuActions.mFileMenu = menu()->addMenu("File"); |
|
185 |
|
186 mOptionMenuActions.mFileBackMoveUp = mOptionMenuActions.mFileMenu->addAction("Back/Move up", this, SLOT(fileBackMoveUp())); |
|
187 mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); |
|
188 |
|
189 mOptionMenuActions.mFileNewMenu = mOptionMenuActions.mFileMenu->addMenu("New"); |
|
190 mOptionMenuActions.mFileNewFile = mOptionMenuActions.mFileNewMenu->addAction("File", this, SLOT(fileNewFile())); |
|
191 mOptionMenuActions.mFileNewDirectory = mOptionMenuActions.mFileNewMenu->addAction("Directory", this, SLOT(fileNewDirectory())); |
|
192 |
|
193 mOptionMenuActions.mFileDelete = mOptionMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete())); |
|
194 mOptionMenuActions.mFileRename = mOptionMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename())); |
|
195 mOptionMenuActions.mFileTouch = mOptionMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch())); |
|
196 |
|
197 mOptionMenuActions.mFileSetAttributes = mOptionMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); |
|
198 } |
|
199 |
|
200 /** |
|
201 Initial setup for Edit submenu |
|
202 */ |
|
203 void FbFileView::createEditMenu() |
|
204 { |
|
205 mOptionMenuActions.mEditMenu = menu()->addMenu("Edit"); |
|
206 |
|
207 mOptionMenuActions.mEditSnapShotToE = mOptionMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); |
|
208 mOptionMenuActions.mEditSnapShotToE->setVisible(false); |
|
209 mOptionMenuActions.mEditCut = mOptionMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); |
|
210 mOptionMenuActions.mEditCopy = mOptionMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); |
|
211 mOptionMenuActions.mEditPaste = mOptionMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); |
|
212 |
|
213 mOptionMenuActions.mEditCopyToFolder = mOptionMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); |
|
214 mOptionMenuActions.mEditMoveToFolder = mOptionMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); |
|
215 |
|
216 mOptionMenuActions.mEditSelect = mOptionMenuActions.mEditMenu->addAction("Select", this, SLOT(editSelect())); |
|
217 mOptionMenuActions.mEditUnselect = mOptionMenuActions.mEditMenu->addAction("Unselect", this, SLOT(editUnselect())); |
|
218 mOptionMenuActions.mEditSelectAll = mOptionMenuActions.mEditMenu->addAction("Select all", this, SLOT(editSelectAll())); |
|
219 mOptionMenuActions.mEditUnselectAll = mOptionMenuActions.mEditMenu->addAction("Unselect all", this, SLOT(editUnselectAll())); |
|
220 } |
|
221 |
|
222 /** |
|
223 Initial setup for View submenu |
|
224 */ |
|
225 void FbFileView::createViewMenu() |
|
226 { |
|
227 mOptionMenuActions.mViewMenu = menu()->addMenu("View"); |
|
228 //mOptionMenuActions.mViewMenu->menuAction()->setVisible(false); |
|
229 |
|
230 mOptionMenuActions.mViewFilterEntries = mOptionMenuActions.mViewMenu->addAction("Filter entries", this, SLOT(viewFilterEntries())); |
|
231 mOptionMenuActions.mViewRefresh = mOptionMenuActions.mViewMenu->addAction("Refresh", this, SLOT(viewRefresh())); |
|
232 } |
|
233 |
|
234 /** |
|
235 Initial setup for Tools submenu |
|
236 */ |
|
237 void FbFileView::createToolsMenu() |
|
238 { |
|
239 mOptionMenuActions.mToolsMenu = menu()->addMenu("Tools"); |
|
240 |
|
241 mOptionMenuActions.mToolsAllAppsToTextFile = mOptionMenuActions.mToolsMenu->addAction("All apps to a text file", this, SLOT(toolsAllAppsToTextFile())); |
|
242 mOptionMenuActions.mToolsAllAppsToTextFile->setVisible(false); |
|
243 mOptionMenuActions.mToolsAllFilesToTextFile = mOptionMenuActions.mToolsMenu->addAction("All files to a text file", this, SLOT(toolsAllFilesToTextFile())); |
|
244 //mOptionMenuActions.mToolsAllFilesToTextFile->setVisible(false); |
|
245 |
|
246 // mOptionMenuActions.mToolsAvkonIconCacheMenu = mOptionMenuActions.mToolsMenu->addMenu("Avkon icon cache"); |
|
247 // mOptionMenuActions.mToolsAvkonIconCacheMenu->menuAction()->setVisible(false); |
|
248 // mOptionMenuActions.mToolsAvkonIconCacheEnable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Enable", this, SLOT(toolsAvkonIconCacheEnable())); |
|
249 // mOptionMenuActions.mToolsAvkonIconCacheDisable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Clear and disable", this, SLOT(toolsAvkonIconCacheDisable())); |
|
250 |
|
251 mOptionMenuActions.mToolsDisableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Disable extended errors", this, SLOT(toolsDisableExtendedErrors())); |
|
252 mOptionMenuActions.mToolsDumpMsgStoreWalk = mOptionMenuActions.mToolsMenu->addAction("Dump msg. store walk", this, SLOT(toolsDumpMsgStoreWalk())); |
|
253 mOptionMenuActions.mToolsDumpMsgStoreWalk->setVisible(false); |
|
254 mOptionMenuActions.mToolsEditDataTypes = mOptionMenuActions.mToolsMenu->addAction("Edit data types", this, SLOT(toolsEditDataTypes())); |
|
255 mOptionMenuActions.mToolsEditDataTypes->setVisible(false); |
|
256 mOptionMenuActions.mToolsEnableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Enable extended errors", this, SLOT(toolsEnableExtendedErrors())); |
|
257 |
|
258 mOptionMenuActions.mToolsErrorSimulateMenu = mOptionMenuActions.mToolsMenu->addMenu("Error simulate"); |
|
259 mOptionMenuActions.mToolsErrorSimulateLeave = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Leave", this, SLOT(toolsErrorSimulateLeave())); |
|
260 mOptionMenuActions.mToolsErrorSimulatePanic = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Panic", this, SLOT(toolsErrorSimulatePanic())); |
|
261 mOptionMenuActions.mToolsErrorSimulatePanic->setVisible(false); |
|
262 mOptionMenuActions.mToolsErrorSimulateException = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Exception", this, SLOT(toolsErrorSimulateException())); |
|
263 |
|
264 // mOptionMenuActions.mLocalConnectivityMenu = mOptionMenuActions.mToolsMenu->addMenu("Local connectivity"); |
|
265 // mOptionMenuActions.mToolsLocalConnectivityActivateInfrared = mOptionMenuActions.mLocalConnectivityMenu->addAction("Activate infrared", this, SLOT(toolsLocalConnectivityActivateInfrared())); |
|
266 // mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch BT UI", this, SLOT(toolsLocalConnectivityLaunchBTUI())); |
|
267 // mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch USB UI", this, SLOT(toolsLocalConnectivityLaunchUSBUI())); |
|
268 |
|
269 mOptionMenuActions.mToolsMessageAttachmentsMenu = mOptionMenuActions.mToolsMenu->addMenu("Message attachments"); |
|
270 mOptionMenuActions.mToolsMessageAttachmentsMenu->menuAction()->setVisible(false); |
|
271 mOptionMenuActions.mToolsMessageInbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Inbox", this, SLOT(toolsMessageInbox())); |
|
272 mOptionMenuActions.mToolsMessageDrafts = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Drafts", this, SLOT(toolsMessageDrafts())); |
|
273 mOptionMenuActions.mToolsMessageSentItems = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Sent items", this, SLOT(toolsMessageSentItems())); |
|
274 mOptionMenuActions.mToolsMessageOutbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Outbox", this, SLOT(toolsMessageOutbox())); |
|
275 |
|
276 mOptionMenuActions.mToolsMemoryInfo = mOptionMenuActions.mToolsMenu->addAction("Memory info", this, SLOT(toolsMemoryInfo())); |
|
277 mOptionMenuActions.mToolsMemoryInfo->setVisible(false); |
|
278 |
|
279 mOptionMenuActions.mToolsSecureBackupMenu = mOptionMenuActions.mToolsMenu->addMenu("Secure backup"); |
|
280 mOptionMenuActions.mToolsSecureBackupMenu->menuAction()->setVisible(false); |
|
281 mOptionMenuActions.mToolsSecureBackStart = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start backup", this, SLOT(toolsSecureBackStart())); |
|
282 mOptionMenuActions.mToolsSecureBackRestore = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start restore", this, SLOT(toolsSecureBackRestore())); |
|
283 mOptionMenuActions.mToolsSecureBackStop = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Stop", this, SLOT(toolsSecureBackStop())); |
|
284 |
|
285 mOptionMenuActions.mToolsSetDebugMask = mOptionMenuActions.mToolsMenu->addAction("Set debug mask", this, SLOT(toolsSetDebugMaskQuestion())); |
|
286 mOptionMenuActions.mToolsShowOpenFilesHere = mOptionMenuActions.mToolsMenu->addAction("Show open files here", this, SLOT(toolsShowOpenFilesHere())); |
|
287 mOptionMenuActions.mToolsShowOpenFilesHere->setVisible(false); |
|
288 } |
|
289 |
|
290 /** |
|
291 Creates Selection mode menu item in option menu |
|
292 */ |
|
293 void FbFileView::createSelectionMenuItem() |
|
294 { |
|
295 if (!mOptionMenuActions.mSelection) { |
|
296 mOptionMenuActions.mSelection = menu()->addAction("Selection mode"); |
|
297 mOptionMenuActions.mSelection->setToolTip("Selection mode"); |
|
298 mOptionMenuActions.mSelection->setCheckable(true); |
|
299 connect(mOptionMenuActions.mSelection, SIGNAL(triggered()), this, SLOT(selectionModeChanged())); |
|
300 } |
|
301 } |
|
302 |
|
303 /** |
|
304 Creates Setting menu item in option menu |
|
305 */ |
|
306 void FbFileView::createSettingsMenuItem() |
|
307 { |
|
308 mOptionMenuActions.mSetting = menu()->addAction("Settings..."); |
|
309 connect(mOptionMenuActions.mSetting, SIGNAL(triggered()), this, SIGNAL(aboutToShowSettingsView())); |
|
310 } |
|
311 |
|
312 |
|
313 /** |
|
314 Creates About menu item in option menu |
|
315 */ |
|
316 void FbFileView::createAboutMenuItem() |
|
317 { |
|
318 // about note |
|
319 mOptionMenuActions.mAbout = menu()->addAction("About"); |
|
320 connect(mOptionMenuActions.mAbout, SIGNAL(triggered()), this, SLOT(about())); |
|
321 } |
|
322 |
|
323 /** |
|
324 Creates Exit menu item in option menu |
|
325 */ |
|
326 void FbFileView::createExitMenuItem() |
|
327 { |
|
328 // application exit |
|
329 mOptionMenuActions.mExit = menu()->addAction("Exit"); |
|
330 connect(mOptionMenuActions.mExit, SIGNAL(triggered()), qApp, SLOT(quit())); |
|
331 } |
|
332 |
|
333 /** |
|
334 update menu: disk admin available only in device root view. edit available only in folder view |
|
335 when file or folder content exist in current folder, or clipboard has copied item. |
|
336 file and view menus updated every time regarding the folder content. |
|
337 tools, settings, about, exit always available. |
|
338 If there's remove and add operations at same time, always remove first |
|
339 to keep to the correct menu items order. |
|
340 */ |
|
341 void FbFileView::updateOptionMenu() |
|
342 { |
|
343 bool isFileItemListEmpty = mFbFileModel->rowCount() == 0; |
|
344 bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); |
|
345 bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); //iModel->FileUtils()->IsCurrentDriveReadOnly(); |
|
346 // bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir(); |
|
347 // bool currentSelected = true; //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex()); |
|
348 bool isAllSelected = mListView->selectionModel()->selection().count() == mFbFileModel->rowCount(); |
|
349 //bool isNoneSelected = mListView->selectionModel()->selection().count() != 0; |
|
350 bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0; |
|
351 bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); |
|
352 bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse(); |
|
353 //bool showSnapShot = false; //iModel->FileUtils()->DriveSnapShotPossible(); |
|
354 |
|
355 bool showEditMenu(true); |
|
356 if (isFileItemListEmpty && isClipBoardEmpty) |
|
357 showEditMenu = false; |
|
358 else |
|
359 showEditMenu = true; |
|
360 |
|
361 mOptionMenuActions.mEditMenu->menuAction()->setVisible(showEditMenu); |
|
362 |
|
363 //mOptionMenuActions.mFileBackMoveUp->setVisible( !isDriveListViewActive); |
|
364 |
|
365 //aMenuPane->SetItemDimmed(EFileBrowserCmdFileView, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory); |
|
366 //aMenuPane->SetItemDimmed(EFileBrowserCmdFileEdit, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory); |
|
367 //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || isCurrentItemDirectory); |
|
368 |
|
369 mOptionMenuActions.mFileNewMenu->menuAction()->setVisible(!isCurrentDriveReadOnly); |
|
370 mOptionMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems/*isSelectionMode*/); |
|
371 mOptionMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems /*&& !isSelectionMode*/); |
|
372 mOptionMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems); |
|
373 |
|
374 mOptionMenuActions.mFileSetAttributes->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems); |
|
375 // TODO mOptionMenuActions.mFileCompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory)); |
|
376 // TODO mOptionMenuActions.mFileDecompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory)); |
|
377 |
|
378 mOptionMenuActions.mEditMenu->menuAction()->setVisible( (!isSelectionMode && !isClipBoardEmpty && !isCurrentDriveReadOnly) |
|
379 || (isSelectionMode)); |
|
380 mOptionMenuActions.mEditCut->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && isSelectionMode && hasSelectedItems); |
|
381 mOptionMenuActions.mEditCopy->setVisible(!isFileItemListEmpty && isSelectionMode && hasSelectedItems); |
|
382 mOptionMenuActions.mEditPaste->setVisible(!isClipBoardEmpty && !isCurrentDriveReadOnly); |
|
383 mOptionMenuActions.mEditCopyToFolder->setVisible(!isFileItemListEmpty && isSelectionMode && hasSelectedItems); |
|
384 mOptionMenuActions.mEditMoveToFolder->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && isSelectionMode && hasSelectedItems); |
|
385 |
|
386 mOptionMenuActions.mEditSelect->setVisible(false/*!currentSelected && !isFileItemListEmpty*/); |
|
387 mOptionMenuActions.mEditUnselect->setVisible(false/*currentSelected && !isFileItemListEmpty*/); |
|
388 mOptionMenuActions.mEditSelectAll->setVisible(!isFileItemListEmpty && isSelectionMode && !isAllSelected); |
|
389 mOptionMenuActions.mEditUnselectAll->setVisible(!isFileItemListEmpty && hasSelectedItems); |
|
390 |
|
391 // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isFileItemListEmpty)); |
|
392 // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive || isFileItemListEmpty)); |
|
393 mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive); |
|
394 mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty); |
|
395 |
|
396 // TODO R_FILEBROWSER_VIEW_SORT_SUBMENU |
|
397 // aMenuPane->SetItemButtonState(iModel->FileUtils()->SortMode(), EEikMenuItemSymbolOn); |
|
398 |
|
399 // TODO R_FILEBROWSER_VIEW_ORDER_SUBMENU |
|
400 // aMenuPane->SetItemButtonState(iModel->FileUtils()->OrderMode(), EEikMenuItemSymbolOn); |
|
401 |
|
402 // aResourceId == R_FILEBROWSER_TOOLS_SUBMENU |
|
403 bool noExtendedErrorsAllowed = mEngineWrapper->ErrRdFileExists(); |
|
404 mOptionMenuActions.mToolsDisableExtendedErrors->setVisible(noExtendedErrorsAllowed); |
|
405 mOptionMenuActions.mToolsEnableExtendedErrors->setVisible(!noExtendedErrorsAllowed); |
|
406 |
|
407 // bool infraRedAllowed = mEngineWrapper->FileExists(KIRAppPath); |
|
408 // bool bluetoothAllowed = mEngineWrapper->FileExists(KBTAppPath); |
|
409 // bool usbAllowed = mEngineWrapper->FileExists(KUSBAppPath); |
|
410 // |
|
411 // bool noLocalCon = !infraRedAllowed && !bluetoothAllowed && !usbAllowed; |
|
412 // mOptionMenuActions.mToolsLocalConnectivityMenu->menuAction()->setVisible(!noLocalCon); |
|
413 // |
|
414 // mOptionMenuActions.mToolsLocalConnectivityActivateInfrared->setVisible(infraRedAllowed); |
|
415 // mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI->setVisible(bluetoothAllowed); |
|
416 // mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI->setVisible(usbAllowed); |
|
417 } |
|
418 |
|
419 void FbFileView::createContextMenu() |
|
420 { |
|
421 mContextMenu = new HbMenu(); |
|
422 connect(mContextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu())); |
|
423 |
|
424 createFileContextMenu(); |
|
425 createEditContextMenu(); |
|
426 createViewContextMenu(); |
|
427 } |
|
428 |
|
429 |
|
430 void FbFileView::createFileContextMenu() |
|
431 { |
|
432 mContextMenuActions.mFileMenu = mContextMenu->addMenu("File"); |
|
433 |
|
434 //mContextMenuActions.mFileBackMoveUp = mContextMenuActions.mFileMenu->addAction("Back/Move up (<-)", this, SLOT(fileBackMoveUp())); |
|
435 // mContextMenuActions.mFileOpenDirectory = mContextMenuActions.mFileMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory())); |
|
436 mContextMenuActions.mFileOpenDirectory = mContextMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory())); |
|
437 mContextMenuActions.mSearch = mContextMenu->addAction("Search...", this, SLOT(fileSearch())); |
|
438 mContextMenuActions.mFileSearch = mContextMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); |
|
439 |
|
440 mContextMenuActions.mFileDelete = mContextMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete())); |
|
441 mContextMenuActions.mFileRename = mContextMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename())); |
|
442 mContextMenuActions.mFileTouch = mContextMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch())); |
|
443 mContextMenuActions.mFileProperties = mContextMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties())); |
|
444 |
|
445 mContextMenuActions.mFileChecksumsMenu = mContextMenuActions.mFileMenu->addMenu("Checksums"); |
|
446 mContextMenuActions.mFileChecksumsMD5 = mContextMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5())); |
|
447 mContextMenuActions.mFileChecksumsMD2 = mContextMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2())); |
|
448 mContextMenuActions.mFileChecksumsSHA1 = mContextMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1())); |
|
449 |
|
450 mContextMenuActions.mFileSetAttributes = mContextMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); |
|
451 } |
|
452 |
|
453 void FbFileView::createEditContextMenu() |
|
454 { |
|
455 mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit"); |
|
456 |
|
457 //mContextMenuActions.mEditSnapShotToE = mContextMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); |
|
458 // mContextMenuActions.mEditSnapShotToE->setVisible(false); |
|
459 mContextMenuActions.mEditCut = mContextMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); |
|
460 mContextMenuActions.mEditCopy = mContextMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); |
|
461 mContextMenuActions.mEditPaste = mContextMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); |
|
462 |
|
463 mContextMenuActions.mEditCopyToFolder = mContextMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); |
|
464 mContextMenuActions.mEditMoveToFolder = mContextMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); |
|
465 } |
|
466 |
|
467 void FbFileView::createViewContextMenu() |
|
468 { |
|
469 |
|
470 } |
|
471 |
|
472 void FbFileView::updateContextMenu() |
|
473 { |
|
474 bool isFileItemListEmpty = mFbFileModel->rowCount() == 0; |
|
475 // bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); |
|
476 bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); |
|
477 bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir(); |
|
478 bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0; |
|
479 bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); |
|
480 bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse(); |
|
481 |
|
482 mContextMenuActions.mFileOpenDirectory->setVisible(!isFileItemListEmpty && isCurrentItemDirectory && isSelectionMode); |
|
483 mContextMenuActions.mSearch->setVisible(!isFileItemListEmpty && isSelectionMode && isCurrentItemDirectory); |
|
484 mContextMenuActions.mFileSearch->setVisible(!isFileItemListEmpty && !isSelectionMode && isCurrentItemDirectory); |
|
485 // File submenu |
|
486 //mContextMenuActions.mFileBackMoveUp->setVisible(); |
|
487 mContextMenuActions.mFileMenu->menuAction()->setVisible(!isSelectionMode); |
|
488 |
|
489 mContextMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly); |
|
490 mContextMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && !isSelectionMode); |
|
491 mContextMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly); |
|
492 mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty && !isSelectionMode); |
|
493 |
|
494 mContextMenuActions.mFileChecksumsMenu->menuAction()->setVisible(!isFileItemListEmpty && !isSelectionMode && !isCurrentItemDirectory); |
|
495 |
|
496 // Edit submenu |
|
497 mContextMenuActions.mEditMenu->menuAction()->setVisible(!isSelectionMode); |
|
498 mContextMenuActions.mEditCut->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty)); |
|
499 mContextMenuActions.mEditCopy->setVisible(!(isFileItemListEmpty)); |
|
500 mContextMenuActions.mEditPaste->setVisible(!isClipBoardEmpty && !isCurrentDriveReadOnly); |
|
501 mContextMenuActions.mEditCopyToFolder->setVisible(!isFileItemListEmpty); |
|
502 mContextMenuActions.mEditMoveToFolder->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty)); |
|
503 } |
|
504 |
|
505 // --------------------------------------------------------------------------- |
|
506 |
|
507 void FbFileView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords) |
|
508 { |
|
509 QModelIndex proxyIndex = listViewItem->modelIndex(); |
|
510 //map to source model |
|
511 mCurrentIndex = mSortFilterProxyModel->mapToSource(proxyIndex); |
|
512 |
|
513 mContextMenu->setPreferredPos(coords); |
|
514 mContextMenu->show(); |
|
515 } |
|
516 |
|
517 /** |
|
518 Create a file browser tool bar |
|
519 */ |
|
520 void FbFileView::createToolBar() |
|
521 { |
|
522 mToolBar = toolBar(); |
|
523 |
|
524 mToolbarBackAction = new HbAction(mToolBar); |
|
525 mToolbarBackAction->setToolTip("Back"); |
|
526 mToolbarBackAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_folder_parent.svg"))); |
|
527 connect(mToolbarBackAction, SIGNAL(triggered()), this, SLOT(fileBackMoveUp())); |
|
528 mToolBar->addAction(mToolbarBackAction); |
|
529 |
|
530 // Find button and its extension |
|
531 HbToolBarExtension* filterExtension = new HbToolBarExtension(); |
|
532 // Set search panel widget |
|
533 mSearchPanel = new HbSearchPanel(filterExtension); |
|
534 mSearchPanel->setMinimumWidth( 360 ); // TODO should be based on layout, screen width |
|
535 connect(mSearchPanel, SIGNAL(criteriaChanged(const QString &)), this, SLOT(filterCriteriaChanged(const QString &))); |
|
536 connect(mSearchPanel, SIGNAL(exitClicked()), filterExtension, SLOT(close())); |
|
537 connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(clearFilterCriteria())); |
|
538 filterExtension->setContentWidget(mSearchPanel); |
|
539 |
|
540 mToolbarFilterAction = mToolBar->addExtension(filterExtension); |
|
541 mToolbarFilterAction->setToolTip("Filter"); |
|
542 mToolbarFilterAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_find.svg"))); |
|
543 //connect(mToolbarFilterAction, SIGNAL(triggered()), this, SLOT(viewFilterEntries())); |
|
544 |
|
545 if (mOptionMenuActions.mSelection) { |
|
546 // TODO Selection mode icon to be added |
|
547 //mOptionMenuActions.mSelection->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_selection_active.svg"))); |
|
548 mToolBar->addAction(mOptionMenuActions.mSelection); |
|
549 } |
|
550 |
|
551 mToolbarPasteAction = new HbAction(mToolBar); |
|
552 mToolbarPasteAction->setText("Paste"); |
|
553 mToolbarPasteAction->setToolTip("Paste"); |
|
554 // TODO Paste icon to be added |
|
555 //mToolbarPasteAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_folder_parent.svg"))); |
|
556 connect(mToolbarPasteAction, SIGNAL(triggered()), this, SLOT(editPaste())); |
|
557 mToolBar->addAction(mToolbarPasteAction); |
|
558 mToolbarPasteAction->setEnabled(false); |
|
559 } |
|
560 |
|
561 /** |
|
562 Refresh FileBrowser view |
|
563 */ |
|
564 void FbFileView::refreshList() |
|
565 { |
|
566 editUnselectAll(); |
|
567 mEngineWrapper->refreshView(); |
|
568 mSearchPanel->setCriteria(QString("")); |
|
569 mListView->reset(); |
|
570 |
|
571 if (mListView->model() && mListView->model()->rowCount() > 0) { |
|
572 QModelIndex firstIndex = mListView->model()->index(0, 0); |
|
573 mListView->scrollTo(firstIndex); |
|
574 } |
|
575 |
|
576 mToolbarPasteAction->setEnabled(mEngineWrapper->isClipBoardListInUse()); |
|
577 |
|
578 TListingMode listingMode = mEngineWrapper->listingMode(); |
|
579 if (listingMode == ENormalEntries) |
|
580 mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); |
|
581 else if (listingMode == ESearchResults) |
|
582 mNaviPane->setPlainText(QString(tr("Search results"))); |
|
583 else if (listingMode == EOpenFiles) |
|
584 mNaviPane->setPlainText(QString(tr("Open files"))); |
|
585 else if (listingMode == EMsgAttachmentsInbox) |
|
586 mNaviPane->setPlainText(QString(tr("Attachments in Inbox"))); |
|
587 else if (listingMode == EMsgAttachmentsDrafts) |
|
588 mNaviPane->setPlainText(QString(tr("Attachments in Drafts"))); |
|
589 else if (listingMode == EMsgAttachmentsSentItems) |
|
590 mNaviPane->setPlainText(QString(tr("Attachments in Sent Items"))); |
|
591 else if (listingMode == EMsgAttachmentsOutbox) |
|
592 mNaviPane->setPlainText(QString(tr("Attachments in Outbox"))); |
|
593 } |
|
594 |
|
595 // --------------------------------------------------------------------------- |
|
596 |
|
597 void FbFileView::fileOpen(HbAction *action) |
|
598 { |
|
599 // Q_UNUSED(action); |
|
600 HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender()); |
|
601 if(!action && dlg && dlg->selectedItems().count()){ |
|
602 int selectionIndex = dlg->selectedItems().at(0).toInt(); |
|
603 |
|
604 if (selectionIndex == 0) { |
|
605 // open editor view |
|
606 emit aboutToShowEditorView(mAbsoluteFilePath, true); |
|
607 } else if (selectionIndex == 1) { |
|
608 // AppArc |
|
609 mEngineWrapper->openAppArc(mAbsoluteFilePath); |
|
610 } else { |
|
611 // DocHandler |
|
612 mEngineWrapper->openDocHandler(mAbsoluteFilePath, true); |
|
613 } |
|
614 } |
|
615 } |
|
616 |
|
617 /** |
|
618 Open overwrite dialog |
|
619 */ |
|
620 void FbFileView::fileOverwriteDialog() |
|
621 { |
|
622 mOverwriteOptions = OverwriteOptions(); |
|
623 // open user-dialog to select: view as text/hex, open w/AppArc or open w/DocH. embed |
|
624 QStringList list; |
|
625 list << QString("Overwrite all") |
|
626 << QString("Skip all existing") |
|
627 << QString("Gen. unique filenames") |
|
628 << QString("Query postfix"); |
|
629 openListDialog(list, QString("Overwrite?"), this, SLOT(fileOverwrite(HbAction *))); |
|
630 } |
|
631 |
|
632 /** |
|
633 File overwrite |
|
634 */ |
|
635 void FbFileView::fileOverwrite(HbAction *action) |
|
636 { |
|
637 HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender()); |
|
638 if(!action && dlg && dlg->selectedItems().count()) { |
|
639 mOverwriteOptions.queryIndex = dlg->selectedItems().at(0).toInt(); |
|
640 if (mOverwriteOptions.queryIndex == EFileActionQueryPostFix) { |
|
641 QString heading = QString("Postfix"); |
|
642 HbInputDialog::queryText(heading, this, SLOT(fileOverwritePostfix(HbAction *)), QString(), scene()); |
|
643 } else if (mOverwriteOptions.queryIndex == EFileActionSkipAllExisting) { |
|
644 mOverwriteOptions.overWriteFlags = 0; |
|
645 } |
|
646 } else { |
|
647 mOverwriteOptions.doFileOperations = false; |
|
648 } |
|
649 } |
|
650 |
|
651 /** |
|
652 File overwrite postfix query dialog |
|
653 */ |
|
654 void FbFileView::fileOverwritePostfix(HbAction *action) |
|
655 { |
|
656 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
657 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
658 mOverwriteOptions.postFix = dlg->value().toString(); |
|
659 } else { |
|
660 mOverwriteOptions.doFileOperations = false; |
|
661 } |
|
662 } |
|
663 |
|
664 // --------------------------------------------------------------------------- |
|
665 /** |
|
666 Show a list dialog |
|
667 \param List aList of item to select item from. |
|
668 \param Title text titleText of a dialog heading widget |
|
669 \return None |
|
670 */ |
|
671 void FbFileView::openListDialog(const QStringList& items, const QString &titleText, QObject* receiver, const char* member) |
|
672 { |
|
673 // Create a list and some simple content for it |
|
674 HbSelectionDialog *dlg = new HbSelectionDialog(); |
|
675 dlg->setAttribute(Qt::WA_DeleteOnClose); |
|
676 // Set items to be popup's content |
|
677 dlg->setStringItems(items); |
|
678 dlg->setSelectionMode(HbAbstractItemView::SingleSelection); |
|
679 |
|
680 HbLabel *title = new HbLabel(dlg); |
|
681 title->setPlainText(titleText); |
|
682 dlg->setHeadingWidget(title); |
|
683 |
|
684 // Launch popup and handle the user response: |
|
685 dlg->open(receiver, member); |
|
686 } |
|
687 |
|
688 // --------------------------------------------------------------------------- |
|
689 |
|
690 void FbFileView::openPropertyDialog(const QStringList& propertyList, const QString& title) |
|
691 { |
|
692 HbDialog *dialog = new HbDialog(); |
|
693 dialog->setDismissPolicy(HbPopup::TapOutside); |
|
694 dialog->setTimeout(HbPopup::NoTimeout); |
|
695 |
|
696 HbLabel *titleWidget = new HbLabel(); |
|
697 titleWidget->setPlainText(title); |
|
698 dialog->setHeadingWidget(titleWidget); |
|
699 |
|
700 // Create a list and some simple content for it |
|
701 HbListWidget *list = new HbListWidget(); |
|
702 QString str; |
|
703 foreach (str, propertyList) { |
|
704 list->addItem(str); |
|
705 } |
|
706 |
|
707 // Connect list item activation signal to close the popup |
|
708 connect(list, SIGNAL(activated(HbListWidgetItem*)), dialog, SLOT(close())); |
|
709 |
|
710 HbAction *cancelAction = new HbAction("Close"); |
|
711 dialog->setPrimaryAction(cancelAction); |
|
712 |
|
713 // Set listwidget to be popup's content |
|
714 dialog->setContentWidget(list); |
|
715 // Launch popup and handle the user response: |
|
716 dialog->open(); |
|
717 } |
|
718 |
|
719 /** |
|
720 Stores selection or current index mapped to source model |
|
721 */ |
|
722 void FbFileView::storeSelectedItemsOrCurrentItem() |
|
723 { |
|
724 QItemSelectionModel *selectionIndexes = mListView->selectionModel(); |
|
725 |
|
726 // by default use selected items |
|
727 if (selectionIndexes) { |
|
728 bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); |
|
729 if (isSelectionMode) { |
|
730 if (selectionIndexes->hasSelection()) { |
|
731 QItemSelection proxyItemSelection = mListView->selectionModel()->selection(); |
|
732 QItemSelection itemSelection = mSortFilterProxyModel->mapSelectionToSource(proxyItemSelection); |
|
733 mSelectionIndexes = itemSelection.indexes(); |
|
734 } else { // or if none selected, clear selection |
|
735 mSelectionIndexes.clear(); |
|
736 } |
|
737 } else { // or if none selected, use the current item index |
|
738 mSelectionIndexes.clear(); |
|
739 QModelIndex currentIndex = currentItemIndex(); //alreade mapped to source model |
|
740 mSelectionIndexes.append(currentIndex); |
|
741 } |
|
742 } |
|
743 } |
|
744 |
|
745 // --------------------------------------------------------------------------- |
|
746 |
|
747 QModelIndex FbFileView::currentItemIndex() |
|
748 { |
|
749 return mCurrentIndex; |
|
750 } |
|
751 |
|
752 // --------------------------------------------------------------------------- |
|
753 // operations in File Menu |
|
754 // --------------------------------------------------------------------------- |
|
755 |
|
756 /** |
|
757 Move back/up in folder browsing history |
|
758 */ |
|
759 void FbFileView::fileBackMoveUp() |
|
760 { |
|
761 mLocationChanged = true; |
|
762 mEngineWrapper->moveUpOneLevel(); |
|
763 //mListView->setRootIndex(currentItemIndex()); |
|
764 refreshList(); |
|
765 if (mEngineWrapper->isDriveListViewActive()) { |
|
766 emit aboutToShowDriveView(); |
|
767 } |
|
768 } |
|
769 |
|
770 void FbFileView::fileOpenDirectory() |
|
771 { |
|
772 mLocationChanged = true; |
|
773 // get selected drive or directory from list view model and open it: |
|
774 //if (mListView->selectionModel()->hasSelection()) { |
|
775 // if (mListView->selectionModel()->selection().count() != 0) { |
|
776 // QModelIndex currentIndex = currentItemIndex(); |
|
777 mEngineWrapper->moveDownToDirectory(currentItemIndex()); |
|
778 // mListView->setRootIndex(currentItemIndex()); |
|
779 refreshList(); |
|
780 // } else { |
|
781 // Notifications::showErrorNote("not selected item!"); |
|
782 // } |
|
783 } |
|
784 |
|
785 void FbFileView::fileSearch() |
|
786 { |
|
787 QString searchPath; |
|
788 HbAction *contextrMenuAction = static_cast<HbAction *>(sender()); |
|
789 if (contextrMenuAction |
|
790 && (contextrMenuAction == mContextMenuActions.mSearch |
|
791 || contextrMenuAction == mContextMenuActions.mFileSearch) |
|
792 && mEngineWrapper->getFileEntry(currentItemIndex()).isDir()) { |
|
793 searchPath = mEngineWrapper->currentPath() |
|
794 + mEngineWrapper->getFileEntry(currentItemIndex()).name() |
|
795 + QString("\\"); |
|
796 } else { |
|
797 searchPath = mEngineWrapper->currentPath(); |
|
798 } |
|
799 |
|
800 emit aboutToShowSearchView(searchPath); |
|
801 } |
|
802 |
|
803 /** |
|
804 Open new file dialog |
|
805 */ |
|
806 void FbFileView::fileNewFile() |
|
807 { |
|
808 QString heading = QString("Enter filename"); |
|
809 HbInputDialog::queryText(heading, this, SLOT(doFileNewFile(HbAction*)), QString(), scene()); |
|
810 } |
|
811 |
|
812 /** |
|
813 Create a new file in current directory with a name queried from user |
|
814 */ |
|
815 void FbFileView::doFileNewFile(HbAction *action) |
|
816 { |
|
817 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
818 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
819 QString newFileName = dlg->value().toString(); |
|
820 mEngineWrapper->createNewFile(newFileName); |
|
821 refreshList(); |
|
822 } |
|
823 } |
|
824 |
|
825 /** |
|
826 Open new directory dialog |
|
827 */ |
|
828 void FbFileView::fileNewDirectory() |
|
829 { |
|
830 QString heading = QString("Enter directory name"); |
|
831 HbInputDialog::queryText(heading, this, SLOT(doFileNewDirectory(HbAction*)), QString(), scene()); |
|
832 } |
|
833 |
|
834 /** |
|
835 Create a new directory in current directory with a name queried from user |
|
836 */ |
|
837 void FbFileView::doFileNewDirectory(HbAction *action) |
|
838 { |
|
839 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
840 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
841 QString newDirectoryName = dlg->value().toString(); |
|
842 mEngineWrapper->createNewDirectory(newDirectoryName); |
|
843 refreshList(); |
|
844 } |
|
845 } |
|
846 |
|
847 /** |
|
848 Question for Delete actually selected files |
|
849 */ |
|
850 void FbFileView::fileDelete() |
|
851 { |
|
852 storeSelectedItemsOrCurrentItem(); |
|
853 const QString messageFormat = "Delete %1 entries?"; |
|
854 QString message = messageFormat.arg(mSelectionIndexes.count()); |
|
855 HbMessageBox::question(message, this, SLOT(doFileDelete(int)), HbMessageBox::Yes | HbMessageBox::No); |
|
856 } |
|
857 |
|
858 /** |
|
859 Delete actually selected files |
|
860 */ |
|
861 void FbFileView::doFileDelete(int action) |
|
862 { |
|
863 if (action == HbMessageBox::Yes) { |
|
864 mEngineWrapper->deleteItems(mSelectionIndexes); |
|
865 mEngineWrapper->startExecutingCommands(QString("Deleting")); |
|
866 } |
|
867 } |
|
868 |
|
869 /** |
|
870 Open rename dialog for actually selected files |
|
871 */ |
|
872 void FbFileView::fileRename() |
|
873 { |
|
874 storeSelectedItemsOrCurrentItem(); |
|
875 mEngineWrapper->setCurrentSelection(mSelectionIndexes); |
|
876 |
|
877 for (int i(0), ie(mSelectionIndexes.count()); i < ie; ++i ) { |
|
878 mProceed = (i == ie-1); // if the last item |
|
879 mModelIndex = mSelectionIndexes.at(i); |
|
880 FbFileEntry entry = mEngineWrapper->getFileEntry(mModelIndex); |
|
881 |
|
882 QString heading = QString("Enter new name"); |
|
883 HbInputDialog::queryText(heading, this, SLOT(doFileRename(HbAction*)), entry.name(), scene()); |
|
884 } |
|
885 } |
|
886 |
|
887 /** |
|
888 Rename actually selected files |
|
889 */ |
|
890 void FbFileView::doFileRename(HbAction *action) |
|
891 { |
|
892 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
893 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
894 mNewFileName = dlg->value().toString(); |
|
895 |
|
896 if (mEngineWrapper->targetExists(mModelIndex, mNewFileName)) { |
|
897 const QString messageTemplate = QString("%1 already exists, overwrite?"); |
|
898 QString message = messageTemplate.arg(mNewFileName); |
|
899 HbMessageBox::question(message, this, SLOT(doFileRenameFileExist(int)), HbMessageBox::Yes | HbMessageBox::No); |
|
900 } else { |
|
901 proceedFileRename(); |
|
902 } |
|
903 } |
|
904 } |
|
905 |
|
906 /** |
|
907 Rename actually selected files |
|
908 */ |
|
909 void FbFileView::doFileRenameFileExist(int action) |
|
910 { |
|
911 if (action == HbMessageBox::Yes) { |
|
912 proceedFileRename(); |
|
913 } |
|
914 } |
|
915 |
|
916 |
|
917 void FbFileView::proceedFileRename() |
|
918 { |
|
919 mEngineWrapper->rename(mModelIndex, mNewFileName); |
|
920 if (mProceed) { |
|
921 mEngineWrapper->startExecutingCommands(QString("Renaming")); |
|
922 refreshList(); |
|
923 } |
|
924 } |
|
925 |
|
926 /** |
|
927 Touch actually selected files |
|
928 */ |
|
929 void FbFileView::fileTouch() |
|
930 { |
|
931 storeSelectedItemsOrCurrentItem(); |
|
932 mEngineWrapper->setCurrentSelection(mSelectionIndexes); |
|
933 |
|
934 if (mEngineWrapper->selectionHasDirs()) { |
|
935 const QString message = "Recurse touch for all selected dirs?"; |
|
936 HbMessageBox::question(message, this, SLOT(doFileTouch(int)), HbMessageBox::Yes | HbMessageBox::No); |
|
937 } else { |
|
938 proceedFileTouch(false); |
|
939 } |
|
940 } |
|
941 |
|
942 /** |
|
943 Touch actually selected files |
|
944 */ |
|
945 void FbFileView::doFileTouch(int action) |
|
946 { |
|
947 bool recurse = false; |
|
948 if (action == HbMessageBox::Yes) { |
|
949 recurse = true; |
|
950 } |
|
951 proceedFileTouch(recurse); |
|
952 } |
|
953 |
|
954 void FbFileView::proceedFileTouch(bool recurse) |
|
955 { |
|
956 mEngineWrapper->touch(recurse); |
|
957 mEngineWrapper->startExecutingCommands(QString("Touching")); |
|
958 refreshList(); |
|
959 } |
|
960 |
|
961 void FbFileView::fileChecksumsMD5() |
|
962 { |
|
963 fileChecksums(EFileChecksumsMD5); |
|
964 } |
|
965 |
|
966 void FbFileView::fileChecksumsMD2() |
|
967 { |
|
968 fileChecksums(EFileChecksumsMD2); |
|
969 } |
|
970 |
|
971 void FbFileView::fileChecksumsSHA1() |
|
972 { |
|
973 fileChecksums(EFileChecksumsSHA1); |
|
974 } |
|
975 |
|
976 void FbFileView::fileChecksums(TFileBrowserCmdFileChecksums checksumType) |
|
977 { |
|
978 mEngineWrapper->showFileCheckSums(currentItemIndex(), checksumType); |
|
979 } |
|
980 |
|
981 /** |
|
982 Show file properties |
|
983 */ |
|
984 void FbFileView::fileProperties() |
|
985 { |
|
986 QModelIndex currentIndex = currentItemIndex(); |
|
987 QStringList propertyList; |
|
988 QString titleText; |
|
989 mEngineWrapper->properties(currentIndex, propertyList, titleText); |
|
990 openPropertyDialog(propertyList, titleText); |
|
991 } |
|
992 |
|
993 void FbFileView::fileSetAttributes() |
|
994 { |
|
995 storeSelectedItemsOrCurrentItem(); |
|
996 mEngineWrapper->setCurrentSelection(mSelectionIndexes); |
|
997 |
|
998 QString attributesViewTitle("Multiple entries"); |
|
999 |
|
1000 quint32 setAttributesMask(0); |
|
1001 quint32 clearAttributesMask(0); |
|
1002 bool recurse(false); |
|
1003 |
|
1004 // set default masks if only one file selected |
|
1005 if (mSelectionIndexes.count() == 1) |
|
1006 { |
|
1007 mModelIndex = mSelectionIndexes.at(0); |
|
1008 FbFileEntry fileEntry = mEngineWrapper->getFileEntry(mModelIndex); |
|
1009 |
|
1010 attributesViewTitle = fileEntry.name(); |
|
1011 |
|
1012 if (fileEntry.isArchive()) |
|
1013 setAttributesMask |= KEntryAttArchive; |
|
1014 else |
|
1015 clearAttributesMask |= KEntryAttArchive; |
|
1016 |
|
1017 if (fileEntry.isHidden()) |
|
1018 setAttributesMask |= KEntryAttHidden; |
|
1019 else |
|
1020 clearAttributesMask |= KEntryAttHidden; |
|
1021 |
|
1022 if (fileEntry.isReadOnly()) |
|
1023 setAttributesMask |= KEntryAttReadOnly; |
|
1024 else |
|
1025 clearAttributesMask |= KEntryAttReadOnly; |
|
1026 |
|
1027 if (fileEntry.isSystem()) |
|
1028 setAttributesMask |= KEntryAttSystem; |
|
1029 else |
|
1030 clearAttributesMask |= KEntryAttSystem; |
|
1031 } |
|
1032 |
|
1033 emit aboutToShowAttributesView(attributesViewTitle, setAttributesMask, clearAttributesMask, recurse); |
|
1034 } |
|
1035 |
|
1036 // edit menu |
|
1037 void FbFileView::editSnapShotToE() |
|
1038 { |
|
1039 |
|
1040 } |
|
1041 |
|
1042 /** |
|
1043 Set selected files into clipboard. |
|
1044 Selected item will be removed after paste operation. |
|
1045 */ |
|
1046 void FbFileView::editCut() |
|
1047 { |
|
1048 storeSelectedItemsOrCurrentItem(); |
|
1049 |
|
1050 // Store indices to clipboard |
|
1051 mClipboardIndexes.clear(); |
|
1052 for (int i = 0; i < mSelectionIndexes.size(); ++i) { |
|
1053 mClipboardIndexes.append(mSelectionIndexes.at(i)); |
|
1054 } |
|
1055 |
|
1056 mEngineWrapper->clipboardCut(mClipboardIndexes); |
|
1057 mEngineWrapper->setCurrentSelection(mClipboardIndexes); |
|
1058 |
|
1059 int operations = mClipboardIndexes.count(); |
|
1060 const QString message = QString ("%1 entries cut to clipboard"); |
|
1061 QString noteMsg = message.arg(operations); |
|
1062 |
|
1063 mToolbarPasteAction->setEnabled(true); |
|
1064 Notifications::showInformationNote(noteMsg); |
|
1065 } |
|
1066 |
|
1067 /** |
|
1068 Set selected files into clipboard. |
|
1069 Selected item will not be removed after paste operation. |
|
1070 */ |
|
1071 void FbFileView::editCopy() |
|
1072 { |
|
1073 storeSelectedItemsOrCurrentItem(); |
|
1074 |
|
1075 // Store indices to clipboard |
|
1076 mClipboardIndexes.clear(); |
|
1077 for (int i = 0; i < mSelectionIndexes.size(); ++i) { |
|
1078 mClipboardIndexes.append(mSelectionIndexes.at(i)); |
|
1079 } |
|
1080 |
|
1081 mEngineWrapper->clipboardCopy(mClipboardIndexes); |
|
1082 mEngineWrapper->setCurrentSelection(mClipboardIndexes); |
|
1083 |
|
1084 int operations = mClipboardIndexes.count(); |
|
1085 |
|
1086 const QString message = QString ("%1 entries copied to clipboard"); |
|
1087 QString noteMsg = message.arg(operations); |
|
1088 |
|
1089 mToolbarPasteAction->setEnabled(true); |
|
1090 Notifications::showInformationNote(noteMsg); |
|
1091 } |
|
1092 |
|
1093 /** |
|
1094 Moves or copies file selection stored in clipboard to a actual directory. |
|
1095 Removing files depend on previous operation, i.e. Cut or Copy |
|
1096 */ |
|
1097 void FbFileView::editPaste() |
|
1098 { |
|
1099 bool someEntryExists(false); |
|
1100 |
|
1101 someEntryExists = mEngineWrapper->isDestinationEntriesExists(mClipboardIndexes, mEngineWrapper->currentPath()); |
|
1102 if (someEntryExists) { |
|
1103 fileOverwriteDialog(); |
|
1104 } |
|
1105 |
|
1106 mEngineWrapper->clipboardPaste(mOverwriteOptions); |
|
1107 mEngineWrapper->startExecutingCommands(mEngineWrapper->getClipBoardMode() == EClipBoardModeCut ? |
|
1108 QString("Moving") : QString("Copying") ); |
|
1109 } |
|
1110 |
|
1111 /** |
|
1112 Open copy to folder new filename dialog |
|
1113 */ |
|
1114 void FbFileView::editCopyToFolder() |
|
1115 { |
|
1116 QString heading = QString("Enter new name"); |
|
1117 FbCopyToFolderSelectionDialog *folderSelectionDialog = new FbCopyToFolderSelectionDialog(); |
|
1118 folderSelectionDialog->open(this, SLOT(doEditCopyToFolder(int))); |
|
1119 } |
|
1120 |
|
1121 /** |
|
1122 Copies current file selection to a queried directory. |
|
1123 */ |
|
1124 void FbFileView::doEditCopyToFolder(int action) |
|
1125 { |
|
1126 FbCopyToFolderSelectionDialog *dlg = qobject_cast<FbCopyToFolderSelectionDialog*>(sender()); |
|
1127 if (dlg && action == HbDialog::Accepted) { |
|
1128 QString targetDir = dlg->selectedFolder(); |
|
1129 |
|
1130 bool someEntryExists(false); |
|
1131 |
|
1132 // TODO Set entry items here |
|
1133 storeSelectedItemsOrCurrentItem(); |
|
1134 mEngineWrapper->setCurrentSelection(mSelectionIndexes); |
|
1135 |
|
1136 someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir); |
|
1137 if (someEntryExists) { |
|
1138 fileOverwriteDialog(); |
|
1139 } |
|
1140 mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, false); |
|
1141 mEngineWrapper->startExecutingCommands(QString("Copying")); |
|
1142 } |
|
1143 } |
|
1144 |
|
1145 /** |
|
1146 Open move to folder new filename dialog. |
|
1147 */ |
|
1148 void FbFileView::editMoveToFolder() |
|
1149 { |
|
1150 QString heading = QString("Enter new name"); |
|
1151 FbMoveToFolderSelectionDialog *folderSelectionDialog = new FbMoveToFolderSelectionDialog(); |
|
1152 folderSelectionDialog->open(this, SLOT(doEditMoveToFolder(int))); |
|
1153 } |
|
1154 |
|
1155 /** |
|
1156 Moves current file selection to a queried directory. |
|
1157 */ |
|
1158 void FbFileView::doEditMoveToFolder(int action) |
|
1159 { |
|
1160 FbMoveToFolderSelectionDialog *dlg = qobject_cast<FbMoveToFolderSelectionDialog*>(sender()); |
|
1161 if (dlg && action == HbDialog::Accepted) { |
|
1162 QString targetDir = dlg->selectedFolder(); |
|
1163 |
|
1164 bool someEntryExists(false); |
|
1165 |
|
1166 // TODO Set entry items here |
|
1167 storeSelectedItemsOrCurrentItem(); |
|
1168 mEngineWrapper->setCurrentSelection(mSelectionIndexes); |
|
1169 |
|
1170 someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir); |
|
1171 if (someEntryExists) { |
|
1172 fileOverwriteDialog(); |
|
1173 } |
|
1174 mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, true); |
|
1175 mEngineWrapper->startExecutingCommands(QString("Moving")); |
|
1176 } |
|
1177 } |
|
1178 |
|
1179 /** |
|
1180 Select current file |
|
1181 */ |
|
1182 void FbFileView::editSelect() |
|
1183 { |
|
1184 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
|
1185 if (selectionModel) { |
|
1186 selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::SelectCurrent); |
|
1187 selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Select); |
|
1188 refreshList(); |
|
1189 } |
|
1190 } |
|
1191 |
|
1192 /** |
|
1193 Unselect current file |
|
1194 */ |
|
1195 void FbFileView::editUnselect() |
|
1196 { |
|
1197 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
|
1198 if (selectionModel) { |
|
1199 selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Deselect); |
|
1200 // itemHighlighted(selectionModel->currentIndex()); |
|
1201 } |
|
1202 } |
|
1203 |
|
1204 /** |
|
1205 Select all files |
|
1206 */ |
|
1207 void FbFileView::editSelectAll() |
|
1208 { |
|
1209 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
|
1210 if (selectionModel) { |
|
1211 |
|
1212 //if (mFileBrowserModel->rowCount() > 0) { |
|
1213 if (mListView->model() && mListView->model()->rowCount() > 0) { |
|
1214 QModelIndex firstIndex = mListView->model()->index(0, 0); |
|
1215 QModelIndex lastIndex = mListView->model()->index( (mListView->model()->rowCount() - 1), 0); |
|
1216 |
|
1217 QItemSelection itemSelection(firstIndex, lastIndex); |
|
1218 selectionModel->select(itemSelection, QItemSelectionModel::SelectCurrent); |
|
1219 } |
|
1220 } |
|
1221 } |
|
1222 |
|
1223 /** |
|
1224 Unselect all files |
|
1225 */ |
|
1226 void FbFileView::editUnselectAll() |
|
1227 { |
|
1228 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
|
1229 if (selectionModel) { |
|
1230 selectionModel->clearSelection(); |
|
1231 } |
|
1232 } |
|
1233 |
|
1234 // --------------------------------------------------------------------------- |
|
1235 // view menu |
|
1236 // --------------------------------------------------------------------------- |
|
1237 void FbFileView::viewFilterEntries() |
|
1238 { |
|
1239 if (mToolBar && mToolBar->actions().count() > 1 && mToolBar->actions().at(1)) { |
|
1240 if (mToolbarFilterAction && mToolbarFilterAction->toolBarExtension()) { |
|
1241 HbToolBarExtension *tbeFilter = mToolbarFilterAction->toolBarExtension(); |
|
1242 tbeFilter->open(); |
|
1243 } |
|
1244 } |
|
1245 } |
|
1246 |
|
1247 /** |
|
1248 Set filter criteria to proxy model |
|
1249 */ |
|
1250 void FbFileView::filterCriteriaChanged(const QString &criteria) |
|
1251 { |
|
1252 mSortFilterProxyModel->setFilterCriteria(criteria); |
|
1253 } |
|
1254 |
|
1255 /** |
|
1256 Set filter criteria to proxy model |
|
1257 */ |
|
1258 void FbFileView::clearFilterCriteria() |
|
1259 { |
|
1260 mSearchPanel->setCriteria(QString("")); |
|
1261 } |
|
1262 |
|
1263 /** |
|
1264 Refresh view |
|
1265 */ |
|
1266 void FbFileView::viewRefresh() |
|
1267 { |
|
1268 refreshList(); |
|
1269 } |
|
1270 |
|
1271 // --------------------------------------------------------------------------- |
|
1272 // tools menu |
|
1273 // --------------------------------------------------------------------------- |
|
1274 void FbFileView::toolsAllAppsToTextFile() |
|
1275 { |
|
1276 |
|
1277 } |
|
1278 |
|
1279 /** |
|
1280 Write all files to text file |
|
1281 */ |
|
1282 void FbFileView::toolsAllFilesToTextFile() |
|
1283 { |
|
1284 mEngineWrapper->toolsWriteAllFiles(); |
|
1285 } |
|
1286 |
|
1287 //void FbFileView::toolsAvkonIconCacheEnable() |
|
1288 //{ |
|
1289 // |
|
1290 //} |
|
1291 //void FbFileView::toolsAvkonIconCacheDisable() |
|
1292 //{ |
|
1293 // |
|
1294 //} |
|
1295 |
|
1296 /** |
|
1297 Disable extended errors |
|
1298 */ |
|
1299 void FbFileView::toolsDisableExtendedErrors() |
|
1300 { |
|
1301 mEngineWrapper->ToolsSetErrRd(false); |
|
1302 } |
|
1303 |
|
1304 void FbFileView::toolsDumpMsgStoreWalk() |
|
1305 { |
|
1306 |
|
1307 } |
|
1308 void FbFileView::toolsEditDataTypes() |
|
1309 { |
|
1310 |
|
1311 } |
|
1312 |
|
1313 /** |
|
1314 Enable extended errors |
|
1315 */ |
|
1316 void FbFileView::toolsEnableExtendedErrors() |
|
1317 { |
|
1318 mEngineWrapper->ToolsSetErrRd(true); |
|
1319 } |
|
1320 |
|
1321 /** |
|
1322 Open simulate leave dialog |
|
1323 */ |
|
1324 void FbFileView::toolsErrorSimulateLeave() |
|
1325 { |
|
1326 int leaveCode = -6; |
|
1327 QString heading = QString("Leave code"); |
|
1328 //HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), leaveCode, scene()); |
|
1329 HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene()); |
|
1330 } |
|
1331 |
|
1332 |
|
1333 /** |
|
1334 Simulate leave. |
|
1335 */ |
|
1336 void FbFileView::doToolsErrorSimulateLeave(HbAction *action) |
|
1337 { |
|
1338 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
1339 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
1340 bool ok; |
|
1341 int leaveCode = dlg->value().toString().toInt(&ok); |
|
1342 if (leaveCode != 0 || ok) { |
|
1343 mEngineWrapper->ToolsErrorSimulateLeave(leaveCode); |
|
1344 } |
|
1345 } |
|
1346 } |
|
1347 |
|
1348 /** |
|
1349 Open simulate panic dialog. |
|
1350 */ |
|
1351 void FbFileView::toolsErrorSimulatePanic() |
|
1352 { |
|
1353 mPanicCategory = QString ("Test Category"); |
|
1354 QString heading = QString("Panic category"); |
|
1355 HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene()); |
|
1356 } |
|
1357 |
|
1358 /** |
|
1359 Simulate panic. |
|
1360 */ |
|
1361 void FbFileView::doToolsErrorSimulatePanicCode(HbAction *action) |
|
1362 { |
|
1363 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
1364 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
1365 mPanicCategory = dlg->value().toString(); |
|
1366 int panicCode(555); |
|
1367 QString heading = QString("Panic code"); |
|
1368 HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene()); |
|
1369 } |
|
1370 } |
|
1371 |
|
1372 /** |
|
1373 Simulate panic. |
|
1374 */ |
|
1375 void FbFileView::doToolsErrorSimulatePanic(HbAction *action) |
|
1376 { |
|
1377 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
1378 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
1379 bool ok; |
|
1380 int panicCode = dlg->value().toInt(&ok); |
|
1381 if (panicCode != 0 || ok) { |
|
1382 mEngineWrapper->ToolsErrorSimulatePanic(mPanicCategory, panicCode); |
|
1383 } |
|
1384 } |
|
1385 } |
|
1386 |
|
1387 /** |
|
1388 Open simulate exception dialog. |
|
1389 */ |
|
1390 void FbFileView::toolsErrorSimulateException() |
|
1391 { |
|
1392 int exceptionCode = 0; |
|
1393 QString heading = QString("Exception code"); |
|
1394 HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene()); |
|
1395 } |
|
1396 |
|
1397 /** |
|
1398 Simulate exception. |
|
1399 */ |
|
1400 void FbFileView::doToolsErrorSimulateException(HbAction *action) |
|
1401 { |
|
1402 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
1403 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
1404 bool ok; |
|
1405 int exceptionCode = dlg->value().toInt(&ok); |
|
1406 if (exceptionCode != 0 || ok) { |
|
1407 mEngineWrapper->ToolsErrorSimulateException(exceptionCode); |
|
1408 } |
|
1409 } |
|
1410 } |
|
1411 |
|
1412 // void FbFileView::toolsLocalConnectivityActivateInfrared() |
|
1413 //{ |
|
1414 // |
|
1415 //} |
|
1416 // void FbFileView::toolsLocalConnectivityLaunchBTUI() |
|
1417 //{ |
|
1418 // |
|
1419 //} |
|
1420 // void FbFileView::toolsLocalConnectivityLaunchUSBUI() |
|
1421 //{ |
|
1422 // |
|
1423 //} |
|
1424 void FbFileView::toolsMessageInbox() |
|
1425 { |
|
1426 |
|
1427 } |
|
1428 void FbFileView::toolsMessageDrafts() |
|
1429 { |
|
1430 |
|
1431 } |
|
1432 void FbFileView::toolsMessageSentItems() |
|
1433 { |
|
1434 |
|
1435 } |
|
1436 void FbFileView::toolsMessageOutbox() |
|
1437 { |
|
1438 |
|
1439 } |
|
1440 void FbFileView::toolsMemoryInfo() |
|
1441 { |
|
1442 |
|
1443 } |
|
1444 void FbFileView::toolsSecureBackStart() |
|
1445 { |
|
1446 |
|
1447 } |
|
1448 void FbFileView::toolsSecureBackRestore() |
|
1449 { |
|
1450 |
|
1451 } |
|
1452 void FbFileView::toolsSecureBackStop() |
|
1453 { |
|
1454 |
|
1455 } |
|
1456 |
|
1457 /** |
|
1458 Open debug mask dialog |
|
1459 */ |
|
1460 void FbFileView::toolsSetDebugMaskQuestion() |
|
1461 { |
|
1462 quint32 dbgMask = mEngineWrapper->getDebugMask(); |
|
1463 QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16)); |
|
1464 QString heading = QString("Kernel debug mask in hex format"); |
|
1465 HbInputDialog::queryText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene()); |
|
1466 } |
|
1467 |
|
1468 /** |
|
1469 Set debug mask |
|
1470 */ |
|
1471 void FbFileView::toolsSetDebugMask(HbAction *action) |
|
1472 { |
|
1473 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
1474 if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { |
|
1475 QString dbgMaskText = dlg->value().toString(); |
|
1476 if (dbgMaskText.length() > 2 && dbgMaskText[0]=='0' && dbgMaskText[1]=='x') { |
|
1477 bool ok; |
|
1478 quint32 dbgMask = dbgMaskText.toUInt(&ok, 16); |
|
1479 if (dbgMask != 0 || ok) { |
|
1480 mEngineWrapper->toolsSetDebugMask(dbgMask); |
|
1481 Notifications::showConfirmationNote(QString("Changed")); |
|
1482 } else { |
|
1483 Notifications::showErrorNote(QString("Cannot convert value")); |
|
1484 } |
|
1485 } else { |
|
1486 Notifications::showErrorNote(QString("Not in hex format")); |
|
1487 } |
|
1488 } |
|
1489 } |
|
1490 |
|
1491 void FbFileView::toolsShowOpenFilesHere() |
|
1492 { |
|
1493 |
|
1494 } |
|
1495 |
|
1496 // --------------------------------------------------------------------------- |
|
1497 // main menu items |
|
1498 // --------------------------------------------------------------------------- |
|
1499 void FbFileView::selectionModeChanged() |
|
1500 { |
|
1501 if (mOptionMenuActions.mSelection->isChecked()) { |
|
1502 activateSelectionMode(); |
|
1503 } else { |
|
1504 deActivateSelectionMode(); |
|
1505 } |
|
1506 } |
|
1507 |
|
1508 /** |
|
1509 Show about note |
|
1510 */ |
|
1511 void FbFileView::about() |
|
1512 { |
|
1513 Notifications::showAboutNote(); |
|
1514 } |
|
1515 |
|
1516 // --------------------------------------------------------------------------- |
|
1517 // End of operations |
|
1518 // --------------------------------------------------------------------------- |
|
1519 |
|
1520 // --------------------------------------------------------------------------- |
|
1521 |
|
1522 /** |
|
1523 Item is selected from list when selection mode is activated from menu |
|
1524 */ |
|
1525 void FbFileView::selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/) |
|
1526 { |
|
1527 //QItemSelectionModel *selectionModel = mListView->selectionModel(); |
|
1528 //itemHighlighted(selectionModel->currentIndex()); |
|
1529 } |
|
1530 |
|
1531 /** |
|
1532 An item is clicked from navigation item list. Navigation item list contains |
|
1533 drive-, folder- or file items. Opens selected drive, folder or file popup menu |
|
1534 */ |
|
1535 void FbFileView::activated(const QModelIndex& index) |
|
1536 { |
|
1537 if (mFbFileModel) { |
|
1538 //map to source model |
|
1539 QModelIndex activatedIndex = mSortFilterProxyModel->mapToSource(index); |
|
1540 |
|
1541 if (mEngineWrapper->getFileEntry(activatedIndex).isDir()) { |
|
1542 // populate new content of changed navigation view. |
|
1543 // mLocationChanged = true; |
|
1544 // mDirectory = filePath; |
|
1545 mEngineWrapper->moveDownToDirectory(activatedIndex); |
|
1546 refreshList(); |
|
1547 } else { // file item |
|
1548 // mSelectedFilePath = filePath; |
|
1549 FbFileEntry fileEntry = mEngineWrapper->getFileEntry(activatedIndex); |
|
1550 mAbsoluteFilePath = fileEntry.path() + fileEntry.name(); |
|
1551 |
|
1552 // open user-dialog to select: view as text/hex, open w/AppArc or open w/DocH. embed |
|
1553 QStringList list; |
|
1554 list << QString("View as text/hex") << QString("Open w/ AppArc") << QString("Open w/ DocH. embed"); |
|
1555 openListDialog(list, QString("Open file"), this, SLOT(fileOpen(HbAction *))); |
|
1556 } |
|
1557 } |
|
1558 } |
|
1559 |
|
1560 // --------------------------------------------------------------------------- |
|
1561 |
|
1562 void FbFileView::activateSelectionMode() |
|
1563 { |
|
1564 QString path; |
|
1565 disconnect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); |
|
1566 mListView->setSelectionMode(HbListView::MultiSelection); |
|
1567 |
|
1568 // QModelIndex index = mFileSystemModel->index(path,0); |
|
1569 // mListView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent); |
|
1570 // mListView->selectionModel()->select(index, QItemSelectionModel::Select); |
|
1571 // //mListView->setHighlightMode(HbItemHighlight::HighlightAlwaysVisible); |
|
1572 // mListView->setFocus(); // TODO use focus in |
|
1573 if (mListView->selectionModel()) { |
|
1574 connect(mListView->selectionModel(), |
|
1575 SIGNAL(selectionChanged(QItemSelection, QItemSelection)), |
|
1576 this, |
|
1577 SLOT(selectionChanged(QItemSelection, QItemSelection))); |
|
1578 // // flag to indicate that selection mode changed, "edit" sub-menu update needed |
|
1579 // mFolderContentChanged = true; |
|
1580 } |
|
1581 } |
|
1582 |
|
1583 // --------------------------------------------------------------------------- |
|
1584 |
|
1585 void FbFileView::deActivateSelectionMode() |
|
1586 { |
|
1587 disconnect(mListView->selectionModel(), |
|
1588 SIGNAL(selectionChanged(QItemSelection, QItemSelection)), |
|
1589 this, |
|
1590 SLOT(selectionChanged(QItemSelection, QItemSelection))); |
|
1591 mListView->setSelectionMode(HbListView::NoSelection); |
|
1592 connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); |
|
1593 editUnselectAll(); |
|
1594 // flag to indicate that selection mode changed, "edit" sub-menu update needed |
|
1595 mFolderContentChanged = true; |
|
1596 } |
|
1597 |
|
1598 // --------------------------------------------------------------------------- |
|