[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/3.5/kdewebdev/quanta
From: Andras Mantia <amantia () kde ! org>
Date: 2006-09-09 17:10:57
Message-ID: 1157821857.855102.13246.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 582528 by amantia:
Improve mimetype and extension based searching for a DTEP that can handle the \
currently opened file. Related to bug #129808.
M +2 -1 ChangeLog
M +1 -0 data/dtep/docbook-4.2/description.rc
M +1 -1 data/dtep/empty/description.rc
M +1 -0 data/dtep/html-frameset/description.rc
M +1 -0 data/dtep/html-strict/description.rc
M +1 -0 data/dtep/html/description.rc
M +1 -0 data/dtep/kde-docbook-4.1.2/description.rc
M +1 -0 data/dtep/kde-docbook-4.2/description.rc
M +1 -0 data/dtep/php/description.rc
M +1 -0 data/dtep/schema/description.rc
M +1 -0 data/dtep/tagxml/description.rc
M +1 -0 data/dtep/wml-1-2/description.rc
M +1 -0 data/dtep/xhtml-basic/description.rc
M +1 -0 data/dtep/xhtml-frameset/description.rc
M +1 -0 data/dtep/xhtml-strict/description.rc
M +1 -0 data/dtep/xhtml/description.rc
M +1 -0 data/dtep/xhtml11/description.rc
M +1 -0 data/dtep/xslt/description.rc
M +8 -8 quanta.kdevelop
M +15 -6 src/document.cpp
M +50 -13 src/dtds.cpp
M +14 -6 src/dtds.h
--- branches/KDE/3.5/kdewebdev/quanta/ChangeLog #582527:582528
@@ -19,11 +19,12 @@
- really abort if a remote directory cannot be created [#117032]
- fix automatic updating of closing tags [#132357]
- accept float numbers for length values [#130295]
- - handle correctly the escaped backslashes inside strings []
+ - handle correctly the escaped backslashes inside strings [#128819]
- improvements:
- make CSS completion work inside style attributes [#80605]
- improve usability of the File Changed dialog [#126058]
+ - improve finding a DTEP for a file [related to #129808]
Version 3.5.4 (Release date: 02-08-2006; Started 24-06-2005):
- bugfixes:
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/docbook-4.2/description.rc \
#582527:582528 @@ -3,6 +3,7 @@
NickName = Docbook XML 4.2
URL = http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd
DoctypeString = book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" \
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" +MimeTypes = text/docbook
DefaultExtension = docbook
Groups = Core
NumOfPages = 1
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/empty/description.rc #582527:582528
@@ -1,7 +1,7 @@
[General]
Name = empty
NickName = Empty DTEP valid for all files
-MimeTypes = text/all
+MimeTypes = all/all
NumOfPages = 0
CaseSensitive = false
Family = 2
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/html-frameset/description.rc \
#582527:582528 @@ -4,6 +4,7 @@
URL = http://www.w3.org/TR/html4/frameset.dtd
DoctypeString = HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" \
"http://www.w3.org/TR/html4/frameset.dtd" Inherits = -//W3C//DTD HTML 4.01//EN
+MimeTypes = text/html
DefaultExtension = html
Groups = Core, I18n, Script
NumOfPages = 2
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/html-strict/description.rc \
#582527:582528 @@ -3,6 +3,7 @@
NickName = HTML 4.01 Strict
URL = http://www.w3.org/TR/html4/strict.dtd
DoctypeString = HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" \
"http://www.w3.org/TR/html4/strict.dtd" +MimeTypes = text/html
DefaultExtension = html
Groups = Core, I18n, Script
NumOfPages = 2
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/html/description.rc #582527:582528
@@ -3,6 +3,7 @@
NickName = HTML 4.01 Transitional
URL = http://www.w3.org/TR/html4/loose.dtd
DoctypeString = HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" \
"http://www.w3.org/TR/html4/loose.dtd" +MimeTypes = text/html
DefaultExtension = html
Groups = Core, I18n, Script
NumOfPages = 2
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/kde-docbook-4.1.2/description.rc \
#582527:582528 @@ -3,6 +3,7 @@
NickName = KDE Docbook XML 4.1.2
URL = dtd/kdex.dtd
DoctypeString = book PUBLIC "-//KDE//DTD DocBook XML V4.1.2-Based Variant V1.0//EN" \
"dtd/kdex.dtd" +MimeTypes = text/docbook
DefaultExtension = docbook
Groups = Core
NumOfPages = 1
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/kde-docbook-4.2/description.rc \
#582527:582528 @@ -4,6 +4,7 @@
URL = dtd/kdex.dtd
DoctypeString = book PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN" \
"dtd/kdex.dtd" Inherits = -//KDE//DTD DocBook XML V4.1.2-Based Variant V1.0//EN
+MimeTypes = text/docbook
DefaultExtension = docbook
Groups = Core
NumOfPages = 1
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/php/description.rc #582527:582528
@@ -1,5 +1,6 @@
[General]
Name = PHP
+MimeTypes = application/x-php
DefaultExtension = php
NumOfPages = 0
CaseSensitive = true
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/schema/description.rc #582527:582528
@@ -1,6 +1,7 @@
[General]
Name = XML Schema
NickName = XML Schema 1.0
+MimeTypes = application/xsd
DefaultExtension = xsd
NumOfPages = 0
CaseSensitive = true
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/tagxml/description.rc #582527:582528
@@ -1,5 +1,6 @@
[General]
Name = TAGS
+MimeTypes = text/xml
DefaultExtension = tag
NickName = Quanta Tag Files
NumOfPages = 0
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/wml-1-2/description.rc #582527:582528
@@ -1,6 +1,7 @@
[General]
Name = -//WAPFORUM//DTD WML 1.2//EN
NickName = WML 1.2
+MimeTypes = text/vnd.wap.wml
DefaultExtension = wml
Groups = Core
NumOfPages = 1
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/xhtml-basic/description.rc \
#582527:582528 @@ -3,6 +3,7 @@
NickName = XHTML 1.0 Basic
URL = http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd
DoctypeString = html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" \
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd" +MimeTypes = text/html
DefaultExtension = html
Groups = Core, I18n
NumOfPages = 1
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/xhtml-frameset/description.rc \
#582527:582528 @@ -3,6 +3,7 @@
NickName = XHTML 1.0 Frameset
URL = http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd
DoctypeString = html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" \
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" +MimeTypes = text/html
DefaultExtension = html
Groups = Core, I18n, Script, Focus, Others
NumOfPages = 4
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/xhtml-strict/description.rc \
#582527:582528 @@ -3,6 +3,7 @@
NickName = XHTML 1.0 Strict
URL = http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
DoctypeString = html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" \
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" +MimeTypes = text/html
DefaultExtension = html
Groups = Core, I18n, Script, Focus, Others
NumOfPages = 4
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/xhtml/description.rc #582527:582528
@@ -3,6 +3,7 @@
NickName = XHTML 1.0 Transitional
URL = http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
DoctypeString = html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" \
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" +MimeTypes = text/html
DefaultExtension = html
Groups = Core, I18n, Script, Focus, Others
NumOfPages = 4
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/xhtml11/description.rc #582527:582528
@@ -3,6 +3,7 @@
NickName = XHTML 1.1
URL = http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd
DoctypeString = html PUBLIC "-//W3C//DTD XHTML 1.1//EN" \
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" +MimeTypes = text/html
DefaultExtension = html
Groups = Core, I18n, Script,Focus
NumOfPages = 3
--- branches/KDE/3.5/kdewebdev/quanta/data/dtep/xslt/description.rc #582527:582528
@@ -1,6 +1,7 @@
[General]
Name = XSLT
NickName = XSLT 1.0
+MimeTypes = text/x-xslt
DefaultExtension = xslt
NumOfPages = 0
CaseSensitive = true
--- branches/KDE/3.5/kdewebdev/quanta/quanta.kdevelop #582527:582528
@@ -19,7 +19,7 @@
<absoluteprojectpath>false</absoluteprojectpath>
<secondaryLanguages/>
<versioncontrol/>
- <defaultencoding></defaultencoding>
+ <defaultencoding/>
</general>
<kdevautoproject>
<general>
@@ -170,7 +170,7 @@
</groups>
<tree>
<hidenonprojectfiles>false</hidenonprojectfiles>
- <hidepatterns/>
+ <hidepatterns></hidepatterns>
<showvcsfields>true</showvcsfields>
</tree>
</kdevfileview>
@@ -193,16 +193,16 @@
</kdevdoctreeview>
<kdevdebugger>
<general>
- <dbgshell></dbgshell>
- <programargs></programargs>
+ <dbgshell/>
+ <programargs/>
<gdbpath>/usr/bin/gdb</gdbpath>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
<runappinappdirectory>true</runappinappdirectory>
- <configGdbScript></configGdbScript>
- <runShellScript></runShellScript>
- <runGdbScript></runGdbScript>
+ <configGdbScript/>
+ <runShellScript/>
+ <runGdbScript/>
</general>
<display>
<staticmembers>false</staticmembers>
@@ -280,7 +280,7 @@
<pcs>KDElibs3</pcs>
</references>
<creategettersetter>
- <prefixGet></prefixGet>
+ <prefixGet/>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
--- branches/KDE/3.5/kdewebdev/quanta/src/document.cpp #582527:582528
@@ -2949,12 +2949,21 @@
}
} else //DOCTYPE not found in file
{
- QString mimetype = KMimeType::findByURL(url())->name();
- const DTDStruct *currdtd = DTDs::ref()->DTDfromMimeType(mimetype);
- if (currdtd)
- setDTDIdentifier(currdtd->name);
- else
- setDTDIdentifier(projectDTD);
+ KURL u = url();
+ QString dtdId = DTDs::ref()->DTDforURL(u)->name;
+// if (dtdId == "empty")
+ {
+ const DTDStruct * dtd = DTDs::ref()->find(projectDTD);
+ if (DTDs::canHandle(dtd, u))
+ dtdId = projectDTD;
+ else
+ {
+ dtd = DTDs::ref()->find(qConfig.defaultDocType);
+ if (DTDs::canHandle(dtd, u))
+ dtdId = qConfig.defaultDocType;
+ }
+ }
+ setDTDIdentifier(dtdId);
}
} else //dtdName is read from the method's parameter
{
--- branches/KDE/3.5/kdewebdev/quanta/src/dtds.cpp #582527:582528
@@ -109,7 +109,23 @@
// kdDebug(24000) << "read:" << *it << endl;
readTagDir(*it, false); // read all tags, but only short form
}
-// kdDebug(24000) << "dtds::dtds constructed" << endl;
+
+//load the mimetypes from the insideDTDs
+ QDictIterator<DTDStruct> it(*m_dict);
+ for( ; it.current(); ++it )
+ {
+ DTDStruct * dtd = it.current();
+ for (uint i = 0; i < dtd->insideDTDs.count(); i++)
+ {
+ const DTDStruct *insideDTD = m_dict->find(dtd->insideDTDs[i]); // search but \
don't load + if (!insideDTD)
+ insideDTD = m_dict->find(getDTDNameFromNickName(dtd->insideDTDs[i])); // \
search but don't load + if (insideDTD && !insideDTD->toplevel)
+ dtd->mimeTypes += insideDTD->mimeTypes;
+ }
+ }
+
+ // kdDebug(24000) << "dtds::dtds constructed" << endl;
}
DTDs::~DTDs()
@@ -189,6 +205,12 @@
int pos = tmpStr.find('(');
dtd->definitionTags[tmpStr.left(pos).stripWhiteSpace()] = tmpStr.mid(pos+1, \
tmpStr.findRev(')')-pos-1).stripWhiteSpace(); }
+ //Which DTD can be present in this one?
+ dtd->insideDTDs = dtdConfig->readListEntry("MayContain");
+ for (uint i = 0; i < dtd->insideDTDs.count(); i++)
+ {
+ dtd->insideDTDs[i] = dtd->insideDTDs[i].stripWhiteSpace().lower();
+ }
m_dict->insert(dtdName.lower(), dtd); //insert the structure into the dictionary
@@ -236,7 +258,7 @@
dtd->inheritsTagsFrom = dtdConfig->readEntry("Inherits").lower();
dtd->documentation = dtdConfig->readEntry("Documentation").lower();
- dtd->defaultExtension = dtdConfig->readEntry("DefaultExtension", "html");
+ dtd->defaultExtension = dtdConfig->readEntry("DefaultExtension");
dtd->caseSensitive = caseSensitive;
int numOfTags = 0;
QTagList *tagList = new QTagList(119, false); //max 119 tag in a DTD
@@ -356,12 +378,6 @@
/**** Code for the new parser *****/
dtdConfig->setGroup("Parsing rules");
- //Which DTD can be present in this one?
- dtd->insideDTDs = dtdConfig->readListEntry("MayContain");
- for (uint i = 0; i < dtd->insideDTDs.count(); i++)
- {
- dtd->insideDTDs[i] = dtd->insideDTDs[i].stripWhiteSpace().lower();
- }
bool appendCommonRules = dtdConfig->readBoolEntry("AppendCommonSpecialAreas", \
true); //Read the special areas and area names
QString rxStr = "";
@@ -1046,18 +1062,39 @@
}
-/** find a DTD for a given mimetype */
-const DTDStruct * DTDs::DTDfromMimeType(const QString &mimetype)
+const DTDStruct * DTDs::DTDforURL(const KURL &url)
{
+ QValueList<DTDStruct*> foundList;
QDictIterator<DTDStruct> it(*m_dict);
for( ; it.current(); ++it )
{
- if (it.current()->toplevel && it.current()->mimeTypes.contains(mimetype))
+ if (it.current()->toplevel && canHandle(it.current(), url))
{
- return it.current();
+ foundList.append(it.current());
}
}
- return 0L;
+ if (foundList.isEmpty())
+ return find("empty");
+ else
+ {
+ QString path = url.path();
+ for (uint i = 0; i < foundList.count(); i++)
+ {
+ if (path.endsWith('.' + foundList[i]->defaultExtension))
+ return foundList[i];
+ }
+ return foundList[0];
+ }
}
+bool DTDs::canHandle(const DTDStruct *dtd, const KURL &url)
+{
+ QString mimetype = KMimeType::findByURL(url)->name();
+ if (dtd->mimeTypes.contains(mimetype))
+ return true;
+ if (url.path().endsWith('.' + dtd->defaultExtension))
+ return true;
+ return false;
+}
+
#include "dtds.moc"
--- branches/KDE/3.5/kdewebdev/quanta/src/dtds.h #582527:582528
@@ -127,13 +127,21 @@
QStringList fileNameList (bool topLevelOnly=false);
- /** finds a dtd for a given mimetype
+ /** finds a dtd for a given url
*
- * @param mimetype look for this type
- * @return the first DTD for this mimetype or 0L
+ * @param url look for this file
+ * @return the first DTD for this mimetype or the "empty" DTD if not found
*/
- const DTDStruct * DTDfromMimeType(const QString &mimetype);
+ const DTDStruct * DTDforURL(const KURL &url);
+ /**
+ * Checks if a DTD can handle the file or not.
+ * @param dtd the DTD to check against
+ * @param url the url pointing to the file
+ * @return true if it can handle
+ */
+ static bool canHandle(const DTDStruct *dtd, const KURL &url);
+
public slots:
/** Load a DTD and convert to a DTEP */
@@ -158,10 +166,10 @@
/** DTD has changed need reparse */
void forceReparse();
-
+
/** Enable/disbale the idle timer*/
void enableIdleTimer(bool);
-
+
void loadToolbarForDTD(const QString&);
private:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic