1 /* |
|
2 * Copyright (c) 2009 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 * Zhiqiang Yang <zhiqiang.yang@nokia.com> |
|
14 * |
|
15 * Description: |
|
16 * The header file of the widget to browse files |
|
17 * |
|
18 */ |
|
19 |
|
20 #ifndef FMFILEBROWSEWIDGET_H |
|
21 #define FMFILEBROWSEWIDGET_H |
|
22 |
|
23 #include "fmcommon.h" |
|
24 #include "fmoperationservice.h" |
|
25 |
|
26 #include <QFileInfo> |
|
27 |
|
28 #include <hbwidget.h> |
|
29 #include <QDir> |
|
30 |
|
31 class QFileSystemModel; |
|
32 class QGraphicsLinearLayout; |
|
33 class HbListView; |
|
34 class HbTreeView; |
|
35 class HbAbstractViewItem; |
|
36 class HbSearchPanel; |
|
37 class HbLabel; |
|
38 |
|
39 class FmFileIconProvider; |
|
40 |
|
41 class FmFileBrowseWidget : public HbWidget |
|
42 { |
|
43 Q_OBJECT |
|
44 |
|
45 public: |
|
46 enum Style { |
|
47 NoStyle, |
|
48 ListStyle, |
|
49 TreeStyle, |
|
50 LabelStyle |
|
51 }; |
|
52 |
|
53 enum TSortType{ |
|
54 ESortByName, |
|
55 ESortByTime, |
|
56 ESortBySize, |
|
57 ESortByType |
|
58 }; |
|
59 |
|
60 explicit FmFileBrowseWidget( HbWidget *parent = 0, FmFileBrowseWidget::Style style = ListStyle ); |
|
61 ~FmFileBrowseWidget(); |
|
62 |
|
63 QFileInfo currentPath() const; |
|
64 QList<QFileInfo> checkedItems() const; |
|
65 Style style() const { return mStyle; } |
|
66 void setStyle( FmFileBrowseWidget::Style style ); |
|
67 bool selectable() const; |
|
68 void setSelectable( bool enable ); |
|
69 void clearSelection(); |
|
70 |
|
71 bool rename( const QString &oldName, const QString &newName ); |
|
72 void setModelFilter( QDir::Filters filters ); |
|
73 |
|
74 int checkPathAndSetStyle( const QString& path ); |
|
75 void sortFiles( TSortType sortType ); |
|
76 void activeSearchPanel(); |
|
77 |
|
78 public slots: |
|
79 bool cdUp(); |
|
80 void setRootPath( const QString &pathName ); |
|
81 |
|
82 // triggered when drive is ejected/inserted |
|
83 void on_driveChanged(); |
|
84 |
|
85 void on_searchPanel_searchOptionsClicked(); |
|
86 void on_searchPanel_criteriaChanged( const QString &criteria ); |
|
87 void on_searchPanel_exitClicked(); |
|
88 |
|
89 signals: |
|
90 void currentPathChanged( const QString& ); |
|
91 void startSearch( const QString &targetPath, const QString &criteria ); |
|
92 void setEmptyMenu( bool isMenuEmpty ); |
|
93 void setTitle( const QString &title ); |
|
94 void listActivated(); |
|
95 |
|
96 private slots: |
|
97 void on_list_activated( const QModelIndex &index ); |
|
98 void on_listActivated(); |
|
99 void on_tree_activated( const QModelIndex &index ); |
|
100 void on_list_longPressed( HbAbstractViewItem *item, const QPointF &coords ); |
|
101 void on_list_pressed( const QModelIndex & index ) ; |
|
102 void on_tree_longPressed( HbAbstractViewItem *item, const QPointF &coords ); |
|
103 |
|
104 void on_viewAction_triggered(); |
|
105 void on_copyAction_triggered(); |
|
106 void on_moveAction_triggered(); |
|
107 void on_deleteAction_triggered(); |
|
108 void on_renameAction_triggered(); |
|
109 void on_sendAction_triggered(); |
|
110 |
|
111 private: |
|
112 void initListView(); |
|
113 void initTreeView(); |
|
114 void initFileModel(); |
|
115 void initLayout(); |
|
116 void initSearchPanel(); |
|
117 void initEmptyTipsLabel(); |
|
118 |
|
119 void changeRootIndex( const QModelIndex &index ); |
|
120 bool isDriver(const QModelIndex &index) const; |
|
121 bool isFolder(const QModelIndex &index) const; |
|
122 |
|
123 HbTreeView *mTreeView; |
|
124 HbListView *mListView; |
|
125 QGraphicsLinearLayout *mLayout; |
|
126 QFileSystemModel *mModel; |
|
127 |
|
128 bool mSelectable; |
|
129 |
|
130 //currentStyle |
|
131 Style mStyle; |
|
132 //used to store original tree/list style |
|
133 Style mFileBrowseStyle; |
|
134 |
|
135 HbAbstractViewItem* mCurrentItem; |
|
136 FmOperationService *mOperationService; |
|
137 |
|
138 QString mFindTargetPath; |
|
139 HbSearchPanel *mSearchPanel; |
|
140 HbLabel *mEmptyTipLabel; |
|
141 |
|
142 QString mCurrentDrive; |
|
143 |
|
144 //used to avoid activate when long press list. |
|
145 bool mListLongPressed; |
|
146 QModelIndex mActivatedModelIndex; |
|
147 |
|
148 // provide icon from filemanger |
|
149 FmFileIconProvider *mFileIconProvider; |
|
150 }; |
|
151 |
|
152 #endif |
|