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 "settingsview.h" |
|
19 #include "enginewrapper.h" |
|
20 #include "filebrowsersettings.h" |
|
21 |
|
22 #include <HbView> |
|
23 #include <HbDataForm> |
|
24 #include <HbDataFormModel> |
|
25 #include <HbDataFormModelItem> |
|
26 #include <HbAction> |
|
27 #include <HbToolBar> |
|
28 |
|
29 #include <QGraphicsLinearLayout> |
|
30 |
|
31 const QStringList DisplayModeModes = (QStringList() << "Full screen" << "Normal"); |
|
32 const QStringList FileViewModes = (QStringList() << "Simple" << "Extended"); |
|
33 const QStringList Modes = (QStringList() << "Yes" << "No"); |
|
34 const QString YesText = QString("Yes"); |
|
35 const QString NoText = QString("No"); |
|
36 const QString acceptActionText = "OK"; |
|
37 const QString rejectActionText = "Cancel"; |
|
38 |
|
39 SettingsView::SettingsView(EngineWrapper &engineWrapper) : |
|
40 mEngineWrapper(engineWrapper), |
|
41 mForm(0), |
|
42 mDisplayModeItem(0), |
|
43 mFileViewItem(0), |
|
44 mShowDirectoryInfoItem(0), |
|
45 mShowAssociatedIconsItem(0), |
|
46 mRememberFolderOnExitItem(0), |
|
47 mRememberLastFolderItem(0), |
|
48 mShowToolbarItem(0), |
|
49 mSupportNetDrivesItem(0), |
|
50 mBypassPlatformSecurityItem(0), |
|
51 mUnlockFilesViaSBItem(0), |
|
52 mIgnoreProtectionAttributesItem(0), |
|
53 mNoROAttributeCopyFromZItem(0) |
|
54 { |
|
55 setTitle("Settings"); |
|
56 |
|
57 // Override back navigation action |
|
58 HbAction *leaveViewAction = new HbAction(Hb::BackNaviAction, this); |
|
59 connect(leaveViewAction, SIGNAL(triggered()), this, SLOT(reject())); |
|
60 setNavigationAction(leaveViewAction); |
|
61 |
|
62 initDataForm(); |
|
63 createToolbar(); |
|
64 } |
|
65 |
|
66 SettingsView::~SettingsView() |
|
67 { |
|
68 } |
|
69 |
|
70 void SettingsView::initDataForm() |
|
71 { |
|
72 mForm = new HbDataForm(this); |
|
73 HbDataFormModel *model = new HbDataFormModel(); |
|
74 |
|
75 // connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), |
|
76 // this, SLOT(toggleChange(QModelIndex, QModelIndex))); |
|
77 |
|
78 |
|
79 // TODO to be done |
|
80 // mDisplayModeItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem); |
|
81 // mDisplayModeItem->setLabel("Display mode: "); |
|
82 // mDisplayModeItem->setContentWidgetData("items", DisplayModeModes); |
|
83 // |
|
84 // mFileViewItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem); |
|
85 // mFileViewItem->setLabel("File view: "); |
|
86 // mFileViewItem->setContentWidgetData("items", FileViewModes); |
|
87 // |
|
88 // mShowDirectoryInfoItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); |
|
89 // mShowDirectoryInfoItem->setLabel("Show directory info: "); |
|
90 // mShowDirectoryInfoItem->setContentWidgetData(QString("text"), YesText); |
|
91 // mShowDirectoryInfoItem->setContentWidgetData(QString("additionalText"), NoText); |
|
92 // |
|
93 // mShowAssociatedIconsItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); |
|
94 // mShowAssociatedIconsItem->setLabel("Show associated icons: "); |
|
95 // mShowAssociatedIconsItem->setContentWidgetData(QString("text"), YesText); |
|
96 // mShowAssociatedIconsItem->setContentWidgetData(QString("additionalText"), NoText); |
|
97 // |
|
98 // mRememberFolderOnExitItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); |
|
99 // mRememberFolderOnExitItem->setLabel("Remember folder on exit: "); |
|
100 // mRememberFolderOnExitItem->setContentWidgetData(QString("text"), YesText); |
|
101 // mRememberFolderOnExitItem->setContentWidgetData(QString("additionalText"), NoText); |
|
102 // |
|
103 // mRememberLastFolderItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); |
|
104 // mRememberLastFolderItem->setLabel("Remember last folder: "); |
|
105 // mRememberLastFolderItem->setContentWidgetData(QString("text"), YesText); |
|
106 // mRememberLastFolderItem->setContentWidgetData(QString("additionalText"), NoText); |
|
107 // |
|
108 // mShowToolbarItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); |
|
109 // mShowToolbarItem->setLabel("Show toolbar: "); |
|
110 // mShowToolbarItem->setContentWidgetData(QString("text"), YesText); |
|
111 // mShowToolbarItem->setContentWidgetData(QString("additionalText"), NoText); |
|
112 |
|
113 mSupportNetDrivesItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); |
|
114 mSupportNetDrivesItem->setLabel("Support net drives: "); |
|
115 mSupportNetDrivesItem->setContentWidgetData(QString("text"), YesText); |
|
116 mSupportNetDrivesItem->setContentWidgetData(QString("additionalText"), NoText); |
|
117 |
|
118 mBypassPlatformSecurityItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); |
|
119 mBypassPlatformSecurityItem->setLabel("Bypass plat.security: "); |
|
120 mBypassPlatformSecurityItem->setContentWidgetData(QString("text"), YesText); |
|
121 mBypassPlatformSecurityItem->setContentWidgetData(QString("additionalText"), NoText); |
|
122 |
|
123 mUnlockFilesViaSBItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); |
|
124 mUnlockFilesViaSBItem->setLabel("Unlock files via SB: "); |
|
125 mUnlockFilesViaSBItem->setContentWidgetData(QString("text"), YesText); |
|
126 mUnlockFilesViaSBItem->setContentWidgetData(QString("additionalText"), NoText); |
|
127 |
|
128 mIgnoreProtectionAttributesItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); |
|
129 mIgnoreProtectionAttributesItem->setLabel("Ign. protection atts: "); |
|
130 mIgnoreProtectionAttributesItem->setContentWidgetData(QString("text"), YesText); |
|
131 mIgnoreProtectionAttributesItem->setContentWidgetData(QString("additionalText"), NoText); |
|
132 |
|
133 mNoROAttributeCopyFromZItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); |
|
134 mNoROAttributeCopyFromZItem->setLabel("No RO-att copy from Z: "); |
|
135 mNoROAttributeCopyFromZItem->setContentWidgetData(QString("text"), YesText); |
|
136 mNoROAttributeCopyFromZItem->setContentWidgetData(QString("additionalText"), NoText); |
|
137 |
|
138 // load file search attribute values from FB engine: |
|
139 loadSettings(mEngineWrapper.settings()); |
|
140 |
|
141 // model->appendDataFormItem(mDisplayModeItem); |
|
142 // model->appendDataFormItem(mFileViewItem); |
|
143 // model->appendDataFormItem(mShowDirectoryInfoItem); |
|
144 // model->appendDataFormItem(mShowAssociatedIconsItem); |
|
145 // model->appendDataFormItem(mRememberFolderOnExitItem); |
|
146 // model->appendDataFormItem(mRememberLastFolderItem); |
|
147 // model->appendDataFormItem(mShowToolbarItem); |
|
148 |
|
149 model->appendDataFormItem(mSupportNetDrivesItem); |
|
150 model->appendDataFormItem(mBypassPlatformSecurityItem); |
|
151 model->appendDataFormItem(mUnlockFilesViaSBItem); |
|
152 model->appendDataFormItem(mIgnoreProtectionAttributesItem); |
|
153 model->appendDataFormItem(mNoROAttributeCopyFromZItem); |
|
154 |
|
155 mForm->setModel(model); |
|
156 |
|
157 QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical,this); |
|
158 layout->addItem(mForm); |
|
159 setLayout(layout); |
|
160 } |
|
161 |
|
162 void SettingsView::createToolbar() |
|
163 { |
|
164 HbToolBar *toolBar = new HbToolBar(this); |
|
165 HbAction *acceptAction = new HbAction(acceptActionText); |
|
166 connect(acceptAction, SIGNAL(triggered()), this, SLOT(accept())); |
|
167 toolBar->addAction(acceptAction); |
|
168 |
|
169 HbAction *rejectAction = new HbAction(rejectActionText); |
|
170 connect(rejectAction, SIGNAL(triggered()), this, SLOT(reject())); |
|
171 toolBar->addAction(rejectAction); |
|
172 |
|
173 setToolBar(toolBar); |
|
174 } |
|
175 |
|
176 /** |
|
177 Set form item values from settings \a settings. |
|
178 */ |
|
179 void SettingsView::loadSettings(const FileBrowserSettings &settings) |
|
180 { |
|
181 // mDisplayModeItem->setContentWidgetData("text", settings.displayMode()); |
|
182 // mFileViewItem->setContentWidgetData("text", settings.fileViewMode()); |
|
183 // mShowDirectoryInfoItem->setContentWidgetData("text", settings.showSubDirectoryInfo()); |
|
184 // mShowAssociatedIconsItem->setContentWidgetData("text", settings.showAssociatedIcons()); |
|
185 // mRememberFolderOnExitItem->setContentWidgetData("text", settings.rememberFolderSelection()); |
|
186 // mRememberLastFolderItem->setContentWidgetData("text", settings.rememberLastPath()); |
|
187 // mShowToolbarItem->setContentWidgetData("text", settings.enableToolbar()); |
|
188 |
|
189 mSupportNetDrivesItem->setContentWidgetData("text", settings.supportNetworkDrives() ? YesText : NoText); |
|
190 mSupportNetDrivesItem->setContentWidgetData("additionalText", !settings.supportNetworkDrives() ? YesText : NoText); |
|
191 |
|
192 mBypassPlatformSecurityItem->setContentWidgetData("text", settings.bypassPlatformSecurity() ? YesText : NoText); |
|
193 mBypassPlatformSecurityItem->setContentWidgetData("additionalText", !settings.bypassPlatformSecurity() ? YesText : NoText); |
|
194 |
|
195 mUnlockFilesViaSBItem->setContentWidgetData("text", settings.removeFileLocks() ? YesText : NoText); |
|
196 mUnlockFilesViaSBItem->setContentWidgetData("additionalText", !settings.removeFileLocks() ? YesText : NoText); |
|
197 |
|
198 mIgnoreProtectionAttributesItem->setContentWidgetData("text", settings.ignoreProtectionsAttributes() ? YesText : NoText); |
|
199 mIgnoreProtectionAttributesItem->setContentWidgetData("additionalText", !settings.ignoreProtectionsAttributes() ? YesText : NoText); |
|
200 |
|
201 mNoROAttributeCopyFromZItem->setContentWidgetData("text", settings.removeROMWriteProrection() ? YesText : NoText); |
|
202 mNoROAttributeCopyFromZItem->setContentWidgetData("additionalText", !settings.removeROMWriteProrection() ? YesText : NoText); |
|
203 } |
|
204 |
|
205 /** |
|
206 Store form item data into \a settings |
|
207 */ |
|
208 void SettingsView::saveSettings(FileBrowserSettings &settings) |
|
209 { |
|
210 // settings.setDisplayMode(mDisplayModeItem->contentWidgetData("text").toInt()); |
|
211 // settings.setFileViewMode(mFileViewItem->contentWidgetData("text").toInt()); |
|
212 // settings.setShowSubDirectoryInfo(mShowDirectoryInfoItem->contentWidgetData("text").toBool()); |
|
213 // settings.setShowAssociatedIcons(mShowAssociatedIconsItem->contentWidgetData("text").toBool()); |
|
214 // settings.setRememberLastPath(mRememberFolderOnExitItem->contentWidgetData("text").toBool()); |
|
215 // //settings.setLastPath(mRememberLastFolderItem->contentWidgetData("text").toString()); |
|
216 // settings.setRememberFolderSelection(mRememberLastFolderItem->contentWidgetData("text").toBool()); |
|
217 // settings.setEnableToolbar(mShowToolbarItem->contentWidgetData("text").toBool()); |
|
218 |
|
219 settings.setSupportNetworkDrives(mSupportNetDrivesItem->contentWidgetData("text").toString() == YesText); |
|
220 settings.setBypassPlatformSecurity(mBypassPlatformSecurityItem->contentWidgetData("text").toString() == YesText); |
|
221 settings.setRemoveFileLocks(mUnlockFilesViaSBItem->contentWidgetData("text").toString() == YesText); |
|
222 settings.setIgnoreProtectionsAttributes(mIgnoreProtectionAttributesItem->contentWidgetData("text").toString() == YesText); |
|
223 settings.setRemoveROMWriteProrection(mNoROAttributeCopyFromZItem->contentWidgetData("text").toString() == YesText); |
|
224 } |
|
225 |
|
226 void SettingsView::constructMenu() |
|
227 { |
|
228 |
|
229 } |
|
230 |
|
231 void SettingsView::accept() |
|
232 { |
|
233 saveSettings(mEngineWrapper.settings()); |
|
234 mEngineWrapper.saveSettings(); |
|
235 emit finished(true); |
|
236 } |
|
237 |
|
238 void SettingsView::reject() |
|
239 { |
|
240 emit finished(false); |
|
241 } |
|
242 |
|
243 // End of file |
|