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
Marco Bubke
flatpak-qt-creator
Commits
12e27549
Commit
12e27549
authored
May 08, 2009
by
Roberto Raggi
Browse files
Introduced IFile::checkPermission() and use it to reduce the number of calls to isWritable().
Done with: mae
parent
cc3f7961
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/plugins/coreplugin/editormanager/editormanager.cpp
View file @
12e27549
...
...
@@ -1201,6 +1201,8 @@ bool EditorManager::saveFile(IEditor *editor)
return
false
;
IFile
*
file
=
editor
->
file
();
file
->
checkPermissions
();
const
QString
&
fileName
=
file
->
fileName
();
if
(
!
fileName
.
isEmpty
()
&&
file
->
isReadOnly
())
{
MakeWritableResult
answer
=
...
...
@@ -1270,6 +1272,7 @@ EditorManager::makeEditorWritable(IEditor *editor)
QMessageBox
::
warning
(
m_d
->
m_core
->
mainWindow
(),
tr
(
"Failed!"
),
tr
(
"Could not open the file for edit with SCC."
));
return
Failed
;
}
file
->
checkPermissions
();
return
OpenedWithVersionControl
;
case
RO_MakeWriteable
:
{
const
bool
permsOk
=
QFile
::
setPermissions
(
fileName
,
QFile
::
permissions
(
fileName
)
|
QFile
::
WriteUser
);
...
...
@@ -1278,6 +1281,7 @@ EditorManager::makeEditorWritable(IEditor *editor)
return
Failed
;
}
}
file
->
checkPermissions
();
return
MadeWritable
;
case
RO_SaveAs
:
return
saveFileAs
(
editor
)
?
SavedAs
:
Failed
;
...
...
src/plugins/coreplugin/ifile.h
View file @
12e27549
...
...
@@ -60,6 +60,8 @@ public:
virtual
void
modified
(
ReloadBehavior
*
behavior
)
=
0
;
virtual
void
checkPermissions
()
{}
signals:
void
changed
();
};
...
...
src/plugins/texteditor/basetextdocument.cpp
View file @
12e27549
...
...
@@ -70,6 +70,7 @@ BaseTextDocument::BaseTextDocument()
{
m_documentMarker
=
new
DocumentMarker
(
m_document
);
m_lineTerminatorMode
=
NativeLineTerminator
;
m_fileIsReadOnly
=
false
;
m_isBinaryData
=
false
;
m_codec
=
QTextCodec
::
codecForLocale
();
m_hasDecodingError
=
false
;
...
...
@@ -149,22 +150,34 @@ bool BaseTextDocument::isReadOnly() const
const
QFileInfo
fi
(
m_fileName
);
return
m_fileIsReadOnly
;
}
bool
BaseTextDocument
::
isModified
()
const
{
return
m_document
->
isModified
();
}
void
BaseTextDocument
::
checkPermissions
()
{
if
(
!
m_fileName
.
isEmpty
())
{
const
QFileInfo
fi
(
m_fileName
);
#ifdef Q_OS_WIN
// Check for permissions on NTFS file systems
qt_ntfs_permission_lookup
++
;
// Check for permissions on NTFS file systems
qt_ntfs_permission_lookup
++
;
#endif
const
bool
ro
=
!
fi
.
isWritable
();
m_fileIsReadOnly
=
!
fi
.
isWritable
();
#ifdef Q_OS_WIN
qt_ntfs_permission_lookup
--
;
qt_ntfs_permission_lookup
--
;
#endif
return
ro
;
}
bool
BaseTextDocument
::
isModified
()
const
{
return
m_document
->
isModified
();
}
else
{
m_fileIsReadOnly
=
false
;
}
}
bool
BaseTextDocument
::
open
(
const
QString
&
fileName
)
...
...
@@ -172,6 +185,7 @@ bool BaseTextDocument::open(const QString &fileName)
QString
title
=
tr
(
"untitled"
);
if
(
!
fileName
.
isEmpty
())
{
const
QFileInfo
fi
(
fileName
);
m_fileIsReadOnly
=
!
fi
.
isWritable
();
m_fileName
=
fi
.
absoluteFilePath
();
QFile
file
(
fileName
);
...
...
src/plugins/texteditor/basetextdocument.h
View file @
12e27549
...
...
@@ -83,6 +83,7 @@ public:
virtual
bool
isReadOnly
()
const
;
virtual
bool
isModified
()
const
;
virtual
bool
isSaveAsAllowed
()
const
{
return
true
;
}
virtual
void
checkPermissions
();
virtual
void
modified
(
Core
::
IFile
::
ReloadBehavior
*
behavior
);
virtual
QString
mimeType
()
const
;
void
setMimeType
(
const
QString
&
mt
);
...
...
@@ -141,6 +142,7 @@ private:
LineTerminatorMode
m_lineTerminatorMode
;
QTextCodec
*
m_codec
;
bool
m_fileIsReadOnly
;
bool
m_isBinaryData
;
bool
m_hasDecodingError
;
QByteArray
m_decodingErrorSample
;
...
...
src/plugins/texteditor/basetexteditor.cpp
View file @
12e27549
...
...
@@ -1332,15 +1332,6 @@ void BaseTextEditorPrivate::setupDocumentSignals(BaseTextDocument *document)
q
->
slotUpdateExtraAreaWidth
();
}
#ifndef TEXTEDITOR_STANDALONE
bool
BaseTextEditorPrivate
::
needMakeWritableCheck
()
const
{
return
!
m_document
->
isModified
()
&&
!
m_document
->
fileName
().
isEmpty
()
&&
m_document
->
isReadOnly
();
}
#endif
bool
Parenthesis
::
hasClosingCollapse
(
const
Parentheses
&
parentheses
)
{
return
closeCollapseAtPos
(
parentheses
)
>=
0
;
...
...
src/plugins/texteditor/basetexteditor_p.h
View file @
12e27549
...
...
@@ -142,9 +142,6 @@ public:
#endif
void
setupDocumentSignals
(
BaseTextDocument
*
document
);
void
updateLineSelectionColor
();
#ifndef TEXTEDITOR_STANDALONE
bool
needMakeWritableCheck
()
const
;
#endif
void
print
(
QPrinter
*
printer
);
...
...
Write
Preview
Supports
Markdown
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