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