qdoc: Remove algorithm to find common prefix
HtmlGenerator::generateCompactList() no longer uses an algorithm to find out a common prefix for classes/qml types when generating the alphabetical lists. The common prefix argument is no longer optional. To indicate there is no common prefix, pass an empty string as the common prefix argument. Task-number: QTBUG-33750 Change-Id: I4b44bbcff909fcea5c7bfd58c6796e303086bc68 Reviewed-by: Topi Reiniö <topi.reinio@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
This commit is contained in:
parent
c025d49119
commit
db7501b051
@ -1022,10 +1022,10 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
|
||||
generateAnnotatedList(relative, marker, qdb_->getCppClasses());
|
||||
}
|
||||
else if (atom->string() == "classes") {
|
||||
generateCompactList(Generic, relative, qdb_->getCppClasses(), true);
|
||||
generateCompactList(Generic, relative, qdb_->getCppClasses(), true, QStringLiteral("Q"));
|
||||
}
|
||||
else if (atom->string() == "qmlclasses") {
|
||||
generateCompactList(Generic, relative, qdb_->getQmlTypes(), true);
|
||||
generateCompactList(Generic, relative, qdb_->getQmlTypes(), true, QStringLiteral(""));
|
||||
}
|
||||
else if (atom->string().contains("classesbymodule")) {
|
||||
QString arg = atom->string().trimmed();
|
||||
@ -1044,19 +1044,21 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
|
||||
generateClassHierarchy(relative, qdb_->getCppClasses());
|
||||
}
|
||||
else if (atom->string() == "compatclasses") {
|
||||
generateCompactList(Generic, relative, qdb_->getCompatibilityClasses(), false);
|
||||
// "compatclasses" is no longer used. Delete this at some point.
|
||||
// mws 03/10/2013
|
||||
generateCompactList(Generic, relative, qdb_->getCompatibilityClasses(), false, QStringLiteral("Q"));
|
||||
}
|
||||
else if (atom->string() == "obsoleteclasses") {
|
||||
generateCompactList(Generic, relative, qdb_->getObsoleteClasses(), false);
|
||||
generateCompactList(Generic, relative, qdb_->getObsoleteClasses(), false, QStringLiteral("Q"));
|
||||
}
|
||||
else if (atom->string() == "obsoleteqmltypes") {
|
||||
generateCompactList(Generic, relative, qdb_->getObsoleteQmlTypes(), false);
|
||||
generateCompactList(Generic, relative, qdb_->getObsoleteQmlTypes(), false, QStringLiteral(""));
|
||||
}
|
||||
else if (atom->string() == "obsoletecppmembers") {
|
||||
generateCompactList(Obsolete, relative, qdb_->getClassesWithObsoleteMembers(), false);
|
||||
generateCompactList(Obsolete, relative, qdb_->getClassesWithObsoleteMembers(), false, QStringLiteral("Q"));
|
||||
}
|
||||
else if (atom->string() == "obsoleteqmlmembers") {
|
||||
generateCompactList(Obsolete, relative, qdb_->getQmlTypesWithObsoleteMembers(), false);
|
||||
generateCompactList(Obsolete, relative, qdb_->getQmlTypesWithObsoleteMembers(), false, QStringLiteral(""));
|
||||
}
|
||||
else if (atom->string() == "functionindex") {
|
||||
generateFunctionIndex(relative);
|
||||
@ -1065,10 +1067,14 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
|
||||
generateLegaleseList(relative, marker);
|
||||
}
|
||||
else if (atom->string() == "mainclasses") {
|
||||
generateCompactList(Generic, relative, qdb_->getMainClasses(), true);
|
||||
// "mainclasses" is no longer used. Delete this at some point.
|
||||
// mws 03/10/2013
|
||||
generateCompactList(Generic, relative, qdb_->getMainClasses(), true, QStringLiteral("Q"));
|
||||
}
|
||||
else if (atom->string() == "services") {
|
||||
generateCompactList(Generic, relative, qdb_->getServiceClasses(), false);
|
||||
// "services" is no longer used. Delete this at some point.
|
||||
// mws 03/10/2013
|
||||
generateCompactList(Generic, relative, qdb_->getServiceClasses(), false, QStringLiteral("Q"));
|
||||
}
|
||||
else if (atom->string() == "overviews") {
|
||||
generateOverviewList(relative);
|
||||
|
@ -381,7 +381,7 @@ private:
|
||||
const Node* relative,
|
||||
const NodeMap& classMap,
|
||||
bool includeAlphabet,
|
||||
QString commonPrefix = QString());
|
||||
QString commonPrefix);
|
||||
void generateFunctionIndex(const Node* relative);
|
||||
void generateLegaleseList(const Node* relative, CodeMarker* marker);
|
||||
void generateOverviewList(const Node* relative);
|
||||
|
@ -491,7 +491,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
|
||||
generateAnnotatedList(relative, marker, qdb_->getCppClasses());
|
||||
}
|
||||
else if (atom->string() == "classes") {
|
||||
generateCompactList(Generic, relative, qdb_->getCppClasses(), true);
|
||||
generateCompactList(Generic, relative, qdb_->getCppClasses(), true, QStringLiteral("Q"));
|
||||
}
|
||||
else if (atom->string() == "qmltypes") {
|
||||
generateCompactList(Generic, relative, qdb_->getQmlTypes(), true, QStringLiteral(""));
|
||||
@ -513,16 +513,18 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
|
||||
generateClassHierarchy(relative, qdb_->getCppClasses());
|
||||
}
|
||||
else if (atom->string() == "compatclasses") {
|
||||
generateCompactList(Generic, relative, qdb_->getCompatibilityClasses(), false);
|
||||
// "compatclasses" is no longer used. Delete this at some point.
|
||||
// mws 03/10/2013
|
||||
generateCompactList(Generic, relative, qdb_->getCompatibilityClasses(), false, QStringLiteral("Q"));
|
||||
}
|
||||
else if (atom->string() == "obsoleteclasses") {
|
||||
generateCompactList(Generic, relative, qdb_->getObsoleteClasses(), false);
|
||||
generateCompactList(Generic, relative, qdb_->getObsoleteClasses(), false, QStringLiteral("Q"));
|
||||
}
|
||||
else if (atom->string() == "obsoleteqmltypes") {
|
||||
generateCompactList(Generic, relative, qdb_->getObsoleteQmlTypes(), false, QStringLiteral(""));
|
||||
}
|
||||
else if (atom->string() == "obsoletecppmembers") {
|
||||
generateCompactList(Obsolete, relative, qdb_->getClassesWithObsoleteMembers(), false);
|
||||
generateCompactList(Obsolete, relative, qdb_->getClassesWithObsoleteMembers(), false, QStringLiteral("Q"));
|
||||
}
|
||||
else if (atom->string() == "obsoleteqmlmembers") {
|
||||
generateCompactList(Obsolete, relative, qdb_->getQmlTypesWithObsoleteMembers(), false, QStringLiteral(""));
|
||||
@ -534,10 +536,14 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
|
||||
generateLegaleseList(relative, marker);
|
||||
}
|
||||
else if (atom->string() == "mainclasses") {
|
||||
generateCompactList(Generic, relative, qdb_->getMainClasses(), true);
|
||||
// "mainclasses" is no longer used. Delete this at some point.
|
||||
// mws 03/10/2013
|
||||
generateCompactList(Generic, relative, qdb_->getMainClasses(), true, QStringLiteral("Q"));
|
||||
}
|
||||
else if (atom->string() == "services") {
|
||||
generateCompactList(Generic, relative, qdb_->getServiceClasses(), false);
|
||||
// "services" is no longer used. Delete this at some point.
|
||||
// mws 03/10/2013
|
||||
generateCompactList(Generic, relative, qdb_->getServiceClasses(), false, QStringLiteral("Q"));
|
||||
}
|
||||
else if (atom->string() == "overviews") {
|
||||
generateOverviewList(relative);
|
||||
@ -2535,49 +2541,11 @@ void HtmlGenerator::generateCompactList(ListType listType,
|
||||
bool includeAlphabet,
|
||||
QString commonPrefix)
|
||||
{
|
||||
const int NumParagraphs = 37; // '0' to '9', 'A' to 'Z', '_'
|
||||
|
||||
if (classMap.isEmpty())
|
||||
return;
|
||||
|
||||
/*
|
||||
If commonPrefix is not empty, then the caller knows what
|
||||
the common prefix is and has passed it in, so just use that
|
||||
one. But if commonPrefix is a null string (default value), then
|
||||
compute a common prefix using this simple algorithm. Note we
|
||||
assume the prefix length is 1, i.e. we will have a single
|
||||
character as the common prefix.
|
||||
*/
|
||||
const int NumParagraphs = 37; // '0' to '9', 'A' to 'Z', '_'
|
||||
int commonPrefixLen = commonPrefix.length();
|
||||
if (commonPrefix.isNull()) {
|
||||
QVector<int> count(26);
|
||||
for (int i=0; i<26; ++i)
|
||||
count[i] = 0;
|
||||
|
||||
NodeMap::const_iterator iter = classMap.constBegin();
|
||||
while (iter != classMap.constEnd()) {
|
||||
if (!iter.key().contains("::")) {
|
||||
QChar c = iter.key()[0];
|
||||
if ((c >= 'A') && (c <= 'Z')) {
|
||||
int idx = c.unicode() - QChar('A').unicode();
|
||||
++count[idx];
|
||||
}
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
int highest = 0;
|
||||
int idx = -1;
|
||||
for (int i=0; i<26; ++i) {
|
||||
if (count[i] > highest) {
|
||||
highest = count[i];
|
||||
idx = i;
|
||||
}
|
||||
}
|
||||
idx += QChar('A').unicode();
|
||||
QChar common(idx);
|
||||
commonPrefix = common;
|
||||
commonPrefixLen = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
Divide the data into 37 paragraphs: 0, ..., 9, A, ..., Z,
|
||||
|
@ -164,7 +164,7 @@ private:
|
||||
const Node *relative,
|
||||
const NodeMap &classMap,
|
||||
bool includeAlphabet,
|
||||
QString commonPrefix = QString());
|
||||
QString commonPrefix);
|
||||
void generateFunctionIndex(const Node *relative);
|
||||
void generateLegaleseList(const Node *relative, CodeMarker *marker);
|
||||
void generateOverviewList(const Node *relative);
|
||||
|
Loading…
Reference in New Issue
Block a user