mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
generic: adjust to KMimeType changes
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
32e9d58d95
commit
ceff785f22
9 changed files with 15 additions and 17 deletions
|
@ -71,7 +71,7 @@ void KateProjectTreeViewContextMenu::exec(const QString& filename, const QPoint&
|
|||
* find correct mimetype to query for possible applications
|
||||
*/
|
||||
QMenu *openWithMenu = menu.addMenu(i18n("Open With"));
|
||||
KMimeType::Ptr mimeType = KMimeType::findByPath(filename);
|
||||
KMimeType::Ptr mimeType = KMimeType::findByUrl(KUrl(filename));
|
||||
KService::List offers = KMimeTypeTrader::self()->query(mimeType->name(), "Application");
|
||||
|
||||
/**
|
||||
|
|
|
@ -241,8 +241,7 @@ QString KateModeManager::fileType (KateDocument *doc, const QString &fileToReadF
|
|||
// Try content-based mimetype
|
||||
KMimeType::Ptr mt;
|
||||
if (!fileToReadFrom.isEmpty()) {
|
||||
int accuracy = 0;
|
||||
mt = KMimeType::findByFileContent(fileToReadFrom, &accuracy);
|
||||
mt = KMimeType::findByUrl(KUrl(fileToReadFrom));
|
||||
if (!mt)
|
||||
mt = KMimeType::defaultMimeTypePtr();
|
||||
} else {
|
||||
|
|
|
@ -1301,8 +1301,7 @@ void KateFileTreeModel::setupIcon(ProxyItem *item)
|
|||
icon_name = "document-save";
|
||||
}
|
||||
else {
|
||||
KUrl url = item->path();
|
||||
icon_name = KMimeType::findByUrl(url, 0, true, true)->iconName();
|
||||
icon_name = KMimeType::findByUrl(item->path(), 0, true)->iconName();
|
||||
}
|
||||
|
||||
if(item->flag(ProxyItem::ModifiedExternally) || item->flag(ProxyItem::DeletedExternally)) {
|
||||
|
|
|
@ -52,10 +52,7 @@ static quint16 getPort(const quint16 portmin, const quint16 portmax)
|
|||
|
||||
static QString getFileMIME(const QString &filepath)
|
||||
{
|
||||
const KMimeType::Ptr kmimetypeptr = KMimeType::findByUrl(
|
||||
KUrl(filepath),
|
||||
mode_t(0), true
|
||||
);
|
||||
const KMimeType::Ptr kmimetypeptr = KMimeType::findByUrl(KUrl(filepath));
|
||||
if (!kmimetypeptr.isNull()) {
|
||||
return kmimetypeptr->name();
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@ private Q_SLOTS:
|
|||
QCOMPARE(mime->patterns(), patterns); // must sort them if more than one
|
||||
|
||||
// Testcase for the shaman.xml bug
|
||||
QCOMPARE(KMimeType::findByPath("/whatever/foo.pkg.tar.gz")->name(), QString("fake/unit-test-fake-mimetype"));
|
||||
QCOMPARE(KMimeType::findByUrl(KUrl("/whatever/foo.pkg.tar.gz"))->name(), QString("fake/unit-test-fake-mimetype"));
|
||||
|
||||
m_mimeTypeCreatedSuccessfully = true;
|
||||
}
|
||||
|
|
|
@ -423,7 +423,7 @@ bool TrashProtocol::createUDSEntry( const QString& physicalPath, const QString&
|
|||
//if ( !url.isEmpty() )
|
||||
// entry.insert( KIO::UDSEntry::UDS_URL, url );
|
||||
|
||||
KMimeType::Ptr mt = KMimeType::findByPath( physicalPath, buff.st_mode );
|
||||
KMimeType::Ptr mt = KMimeType::findByUrl( KUrl(physicalPath), buff.st_mode );
|
||||
if ( mt )
|
||||
entry.insert( KIO::UDSEntry::UDS_MIME_TYPE, mt->name() );
|
||||
entry.insert( KIO::UDSEntry::UDS_ACCESS, access );
|
||||
|
|
|
@ -55,12 +55,15 @@ int main(int argc, char *argv[])
|
|||
if (fileName == QLatin1String("-")) {
|
||||
QFile qstdin;
|
||||
qstdin.open(stdin, QIODevice::ReadOnly);
|
||||
const QByteArray data = qstdin.readAll();
|
||||
mime = KMimeType::findByContent(data, &accuracy);
|
||||
mime = KMimeType::findByContent(qstdin.readAll(), &accuracy);
|
||||
} else if (args->isSet("f")) {
|
||||
mime = KMimeType::findByName(fileName, &accuracy);
|
||||
} else if (args->isSet("c")) {
|
||||
mime = KMimeType::findByFileContent(fileName, &accuracy);
|
||||
QFile qfile(fileName);
|
||||
qfile.open(QIODevice::ReadOnly);
|
||||
mime = KMimeType::findByContent(qfile.read(16384), &accuracy);
|
||||
} else {
|
||||
mime = KMimeType::findByPath(fileName, 0, args->isSet("f"), &accuracy);
|
||||
mime = KMimeType::findByUrl(KUrl(fileName), 0, false, &accuracy);
|
||||
}
|
||||
if ( mime && mime->name() != KMimeType::defaultMimeType() ) {
|
||||
printf("%s\n", mime->name().toLatin1().constData());
|
||||
|
|
|
@ -463,7 +463,7 @@ void SessionController::updateOpenWithMenu(const QString &selectedText)
|
|||
return;
|
||||
|
||||
// TODO: handle relative URL/path selection properly, it will cost a bit of I/O
|
||||
KMimeType::Ptr mimeType = KMimeType::findByPath(searchText);
|
||||
KMimeType::Ptr mimeType = KMimeType::findByUrl(KUrl(searchText));
|
||||
KService::List offers = KMimeTypeTrader::self()->query(mimeType->name(), "Application");
|
||||
|
||||
for(KService::List::Iterator it = offers.begin(); it != offers.end(); ++it) {
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
|
||||
QIcon fileSystemIcon(const QFileInfo &file) final
|
||||
{
|
||||
KMimeType::Ptr mime = KMimeType::findByPath(file.filePath(), 0, true);
|
||||
KMimeType::Ptr mime = KMimeType::findByUrl(KUrl(file.filePath()));
|
||||
if (!mime)
|
||||
return QIcon();
|
||||
return KIcon(mime->iconName());
|
||||
|
|
Loading…
Add table
Reference in a new issue