mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +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
|
* find correct mimetype to query for possible applications
|
||||||
*/
|
*/
|
||||||
QMenu *openWithMenu = menu.addMenu(i18n("Open With"));
|
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");
|
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
|
// Try content-based mimetype
|
||||||
KMimeType::Ptr mt;
|
KMimeType::Ptr mt;
|
||||||
if (!fileToReadFrom.isEmpty()) {
|
if (!fileToReadFrom.isEmpty()) {
|
||||||
int accuracy = 0;
|
mt = KMimeType::findByUrl(KUrl(fileToReadFrom));
|
||||||
mt = KMimeType::findByFileContent(fileToReadFrom, &accuracy);
|
|
||||||
if (!mt)
|
if (!mt)
|
||||||
mt = KMimeType::defaultMimeTypePtr();
|
mt = KMimeType::defaultMimeTypePtr();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1301,8 +1301,7 @@ void KateFileTreeModel::setupIcon(ProxyItem *item)
|
||||||
icon_name = "document-save";
|
icon_name = "document-save";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
KUrl url = item->path();
|
icon_name = KMimeType::findByUrl(item->path(), 0, true)->iconName();
|
||||||
icon_name = KMimeType::findByUrl(url, 0, true, true)->iconName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(item->flag(ProxyItem::ModifiedExternally) || item->flag(ProxyItem::DeletedExternally)) {
|
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)
|
static QString getFileMIME(const QString &filepath)
|
||||||
{
|
{
|
||||||
const KMimeType::Ptr kmimetypeptr = KMimeType::findByUrl(
|
const KMimeType::Ptr kmimetypeptr = KMimeType::findByUrl(KUrl(filepath));
|
||||||
KUrl(filepath),
|
|
||||||
mode_t(0), true
|
|
||||||
);
|
|
||||||
if (!kmimetypeptr.isNull()) {
|
if (!kmimetypeptr.isNull()) {
|
||||||
return kmimetypeptr->name();
|
return kmimetypeptr->name();
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,7 +273,7 @@ private Q_SLOTS:
|
||||||
QCOMPARE(mime->patterns(), patterns); // must sort them if more than one
|
QCOMPARE(mime->patterns(), patterns); // must sort them if more than one
|
||||||
|
|
||||||
// Testcase for the shaman.xml bug
|
// 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;
|
m_mimeTypeCreatedSuccessfully = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -423,7 +423,7 @@ bool TrashProtocol::createUDSEntry( const QString& physicalPath, const QString&
|
||||||
//if ( !url.isEmpty() )
|
//if ( !url.isEmpty() )
|
||||||
// entry.insert( KIO::UDSEntry::UDS_URL, url );
|
// 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 )
|
if ( mt )
|
||||||
entry.insert( KIO::UDSEntry::UDS_MIME_TYPE, mt->name() );
|
entry.insert( KIO::UDSEntry::UDS_MIME_TYPE, mt->name() );
|
||||||
entry.insert( KIO::UDSEntry::UDS_ACCESS, access );
|
entry.insert( KIO::UDSEntry::UDS_ACCESS, access );
|
||||||
|
|
|
@ -55,12 +55,15 @@ int main(int argc, char *argv[])
|
||||||
if (fileName == QLatin1String("-")) {
|
if (fileName == QLatin1String("-")) {
|
||||||
QFile qstdin;
|
QFile qstdin;
|
||||||
qstdin.open(stdin, QIODevice::ReadOnly);
|
qstdin.open(stdin, QIODevice::ReadOnly);
|
||||||
const QByteArray data = qstdin.readAll();
|
mime = KMimeType::findByContent(qstdin.readAll(), &accuracy);
|
||||||
mime = KMimeType::findByContent(data, &accuracy);
|
} else if (args->isSet("f")) {
|
||||||
|
mime = KMimeType::findByName(fileName, &accuracy);
|
||||||
} else if (args->isSet("c")) {
|
} 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 {
|
} else {
|
||||||
mime = KMimeType::findByPath(fileName, 0, args->isSet("f"), &accuracy);
|
mime = KMimeType::findByUrl(KUrl(fileName), 0, false, &accuracy);
|
||||||
}
|
}
|
||||||
if ( mime && mime->name() != KMimeType::defaultMimeType() ) {
|
if ( mime && mime->name() != KMimeType::defaultMimeType() ) {
|
||||||
printf("%s\n", mime->name().toLatin1().constData());
|
printf("%s\n", mime->name().toLatin1().constData());
|
||||||
|
|
|
@ -463,7 +463,7 @@ void SessionController::updateOpenWithMenu(const QString &selectedText)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: handle relative URL/path selection properly, it will cost a bit of I/O
|
// 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");
|
KService::List offers = KMimeTypeTrader::self()->query(mimeType->name(), "Application");
|
||||||
|
|
||||||
for(KService::List::Iterator it = offers.begin(); it != offers.end(); ++it) {
|
for(KService::List::Iterator it = offers.begin(); it != offers.end(); ++it) {
|
||||||
|
|
|
@ -80,7 +80,7 @@ public:
|
||||||
|
|
||||||
QIcon fileSystemIcon(const QFileInfo &file) final
|
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)
|
if (!mime)
|
||||||
return QIcon();
|
return QIcon();
|
||||||
return KIcon(mime->iconName());
|
return KIcon(mime->iconName());
|
||||||
|
|
Loading…
Add table
Reference in a new issue