Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
3b315ed4
Commit
3b315ed4
authored
Dec 09, 2008
by
hjk
Browse files
fix file name validation bug
parent
342caa21
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/libs/utils/pathchooser.cpp
View file @
3b315ed4
...
...
@@ -55,7 +55,8 @@ namespace Utils {
#endif
// ------------------ PathValidatingLineEdit
class
PathValidatingLineEdit
:
public
BaseValidatingLineEdit
{
class
PathValidatingLineEdit
:
public
BaseValidatingLineEdit
{
public:
explicit
PathValidatingLineEdit
(
PathChooser
*
chooser
,
QWidget
*
parent
=
0
);
...
...
@@ -79,7 +80,8 @@ bool PathValidatingLineEdit::validate(const QString &value, QString *errorMessag
}
// ------------------ PathChooserPrivate
struct
PathChooserPrivate
{
struct
PathChooserPrivate
{
PathChooserPrivate
(
PathChooser
*
chooser
);
PathValidatingLineEdit
*
m_lineEdit
;
...
...
@@ -160,9 +162,9 @@ void PathChooser::slotBrowse()
// TODO make cross-platform
// Delete trailing slashes unless it is "/", only
if
(
!
newPath
.
isEmpty
())
{
if
(
newPath
.
size
()
>
1
&&
newPath
.
endsWith
(
QDir
::
separator
()))
newPath
.
truncate
(
newPath
.
size
()
-
1
);
if
(
!
newPath
.
isEmpty
())
{
if
(
newPath
.
size
()
>
1
&&
newPath
.
endsWith
(
QDir
::
separator
()))
newPath
.
truncate
(
newPath
.
size
()
-
1
);
setPath
(
newPath
);
}
}
...
...
@@ -174,7 +176,7 @@ bool PathChooser::isValid() const
QString
PathChooser
::
errorMessage
()
const
{
return
m_d
->
m_lineEdit
->
errorMessage
();
return
m_d
->
m_lineEdit
->
errorMessage
();
}
bool
PathChooser
::
validatePath
(
const
QString
&
path
,
QString
*
errorMessage
)
...
...
@@ -207,17 +209,19 @@ bool PathChooser::validatePath(const QString &path, QString *errorMessage)
// Check expected kind
switch
(
m_d
->
m_acceptingKind
)
{
case
PathChooser
::
Directory
:
if
(
!
isDir
)
if
(
!
isDir
)
{
if
(
errorMessage
)
*
errorMessage
=
tr
(
"The path '%1' is not a directory."
).
arg
(
path
);
return
false
;
}
break
;
case
PathChooser
::
File
:
if
(
isDir
)
if
(
isDir
)
{
if
(
errorMessage
)
*
errorMessage
=
tr
(
"The path '%1' is not a file."
).
arg
(
path
);
return
false
;
}
break
;
case
PathChooser
::
Command
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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