FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlitebrowser/src/FileDialog.cpp at master · PeterDaveHello/sqlitebrowser · GitHub
PeterDaveHello
/
sqlitebrowser
Public
forked from
sqlitebrowser/sqlitebrowser
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlitebrowser
/
src
/
FileDialog.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
83 lines (72 loc) · 3.29 KB
Breadcrumbs
sqlitebrowser
/
src
/
FileDialog.cpp
Copy path
File metadata and controls
83 lines (72 loc) · 3.29 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#
include
"
FileDialog.h
"
#
include
"
Settings.h
"
QString
FileDialog::getOpenFileName
(
const
FileDialogTypes dialogType, QWidget* parent,
const
QString& caption,
const
QString &filter, QString *selectedFilter, Options options)
{
QString result =
QFileDialog::getOpenFileName
(parent, caption,
getFileDialogPath
(dialogType), filter, selectedFilter, options);
if
(!result.
isEmpty
())
setFileDialogPath
(dialogType, result);
return
result;
}
QStringList
FileDialog::getOpenFileNames
(
const
FileDialogTypes dialogType, QWidget *parent,
const
QString &caption,
const
QString &filter, QString *selectedFilter, QFileDialog::Options options)
{
QStringList result =
QFileDialog::getOpenFileNames
(parent, caption,
getFileDialogPath
(dialogType), filter, selectedFilter, options);
if
(!result.
isEmpty
())
{
QFileInfo path =
QFileInfo
(result.
first
());
setFileDialogPath
(dialogType, path.
absolutePath
());
}
return
result;
}
QString
FileDialog::getSaveFileName
(
const
FileDialogTypes dialogType, QWidget* parent,
const
QString& caption,
const
QString& filter,
const
QString& defaultFileName, QString* selectedFilter, Options options)
{
QString dir =
getFileDialogPath
(dialogType);
if
(!defaultFileName.
isEmpty
())
dir +=
"
/
"
+ defaultFileName;
QString result =
QFileDialog::getSaveFileName
(parent, caption, dir, filter, selectedFilter, options);
if
(!result.
isEmpty
())
setFileDialogPath
(dialogType, result);
return
result;
}
QString
FileDialog::getExistingDirectory
(
const
FileDialogTypes dialogType, QWidget* parent,
const
QString& caption, Options options)
{
QString result =
QFileDialog::getExistingDirectory
(parent, caption,
getFileDialogPath
(dialogType), options);
if
(!result.
isEmpty
())
setFileDialogPath
(dialogType, result);
return
result;
}
QString
FileDialog::getFileDialogPath
(
const
FileDialogTypes dialogType)
{
switch
(
Settings::getValue
(
"
db
"
,
"
savedefaultlocation
"
).
toInt
())
{
case
0
:
//
Remember last location
case
2
: {
//
Remember last location for current session only
QHash<QString, QVariant> lastLocations =
Settings::getValue
(
"
db
"
,
"
lastlocations
"
).
toHash
();
return
lastLocations[
QString
(dialogType)].
toString
();
}
case
1
:
//
Always use this locations
return
Settings::getValue
(
"
db
"
,
"
defaultlocation
"
).
toString
();
default
:
return
QString
();
}
}
void
FileDialog::setFileDialogPath
(
const
FileDialogTypes dialogType,
const
QString& new_path)
{
QString dir =
QFileInfo
(new_path).
absolutePath
();
QHash<QString, QVariant> lastLocations =
Settings::getValue
(
"
db
"
,
"
lastlocations
"
).
toHash
();
lastLocations[
QString
(dialogType)] = dir;
switch
(
Settings::getValue
(
"
db
"
,
"
savedefaultlocation
"
).
toInt
())
{
case
0
:
//
Remember last location
Settings::setValue
(
"
db
"
,
"
lastlocations
"
, lastLocations);
break
;
case
2
:
//
Remember last location for current session only
Settings::setValue
(
"
db
"
,
"
lastlocations
"
, lastLocations,
false
);
break
;
case
1
:
//
Always use this locations
break
;
//
Do nothing
}
}
QString
FileDialog::getSqlDatabaseFileFilter
()
{
return
Settings::getValue
(
"
General
"
,
"
DBFileExtensions
"
).
toString
() +
"
;;
"
+
QObject::tr
(
"
All files (*)
"
);
//
Always add "All files (*)" to the available filters
}
Back
|
FazBrowse Home
|
New Git URL