mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
generic: bump minimim shared-mime-info requirement to v0.70
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
01f6ddfca4
commit
9ed732fc63
5 changed files with 7 additions and 38 deletions
|
@ -60,7 +60,7 @@ set_package_properties(ZLIB PROPERTIES
|
|||
PURPOSE "Required by the core KDE libraries and some critical kioslaves"
|
||||
)
|
||||
|
||||
find_package(SharedMimeInfo 0.60)
|
||||
find_package(SharedMimeInfo 0.70)
|
||||
set_package_properties(SharedMimeInfo PROPERTIES
|
||||
DESCRIPTION "Shared Mime Info"
|
||||
URL "http://freedesktop.org/wiki/Software/shared-mime-info"
|
||||
|
|
|
@ -73,9 +73,6 @@ bool KMimeGlobsFileParser::parseGlobFile(QIODevice* file, Format format, AllGlob
|
|||
if (!file->open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
|
||||
// If we're not going to get the "cs" flag because smi is too old, then we need to emulate it for *.C at least.
|
||||
const bool caseSensitiveHackNeeded = (KMimeType::sharedMimeInfoVersion() <= KDE_MAKE_VERSION(0, 60, 0));
|
||||
|
||||
QTextStream stream(file);
|
||||
//stream.setCodec("UTF-8"); // should be all latin1
|
||||
QString lastMime, lastPattern;
|
||||
|
@ -120,9 +117,6 @@ bool KMimeGlobsFileParser::parseGlobFile(QIODevice* file, Format format, AllGlob
|
|||
|
||||
bool caseSensitive = flagList.contains(QLatin1String("cs"));
|
||||
|
||||
if (caseSensitiveHackNeeded && (pattern == QLatin1String("*.C") || pattern == QLatin1String("*.c") || pattern == QLatin1String("core")))
|
||||
caseSensitive = true;
|
||||
|
||||
if (pattern == QLatin1String("__NOGLOBS__")) {
|
||||
//kDebug() << "removing" << mimeTypeName;
|
||||
globs.removeMime(mimeTypeName);
|
||||
|
|
|
@ -685,16 +685,10 @@ void KMimeTypePrivate::ensureXmlDataLoaded() const
|
|||
}
|
||||
m_strComment = comment;
|
||||
|
||||
const bool globsInXml = (KMimeType::sharedMimeInfoVersion() >= KDE_MAKE_VERSION(0, 70, 0));
|
||||
if (globsInXml) {
|
||||
if (!mainPattern.isEmpty() && m_lstPatterns.first() != mainPattern) {
|
||||
// ensure it's first in the list of patterns
|
||||
m_lstPatterns.removeAll(mainPattern);
|
||||
m_lstPatterns.prepend(mainPattern);
|
||||
}
|
||||
} else {
|
||||
// Fallback: get the patterns from the globs file
|
||||
m_lstPatterns = KMimeTypeRepository::self()->patternsForMimetype(m_strName);
|
||||
if (!mainPattern.isEmpty() && m_lstPatterns.first() != mainPattern) {
|
||||
// ensure it's first in the list of patterns
|
||||
m_lstPatterns.removeAll(mainPattern);
|
||||
m_lstPatterns.prepend(mainPattern);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -714,21 +708,6 @@ QString KMimeType::mainExtension() const
|
|||
{
|
||||
Q_D(const KMimeType);
|
||||
|
||||
#if 1 // HACK START - can be removed once shared-mime-info >= 0.70 is used/required.
|
||||
// The idea was: first usable pattern from m_lstPatterns.
|
||||
// But update-mime-database makes a mess of the order of the patterns,
|
||||
// because it uses a hash internally.
|
||||
static const struct { const char* mime; const char* extension; } s_hardcodedMimes[] = {
|
||||
{ "text/plain", ".txt" } };
|
||||
if (d->m_lstPatterns.count() > 1) {
|
||||
const QByteArray me = name().toLatin1();
|
||||
for (uint i = 0; i < sizeof(s_hardcodedMimes)/sizeof(*s_hardcodedMimes); ++i) {
|
||||
if (me == s_hardcodedMimes[i].mime)
|
||||
return QString::fromLatin1(s_hardcodedMimes[i].extension);
|
||||
}
|
||||
}
|
||||
#endif // HACK END
|
||||
|
||||
Q_FOREACH(const QString& pattern, patterns()) {
|
||||
// Skip if if looks like: README or *. or *.*
|
||||
// or *.JP*G or *.JP?
|
||||
|
|
|
@ -748,9 +748,7 @@ void KMimeTypeTest::testPatterns_data()
|
|||
QTest::addColumn<QString>("mainExtension");
|
||||
QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << ".pdf";
|
||||
QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << ".kpr";
|
||||
if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
|
||||
QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << ".wp";
|
||||
}
|
||||
QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << ".wp";
|
||||
QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << ".odt";
|
||||
QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << ".odp";
|
||||
QTest::newRow("mimetype with multiple patterns, *.doc added by kde") << "text/plain" << "*.asc;*.txt;*.doc;*,v" << ".txt";
|
||||
|
|
|
@ -214,9 +214,7 @@ private Q_SLOTS:
|
|||
QTest::newRow("#184852") << "audio/x-tuxguitar" << "audio-x-generic.png";
|
||||
QTest::newRow("#178847") << "image/x-compressed-xcf" << "image-x-generic.png";
|
||||
|
||||
if (sharedMimeInfoVersion >= KDE_MAKE_VERSION(0, 40, 0)) {
|
||||
QTest::newRow("mimetype generic icon") << "application-x-fluid" << "x-office-document.png";
|
||||
}
|
||||
QTest::newRow("mimetype generic icon") << "application-x-fluid" << "x-office-document.png";
|
||||
}
|
||||
|
||||
void testLoadMimeTypeIcon()
|
||||
|
|
Loading…
Add table
Reference in a new issue