mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
kate: do not use KMimeType::defaultMimeTypePtr()
even tho KMimeType is shared data QString is cheaper to create and pass around Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
ceff785f22
commit
db1a98803e
2 changed files with 16 additions and 15 deletions
|
@ -1851,16 +1851,17 @@ bool KateDocument::print ()
|
|||
//BEGIN KTextEditor::DocumentInfoInterface (### unfinished)
|
||||
QString KateDocument::mimeType()
|
||||
{
|
||||
KMimeType::Ptr result = KMimeType::defaultMimeTypePtr();
|
||||
|
||||
// if the document has a URL, try KMimeType::findByURL
|
||||
if ( ! this->url().isEmpty() )
|
||||
result = KMimeType::findByUrl( this->url() );
|
||||
return KMimeType::findByUrl( this->url() )->name();
|
||||
|
||||
else if ( this->url().isEmpty() || ! this->url().isLocalFile() )
|
||||
result = mimeTypeForContent();
|
||||
else if ( this->url().isEmpty() || ! this->url().isLocalFile() ) {
|
||||
KMimeType::Ptr mime = mimeTypeForContent();
|
||||
if (mime)
|
||||
return mime->name();
|
||||
}
|
||||
|
||||
return result->name();
|
||||
return KMimeType::defaultMimeType();
|
||||
}
|
||||
|
||||
KMimeType::Ptr KateDocument::mimeTypeForContent()
|
||||
|
@ -1886,9 +1887,7 @@ KMimeType::Ptr KateDocument::mimeTypeForContent()
|
|||
}
|
||||
buf.resize( bufpos );
|
||||
|
||||
int accuracy = 0;
|
||||
KMimeType::Ptr mt = KMimeType::findByContent(buf, &accuracy);
|
||||
return mt ? mt : KMimeType::defaultMimeTypePtr();
|
||||
return KMimeType::findByContent(buf);
|
||||
}
|
||||
//END KTextEditor::DocumentInfoInterface
|
||||
|
||||
|
|
|
@ -239,20 +239,22 @@ QString KateModeManager::fileType (KateDocument *doc, const QString &fileToReadF
|
|||
}
|
||||
|
||||
// Try content-based mimetype
|
||||
KMimeType::Ptr mt;
|
||||
QString mime;
|
||||
if (!fileToReadFrom.isEmpty()) {
|
||||
mt = KMimeType::findByUrl(KUrl(fileToReadFrom));
|
||||
if (!mt)
|
||||
mt = KMimeType::defaultMimeTypePtr();
|
||||
mime = KMimeType::findByUrl(KUrl(fileToReadFrom))->name();
|
||||
} else {
|
||||
mt = doc->mimeTypeForContent();
|
||||
KMimeType::Ptr mt = doc->mimeTypeForContent();
|
||||
if (mt)
|
||||
mime = mt->name();
|
||||
else
|
||||
mime = KMimeType::defaultMimeType();
|
||||
}
|
||||
|
||||
QList<KateFileType*> types;
|
||||
|
||||
foreach (KateFileType *type, m_types)
|
||||
{
|
||||
if (type->mimetypes.indexOf (mt->name()) > -1)
|
||||
if (type->mimetypes.indexOf (mime) > -1)
|
||||
types.append (type);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue