Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
KFind
Commits
468978b1
Commit
468978b1
authored
Jun 19, 2017
by
Laurent Montel
😁
Browse files
Port to QFileDialog
parent
b1b6501d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/kfindtreeview.cpp
View file @
468978b1
...
...
@@ -31,7 +31,7 @@
#include <QMenu>
#include <KActionCollection>
#include <
kf
ile
d
ialog
.h
>
#include <
QF
ile
D
ialog>
#include <krun.h>
#include <kmessagebox.h>
#include <kglobal.h>
...
...
@@ -430,18 +430,12 @@ void KFindTreeView::copySelection()
void
KFindTreeView
::
saveResults
()
{
KFileDialog
*
dlg
=
new
KFileDialog
(
QUrl
(),
QString
(),
this
)
;
dlg
->
setOperationMode
(
KFileDialog
::
Saving
);
dlg
->
setWindowTitle
(
i18nc
(
"@title:window"
,
"Save Results As"
)
);
dlg
->
setFilter
(
QStringLiteral
(
"*.html|%1
\n
*.txt|%2"
).
arg
(
i18n
(
"HTML page"
),
i18n
(
"Text file"
))
);
dlg
->
setConfirmOverwrite
(
true
);
QString
selectedFilter
;
QUrl
u
=
QFileDialog
::
getSaveFileUrl
(
this
,
i18nc
(
"@title:window"
,
"Save Results As"
)
,
QUrl
(),
QStringLiteral
(
"*.html|%1
\n
*.txt|%2"
).
arg
(
i18n
(
"HTML page"
),
i18n
(
"Text file"
))
,
&
selectedFilter
);
dlg
->
exec
();
QUrl
u
=
dlg
->
selectedUrl
();
QString
filter
=
dlg
->
currentFilter
();
delete
dlg
;
if
(
!
u
.
isValid
()
||
!
u
.
isLocalFile
())
{
return
;
...
...
@@ -458,8 +452,8 @@ void KFindTreeView::saveResults()
QTextStream
stream
(
&
file
);
stream
.
setCodec
(
QTextCodec
::
codecForLocale
());
QList
<
KFindItem
>
itemList
=
m_model
->
getItemList
();
if
(
f
ilter
==
QLatin1String
(
"*.html"
))
{
const
QList
<
KFindItem
>
itemList
=
m_model
->
getItemList
();
if
(
selectedF
ilter
==
QLatin1String
(
"*.html"
))
{
stream
<<
QString
::
fromLatin1
(
"<!DOCTYPE html PUBLIC
\"
-//W3C//DTD XHTML 1.0 Strict//EN
\"
"
"
\"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
\"
><html xmlns=
\"
http://www.w3.org/1999/xhtml
\"
>
\n
"
"<head>
\n
"
...
...
@@ -470,14 +464,14 @@ void KFindTreeView::saveResults()
.
arg
(
QString
::
fromLatin1
(
QTextCodec
::
codecForLocale
()
->
name
()))
.
arg
(
i18n
(
"KFind Results File"
));
Q_FOREACH
(
const
KFindItem
&
item
,
itemList
)
{
for
(
const
KFindItem
&
item
:
itemList
)
{
const
KFileItem
fileItem
=
item
.
getFileItem
();
stream
<<
QStringLiteral
(
"<dt><a href=
\"
%1
\"
>%2</a></dt>
\n
"
).
arg
(
fileItem
.
url
().
url
(),
fileItem
.
url
().
toDisplayString
());
}
stream
<<
QStringLiteral
(
"</dl>
\n
</body>
\n
</html>
\n
"
);
}
else
{
Q_FOREACH
(
const
KFindItem
&
item
,
itemList
)
{
for
(
const
KFindItem
&
item
:
itemList
)
{
stream
<<
item
.
getFileItem
().
url
().
url
()
<<
endl
;
}
}
...
...
src/kftabdlg.cpp
View file @
468978b1
...
...
@@ -38,7 +38,7 @@
#include <klineedit.h>
#include <kmessagebox.h>
#include <KNumInput>
#include <
kf
ile
d
ialog
.h
>
#include <
QF
ile
D
ialog>
#include <kregexpeditorinterface.h>
#include <kservicetypetrader.h>
#include <kstandarddirs.h>
...
...
@@ -796,8 +796,8 @@ void KfindTabWidget::setQuery(KQuery *query)
void
KfindTabWidget
::
getDirectory
()
{
QString
result
=
K
FileDialog
::
getExistingDirectory
(
QUrl
::
fromUserInput
(
dirBox
->
currentText
().
trimmed
())
,
this
)
;
const
QString
result
=
Q
FileDialog
::
getExistingDirectory
(
this
,
QString
(),
dirBox
->
currentText
().
trimmed
());
if
(
!
result
.
isEmpty
())
{
for
(
int
i
=
0
;
i
<
dirBox
->
count
();
i
++
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment