23 #include "fmlogger.h" |
23 #include "fmlogger.h" |
24 #include "fmutils.h" |
24 #include "fmutils.h" |
25 #include "fmdrivemodel.h" |
25 #include "fmdrivemodel.h" |
26 #include "fmcommon.h" |
26 #include "fmcommon.h" |
27 |
27 |
28 #include "hbwidget.h" |
28 #include <hbwidget.h> |
29 #include "hblabel.h" |
29 #include <hblabel.h> |
30 #include "hbaction.h" |
30 #include <hbaction.h> |
31 #include "hbpushbutton.h" |
31 #include <hbpushbutton.h> |
32 #include "hblineedit.h" |
32 #include <hblineedit.h> |
33 |
33 #include <hbtranslator.h> |
|
34 |
34 #include <QGraphicsLinearLayout> |
35 #include <QGraphicsLinearLayout> |
|
36 #include <QEventLoop> |
35 |
37 |
36 FmFileDialog::FmFileDialog( QGraphicsItem *parent ) : |
38 FmFileDialog::FmFileDialog( QGraphicsItem *parent ) : |
37 HbDialog( parent ), d_ptr( new FmFileDialogPrivate( this ) ) |
39 HbDialog( parent ), d_ptr( new FmFileDialogPrivate( this ) ) |
38 { |
40 { |
39 } |
41 } |
107 const QString &title, |
113 const QString &title, |
108 const QString &dir, |
114 const QString &dir, |
109 const QStringList &nameFilters, |
115 const QStringList &nameFilters, |
110 Options options ) |
116 Options options ) |
111 { |
117 { |
|
118 HbTranslator translator("filemanager"); |
|
119 translator.loadCommon(); |
|
120 |
112 QString ret; |
121 QString ret; |
113 |
122 |
114 FmFileDialogPrivate::FmFileDialogArgs args; |
123 FmFileDialogPrivate::FmFileDialogArgs args; |
115 args.mDialogMode = FmFileDialogPrivate::SaveFileMode; |
124 args.mDialogMode = FmFileDialogPrivate::SaveFileMode; |
116 args.mTitle = title; |
125 args.mTitle = title; |
134 |
143 |
135 |
144 |
136 |
145 |
137 bool FmFileDialog::exec() |
146 bool FmFileDialog::exec() |
138 { |
147 { |
139 if ( d_ptr->isOkAction( HbDialog::exec() ) ) { |
148 HbDialog::open( this, SLOT(dialogClosed(HbAction*)) ); |
|
149 d_ptr->eventLoop().exec(); |
|
150 |
|
151 if ( d_ptr->isOkAction( d_ptr->retAction() ) ) { |
140 return true; |
152 return true; |
141 } else { |
153 } else { |
142 return false ; |
154 return false ; |
143 } |
155 } |
144 } |
156 } |
145 |
157 |
146 |
158 void FmFileDialog::dialogClosed(HbAction *action) |
147 |
159 { |
148 |
160 d_ptr->setRetAction( action ); |
|
161 d_ptr->eventLoop().exit(); |
|
162 } |
|
163 |
|
164 |
|
165 HbAction *FmFileDialog::primaryAction() const |
|
166 { |
|
167 QList<QAction *> actionList = QGraphicsWidget::actions(); |
|
168 if (actionList.size() > 0) { |
|
169 return (HbAction *)(actionList.at(0)); |
|
170 } else { |
|
171 return 0; |
|
172 } |
|
173 |
|
174 } |
|
175 |
|
176 void FmFileDialog::setPrimaryAction( HbAction *action ) |
|
177 { |
|
178 QList<QAction *> actionList = QGraphicsWidget::actions(); |
|
179 if (actionList.size() == 0) { |
|
180 QGraphicsWidget::addAction(action); |
|
181 } else if (actionList.size() == 1) { |
|
182 actionList.clear(); |
|
183 QGraphicsWidget::addAction(action); |
|
184 } else if (actionList.size() == 2) { |
|
185 actionList.removeAt(0); |
|
186 actionList.insert(0, action); |
|
187 } |
|
188 } |
|
189 |
|
190 HbAction *FmFileDialog::secondaryAction() const |
|
191 { |
|
192 QList<QAction *> actionList = QGraphicsWidget::actions(); |
|
193 if (actionList.size() > 1) { |
|
194 return (HbAction *)(actionList.at(1)); |
|
195 } else { |
|
196 return 0; |
|
197 } |
|
198 } |
|
199 |
|
200 void FmFileDialog::setSecondaryAction( HbAction *action ) |
|
201 { |
|
202 QList<QAction *> actionList = QGraphicsWidget::actions(); |
|
203 if (actionList.size() == 0) { |
|
204 QGraphicsWidget::addAction(new HbAction(hbTrId("Ok"))); |
|
205 QGraphicsWidget::addAction(action); |
|
206 } else if (actionList.size() == 1) { |
|
207 QGraphicsWidget::addAction(action); |
|
208 } else if (actionList.size() == 2) { |
|
209 actionList.removeAt(1); |
|
210 actionList.insert(1, action); |
|
211 } |
|
212 |
|
213 } |
|
214 |