diff --git a/docs/CodeStyle.md b/docs/CodeStyle.md new file mode 100644 index 0000000000..c65caf0c49 --- /dev/null +++ b/docs/CodeStyle.md @@ -0,0 +1,103 @@ +Code Formatting Guidelines +========================== + +Sigil uses astyle to auto format all .h and .cpp files. The following is used +for formatting: + + $ astyle -A10 -s4 -xl -S -w -Y -m1 -H -k3 -W3 -j -z2 -xy -R "*.h" + $ astyle -A10 -s4 -xl -S -w -Y -m1 -H -k3 -W3 -j -z2 -xy -R "*.cpp" + + +-A10 +---- + +"One True Brace Style" formatting/indenting uses linux brackets and adds +brackets to unbracketed one line conditional statements. Opening brackets +are broken from namespaces, classes, and function definitions. Brackets +re attached to everything else including statements within a function, +arrays, structs, and enums. + + int Foo(bool isBar) + { + if (isFoo) { + bar(); + return 1; + } else { + return 0; + } + } + + +-s4 +--- + +Indent using 4 spaces per indent. + + +-xl +--- + +Attach brackets to class and struct inline function definitions. + + +-S +-- + +Indent 'switch' blocks so that the 'case X:' statements are indented in the +switch block. The entire case block is indented. + + +-w +-- + +Indent multi-line preprocessor definitions ending with a backslash + + +-Y +-- + +Indent C++ comments beginning in column one. + + +-m1 +--- + +Set the minimal indent that is added when a header is built of multiple lines. + + +-H +-- + +Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...). + + +-k3 +--- + +Attach a pointer or reference operator (*, &, or ^) to the variable name. + + +-W3 +--- + +This option will align references separate from pointers. + + +-j +-- + +Add brackets to unbracketed one line conditional statements +(e.g. 'if', 'for', 'while'...). + + +-z2 +--- + +Force use of the Linux (\n) line end style. + + +-xy +--- + +Closes whitespace in the angle brackets of template definitions. Closing the +ending angle brackets is now allowed by the C++11 standard. diff --git a/src/Sigil/BookManipulation/Book.cpp b/src/Sigil/BookManipulation/Book.cpp index 93dd63cf15..d2be32ef90 100644 --- a/src/Sigil/BookManipulation/Book.cpp +++ b/src/Sigil/BookManipulation/Book.cpp @@ -67,75 +67,75 @@ static const QString EMPTY_HTML_FILE = "\n" ""; -static const QString SGC_TOC_CSS_FILE = - "div.sgc-toc-title {\n" - " font-size: 2em;\n" - " font-weight: bold;\n" - " margin-bottom: 1em;\n" - " text-align: center;\n" - "}\n\n" - "div.sgc-toc-level-1 {\n" - " margin-left: 0em;\n" - "}\n\n" - "div.sgc-toc-level-2 {\n" - " margin-left: 2em;\n" - "}\n\n" - "div.sgc-toc-level-3 {\n" - " margin-left: 2em;\n" - "}\n\n" - "div.sgc-toc-level-4 {\n" - " margin-left: 2em;\n" - "}\n\n" - "div.sgc-toc-level-5 {\n" - " margin-left: 2em;\n" - "}\n\n" - "div.sgc-toc-level-6 {\n" - " margin-left: 2em;\n" - "}\n"; - -static const QString SGC_INDEX_CSS_FILE = - "div.sgc-index-title {\n" - " font-size: 2em;\n" - " font-weight: bold;\n" - " margin-bottom: 1em;\n" - " text-align: center;\n" - "}\n\n" - "div.sgc-index-body {\n" - " margin-left: -2em;\n" - "}\n\n" - "div.sgc-index-entry {\n" - " margin-top: 0em;\n" - " margin-bottom: 0.5em;\n" - " margin-left: 3.5em;\n" - " text-indent: -1.5em;\n" - "}\n\n" - "div.sgc-index-new-letter {\n" - " margin-top: 1.5em;\n" - " margin-left: 1.3em;\n" - " margin-bottom: 0.5em;\n" - " font-size: 1.5em;\n" - " font-weight: bold;\n" - " border-bottom: solid black 4px;\n" - " width: 50%;\n" - "}\n"; - -const QString HTML_COVER_SOURCE = -"\n" -"\n" -"\n" -"\n" -" Cover\n" -"\n" -"" -"\n" -"
\n" -" \n" -" \n" -" \n" -"
\n" -"\n" -"\n"; +static const QString SGC_TOC_CSS_FILE = + "div.sgc-toc-title {\n" + " font-size: 2em;\n" + " font-weight: bold;\n" + " margin-bottom: 1em;\n" + " text-align: center;\n" + "}\n\n" + "div.sgc-toc-level-1 {\n" + " margin-left: 0em;\n" + "}\n\n" + "div.sgc-toc-level-2 {\n" + " margin-left: 2em;\n" + "}\n\n" + "div.sgc-toc-level-3 {\n" + " margin-left: 2em;\n" + "}\n\n" + "div.sgc-toc-level-4 {\n" + " margin-left: 2em;\n" + "}\n\n" + "div.sgc-toc-level-5 {\n" + " margin-left: 2em;\n" + "}\n\n" + "div.sgc-toc-level-6 {\n" + " margin-left: 2em;\n" + "}\n"; + +static const QString SGC_INDEX_CSS_FILE = + "div.sgc-index-title {\n" + " font-size: 2em;\n" + " font-weight: bold;\n" + " margin-bottom: 1em;\n" + " text-align: center;\n" + "}\n\n" + "div.sgc-index-body {\n" + " margin-left: -2em;\n" + "}\n\n" + "div.sgc-index-entry {\n" + " margin-top: 0em;\n" + " margin-bottom: 0.5em;\n" + " margin-left: 3.5em;\n" + " text-indent: -1.5em;\n" + "}\n\n" + "div.sgc-index-new-letter {\n" + " margin-top: 1.5em;\n" + " margin-left: 1.3em;\n" + " margin-bottom: 0.5em;\n" + " font-size: 1.5em;\n" + " font-weight: bold;\n" + " border-bottom: solid black 4px;\n" + " width: 50%;\n" + "}\n"; + +const QString HTML_COVER_SOURCE = + "\n" + "\n" + "\n" + "\n" + " Cover\n" + "\n" + "" + "\n" + "
\n" + " \n" + " \n" + " \n" + "
\n" + "\n" + "\n"; Book::Book() : @@ -189,17 +189,17 @@ QString Book::GetPublicationIdentifier() const } -QList< Metadata::MetaElement > Book::GetMetadata() const +QList Book::GetMetadata() const { return GetConstOPF().GetDCMetadata(); } -QList< QVariant > Book::GetMetadataValues(QString text) const +QList Book::GetMetadataValues(QString text) const { return GetConstOPF().GetDCMetadataValues(text); } -void Book::SetMetadata(const QList< Metadata::MetaElement > metadata) +void Book::SetMetadata(const QList metadata) { GetOPF().SetDCMetadata(metadata); SetModified(true); @@ -208,7 +208,7 @@ void Book::SetMetadata(const QList< Metadata::MetaElement > metadata) QString Book::GetFirstUniqueSectionName(QString extension) { // If not files just return the default first name - QList< HTMLResource * > html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(true); + QList html_resources = m_Mainfolder.GetResourceTypeList(true); if (html_resources.count() < 1) { return FIRST_SECTION_NAME; @@ -234,7 +234,7 @@ QString Book::GetFirstUniqueSectionName(QString extension) QList Book::GetHTMLResources() { - return m_Mainfolder.GetResourceTypeList< HTMLResource >(false); + return m_Mainfolder.GetResourceTypeList(false); } HTMLResource &Book::CreateNewHTMLFile() @@ -242,7 +242,7 @@ HTMLResource &Book::CreateNewHTMLFile() TempFolder tempfolder; QString fullfilepath = tempfolder.GetPath() + "/" + GetFirstUniqueSectionName(); Utility::WriteUnicodeTextFile(PLACEHOLDER_TEXT, fullfilepath); - HTMLResource &html_resource = *qobject_cast< HTMLResource * >( + HTMLResource &html_resource = *qobject_cast( &m_Mainfolder.AddContentFileToFolder(fullfilepath)); SetModified(true); return html_resource; @@ -264,7 +264,7 @@ HTMLResource &Book::CreateEmptyHTMLFile(HTMLResource &resource) new_resource.SetText(EMPTY_HTML_FILE); if (&resource != NULL) { - QList< HTMLResource * > html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(true); + QList html_resources = m_Mainfolder.GetResourceTypeList(true); int reading_order = GetOPF().GetReadingOrder(resource) + 1; if (reading_order > 0) { @@ -284,7 +284,7 @@ void Book::MoveResourceAfter(HTMLResource &from_resource, HTMLResource &to_resou return; } - QList< HTMLResource * > html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(true); + QList html_resources = m_Mainfolder.GetResourceTypeList(true); int to_after_reading_order = GetOPF().GetReadingOrder(to_resource) + 1; int from_reading_order = GetOPF().GetReadingOrder(from_resource) ; @@ -307,7 +307,7 @@ HTMLResource &Book::CreateHTMLCoverFile(QString text) html_resource.SaveToDisk(); // Move file to start of book. - QList< HTMLResource * > html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(true); + QList html_resources = m_Mainfolder.GetResourceTypeList(true); html_resources.removeOne(&html_resource); html_resources.prepend(&html_resource); GetOPF().UpdateSpineOrder(html_resources); @@ -338,7 +338,7 @@ CSSResource &Book::CreateEmptyCSSFile() TempFolder tempfolder; QString fullfilepath = tempfolder.GetPath() + "/" + m_Mainfolder.GetUniqueFilenameVersion(FIRST_CSS_NAME); Utility::WriteUnicodeTextFile("", fullfilepath); - CSSResource &css_resource = *qobject_cast< CSSResource * >( + CSSResource &css_resource = *qobject_cast( &m_Mainfolder.AddContentFileToFolder(fullfilepath)); SetModified(true); return css_resource; @@ -350,7 +350,7 @@ SVGResource &Book::CreateEmptySVGFile() TempFolder tempfolder; QString fullfilepath = tempfolder.GetPath() + "/" + m_Mainfolder.GetUniqueFilenameVersion(FIRST_SVG_NAME); Utility::WriteUnicodeTextFile("", fullfilepath); - SVGResource &svg_resource = *qobject_cast< SVGResource * >( + SVGResource &svg_resource = *qobject_cast( &m_Mainfolder.AddContentFileToFolder(fullfilepath)); SetModified(true); return svg_resource; @@ -362,7 +362,7 @@ HTMLResource &Book::CreateSectionBreakOriginalResource(const QString &content, H const QString originating_filename = originating_resource.Filename(); int reading_order = GetOPF().GetReadingOrder(originating_resource); Q_ASSERT(reading_order >= 0); - QList< HTMLResource * > html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(true); + QList html_resources = m_Mainfolder.GetResourceTypeList(true); QString old_extension = originating_filename.right(originating_filename.length() - originating_filename.lastIndexOf(".")); originating_resource.RenameTo(GetFirstUniqueSectionName(old_extension)); HTMLResource &new_resource = CreateNewHTMLFile(); @@ -375,7 +375,7 @@ HTMLResource &Book::CreateSectionBreakOriginalResource(const QString &content, H GetOPF().UpdateSpineOrder(html_resources); // Update references between the two new files. Since they used to be one single file we can // assume that each id is unique (if they aren't then the references were broken anyway). - QList< HTMLResource * > new_files; + QList new_files; new_files.append(&originating_resource); new_files.append(&new_resource); AnchorUpdates::UpdateAllAnchorsWithIDs(new_files); @@ -405,11 +405,11 @@ void Book::CreateNewSections(const QStringList &new_sections, HTMLResource &orig } TempFolder tempfolder; - QFutureSynchronizer< NewSectionResult > sync; - QList< HTMLResource * > html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(true); + QFutureSynchronizer sync; + QList html_resources = m_Mainfolder.GetResourceTypeList(true); // A list of all the files that have not been involved in the split. // This will be used later when anchors are updated. - QList< HTMLResource * > other_files = html_resources; + QList other_files = html_resources; other_files.removeOne(&original_resource); int next_reading_order; @@ -436,9 +436,9 @@ void Book::CreateNewSections(const QStringList &new_sections, HTMLResource &orig } sync.waitForFinished(); - QList< HTMLResource * > new_files; + QList new_files; new_files.append(&original_resource); - QList< QFuture< NewSectionResult > > futures = sync.futures(); + QList> futures = sync.futures(); if (original_position == -1) { // Add new sections to the end of the book @@ -498,8 +498,8 @@ bool Book::IsDataOnDiskWellFormed(HTMLResource &html_resource) Resource *Book::PreviousResource(Resource *resource) { const QString defunct_filename = resource->Filename(); - QList< HTMLResource * > html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(true); - HTMLResource *html_resource = qobject_cast< HTMLResource * >(resource); + QList html_resources = m_Mainfolder.GetResourceTypeList(true); + HTMLResource *html_resource = qobject_cast(resource); int previous_file_reading_order = html_resources.indexOf(html_resource) - 1; if (previous_file_reading_order < 0) { @@ -507,18 +507,18 @@ Resource *Book::PreviousResource(Resource *resource) } HTMLResource &previous_html = *html_resources[ previous_file_reading_order ]; - return qobject_cast< Resource *>(&previous_html); + return qobject_cast(&previous_html); } -QHash < QString, QList< XhtmlDoc::XMLElement > > Book::GetLinkElements() +QHash > Book::GetLinkElements() { - QHash< QString, QList< XhtmlDoc::XMLElement > > links_in_html; - const QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(false); - QFuture< boost::tuple > > future = QtConcurrent::mapped(html_resources, GetLinkElementsInHTMLFileMapped); + QHash> links_in_html; + const QList html_resources = m_Mainfolder.GetResourceTypeList(false); + QFuture>> future = QtConcurrent::mapped(html_resources, GetLinkElementsInHTMLFileMapped); for (int i = 0; i < future.results().count(); i++) { QString filename; - QList< XhtmlDoc::XMLElement > links; + QList links; tie(filename, links) = future.resultAt(i); // Each target entry has a list of filenames that contain it links_in_html[filename] = links; @@ -527,7 +527,7 @@ QHash < QString, QList< XhtmlDoc::XMLElement > > Book::GetLinkElements() return links_in_html; } -tuple > Book::GetLinkElementsInHTMLFileMapped(HTMLResource *html_resource) +tuple> Book::GetLinkElementsInHTMLFileMapped(HTMLResource *html_resource) { return make_tuple(html_resource->Filename(), XhtmlDoc::GetTagsInDocument(html_resource->GetText(), "a")); @@ -537,8 +537,8 @@ tuple > Book::GetLinkElementsInHTMLFileMa QStringList Book::GetStyleUrlsInHTMLFiles() { QStringList images_in_html; - const QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(false); - QFuture< boost::tuple > future = QtConcurrent::mapped(html_resources, GetStyleUrlsInHTMLFileMapped); + const QList html_resources = m_Mainfolder.GetResourceTypeList(false); + QFuture> future = QtConcurrent::mapped(html_resources, GetStyleUrlsInHTMLFileMapped); for (int i = 0; i < future.results().count(); i++) { QString filename; @@ -560,8 +560,8 @@ tuple Book::GetStyleUrlsInHTMLFileMapped(HTMLResource *htm QHash Book::GetIdsInHTMLFiles() { QHash ids_in_html; - const QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(false); - QFuture< boost::tuple > future = QtConcurrent::mapped(html_resources, GetIdsInHTMLFileMapped); + const QList html_resources = m_Mainfolder.GetResourceTypeList(false); + QFuture> future = QtConcurrent::mapped(html_resources, GetIdsInHTMLFileMapped); for (int i = 0; i < future.results().count(); i++) { QString filename; @@ -613,8 +613,8 @@ QStringList Book::GetIdsInHrefs() QHash Book::GetHrefsInHTMLFiles() { QHash hrefs_in_html; - const QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(false); - QFuture< boost::tuple > future = QtConcurrent::mapped(html_resources, GetHrefsInHTMLFileMapped); + const QList html_resources = m_Mainfolder.GetResourceTypeList(false); + QFuture> future = QtConcurrent::mapped(html_resources, GetHrefsInHTMLFileMapped); for (int i = 0; i < future.results().count(); i++) { QString filename; @@ -636,9 +636,9 @@ tuple Book::GetHrefsInHTMLFileMapped(HTMLResource *html_re QHash Book::GetClassesInHTMLFiles() { QHash classes_in_html; - const QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(false); + const QList html_resources = m_Mainfolder.GetResourceTypeList(false); - QFuture< tuple > future = QtConcurrent::mapped(html_resources, GetClassesInHTMLFileMapped); + QFuture> future = QtConcurrent::mapped(html_resources, GetClassesInHTMLFileMapped); for (int i = 0; i < future.results().count(); i++) { QString filename; QStringList class_names; @@ -660,7 +660,7 @@ tuple Book::GetClassesInHTMLFileMapped(HTMLResource *html_ QStringList Book::GetClassesInHTMLFile(QString filename) { - QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(true); + QList html_resources = m_Mainfolder.GetResourceTypeList(true); foreach(HTMLResource * html_resource, html_resources) { if (html_resource->Filename() == filename) { return XhtmlDoc::GetAllDescendantClasses(*XhtmlDoc::LoadTextIntoDocument(html_resource->GetText()).get()->getDocumentElement()); @@ -672,8 +672,8 @@ QStringList Book::GetClassesInHTMLFile(QString filename) QHash Book::GetImagesInHTMLFiles() { QHash media_in_html; - const QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(false); - QFuture< tuple > future = QtConcurrent::mapped(html_resources, GetImagesInHTMLFileMapped); + const QList html_resources = m_Mainfolder.GetResourceTypeList(false); + QFuture> future = QtConcurrent::mapped(html_resources, GetImagesInHTMLFileMapped); for (int i = 0; i < future.results().count(); i++) { QString filename; @@ -688,8 +688,8 @@ QHash Book::GetImagesInHTMLFiles() QHash Book::GetVideoInHTMLFiles() { QHash media_in_html; - const QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(false); - QFuture< tuple > future = QtConcurrent::mapped(html_resources, GetVideoInHTMLFileMapped); + const QList html_resources = m_Mainfolder.GetResourceTypeList(false); + QFuture> future = QtConcurrent::mapped(html_resources, GetVideoInHTMLFileMapped); for (int i = 0; i < future.results().count(); i++) { QString filename; @@ -704,8 +704,8 @@ QHash Book::GetVideoInHTMLFiles() QHash Book::GetAudioInHTMLFiles() { QHash media_in_html; - const QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(false); - QFuture< tuple > future = QtConcurrent::mapped(html_resources, GetAudioInHTMLFileMapped); + const QList html_resources = m_Mainfolder.GetResourceTypeList(false); + QFuture> future = QtConcurrent::mapped(html_resources, GetAudioInHTMLFileMapped); for (int i = 0; i < future.results().count(); i++) { QString filename; @@ -720,9 +720,9 @@ QHash Book::GetAudioInHTMLFiles() QHash Book::GetHTMLFilesUsingMedia() { QHash html_files; - const QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(false); + const QList html_resources = m_Mainfolder.GetResourceTypeList(false); - QFuture< tuple > future = QtConcurrent::mapped(html_resources, GetMediaInHTMLFileMapped); + QFuture> future = QtConcurrent::mapped(html_resources, GetMediaInHTMLFileMapped); for (int i = 0; i < future.results().count(); i++) { QString html_filename; @@ -739,9 +739,9 @@ QHash Book::GetHTMLFilesUsingMedia() QHash Book::GetHTMLFilesUsingImages() { QHash html_files; - const QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(false); + const QList html_resources = m_Mainfolder.GetResourceTypeList(false); - QFuture< tuple > future = QtConcurrent::mapped(html_resources, GetImagesInHTMLFileMapped); + QFuture> future = QtConcurrent::mapped(html_resources, GetImagesInHTMLFileMapped); for (int i = 0; i < future.results().count(); i++) { QString html_filename; @@ -784,7 +784,7 @@ QList Book::GetNonWellFormedHTMLFiles() { QList malformed_resources; - foreach (HTMLResource *h, m_Mainfolder.GetResourceTypeList< HTMLResource >(false)) { + foreach (HTMLResource *h, m_Mainfolder.GetResourceTypeList(false)) { if (!IsDataWellFormed(*h)) { malformed_resources << h; } @@ -796,7 +796,7 @@ QList Book::GetNonWellFormedHTMLFiles() QSet Book::GetWordsInHTMLFiles() { QStringList all_words; - const QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(false); + const QList html_resources = m_Mainfolder.GetResourceTypeList(false); QFuture future = QtConcurrent::mapped(html_resources, GetWordsInHTMLFileMapped); for (int i = 0; i < future.results().count(); i++) { @@ -815,7 +815,7 @@ QStringList Book::GetWordsInHTMLFileMapped(HTMLResource *html_resource) QHash Book::GetUniqueWordsInHTMLFiles() { QHash all_words; - const QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(false); + const QList html_resources = m_Mainfolder.GetResourceTypeList(false); QFuture future = QtConcurrent::mapped(html_resources, GetWordsInHTMLFileMapped); for (int i = 0; i < future.results().count(); i++) { @@ -823,8 +823,7 @@ QHash Book::GetUniqueWordsInHTMLFiles() foreach (QString word, result) { if (all_words.contains(word)) { all_words[word]++; - } - else { + } else { all_words[word] = 1; } } @@ -836,8 +835,8 @@ QHash Book::GetUniqueWordsInHTMLFiles() QHash Book::GetStylesheetsInHTMLFiles() { QHash links_in_html; - const QList html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(false); - QFuture< boost::tuple > future = QtConcurrent::mapped(html_resources, GetStylesheetsInHTMLFileMapped); + const QList html_resources = m_Mainfolder.GetResourceTypeList(false); + QFuture> future = QtConcurrent::mapped(html_resources, GetStylesheetsInHTMLFileMapped); for (int i = 0; i < future.results().count(); i++) { QString filename; @@ -933,20 +932,20 @@ Resource *Book::MergeResources(QList resources) qApp->processEvents(QEventLoop::ExcludeUserInputEvents); // It is the user's responsibility to ensure that all ids used across the two merged files are unique. // Reconcile all references to the files that were merged. - QList< HTMLResource * > html_resources = m_Mainfolder.GetResourceTypeList< HTMLResource >(true); + QList html_resources = m_Mainfolder.GetResourceTypeList(true); AnchorUpdates::UpdateAllAnchors(html_resources, merged_filenames, &sink_html_resource); SetModified(true); return NULL; } -QList Book::GetAllResources() +QList Book::GetAllResources() { return m_Mainfolder.GetResourceList(); } void Book::SaveAllResourcesToDisk() { - QList< Resource * > resources = m_Mainfolder.GetResourceList(); + QList resources = m_Mainfolder.GetResourceList(); m_Mainfolder.SuspendWatchingResources(); QtConcurrent::blockingMap(resources, SaveOneResourceToDisk); m_Mainfolder.ResumeWatchingResources(); @@ -961,7 +960,7 @@ bool Book::IsModified() const bool Book::HasObfuscatedFonts() const { - QList< FontResource * > font_resources = m_Mainfolder.GetResourceTypeList< FontResource >(); + QList font_resources = m_Mainfolder.GetResourceTypeList(); if (font_resources.empty()) { return false; @@ -1000,7 +999,7 @@ void Book::SaveOneResourceToDisk(Resource *resource) Book::NewSectionResult Book::CreateOneNewSection(NewSection section_info) { - return CreateOneNewSection(section_info, QHash< QString, QString >()); + return CreateOneNewSection(section_info, QHash()); } @@ -1010,7 +1009,7 @@ Book::NewSectionResult Book::CreateOneNewSection(NewSection section_info, QString filename = section_info.new_file_prefix % "_" % QString("%1").arg(section_info.file_suffix + 1, 4, 10, QChar('0')) + section_info.file_extension; QString fullfilepath = section_info.temp_folder_path + "/" + filename; Utility::WriteUnicodeTextFile("PLACEHOLDER", fullfilepath); - HTMLResource *html_resource = qobject_cast< HTMLResource * >( + HTMLResource *html_resource = qobject_cast( &m_Mainfolder.AddContentFileToFolder(fullfilepath)); Q_ASSERT(html_resource); @@ -1020,7 +1019,7 @@ Book::NewSectionResult Book::CreateOneNewSection(NewSection section_info, html_resource->SetText( XhtmlDoc::GetDomDocumentAsString(*PerformHTMLUpdates(CleanSource::Clean(section_info.source), html_updates, - QHash< QString, QString >() + QHash() )().get())); } diff --git a/src/Sigil/BookManipulation/Book.h b/src/Sigil/BookManipulation/Book.h index e3b946fe72..39a52eb4f6 100644 --- a/src/Sigil/BookManipulation/Book.h +++ b/src/Sigil/BookManipulation/Book.h @@ -112,14 +112,14 @@ class Book : public QObject * * @return A list of the book's metadata. */ - QList< Metadata::MetaElement > GetMetadata() const; + QList GetMetadata() const; /** * Returns the values for a specific metadata name. * * @return A list of values */ - QList< QVariant > GetMetadataValues(QString text) const; + QList GetMetadataValues(QString text) const; /** * Replaces the book's current meta information with the received metadata. @@ -128,7 +128,7 @@ class Book : public QObject * are the metadata names, and the values are the lists of * metadata values for that metadata name. */ - void SetMetadata(const QList< Metadata::MetaElement > metadata); + void SetMetadata(const QList metadata); QString GetFirstUniqueSectionName(QString extension = QString()); @@ -206,8 +206,8 @@ class Book : public QObject */ Resource *PreviousResource(Resource *resource); - QHash < QString, QList< XhtmlDoc::XMLElement > > GetLinkElements(); - static boost::tuple > GetLinkElementsInHTMLFileMapped(HTMLResource *html_resource); + QHash > GetLinkElements(); + static boost::tuple> GetLinkElementsInHTMLFileMapped(HTMLResource *html_resource); QStringList GetStyleUrlsInHTMLFiles(); static boost::tuple GetStyleUrlsInHTMLFileMapped(HTMLResource *html_resource); @@ -253,7 +253,7 @@ class Book : public QObject */ Resource *MergeResources(QList resources); - QList GetAllResources(); + QList GetAllResources(); /** * Makes sure that all the resources have saved the state of @@ -379,7 +379,7 @@ public slots: * @param html_updates Any reference updates that need to be performed. */ NewSectionResult CreateOneNewSection(NewSection section_info, - const QHash< QString, QString > &html_updates); + const QHash &html_updates); //////////////////////////// @@ -397,7 +397,7 @@ public slots: * are the metadata names, and the values are the lists of * metadata values for that metadata name. */ - QHash< QString, QList< QVariant > > m_Metadata; + QHash> m_Metadata; /** * Stores the modified state of the book. diff --git a/src/Sigil/BookManipulation/BookReports.cpp b/src/Sigil/BookManipulation/BookReports.cpp index b1af4fbcb0..d20659511d 100644 --- a/src/Sigil/BookManipulation/BookReports.cpp +++ b/src/Sigil/BookManipulation/BookReports.cpp @@ -34,10 +34,10 @@ #include "Misc/CSSInfo.h" #include "Misc/SettingsStore.h" -QList BookReports::GetHTMLClassUsage(QSharedPointer< Book > book, bool show_progress) +QList BookReports::GetHTMLClassUsage(QSharedPointer book, bool show_progress) { - QList html_resources = book->GetFolderKeeper().GetResourceTypeList< HTMLResource >(false); - QList css_resources = book->GetFolderKeeper().GetResourceTypeList< CSSResource >(false); + QList html_resources = book->GetFolderKeeper().GetResourceTypeList(false); + QList css_resources = book->GetFolderKeeper().GetResourceTypeList(false); QList html_classes_usage; // Save each CSS file's text so we don't have to reload it when checking each HTML file QHash css_text; @@ -104,9 +104,9 @@ QList BookReports::GetHTMLClassUsage(QSharedPointer< B return html_classes_usage; } -QList BookReports::GetCSSSelectorUsage(QSharedPointer< Book > book, QList html_classes_usage) +QList BookReports::GetCSSSelectorUsage(QSharedPointer book, QList html_classes_usage) { - QList css_resources = book->GetFolderKeeper().GetResourceTypeList< CSSResource >(false); + QList css_resources = book->GetFolderKeeper().GetResourceTypeList(false); QList css_selectors_usage; // Now check the CSS files to see if their classes appear in an HTML file foreach(CSSResource * css_resource, css_resources) { diff --git a/src/Sigil/BookManipulation/BookReports.h b/src/Sigil/BookManipulation/BookReports.h index ad2632a981..84e40a703b 100644 --- a/src/Sigil/BookManipulation/BookReports.h +++ b/src/Sigil/BookManipulation/BookReports.h @@ -46,8 +46,8 @@ class BookReports int css_selector_position; }; - static QList GetHTMLClassUsage(QSharedPointer< Book > book, bool show_progress = false); - static QList GetCSSSelectorUsage(QSharedPointer< Book > book, QList html_classes_usage); + static QList GetHTMLClassUsage(QSharedPointer book, bool show_progress = false); + static QList GetCSSSelectorUsage(QSharedPointer book, QList html_classes_usage); }; #endif // BOOKREPORTS_H diff --git a/src/Sigil/BookManipulation/CleanSource.cpp b/src/Sigil/BookManipulation/CleanSource.cpp index 82f43c3c67..b3c80b5a85 100644 --- a/src/Sigil/BookManipulation/CleanSource.cpp +++ b/src/Sigil/BookManipulation/CleanSource.cpp @@ -207,7 +207,7 @@ QString CleanSource::CleanCSS(const QString &source, int old_num_styles) // of a single CSS style tag QStringList CleanSource::CSSStyleTags(const QString &source) { - QList< XhtmlDoc::XMLElement > style_tag_nodes; + QList style_tag_nodes; try { style_tag_nodes = XhtmlDoc::GetTagsInHead(source, "style"); @@ -427,15 +427,15 @@ QString CleanSource::WriteNewCSSStyleTags(const QString &source, const QStringLi } -tuple< QString, QStringList > CleanSource::RemoveRedundantClasses(const QString &source, const QStringList &css_style_tags) +tuple CleanSource::RemoveRedundantClasses(const QString &source, const QStringList &css_style_tags) { - QHash< QString, QString > redundant_classes = GetRedundantClasses(css_style_tags); + QHash redundant_classes = GetRedundantClasses(css_style_tags); return make_tuple(RemoveRedundantClassesSource(source, redundant_classes), RemoveRedundantClassesTags(css_style_tags, redundant_classes)); } // Removes redundant CSS classes from the provided CSS style tags -QStringList CleanSource::RemoveRedundantClassesTags(const QStringList &css_style_tags, const QHash< QString, QString > redundant_classes) +QStringList CleanSource::RemoveRedundantClassesTags(const QStringList &css_style_tags, const QHash redundant_classes) { QStringList new_css_style_tags = css_style_tags; QStringList last_tag_styles = new_css_style_tags.last().split(QChar('\n')); @@ -451,7 +451,7 @@ QStringList CleanSource::RemoveRedundantClassesTags(const QStringList &css_style // Removes redundant CSS classes from the provided XHTML source code; // Updates references to older classes that do the same thing -QString CleanSource::RemoveRedundantClassesSource(const QString &source, const QHash< QString, QString > redundant_classes) +QString CleanSource::RemoveRedundantClassesSource(const QString &source, const QHash redundant_classes) { QString newsource = source; foreach(QString key, redundant_classes.keys()) { @@ -471,9 +471,9 @@ QString CleanSource::RemoveRedundantClassesSource(const QString &source, const Q // Returns a QHash with keys being the new redundant CSS classes, // and the values being the old classes that already do the job of the new ones. -QHash< QString, QString > CleanSource::GetRedundantClasses(const QStringList &css_style_tags) +QHash CleanSource::GetRedundantClasses(const QStringList &css_style_tags) { - QHash< QString, QString > redundant_classes; + QHash redundant_classes; // HACK: This whole concept is really ugly. // a) We need to fix Tidy so it doesn't create useless new classes. // b) We need a real CSS parser. One that knows which HTML element @@ -607,8 +607,8 @@ QString CleanSource::CharToEntity(const QString &source) { SettingsStore settings; QString new_source = source; - QList< std::pair < ushort, QString > > codenames = settings.preserveEntityCodeNames(); - std::pair < ushort, QString > epair; + QList> codenames = settings.preserveEntityCodeNames(); + std::pair epair; foreach(epair, codenames) { new_source.replace(QChar(epair.first), epair.second); } diff --git a/src/Sigil/BookManipulation/CleanSource.h b/src/Sigil/BookManipulation/CleanSource.h index 0bf10b6ee6..d255db36a1 100644 --- a/src/Sigil/BookManipulation/CleanSource.h +++ b/src/Sigil/BookManipulation/CleanSource.h @@ -108,21 +108,21 @@ class CleanSource // Removes redundant CSS classes from the style tags and source code; // Calls more specific version. - static tuple< QString, QStringList > RemoveRedundantClasses(const QString &source, + static tuple RemoveRedundantClasses(const QString &source, const QStringList &css_style_tags); // Removes redundant CSS classes from the provided CSS style tags static QStringList RemoveRedundantClassesTags(const QStringList &css_style_tags, - const QHash< QString, QString > redundant_classes); + const QHash redundant_classes); // Removes redundant CSS classes from the provided XHTML source code; // Updates references to older classes that do the same thing static QString RemoveRedundantClassesSource(const QString &source, - const QHash< QString, QString > redundant_classes); + const QHash redundant_classes); // Returns a QHash with keys being the new redundant CSS classes, // and the values the old classes that already do the job of the new ones. - static QHash< QString, QString > GetRedundantClasses(const QStringList &css_style_tags); + static QHash GetRedundantClasses(const QStringList &css_style_tags); /** * Removes HTML meta tags with charset declarations. diff --git a/src/Sigil/BookManipulation/FolderKeeper.cpp b/src/Sigil/BookManipulation/FolderKeeper.cpp index 0489bfd308..9faf5b3e43 100644 --- a/src/Sigil/BookManipulation/FolderKeeper.cpp +++ b/src/Sigil/BookManipulation/FolderKeeper.cpp @@ -278,12 +278,12 @@ QStringList FolderKeeper::GetSortedContentFilesList() const } -QList< Resource * > FolderKeeper::GetResourceList() const +QList FolderKeeper::GetResourceList() const { return m_Resources.values(); } -QList< Resource * > FolderKeeper::GetResourceListByType(Resource::ResourceType type) const +QList FolderKeeper::GetResourceListByType(Resource::ResourceType type) const { QList resources; foreach (Resource *resource, m_Resources.values()) { diff --git a/src/Sigil/BookManipulation/FolderKeeper.h b/src/Sigil/BookManipulation/FolderKeeper.h index 5e14bf03cf..675136ef63 100644 --- a/src/Sigil/BookManipulation/FolderKeeper.h +++ b/src/Sigil/BookManipulation/FolderKeeper.h @@ -120,9 +120,9 @@ class FolderKeeper : public QObject * * @return The resource list. */ - QList< Resource * > GetResourceList() const; + QList GetResourceList() const; - QList< Resource * > GetResourceListByType(Resource::ResourceType type) const; + QList GetResourceListByType(Resource::ResourceType type) const; /** * Returns a list of all resources of type T in a list @@ -131,8 +131,8 @@ class FolderKeeper : public QObject * @param should_be_sorted If \c true, the list is sorted. * @return The resource list. */ - template< class T > - QList< T * > GetResourceTypeList(bool should_be_sorted = false) const; + template + QList GetResourceTypeList(bool should_be_sorted = false) const; /** * Returns a list of all resources of type T in a list @@ -141,8 +141,8 @@ class FolderKeeper : public QObject * @param should_be_sorted If \c true, the list is sorted. * @return The resource list. */ - template< class T > - QList< Resource * > GetResourceTypeAsGenericList(bool should_be_sorted = false) const; + template + QList GetResourceTypeAsGenericList(bool should_be_sorted = false) const; /** * Returns a resource with the given identifier. @@ -288,11 +288,11 @@ private slots: * @param second_item The second item in the comparison. * @return The less-than comparison result. */ - template< typename T > + template static bool PointerLessThan(T *first_item, T *second_item); - template< typename T > - QList< T * > ListResourceSort(const QList< T * > &resource_list) const; + template + QList ListResourceSort(const QList &resource_list) const; /////////////////////////////// @@ -316,7 +316,7 @@ private slots: * The keys are the UUID identifiers, the values * are the pointers to the actual resources. */ - QHash< QString, Resource * > m_Resources; + QHash m_Resources; /** * Ensures thread-safe access to the m_Resources hash. @@ -349,12 +349,12 @@ private slots: }; -template< class T > -QList< T * > FolderKeeper::GetResourceTypeList(bool should_be_sorted) const +template +QList FolderKeeper::GetResourceTypeList(bool should_be_sorted) const { - QList< T * > onetype_resources; + QList onetype_resources; foreach(Resource * resource, m_Resources.values()) { - T *type_resource = qobject_cast< T * >(resource); + T *type_resource = qobject_cast(resource); if (type_resource) { onetype_resources.append(type_resource); @@ -368,12 +368,12 @@ QList< T * > FolderKeeper::GetResourceTypeList(bool should_be_sorted) const return onetype_resources; } -template< class T > -QList< Resource * > FolderKeeper::GetResourceTypeAsGenericList(bool should_be_sorted) const +template +QList FolderKeeper::GetResourceTypeAsGenericList(bool should_be_sorted) const { - QList< Resource * > resources; + QList resources; foreach(Resource * resource, m_Resources.values()) { - T *type_resource = qobject_cast< T * >(resource); + T *type_resource = qobject_cast(resource); if (type_resource) { resources.append(resource); @@ -388,11 +388,11 @@ QList< Resource * > FolderKeeper::GetResourceTypeAsGenericList(bool should_be_so } -template< typename T > inline -QList< T * > FolderKeeper::ListResourceSort(const QList< T * > &resource_list) const +template inline +QList FolderKeeper::ListResourceSort(const QList &resource_list) const { - QList< T * > sorted_list = resource_list; - qSort(sorted_list.begin(), sorted_list.end(), FolderKeeper::PointerLessThan< T >); + QList sorted_list = resource_list; + qSort(sorted_list.begin(), sorted_list.end(), FolderKeeper::PointerLessThan); return sorted_list; } @@ -400,11 +400,11 @@ QList< T * > FolderKeeper::ListResourceSort(const QList< T * > &resource_list) // This has to be inline, otherwise we get linker errors about this // specialization already being defined. template<> inline -QList< HTMLResource * > FolderKeeper::ListResourceSort< HTMLResource >(const QList< HTMLResource * > &resource_list) const +QList FolderKeeper::ListResourceSort(const QList &resource_list) const { QStringList spine_order_filenames = GetOPF().GetSpineOrderFilenames(); - QList< HTMLResource * > htmls = resource_list; - QList< HTMLResource * > sorted_htmls; + QList htmls = resource_list; + QList sorted_htmls; foreach(const QString & spine_filename, spine_order_filenames) { for (int i = 0; i < htmls.count(); ++i) { if (spine_filename == htmls[ i ]->Filename()) { @@ -422,7 +422,7 @@ QList< HTMLResource * > FolderKeeper::ListResourceSort< HTMLResource >(const QLi } -template< typename T > inline +template inline bool FolderKeeper::PointerLessThan(T *first_item, T *second_item) { Q_ASSERT(first_item); diff --git a/src/Sigil/BookManipulation/GuideSemantics.cpp b/src/Sigil/BookManipulation/GuideSemantics.cpp index 2850b44ff3..4ceb830195 100644 --- a/src/Sigil/BookManipulation/GuideSemantics.cpp +++ b/src/Sigil/BookManipulation/GuideSemantics.cpp @@ -47,7 +47,7 @@ GuideSemantics &GuideSemantics::Instance() } -const QHash< int, tuple< QString, QString > > &GuideSemantics::GetGuideTypeMapping() +const QHash> &GuideSemantics::GetGuideTypeMapping() { return m_GuideTypeMapping; } diff --git a/src/Sigil/BookManipulation/GuideSemantics.h b/src/Sigil/BookManipulation/GuideSemantics.h index d204be2920..d48b61b7b7 100644 --- a/src/Sigil/BookManipulation/GuideSemantics.h +++ b/src/Sigil/BookManipulation/GuideSemantics.h @@ -77,7 +77,7 @@ class GuideSemantics * * @return The reference. */ - const QHash< int, tuple< QString, QString > > &GetGuideTypeMapping(); + const QHash> &GetGuideTypeMapping(); /** * Maps a reference type string ("loi", "cover" etc.) @@ -126,13 +126,13 @@ class GuideSemantics * A mapping between GuideSemanticType * and the reference type and default title. */ - QHash< int, tuple< QString, QString > > m_GuideTypeMapping; + QHash> m_GuideTypeMapping; /** * A mapping of a reference type string ("loi", "cover" etc.) * to a value in the GuideSemanticType enum. */ - QHash< QString, int > m_ReferenceTypeToGuideEnum; + QHash m_ReferenceTypeToGuideEnum; }; diff --git a/src/Sigil/BookManipulation/Headings.cpp b/src/Sigil/BookManipulation/Headings.cpp index b83a2f01c1..1735e8d3d5 100644 --- a/src/Sigil/BookManipulation/Headings.cpp +++ b/src/Sigil/BookManipulation/Headings.cpp @@ -51,13 +51,13 @@ const QString OLD_SIGIL_NOT_IN_TOC_CLASS = "sigilNotInTOC"; // Returns a list of headings from the provided XHTML source; // the list is flat, the headings are *not* in a hierarchy tree -QList< Headings::Heading > Headings::GetHeadingList(QList< HTMLResource * > html_resources, +QList Headings::GetHeadingList(QList html_resources, bool include_unwanted_headings) { - QList< Headings::Heading > heading_list; - QList< QList< Headings::Heading > > per_file_headings = - QtConcurrent::blockingMapped(html_resources, - boost::bind(GetHeadingListForOneFile, _1, include_unwanted_headings)); + QList heading_list; + QList> per_file_headings = + QtConcurrent::blockingMapped(html_resources, + boost::bind(GetHeadingListForOneFile, _1, include_unwanted_headings)); for (int i = 0; i < per_file_headings.count(); ++i) { heading_list.append(per_file_headings.at(i)); @@ -67,7 +67,7 @@ QList< Headings::Heading > Headings::GetHeadingList(QList< HTMLResource * > html } -QList< Headings::Heading > Headings::GetHeadingListForOneFile(HTMLResource *html_resource, +QList Headings::GetHeadingListForOneFile(HTMLResource *html_resource, bool include_unwanted_headings) { Q_ASSERT(html_resource); @@ -75,7 +75,7 @@ QList< Headings::Heading > Headings::GetHeadingListForOneFile(HTMLResource *html // not a have reference and the DOMDocument will be destroyed. shared_ptr d = XhtmlDoc::LoadTextIntoDocument(html_resource->GetText()); const xc::DOMDocument &document = *d.get(); - QList< xc::DOMElement *> dom_elements = XhtmlDoc::GetTagMatchingDescendants(document, "body"); + QList dom_elements = XhtmlDoc::GetTagMatchingDescendants(document, "body"); // We want to ensure we don't try to get an element out of an empty list. // This could happen if there is no body but there should never be an HTMLResource @@ -87,7 +87,7 @@ QList< Headings::Heading > Headings::GetHeadingListForOneFile(HTMLResource *html xc::DOMElement &body_element = *dom_elements.at(0); QList heading_nodes = XhtmlDoc::GetTagMatchingDescendants(document, HEADING_TAGS); int num_heading_nodes = heading_nodes.count(); - QList< Headings::Heading > headings; + QList headings; for (int i = 0; i < num_heading_nodes; ++i) { xc::DOMElement &element = *heading_nodes.at(i); @@ -125,9 +125,9 @@ QList< Headings::Heading > Headings::GetHeadingListForOneFile(HTMLResource *html // Takes a flat list of headings and returns a list with those // headings sorted into a hierarchy -QList< Headings::Heading > Headings::MakeHeadingHeirarchy(const QList< Heading > &headings) +QList Headings::MakeHeadingHeirarchy(const QList &headings) { - QList< Heading > ordered_headings = headings; + QList ordered_headings = headings; for (int i = 0; i < ordered_headings.size(); ++i) { // As long as the headings after this one are @@ -152,9 +152,9 @@ QList< Headings::Heading > Headings::MakeHeadingHeirarchy(const QList< Heading > } -QList< Headings::Heading > Headings::GetFlattenedHeadings(const QList< Heading > &headings) +QList Headings::GetFlattenedHeadings(const QList &headings) { - QList< Heading > flat_headings; + QList flat_headings; foreach(Heading heading, headings) { flat_headings.append(FlattenHeadingNode(heading)); } @@ -164,9 +164,9 @@ QList< Headings::Heading > Headings::GetFlattenedHeadings(const QList< Heading > // Flattens the provided heading node and its children // into a list and returns it -QList< Headings::Heading > Headings::FlattenHeadingNode(Heading heading) +QList Headings::FlattenHeadingNode(Heading heading) { - QList< Heading > my_headings; + QList my_headings; my_headings.append(heading); foreach(Heading child_heading, heading.children) { my_headings.append(FlattenHeadingNode(child_heading)); diff --git a/src/Sigil/BookManipulation/Headings.h b/src/Sigil/BookManipulation/Headings.h index 0eb6504272..8b0f554a7d 100644 --- a/src/Sigil/BookManipulation/Headings.h +++ b/src/Sigil/BookManipulation/Headings.h @@ -75,7 +75,7 @@ class Headings // The headings 'below' this one // (those that appear after it in the source and // are of higher level/smaller size) - QList< Heading > children; + QList children; // Have we made a change to the document using the TOC dialog bool is_changed; @@ -93,23 +93,23 @@ class Headings // the list is flat, the headings are *not* in a hierarchy tree. // Set include_unwanted_headings to true to get headings that the // user has marked as unwanted. - static QList< Heading > GetHeadingList(QList< HTMLResource * > html_resources, - bool include_unwanted_headings = false); + static QList GetHeadingList(QList html_resources, + bool include_unwanted_headings = false); - static QList< Heading > GetHeadingListForOneFile(HTMLResource *html_resource, + static QList GetHeadingListForOneFile(HTMLResource *html_resource, bool include_unwanted_headings = false); // Takes a flat list of headings and returns a list with those // headings sorted into a hierarchy - static QList< Heading > MakeHeadingHeirarchy(const QList< Heading > &headings); + static QList MakeHeadingHeirarchy(const QList &headings); // Takes a hierarchical list of headings and converts it into a flat list - static QList< Heading > GetFlattenedHeadings(const QList< Heading > &headings); + static QList GetFlattenedHeadings(const QList &headings); private: // Flattens the provided heading node and its children // into a list and returns it - static QList< Heading > FlattenHeadingNode(Heading heading); + static QList FlattenHeadingNode(Heading heading); // Adds the new_child heading to the parent heading; // the new_child is propagated down the tree if necessary diff --git a/src/Sigil/BookManipulation/Index.cpp b/src/Sigil/BookManipulation/Index.cpp index b911b85da7..505506b998 100644 --- a/src/Sigil/BookManipulation/Index.cpp +++ b/src/Sigil/BookManipulation/Index.cpp @@ -69,15 +69,15 @@ void Index::AddIndexIDsOneFile(HTMLResource *html_resource) { QWriteLocker locker(&html_resource->GetLock()); shared_ptr d = XhtmlDoc::LoadTextIntoDocument(html_resource->GetText()); - QList< xc::DOMNode * > nodes = XhtmlDoc::GetIDNodes(*d.get()); + QList nodes = XhtmlDoc::GetIDNodes(*d.get()); bool resource_updated = false; int index_id_number = 1; foreach(xc::DOMNode * node, nodes) { QString index_id_value; - xc::DOMElement &element = static_cast< xc::DOMElement &>(*node); + xc::DOMElement &element = static_cast(*node); // Get the text of all sub-nodes. - QString text_node_text = XhtmlDoc::GetIDElementText(*node); + QString text_node_text = XhtmlDoc::GetIDElementText(*node); // Convert   to space since Index Editor unfortunately does the same. text_node_text.replace(QChar(160), " "); diff --git a/src/Sigil/BookManipulation/Metadata.cpp b/src/Sigil/BookManipulation/Metadata.cpp index e341a006b0..884c88d5e3 100644 --- a/src/Sigil/BookManipulation/Metadata.cpp +++ b/src/Sigil/BookManipulation/Metadata.cpp @@ -97,13 +97,13 @@ bool Metadata::IsRelator(QString code) return m_Relators.contains(code); } -const QHash< QString, Metadata::MetaInfo > &Metadata::GetRelatorMap() +const QHash &Metadata::GetRelatorMap() { return m_Relators; } -const QHash< QString, Metadata::MetaInfo > &Metadata::GetBasicMetaMap() +const QHash &Metadata::GetBasicMetaMap() { return m_Basic; } diff --git a/src/Sigil/BookManipulation/Metadata.h b/src/Sigil/BookManipulation/Metadata.h index 05ac855134..30d16a3bdf 100644 --- a/src/Sigil/BookManipulation/Metadata.h +++ b/src/Sigil/BookManipulation/Metadata.h @@ -62,13 +62,13 @@ class Metadata : public QObject // The attributes of the element; // the keys are the attribute names, // the values are the attribute values - QHash< QString, QString > attributes; + QHash attributes; }; static Metadata &Instance(); - const QHash< QString, MetaInfo > &GetRelatorMap(); - const QHash< QString, MetaInfo > &GetBasicMetaMap(); + const QHash &GetRelatorMap(); + const QHash &GetBasicMetaMap(); bool IsRelator(QString code); @@ -132,26 +132,26 @@ class Metadata : public QObject // The keys are the untranslated Dublin Core element types // and the values are the MetaInfo structures // (see http://www.idpf.org/2007/opf/OPF_2.0_final_spec.html#Section2.2 ); - QHash< QString, MetaInfo > m_Basic; + QHash m_Basic; // The keys are the Dublin Core element user-friendly names // the values are the element types for those names - QHash< QString, QString > m_BasicFullNames; + QHash m_BasicFullNames; // The keys are the MARC relator codes // and the values are the MetaInfo structures // (see http://www.loc.gov/marc/relators/relaterm.html ); - QHash< QString, MetaInfo > m_Relators; + QHash m_Relators; // The keys are the full relator names // the values are the MARC relator codes // (e.g. aut -> Author ) - QHash< QString, QString > m_RelatorFullNames; + QHash m_RelatorFullNames; // The keys are special field names // the values are the text to display // (e.g. date -> Date ) - QHash< QString, QString > m_Text; + QHash m_Text; }; diff --git a/src/Sigil/BookManipulation/XhtmlDoc.cpp b/src/Sigil/BookManipulation/XhtmlDoc.cpp index b9bb49102e..ac25e5a235 100644 --- a/src/Sigil/BookManipulation/XhtmlDoc.cpp +++ b/src/Sigil/BookManipulation/XhtmlDoc.cpp @@ -105,7 +105,7 @@ QString XhtmlDoc::ResolveCustomEntities(const QString &source) QString new_source = source; QRegularExpression entity_search(ENTITY_SEARCH); - QHash< QString, QString > entities; + QHash entities; int main_index = 0; // Catch all custom entity declarations... @@ -138,13 +138,13 @@ QString XhtmlDoc::ResolveCustomEntities(const QString &source) // Returns a list of XMLElements representing all // the elements of the specified tag name // in the head section of the provided XHTML source code -QList< XhtmlDoc::XMLElement > XhtmlDoc::GetTagsInHead(const QString &source, const QString &tag_name) +QList XhtmlDoc::GetTagsInHead(const QString &source, const QString &tag_name) { // TODO: how about replacing uses of this function // with XPath expressions? Profile for speed. QXmlStreamReader reader(source); bool in_head = false; - QList< XMLElement > matching_elements; + QList matching_elements; while (!reader.atEnd()) { reader.readNext(); @@ -177,12 +177,12 @@ QList< XhtmlDoc::XMLElement > XhtmlDoc::GetTagsInHead(const QString &source, con // Returns a list of XMLElements representing all // the elements of the specified tag name // in the entire document of the provided XHTML source code -QList< XhtmlDoc::XMLElement > XhtmlDoc::GetTagsInDocument(const QString &source, const QString &tag_name) +QList XhtmlDoc::GetTagsInDocument(const QString &source, const QString &tag_name) { // TODO: how about replacing uses of this function // with XPath expressions? Profile for speed. QXmlStreamReader reader(source); - QList< XMLElement > matching_elements; + QList matching_elements; while (!reader.atEnd()) { reader.readNext(); @@ -205,11 +205,11 @@ QList< XhtmlDoc::XMLElement > XhtmlDoc::GetTagsInDocument(const QString &source, } -QList< xc::DOMNode * > XhtmlDoc::GetNodeChildren(const xc::DOMNode &node) +QList XhtmlDoc::GetNodeChildren(const xc::DOMNode &node) { xc::DOMNodeList *children = node.getChildNodes(); int num_children = children->getLength(); - QList< xc::DOMNode * > qtchildren; + QList qtchildren; for (int i = 0; i < num_children; ++i) { qtchildren.append(children->item(i)); @@ -219,9 +219,9 @@ QList< xc::DOMNode * > XhtmlDoc::GetNodeChildren(const xc::DOMNode &node) } -QHash< QString, QString > XhtmlDoc::GetNodeAttributes(const xc::DOMNode &node) +QHash XhtmlDoc::GetNodeAttributes(const xc::DOMNode &node) { - QHash< QString, QString > attributes_hash; + QHash attributes_hash; xc::DOMNamedNodeMap *attributes = node.getAttributes(); if (!attributes) { @@ -229,7 +229,7 @@ QHash< QString, QString > XhtmlDoc::GetNodeAttributes(const xc::DOMNode &node) } for (uint i = 0; i < attributes->getLength(); ++i) { - xc::DOMAttr &attribute = *static_cast< xc::DOMAttr * >(attributes->item(i)); + xc::DOMAttr &attribute = *static_cast(attributes->item(i)); attributes_hash[ GetAttributeName(attribute) ] = XtoQ(attribute.getValue()); } @@ -237,16 +237,16 @@ QHash< QString, QString > XhtmlDoc::GetNodeAttributes(const xc::DOMNode &node) } -QList< xc::DOMElement * > XhtmlDoc::GetTagMatchingDescendants(const xc::DOMNode &node, const QStringList &tag_names) +QList XhtmlDoc::GetTagMatchingDescendants(const xc::DOMNode &node, const QStringList &tag_names) { - QList< xc::DOMElement * > matching_nodes; + QList matching_nodes; if (tag_names.contains(GetNodeName(node), Qt::CaseInsensitive)) { matching_nodes.append((xc::DOMElement *) &node); } if (node.hasChildNodes()) { - QList< xc::DOMNode * > children = GetNodeChildren(node); + QList children = GetNodeChildren(node); for (int i = 0; i < children.count(); ++i) { matching_nodes.append(GetTagMatchingDescendants(*children.at(i), tag_names)); @@ -258,37 +258,37 @@ QList< xc::DOMElement * > XhtmlDoc::GetTagMatchingDescendants(const xc::DOMNode // TODO: turn the overloads into a template -QList< xc::DOMElement * > XhtmlDoc::GetTagMatchingDescendants(const xc::DOMElement &node, const QString &tag_name) +QList XhtmlDoc::GetTagMatchingDescendants(const xc::DOMElement &node, const QString &tag_name) { xc::DOMNodeList *children = node.getElementsByTagName(QtoX(tag_name)); int num_children = children->getLength(); - QList< xc::DOMElement * > qtchildren; + QList qtchildren; for (int i = 0; i < num_children; ++i) { - qtchildren.append(static_cast< xc::DOMElement * >(children->item(i))); + qtchildren.append(static_cast(children->item(i))); } return qtchildren; } -QList< xc::DOMElement * > XhtmlDoc::GetTagMatchingDescendants(const xc::DOMDocument &node, const QString &tag_name) +QList XhtmlDoc::GetTagMatchingDescendants(const xc::DOMDocument &node, const QString &tag_name) { return GetTagMatchingDescendants(node, tag_name, "*"); } -QList< xc::DOMElement * > XhtmlDoc::GetTagMatchingDescendants( +QList XhtmlDoc::GetTagMatchingDescendants( const xc::DOMDocument &node, const QString &tag_name, const QString &namespace_name) { xc::DOMNodeList *children = node.getElementsByTagNameNS(QtoX(namespace_name), QtoX(tag_name)); int num_children = children->getLength(); - QList< xc::DOMElement * > qtchildren; + QList qtchildren; for (int i = 0; i < num_children; ++i) { - qtchildren.append(static_cast< xc::DOMElement * >(children->item(i))); + qtchildren.append(static_cast(children->item(i))); } return qtchildren; @@ -297,11 +297,11 @@ QList< xc::DOMElement * > XhtmlDoc::GetTagMatchingDescendants( QList XhtmlDoc::GetAllDescendantClasses(const xc::DOMNode &node) { if (node.getNodeType() != xc::DOMNode::ELEMENT_NODE) { - return QList< QString >(); + return QList(); } - const xc::DOMElement *element = static_cast< const xc::DOMElement * >(&node); - QList< QString > classes; + const xc::DOMElement *element = static_cast(&node); + QList classes; QString element_name = GetNodeName(*element); if (element->hasAttribute(QtoX("class"))) { @@ -312,7 +312,7 @@ QList XhtmlDoc::GetAllDescendantClasses(const xc::DOMNode &node) } if (node.hasChildNodes()) { - QList< xc::DOMNode * > children = GetNodeChildren(node); + QList children = GetNodeChildren(node); for (int i = 0; i < children.count(); ++i) { classes.append(GetAllDescendantClasses(*children.at(i))); @@ -322,14 +322,14 @@ QList XhtmlDoc::GetAllDescendantClasses(const xc::DOMNode &node) return classes; } -QList< QString > XhtmlDoc::GetAllDescendantStyleUrls(const xc::DOMNode &node) +QList XhtmlDoc::GetAllDescendantStyleUrls(const xc::DOMNode &node) { if (node.getNodeType() != xc::DOMNode::ELEMENT_NODE) { - return QList< QString >(); + return QList(); } - const xc::DOMElement *element = static_cast< const xc::DOMElement * >(&node); - QList< QString > styles; + const xc::DOMElement *element = static_cast(&node); + QList styles; if (element->hasAttribute(QtoX("style"))) { QString attribute = XtoQ(element->getAttribute(QtoX("style"))); @@ -341,7 +341,7 @@ QList< QString > XhtmlDoc::GetAllDescendantStyleUrls(const xc::DOMNode &node) } if (node.hasChildNodes()) { - QList< xc::DOMNode * > children = GetNodeChildren(node); + QList children = GetNodeChildren(node); for (int i = 0; i < children.count(); ++i) { styles.append(GetAllDescendantStyleUrls(*children.at(i))); @@ -351,14 +351,14 @@ QList< QString > XhtmlDoc::GetAllDescendantStyleUrls(const xc::DOMNode &node) return styles; } -QList< QString > XhtmlDoc::GetAllDescendantIDs(const xc::DOMNode &node) +QList XhtmlDoc::GetAllDescendantIDs(const xc::DOMNode &node) { if (node.getNodeType() != xc::DOMNode::ELEMENT_NODE) { - return QList< QString >(); + return QList(); } - const xc::DOMElement *element = static_cast< const xc::DOMElement * >(&node); - QList< QString > IDs; + const xc::DOMElement *element = static_cast(&node); + QList IDs; if (element->hasAttribute(QtoX("id"))) { IDs.append(XtoQ(element->getAttribute(QtoX("id")))); @@ -371,7 +371,7 @@ QList< QString > XhtmlDoc::GetAllDescendantIDs(const xc::DOMNode &node) } if (node.hasChildNodes()) { - QList< xc::DOMNode * > children = GetNodeChildren(node); + QList children = GetNodeChildren(node); for (int i = 0; i < children.count(); ++i) { IDs.append(GetAllDescendantIDs(*children.at(i))); @@ -381,21 +381,21 @@ QList< QString > XhtmlDoc::GetAllDescendantIDs(const xc::DOMNode &node) return IDs; } -QList< QString > XhtmlDoc::GetAllDescendantHrefs(const xc::DOMNode &node) +QList XhtmlDoc::GetAllDescendantHrefs(const xc::DOMNode &node) { if (node.getNodeType() != xc::DOMNode::ELEMENT_NODE) { - return QList< QString >(); + return QList(); } - const xc::DOMElement *element = static_cast< const xc::DOMElement * >(&node); - QList< QString > hrefs; + const xc::DOMElement *element = static_cast(&node); + QList hrefs; if (element->hasAttribute(QtoX("href"))) { hrefs.append(XtoQ(element->getAttribute(QtoX("href")))); } if (node.hasChildNodes()) { - QList< xc::DOMNode * > children = GetNodeChildren(node); + QList children = GetNodeChildren(node); for (int i = 0; i < children.count(); ++i) { hrefs.append(GetAllDescendantHrefs(*children.at(i))); @@ -411,12 +411,12 @@ QString XhtmlDoc::GetDomNodeAsString(const xc::DOMNode &node) { XMLCh LS[] = { xc::chLatin_L, xc::chLatin_S, xc::chNull }; xc::DOMImplementation *impl = xc::DOMImplementationRegistry::getDOMImplementation(LS); - shared_ptr< xc::DOMLSSerializer > serializer( + shared_ptr serializer( ((xc::DOMImplementationLS *) impl)->createLSSerializer(), - XercesExt::XercesDeallocator< xc::DOMLSSerializer >); + XercesExt::XercesDeallocator); serializer->getDomConfig()->setParameter(xc::XMLUni::fgDOMWRTDiscardDefaultContent, false); serializer->getDomConfig()->setParameter(xc::XMLUni::fgDOMWRTBOM, true); - shared_ptr< XMLCh > xwritten(serializer->writeToString(&node), XercesExt::XercesStringDeallocator); + shared_ptr xwritten(serializer->writeToString(&node), XercesExt::XercesStringDeallocator); return XtoQ(xwritten.get()); } @@ -432,13 +432,13 @@ QString XhtmlDoc::GetDomDocumentAsString(const xc::DOMDocument &document) } -shared_ptr< xc::DOMDocument > XhtmlDoc::CopyDomDocument(const xc::DOMDocument &document) +shared_ptr XhtmlDoc::CopyDomDocument(const xc::DOMDocument &document) { - return RaiiWrapDocument(static_cast< xc::DOMDocument * >(document.cloneNode(true))); + return RaiiWrapDocument(static_cast(document.cloneNode(true))); } -shared_ptr< xc::DOMDocument > XhtmlDoc::LoadTextIntoDocument(const QString &source) +shared_ptr XhtmlDoc::LoadTextIntoDocument(const QString &source) { XercesExt::LocationAwareDOMParser parser; // This scanner ignores schemas @@ -455,7 +455,7 @@ shared_ptr< xc::DOMDocument > XhtmlDoc::LoadTextIntoDocument(const QString &sour // We use source.count() * 2 because count returns // the number of QChars, which are 2 bytes long xc::MemBufInputSource input( - reinterpret_cast< const XMLByte * >(prepared_source.utf16()), + reinterpret_cast(prepared_source.utf16()), prepared_source.count() * 2, "empty"); XMLCh UTF16[] = { xc::chLatin_U, xc::chLatin_T, xc::chLatin_F, xc::chDigit_1, xc::chDigit_6, xc::chNull }; @@ -465,9 +465,9 @@ shared_ptr< xc::DOMDocument > XhtmlDoc::LoadTextIntoDocument(const QString &sour } -shared_ptr< xc::DOMDocument > XhtmlDoc::RaiiWrapDocument(xc::DOMDocument *document) +shared_ptr XhtmlDoc::RaiiWrapDocument(xc::DOMDocument *document) { - return shared_ptr< xc::DOMDocument >(document, XercesExt::XercesDeallocator< xc::DOMDocument >); + return shared_ptr(document, XercesExt::XercesDeallocator); } @@ -485,7 +485,7 @@ int XhtmlDoc::NodeColumnNumber(const xc::DOMNode &node) XhtmlDoc::WellFormedError XhtmlDoc::WellFormedErrorForSource(const QString &source) { - boost::scoped_ptr< xc::SAX2XMLReader > parser(xc::XMLReaderFactory::createXMLReader()); + boost::scoped_ptr parser(xc::XMLReaderFactory::createXMLReader()); parser->setFeature(xc::XMLUni::fgSAX2CoreValidation, false); parser->setFeature(xc::XMLUni::fgXercesSchema, false); parser->setFeature(xc::XMLUni::fgXercesLoadSchema, false); @@ -504,7 +504,7 @@ XhtmlDoc::WellFormedError XhtmlDoc::WellFormedErrorForSource(const QString &sour // We use source.count() * 2 because count returns // the number of QChars, which are 2 bytes long xc::MemBufInputSource input( - reinterpret_cast< const XMLByte * >(prepared_source.utf16()), + reinterpret_cast(prepared_source.utf16()), prepared_source.count() * 2, "empty"); XMLCh UTF16[] = { xc::chLatin_U, xc::chLatin_T, xc::chLatin_F, xc::chDigit_1, xc::chDigit_6, xc::chNull }; @@ -518,7 +518,7 @@ XhtmlDoc::WellFormedError XhtmlDoc::WellFormedErrorForSource(const QString &sour collector.AddNewExceptionAsResult(exception); } - std::vector< fc::Result > results = collector.GetResults(); + std::vector results = collector.GetResults(); if (!results.empty()) { XhtmlDoc::WellFormedError error; @@ -545,7 +545,7 @@ xc::DOMElement *XhtmlDoc::CreateElementInDocument( const QString &namespace_name, xc::DOMDocument &document) { - return CreateElementInDocument(tag_name, namespace_name, document, QHash< QString, QString >()); + return CreateElementInDocument(tag_name, namespace_name, document, QHash()); } @@ -553,7 +553,7 @@ xc::DOMElement *XhtmlDoc::CreateElementInDocument( const QString &tag_name, const QString &namespace_name, xc::DOMDocument &document, - QHash< QString, QString > attributes) + QHash attributes) { xc::DOMElement *element = document.createElementNS(QtoX(namespace_name), QtoX(tag_name)); foreach(QString attribute_name, attributes.keys()) { @@ -565,7 +565,7 @@ xc::DOMElement *XhtmlDoc::CreateElementInDocument( xc::DOMElement *XhtmlDoc::RenameElementInDocument(xc::DOMDocument &document, xc::DOMNode &node, QString tag_name) { - xc::DOMElement *element = static_cast< xc::DOMElement * >(&node); + xc::DOMElement *element = static_cast(&node); xc::DOMElement *new_element = CreateElementInDocument(tag_name, XtoQ(element->getNamespaceURI()), document, GetNodeAttributes(node)); // Move all the children @@ -607,9 +607,9 @@ QString XhtmlDoc::ResolveHTMLEntities(const QString &text) // A tree node class without a children() function... // appallingly stupid, isn't it? -QList< QWebElement > XhtmlDoc::QWebElementChildren(const QWebElement &element) +QList XhtmlDoc::QWebElementChildren(const QWebElement &element) { - QList< QWebElement > children; + QList children; const QWebElement &first_child = element.firstChild(); if (!first_child.isNull()) { @@ -666,7 +666,7 @@ QStringList XhtmlDoc::GetSGFSectionSplits(const QString &source, QStringList XhtmlDoc::GetLinkedStylesheets(const QString &source) { - QList< XhtmlDoc::XMLElement > link_tag_nodes; + QList link_tag_nodes; try { link_tag_nodes = XhtmlDoc::GetTagsInHead(source, "link"); @@ -679,8 +679,8 @@ QStringList XhtmlDoc::GetLinkedStylesheets(const QString &source) foreach(XhtmlDoc::XMLElement element, link_tag_nodes) { if (element.attributes.contains("type") && ( - (element.attributes.value("type").toLower() == "text/css") || - (element.attributes.value("type").toLower() == "text/x-oeb1-css") + (element.attributes.value("type").toLower() == "text/css") || + (element.attributes.value("type").toLower() == "text/x-oeb1-css") ) && element.attributes.contains("rel") && (element.attributes.value("rel").toLower() == "stylesheet") && @@ -756,12 +756,12 @@ xc::DOMDocumentFragment *XhtmlDoc::ConvertToDocumentFragment(const xc::DOMNodeLi // Converts a DomNodeList to a regular QList -QList< xc::DOMNode * > XhtmlDoc::ConvertToRegularList(const xc::DOMNodeList &list) +QList XhtmlDoc::ConvertToRegularList(const xc::DOMNodeList &list) { // Since a DomNodeList is "live", we store the count // so we don't have to recalculate it every loop iteration int count = list.getLength(); - QList< xc::DOMNode * > nodes; + QList nodes; for (int i = 0; i < count; ++i) { nodes.append(list.item(i)); @@ -772,12 +772,12 @@ QList< xc::DOMNode * > XhtmlDoc::ConvertToRegularList(const xc::DOMNodeList &lis // Returns a list with only the element nodes -QList< xc::DOMNode * > XhtmlDoc::ExtractElements(const xc::DOMNodeList &list) +QList XhtmlDoc::ExtractElements(const xc::DOMNodeList &list) { // Since a DomNodeList is "live", we store the count // so we don't have to recalculate it every loop iteration int count = list.getLength(); - QList< xc::DOMNode * > element_nodes; + QList element_nodes; for (int i = 0; i < count; ++i) { xc::DOMNode *node = list.item(i); @@ -845,12 +845,12 @@ int XhtmlDoc::GetCustomIndexInList(const xc::DOMNode &node, const xc::DOMNodeLis // Returns a list of all the "visible" text nodes that are descendants // of the specified node. "Visible" means we ignore style tags, script tags etc... -QList< xc::DOMNode * > XhtmlDoc::GetVisibleTextNodes(const xc::DOMNode &node) +QList XhtmlDoc::GetVisibleTextNodes(const xc::DOMNode &node) { // TODO: investigate possible parallelization // opportunities for this function (profile before and after!) if (node.getNodeType() == xc::DOMNode::TEXT_NODE) { - return QList< xc::DOMNode * >() << const_cast< xc::DOMNode * >(&node); + return QList() << const_cast(&node); } else { QString node_name = GetNodeName(node); @@ -858,8 +858,8 @@ QList< xc::DOMNode * > XhtmlDoc::GetVisibleTextNodes(const xc::DOMNode &node) node_name != "script" && node_name != "style" ) { - QList< xc::DOMNode * > children = GetNodeChildren(node); - QList< xc::DOMNode * > text_nodes; + QList children = GetNodeChildren(node); + QList text_nodes; for (int i = 0; i < children.count(); ++i) { text_nodes.append(GetVisibleTextNodes(*children.at(i))); @@ -869,7 +869,7 @@ QList< xc::DOMNode * > XhtmlDoc::GetVisibleTextNodes(const xc::DOMNode &node) } } - return QList< xc::DOMNode * >(); + return QList(); } @@ -911,7 +911,7 @@ QList XhtmlDoc::GetIDNodes(const xc::DOMNode &node) QString XhtmlDoc::GetIDElementText(const xc::DOMNode &node) { QString text; - QList< xc::DOMNode * > children = GetNodeChildren(node); + QList children = GetNodeChildren(node); // Combine all text nodes for this node plus all text for non-ID element children for (int i = 0; i < children.count(); ++i) { @@ -933,16 +933,16 @@ QString XhtmlDoc::GetIDElementText(const xc::DOMNode &node) // Returns a list of ALL text nodes that are descendants // of the specified node. -QList< xc::DOMNode * > XhtmlDoc::GetAllTextNodes(const xc::DOMNode &node) +QList XhtmlDoc::GetAllTextNodes(const xc::DOMNode &node) { // TODO: investigate possible parallelization // opportunities for this function (profile before and after!) if (node.getNodeType() == xc::DOMNode::TEXT_NODE) { - return QList< xc::DOMNode * >() << const_cast< xc::DOMNode * >(&node); + return QList() << const_cast(&node); } else { if (node.hasChildNodes()) { - QList< xc::DOMNode * > children = GetNodeChildren(node); - QList< xc::DOMNode * > text_nodes; + QList children = GetNodeChildren(node); + QList text_nodes; for (int i = 0; i < children.count(); ++i) { text_nodes.append(GetAllTextNodes(*children.at(i))); @@ -952,7 +952,7 @@ QList< xc::DOMNode * > XhtmlDoc::GetAllTextNodes(const xc::DOMNode &node) } } - return QList< xc::DOMNode * >(); + return QList(); } @@ -970,7 +970,7 @@ xc::DOMNode &XhtmlDoc::GetAncestorBlockElement(const xc::DOMNode &node) } if (parent_node) { - return const_cast< xc::DOMNode & >(*parent_node); + return const_cast(*parent_node); } else { return *(node.getOwnerDocument()->getElementsByTagName(QtoX("body"))->item(0)); } @@ -1006,7 +1006,7 @@ QStringList XhtmlDoc::GetMediaPathsFromMediaChildren(const xc::DOMNode &node, QS QStringList XhtmlDoc::GetAllMediaPathsFromMediaChildren(const xc::DOMNode &node, QStringList tags) { // "Normal" HTML media file elements - QList< xc::DOMElement * > nodes = GetTagMatchingDescendants(node, tags); + QList nodes = GetTagMatchingDescendants(node, tags); QStringList links; // Get a list of all media files referenced foreach(xc::DOMElement * node, nodes) { @@ -1028,7 +1028,7 @@ QStringList XhtmlDoc::GetAllMediaPathsFromMediaChildren(const xc::DOMNode &node, QStringList XhtmlDoc::GetAllHrefPaths(const xc::DOMNode &node) { // Anchor tags - QList< xc::DOMElement * > nodes = GetTagMatchingDescendants(node, ANCHOR_TAGS); + QList nodes = GetTagMatchingDescendants(node, ANCHOR_TAGS); QStringList hrefs; // Get a list of all defined hrefs foreach(xc::DOMElement * node, nodes) { @@ -1075,7 +1075,7 @@ QString XhtmlDoc::PrepareSourceForXerces(const QString &source) // Returns the node identified by the specified ViewEditor element hierarchy xc::DOMNode *XhtmlDoc::GetNodeFromHierarchy(const xc::DOMDocument &document, - const QList< ViewEditor::ElementIndex > &hierarchy) + const QList &hierarchy) { xc::DOMNode *node = document.getElementsByTagName(QtoX("html"))->item(0); if (node == NULL) { @@ -1085,7 +1085,7 @@ xc::DOMNode *XhtmlDoc::GetNodeFromHierarchy(const xc::DOMDocument &document, xc::DOMNodeList *tmp_node = NULL; for (int i = 0; i < hierarchy.count() - 1; ++i) { - QList< xc::DOMNode * > children; + QList children; tmp_node = node->getChildNodes(); if (tmp_node != NULL) { @@ -1118,11 +1118,11 @@ xc::DOMNode *XhtmlDoc::GetNodeFromHierarchy(const xc::DOMDocument &document, } // Creates a ViewEditor element hierarchy from the specified node -QList< ViewEditor::ElementIndex > XhtmlDoc::GetHierarchyFromNode(const xc::DOMNode &node) +QList XhtmlDoc::GetHierarchyFromNode(const xc::DOMNode &node) { xc::DOMNode *html_node = node.getOwnerDocument()->getElementsByTagName(QtoX("html"))->item(0); const xc::DOMNode *current_node = &node; - QList< ViewEditor::ElementIndex > element_list; + QList element_list; while (current_node != html_node) { xc::DOMNode *parent = current_node->getParentNode(); @@ -1149,7 +1149,7 @@ QString XhtmlDoc::GetNodeChildrenAsString(const xc::DOMNode *node) for (int i=0; i attributes; + QHash attributes; }; // Resolves custom ENTITY declarations @@ -60,39 +60,39 @@ class XhtmlDoc // Returns a list of XMLElements representing all // the elements of the specified tag name // in the head section of the provided XHTML source code - static QList< XMLElement > GetTagsInHead(const QString &source, const QString &tag_name); + static QList GetTagsInHead(const QString &source, const QString &tag_name); // Returns a list of XMLElements representing all // the elements of the specified tag name // in the entire document of the provided XHTML source code - static QList< XMLElement > GetTagsInDocument(const QString &source, const QString &tag_name); + static QList GetTagsInDocument(const QString &source, const QString &tag_name); - static QList< xc::DOMNode * > GetNodeChildren(const xc::DOMNode &node); + static QList GetNodeChildren(const xc::DOMNode &node); - static QHash< QString, QString > GetNodeAttributes(const xc::DOMNode &node); + static QHash GetNodeAttributes(const xc::DOMNode &node); - static QList< xc::DOMElement * > GetTagMatchingDescendants( + static QList GetTagMatchingDescendants( const xc::DOMNode &node, const QStringList &tag_names); - static QList< xc::DOMElement * > GetTagMatchingDescendants( + static QList GetTagMatchingDescendants( const xc::DOMElement &node, const QString &tag_name); - static QList< xc::DOMElement * > GetTagMatchingDescendants( + static QList GetTagMatchingDescendants( const xc::DOMDocument &node, const QString &tag_name); - static QList< xc::DOMElement * > GetTagMatchingDescendants( + static QList GetTagMatchingDescendants( const xc::DOMDocument &node, const QString &tag_name, const QString &namespace_name); - static QList< QString > GetAllDescendantStyleUrls(const xc::DOMNode &node); + static QList GetAllDescendantStyleUrls(const xc::DOMNode &node); - static QList< QString > GetAllDescendantHrefs(const xc::DOMNode &node); + static QList GetAllDescendantHrefs(const xc::DOMNode &node); - static QList< QString > GetAllDescendantIDs(const xc::DOMNode &node); + static QList GetAllDescendantIDs(const xc::DOMNode &node); static QList GetAllDescendantClasses(const xc::DOMNode &node); static QString GetDomNodeAsString(const xc::DOMNode &node); @@ -103,11 +103,11 @@ class XhtmlDoc * Parses the source text into a DOM and returns a shared pointer * to the heap-created document. */ - static boost::shared_ptr< xc::DOMDocument > LoadTextIntoDocument(const QString &source); + static boost::shared_ptr LoadTextIntoDocument(const QString &source); - static boost::shared_ptr< xc::DOMDocument > CopyDomDocument(const xc::DOMDocument &document); + static boost::shared_ptr CopyDomDocument(const xc::DOMDocument &document); - static boost::shared_ptr< xc::DOMDocument > RaiiWrapDocument(xc::DOMDocument *document); + static boost::shared_ptr RaiiWrapDocument(xc::DOMDocument *document); static int NodeLineNumber(const xc::DOMNode &node); @@ -133,7 +133,7 @@ class XhtmlDoc const QString &tag_name, const QString &namespace_name, xc::DOMDocument &document, - QHash< QString, QString > attributes); + QHash attributes); static xc::DOMElement *RenameElementInDocument(xc::DOMDocument &document, xc::DOMNode &node, QString tag_name); @@ -151,7 +151,7 @@ class XhtmlDoc // Bonnie & Clyde static QString ResolveHTMLEntities(const QString &text); - static QList< QWebElement > QWebElementChildren(const QWebElement &element); + static QList QWebElementChildren(const QWebElement &element); /** * Splits the provided source on SGF section breaks. @@ -189,10 +189,10 @@ class XhtmlDoc static xc::DOMDocumentFragment *ConvertToDocumentFragment(const xc::DOMNodeList &list); // Converts a DomNodeList to a regular QList - static QList< xc::DOMNode * > ConvertToRegularList(const xc::DOMNodeList &list); + static QList ConvertToRegularList(const xc::DOMNodeList &list); // Returns a list with only the element nodes - static QList< xc::DOMNode * > ExtractElements(const xc::DOMNodeList &list); + static QList ExtractElements(const xc::DOMNodeList &list); // Returns the node's real index in the list static int GetRealIndexInList(const xc::DOMNode &node, const xc::DOMNodeList &list); @@ -209,7 +209,7 @@ class XhtmlDoc // Returns a list of all the "visible" text nodes that are descendants // of the specified node. "Visible" means we ignore style tags, script tags etc... - static QList< xc::DOMNode * > GetVisibleTextNodes(const xc::DOMNode &node); + static QList GetVisibleTextNodes(const xc::DOMNode &node); // Returns a list of all the nodes that are suitable for use with "id" attributes static QList GetIDNodes(const xc::DOMNode &node); @@ -219,7 +219,7 @@ class XhtmlDoc // Returns a list of ALL text nodes that are descendants // of the specified node. - static QList< xc::DOMNode * > GetAllTextNodes(const xc::DOMNode &node); + static QList GetAllTextNodes(const xc::DOMNode &node); // Returns the first block element ancestor of the specified node static xc::DOMNode &GetAncestorBlockElement(const xc::DOMNode &node); @@ -228,16 +228,16 @@ class XhtmlDoc static QStringList GetMediaPathsFromMediaChildren(const xc::DOMNode &node, QStringList tags); - static QStringList GetAllMediaPathsFromMediaChildren(const xc::DOMNode &node, QStringList tags); + static QStringList GetAllMediaPathsFromMediaChildren(const xc::DOMNode &node, QStringList tags); static QStringList GetAllHrefPaths(const xc::DOMNode &node); // Returns the node identified by the specified ViewEditor element hierarchy static xc::DOMNode *GetNodeFromHierarchy(const xc::DOMDocument &document, - const QList< ViewEditor::ElementIndex > &hierarchy); + const QList &hierarchy); // Creates a ViewEditor element hierarchy from the specified node - static QList< ViewEditor::ElementIndex > GetHierarchyFromNode(const xc::DOMNode &node); + static QList GetHierarchyFromNode(const xc::DOMNode &node); // Gets all children of a node as a string. static QString GetNodeChildrenAsString(const xc::DOMNode *node); diff --git a/src/Sigil/CMakeLists.txt b/src/Sigil/CMakeLists.txt index 0823d4ca86..fe6025ef3b 100644 --- a/src/Sigil/CMakeLists.txt +++ b/src/Sigil/CMakeLists.txt @@ -41,6 +41,22 @@ endif() ############################################################################# +if (NOT MSVC) + include(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) + CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) + if(COMPILER_SUPPORTS_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + elseif(COMPILER_SUPPORTS_CXX0X) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + else() + message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") + endif() +endif() + +############################################################################# + + # Qt5 packages minimum version 5.1 find_package(Qt5 COMPONENTS Core Network Svg WebKit WebKitWidgets Widgets Xml XmlPatterns Concurrent PrintSupport LinguistTools) set(CMAKE_AUTOMOC ON) diff --git a/src/Sigil/Dialogs/About.cpp b/src/Sigil/Dialogs/About.cpp index ff427798f6..59c817275c 100644 --- a/src/Sigil/Dialogs/About.cpp +++ b/src/Sigil/Dialogs/About.cpp @@ -44,25 +44,25 @@ About::About(QWidget *parent) QRegularExpression version_number(VERSION_NUMBERS); QRegularExpressionMatch mo = version_number.match(SIGIL_VERSION); QString version_text = QString("%1.%2.%3") - .arg(mo.captured(1).toInt()) - .arg(mo.captured(2).toInt()) - .arg(mo.captured(3).toInt()); + .arg(mo.captured(1).toInt()) + .arg(mo.captured(2).toInt()) + .arg(mo.captured(3).toInt()); ui.lbVersionDisplay->setText(version_text); QString credits = "

" + tr("Maintainer / Lead Developer") + "

" + - "
  • John Schember
" + - "

" + tr("Code Contributors") + "

" + - "
    " + - "
  • Kevin Hendricks
  • " + - "
  • Grant Drake
  • " + - "
  • Dave Heiland
  • " + - "
  • Charles King
  • " + - "
  • Daniel Pavel
  • " + - "
  • Grzegorz Wolszczak
  • " + - "
" + - "

" + tr("Translators") + "

" + - "" + - "

" + tr("Original Creator") + "

" + - "
  • Strahinja Marković (" + tr("retired") + ")
"; + "
  • John Schember
" + + "

" + tr("Code Contributors") + "

" + + "
    " + + "
  • Kevin Hendricks
  • " + + "
  • Grant Drake
  • " + + "
  • Dave Heiland
  • " + + "
  • Charles King
  • " + + "
  • Daniel Pavel
  • " + + "
  • Grzegorz Wolszczak
  • " + + "
" + + "

" + tr("Translators") + "

" + + "" + + "

" + tr("Original Creator") + "

" + + "
  • Strahinja Marković (" + tr("retired") + ")
"; ui.creditsDisplay->setText(credits); } diff --git a/src/Sigil/Dialogs/AddMetadata.cpp b/src/Sigil/Dialogs/AddMetadata.cpp index 3a49815e02..1c937f5945 100644 --- a/src/Sigil/Dialogs/AddMetadata.cpp +++ b/src/Sigil/Dialogs/AddMetadata.cpp @@ -28,7 +28,7 @@ static const QString SETTINGS_GROUP = "add_metadata"; -AddMetadata::AddMetadata(const QHash< QString, Metadata::MetaInfo > &metadata, QWidget *parent) +AddMetadata::AddMetadata(const QHash &metadata, QWidget *parent) : QDialog(parent), m_Metadata(metadata) diff --git a/src/Sigil/Dialogs/AddMetadata.h b/src/Sigil/Dialogs/AddMetadata.h index db322238c8..82da2308bc 100644 --- a/src/Sigil/Dialogs/AddMetadata.h +++ b/src/Sigil/Dialogs/AddMetadata.h @@ -48,7 +48,7 @@ class AddMetadata : public QDialog * @param metadata The metadata list that this dialog displays. \see Metadata * @param parent The dialog's parent. */ - AddMetadata(const QHash< QString, Metadata::MetaInfo > &metadata, QWidget *parent = 0); + AddMetadata(const QHash &metadata, QWidget *parent = 0); /** * Returns the list of names selected by user. @@ -98,7 +98,7 @@ private slots: * Represents the metadata list that this dialog displays. * @see Metadata */ - const QHash< QString, Metadata::MetaInfo > &m_Metadata; + const QHash &m_Metadata; /** * Holds the names of the selected entries diff --git a/src/Sigil/Dialogs/ClipEditor.cpp b/src/Sigil/Dialogs/ClipEditor.cpp index ed3fed2604..189a0396f8 100644 --- a/src/Sigil/Dialogs/ClipEditor.cpp +++ b/src/Sigil/Dialogs/ClipEditor.cpp @@ -463,7 +463,7 @@ void ClipEditor::AutoFill() QStringList css_list; - QList css_resources = m_Book->GetFolderKeeper().GetResourceTypeList< CSSResource >(false); + QList css_resources = m_Book->GetFolderKeeper().GetResourceTypeList(false); foreach(CSSResource * css_resource, css_resources) { CSSInfo css_info(css_resource->GetText(), true); @@ -477,8 +477,7 @@ void ClipEditor::AutoFill() css_list.append("p" % group); css_list.append("span" % group); css_list.append("div" % group); - } - else { + } else { css_list.append(group); } } @@ -501,7 +500,7 @@ void ClipEditor::AutoFill() m_ClipEditorModel->AddEntryToModel(entry, false, group_item); } - QMessageBox::information(this, tr("Clip Editor"), tr("CSS entries added: %n", "",css_list.count())); + QMessageBox::information(this, tr("Clip Editor"), tr("CSS entries added: %n", "",css_list.count())); } diff --git a/src/Sigil/Dialogs/ClipEditor.h b/src/Sigil/Dialogs/ClipEditor.h index ed5a4d0904..8a7c55222a 100644 --- a/src/Sigil/Dialogs/ClipEditor.h +++ b/src/Sigil/Dialogs/ClipEditor.h @@ -142,7 +142,7 @@ private slots: ClipEditorModel *m_ClipEditorModel; - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; QString m_LastFolderOpen; diff --git a/src/Sigil/Dialogs/DeleteStyles.cpp b/src/Sigil/Dialogs/DeleteStyles.cpp index 46bedd0165..239d04461b 100644 --- a/src/Sigil/Dialogs/DeleteStyles.cpp +++ b/src/Sigil/Dialogs/DeleteStyles.cpp @@ -25,7 +25,7 @@ static const QString SETTINGS_GROUP = "delete_styles"; -DeleteStyles::DeleteStyles(QHash< QString, QList > css_styles_to_delete, QWidget *parent) +DeleteStyles::DeleteStyles(QHash> css_styles_to_delete, QWidget *parent) : QDialog(parent), m_CSSStylesToDelete(css_styles_to_delete) @@ -35,7 +35,7 @@ DeleteStyles::DeleteStyles(QHash< QString, QList > css_s SetUpTable(); ReadSettings(); // Get list of styles - QHashIterator< QString, QList > stylesheets(m_CSSStylesToDelete); + QHashIterator> stylesheets(m_CSSStylesToDelete); while (stylesheets.hasNext()) { stylesheets.next(); @@ -110,7 +110,7 @@ void DeleteStyles::SaveStylesToDelete() } } -QHash< QString, QList > DeleteStyles::GetStylesToDelete() +QHash> DeleteStyles::GetStylesToDelete() { return m_CSSStylesToDelete; } diff --git a/src/Sigil/Dialogs/DeleteStyles.h b/src/Sigil/Dialogs/DeleteStyles.h index 6705f713b6..920561fdeb 100644 --- a/src/Sigil/Dialogs/DeleteStyles.h +++ b/src/Sigil/Dialogs/DeleteStyles.h @@ -41,10 +41,10 @@ class DeleteStyles: public QDialog * @param opf The OPF whose metadata we want to edit. * @param parent The object's parent. */ - DeleteStyles(QHash< QString, QList > css_styles_to_delete, QWidget *parent = 0); + DeleteStyles(QHash> css_styles_to_delete, QWidget *parent = 0); ~DeleteStyles(); - QHash< QString, QList > GetStylesToDelete(); + QHash> GetStylesToDelete(); signals: void OpenFileRequest(QString, int); @@ -63,7 +63,7 @@ private slots: QStandardItemModel m_Model; - QHash< QString, QList > m_CSSStylesToDelete; + QHash> m_CSSStylesToDelete; Ui::DeleteStyles ui; }; diff --git a/src/Sigil/Dialogs/EditTOC.cpp b/src/Sigil/Dialogs/EditTOC.cpp index 509f181bd1..f7394cee1f 100644 --- a/src/Sigil/Dialogs/EditTOC.cpp +++ b/src/Sigil/Dialogs/EditTOC.cpp @@ -33,7 +33,7 @@ static const QString SETTINGS_GROUP = "edit_toc"; static const int COLUMN_INDENTATION = 20; -EditTOC::EditTOC(QSharedPointer< Book > book, QList resources, QWidget *parent) +EditTOC::EditTOC(QSharedPointer book, QList resources, QWidget *parent) : QDialog(parent), m_Book(book), @@ -101,8 +101,7 @@ NCXModel::NCXEntry EditTOC::ConvertItemToEntry(QStandardItem *item) parent_item = m_TableOfContents->invisibleRootItem(); } entry.target = parent_item->child(item->row(), 1)->text(); - } - else { + } else { entry.is_root = true; } @@ -188,7 +187,7 @@ void EditTOC::MoveRight() QStandardItem *parent_item = item->parent(); if (!parent_item) { - parent_item = m_TableOfContents->invisibleRootItem(); + parent_item = m_TableOfContents->invisibleRootItem(); } // Make the item above the parent of this item @@ -221,7 +220,7 @@ void EditTOC::MoveUp() QStandardItem *parent_item = item->parent(); if (!parent_item) { - parent_item = m_TableOfContents->invisibleRootItem(); + parent_item = m_TableOfContents->invisibleRootItem(); } QList row_items = parent_item->takeRow(item_row); @@ -244,7 +243,7 @@ void EditTOC::MoveDown() QStandardItem *parent_item = item->parent(); if (!parent_item) { - parent_item = m_TableOfContents->invisibleRootItem(); + parent_item = m_TableOfContents->invisibleRootItem(); } int item_row = item->row(); @@ -285,7 +284,7 @@ void EditTOC::AddEntry(bool above) QStandardItem *parent_item = item->parent(); if (!parent_item) { - parent_item = m_TableOfContents->invisibleRootItem(); + parent_item = m_TableOfContents->invisibleRootItem(); } // Add a new empty row of items @@ -331,7 +330,7 @@ void EditTOC::DeleteEntry() QStandardItem *parent_item = item->parent(); if (!parent_item) { - parent_item = m_TableOfContents->invisibleRootItem(); + parent_item = m_TableOfContents->invisibleRootItem(); } parent_item->takeRow(item->row()); diff --git a/src/Sigil/Dialogs/EditTOC.h b/src/Sigil/Dialogs/EditTOC.h index d228a5b3d3..99a3fd7cd3 100644 --- a/src/Sigil/Dialogs/EditTOC.h +++ b/src/Sigil/Dialogs/EditTOC.h @@ -45,7 +45,7 @@ class EditTOC : public QDialog public: - EditTOC(QSharedPointer< Book > book, QList resources, QWidget *parent = 0); + EditTOC(QSharedPointer book, QList resources, QWidget *parent = 0); ~EditTOC(); @@ -98,7 +98,7 @@ private slots: // PRIVATE MEMBER VARIABLES /////////////////////////////// - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; QList m_Resources; diff --git a/src/Sigil/Dialogs/HeadingSelector.cpp b/src/Sigil/Dialogs/HeadingSelector.cpp index df577a63dd..1816cd88ae 100644 --- a/src/Sigil/Dialogs/HeadingSelector.cpp +++ b/src/Sigil/Dialogs/HeadingSelector.cpp @@ -42,7 +42,7 @@ const QString OLD_SIGIL_TOC_ID_PREFIX = "heading_id_"; // Constructor; // the first parameter is the book whose TOC // is being edited, the second is the dialog's parent -HeadingSelector::HeadingSelector(QSharedPointer< Book > book, QWidget *parent) +HeadingSelector::HeadingSelector(QSharedPointer book, QWidget *parent) : QDialog(parent), m_Book(book), @@ -56,8 +56,8 @@ HeadingSelector::HeadingSelector(QSharedPointer< Book > book, QWidget *parent) ConnectSignalsToSlots(); ui.tvTOCDisplay->setModel(&m_TableOfContents); LockHTMLResources(); - QList< Headings::Heading > flat_headings = Headings::GetHeadingList( - m_Book->GetFolderKeeper().GetResourceTypeList< HTMLResource >(true), true); + QList flat_headings = Headings::GetHeadingList( + m_Book->GetFolderKeeper().GetResourceTypeList(true), true); m_Headings = Headings::MakeHeadingHeirarchy(flat_headings); PopulateSelectHeadingCombo(GetMaxHeadingLevel(flat_headings)); RefreshTOCModelDisplay(); @@ -294,7 +294,7 @@ int HeadingSelector::UpdateOneHeadingElement(QStandardItem *item, QStringList us QString new_id_attribute(existing_id_attribute); if (!heading->include_in_toc || heading->at_file_start) { - // Since this heading is not being put in the toc or does not need an id + // Since this heading is not being put in the toc or does not need an id // because it is at the top of the file, we will remove any existing id from it // provided it is Sigil generated and not in use already. if (!used_ids.contains(existing_id_attribute) && @@ -421,7 +421,7 @@ void HeadingSelector::ChangeHeadingLevel(int change_amount) // Rename in document heading->element = XhtmlDoc::RenameElementInDocument(*heading->document, *heading->element, new_tag_name); // Clear all children information then rebuild hierarchy - QList< Headings::Heading > flat_headings = Headings::GetFlattenedHeadings(m_Headings); + QList flat_headings = Headings::GetFlattenedHeadings(m_Headings); for (int i = 0; i < flat_headings.count(); i++) { flat_headings[i].children.clear(); @@ -577,7 +577,7 @@ void HeadingSelector::InsertHeadingIntoModel(Headings::Heading &heading, QStanda // Apparently using \n in the string means you don't have to replace < with < or > with > QString html = XhtmlDoc::GetDomNodeAsString(*heading.element).remove("xmlns=\"http://www.w3.org/1999/xhtml\""); item_heading->setToolTip(heading.resource_file->Filename() + ":\n\n" + html); - QList< QStandardItem * > items; + QList items; items << item_heading << heading_level << heading_included_check; parent_item->appendRow(items); @@ -630,7 +630,7 @@ void HeadingSelector::RemoveExcludedItems(QStandardItem *item) if (check_state == Qt::Unchecked) { if (item->hasChildren()) { while (item->rowCount() > 0) { - QList< QStandardItem * > child_row = item->takeRow(0); + QList child_row = item->takeRow(0); if (!AddRowToVisiblePredecessorSucceeded(child_row, item)) { item_parent->insertRow(item->row(), child_row); @@ -644,7 +644,7 @@ void HeadingSelector::RemoveExcludedItems(QStandardItem *item) } -bool HeadingSelector::AddRowToVisiblePredecessorSucceeded(const QList< QStandardItem * > &child_row, +bool HeadingSelector::AddRowToVisiblePredecessorSucceeded(const QList &child_row, QStandardItem *row_parent) { Q_ASSERT(row_parent); @@ -662,7 +662,7 @@ bool HeadingSelector::AddRowToVisiblePredecessorSucceeded(const QList< QStandard // before the child_row heading whose parent heading is disappearing. The new parent // needs to also be marked as "include_in_toc". bool HeadingSelector::AddRowToCorrectItem(QStandardItem *item, - const QList< QStandardItem * > &child_row, + const QList &child_row, int child_index_limit) { int child_start_index = child_index_limit != -1 ? child_index_limit - 1 : item->rowCount() - 1; @@ -729,13 +729,13 @@ Headings::Heading *HeadingSelector::GetItemHeading(const QStandardItem *item) return NULL; } - Headings::Heading *heading = item->data().value< Headings::HeadingPointer >().heading; + Headings::Heading *heading = item->data().value().heading; return heading; } // Get the maximum heading level for all headings -int HeadingSelector::GetMaxHeadingLevel(QList< Headings::Heading > flat_headings) +int HeadingSelector::GetMaxHeadingLevel(QList flat_headings) { int maxLevel = 0; foreach(Headings::Heading heading, flat_headings) { @@ -857,7 +857,7 @@ void HeadingSelector::WriteSettings() void HeadingSelector::LockHTMLResources() { - foreach(HTMLResource * resource, m_Book->GetFolderKeeper().GetResourceTypeList< HTMLResource >(true)) { + foreach(HTMLResource * resource, m_Book->GetFolderKeeper().GetResourceTypeList(true)) { resource->GetLock().lockForWrite(); } } @@ -865,7 +865,7 @@ void HeadingSelector::LockHTMLResources() void HeadingSelector::UnlockHTMLResources() { - foreach(HTMLResource * resource, m_Book->GetFolderKeeper().GetResourceTypeList< HTMLResource >(true)) { + foreach(HTMLResource * resource, m_Book->GetFolderKeeper().GetResourceTypeList(true)) { resource->GetLock().unlock(); } } diff --git a/src/Sigil/Dialogs/HeadingSelector.h b/src/Sigil/Dialogs/HeadingSelector.h index d37ab7e1cb..eb6f09c2b6 100644 --- a/src/Sigil/Dialogs/HeadingSelector.h +++ b/src/Sigil/Dialogs/HeadingSelector.h @@ -45,7 +45,7 @@ class HeadingSelector : public QDialog // Constructor; // the first parameter is the book whose TOC // is being edited, the second is the dialog's parent - HeadingSelector(QSharedPointer< Book > book, QWidget *parent = 0); + HeadingSelector(QSharedPointer book, QWidget *parent = 0); // Destructor ~HeadingSelector(); @@ -131,7 +131,7 @@ private slots: // of those items rise to their parent's hierarchy level void RemoveExcludedItems(QStandardItem *item); - bool AddRowToVisiblePredecessorSucceeded(const QList< QStandardItem * > &child_row, + bool AddRowToVisiblePredecessorSucceeded(const QList &child_row, QStandardItem *row_parent); /** @@ -147,7 +147,7 @@ private slots: * a lower index than this. */ bool AddRowToCorrectItem(QStandardItem *item, - const QList< QStandardItem * > &child_row, + const QList &child_row, int child_index_limit = -1); QStandardItem *GetActualItemParent(const QStandardItem *item); @@ -156,7 +156,7 @@ private slots: // Get the maximum heading level for all headings - int GetMaxHeadingLevel(QList< Headings::Heading > flat_headings); + int GetMaxHeadingLevel(QList flat_headings); // Add the selectable entries to the Select Heading combo box void PopulateSelectHeadingCombo(int max_heading_level); @@ -191,13 +191,13 @@ private slots: /////////////////////////////// // The book whose TOC is being edited - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; // The model displayed and edited in the tree view QStandardItemModel m_TableOfContents; // The tree of all the headings in the book - QList< Headings::Heading > m_Headings; + QList m_Headings; QMenu *m_ContextMenu; diff --git a/src/Sigil/Dialogs/IndexEditor.h b/src/Sigil/Dialogs/IndexEditor.h index 1484896b2d..3531be18c8 100644 --- a/src/Sigil/Dialogs/IndexEditor.h +++ b/src/Sigil/Dialogs/IndexEditor.h @@ -118,7 +118,7 @@ private slots: IndexEditorModel *m_IndexEditorModel; - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; QString m_LastFolderOpen; diff --git a/src/Sigil/Dialogs/LinkStylesheets.cpp b/src/Sigil/Dialogs/LinkStylesheets.cpp index bba66fbd78..2496e2dc2b 100644 --- a/src/Sigil/Dialogs/LinkStylesheets.cpp +++ b/src/Sigil/Dialogs/LinkStylesheets.cpp @@ -29,7 +29,7 @@ static const QString SETTINGS_GROUP = "link_stylesheets"; // Constructor; -LinkStylesheets::LinkStylesheets(QList > stylesheets_map, QWidget *parent) +LinkStylesheets::LinkStylesheets(QList> stylesheets_map, QWidget *parent) : QDialog(parent), m_StylesheetsMap(stylesheets_map) @@ -85,7 +85,7 @@ void LinkStylesheets::InsertStylesheetIntoModel(std::pair stylesh item_included_check->setCheckState(Qt::Unchecked); } - QList< QStandardItem * > items; + QList items; items << item_included_check << item_filename; m_StylesheetsModel.invisibleRootItem()->appendRow(items); } @@ -132,7 +132,7 @@ void LinkStylesheets::MoveUp() return; } - QList< QStandardItem * > items = m_StylesheetsModel.invisibleRootItem()->takeRow(row - 1); + QList items = m_StylesheetsModel.invisibleRootItem()->takeRow(row - 1); m_StylesheetsModel.invisibleRootItem()->insertRow(row, items); } @@ -151,7 +151,7 @@ void LinkStylesheets::MoveDown() return; } - QList< QStandardItem * > items = m_StylesheetsModel.invisibleRootItem()->takeRow(row + 1); + QList items = m_StylesheetsModel.invisibleRootItem()->takeRow(row + 1); m_StylesheetsModel.invisibleRootItem()->insertRow(row, items); } @@ -162,7 +162,7 @@ void LinkStylesheets::UpdateStylesheets() int rows = m_StylesheetsModel.invisibleRootItem()->rowCount(); for (int row = 0; row < rows; row++) { - QList< QStandardItem * > items = m_StylesheetsModel.invisibleRootItem()->takeRow(0); + QList items = m_StylesheetsModel.invisibleRootItem()->takeRow(0); if (items.at(0)->checkState() == Qt::Checked) { m_Stylesheets << items.at(1)->data(Qt::DisplayRole).toString(); diff --git a/src/Sigil/Dialogs/LinkStylesheets.h b/src/Sigil/Dialogs/LinkStylesheets.h index feb0c30792..83b0e3259a 100644 --- a/src/Sigil/Dialogs/LinkStylesheets.h +++ b/src/Sigil/Dialogs/LinkStylesheets.h @@ -39,7 +39,7 @@ class LinkStylesheets : public QDialog // Constructor; // The first parameter is the list of included/excluded stylesheets - LinkStylesheets(QList > stylesheet_map, QWidget *parent = 0); + LinkStylesheets(QList> stylesheet_map, QWidget *parent = 0); QStringList GetStylesheets(); @@ -77,7 +77,7 @@ private slots: QStandardItemModel m_StylesheetsModel; // The list of stylesheets to include/exclude - QList< std::pair > m_StylesheetsMap; + QList> m_StylesheetsMap; // The new list of stylesheets to include QStringList m_Stylesheets; diff --git a/src/Sigil/Dialogs/MetaEditor.cpp b/src/Sigil/Dialogs/MetaEditor.cpp index 91f52695a8..4792d9ef3b 100644 --- a/src/Sigil/Dialogs/MetaEditor.cpp +++ b/src/Sigil/Dialogs/MetaEditor.cpp @@ -53,7 +53,7 @@ MetaEditor::~MetaEditor() } } -void MetaEditor::SetBook(QSharedPointer< Book > book) +void MetaEditor::SetBook(QSharedPointer book) { m_Book = book; m_OPF = &(m_Book->GetOPF()); @@ -273,9 +273,9 @@ void MetaEditor::AddMetaElement(QString name, QVariant value, QString role_type, void MetaEditor::SetDataModifiedIfNeeded() { if (m_OriginalData.title != ui.leTitle->text() || - m_OriginalData.author != ui.leAuthor->text() || - m_OriginalData.file_as != ui.leAuthorFileAs->text() || - m_OriginalData.language != ui.cbLanguages->currentText()) { + m_OriginalData.author != ui.leAuthor->text() || + m_OriginalData.file_as != ui.leAuthorFileAs->text() || + m_OriginalData.language != ui.cbLanguages->currentText()) { m_IsDataModified = true; } } @@ -385,9 +385,9 @@ bool MetaEditor::OkToSplitInput(const QString &metaname) } -QList< QVariant > MetaEditor::InputsInField(const QString &field_value) +QList MetaEditor::InputsInField(const QString &field_value) { - QList< QVariant > inputs; + QList inputs; foreach(QString input, field_value.split(";", QString::SkipEmptyParts)) { inputs.append(input.simplified()); } @@ -503,7 +503,7 @@ void MetaEditor::MoveUp() qSort(rows); // Move the rows as a block starting from the top foreach(int row, rows) { - QList< QStandardItem * > items = m_MetaModel.invisibleRootItem()->takeRow(row - 1); + QList items = m_MetaModel.invisibleRootItem()->takeRow(row - 1); m_MetaModel.invisibleRootItem()->insertRow(row, items); } } @@ -534,7 +534,7 @@ void MetaEditor::MoveDown() // Move the rows as a block starting from the bottom for (int i = rows.count() - 1; i >= 0; i--) { int row = rows.at(i); - QList< QStandardItem * > items = m_MetaModel.invisibleRootItem()->takeRow(row + 1); + QList items = m_MetaModel.invisibleRootItem()->takeRow(row + 1); m_MetaModel.invisibleRootItem()->insertRow(row, items); } } diff --git a/src/Sigil/Dialogs/MetaEditor.h b/src/Sigil/Dialogs/MetaEditor.h index f398fa0db7..946b633e4c 100644 --- a/src/Sigil/Dialogs/MetaEditor.h +++ b/src/Sigil/Dialogs/MetaEditor.h @@ -51,7 +51,7 @@ class MetaEditor : public QDialog */ MetaEditor(QWidget *parent = 0); ~MetaEditor(); - void SetBook(QSharedPointer< Book > book); + void SetBook(QSharedPointer book); void ForceClose(); signals: @@ -180,7 +180,7 @@ private slots: * @param field_value The raw string value of the field. * @return The list of actual metadata values. */ - static QList< QVariant > InputsInField(const QString &field_value); + static QList InputsInField(const QString &field_value); /** * Fills the language combobox with all the supported languages. @@ -233,9 +233,9 @@ private slots: * * @see Book::m_Metadata */ - QList< Metadata::MetaElement > m_Metadata; + QList m_Metadata; - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; MetaEditorItemDelegate *m_cbDelegate; diff --git a/src/Sigil/Dialogs/PluginRunner.cpp b/src/Sigil/Dialogs/PluginRunner.cpp index 412f4cc420..9870d2185b 100644 --- a/src/Sigil/Dialogs/PluginRunner.cpp +++ b/src/Sigil/Dialogs/PluginRunner.cpp @@ -27,17 +27,17 @@ const QString PluginRunner::NCXFILEINFO = "OEBPS/toc.ncx" + SEP + SEP + "applica const QStringList PluginRunner::CHANGESTAGS = QStringList() << "deleted" << "added" << "modified"; -PluginRunner::PluginRunner(TabManager* tabMgr, QWidget * parent) +PluginRunner::PluginRunner(TabManager *tabMgr, QWidget *parent) : QDialog(parent), - m_mainWindow(qobject_cast(parent)), - m_tabManager(tabMgr), - m_outputDir(m_folder.GetPath()), - m_pluginName(""), - m_pluginOutput(""), - m_algorithm(""), - m_result(""), - m_xhtml_net_change(0), - m_ready(false) + m_mainWindow(qobject_cast(parent)), + m_tabManager(tabMgr), + m_outputDir(m_folder.GetPath()), + m_pluginName(""), + m_pluginOutput(""), + m_algorithm(""), + m_result(""), + m_xhtml_net_change(0), + m_ready(false) { // get book manipulation objects @@ -47,9 +47,9 @@ PluginRunner::PluginRunner(TabManager* tabMgr, QWidget * parent) // set default font obfuscation algorithm to use // ADOBE_FONT_ALGO_ID or IDPF_FONT_ALGO_ID ?? - QList< Resource * > fonts = m_book->GetFolderKeeper().GetResourceListByType(Resource::FontResourceType); + QList fonts = m_book->GetFolderKeeper().GetResourceListByType(Resource::FontResourceType); foreach (Resource * resource, fonts) { - FontResource * font_resource = qobject_cast< FontResource * > (resource); + FontResource *font_resource = qobject_cast (resource); QString algorithm = font_resource->GetObfuscationAlgorithm(); if (!algorithm.isEmpty()) { m_algorithm = algorithm; @@ -58,7 +58,7 @@ PluginRunner::PluginRunner(TabManager* tabMgr, QWidget * parent) } // build hashes of href (book root relative path) to resources - QList< Resource * > resources = m_book->GetFolderKeeper().GetResourceList(); + QList resources = m_book->GetFolderKeeper().GetResourceList(); foreach (Resource * resource, resources) { QString href = resource->GetRelativePathToRoot(); if (resource->Type() == Resource::HTMLResourceType) { @@ -113,7 +113,7 @@ int PluginRunner::exec(const QString &name) return QDialog::Rejected; } - // The launcher and plugin path are both platform specific and engine/interpreter specific + // The launcher and plugin path are both platform specific and engine/interpreter specific launcher_root = PluginDB::launcherRoot(); // Note: Keep SupportedEngines() in sync with the engine calling code here. @@ -121,13 +121,13 @@ int PluginRunner::exec(const QString &name) m_launcherPath = launcher_root + "/python/launcher.py"; m_pluginPath = m_pluginsFolder + "/" + m_pluginName + "/" + "plugin.py"; if (!QFileInfo(m_launcherPath).exists()) { - Utility::DisplayStdErrorDialog(tr("Installation Error: plugin launcher ") + + Utility::DisplayStdErrorDialog(tr("Installation Error: plugin launcher ") + m_launcherPath + tr(" does not exist")); reject(); return QDialog::Rejected; } } else { - Utility::DisplayStdErrorDialog(tr("Error: plugin engine ") + + Utility::DisplayStdErrorDialog(tr("Error: plugin engine ") + m_engine + tr(" is not supported (yet!)")); reject(); return QDialog::Rejected; @@ -143,7 +143,7 @@ int PluginRunner::exec(const QString &name) return QDialog::exec(); } -void PluginRunner::startPlugin() +void PluginRunner::startPlugin() { QStringList args; if (!m_ready) { @@ -179,18 +179,18 @@ void PluginRunner::startPlugin() } -void PluginRunner::processOutput() +void PluginRunner::processOutput() { QByteArray newbytedata = m_process.readAllStandardOutput(); m_pluginOutput = m_pluginOutput + newbytedata ; } -void PluginRunner::pluginFinished(int exitcode, QProcess::ExitStatus exitstatus) +void PluginRunner::pluginFinished(int exitcode, QProcess::ExitStatus exitstatus) { if (exitstatus == QProcess::CrashExit) { ui.textEdit->append(tr("Launcher process crashed")); - } + } // launcher exiting properly does not mean target plugin succeeded or failed // we need to parse the response xml to find the true result of target plugin ui.okButton->setEnabled(true); @@ -218,7 +218,7 @@ void PluginRunner::pluginFinished(int exitcode, QProcess::ExitStatus exitstatus) // don't allow changes to proceed if they will remove the very last xhtml/html file if (m_xhtml_net_change < 0) { - QList< Resource * > htmlresources = m_book->GetFolderKeeper().GetResourceListByType(Resource::HTMLResourceType); + QList htmlresources = m_book->GetFolderKeeper().GetResourceListByType(Resource::HTMLResourceType); if (htmlresources.count() + m_xhtml_net_change < 0) { Utility::DisplayStdErrorDialog(tr("Error: Plugin Tried to Remove the Last XHTML file .. aborting changes")); ui.statusLbl->setText(tr("Status: No Changes Made")); @@ -235,7 +235,7 @@ void PluginRunner::pluginFinished(int exitcode, QProcess::ExitStatus exitstatus) // before deleting make sure a tab of at least one of the remaining html files will be open // to prevent deleting the last tab when deleting resources - QList < Resource * > remainingResources = m_xhtmlFiles.values(); + QList remainingResources = m_xhtmlFiles.values(); QList tabResources = m_tabManager->GetTabResources(); bool tabs_will_remain = false; foreach (Resource * tab_resource, tabResources) { @@ -245,7 +245,7 @@ void PluginRunner::pluginFinished(int exitcode, QProcess::ExitStatus exitstatus) } } if (! tabs_will_remain) { - Resource * xhtmlresource = remainingResources.at(0); + Resource *xhtmlresource = remainingResources.at(0); m_mainWindow->OpenResource(*xhtmlresource); } @@ -321,7 +321,7 @@ bool PluginRunner::processResultXML() while (!reader.atEnd()) { reader.readNext(); if (reader.isStartElement()) { - QString name = reader.name().toString(); + QString name = reader.name().toString(); if (name == "result") { QString result = reader.readElementText(); m_result = result; @@ -350,7 +350,9 @@ bool PluginRunner::processResultXML() } } else if (reader.name() == "added") { m_filesToAdd.append(fileinfo); - if (mime == "application/xhtml+xml") m_xhtml_net_change++; + if (mime == "application/xhtml+xml") { + m_xhtml_net_change++; + } } else { m_filesToModify.append(fileinfo); } @@ -379,10 +381,15 @@ bool PluginRunner::checkIsWellFormed() QString href = fdata[ hrefField ]; QString id = fdata[ idField ]; QString mime = fdata[ mimeField ]; - if (mime == "application/oebps-package+xml") filesToCheck.append(href); - else if (mime == "application/x-dtbncx+xml") filesToCheck.append(href); - else if (mime == "application/oebs-page-map+xml") filesToCheck.append(href); - else if (mime == "application/xhtml+xml") filesToCheck.append(href); + if (mime == "application/oebps-package+xml") { + filesToCheck.append(href); + } else if (mime == "application/x-dtbncx+xml") { + filesToCheck.append(href); + } else if (mime == "application/oebs-page-map+xml") { + filesToCheck.append(href); + } else if (mime == "application/xhtml+xml") { + filesToCheck.append(href); + } } } if (!m_filesToModify.isEmpty()) { @@ -391,10 +398,15 @@ bool PluginRunner::checkIsWellFormed() QString href = fdata[ hrefField ]; QString id = fdata[ idField ]; QString mime = fdata[ mimeField ]; - if (mime == "application/oebps-package+xml") filesToCheck.append(href); - else if (mime == "application/x-dtbncx+xml") filesToCheck.append(href); - else if (mime == "application/oebs-page-map+xml") filesToCheck.append(href); - else if (mime == "application/xhtml+xml") filesToCheck.append(href); + if (mime == "application/oebps-package+xml") { + filesToCheck.append(href); + } else if (mime == "application/x-dtbncx+xml") { + filesToCheck.append(href); + } else if (mime == "application/oebs-page-map+xml") { + filesToCheck.append(href); + } else if (mime == "application/xhtml+xml") { + filesToCheck.append(href); + } } } if (!filesToCheck.isEmpty()) { @@ -404,8 +416,8 @@ bool PluginRunner::checkIsWellFormed() QString data = Utility::ReadUnicodeTextFile(filePath); XhtmlDoc::WellFormedError error = XhtmlDoc::WellFormedErrorForSource(data); if (error.line != -1) { - errors.append(tr("Incorrect XHTML/XML: ") + href + tr(" Line/Col ") + QString::number(error.line) + - "," + QString::number(error.column) + " " + error.message); + errors.append(tr("Incorrect XHTML/XML: ") + href + tr(" Line/Col ") + QString::number(error.line) + + "," + QString::number(error.column) + " " + error.message); well_formed = false; } } @@ -419,8 +431,8 @@ bool PluginRunner::checkIsWellFormed() msgBox.setWindowTitle(tr("Check Report")); msgBox.setText(tr("Incorrect XHTML/XML Detected\nAre you Sure You Want to Continue?")); msgBox.setDetailedText(errors.join("\n")); - QPushButton * yesButton = msgBox.addButton(QMessageBox::Yes); - QPushButton * noButton = msgBox.addButton(QMessageBox::No); + QPushButton *yesButton = msgBox.addButton(QMessageBox::Yes); + QPushButton *noButton = msgBox.addButton(QMessageBox::No); msgBox.setDefaultButton(noButton); msgBox.exec(); if (msgBox.clickedButton() == yesButton) { @@ -431,7 +443,7 @@ bool PluginRunner::checkIsWellFormed() } -bool PluginRunner::deleteFiles(const QStringList & files) +bool PluginRunner::deleteFiles(const QStringList &files) { QList tabResources=m_tabManager->GetTabResources(); bool changes_made = false; @@ -442,13 +454,17 @@ bool PluginRunner::deleteFiles(const QStringList & files) QString id = fdata[ idField ]; QString mime = fdata[ mimeField ]; // content.opf and toc.ncx can not be added or deleted - if (mime == "application/oebps-package+xml") continue; - if (mime == "application/x-dtbncx+xml") continue; - Resource * resource = m_hrefToRes.value(href, NULL); + if (mime == "application/oebps-package+xml") { + continue; + } + if (mime == "application/x-dtbncx+xml") { + continue; + } + Resource *resource = m_hrefToRes.value(href, NULL); if (resource) { ui.statusLbl->setText(tr("Status: deleting ") + resource->Filename()); - if(tabResources.contains(resource)) { + if (tabResources.contains(resource)) { m_tabManager->CloseTabForResource(*resource); } m_book->GetFolderKeeper().RemoveResource(*resource); @@ -462,7 +478,7 @@ bool PluginRunner::deleteFiles(const QStringList & files) } -bool PluginRunner::addFiles(const QStringList & files) +bool PluginRunner::addFiles(const QStringList &files) { ui.statusLbl->setText("Status: adding files"); foreach (QString fileinfo, files) { @@ -488,8 +504,8 @@ bool PluginRunner::addFiles(const QStringList & files) msgBox.setWindowFlags(Qt::Window | Qt::WindowStaysOnTopHint); msgBox.setWindowTitle(tr("Input Plugin")); msgBox.setText(tr("Your current book will be completely replaced losing any unsaved changes ... Are you sure you want to proceed")); - QPushButton * yesButton = msgBox.addButton(QMessageBox::Yes); - QPushButton * noButton = msgBox.addButton(QMessageBox::No); + QPushButton *yesButton = msgBox.addButton(QMessageBox::Yes); + QPushButton *noButton = msgBox.addButton(QMessageBox::No); msgBox.setDefaultButton(noButton); msgBox.exec(); if (msgBox.clickedButton() == yesButton) { @@ -503,15 +519,19 @@ bool PluginRunner::addFiles(const QStringList & files) } // content.opf and toc.ncx can not be added or deleted - if (mime == "application/oebps-package+xml") continue; - if (mime == "application/x-dtbncx+xml") continue; + if (mime == "application/oebps-package+xml") { + continue; + } + if (mime == "application/x-dtbncx+xml") { + continue; + } // No need to copy to ebook root as AddContentToFolder does that for us QString inpath = m_outputDir + "/" + href; QFileInfo fi(inpath); ui.statusLbl->setText(tr("Status: adding ") + fi.fileName()); - Resource & resource = m_book->GetFolderKeeper().AddContentFileToFolder(inpath,false); + Resource &resource = m_book->GetFolderKeeper().AddContentFileToFolder(inpath,false); // AudioResource, VideoResource, FontResource, ImageResource do not appear to be cached @@ -522,32 +542,32 @@ bool PluginRunner::addFiles(const QStringList & files) if (resource.Type() == Resource::FontResourceType && !m_algorithm.isEmpty()) { - FontResource * font_resource = qobject_cast< FontResource * > (&resource); + FontResource *font_resource = qobject_cast (&resource); font_resource->SetObfuscationAlgorithm(m_algorithm); } else if (resource.Type() == Resource::HTMLResourceType) { - HTMLResource * html_resource = qobject_cast< HTMLResource * > (&resource); + HTMLResource *html_resource = qobject_cast (&resource); html_resource->SetText(Utility::ReadUnicodeTextFile(inpath)); } else if (resource.Type() == Resource::CSSResourceType) { - CSSResource * css_resource = qobject_cast< CSSResource * > (&resource); + CSSResource *css_resource = qobject_cast (&resource); css_resource->SetText(Utility::ReadUnicodeTextFile(inpath)); } else if (resource.Type() == Resource::SVGResourceType) { - SVGResource * svg_resource = qobject_cast< SVGResource * > (&resource); + SVGResource *svg_resource = qobject_cast (&resource); svg_resource->SetText(Utility::ReadUnicodeTextFile(inpath)); } else if (resource.Type() == Resource::MiscTextResourceType) { - MiscTextResource * misctext_resource = qobject_cast< MiscTextResource * > (&resource); + MiscTextResource *misctext_resource = qobject_cast (&resource); misctext_resource->SetText(Utility::ReadUnicodeTextFile(inpath)); } else if (resource.Type() == Resource::XMLResourceType) { - XMLResource * xml_resource = qobject_cast< XMLResource * > (&resource); + XMLResource *xml_resource = qobject_cast (&resource); xml_resource->SetText(Utility::ReadUnicodeTextFile(inpath)); } } @@ -555,7 +575,7 @@ bool PluginRunner::addFiles(const QStringList & files) } -bool PluginRunner::modifyFiles(const QStringList & files) +bool PluginRunner::modifyFiles(const QStringList &files) { ui.statusLbl->setText(tr("Status: cleaning up - modifying files")); // rearrange list to force content.opf and toc.ncx modifications to be done last @@ -571,8 +591,12 @@ bool PluginRunner::modifyFiles(const QStringList & files) newfiles.append(fileinfo); } } - if (!modifyopf.isEmpty()) newfiles.append(modifyopf); - if (!modifyncx.isEmpty()) newfiles.append(modifyncx); + if (!modifyopf.isEmpty()) { + newfiles.append(modifyopf); + } + if (!modifyncx.isEmpty()) { + newfiles.append(modifyncx); + } foreach (QString fileinfo, newfiles) { QStringList fdata = fileinfo.split(SEP); @@ -584,7 +608,7 @@ bool PluginRunner::modifyFiles(const QStringList & files) QFileInfo fi(outpath); ui.statusLbl->setText(tr("Status: modifying ") + fi.fileName()); Utility::ForceCopyFile(inpath, outpath); - Resource * resource = m_hrefToRes.value(href); + Resource *resource = m_hrefToRes.value(href); if (resource) { // AudioResource, VideoResource, FontResource, ImageResource do not appear to be editable @@ -594,40 +618,40 @@ bool PluginRunner::modifyFiles(const QStringList & files) if (resource->Type() == Resource::HTMLResourceType) { - HTMLResource * html_resource = qobject_cast< HTMLResource * > (resource); + HTMLResource *html_resource = qobject_cast (resource); html_resource->SetText(Utility::ReadUnicodeTextFile(inpath)); } else if (resource->Type() == Resource::CSSResourceType) { - CSSResource * css_resource = qobject_cast< CSSResource * > (resource); + CSSResource *css_resource = qobject_cast (resource); css_resource->SetText(Utility::ReadUnicodeTextFile(inpath)); } else if (resource->Type() == Resource::SVGResourceType) { - SVGResource * svg_resource = qobject_cast< SVGResource * > (resource); + SVGResource *svg_resource = qobject_cast (resource); svg_resource->SetText(Utility::ReadUnicodeTextFile(inpath)); } else if (resource->Type() == Resource::MiscTextResourceType) { - MiscTextResource * misctext_resource = qobject_cast< MiscTextResource * > (resource); + MiscTextResource *misctext_resource = qobject_cast (resource); misctext_resource->SetText(Utility::ReadUnicodeTextFile(inpath)); - } else if (resource->Type() == Resource::OPFResourceType) { + } else if (resource->Type() == Resource::OPFResourceType) { - OPFResource * opf_resource = qobject_cast< OPFResource * > (resource); + OPFResource *opf_resource = qobject_cast (resource); opf_resource->SetText(Utility::ReadUnicodeTextFile(outpath)); - } else if (resource->Type() == Resource::NCXResourceType) { + } else if (resource->Type() == Resource::NCXResourceType) { - NCXResource * ncx_resource = qobject_cast< NCXResource * > (resource); + NCXResource *ncx_resource = qobject_cast (resource); ncx_resource->SetText(Utility::ReadUnicodeTextFile(outpath)); } else if (resource->Type() == Resource::XMLResourceType) { - XMLResource * xml_resource = qobject_cast< XMLResource * > (resource); + XMLResource *xml_resource = qobject_cast (resource); xml_resource->SetText(Utility::ReadUnicodeTextFile(inpath)); } - } + } } return true; } diff --git a/src/Sigil/Dialogs/PluginRunner.h b/src/Sigil/Dialogs/PluginRunner.h index 5350b1fb06..9e517e0835 100644 --- a/src/Sigil/Dialogs/PluginRunner.h +++ b/src/Sigil/Dialogs/PluginRunner.h @@ -93,10 +93,10 @@ private slots: QProcess m_process; - MainWindow * m_mainWindow; - TabManager * m_tabManager; + MainWindow *m_mainWindow; + TabManager *m_tabManager; QSharedPointer m_book; - BookBrowser * m_bookBrowser; + BookBrowser *m_bookBrowser; TempFolder m_folder; QString m_outputDir; @@ -119,8 +119,8 @@ private slots: int m_xhtml_net_change; - QHash < QString, Resource * > m_hrefToRes; - QHash < QString, Resource * > m_xhtmlFiles; + QHash m_hrefToRes; + QHash m_xhtmlFiles; bool m_ready; diff --git a/src/Sigil/Dialogs/PreferenceWidgets/KeyboardShortcutsWidget.cpp b/src/Sigil/Dialogs/PreferenceWidgets/KeyboardShortcutsWidget.cpp index bcf18e7e54..ea54f165a5 100644 --- a/src/Sigil/Dialogs/PreferenceWidgets/KeyboardShortcutsWidget.cpp +++ b/src/Sigil/Dialogs/PreferenceWidgets/KeyboardShortcutsWidget.cpp @@ -287,7 +287,7 @@ void KeyboardShortcutsWidget::markSequencesAsDuplicatedIfNeeded() { // This is not optized , but since this will be called rather seldom // effort for optimization may not be worth it - QMap > seqMap; + QMap> seqMap; // Go through all items for (int i = 0; i < ui.commandList->topLevelItemCount(); i++) { diff --git a/src/Sigil/Dialogs/PreferenceWidgets/PluginWidget.cpp b/src/Sigil/Dialogs/PreferenceWidgets/PluginWidget.cpp index 50480c5b15..b75df19466 100644 --- a/src/Sigil/Dialogs/PreferenceWidgets/PluginWidget.cpp +++ b/src/Sigil/Dialogs/PreferenceWidgets/PluginWidget.cpp @@ -17,9 +17,9 @@ #include "Misc/Utility.h" -PluginWidget::PluginWidget() +PluginWidget::PluginWidget() : - m_isDirty(false) + m_isDirty(false) { ui.setupUi(this); readSettings(); @@ -30,7 +30,7 @@ PluginWidget::PluginWidget() PluginWidget::ResultAction PluginWidget::saveSettings() { if (!m_isDirty) { - return PreferencesWidget::ResultAction_None; + return PreferencesWidget::ResultAction_None; } PluginDB *pdb = PluginDB::instance(); @@ -116,12 +116,15 @@ void PluginWidget::addPlugin() QString pluginname = zipinfo.baseName(); // strip off any versioning present in zip name after first "_" to get internal folder name int version_index = pluginname.indexOf("_"); - if (version_index > -1) pluginname.truncate(version_index); + if (version_index > -1) { + pluginname.truncate(version_index); + } Plugin *p = pdb->get_plugin(pluginname); - if (p == NULL) + if (p == NULL) { return; + } int rows = ui.pluginTable->rowCount(); ui.pluginTable->insertRow(rows); @@ -134,7 +137,7 @@ void PluginWidget::addPlugin() void PluginWidget::removePlugin() { // limited to work with one selection at a time to prevent row mixup upon removal - QList itemlist = ui.pluginTable->selectedItems(); + QList itemlist = ui.pluginTable->selectedItems(); if (itemlist.isEmpty()) { Utility::DisplayStdWarningDialog(tr("Nothing is Selected.")); return; @@ -174,7 +177,9 @@ void PluginWidget::removeAllPlugins() void PluginWidget::AutoFindPy2() { QString p2path = QStandardPaths::findExecutable("python2"); - if (p2path.isEmpty()) p2path = QStandardPaths::findExecutable("python"); + if (p2path.isEmpty()) { + p2path = QStandardPaths::findExecutable("python"); + } ui.editPathPy2->setText(p2path); m_isDirty = true; } @@ -182,7 +187,9 @@ void PluginWidget::AutoFindPy2() void PluginWidget::AutoFindPy3() { QString p3path = QStandardPaths::findExecutable("python3"); - if (p3path.isEmpty()) p3path = QStandardPaths::findExecutable("python"); + if (p3path.isEmpty()) { + p3path = QStandardPaths::findExecutable("python"); + } ui.editPathPy3->setText(p3path); m_isDirty = true; } @@ -213,7 +220,7 @@ void PluginWidget::enginePy2PathChanged() QString enginepath = ui.editPathPy2->text(); if (!enginepath.isEmpty()) { QFileInfo enginfo(enginepath); - if (!enginfo.exists() || !enginfo.isFile() || !enginfo.isReadable() || !enginfo.isExecutable() ){ + if (!enginfo.exists() || !enginfo.isFile() || !enginfo.isReadable() || !enginfo.isExecutable() ) { disconnect(ui.editPathPy2, SIGNAL(editingFinished()), this, SLOT(enginePy2PathChanged())); Utility::DisplayStdWarningDialog(tr("Incorrect Interpreter Path selected")); ui.editPathPy2->setText(""); @@ -229,7 +236,7 @@ void PluginWidget::enginePy3PathChanged() QString enginepath = ui.editPathPy3->text(); if (!enginepath.isEmpty()) { QFileInfo enginfo(enginepath); - if (!enginfo.exists() || !enginfo.isFile() || !enginfo.isReadable() || !enginfo.isExecutable() ){ + if (!enginfo.exists() || !enginfo.isFile() || !enginfo.isReadable() || !enginfo.isExecutable() ) { disconnect(ui.editPathPy3, SIGNAL(editingFinished()), this, SLOT(enginePy3PathChanged())); Utility::DisplayStdWarningDialog(tr("Incorrect Interpreter Path selected")); ui.editPathPy3->setText(""); diff --git a/src/Sigil/Dialogs/PreferenceWidgets/PreserveEntitiesWidget.cpp b/src/Sigil/Dialogs/PreferenceWidgets/PreserveEntitiesWidget.cpp index 3b8e74635c..1fd4ccfb54 100644 --- a/src/Sigil/Dialogs/PreferenceWidgets/PreserveEntitiesWidget.cpp +++ b/src/Sigil/Dialogs/PreferenceWidgets/PreserveEntitiesWidget.cpp @@ -43,12 +43,12 @@ PreferencesWidget::ResultAction PreserveEntitiesWidget::saveSettings() // Save preserve entities information SettingsStore settings; - QList< std::pair< ushort, QString > > codenames; + QList> codenames; for (int i = 0; i < ui.entityList->count(); ++i) { QString name = ui.entityList->item(i)->text(); ushort code = XMLEntities::instance()->GetEntityCode(name); if (code > 0) { - std::pair < ushort, QString > epair( code, name ); + std::pair epair( code, name ); codenames.append(epair); } } @@ -73,7 +73,7 @@ void PreserveEntitiesWidget::addEntities() // Add the entities to the list foreach(QString name, names) { if (!name.isEmpty()) { - if (XMLEntities::instance()->GetEntityCode(name) > 0) { + if (XMLEntities::instance()->GetEntityCode(name) > 0) { QListWidgetItem *item = new QListWidgetItem(name, ui.entityList); item->setFlags(item->flags() | Qt::ItemIsEditable); ui.entityList->addItem(item); @@ -105,8 +105,8 @@ void PreserveEntitiesWidget::readSettings() { // Load the available entities. SettingsStore settings; - std::pair < ushort, QString > epair; - QList < std::pair < ushort, QString > > codenames = settings.preserveEntityCodeNames(); + std::pair epair; + QList > codenames = settings.preserveEntityCodeNames(); QStringList names; ui.entityList->clear(); foreach( epair, codenames) { diff --git a/src/Sigil/Dialogs/PreferenceWidgets/SpellCheckWidget.cpp b/src/Sigil/Dialogs/PreferenceWidgets/SpellCheckWidget.cpp index 7468cc0156..7f9f00686e 100644 --- a/src/Sigil/Dialogs/PreferenceWidgets/SpellCheckWidget.cpp +++ b/src/Sigil/Dialogs/PreferenceWidgets/SpellCheckWidget.cpp @@ -178,8 +178,7 @@ void SpellCheckWidget::addNewItem(bool enabled, QString dict_name) checkbox_item->setCheckState(Qt::Checked); if (enabled) { checkbox_item->setCheckState(Qt::Checked); - } - else { + } else { checkbox_item->setCheckState(Qt::Unchecked); } rowItems << checkbox_item; @@ -278,7 +277,7 @@ void SpellCheckWidget::copyUserDict() if (!item) { return; - } + } // Get the current words, before creating so list doesn't change QStringList words; diff --git a/src/Sigil/Dialogs/Preferences.cpp b/src/Sigil/Dialogs/Preferences.cpp index dc14dd4d81..791390b4ac 100644 --- a/src/Sigil/Dialogs/Preferences.cpp +++ b/src/Sigil/Dialogs/Preferences.cpp @@ -124,9 +124,9 @@ void Preferences::readSettings() int last_preference_index = settings.value("lastpreference", 0).toInt(); if (last_preference_index > ui.availableWidgets->count() - 1) { - last_preference_index = 0; + last_preference_index = 0; } - + ui.availableWidgets->setCurrentRow(last_preference_index); settings.endGroup(); } diff --git a/src/Sigil/Dialogs/Reports.cpp b/src/Sigil/Dialogs/Reports.cpp index 79c06b471e..6249ec24d1 100644 --- a/src/Sigil/Dialogs/Reports.cpp +++ b/src/Sigil/Dialogs/Reports.cpp @@ -107,7 +107,7 @@ Reports::~Reports() } } -void Reports::CreateReports(QSharedPointer< Book > book) +void Reports::CreateReports(QSharedPointer book) { QApplication::setOverrideCursor(Qt::WaitCursor); // Display progress dialog diff --git a/src/Sigil/Dialogs/Reports.h b/src/Sigil/Dialogs/Reports.h index 053699f3cb..0c932ae867 100644 --- a/src/Sigil/Dialogs/Reports.h +++ b/src/Sigil/Dialogs/Reports.h @@ -46,7 +46,7 @@ class Reports : public QDialog Reports(QWidget *parent = 0); ~Reports(); - void CreateReports(QSharedPointer< Book > book); + void CreateReports(QSharedPointer book); signals: void Refresh(); diff --git a/src/Sigil/Dialogs/ReportsWidgets/AllFilesWidget.cpp b/src/Sigil/Dialogs/ReportsWidgets/AllFilesWidget.cpp index 6a04b32139..4546ea8df0 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/AllFilesWidget.cpp +++ b/src/Sigil/Dialogs/ReportsWidgets/AllFilesWidget.cpp @@ -50,7 +50,7 @@ AllFilesWidget::AllFilesWidget() connectSignalsSlots(); } -void AllFilesWidget::CreateReport(QSharedPointer< Book > book) +void AllFilesWidget::CreateReport(QSharedPointer book) { m_Book = book; m_AllResources = m_Book->GetAllResources(); @@ -205,7 +205,7 @@ void AllFilesWidget::Save() row_text.append(text); } else { row_text.append("," % text); - } + } } report_info.append(row_text % "\n"); @@ -309,7 +309,7 @@ QString AllFilesWidget::GetType(Resource *resource) break; } - case Resource::MiscTextResourceType: + case Resource::MiscTextResourceType: case Resource::TextResourceType: { type = "Text"; break; diff --git a/src/Sigil/Dialogs/ReportsWidgets/AllFilesWidget.h b/src/Sigil/Dialogs/ReportsWidgets/AllFilesWidget.h index 19ae96c2d2..f05dbbbc6d 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/AllFilesWidget.h +++ b/src/Sigil/Dialogs/ReportsWidgets/AllFilesWidget.h @@ -48,7 +48,7 @@ class AllFilesWidget : public ReportsWidget public: AllFilesWidget(); - void CreateReport(QSharedPointer< Book > book); + void CreateReport(QSharedPointer book); void SetupTable(int sort_column = 1, Qt::SortOrder sort_order = Qt::AscendingOrder); @@ -75,7 +75,7 @@ private slots: QList m_AllResources; - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; QStandardItemModel *m_ItemModel; diff --git a/src/Sigil/Dialogs/ReportsWidgets/CSSFilesWidget.cpp b/src/Sigil/Dialogs/ReportsWidgets/CSSFilesWidget.cpp index 4535565628..6af3527f6b 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/CSSFilesWidget.cpp +++ b/src/Sigil/Dialogs/ReportsWidgets/CSSFilesWidget.cpp @@ -53,11 +53,11 @@ CSSFilesWidget::CSSFilesWidget() connectSignalsSlots(); } -void CSSFilesWidget::CreateReport(QSharedPointer< Book > book) +void CSSFilesWidget::CreateReport(QSharedPointer book) { m_Book = book; - m_HTMLResources = m_Book->GetFolderKeeper().GetResourceTypeList< HTMLResource >(false); - m_CSSResources = m_Book->GetFolderKeeper().GetResourceTypeList< CSSResource >(false); + m_HTMLResources = m_Book->GetFolderKeeper().GetResourceTypeList(false); + m_CSSResources = m_Book->GetFolderKeeper().GetResourceTypeList(false); SetupTable(); } @@ -226,12 +226,12 @@ void CSSFilesWidget::Save() QString text = ""; if (item) { text = item->text(); - } + } if (col == 0) { row_text.append(text); } else { row_text.append("," % text); - } + } } report_info.append(row_text % "\n"); diff --git a/src/Sigil/Dialogs/ReportsWidgets/CSSFilesWidget.h b/src/Sigil/Dialogs/ReportsWidgets/CSSFilesWidget.h index d1302c1ff9..1c84fef0ae 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/CSSFilesWidget.h +++ b/src/Sigil/Dialogs/ReportsWidgets/CSSFilesWidget.h @@ -47,7 +47,7 @@ class CSSFilesWidget : public ReportsWidget public: CSSFilesWidget(); - void CreateReport(QSharedPointer< Book > book); + void CreateReport(QSharedPointer book); void SetupTable(int sort_column = 1, Qt::SortOrder sort_order = Qt::AscendingOrder); diff --git a/src/Sigil/Dialogs/ReportsWidgets/CharactersInHTMLFilesWidget.cpp b/src/Sigil/Dialogs/ReportsWidgets/CharactersInHTMLFilesWidget.cpp index 6cc0f2baaa..86c49519ba 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/CharactersInHTMLFilesWidget.cpp +++ b/src/Sigil/Dialogs/ReportsWidgets/CharactersInHTMLFilesWidget.cpp @@ -54,7 +54,7 @@ CharactersInHTMLFilesWidget::CharactersInHTMLFilesWidget() connectSignalsSlots(); } -void CharactersInHTMLFilesWidget::CreateReport(QSharedPointer< Book > book) +void CharactersInHTMLFilesWidget::CreateReport(QSharedPointer book) { m_Book = book; SetupTable(); @@ -88,7 +88,7 @@ void CharactersInHTMLFilesWidget::SetupTable() void CharactersInHTMLFilesWidget::AddTableData() { const QList html_resources = m_Book->GetHTMLResources(); - QList < QChar > characters = GetDisplayedCharacters(html_resources); + QList characters = GetDisplayedCharacters(html_resources); QString all_characters; foreach (QChar c, characters) { all_characters.append(c); @@ -135,7 +135,7 @@ void CharactersInHTMLFilesWidget::PageLoaded() m_PageLoaded = true; } -QList < QChar > CharactersInHTMLFilesWidget::GetDisplayedCharacters(QList< HTMLResource * > resources) +QList CharactersInHTMLFilesWidget::GetDisplayedCharacters(QList resources) { QWebView *view = new QWebView(); view->setGeometry(0,0,200,200); @@ -162,13 +162,13 @@ QList < QChar > CharactersInHTMLFilesWidget::GetDisplayedCharacters(QList< HTMLR all_characters.append(text); } - QMap < QChar, QChar> character_map; + QMap character_map; foreach (const QChar c, all_characters) { if (c != '\n') { character_map.insert(c, c); } } - QList < QChar > character_list; + QList character_list; character_list = character_map.values(); return character_list; @@ -231,7 +231,7 @@ void CharactersInHTMLFilesWidget::Save() row_text.append(text); } else { row_text.append("," % text); - } + } } report_info.append(row_text % "\n"); diff --git a/src/Sigil/Dialogs/ReportsWidgets/CharactersInHTMLFilesWidget.h b/src/Sigil/Dialogs/ReportsWidgets/CharactersInHTMLFilesWidget.h index 6e736296d7..21da16c07b 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/CharactersInHTMLFilesWidget.h +++ b/src/Sigil/Dialogs/ReportsWidgets/CharactersInHTMLFilesWidget.h @@ -45,7 +45,7 @@ class CharactersInHTMLFilesWidget : public ReportsWidget public: CharactersInHTMLFilesWidget(); - void CreateReport(QSharedPointer< Book > m_Book); + void CreateReport(QSharedPointer m_Book); signals: void CloseDialog(); @@ -69,9 +69,9 @@ private slots: void SetupTable(); void AddTableData(); - QList < QChar > GetDisplayedCharacters(QList< HTMLResource * > resources); + QList GetDisplayedCharacters(QList resources); - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; QStandardItemModel *m_ItemModel; diff --git a/src/Sigil/Dialogs/ReportsWidgets/ClassesInHTMLFilesWidget.cpp b/src/Sigil/Dialogs/ReportsWidgets/ClassesInHTMLFilesWidget.cpp index cba2817f1e..773bb31149 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/ClassesInHTMLFilesWidget.cpp +++ b/src/Sigil/Dialogs/ReportsWidgets/ClassesInHTMLFilesWidget.cpp @@ -51,7 +51,7 @@ ClassesInHTMLFilesWidget::ClassesInHTMLFilesWidget() connectSignalsSlots(); } -void ClassesInHTMLFilesWidget::CreateReport(QSharedPointer< Book > book) +void ClassesInHTMLFilesWidget::CreateReport(QSharedPointer book) { m_Book = book; SetupTable(); @@ -183,12 +183,12 @@ void ClassesInHTMLFilesWidget::Save() QString text = ""; if (item) { text = item->text(); - } + } if (col == 0) { row_text.append(text); } else { row_text.append("," % text); - } + } } report_info.append(row_text % "\n"); diff --git a/src/Sigil/Dialogs/ReportsWidgets/ClassesInHTMLFilesWidget.h b/src/Sigil/Dialogs/ReportsWidgets/ClassesInHTMLFilesWidget.h index 93a4e7c0fb..5452026dba 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/ClassesInHTMLFilesWidget.h +++ b/src/Sigil/Dialogs/ReportsWidgets/ClassesInHTMLFilesWidget.h @@ -45,7 +45,7 @@ class ClassesInHTMLFilesWidget : public ReportsWidget public: ClassesInHTMLFilesWidget(); - void CreateReport(QSharedPointer< Book > book); + void CreateReport(QSharedPointer book); signals: void CloseDialog(); @@ -66,7 +66,7 @@ private slots: void SetupTable(); void AddTableData(QList html_classes_usage); - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; QStandardItemModel *m_ItemModel; diff --git a/src/Sigil/Dialogs/ReportsWidgets/HTMLFilesWidget.cpp b/src/Sigil/Dialogs/ReportsWidgets/HTMLFilesWidget.cpp index d52b3ff6bd..a9df613506 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/HTMLFilesWidget.cpp +++ b/src/Sigil/Dialogs/ReportsWidgets/HTMLFilesWidget.cpp @@ -53,10 +53,10 @@ HTMLFilesWidget::HTMLFilesWidget() connectSignalsSlots(); } -void HTMLFilesWidget::CreateReport(QSharedPointer< Book > book) +void HTMLFilesWidget::CreateReport(QSharedPointer book) { m_Book = book; - m_HTMLResources = m_Book->GetFolderKeeper().GetResourceTypeList< HTMLResource >(false); + m_HTMLResources = m_Book->GetFolderKeeper().GetResourceTypeList(false); SetupTable(); } @@ -285,12 +285,12 @@ void HTMLFilesWidget::Save() QString text = ""; if (item) { text = item->text(); - } + } if (col == 0) { row_text.append(text); } else { row_text.append("," % text); - } + } } report_info.append(row_text % "\n"); diff --git a/src/Sigil/Dialogs/ReportsWidgets/HTMLFilesWidget.h b/src/Sigil/Dialogs/ReportsWidgets/HTMLFilesWidget.h index 7f54bc851b..70c27da674 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/HTMLFilesWidget.h +++ b/src/Sigil/Dialogs/ReportsWidgets/HTMLFilesWidget.h @@ -48,7 +48,7 @@ class HTMLFilesWidget : public ReportsWidget public: HTMLFilesWidget(); - void CreateReport(QSharedPointer< Book > book); + void CreateReport(QSharedPointer book); void SetupTable(int sort_column = 1, Qt::SortOrder sort_order = Qt::AscendingOrder); @@ -79,7 +79,7 @@ private slots: QList m_HTMLResources; - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; QStandardItemModel *m_ItemModel; diff --git a/src/Sigil/Dialogs/ReportsWidgets/ImageFilesWidget.cpp b/src/Sigil/Dialogs/ReportsWidgets/ImageFilesWidget.cpp index 3f9a8d7bbe..ee80dc7597 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/ImageFilesWidget.cpp +++ b/src/Sigil/Dialogs/ReportsWidgets/ImageFilesWidget.cpp @@ -56,12 +56,12 @@ ImageFilesWidget::ImageFilesWidget() ReadSettings(); } -void ImageFilesWidget::CreateReport(QSharedPointer< Book > book) +void ImageFilesWidget::CreateReport(QSharedPointer book) { m_Book = book; m_AllImageResources.clear(); - QList image_resources = m_Book->GetFolderKeeper().GetResourceTypeList< ImageResource >(false); - QList svg_resources = m_Book->GetFolderKeeper().GetResourceTypeList< SVGResource >(false); + QList image_resources = m_Book->GetFolderKeeper().GetResourceTypeList(false); + QList svg_resources = m_Book->GetFolderKeeper().GetResourceTypeList(false); // Images actually consist of 2 resource types ImageResource and SVGResource foreach(ImageResource * image_resource, image_resources) { m_AllImageResources.append(image_resource); @@ -283,12 +283,12 @@ void ImageFilesWidget::Save() QString text = ""; if (item) { text = item->text(); - } + } if (col == 0) { row_text.append(text); } else { row_text.append("," % text); - } + } } report_info.append(row_text % "\n"); diff --git a/src/Sigil/Dialogs/ReportsWidgets/ImageFilesWidget.h b/src/Sigil/Dialogs/ReportsWidgets/ImageFilesWidget.h index d510e08818..44fc037f89 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/ImageFilesWidget.h +++ b/src/Sigil/Dialogs/ReportsWidgets/ImageFilesWidget.h @@ -47,7 +47,7 @@ class ImageFilesWidget : public ReportsWidget public: ImageFilesWidget(); - void CreateReport(QSharedPointer< Book > book); + void CreateReport(QSharedPointer book); void SetupTable(int sort_column = 1, Qt::SortOrder sort_order = Qt::AscendingOrder); diff --git a/src/Sigil/Dialogs/ReportsWidgets/LinksWidget.cpp b/src/Sigil/Dialogs/ReportsWidgets/LinksWidget.cpp index 6ec9985982..e5bda281f4 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/LinksWidget.cpp +++ b/src/Sigil/Dialogs/ReportsWidgets/LinksWidget.cpp @@ -50,10 +50,10 @@ LinksWidget::LinksWidget() connectSignalsSlots(); } -void LinksWidget::CreateReport(QSharedPointer< Book > book) +void LinksWidget::CreateReport(QSharedPointer book) { m_Book = book; - m_HTMLResources = m_Book->GetFolderKeeper().GetResourceTypeList< HTMLResource >(false); + m_HTMLResources = m_Book->GetFolderKeeper().GetResourceTypeList(false); SetupTable(); } @@ -78,9 +78,9 @@ void LinksWidget::SetupTable(int sort_column, Qt::SortOrder sort_order) ui.fileTree->header()->setSortIndicatorShown(true); ui.fileTree->header()->setToolTip( tr("Report shows all source and target links using the anchor tag \"a\".") - ); + ); - QHash< QString, QList< XhtmlDoc::XMLElement > > links = m_Book->GetLinkElements(); + QHash> links = m_Book->GetLinkElements(); QHash all_ids = m_Book->GetIdsInHTMLFiles(); QStringList html_filenames; foreach(Resource *resource, m_HTMLResources) { @@ -108,7 +108,7 @@ void LinksWidget::SetupTable(int sort_column, Qt::SortOrder sort_order) item->setText(source_id); rowItems << item; - // Source text + // Source text item = new QStandardItem(); item->setText(element.text); rowItems << item; @@ -126,8 +126,7 @@ void LinksWidget::SetupTable(int sort_column, Qt::SortOrder sort_order) } href_id = url.fragment(); is_target_file = true; - } - else { + } else { // Just show url href_file = href; } @@ -164,7 +163,7 @@ void LinksWidget::SetupTable(int sort_column, Qt::SortOrder sort_order) // As long as an anchor tag was used! XhtmlDoc::XMLElement target; bool found = false; - + QString target_file = href_file; if (target_file.isEmpty()) { target_file = filename; @@ -177,12 +176,12 @@ void LinksWidget::SetupTable(int sort_column, Qt::SortOrder sort_order) } } if (found) { - + // Target Text item = new QStandardItem(); item->setText(target.text); rowItems << item; - + // Target's Target file and id QString target_href = target.attributes["href"]; QUrl target_url(target_href); @@ -194,20 +193,19 @@ void LinksWidget::SetupTable(int sort_column, Qt::SortOrder sort_order) target_href_file.replace("../Text/", ""); } target_href_id = target_url.fragment(); - } - else { + } else { // Just show url target_href_file = target_href; } - + item = new QStandardItem(); item->setText(target_href_file); rowItems << item; - + item = new QStandardItem(); item->setText(target_href_id); rowItems << item; - + // Match - destination link points to source if (target_href_file.isEmpty()) { target_href_file = target_file; @@ -245,11 +243,11 @@ void LinksWidget::FilterEditTextChangedSlot(const QString &text) for (int row = 0; row < root_item->rowCount(); row++) { if (text.isEmpty() || root_item->child(row, 0)->text().toLower().contains(lowercaseText) || - root_item->child(row, 1)->text().toLower().contains(lowercaseText) || - root_item->child(row, 2)->text().toLower().contains(lowercaseText) || - root_item->child(row, 3)->text().toLower().contains(lowercaseText) || - root_item->child(row, 4)->text().toLower().contains(lowercaseText) || - root_item->child(row, 5)->text().toLower().contains(lowercaseText)) { + root_item->child(row, 1)->text().toLower().contains(lowercaseText) || + root_item->child(row, 2)->text().toLower().contains(lowercaseText) || + root_item->child(row, 3)->text().toLower().contains(lowercaseText) || + root_item->child(row, 4)->text().toLower().contains(lowercaseText) || + root_item->child(row, 5)->text().toLower().contains(lowercaseText)) { ui.fileTree->setRowHidden(row, parent_index, false); if (first_visible_row == -1) { @@ -290,12 +288,12 @@ void LinksWidget::Save() QString text = ""; if (item) { text = item->text(); - } + } if (col == 0) { row_text.append(text); } else { row_text.append("," % text); - } + } } report_info.append(row_text % "\n"); diff --git a/src/Sigil/Dialogs/ReportsWidgets/LinksWidget.h b/src/Sigil/Dialogs/ReportsWidgets/LinksWidget.h index 81be9bd028..242d963585 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/LinksWidget.h +++ b/src/Sigil/Dialogs/ReportsWidgets/LinksWidget.h @@ -48,7 +48,7 @@ class LinksWidget : public ReportsWidget public: LinksWidget(); - void CreateReport(QSharedPointer< Book > book); + void CreateReport(QSharedPointer book); void SetupTable(int sort_column = 1, Qt::SortOrder sort_order = Qt::AscendingOrder); @@ -73,7 +73,7 @@ private slots: QList m_HTMLResources; - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; QStandardItemModel *m_ItemModel; diff --git a/src/Sigil/Dialogs/ReportsWidgets/ReportsWidget.h b/src/Sigil/Dialogs/ReportsWidgets/ReportsWidget.h index 6857b8c40c..b2c78b29a6 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/ReportsWidget.h +++ b/src/Sigil/Dialogs/ReportsWidgets/ReportsWidget.h @@ -36,7 +36,7 @@ class ReportsWidget : public QWidget Q_OBJECT public: - virtual void CreateReport(QSharedPointer< Book > book) = 0; + virtual void CreateReport(QSharedPointer book) = 0; }; #endif // REPORTSWIDGET_H diff --git a/src/Sigil/Dialogs/ReportsWidgets/StylesInCSSFilesWidget.cpp b/src/Sigil/Dialogs/ReportsWidgets/StylesInCSSFilesWidget.cpp index b8caaba00f..36e209edc1 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/StylesInCSSFilesWidget.cpp +++ b/src/Sigil/Dialogs/ReportsWidgets/StylesInCSSFilesWidget.cpp @@ -52,7 +52,7 @@ StylesInCSSFilesWidget::StylesInCSSFilesWidget() connectSignalsSlots(); } -void StylesInCSSFilesWidget::CreateReport(QSharedPointer< Book > book) +void StylesInCSSFilesWidget::CreateReport(QSharedPointer book) { m_Book = book; SetupTable(); @@ -164,14 +164,14 @@ void StylesInCSSFilesWidget::DoubleClick() void StylesInCSSFilesWidget::Delete() { QString style_names; - QHash< QString, QStringList> stylesheet_styles; + QHash stylesheet_styles; foreach(QModelIndex index, ui.fileTree->selectionModel()->selectedRows(0)) { QString filename = m_ItemModel->itemFromIndex(index)->text(); QString name = m_ItemModel->itemFromIndex(index.sibling(index.row(), 1))->text(); stylesheet_styles[filename].append(name); } int count = 0; - QHashIterator< QString, QStringList> it_stylesheet_styles(stylesheet_styles); + QHashIterator it_stylesheet_styles(stylesheet_styles); while (it_stylesheet_styles.hasNext()) { it_stylesheet_styles.next(); diff --git a/src/Sigil/Dialogs/ReportsWidgets/StylesInCSSFilesWidget.h b/src/Sigil/Dialogs/ReportsWidgets/StylesInCSSFilesWidget.h index c691b4b8df..c7bec3918a 100644 --- a/src/Sigil/Dialogs/ReportsWidgets/StylesInCSSFilesWidget.h +++ b/src/Sigil/Dialogs/ReportsWidgets/StylesInCSSFilesWidget.h @@ -48,7 +48,7 @@ class StylesInCSSFilesWidget : public ReportsWidget public: StylesInCSSFilesWidget(); - void CreateReport(QSharedPointer< Book > book); + void CreateReport(QSharedPointer book); signals: void CloseDialog(); @@ -77,7 +77,7 @@ private slots: void AddTableData(QList css_selectors_usage); - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; QStandardItemModel *m_ItemModel; diff --git a/src/Sigil/Dialogs/SelectHyperlink.cpp b/src/Sigil/Dialogs/SelectHyperlink.cpp index afea1d8dde..396e57c105 100644 --- a/src/Sigil/Dialogs/SelectHyperlink.cpp +++ b/src/Sigil/Dialogs/SelectHyperlink.cpp @@ -27,7 +27,7 @@ static QString SETTINGS_GROUP = "select_hyperlink"; -SelectHyperlink::SelectHyperlink(QString default_href, HTMLResource *html_resource, QList resources, QSharedPointer< Book > book, QWidget *parent) +SelectHyperlink::SelectHyperlink(QString default_href, HTMLResource *html_resource, QList resources, QSharedPointer book, QWidget *parent) : QDialog(parent), m_CurrentHTMLResource(html_resource), diff --git a/src/Sigil/Dialogs/SelectHyperlink.h b/src/Sigil/Dialogs/SelectHyperlink.h index 44d26a9949..a3e4df2882 100644 --- a/src/Sigil/Dialogs/SelectHyperlink.h +++ b/src/Sigil/Dialogs/SelectHyperlink.h @@ -73,7 +73,7 @@ private slots: QList m_Resources; - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; QStandardItemModel *m_SelectHyperlinkModel; diff --git a/src/Sigil/Dialogs/SelectId.cpp b/src/Sigil/Dialogs/SelectId.cpp index fa901d51a6..42dd9ced87 100644 --- a/src/Sigil/Dialogs/SelectId.cpp +++ b/src/Sigil/Dialogs/SelectId.cpp @@ -29,7 +29,7 @@ static QString SETTINGS_GROUP = "select_id"; -SelectId::SelectId(QString id, HTMLResource *html_resource, QSharedPointer< Book > book, QWidget *parent) +SelectId::SelectId(QString id, HTMLResource *html_resource, QSharedPointer book, QWidget *parent) : QDialog(parent), m_SelectedText(id), diff --git a/src/Sigil/Dialogs/SelectId.h b/src/Sigil/Dialogs/SelectId.h index e9f766616f..757d3dbd04 100644 --- a/src/Sigil/Dialogs/SelectId.h +++ b/src/Sigil/Dialogs/SelectId.h @@ -55,7 +55,7 @@ private slots: HTMLResource *m_HTMLResource; - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; Ui::SelectId ui; }; diff --git a/src/Sigil/Dialogs/SpellcheckEditor.cpp b/src/Sigil/Dialogs/SpellcheckEditor.cpp index 7135f52e60..eec877434a 100644 --- a/src/Sigil/Dialogs/SpellcheckEditor.cpp +++ b/src/Sigil/Dialogs/SpellcheckEditor.cpp @@ -187,8 +187,7 @@ void SpellcheckEditor::Add() } if (enabled) { emit ShowStatusMessageRequest(tr("Added word(s) to dictionary.")); - } - else { + } else { emit ShowStatusMessageRequest(tr("Added word(s) to dictionary. The dictionary is not enabled in Preferences.")); } emit SpellingHighlightRefreshRequest(); @@ -252,7 +251,7 @@ void SpellcheckEditor::CreateModel(int sort_column, Qt::SortOrder sort_order) i.next(); QString word = i.key(); int count = unique_words.value(word); - + bool misspelled = !sc->spell(word); if (misspelled) { total_misspelled_words++; @@ -268,8 +267,7 @@ void SpellcheckEditor::CreateModel(int sort_column, Qt::SortOrder sort_order) QStandardItem *word_item = new QStandardItem(word); word_item->setEditable(false); row_items << word_item; - } - else { + } else { CaseInsensitiveItem *word_item = new CaseInsensitiveItem(); word_item->setText(word); word_item->setEditable(false); @@ -283,8 +281,7 @@ void SpellcheckEditor::CreateModel(int sort_column, Qt::SortOrder sort_order) misspelled_item->setEditable(false); if (misspelled) { misspelled_item->setText(tr("Yes")); - } - else { + } else { misspelled_item->setText(tr("No")); } row_items << misspelled_item ; @@ -463,7 +460,7 @@ void SpellcheckEditor::ReadSettings() if (settings.contains(SHOW_ALL_WORDS)) { if (settings.value(SHOW_ALL_WORDS).toBool()) { disconnect(ui.ShowAllWords, SIGNAL(stateChanged(int)), - this, SLOT(ChangeState(int))); + this, SLOT(ChangeState(int))); ui.ShowAllWords->setCheckState(Qt::Checked); connect(ui.ShowAllWords, SIGNAL(stateChanged(int)), this, SLOT(ChangeState(int))); @@ -472,7 +469,7 @@ void SpellcheckEditor::ReadSettings() if (settings.contains(CASE_INSENSITIVE_SORT)) { if (settings.value(CASE_INSENSITIVE_SORT).toBool()) { disconnect(ui.CaseInsensitiveSort, SIGNAL(stateChanged(int)), - this, SLOT(ChangeState(int))); + this, SLOT(ChangeState(int))); ui.CaseInsensitiveSort->setCheckState(Qt::Checked); connect(ui.CaseInsensitiveSort, SIGNAL(stateChanged(int)), this, SLOT(ChangeState(int))); @@ -572,7 +569,7 @@ void SpellcheckEditor::ConnectSignalsSlots() connect(ui.ChangeAll, SIGNAL(clicked()), this, SLOT(ChangeAll())); connect(ui.SpellcheckEditorTree, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(OpenContextMenu(const QPoint &))); - connect(ui.SpellcheckEditorTree->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), + connect(ui.SpellcheckEditorTree->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(Sort(int, Qt::SortOrder))); connect(m_Ignore, SIGNAL(triggered()), this, SLOT(Ignore())); connect(m_Add, SIGNAL(triggered()), this, SLOT(Add())); diff --git a/src/Sigil/Dialogs/SpellcheckEditor.h b/src/Sigil/Dialogs/SpellcheckEditor.h index 92bae10387..bed8c9ab74 100644 --- a/src/Sigil/Dialogs/SpellcheckEditor.h +++ b/src/Sigil/Dialogs/SpellcheckEditor.h @@ -112,7 +112,7 @@ private slots: QAction *m_Find; QAction *m_SelectAll; - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; QStandardItemModel *m_SpellcheckEditorModel; diff --git a/src/Sigil/Exporters/EncryptionXmlWriter.cpp b/src/Sigil/Exporters/EncryptionXmlWriter.cpp index ced81481cf..d8e69903eb 100644 --- a/src/Sigil/Exporters/EncryptionXmlWriter.cpp +++ b/src/Sigil/Exporters/EncryptionXmlWriter.cpp @@ -36,7 +36,7 @@ void EncryptionXmlWriter::WriteXML() m_Writer->writeStartElement("encryption"); m_Writer->writeAttribute("xmlns", "urn:oasis:names:tc:opendocument:xmlns:container"); m_Writer->writeAttribute("xmlns:enc", "http://www.w3.org/2001/04/xmlenc#"); - QList< FontResource * > font_resources = m_Book.GetFolderKeeper().GetResourceTypeList< FontResource >(); + QList font_resources = m_Book.GetFolderKeeper().GetResourceTypeList(); foreach(FontResource * font_resource, font_resources) { WriteEncryptedData(*font_resource); } diff --git a/src/Sigil/Exporters/ExportEPUB.cpp b/src/Sigil/Exporters/ExportEPUB.cpp index 72d5f8085f..02bf4fd65c 100644 --- a/src/Sigil/Exporters/ExportEPUB.cpp +++ b/src/Sigil/Exporters/ExportEPUB.cpp @@ -68,7 +68,7 @@ static const QString EPUB_MIME_TYPE = "application/epub+zip"; // Constructor; // the first parameter is the location where the book // should be save to, and the second is the book to be saved -ExportEPUB::ExportEPUB(const QString &fullfilepath, QSharedPointer< Book > book) +ExportEPUB::ExportEPUB(const QString &fullfilepath, QSharedPointer book) : m_FullFilePath(fullfilepath), m_Book(book) @@ -288,7 +288,7 @@ void ExportEPUB::ObfuscateFonts(const QString &fullfolderpath) { QString uuid_id = m_Book->GetOPF().GetUUIDIdentifierValue(); QString main_id = m_Book->GetPublicationIdentifier(); - QList< FontResource * > font_resources = m_Book->GetFolderKeeper().GetResourceTypeList< FontResource >(); + QList font_resources = m_Book->GetFolderKeeper().GetResourceTypeList(); foreach(FontResource * font_resource, font_resources) { QString algorithm = font_resource->GetObfuscationAlgorithm(); diff --git a/src/Sigil/Exporters/ExportEPUB.h b/src/Sigil/Exporters/ExportEPUB.h index 94a03169f3..f5527a7888 100644 --- a/src/Sigil/Exporters/ExportEPUB.h +++ b/src/Sigil/Exporters/ExportEPUB.h @@ -35,7 +35,7 @@ class ExportEPUB : public Exporter // Constructor; // the first parameter is the location where the book // should be save to, and the second is the book to be saved - ExportEPUB(const QString &fullfilepath, QSharedPointer< Book > book); + ExportEPUB(const QString &fullfilepath, QSharedPointer book); // Destructor virtual ~ExportEPUB(); @@ -73,7 +73,7 @@ class ExportEPUB : public Exporter QString m_FullFilePath; // The book being exported - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; }; diff --git a/src/Sigil/Exporters/ExporterFactory.cpp b/src/Sigil/Exporters/ExporterFactory.cpp index c62e449c4d..0e64f32d95 100644 --- a/src/Sigil/Exporters/ExporterFactory.cpp +++ b/src/Sigil/Exporters/ExporterFactory.cpp @@ -39,7 +39,7 @@ ExporterFactory::~ExporterFactory() // Returns a reference to the exporter // appropriate for the given filename -Exporter &ExporterFactory::GetExporter(const QString &filename, QSharedPointer< Book > book) +Exporter &ExporterFactory::GetExporter(const QString &filename, QSharedPointer book) { QString extension = QFileInfo(filename).suffix().toLower(); diff --git a/src/Sigil/Exporters/ExporterFactory.h b/src/Sigil/Exporters/ExporterFactory.h index cb15b42732..0156208625 100644 --- a/src/Sigil/Exporters/ExporterFactory.h +++ b/src/Sigil/Exporters/ExporterFactory.h @@ -39,7 +39,7 @@ class ExporterFactory // Returns a reference to the exporter // appropriate for the given filename - Exporter &GetExporter(const QString &filename, QSharedPointer< Book > book); + Exporter &GetExporter(const QString &filename, QSharedPointer book); private: diff --git a/src/Sigil/Exporters/NCXWriter.cpp b/src/Sigil/Exporters/NCXWriter.cpp index 624343f264..bc1c0f3b4c 100644 --- a/src/Sigil/Exporters/NCXWriter.cpp +++ b/src/Sigil/Exporters/NCXWriter.cpp @@ -32,7 +32,7 @@ NCXWriter::NCXWriter(const Book &book, QIODevice &device) : XMLWriter(book, device), m_Headings(Headings::MakeHeadingHeirarchy( - Headings::GetHeadingList(book.GetFolderKeeper().GetResourceTypeList< HTMLResource >(true)))), + Headings::GetHeadingList(book.GetFolderKeeper().GetResourceTypeList(true)))), m_NCXRootEntry(NCXModel::NCXEntry()) { } @@ -91,7 +91,7 @@ void NCXWriter::WriteHead() void NCXWriter::WriteDocTitle() { QString document_title; - QList< QVariant > titles = m_Book.GetMetadataValues("title"); + QList titles = m_Book.GetMetadataValues("title"); if (titles.isEmpty()) { document_title = "Unknown"; @@ -135,7 +135,7 @@ void NCXWriter::WriteFallbackNavPoint() m_Writer->writeStartElement("navLabel"); m_Writer->writeTextElement("text", "Start"); m_Writer->writeEndElement(); - QList< HTMLResource * > html_resources = m_Book.GetFolderKeeper().GetResourceTypeList< HTMLResource >(true); + QList html_resources = m_Book.GetFolderKeeper().GetResourceTypeList(true); Q_ASSERT(!html_resources.isEmpty()); m_Writer->writeEmptyElement("content"); m_Writer->writeAttribute("src", Utility::URLEncodePath(html_resources.at(0)->GetRelativePathToOEBPS())); diff --git a/src/Sigil/Exporters/NCXWriter.h b/src/Sigil/Exporters/NCXWriter.h index fcae93bfc8..21de3a120f 100644 --- a/src/Sigil/Exporters/NCXWriter.h +++ b/src/Sigil/Exporters/NCXWriter.h @@ -109,7 +109,7 @@ class NCXWriter : private XMLWriter /** * A hierarchical tree of all the headings in the book. */ - const QList< Headings::Heading > m_Headings; + const QList m_Headings; NCXModel::NCXEntry m_NCXRootEntry; }; diff --git a/src/Sigil/Importers/ImportEPUB.cpp b/src/Sigil/Importers/ImportEPUB.cpp index 003f7b2b69..5611705c54 100644 --- a/src/Sigil/Importers/ImportEPUB.cpp +++ b/src/Sigil/Importers/ImportEPUB.cpp @@ -79,13 +79,13 @@ static const QString NCX_EXTENSION = "ncx"; const QString ADOBE_FONT_ALGO_ID = "http://ns.adobe.com/pdf/enc#RC"; const QString IDPF_FONT_ALGO_ID = "http://www.idpf.org/2008/embedding"; static const QString CONTAINER_XML = "\n" - "\n" - " \n" - " \n" - " \n" - "\n"; + "\n" + " \n" + " \n" + " \n" + "\n"; -static QCodePage437Codec *cp437 = 0; +static QCodePage437Codec *cp437 = 0; // Constructor; // The parameter is the file to be imported @@ -143,7 +143,7 @@ QSharedPointer ImportEPUB::GetBook() // Load the content into the HTMLResource so we can perform a well formed check. try { hresource->SetText(HTMLEncodingResolver::ReadHTMLFile(hresource->GetFullPath())); - } catch(...) { + } catch (...) { if (ss.cleanOn() & CLEANON_OPEN) { non_well_formed << hresource; continue; @@ -161,11 +161,11 @@ QSharedPointer ImportEPUB::GetBook() if (QMessageBox::Yes == QMessageBox::warning(QApplication::activeWindow(), tr("Sigil"), tr("This EPUB has HTML files that are not well formed. " - "Sigil can attempt to automatically fix these files, although this " - "can result in data loss.\n\n" - "Do you want to automatically fix the files?"), + "Sigil can attempt to automatically fix these files, although this " + "can result in data loss.\n\n" + "Do you want to automatically fix the files?"), QMessageBox::Yes|QMessageBox::No) - ) { + ) { non_well_formed.clear(); } QApplication::setOverrideCursor(Qt::WaitCursor); @@ -466,8 +466,7 @@ void ImportEPUB::LocateOPF() QXmlStreamReader container; try { container.addData(Utility::ReadUnicodeTextFile(fullpath)); - } - catch (CannotOpenFile) { + } catch (CannotOpenFile) { // Find the first OPF file. QString OPFfile; QDirIterator files(m_ExtractedFolderPath, QStringList() << "*.opf", QDir::NoFilter, QDirIterator::Subdirectories); @@ -478,8 +477,8 @@ void ImportEPUB::LocateOPF() if (OPFfile.isEmpty()) { boost_throw(CannotOpenFile() - << errinfo_file_fullpath(fullpath.toStdString()) - << errinfo_file_errorstring("Missing and no OPF in archive.")); + << errinfo_file_fullpath(fullpath.toStdString()) + << errinfo_file_errorstring("Missing and no OPF in archive.")); } // Create a default container.xml. @@ -699,7 +698,7 @@ QHash ImportEPUB::LoadFolderStructure() { QList keys = m_Files.keys(); int num_files = keys.count(); - QFutureSynchronizer > sync; + QFutureSynchronizer> sync; for (int i = 0; i < num_files; ++i) { QString id = keys.at(i); @@ -711,13 +710,13 @@ QHash ImportEPUB::LoadFolderStructure() } sync.waitForFinished(); - QList > > futures = sync.futures(); + QList>> futures = sync.futures(); int num_futures = futures.count(); QHash updates; for (int i = 0; i < num_futures; ++i) { - tuple< QString, QString > result = futures.at(i).result(); - updates[result.get<0>()] = result.get< 1 >(); + tuple result = futures.at(i).result(); + updates[result.get<0>()] = result.get<1>(); } updates.remove(UPDATE_ERROR_STRING); @@ -728,7 +727,7 @@ QHash ImportEPUB::LoadFolderStructure() tuple ImportEPUB::LoadOneFile(const QString &path, const QString &mimetype) { QString fullfilepath = QFileInfo(m_OPFFilePath).absolutePath() + "/" + path; - + try { Resource &resource = m_Book->GetFolderKeeper().AddContentFileToFolder(fullfilepath, false, mimetype); QString newpath = "../" + resource.GetRelativePathToOEBPS(); diff --git a/src/Sigil/Importers/ImportEPUB.h b/src/Sigil/Importers/ImportEPUB.h index 2fbc0d0395..9ee154bdc0 100644 --- a/src/Sigil/Importers/ImportEPUB.h +++ b/src/Sigil/Importers/ImportEPUB.h @@ -50,7 +50,7 @@ class ImportEPUB : public Importer // Reads and parses the file // and returns the created Book - virtual QSharedPointer< Book > GetBook(); + virtual QSharedPointer GetBook(); private: /** @@ -107,7 +107,7 @@ class ImportEPUB : public Importer * @return A hash with keys being old references (URLs) to resources, * and values being the new references to those resources. */ - QHash< QString, QString > LoadFolderStructure(); + QHash LoadFolderStructure(); /** * Loads a single file. @@ -117,8 +117,8 @@ class ImportEPUB : public Importer * @return A tuple where the first member is the old path to the file, * and the new member is the new, OEBPS-relative path to it. */ - tuple< QString, QString > LoadOneFile(const QString &path, - const QString &mimetype = QString()); + tuple LoadOneFile(const QString &path, + const QString &mimetype = QString()); /** * Performs the necessary modifications to the OPF @@ -138,11 +138,11 @@ class ImportEPUB : public Importer * absolute paths to the files and the values are the * encryption algorithm IDs. */ - QHash< QString, QString > ParseEncryptionXml(); + QHash ParseEncryptionXml(); - bool BookContentEncrypted(const QHash< QString, QString > &encrypted_files); + bool BookContentEncrypted(const QHash &encrypted_files); - void AddObfuscatedButUndeclaredFonts(const QHash< QString, QString > &encrypted_files); + void AddObfuscatedButUndeclaredFonts(const QHash &encrypted_files); /** * Another workaround function to handle com.apple.ibooks.display-options.xml @@ -155,9 +155,9 @@ class ImportEPUB : public Importer */ void AddNonStandardAppleXML(); - void ProcessFontFiles(const QList< Resource * > &resources, - const QHash< QString, QString > &updates, - const QHash< QString, QString > &encrypted_files); + void ProcessFontFiles(const QList &resources, + const QHash &updates, + const QHash &encrypted_files); /** * The main temp folder where files are stored. @@ -187,21 +187,21 @@ class ImportEPUB : public Importer * manifest; The keys are the element ID's, * the values are stored paths to the files. */ - QMap< QString, QString > m_Files; + QMap m_Files; /** * The map of all files in the publication's manifest; * The keys are the element ID's, the vaules are the * mimetype of the file. */ - QMap< QString, QString > m_FileMimetypes; + QMap m_FileMimetypes; /** * InDesign likes listing several files multiple times in the manifest, * even though that's explicitly forbidden by the spec. So we use this * to make sure we don't load such files multiple times. */ - QSet< QString > m_MainfestFilePaths; + QSet m_MainfestFilePaths; /** * The identifier of the book's unique identifier. @@ -224,7 +224,7 @@ class ImportEPUB : public Importer * an NCX mimetype. Only one of them will be the actual NCX though. * This hash stores all the candidates, as an ID-to-href mapping. */ - QHash< QString, QString > m_NcxCandidates; + QHash m_NcxCandidates; bool m_HasSpineItems; bool m_NCXNotInManifest; diff --git a/src/Sigil/Importers/ImportHTML.cpp b/src/Sigil/Importers/ImportHTML.cpp index 40bdcb01dc..30d3cc3bef 100644 --- a/src/Sigil/Importers/ImportHTML.cpp +++ b/src/Sigil/Importers/ImportHTML.cpp @@ -59,7 +59,7 @@ ImportHTML::ImportHTML(const QString &fullfilepath) } -void ImportHTML::SetBook(QSharedPointer< Book > book, bool ignore_duplicates) +void ImportHTML::SetBook(QSharedPointer book, bool ignore_duplicates) { m_Book = book; m_IgnoreDuplicates = ignore_duplicates; @@ -75,9 +75,9 @@ XhtmlDoc::WellFormedError ImportHTML::CheckValidToLoad() // Reads and parses the file // and returns the created Book -QSharedPointer< Book > ImportHTML::GetBook() +QSharedPointer ImportHTML::GetBook() { - shared_ptr< xc::DOMDocument > document = XhtmlDoc::LoadTextIntoDocument(LoadSource()); + shared_ptr document = XhtmlDoc::LoadTextIntoDocument(LoadSource()); LoadMetadata(*document); UpdateFiles(CreateHTMLResource(), *document, LoadFolderStructure(*document)); return m_Book; @@ -110,8 +110,8 @@ QString ImportHTML::LoadSource() // and tries to convert it to Dublin Core void ImportHTML::LoadMetadata(const xc::DOMDocument &document) { - QList< xc::DOMElement * > metatags = XhtmlDoc::GetTagMatchingDescendants(document, "meta"); - QList< Metadata::MetaElement > metadata; + QList metatags = XhtmlDoc::GetTagMatchingDescendants(document, "meta"); + QList metadata; for (int i = 0; i < metatags.count(); ++i) { xc::DOMElement &element = *metatags.at(i); @@ -131,7 +131,7 @@ HTMLResource &ImportHTML::CreateHTMLResource() TempFolder tempfolder; QString fullfilepath = tempfolder.GetPath() + "/" + QFileInfo(m_FullFilePath).fileName(); Utility::WriteUnicodeTextFile("TEMP_SOURCE", fullfilepath); - HTMLResource &resource = *qobject_cast< HTMLResource * >( + HTMLResource &resource = *qobject_cast( &m_Book->GetFolderKeeper().AddContentFileToFolder(fullfilepath)); return resource; } @@ -139,22 +139,22 @@ HTMLResource &ImportHTML::CreateHTMLResource() void ImportHTML::UpdateFiles(HTMLResource &html_resource, xc::DOMDocument &document, - const QHash< QString, QString > &updates) + const QHash &updates) { Q_ASSERT(&html_resource != NULL); - QHash< QString, QString > html_updates; - QHash< QString, QString > css_updates; + QHash html_updates; + QHash css_updates; tie(html_updates, css_updates, boost::tuples::ignore) = UniversalUpdates::SeparateHtmlCssXmlUpdates(updates); - QList< Resource * > all_files = m_Book->GetFolderKeeper().GetResourceList(); + QList all_files = m_Book->GetFolderKeeper().GetResourceList(); int num_files = all_files.count(); - QList< CSSResource * > css_resources; + QList css_resources; for (int i = 0; i < num_files; ++i) { Resource *resource = all_files.at(i); if (resource->Type() == Resource::CSSResourceType) { - css_resources.append(qobject_cast< CSSResource * >(resource)); + css_resources.append(qobject_cast(resource)); } } @@ -168,15 +168,15 @@ void ImportHTML::UpdateFiles(HTMLResource &html_resource, // Loads the referenced files into the main folder of the book; // as the files get a new name, the references are updated -QHash< QString, QString > ImportHTML::LoadFolderStructure(const xc::DOMDocument &document) +QHash ImportHTML::LoadFolderStructure(const xc::DOMDocument &document) { - QFutureSynchronizer< QHash< QString, QString > > sync; + QFutureSynchronizer> sync; sync.addFuture(QtConcurrent::run(this, &ImportHTML::LoadMediaFiles, &document)); sync.addFuture(QtConcurrent::run(this, &ImportHTML::LoadStyleFiles, &document)); sync.waitForFinished(); - QList< QFuture< QHash< QString, QString > > > futures = sync.futures(); + QList>> futures = sync.futures(); int num_futures = futures.count(); - QHash< QString, QString > updates; + QHash updates; for (int i = 0; i < num_futures; ++i) { updates.unite(futures.at(i).result()); @@ -186,10 +186,10 @@ QHash< QString, QString > ImportHTML::LoadFolderStructure(const xc::DOMDocument } -QHash< QString, QString > ImportHTML::LoadMediaFiles(const xc::DOMDocument *document) +QHash ImportHTML::LoadMediaFiles(const xc::DOMDocument *document) { QStringList file_paths = XhtmlDoc::GetMediaPathsFromMediaChildren(*document, IMAGE_TAGS + VIDEO_TAGS + AUDIO_TAGS); - QHash< QString, QString > updates; + QHash updates; QDir folder(QFileInfo(m_FullFilePath).absoluteDir()); QStringList current_filenames = m_Book->GetFolderKeeper().GetAllFilenames(); // Load the media files (images, video, audio) into the book and @@ -218,10 +218,10 @@ QHash< QString, QString > ImportHTML::LoadMediaFiles(const xc::DOMDocument *docu } -QHash< QString, QString > ImportHTML::LoadStyleFiles(const xc::DOMDocument *document) +QHash ImportHTML::LoadStyleFiles(const xc::DOMDocument *document) { - QList< xc::DOMElement * > link_nodes = XhtmlDoc::GetTagMatchingDescendants(*document, "link"); - QHash< QString, QString > updates; + QList link_nodes = XhtmlDoc::GetTagMatchingDescendants(*document, "link"); + QHash updates; QStringList current_filenames = m_Book->GetFolderKeeper().GetAllFilenames(); for (int i = 0; i < link_nodes.count(); ++i) { diff --git a/src/Sigil/Importers/ImportHTML.h b/src/Sigil/Importers/ImportHTML.h index 553e625ef2..1a86def2e2 100644 --- a/src/Sigil/Importers/ImportHTML.h +++ b/src/Sigil/Importers/ImportHTML.h @@ -42,13 +42,13 @@ class ImportHTML : public Importer // Needed so that we can use an existing Book // in which to load HTML files (and their dependencies). - void SetBook(QSharedPointer< Book > book, bool ignore_duplicates); + void SetBook(QSharedPointer book, bool ignore_duplicates); virtual XhtmlDoc::WellFormedError CheckValidToLoad(); // Reads and parses the file // and returns the created Book. - virtual QSharedPointer< Book > GetBook(); + virtual QSharedPointer GetBook(); private: @@ -63,17 +63,17 @@ class ImportHTML : public Importer void UpdateFiles(HTMLResource &html_resource, xc::DOMDocument &document, - const QHash< QString, QString > &updates); + const QHash &updates); // Loads the referenced files into the main folder of the book; // as the files get a new name, the references are updated - QHash< QString, QString > LoadFolderStructure(const xc::DOMDocument &document); + QHash LoadFolderStructure(const xc::DOMDocument &document); // Returns a hash with keys being old references (URLs) to resources, // and values being the new references to those resources. - QHash< QString, QString > LoadMediaFiles(const xc::DOMDocument *document); + QHash LoadMediaFiles(const xc::DOMDocument *document); - QHash< QString, QString > LoadStyleFiles(const xc::DOMDocument *document); + QHash LoadStyleFiles(const xc::DOMDocument *document); /////////////////////////////// diff --git a/src/Sigil/Importers/ImportTXT.cpp b/src/Sigil/Importers/ImportTXT.cpp index 93b66b21fd..3406ebb2b3 100644 --- a/src/Sigil/Importers/ImportTXT.cpp +++ b/src/Sigil/Importers/ImportTXT.cpp @@ -45,7 +45,7 @@ ImportTXT::ImportTXT(const QString &fullfilepath) // Reads and parses the file // and returns the created Book -QSharedPointer< Book > ImportTXT::GetBook() +QSharedPointer ImportTXT::GetBook() { if (!Utility::IsFileReadable(m_FullFilePath)) { boost_throw(CannotReadFile() << errinfo_file_fullpath(m_FullFilePath.toStdString())); @@ -77,7 +77,7 @@ HTMLResource *ImportTXT::CreateHTMLResource(const QString &source) QString fullfilepath = tempfolder.GetPath() + "/" + FIRST_SECTION_NAME; Utility::WriteUnicodeTextFile(source, fullfilepath); m_Book->GetFolderKeeper().AddContentFileToFolder(fullfilepath); - return m_Book->GetFolderKeeper().GetResourceTypeList< HTMLResource >()[ 0 ]; + return m_Book->GetFolderKeeper().GetResourceTypeList()[ 0 ]; } diff --git a/src/Sigil/Importers/ImportTXT.h b/src/Sigil/Importers/ImportTXT.h index a5eabfc326..7e1ad31e80 100644 --- a/src/Sigil/Importers/ImportTXT.h +++ b/src/Sigil/Importers/ImportTXT.h @@ -39,7 +39,7 @@ class ImportTXT : public Importer // Reads and parses the file // and returns the created Book - virtual QSharedPointer< Book > GetBook(); + virtual QSharedPointer GetBook(); private: diff --git a/src/Sigil/Importers/Importer.h b/src/Sigil/Importers/Importer.h index 600ac2c0ef..05eb008d52 100644 --- a/src/Sigil/Importers/Importer.h +++ b/src/Sigil/Importers/Importer.h @@ -60,7 +60,7 @@ class Importer * * @return The file as a Book object, RAII wrapped. */ - virtual QSharedPointer< Book > GetBook() = 0; + virtual QSharedPointer GetBook() = 0; /** * Call this after calling GetBook() to get any warning messages that @@ -85,7 +85,7 @@ class Importer * The Book that will be created * by the importing process. */ - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; QStringList m_LoadWarnings; }; diff --git a/src/Sigil/Importers/ImporterFactory.cpp b/src/Sigil/Importers/ImporterFactory.cpp index 40d9ea15fd..71421a75bb 100644 --- a/src/Sigil/Importers/ImporterFactory.cpp +++ b/src/Sigil/Importers/ImporterFactory.cpp @@ -77,7 +77,7 @@ Importer *ImporterFactory::GetImporter(const QString &filename) if (!m_importer_epub) { m_importer_epub = new ImportEPUB(filename); } - return m_importer_epub; + return m_importer_epub; } return NULL; diff --git a/src/Sigil/Importers/ImporterFactory.h b/src/Sigil/Importers/ImporterFactory.h index e46b6d9e2c..972df4970b 100644 --- a/src/Sigil/Importers/ImporterFactory.h +++ b/src/Sigil/Importers/ImporterFactory.h @@ -36,7 +36,7 @@ class ImporterFactory // Destructor ~ImporterFactory(); - // Returns the appropriate importer + // Returns the appropriate importer // for the given filename Importer *GetImporter(const QString &filename); diff --git a/src/Sigil/MainUI/BookBrowser.cpp b/src/Sigil/MainUI/BookBrowser.cpp index 0cdf5b0b23..ec26271fa6 100644 --- a/src/Sigil/MainUI/BookBrowser.cpp +++ b/src/Sigil/MainUI/BookBrowser.cpp @@ -91,7 +91,7 @@ void BookBrowser::showEvent(QShowEvent *event) raise(); } -void BookBrowser::SetBook(QSharedPointer< Book > book) +void BookBrowser::SetBook(QSharedPointer book) { m_Book = book; m_OPFModel.SetBook(book); @@ -423,7 +423,7 @@ void BookBrowser::CopyHTML() return; } - HTMLResource ¤t_html_resource = *qobject_cast< HTMLResource * >(current_resource); + HTMLResource ¤t_html_resource = *qobject_cast(current_resource); // Create an empty file HTMLResource &new_html_resource = m_Book->CreateEmptyHTMLFile(current_html_resource); m_Book->MoveResourceAfter(new_html_resource, current_html_resource); @@ -440,7 +440,7 @@ void BookBrowser::CopyHTML() void BookBrowser::AddNewHTML() { Resource *current_resource = GetCurrentResource(); - HTMLResource ¤t_html_resource = *qobject_cast< HTMLResource * >(current_resource); + HTMLResource ¤t_html_resource = *qobject_cast(current_resource); HTMLResource &new_html_resource = m_Book->CreateEmptyHTMLFile(current_html_resource); if (current_resource != NULL) { @@ -461,7 +461,7 @@ void BookBrowser::CopyCSS() return; } - CSSResource ¤t_css_resource = *qobject_cast< CSSResource * >(current_resource); + CSSResource ¤t_css_resource = *qobject_cast(current_resource); // Create an empty file CSSResource &new_resource = m_Book->CreateEmptyCSSFile(); // Copy the text from the current file @@ -516,9 +516,9 @@ QStringList BookBrowser::AddExisting(bool only_multimedia, bool only_images) } QStringList filepaths = QFileDialog::getOpenFileNames(this, - tr("Add Existing Files"), - m_LastFolderOpen, - filter_string); + tr("Add Existing Files"), + m_LastFolderOpen, + filter_string); if (filepaths.isEmpty()) { return added_files; @@ -527,10 +527,10 @@ QStringList BookBrowser::AddExisting(bool only_multimedia, bool only_images) m_LastFolderOpen = QFileInfo(filepaths.first()).absolutePath(); // We need to store the current metadata since the // GetBook call will clear it. - QList< Metadata::MetaElement > old_metadata = m_Book->GetMetadata(); + QList old_metadata = m_Book->GetMetadata(); QStringList current_filenames = m_Book->GetFolderKeeper().GetAllFilenames(); QStringList invalid_filenames; - HTMLResource *current_html_resource = qobject_cast< HTMLResource * >(GetCurrentResource()); + HTMLResource *current_html_resource = qobject_cast(GetCurrentResource()); Resource *open_resource = NULL; // Display progress dialog if adding several items // Avoid dialog popping up over Insert File from disk for duplicate file all the time @@ -557,8 +557,7 @@ QStringList BookBrowser::AddExisting(bool only_multimedia, bool only_images) tr("File is not an image and cannot be used:\n\n\"%1\".").arg(filepath)); continue; } - } - else if (only_multimedia) { + } else if (only_multimedia) { if (!IMAGE_EXTENSIONS.contains(QFileInfo(filepath).suffix().toLower()) && !SVG_EXTENSIONS.contains(QFileInfo(filepath).suffix().toLower()) && !VIDEO_EXTENSIONS.contains(QFileInfo(filepath).suffix().toLower()) && @@ -622,7 +621,7 @@ QStringList BookBrowser::AddExisting(bool only_multimedia, bool only_images) // this call merely mutates our Book. html_import.GetBook(); Resource &added_resource = m_Book->GetFolderKeeper().GetResourceByFilename(filename); - HTMLResource *added_html_resource = qobject_cast< HTMLResource * >(&added_resource); + HTMLResource *added_html_resource = qobject_cast(&added_resource); if (current_html_resource && added_html_resource) { m_Book->MoveResourceAfter(*added_html_resource, *current_html_resource); @@ -934,7 +933,7 @@ void BookBrowser::RenameSelected() file_extension = old_filename.right(old_filename.length() - old_filename.lastIndexOf('.')); } - // Save the name + // Save the name QString name; if (template_number_string.isEmpty()) { // If no name or number given for template, then use old name but with new extension @@ -1014,7 +1013,7 @@ void BookBrowser::RemoveResources(QList tab_resources, QListGetFolderKeeper().GetResourceTypeList< HTMLResource >().count()) { + resources.count() == m_Book->GetFolderKeeper().GetResourceTypeList().count()) { { Utility::DisplayStdErrorDialog( tr("You cannot remove all html files.\n" @@ -1051,7 +1050,7 @@ void BookBrowser::RemoveResources(QList tab_resources, QList selected_resources = ValidSelectedResources(); + QList selected_resources = ValidSelectedResources(); bool keep_selection = true; foreach (Resource *resource, selected_resources) { if (resources.contains(resource)) { @@ -1061,8 +1060,7 @@ void BookBrowser::RemoveResources(QList tab_resources, QList tab_resources, QList resources = ValidSelectedResources(); int scrollY = m_TreeView.verticalScrollBar()->value(); - ImageResource *image_resource = qobject_cast< ImageResource * >(GetCurrentResource()); + ImageResource *image_resource = qobject_cast(GetCurrentResource()); if (image_resource == NULL) { emit ShowStatusMessageRequest(tr("Unable to set file as cover image.")); return; @@ -1181,7 +1178,7 @@ void BookBrowser::AddGuideSemanticType(int type) } foreach(Resource * resource, resources) { - HTMLResource *html_resource = qobject_cast< HTMLResource * >(resource); + HTMLResource *html_resource = qobject_cast(resource); m_Book->GetOPF().AddGuideSemanticType(*html_resource, (GuideSemantics::GuideSemanticType) type); } @@ -1221,7 +1218,7 @@ void BookBrowser::LinkStylesheets() void BookBrowser::NoObfuscationMethod() { foreach(Resource * resource, ValidSelectedResources()) { - FontResource *font_resource = qobject_cast< FontResource * >(resource); + FontResource *font_resource = qobject_cast(resource); Q_ASSERT(font_resource); font_resource->SetObfuscationAlgorithm(""); } @@ -1231,7 +1228,7 @@ void BookBrowser::NoObfuscationMethod() void BookBrowser::AdobesObfuscationMethod() { foreach(Resource * resource, ValidSelectedResources()) { - FontResource *font_resource = qobject_cast< FontResource * >(resource); + FontResource *font_resource = qobject_cast(resource); Q_ASSERT(font_resource); font_resource->SetObfuscationAlgorithm(ADOBE_FONT_ALGO_ID); } @@ -1241,7 +1238,7 @@ void BookBrowser::AdobesObfuscationMethod() void BookBrowser::IdpfsObfuscationMethod() { foreach(Resource * resource, ValidSelectedResources()) { - FontResource *font_resource = qobject_cast< FontResource * >(resource); + FontResource *font_resource = qobject_cast(resource); Q_ASSERT(font_resource); font_resource->SetObfuscationAlgorithm(IDPF_FONT_ALGO_ID); } @@ -1252,7 +1249,7 @@ void BookBrowser::ValidateStylesheetWithW3C() { QList resources = ValidSelectedResources(Resource::CSSResourceType); foreach(Resource * resource, resources) { - CSSResource *css_resource = qobject_cast< CSSResource * >(resource); + CSSResource *css_resource = qobject_cast(resource); Q_ASSERT(css_resource); css_resource->ValidateStylesheetWithW3C(); } @@ -1576,7 +1573,7 @@ void BookBrowser::SetupHTMLSemanticContextMenu(Resource *resource) void BookBrowser::SetupImageSemanticContextMenu(Resource *resource) { m_SemanticsContextMenu.addAction(m_CoverImage); - ImageResource *image_resource = qobject_cast< ImageResource * >(GetCurrentResource()); + ImageResource *image_resource = qobject_cast(GetCurrentResource()); Q_ASSERT(image_resource); m_CoverImage->setChecked(false); @@ -1592,7 +1589,7 @@ void BookBrowser::SetHTMLSemanticActionCheckState(Resource *resource) return; } - HTMLResource *html_resource = qobject_cast< HTMLResource * >(resource); + HTMLResource *html_resource = qobject_cast(resource); Q_ASSERT(html_resource); foreach(QAction * action, m_GuideSemanticActions) { action->setChecked(false); @@ -1605,7 +1602,7 @@ void BookBrowser::SetHTMLSemanticActionCheckState(Resource *resource) } foreach(Resource * valid_resource, ValidSelectedResources()) { - HTMLResource *valid_html_resource = qobject_cast< HTMLResource * >(valid_resource); + HTMLResource *valid_html_resource = qobject_cast(valid_resource); Q_ASSERT(html_resource); GuideSemantics::GuideSemanticType valid_semantic_type = m_Book->GetOPF().GetGuideSemanticTypeForResource(*valid_html_resource); @@ -1642,13 +1639,13 @@ void BookBrowser::SetFontObfuscationActionCheckState() } // Get the algorithm used by the first font - FontResource *font_resource = qobject_cast< FontResource * >(resource); + FontResource *font_resource = qobject_cast(resource); Q_ASSERT(font_resource); QString algorithm = font_resource->GetObfuscationAlgorithm(); // Now compare against all the other fonts and if the same set a checkmark bool same_algorithm = true; foreach(Resource * resource, ValidSelectedResources()) { - FontResource *font_resource2 = qobject_cast< FontResource * >(resource); + FontResource *font_resource2 = qobject_cast(resource); Q_ASSERT(font_resource); QString algorithm2 = font_resource2->GetObfuscationAlgorithm(); diff --git a/src/Sigil/MainUI/BookBrowser.h b/src/Sigil/MainUI/BookBrowser.h index 6bfe45f0ff..d50b35387a 100644 --- a/src/Sigil/MainUI/BookBrowser.h +++ b/src/Sigil/MainUI/BookBrowser.h @@ -119,7 +119,7 @@ public slots: * * @param book The book to be displayed. */ - void SetBook(QSharedPointer< Book > book); + void SetBook(QSharedPointer book); /** * Refreshes the display of the book. @@ -451,7 +451,7 @@ private slots: /** * The book currently being displayed. */ - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; /** * The tree view used to represent the book's files. @@ -511,7 +511,7 @@ private slots: * All the semantic actions for the * element. Only present on HTMLResources. */ - QList< QAction * > m_GuideSemanticActions; + QList m_GuideSemanticActions; /** * Used to translate all the triggered() signals from the diff --git a/src/Sigil/MainUI/ClipsWindow.cpp b/src/Sigil/MainUI/ClipsWindow.cpp index 98546f9862..ccb6786c36 100644 --- a/src/Sigil/MainUI/ClipsWindow.cpp +++ b/src/Sigil/MainUI/ClipsWindow.cpp @@ -66,7 +66,7 @@ void ClipsWindow::showEvent(QShowEvent *event) } void ClipsWindow::SetupTreeView() -{ +{ m_ClipsModel = ClipEditorModel::instance(); m_TreeView.setModel(m_ClipsModel); m_TreeView.setSortingEnabled(false); diff --git a/src/Sigil/MainUI/FindReplace.cpp b/src/Sigil/MainUI/FindReplace.cpp index b84c3308cd..78d74f39f0 100644 --- a/src/Sigil/MainUI/FindReplace.cpp +++ b/src/Sigil/MainUI/FindReplace.cpp @@ -137,8 +137,7 @@ void FindReplace::ShowHideMarkedText(bool marked) if (marked) { ui.cbLookWhere->hide(); ui.MarkedTextIndicator->show(); - } - else { + } else { ui.cbLookWhere->show(); ui.MarkedTextIndicator->hide(); } @@ -238,8 +237,7 @@ bool FindReplace::FindAnyText(QString text, bool escape) QString search_text; if (escape) { search_text = QRegularExpression::escape(text); - } - else { + } else { search_text = text + "(?![^<>]*>)(?!.*]*>)"; } ui.cbFind->setEditText(search_text); @@ -672,7 +670,7 @@ bool FindReplace::IsCurrentFileInHTMLSelection() bool found = false; QList resources = GetHTMLFiles(); Resource *current_resource = GetCurrentResource(); - HTMLResource *current_html_resource = qobject_cast< HTMLResource *>(current_resource); + HTMLResource *current_html_resource = qobject_cast(current_resource); if (current_html_resource) { foreach(Resource * resource, resources) { @@ -715,8 +713,7 @@ QList FindReplace::GetHTMLFiles() break; } } - } - else { + } else { bool keep = false; foreach (Resource *resource, all_resources) { if (resource == current_resource) { @@ -821,7 +818,7 @@ bool FindReplace::FindInAllFiles(Searchable::Direction direction) HTMLResource *FindReplace::GetNextContainingHTMLResource(Searchable::Direction direction) { Resource *current_resource = GetCurrentResource(); - HTMLResource *starting_html_resource = qobject_cast< HTMLResource *> (current_resource); + HTMLResource *starting_html_resource = qobject_cast (current_resource); QList resources = GetHTMLFiles(); @@ -831,9 +828,9 @@ HTMLResource *FindReplace::GetNextContainingHTMLResource(Searchable::Direction d if (!starting_html_resource || (GetLookWhere() == FindReplace::LookWhere_SelectedHTMLFiles && !IsCurrentFileInHTMLSelection())) { if (direction == Searchable::Direction_Up) { - starting_html_resource = qobject_cast< HTMLResource *>(resources.first()); + starting_html_resource = qobject_cast(resources.first()); } else { - starting_html_resource = qobject_cast< HTMLResource *>(resources.last()); + starting_html_resource = qobject_cast(resources.last()); } } @@ -892,7 +889,7 @@ HTMLResource *FindReplace::GetNextHTMLResource(HTMLResource *current_resource, S if (next_reading_order > max_reading_order || next_reading_order < 0) { return NULL; } else { - HTMLResource &html_resource = *qobject_cast< HTMLResource *>(resources[ next_reading_order ]); + HTMLResource &html_resource = *qobject_cast(resources[ next_reading_order ]); return &html_resource; } } diff --git a/src/Sigil/MainUI/FindReplace.h b/src/Sigil/MainUI/FindReplace.h index d1f7794cfa..2eba3d10fa 100644 --- a/src/Sigil/MainUI/FindReplace.h +++ b/src/Sigil/MainUI/FindReplace.h @@ -217,7 +217,7 @@ private slots: void SetLookWhere(int look_where); void SetSearchDirection(int search_direction); - template< class T > + template bool ResourceContainsCurrentRegex(T *resource); /** @@ -309,7 +309,7 @@ private slots: }; -template< class T > +template bool FindReplace::ResourceContainsCurrentRegex(T *resource) { // For now, this must hold @@ -317,7 +317,7 @@ bool FindReplace::ResourceContainsCurrentRegex(T *resource) Resource *generic_resource = resource; return SearchOperations::CountInFiles( GetSearchRegex(), - QList< Resource * >() << generic_resource, + QList() << generic_resource, SearchOperations::CodeViewSearch, m_SpellCheck) > 0; } diff --git a/src/Sigil/MainUI/MainWindow.cpp b/src/Sigil/MainUI/MainWindow.cpp index 31e6631f2a..75b9f5639b 100644 --- a/src/Sigil/MainUI/MainWindow.cpp +++ b/src/Sigil/MainUI/MainWindow.cpp @@ -231,8 +231,9 @@ void MainWindow::loadPluginsMenu() foreach(QString key, keys) { Plugin *p = plugins.value(key); - if (p == NULL) + if (p == NULL) { continue; + } QString pname = p->get_name(); QString ptype = p->get_type(); @@ -311,13 +312,13 @@ QList MainWindow::GetAllHTMLResources() } -QSharedPointer< Book > MainWindow::GetCurrentBook() +QSharedPointer MainWindow::GetCurrentBook() { return m_Book; } -BookBrowser * MainWindow::GetBookBrowser() +BookBrowser *MainWindow::GetBookBrowser() { return m_BookBrowser; } @@ -330,7 +331,7 @@ ContentTab &MainWindow::GetCurrentContentTab() FlowTab *MainWindow::GetCurrentFlowTab() { - return qobject_cast< FlowTab * >(&GetCurrentContentTab()); + return qobject_cast(&GetCurrentContentTab()); } void MainWindow::ResetLinkOrStyleBookmark() @@ -458,12 +459,12 @@ void MainWindow::OpenResource(Resource &resource, } void MainWindow::OpenResourceAndWaitUntilLoaded(Resource &resource, - int line_to_scroll_to, - int position_to_scroll_to, - const QString &caret_location_to_scroll_to, - MainWindow::ViewState view_state, - const QUrl &fragment, - bool precede_current_tab) + int line_to_scroll_to, + int position_to_scroll_to, + const QString &caret_location_to_scroll_to, + MainWindow::ViewState view_state, + const QUrl &fragment, + bool precede_current_tab) { OpenResource(resource, line_to_scroll_to, position_to_scroll_to, caret_location_to_scroll_to, view_state, fragment, precede_current_tab); while (!GetCurrentContentTab().IsLoadingFinished()) { @@ -479,7 +480,7 @@ void MainWindow::ResourceUpdatedFromDisk(Resource &resource) int duration = 10000; if (resource.Type() == Resource::HTMLResourceType) { - HTMLResource &html_resource = *qobject_cast< HTMLResource *>(&resource); + HTMLResource &html_resource = *qobject_cast(&resource); if (!m_Book->IsDataOnDiskWellFormed(html_resource)) { OpenResource(resource, -1, -1, QString(), MainWindow::ViewState_CodeView); message = QString(tr("Warning")) + ": " + message + " " + tr("The file was NOT well formed and may be corrupted."); @@ -509,10 +510,10 @@ void MainWindow::ShowLastOpenFileWarnings() { if (!m_LastOpenFileWarnings.isEmpty()) { Utility::DisplayStdWarningDialog( - "

" % - tr("This EPUB contains errors.") % - "

" % - tr("Select Show Details for more information.") % + "

" % + tr("This EPUB contains errors.") % + "

" % + tr("Select Show Details for more information.") % "

", m_LastOpenFileWarnings.join("\n")); m_LastOpenFileWarnings.clear(); @@ -646,7 +647,7 @@ void MainWindow::OpenRecentFile() // The nasty IFDEFs are here to enable the multi-document // interface on the Mac; Lin and Win just use multiple // instances of the Sigil application - QAction *action = qobject_cast< QAction *>(sender()); + QAction *action = qobject_cast(sender()); if (action != NULL) { #ifndef Q_OS_MAC @@ -1021,7 +1022,7 @@ void MainWindow::AddCover() // Populate the HTML cover file with the necessary text. // If a template file exists, use its text for the cover source. - QString text = HTML_COVER_SOURCE; + QString text = HTML_COVER_SOURCE; QString cover_path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + HTML_COVER_FILENAME; if (QFile::exists(cover_path)) { text = Utility::ReadUnicodeTextFile(cover_path); @@ -1030,8 +1031,7 @@ void MainWindow::AddCover() // Create an HTMLResource for the cover if it doesn't exist. if (html_cover_resource == NULL) { html_cover_resource = &m_Book->CreateHTMLCoverFile(text); - } - else { + } else { html_cover_resource->SetText(text); } @@ -1058,8 +1058,7 @@ void MainWindow::AddCover() text.replace("SGC_IMAGE_WIDTH", width); text.replace("SGC_IMAGE_HEIGHT", height); html_cover_resource->SetText(text); - } - else { + } else { Utility::DisplayStdErrorDialog(tr("Unexpected error. Only image files can be used for the cover.")); } } catch (const ResourceDoesNotExist &) { @@ -1093,15 +1092,14 @@ void MainWindow::CreateIndex() found_css = true; } } - + // If Index CSS file does not exist look for a default file // in preferences directory and if none create one. if (!found_css) { QString css_path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + SGC_INDEX_CSS_FILENAME; if (QFile::exists(css_path)) { m_BookBrowser->AddFile(css_path); - } - else { + } else { m_BookBrowser->CreateIndexCSSFile(); } } @@ -1167,7 +1165,7 @@ void MainWindow::CreateIndex() void MainWindow::DeleteReportsStyles(QList reports_styles_to_delete) { // Convert the styles to CSS Selectors - QHash< QString, QList > css_styles_to_delete; + QHash> css_styles_to_delete; foreach(BookReports::StyleData * report_style, reports_styles_to_delete) { CSSInfo::CSSSelector *selector = new CSSInfo::CSSSelector(); selector->groupText = report_style->css_selector_text; @@ -1193,7 +1191,7 @@ void MainWindow::DeleteReportsStyles(QList reports_sty QApplication::setOverrideCursor(Qt::WaitCursor); // Actually delete the styles - QHashIterator< QString, QList > stylesheets_to_delete(css_styles_to_delete); + QHashIterator> stylesheets_to_delete(css_styles_to_delete); while (stylesheets_to_delete.hasNext()) { stylesheets_to_delete.next(); @@ -1430,12 +1428,10 @@ void MainWindow::InsertFiles(const QStringList &selected_files) QString html; if (resource.Type() == Resource::ImageResourceType || resource.Type() == Resource::SVGResourceType) { html = QString("\"%1\"").arg(filename).arg(relative_path); - } - else if (resource.Type() == Resource::VideoResourceType) { + } else if (resource.Type() == Resource::VideoResourceType) { // When inserted in BV the filename will disappear html = QString("").arg(relative_path).arg(filename); - } - else if (resource.Type() == Resource::AudioResourceType) { + } else if (resource.Type() == Resource::AudioResourceType) { html = QString("").arg(relative_path).arg(filename); } @@ -1504,7 +1500,7 @@ void MainWindow::InsertId() return; } - HTMLResource *html_resource = qobject_cast< HTMLResource * >(&flow_tab->GetLoadedResource()); + HTMLResource *html_resource = qobject_cast(&flow_tab->GetLoadedResource()); SelectId select_id(id, html_resource, m_Book, this); @@ -1544,7 +1540,7 @@ void MainWindow::InsertHyperlink() return; } - HTMLResource *html_resource = qobject_cast< HTMLResource * >(&flow_tab->GetLoadedResource()); + HTMLResource *html_resource = qobject_cast(&flow_tab->GetLoadedResource()); QList resources = GetAllHTMLResources() + m_BookBrowser->AllMediaResources(); SelectHyperlink select_hyperlink(href, html_resource, resources, m_Book, this); @@ -1916,7 +1912,7 @@ void MainWindow::FindWord(QString word) } } - // Get list of files from current to end followed + // Get list of files from current to end followed // by start to just before current file. QList html_resources; QList resources = GetAllHTMLResources(); @@ -1994,9 +1990,9 @@ void MainWindow::UpdateWord(QString old_word, QString new_word) QApplication::restoreOverrideCursor(); } -QList > MainWindow::GetStylesheetsMap(QList resources) +QList> MainWindow::GetStylesheetsMap(QList resources) { - QList< std::pair< QString, bool> > stylesheet_map; + QList> stylesheet_map; QList css_resources = m_BookBrowser->AllCSSResources(); // Use the first resource to get a list of known linked stylesheets in order. QStringList checked_linked_paths = GetStylesheetsAlreadyLinked(resources.at(0)); @@ -2028,7 +2024,7 @@ QList > MainWindow::GetStylesheetsMap(QList(resource); + HTMLResource *html_resource = qobject_cast(resource); QStringList linked_stylesheets; QStringList existing_stylesheets; foreach(Resource * css_resource, m_BookBrowser->AllCSSResources()) { @@ -2122,15 +2118,14 @@ void MainWindow::CreateHTMLTOC() found_css = true; } } - + // If HTML TOC CSS file does not exist look for a default file // in preferences directory and if none create one. if (!found_css) { QString css_path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + SGC_TOC_CSS_FILENAME; if (QFile::exists(css_path)) { m_BookBrowser->AddFile(css_path); - } - else { + } else { m_BookBrowser->CreateHTMLTOCCSSFile(); } } @@ -2231,8 +2226,7 @@ void MainWindow::MarkSelection() m_FindReplace->ShowHideMarkedText(marked); if (marked) { ShowMessageOnStatusBar(tr("Text selection marked.")); - } - else { + } else { ShowMessageOnStatusBar(tr("Text selection unmarked.")); } } @@ -2242,8 +2236,7 @@ void MainWindow::ClearMarkedText(ContentTab *old_tab) bool cleared = false; if (old_tab) { cleared = old_tab->ClearMarkedText(); - } - else { + } else { ContentTab &tab = GetCurrentContentTab(); if (&tab == NULL) { return; @@ -2913,7 +2906,7 @@ void MainWindow::SetupPreviewTimer() void MainWindow::UpdatePreviewRequest() { if (m_PreviewTimer.isActive()) { - m_PreviewTimer.stop(); + m_PreviewTimer.stop(); } m_PreviewTimer.start(); } @@ -2941,32 +2934,29 @@ void MainWindow::UpdatePreview() tab.SaveTabContent(); } - html_resource = qobject_cast< HTMLResource * >(&tab.GetLoadedResource()); + html_resource = qobject_cast(&tab.GetLoadedResource()); if (!html_resource) { html_resource = m_PreviousHTMLResource; - } - else { + } else { m_PreviousHTMLResource = NULL; } if (html_resource) { - FlowTab *flow_tab = qobject_cast< FlowTab * >(&tab); + FlowTab *flow_tab = qobject_cast(&tab); if (flow_tab) { // Make sure the document is loaded. As soon as the views are created // signals are sent that it has changed which requests Preview to update // so these need to be ignored. Once the document is loaded it signals again. - if(!flow_tab->IsLoadingFinished()) { + if (!flow_tab->IsLoadingFinished()) { return; } text = flow_tab->GetText(); location = flow_tab->GetCaretLocation(); - } - else { + } else { text = m_PreviousHTMLText; if (m_PreviousHTMLResource) { location = m_PreviewWindow->GetCaretLocation(); - } - else { + } else { location = m_PreviousHTMLLocation; } } @@ -3281,7 +3271,7 @@ bool MainWindow::MaybeSaveDialogSaysProceed() } -void MainWindow::SetNewBook(QSharedPointer< Book > new_book) +void MainWindow::SetNewBook(QSharedPointer new_book) { m_TabManager.CloseOtherTabs(); m_TabManager.CloseAllTabs(true); @@ -3318,7 +3308,7 @@ void MainWindow::ResourcesAddedOrDeleted() void MainWindow::CreateNewBook() { - QSharedPointer< Book > new_book = QSharedPointer< Book >(new Book()); + QSharedPointer new_book = QSharedPointer(new Book()); new_book->CreateEmptyHTMLFile(); SetNewBook(new_book); new_book->SetModified(false); @@ -3455,13 +3445,13 @@ bool MainWindow::SaveFile(const QString &fullfilepath, bool update_current_filen if (not_well_formed) { QApplication::restoreOverrideCursor(); bool auto_fix = QMessageBox::Yes == QMessageBox::warning(this, - tr("Sigil"), - tr("This EPUB has HTML files that are not well formed and " - "your current Clean Source preferences are set to automatically clean on Save. " - "Saving a file that is not well formed will cause it to be automatically " - "fixed, which can result in data loss.\n\n" - "Do you want to automatically fix the files before saving?"), - QMessageBox::Yes|QMessageBox::No); + tr("Sigil"), + tr("This EPUB has HTML files that are not well formed and " + "your current Clean Source preferences are set to automatically clean on Save. " + "Saving a file that is not well formed will cause it to be automatically " + "fixed, which can result in data loss.\n\n" + "Do you want to automatically fix the files before saving?"), + QMessageBox::Yes|QMessageBox::No); QApplication::setOverrideCursor(Qt::WaitCursor); if (auto_fix) { CleanSource::ReformatAll(resources, CleanSource::Clean); @@ -3471,7 +3461,7 @@ bool MainWindow::SaveFile(const QString &fullfilepath, bool update_current_filen CleanSource::ReformatAll(resources, CleanSource::Clean); } } - + ExporterFactory().GetExporter(fullfilepath, m_Book).WriteBook(); // Return the focus back to the current tab @@ -3488,8 +3478,7 @@ bool MainWindow::SaveFile(const QString &fullfilepath, bool update_current_filen if (not_well_formed) { ShowMessageOnStatusBar(tr("EPUB saved, but not all HTML files are well formed.")); - } - else { + } else { ShowMessageOnStatusBar(tr("EPUB saved.")); } QApplication::restoreOverrideCursor(); @@ -3547,8 +3536,7 @@ void MainWindow::ZoomByFactor(float new_zoom_factor) if (m_ZoomPreview && m_PreviewWindow->IsVisible()) { m_PreviewWindow->SetZoomFactor(new_zoom_factor); - } - else { + } else { tab.SetZoomFactor(new_zoom_factor); } } @@ -3557,8 +3545,7 @@ float MainWindow::GetZoomFactor() { if (m_ZoomPreview && m_PreviewWindow->IsVisible()) { return m_PreviewWindow->GetZoomFactor(); - } - else { + } else { ContentTab &tab = m_TabManager.GetCurrentContentTab(); if (&tab != NULL) { @@ -3630,9 +3617,9 @@ void MainWindow::SetInsertedFileWatchResourceFile(const QString &pathname) } } -const QMap< QString, QString > MainWindow::GetLoadFiltersMap() +const QMap MainWindow::GetLoadFiltersMap() { - QMap< QString, QString > file_filters; + QMap file_filters; file_filters[ "epub" ] = tr("EPUB files (*.epub)"); file_filters[ "htm" ] = tr("HTML files (*.htm *.html *.xhtml)"); file_filters[ "html" ] = tr("HTML files (*.htm *.html *.xhtml)"); @@ -3643,9 +3630,9 @@ const QMap< QString, QString > MainWindow::GetLoadFiltersMap() } -const QMap< QString, QString > MainWindow::GetSaveFiltersMap() +const QMap MainWindow::GetSaveFiltersMap() { - QMap< QString, QString > file_filters; + QMap file_filters; file_filters[ "epub" ] = tr("EPUB file (*.epub)"); return file_filters; } @@ -3674,7 +3661,7 @@ void MainWindow::UpdateUiWithCurrentFile(const QString &fullfilepath) // Update the recent files actions on // ALL the main windows foreach(QWidget * window, QApplication::topLevelWidgets()) { - if (MainWindow *mainWin = qobject_cast< MainWindow * >(window)) { + if (MainWindow *mainWin = qobject_cast(window)) { mainWin->UpdateRecentFileActions(); } } @@ -4065,8 +4052,7 @@ void MainWindow::UpdateClipButton(int clip_number, QAction *ui_action) clip_text.replace('&', "&").replace('<', "<").replace('>', ">"); ui_action->setToolTip(clip_text); ui_action->setVisible(true); - } - else { + } else { ui_action->setText(""); ui_action->setToolTip(""); ui_action->setVisible(false); @@ -4483,7 +4469,7 @@ void MainWindow::ConnectSignalsToSlots() connect(m_SpellcheckEditor, SIGNAL(SpellingHighlightRefreshRequest()), this, SLOT(RefreshSpellingHighlighting())); connect(m_SpellcheckEditor, SIGNAL(FindWordRequest(QString)), this, SLOT(FindWord(QString))); connect(m_SpellcheckEditor, SIGNAL(UpdateWordRequest(QString, QString)), this, SLOT(UpdateWord(QString, QString))); - connect(m_SpellcheckEditor, SIGNAL(ShowStatusMessageRequest(const QString &)), + connect(m_SpellcheckEditor, SIGNAL(ShowStatusMessageRequest(const QString &)), this, SLOT(ShowMessageOnStatusBar(const QString &))); connect(m_Reports, SIGNAL(Refresh()), this, SLOT(ReportsDialog())); connect(m_Reports, SIGNAL(OpenFileRequest(QString, int)), this, SLOT(OpenFile(QString, int))); @@ -4565,8 +4551,8 @@ void MainWindow::MakeTabConnections(ContentTab *tab) connect(this, SIGNAL(SettingsChanged()), tab, SLOT(LoadSettings())); connect(tab, SIGNAL(OpenIndexEditorRequest(IndexEditorModel::indexEntry *)), this, SLOT(IndexEditorDialog(IndexEditorModel::indexEntry *))); - connect(tab, SIGNAL(ViewImageRequest(const QUrl&)), - this, SLOT(ViewImageDialog(const QUrl&))); + connect(tab, SIGNAL(ViewImageRequest(const QUrl &)), + this, SLOT(ViewImageDialog(const QUrl &))); connect(tab, SIGNAL(GoToLinkedStyleDefinitionRequest(const QString &, const QString &)), this, SLOT(GoToLinkedStyleDefinition(const QString &, const QString &))); connect(tab, SIGNAL(BookmarkLinkOrStyleLocationRequest()), diff --git a/src/Sigil/MainUI/MainWindow.h b/src/Sigil/MainUI/MainWindow.h index 852e3daaac..8ee95a4700 100644 --- a/src/Sigil/MainUI/MainWindow.h +++ b/src/Sigil/MainUI/MainWindow.h @@ -107,7 +107,7 @@ class MainWindow : public QMainWindow * * @return A shared pointer to the book. */ - QSharedPointer< Book > GetCurrentBook(); + QSharedPointer GetCurrentBook(); /** @@ -115,7 +115,7 @@ class MainWindow : public QMainWindow * * @return A pointer to the BookBrowser */ - BookBrowser * GetBookBrowser(); + BookBrowser *GetBookBrowser(); /** @@ -187,8 +187,8 @@ class MainWindow : public QMainWindow * * @return The load dialog filters. */ - static const QMap< QString, QString > GetLoadFiltersMap(); - + static const QMap GetLoadFiltersMap(); + /** * Loads a book from the file specified. * @@ -214,17 +214,17 @@ public slots: bool precede_current_tab = false); void OpenResourceAndWaitUntilLoaded(Resource &resource, - int line_to_scroll_to = -1, - int position_to_scroll_to = -1, - const QString &caret_location_to_scroll_to = QString(), - MainWindow::ViewState view_state = MainWindow::ViewState_Unknown, - const QUrl &fragment = QUrl(), - bool precede_current_tab = false); + int line_to_scroll_to = -1, + int position_to_scroll_to = -1, + const QString &caret_location_to_scroll_to = QString(), + MainWindow::ViewState view_state = MainWindow::ViewState_Unknown, + const QUrl &fragment = QUrl(), + bool precede_current_tab = false); void CreateIndex(); void runPlugin(QAction *action); - + void ResourcesAddedOrDeleted(); @@ -590,7 +590,7 @@ private slots: /** * Return a map of stylesheets included/excluded for all given resources */ - QList< std::pair > GetStylesheetsMap(QList resources); + QList> GetStylesheetsMap(QList resources); /** * Return the list of stylesheets linked to the given resource @@ -636,7 +636,7 @@ private slots: void UpdateClipsUI(); - /** + /** * support for plugins */ void loadPluginsMenu(); @@ -680,7 +680,7 @@ private slots: * * @param new_book The new book for editing. */ - void SetNewBook(QSharedPointer< Book > new_book); + void SetNewBook(QSharedPointer new_book); /** * Creates a new, empty book and replaces @@ -737,7 +737,7 @@ private slots: * * @return The save dialog filters. */ - static const QMap< QString, QString > GetSaveFiltersMap(); + static const QMap GetSaveFiltersMap(); /** * Sets the current file in the window title and also @@ -851,7 +851,7 @@ private slots: /** * The book currently being worked on. */ - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; /** * The last folder from which the user opened or saved a file. @@ -932,7 +932,7 @@ private slots: * A map with keys being extensions of file types * we can load, and the values being filters for use in file dialogs. */ - const QMap< QString, QString > c_SaveFilters; + const QMap c_SaveFilters; /** * A map with keys being extensions of file types @@ -999,11 +999,11 @@ private slots: /** * dynamically updated plugin menus and actions */ - QMenu * m_menuPlugins; - QMenu * m_menuPluginsInput; - QMenu * m_menuPluginsOutput; - QMenu * m_menuPluginsEdit; - QAction * m_actionManagePlugins; + QMenu *m_menuPlugins; + QMenu *m_menuPluginsInput; + QMenu *m_menuPluginsOutput; + QMenu *m_menuPluginsEdit; + QAction *m_actionManagePlugins; bool m_SaveCSS; /** diff --git a/src/Sigil/MainUI/NCXModel.cpp b/src/Sigil/MainUI/NCXModel.cpp index 57daa8bd23..9f1b06812f 100644 --- a/src/Sigil/MainUI/NCXModel.cpp +++ b/src/Sigil/MainUI/NCXModel.cpp @@ -33,13 +33,13 @@ NCXModel::NCXModel(QObject *parent) QStandardItemModel(parent), m_Book(NULL), m_RefreshInProgress(false), - m_NcxRootWatcher(*new QFutureWatcher< NCXModel::NCXEntry >(this)) + m_NcxRootWatcher(*new QFutureWatcher(this)) { connect(&m_NcxRootWatcher, SIGNAL(finished()), this, SLOT(RefreshEnd())); } -void NCXModel::SetBook(QSharedPointer< Book > book) +void NCXModel::SetBook(QSharedPointer book) { { // We need to make sure we don't step on the toes of GetNCXText diff --git a/src/Sigil/MainUI/NCXModel.h b/src/Sigil/MainUI/NCXModel.h index f8e9ac692e..73c5bdba1a 100644 --- a/src/Sigil/MainUI/NCXModel.h +++ b/src/Sigil/MainUI/NCXModel.h @@ -59,7 +59,7 @@ class NCXModel : public QStandardItemModel * * @param book The book whose model we will be building. */ - void SetBook(QSharedPointer< Book > book); + void SetBook(QSharedPointer book); /** * Translates a model index of an item into an URL @@ -99,7 +99,7 @@ class NCXModel : public QStandardItemModel /** * This entry's sub-entries (its children). */ - QList< NCXEntry > children; + QList children; /** * If \c true, then this is an "invisible" root NCXEntry; @@ -180,7 +180,7 @@ private slots: /** * The book whose model we are representing. */ - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; /** * If \c true, then a refresh operation is in progress. @@ -196,7 +196,7 @@ private slots: * Watches the completion of the GetRootNCXEntry func * and signals the RefreshEnd func when the root NCX entry is ready. */ - QFutureWatcher< NCXEntry > &m_NcxRootWatcher; + QFutureWatcher &m_NcxRootWatcher; }; diff --git a/src/Sigil/MainUI/OPFModel.cpp b/src/Sigil/MainUI/OPFModel.cpp index 57247d2d64..7e639a9210 100644 --- a/src/Sigil/MainUI/OPFModel.cpp +++ b/src/Sigil/MainUI/OPFModel.cpp @@ -38,7 +38,7 @@ #include "sigil_exception.h" #include "SourceUpdates/UniversalUpdates.h" -static const QList< QChar > FORBIDDEN_FILENAME_CHARS = QList< QChar >() << '<' << '>' << ':' +static const QList FORBIDDEN_FILENAME_CHARS = QList() << '<' << '>' << ':' << '"' << '/' << '\\' << '|' << '?' << '*'; @@ -59,7 +59,7 @@ OPFModel::OPFModel(QObject *parent) this, SLOT(RowsRemovedHandler(const QModelIndex &, int, int))); connect(this, SIGNAL(itemChanged(QStandardItem *)), this, SLOT(ItemChangedHandler(QStandardItem *))); - QList< QStandardItem * > items; + QList items; items.append(&m_TextFolderItem); items.append(&m_StylesFolderItem); items.append(&m_ImagesFolderItem); @@ -81,7 +81,7 @@ OPFModel::OPFModel(QObject *parent) } -void OPFModel::SetBook(QSharedPointer< Book > book) +void OPFModel::SetBook(QSharedPointer book) { m_Book = book; connect(this, SIGNAL(BookContentModified()), m_Book.data(), SLOT(SetModified())); @@ -124,13 +124,13 @@ QModelIndex OPFModel::GetTextFolderModelIndex() } -QList OPFModel::GetResourceListInFolder(Resource *resource) +QList OPFModel::GetResourceListInFolder(Resource *resource) { return GetResourceListInFolder(resource->Type()); } -QList OPFModel::GetResourceListInFolder(Resource::ResourceType resource_type) +QList OPFModel::GetResourceListInFolder(Resource::ResourceType resource_type) { QList resources; QStandardItem *folder = NULL; @@ -187,7 +187,7 @@ QModelIndex OPFModel::GetModelItemIndex(Resource &resource, IndexChoice indexCho (child == &m_MiscFolderItem && resourceType == Resource::GenericResourceType) || (child == &m_AudioFolderItem && resourceType == Resource::AudioResourceType) || (child == &m_VideoFolderItem && resourceType == Resource::VideoResourceType) - ) { + ) { folder = child; } } @@ -307,7 +307,7 @@ void OPFModel::ItemChangedHandler(QStandardItem *item) if (!Utility::use_filename_warning(new_filename)) { item->setText(resource.Filename()); return; - } + } RenameResource(resource, new_filename); } } @@ -329,7 +329,7 @@ bool OPFModel:: RenameResourceList(QList resources, QList n { QApplication::setOverrideCursor(Qt::WaitCursor); QStringList not_renamed; - QHash< QString, QString > update; + QHash update; foreach(Resource * resource, resources) { const QString &old_fullpath = resource->GetFullPath(); QString old_filename = resource->Filename(); @@ -381,7 +381,7 @@ void OPFModel::InitializeModel() { Q_ASSERT(m_Book); ClearModel(); - QList< Resource * > resources = m_Book->GetFolderKeeper().GetResourceList(); + QList resources = m_Book->GetFolderKeeper().GetResourceList(); QHash reading_order_all = m_Book->GetOPF().GetReadingOrderAll(resources); QHash semantic_type_all = m_Book->GetOPF().GetGuideSemanticNameForPaths(); @@ -401,8 +401,7 @@ void OPFModel::InitializeModel() int reading_order = -1; if (reading_order_all.contains(resource)) { reading_order = reading_order_all[resource]; - } - else { + } else { reading_order = NO_READING_ORDER; } @@ -441,13 +440,13 @@ void OPFModel::InitializeModel() void OPFModel::UpdateHTMLReadingOrders() { - QList< HTMLResource * > reading_order_htmls; + QList reading_order_htmls; for (int i = 0; i < m_TextFolderItem.rowCount(); ++i) { QStandardItem *html_item = m_TextFolderItem.child(i); Q_ASSERT(html_item); html_item->setData(i, READING_ORDER_ROLE); - HTMLResource *html_resource = qobject_cast< HTMLResource * >( + HTMLResource *html_resource = qobject_cast( &m_Book->GetFolderKeeper().GetResourceByIdentifier(html_item->data().toString())); if (html_resource != NULL) { diff --git a/src/Sigil/MainUI/OPFModel.h b/src/Sigil/MainUI/OPFModel.h index 945941d430..034fe52fab 100644 --- a/src/Sigil/MainUI/OPFModel.h +++ b/src/Sigil/MainUI/OPFModel.h @@ -63,7 +63,7 @@ class OPFModel : public QStandardItemModel * * @param book The book whose model we will be building. */ - void SetBook(QSharedPointer< Book > book); + void SetBook(QSharedPointer book); /** * Forces the recreation of the model @@ -113,7 +113,7 @@ class OPFModel : public QStandardItemModel * @param item The resource in the folder whose list we want * @return The list of resources in the same folder as the given resource */ - QList GetResourceListInFolder(Resource *resource); + QList GetResourceListInFolder(Resource *resource); /** * Gets a sorted list of the resources in the folder containing the given resource type @@ -121,7 +121,7 @@ class OPFModel : public QStandardItemModel * @param item The resource type in the folder whose list we want * @return The list of resources in the same folder as the given resource */ - QList GetResourceListInFolder(Resource::ResourceType resource_type); + QList GetResourceListInFolder(Resource::ResourceType resource_type); /** * Gets an item's resource type. @@ -251,7 +251,7 @@ private slots: /** * The book whose model we are representing. */ - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; QStandardItem &m_TextFolderItem; /**< The Text folder item. */ QStandardItem &m_StylesFolderItem; /**< The Styles folder item. */ diff --git a/src/Sigil/MainUI/OPFModelItem.h b/src/Sigil/MainUI/OPFModelItem.h index 4dea5215af..325b558fc1 100644 --- a/src/Sigil/MainUI/OPFModelItem.h +++ b/src/Sigil/MainUI/OPFModelItem.h @@ -29,7 +29,7 @@ #include #include -static const int NO_READING_ORDER = std::numeric_limits< int >::max(); +static const int NO_READING_ORDER = std::numeric_limits::max(); static const int READING_ORDER_ROLE = Qt::UserRole + 2; static const int ALPHANUMERIC_ORDER_ROLE = Qt::UserRole + 3; diff --git a/src/Sigil/MainUI/PreviewWindow.cpp b/src/Sigil/MainUI/PreviewWindow.cpp index 037f4e8e55..f5dbe22b80 100644 --- a/src/Sigil/MainUI/PreviewWindow.cpp +++ b/src/Sigil/MainUI/PreviewWindow.cpp @@ -127,7 +127,7 @@ void PreviewWindow::showEvent(QShowEvent *event) emit Shown(); } -void PreviewWindow::UpdatePage(QString filename, QString text, QList< ViewEditor::ElementIndex > location) +void PreviewWindow::UpdatePage(QString filename, QString text, QList location) { if (!m_Preview->isVisible()) { return; @@ -151,7 +151,8 @@ QList PreviewWindow::GetCaretLocation() return m_Preview->GetCaretLocation(); } -void PreviewWindow::SetZoomFactor(float factor) { +void PreviewWindow::SetZoomFactor(float factor) +{ m_Preview->SetZoomFactor(factor); } diff --git a/src/Sigil/MainUI/PreviewWindow.h b/src/Sigil/MainUI/PreviewWindow.h index f8b5d252bc..c66dcb5ded 100644 --- a/src/Sigil/MainUI/PreviewWindow.h +++ b/src/Sigil/MainUI/PreviewWindow.h @@ -49,7 +49,7 @@ class PreviewWindow : public QDockWidget float GetZoomFactor(); public slots: - void UpdatePage(QString filename, QString text, QList< ViewEditor::ElementIndex > location); + void UpdatePage(QString filename, QString text, QList location); void SetZoomFactor(float factor); void SplitterMoved(int pos, int index); diff --git a/src/Sigil/MainUI/TableOfContents.cpp b/src/Sigil/MainUI/TableOfContents.cpp index a8da0167f4..cb8b6beac0 100644 --- a/src/Sigil/MainUI/TableOfContents.cpp +++ b/src/Sigil/MainUI/TableOfContents.cpp @@ -72,7 +72,7 @@ void TableOfContents::showEvent(QShowEvent *event) raise(); } -void TableOfContents::SetBook(QSharedPointer< Book > book) +void TableOfContents::SetBook(QSharedPointer book) { m_Book = book; m_NCXModel.SetBook(book); diff --git a/src/Sigil/MainUI/TableOfContents.h b/src/Sigil/MainUI/TableOfContents.h index 6ecb3e6164..f118bfecb1 100644 --- a/src/Sigil/MainUI/TableOfContents.h +++ b/src/Sigil/MainUI/TableOfContents.h @@ -61,7 +61,7 @@ public slots: * * @param book The book to be displayed. */ - void SetBook(QSharedPointer< Book > book); + void SetBook(QSharedPointer book); /** * Refreshes the display of the book's TOC. @@ -137,7 +137,7 @@ private slots: /** * The book currently being displayed. */ - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; /** * A container widget for the TOC UI widgets. diff --git a/src/Sigil/MainUI/ValidationResultsView.cpp b/src/Sigil/MainUI/ValidationResultsView.cpp index eed36b836a..f5733aab1b 100644 --- a/src/Sigil/MainUI/ValidationResultsView.cpp +++ b/src/Sigil/MainUI/ValidationResultsView.cpp @@ -60,7 +60,7 @@ void ValidationResultsView::showEvent(QShowEvent *event) void ValidationResultsView::ValidateCurrentBook() { ClearResults(); - std::vector< fc::Result > results; + std::vector results; QApplication::setOverrideCursor(Qt::WaitCursor); m_Book->SaveAllResourcesToDisk(); @@ -90,7 +90,7 @@ void ValidationResultsView::ClearResults() } -void ValidationResultsView::SetBook(QSharedPointer< Book > book) +void ValidationResultsView::SetBook(QSharedPointer book) { m_Book = book; ClearResults(); @@ -135,7 +135,7 @@ void ValidationResultsView::SetUpTable() } -void ValidationResultsView::DisplayResults(const std::vector< fc::Result > &results) +void ValidationResultsView::DisplayResults(const std::vector &results) { m_ResultTable.clear(); diff --git a/src/Sigil/MainUI/ValidationResultsView.h b/src/Sigil/MainUI/ValidationResultsView.h index 4fa2440173..316e85c2b3 100644 --- a/src/Sigil/MainUI/ValidationResultsView.h +++ b/src/Sigil/MainUI/ValidationResultsView.h @@ -74,7 +74,7 @@ public slots: * * @param book The book to be validated. */ - void SetBook(QSharedPointer< Book > book); + void SetBook(QSharedPointer book); signals: @@ -116,7 +116,7 @@ private slots: * * @param results A list of FlightCrew validation results. */ - void DisplayResults(const std::vector< fc::Result > &results); + void DisplayResults(const std::vector &results); /** * Informs the user that no problems were found. @@ -149,7 +149,7 @@ private slots: /** * The book being validated. */ - QSharedPointer< Book > m_Book; + QSharedPointer m_Book; }; #endif // VALIDATIONRESULTSVIEW_H diff --git a/src/Sigil/Misc/CSSInfo.cpp b/src/Sigil/Misc/CSSInfo.cpp index 17b94e60da..c699598d21 100644 --- a/src/Sigil/Misc/CSSInfo.cpp +++ b/src/Sigil/Misc/CSSInfo.cpp @@ -48,7 +48,7 @@ CSSInfo::CSSInfo(const QString &text, bool isCSSFile) } } -QList< CSSInfo::CSSSelector * > CSSInfo::getClassSelectors(const QString filterClassName) +QList CSSInfo::getClassSelectors(const QString filterClassName) { QList selectors; foreach(CSSInfo::CSSSelector * cssSelector, m_CSSSelectors) { @@ -65,7 +65,7 @@ CSSInfo::CSSSelector *CSSInfo::getCSSSelectorForElementClass(const QString &elem { if (!className.isEmpty()) { // Find the selector(s) if any with this class name - QList< CSSInfo::CSSSelector * > class_selectors = getClassSelectors(className); + QList class_selectors = getClassSelectors(className); if (class_selectors.count() > 0) { // First look for match on element and class @@ -83,8 +83,7 @@ CSSInfo::CSSSelector *CSSInfo::getCSSSelectorForElementClass(const QString &elem } } } - } - else { + } else { // try match on element name alone foreach(CSSInfo::CSSSelector * cssSelector, m_CSSSelectors) { @@ -112,7 +111,7 @@ QStringList CSSInfo::getAllPropertyValues(QString property) last_selector_line = cssSelector->line; - QList< CSSInfo::CSSProperty * > properties = getCSSProperties(m_OriginalText, cssSelector->openingBracePos + 1, cssSelector->closingBracePos); + QList properties = getCSSProperties(m_OriginalText, cssSelector->openingBracePos + 1, cssSelector->closingBracePos); foreach (CSSInfo::CSSProperty *p, properties) { // If property is empty return properties of everything if (property.isEmpty() || p->name == property) { @@ -149,7 +148,7 @@ QString CSSInfo::getReformattedCSSText(bool multipleLineFormat) } // Now replace the contents inside the braces - QList< CSSInfo::CSSProperty * > new_properties = getCSSProperties(m_OriginalText, cssSelector->openingBracePos + 1, cssSelector->closingBracePos); + QList new_properties = getCSSProperties(m_OriginalText, cssSelector->openingBracePos + 1, cssSelector->closingBracePos); const QString &new_properties_text = formatCSSProperties(new_properties, multipleLineFormat, selector_indent); new_text.replace(cssSelector->openingBracePos + 1, cssSelector->closingBracePos - cssSelector->openingBracePos - 1, new_properties_text); // Reformat the selector text itself - whitespace only since incomplete parsing. @@ -269,7 +268,7 @@ QString CSSInfo::removeMatchingSelectors(QList cssSelectors) return new_text; } -QList< CSSInfo::CSSProperty * > CSSInfo::getCSSProperties(const QString &text, const int &styleTextStartPos, const int &styleTextEndPos) +QList CSSInfo::getCSSProperties(const QString &text, const int &styleTextStartPos, const int &styleTextEndPos) { QList new_properties; @@ -301,7 +300,7 @@ QList< CSSInfo::CSSProperty * > CSSInfo::getCSSProperties(const QString &text, c return new_properties; } -QString CSSInfo::formatCSSProperties(QList< CSSInfo::CSSProperty * > new_properties, bool multipleLineFormat, const int &selectorIndent) +QString CSSInfo::formatCSSProperties(QList new_properties, bool multipleLineFormat, const int &selectorIndent) { QString tab_spaces = QString(" ").repeated(TAB_SPACES_WIDTH + selectorIndent); diff --git a/src/Sigil/Misc/CSSInfo.h b/src/Sigil/Misc/CSSInfo.h index 3a7a3f2a62..03438aba78 100644 --- a/src/Sigil/Misc/CSSInfo.h +++ b/src/Sigil/Misc/CSSInfo.h @@ -65,7 +65,7 @@ class CSSInfo : public QObject /** * Return selectors subset for only class based CSS declarations. */ - QList< CSSSelector * > getClassSelectors(const QString filterClassName = ""); + QList getClassSelectors(const QString filterClassName = ""); /** * Search for a line position for a tag element name and an optional @@ -74,12 +74,12 @@ class CSSInfo : public QObject */ CSSSelector *getCSSSelectorForElementClass(const QString &elementName, const QString &className); - + /** * Return a list of all property values for the given property in the CSS. */ QStringList getAllPropertyValues(QString property); - + /** * Return the original text with a reformatted appearance either to * a multiple line style (each property on its own line) or single line style. @@ -94,15 +94,15 @@ class CSSInfo : public QObject */ QString removeMatchingSelectors(QList cssSelectors); - static QList< CSSProperty * > getCSSProperties(const QString &text, const int &styleTextStartPos, const int &styleTextEndPos); - static QString formatCSSProperties(QList< CSSProperty * > new_properties, bool multipleLineFormat, const int &selectorIndent = 0); + static QList getCSSProperties(const QString &text, const int &styleTextStartPos, const int &styleTextEndPos); + static QString formatCSSProperties(QList new_properties, bool multipleLineFormat, const int &selectorIndent = 0); private: bool findInlineStyleBlock(const QString &text, const int &offset, int &styleStart, int &styleEnd); void parseCSSSelectors(const QString &text, const int &offsetLines, const int &offsetPos); QString replaceBlockComments(const QString &text); - QList< CSSSelector * > m_CSSSelectors; + QList m_CSSSelectors; QString m_OriginalText; bool m_IsCSSFile; }; diff --git a/src/Sigil/Misc/HTMLEncodingResolver.cpp b/src/Sigil/Misc/HTMLEncodingResolver.cpp index d6744d8190..2e7e92a000 100644 --- a/src/Sigil/Misc/HTMLEncodingResolver.cpp +++ b/src/Sigil/Misc/HTMLEncodingResolver.cpp @@ -113,7 +113,7 @@ const QTextCodec *HTMLEncodingResolver::GetCodecForHTML(const QByteArray &raw_te return codec; } } - + // Check if the charset is set in the head. QRegularExpression char_re(CHARSET_ATTRIBUTE); QRegularExpressionMatch char_mo = char_re.match(text); diff --git a/src/Sigil/Misc/HTMLSpellCheck.cpp b/src/Sigil/Misc/HTMLSpellCheck.cpp index 8e70451ed6..0ef6f72b8c 100644 --- a/src/Sigil/Misc/HTMLSpellCheck.cpp +++ b/src/Sigil/Misc/HTMLSpellCheck.cpp @@ -32,7 +32,7 @@ const int MAX_WORD_LENGTH = 90; -QList< HTMLSpellCheck::MisspelledWord > HTMLSpellCheck::GetMisspelledWords(const QString &orig_text, +QList HTMLSpellCheck::GetMisspelledWords(const QString &orig_text, int start_offset, int end_offset, const QString &search_regex, @@ -45,7 +45,7 @@ QList< HTMLSpellCheck::MisspelledWord > HTMLSpellCheck::GetMisspelledWords(const bool in_entity = false; int word_start = 0; QRegularExpression search(search_regex); - QList< HTMLSpellCheck::MisspelledWord > misspellings; + QList misspellings; // Make sure text has beginning/end boundary markers for easier parsing QString text = QChar(' ') + orig_text + QChar(' '); // Ignore wherever it appears - change to spaces to keep text positions @@ -156,12 +156,12 @@ bool HTMLSpellCheck::IsBoundary(QChar prev_c, QChar c, QChar next_c) } -QList< HTMLSpellCheck::MisspelledWord > HTMLSpellCheck::GetMisspelledWords(const QString &text) +QList HTMLSpellCheck::GetMisspelledWords(const QString &text) { return GetMisspelledWords(text, 0, text.count(), ""); } -QList< HTMLSpellCheck::MisspelledWord > HTMLSpellCheck::GetWords(const QString &text) +QList HTMLSpellCheck::GetWords(const QString &text) { return GetMisspelledWords(text, 0, text.count(), "", false, true); } @@ -171,7 +171,7 @@ HTMLSpellCheck::MisspelledWord HTMLSpellCheck::GetFirstMisspelledWord(const QStr int end_offset, const QString &search_regex) { - QList< HTMLSpellCheck::MisspelledWord > misspelled_words = GetMisspelledWords(text, start_offset, end_offset, search_regex, true); + QList misspelled_words = GetMisspelledWords(text, start_offset, end_offset, search_regex, true); HTMLSpellCheck::MisspelledWord misspelled_word; if (!misspelled_words.isEmpty()) { @@ -187,7 +187,7 @@ HTMLSpellCheck::MisspelledWord HTMLSpellCheck::GetLastMisspelledWord(const QStri int end_offset, const QString &search_regex) { - QList< HTMLSpellCheck::MisspelledWord > misspelled_words = GetMisspelledWords(text, start_offset, end_offset, search_regex); + QList misspelled_words = GetMisspelledWords(text, start_offset, end_offset, search_regex); HTMLSpellCheck::MisspelledWord misspelled_word; if (!misspelled_words.isEmpty()) { @@ -222,7 +222,7 @@ int HTMLSpellCheck::CountAllWords(const QString &text) QStringList HTMLSpellCheck::GetAllWords(const QString &text) { - QList< HTMLSpellCheck::MisspelledWord > words = GetMisspelledWords(text, 0, text.count(), "", false, true); + QList words = GetMisspelledWords(text, 0, text.count(), "", false, true); QStringList all_words_text; foreach(HTMLSpellCheck::MisspelledWord word, words) { all_words_text.append(word.text); @@ -232,7 +232,7 @@ QStringList HTMLSpellCheck::GetAllWords(const QString &text) int HTMLSpellCheck::WordPosition(QString text, QString word, int start_pos) { - QList< HTMLSpellCheck::MisspelledWord > words = GetWords(text); + QList words = GetWords(text); foreach (HTMLSpellCheck::MisspelledWord w, words) { if (w.offset < start_pos) { diff --git a/src/Sigil/Misc/HTMLSpellCheck.h b/src/Sigil/Misc/HTMLSpellCheck.h index 9fb2144503..112dd1061f 100644 --- a/src/Sigil/Misc/HTMLSpellCheck.h +++ b/src/Sigil/Misc/HTMLSpellCheck.h @@ -36,16 +36,16 @@ class HTMLSpellCheck int length; }; - static QList< MisspelledWord > GetMisspelledWords(const QString &text, + static QList GetMisspelledWords(const QString &text, int start_offset, int end_offset, const QString &search_regex, bool first_only = false, bool include_all_words = false); - static QList< MisspelledWord > GetMisspelledWords(const QString &text); + static QList GetMisspelledWords(const QString &text); - static QList< HTMLSpellCheck::MisspelledWord > GetWords(const QString &text); + static QList GetWords(const QString &text); static int CountMisspelledWords(const QString &text, int start_offset, diff --git a/src/Sigil/Misc/Plugin.cpp b/src/Sigil/Misc/Plugin.cpp index f0d43b6000..f0855cf583 100644 --- a/src/Sigil/Misc/Plugin.cpp +++ b/src/Sigil/Misc/Plugin.cpp @@ -39,20 +39,27 @@ Plugin::Plugin() Plugin::Plugin(const QHash &info) { - if (info.contains("name")) + if (info.contains("name")) { set_name(info.value("name")); - if (info.contains("author")) + } + if (info.contains("author")) { set_author(info.value("author")); - if (info.contains("description")) + } + if (info.contains("description")) { set_description(info.value("description")); - if (info.contains("type")) + } + if (info.contains("type")) { set_type(info.value("type")); - if (info.contains("version")) + } + if (info.contains("version")) { set_version(info.value("version")); - if (info.contains("engine")) + } + if (info.contains("engine")) { set_engine(info.value("engine")); - if (info.contains("oslist")) + } + if (info.contains("oslist")) { set_engine(info.value("oslist")); + } } Plugin::~Plugin() diff --git a/src/Sigil/Misc/PluginDB.cpp b/src/Sigil/Misc/PluginDB.cpp index 7177829c1e..4648bdd768 100644 --- a/src/Sigil/Misc/PluginDB.cpp +++ b/src/Sigil/Misc/PluginDB.cpp @@ -75,7 +75,7 @@ QString PluginDB::launcherRoot() { QString launcher_root; - launcher_root = QCoreApplication::applicationDirPath(); + launcher_root = QCoreApplication::applicationDirPath(); #ifdef Q_OS_MAC launcher_root += "/../plugin_launchers/"; @@ -100,8 +100,9 @@ void PluginDB::load_plugins_from_disk(bool force) QStringList dplugins; Plugin *plugin; - if (!d.exists()) + if (!d.exists()) { return; + } dplugins = d.entryList(QStringList("*"), QDir::Dirs|QDir::NoDotAndDotDot); @@ -118,16 +119,19 @@ PluginDB::AddResult PluginDB::add_plugin(const QString &path, bool force) QFileInfo zipinfo(path); QString name = zipinfo.baseName(); - // strip off any versioning present in zip name after first "_" to get internal folder name + // strip off any versioning present in zip name after first "_" to get internal folder name int version_index = name.indexOf("_"); - if (version_index > -1) name.truncate(version_index); + if (version_index > -1) { + name.truncate(version_index); + } if (!verify_plugin_zip(path, name)) { return PluginDB::AR_INVALID; } - if (!Utility::UnZip(path, pluginsPath())) + if (!Utility::UnZip(path, pluginsPath())) { return PluginDB::AR_UNZIP; + } ret = add_plugin_int(name, force); if (ret != PluginDB::AR_SUCCESS) { @@ -144,15 +148,18 @@ PluginDB::AddResult PluginDB::add_plugin_int(const QString &name, bool force) { Plugin *plugin; - if (!force && m_plugins.contains(name)) + if (!force && m_plugins.contains(name)) { return PluginDB::AR_EXISTS; + } plugin = load_plugin(name); - if (plugin == NULL) + if (plugin == NULL) { return PluginDB::AR_XML; + } - if (force && m_plugins.contains(name)) + if (force && m_plugins.contains(name)) { delete m_plugins.take(plugin->get_name()); + } m_plugins.insert(plugin->get_name(), plugin); return PluginDB::AR_SUCCESS; @@ -162,27 +169,31 @@ PluginDB::AddResult PluginDB::add_plugin_int(const QString &name, bool force) bool PluginDB::verify_plugin_zip(const QString &path, const QString &name) { QStringList filelist = Utility::ZipInspect(path); - if (filelist.isEmpty()) + if (filelist.isEmpty()) { return false; + } foreach (QString filepath, filelist) { if (name != filepath.split("/").at(0)) { return false; } } - if (!filelist.contains(name + "/" + "plugin.xml")) + if (!filelist.contains(name + "/" + "plugin.xml")) { return false; + } return true; } void PluginDB::remove_plugin(const QString &name) { - if (!m_plugins.contains(name)) + if (!m_plugins.contains(name)) { return; + } Plugin *p = m_plugins.take(name); - if (p != NULL) + if (p != NULL) { delete p; + } Utility::removeDir(pluginsPath() + "/" + name); emit plugins_changed(); } @@ -237,8 +248,9 @@ Plugin *PluginDB::load_plugin(const QString &name) QString xmlpath = pluginsPath() + "/" + name + "/plugin.xml"; QFile file(xmlpath); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { return NULL; + } Plugin *plugin = new Plugin(); QXmlStreamReader reader(&file); diff --git a/src/Sigil/Misc/QCodePage437Codec.cpp b/src/Sigil/Misc/QCodePage437Codec.cpp index 1db878d1fd..584ff91eb2 100644 --- a/src/Sigil/Misc/QCodePage437Codec.cpp +++ b/src/Sigil/Misc/QCodePage437Codec.cpp @@ -22,8 +22,8 @@ static const char hexchars[] = "0123456789ABCDEF"; // Convert IBM437 character codes 0x00 - 0xFF into Unicode. -static ushort const cp437ToUnicode[256] = - {0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, +static ushort const cp437ToUnicode[256] = { + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001c, 0x001b, 0x007f, 0x001d, 0x001e, 0x001f, @@ -54,13 +54,14 @@ static ushort const cp437ToUnicode[256] = 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x03bc, 0x03c4, 0x03a6, 0x0398, 0x03a9, 0x03b4, 0x221e, 0x03c6, 0x03b5, 0x2229, 0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248, - 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0}; + 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0 +}; // Convert Unicode 0x0000 - 0x00FF into IBM437. -static unsigned char const cp437FromUnicode[256] = - {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, +static unsigned char const cp437FromUnicode[256] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x7f, 0x1b, 0x1a, 0x1d, 0x1e, 0x1f, @@ -91,7 +92,8 @@ static unsigned char const cp437FromUnicode[256] = 0x85, 0xa0, 0x83, '?' , 0x84, 0x86, 0x91, 0x87, 0x8a, 0x82, 0x88, 0x89, 0x8d, 0xa1, 0x8c, 0x8b, '?' , 0xa4, 0x95, 0xa2, 0x93, '?' , 0x94, 0xf6, - '?' , 0x97, 0xa3, 0x96, 0x81, '?' , '?' , 0x98}; + '?' , 0x97, 0xa3, 0x96, 0x81, '?' , '?' , 0x98 +}; QCodePage437Codec::QCodePage437Codec() { @@ -133,14 +135,15 @@ QString QCodePage437Codec::convertToUnicode(const char *in, int length, Converte length -= 6; while ( length-- > 0 ) { char ch = *in++; - if ( ch >= '0' && ch <= '9' ) + if ( ch >= '0' && ch <= '9' ) { digit = ch - '0'; - else if ( ch >= 'A' && ch <= 'F' ) + } else if ( ch >= 'A' && ch <= 'F' ) { digit = ch - 'A' + 10; - else if ( ch >= 'a' && ch <= 'f' ) + } else if ( ch >= 'a' && ch <= 'f' ) { digit = ch - 'a' + 10; - else + } else { continue; + } value = value * 16 + digit; ++nibble; if ( nibble >= 4 ) { @@ -153,8 +156,9 @@ QString QCodePage437Codec::convertToUnicode(const char *in, int length, Converte } else { // Regular 437-encoded string. - while ( length-- > 0 ) + while ( length-- > 0 ) { str += QChar((unsigned int)cp437ToUnicode[*in++ & 0xFF]); + } } return str; @@ -170,10 +174,11 @@ QByteArray QCodePage437Codec::convertFromUnicode(const QChar *in, int length, Co bool non437 = false; for ( int posn = 0; !non437 && posn < length; ++posn ) { ch = in[posn].unicode(); - if ( ch >= 0x0100 ) + if ( ch >= 0x0100 ) { non437 = true; - else if ( cp437FromUnicode[ch] == '?' && ch != '?' ) + } else if ( cp437FromUnicode[ch] == '?' && ch != '?' ) { non437 = true; + } } if ( non437 ) { // There is a non CP437 character in this string, so use UCS-2. diff --git a/src/Sigil/Misc/SearchOperations.cpp b/src/Sigil/Misc/SearchOperations.cpp index 6936bc5eea..1c4c14e534 100644 --- a/src/Sigil/Misc/SearchOperations.cpp +++ b/src/Sigil/Misc/SearchOperations.cpp @@ -45,7 +45,7 @@ using boost::tie; using boost::tuple; int SearchOperations::CountInFiles(const QString &search_regex, - QList< Resource * > resources, + QList resources, SearchType search_type, bool check_spelling) { @@ -66,7 +66,7 @@ int SearchOperations::CountInFiles(const QString &search_regex, int SearchOperations::ReplaceInAllFIles(const QString &search_regex, const QString &replacement, - QList< Resource * > resources, + QList resources, SearchType search_type) { QProgressDialog progress(QObject::tr("Replacing search term..."), 0, 0, resources.count(), Utility::GetMainWindow()); @@ -90,13 +90,13 @@ int SearchOperations::CountInFile(const QString &search_regex, bool check_spelling) { QReadLocker locker(&resource->GetLock()); - HTMLResource *html_resource = qobject_cast< HTMLResource * >(resource); + HTMLResource *html_resource = qobject_cast(resource); if (html_resource) { return CountInHTMLFile(search_regex, html_resource, search_type, check_spelling); } - TextResource *text_resource = qobject_cast< TextResource * >(resource); + TextResource *text_resource = qobject_cast(resource); if (text_resource) { return CountInTextFile(search_regex, text_resource); @@ -140,13 +140,13 @@ int SearchOperations::ReplaceInFile(const QString &search_regex, SearchType search_type) { QWriteLocker locker(&resource->GetLock()); - HTMLResource *html_resource = qobject_cast< HTMLResource * >(resource); + HTMLResource *html_resource = qobject_cast(resource); if (html_resource) { return ReplaceHTMLInFile(search_regex, replacement, html_resource, search_type); } - TextResource *text_resource = qobject_cast< TextResource * >(resource); + TextResource *text_resource = qobject_cast(resource); if (text_resource) { return ReplaceTextInFile(search_regex, replacement, text_resource); @@ -187,7 +187,7 @@ int SearchOperations::ReplaceTextInFile(const QString &search_regex, } -tuple< QString, int > SearchOperations::PerformGlobalReplace(const QString &text, +tuple SearchOperations::PerformGlobalReplace(const QString &text, const QString &search_regex, const QString &replacement) { @@ -210,7 +210,7 @@ tuple< QString, int > SearchOperations::PerformGlobalReplace(const QString &text } -tuple< QString, int > SearchOperations::PerformHTMLSpellCheckReplace(const QString &text, +tuple SearchOperations::PerformHTMLSpellCheckReplace(const QString &text, const QString &search_regex, const QString &replacement) { @@ -218,7 +218,7 @@ tuple< QString, int > SearchOperations::PerformHTMLSpellCheckReplace(const QStri int count = 0; int offset = 0; SPCRE *spcre = PCRECache::instance()->getObject(search_regex); - QList< HTMLSpellCheck::MisspelledWord > check_spelling = HTMLSpellCheck::GetMisspelledWords(text, 0, text.count(), search_regex); + QList check_spelling = HTMLSpellCheck::GetMisspelledWords(text, 0, text.count(), search_regex); foreach(HTMLSpellCheck::MisspelledWord misspelled_word, check_spelling) { SPCRE::MatchInfo match_info = spcre->getFirstMatchInfo(misspelled_word.text); diff --git a/src/Sigil/Misc/SearchOperations.h b/src/Sigil/Misc/SearchOperations.h index e60a8827b5..86b8a3dfc0 100644 --- a/src/Sigil/Misc/SearchOperations.h +++ b/src/Sigil/Misc/SearchOperations.h @@ -48,14 +48,14 @@ class SearchOperations * @return The number of matching occurrences. */ static int CountInFiles(const QString &search_regex, - QList< Resource * > resources, + QList resources, SearchType search_type, bool check_spelling = false); static int ReplaceInAllFIles(const QString &search_regex, const QString &replacement, - QList< Resource * > resources, + QList resources, SearchType search_type); private: @@ -89,11 +89,11 @@ class SearchOperations const QString &replacement, TextResource *text_resource); - static tuple< QString, int > PerformGlobalReplace(const QString &text, + static tuple PerformGlobalReplace(const QString &text, const QString &search_regex, const QString &replacement); - static tuple< QString, int > PerformHTMLSpellCheckReplace(const QString &text, + static tuple PerformHTMLSpellCheckReplace(const QString &text, const QString &search_regex, const QString &replacement); diff --git a/src/Sigil/Misc/SettingsStore.cpp b/src/Sigil/Misc/SettingsStore.cpp index 156d792570..a0b71ba5e2 100644 --- a/src/Sigil/Misc/SettingsStore.cpp +++ b/src/Sigil/Misc/SettingsStore.cpp @@ -188,15 +188,15 @@ int SettingsStore::cleanOn() return value(KEY_CLEAN_ON, (CLEANON_OPEN | CLEANON_SAVE)).toInt(); } -QList < std::pair < ushort, QString > > SettingsStore::preserveEntityCodeNames() +QList > SettingsStore::preserveEntityCodeNames() { clearSettingsGroup(); - QList < std::pair < ushort, QString > > codenames; + QList > codenames; QStringList names = value(KEY_PRESERVE_ENTITY_NAMES, " ").toStringList(); QString codes = value(KEY_PRESERVE_ENTITY_CODES, QChar(160)).toString(); int i = 0; foreach(QString name, names) { - std::pair < ushort, QString > epair; + std::pair epair; epair.first = (ushort) codes.at(i++).unicode(); epair.second = name; codenames.append(epair); @@ -354,12 +354,12 @@ void SettingsStore::setCleanOn(int on) setValue(KEY_CLEAN_ON, on); } -void SettingsStore::setPreserveEntityCodeNames(const QList< std::pair < ushort, QString > > codenames) +void SettingsStore::setPreserveEntityCodeNames(const QList> codenames) { clearSettingsGroup(); QStringList names; QString codes; - std::pair < ushort, QString > epair; + std::pair epair; foreach (epair, codenames) { names.append(epair.second); codes.append(QChar(epair.first)); diff --git a/src/Sigil/Misc/SettingsStore.h b/src/Sigil/Misc/SettingsStore.h index 905a9ed467..9a871585b5 100644 --- a/src/Sigil/Misc/SettingsStore.h +++ b/src/Sigil/Misc/SettingsStore.h @@ -93,7 +93,7 @@ class SettingsStore : public QSettings * Get the list of entities/code pairs to preserve */ - QList< std::pair < ushort, QString > > preserveEntityCodeNames(); + QList> preserveEntityCodeNames(); /** * Support for Plugins @@ -240,14 +240,14 @@ public slots: /** * Set the list of paired code, entity strings to preserve. */ - - void setPreserveEntityCodeNames(const QList< std::pair < ushort, QString > > codenames); + + void setPreserveEntityCodeNames(const QList> codenames); /** * Support for Plugins */ - + void setPluginEnginePaths(const QHash &enginepaths); /** diff --git a/src/Sigil/Misc/SpellCheck.cpp b/src/Sigil/Misc/SpellCheck.cpp index 1df6c40cff..f782f76f53 100644 --- a/src/Sigil/Misc/SpellCheck.cpp +++ b/src/Sigil/Misc/SpellCheck.cpp @@ -162,7 +162,7 @@ void SpellCheck::ignoreWordInDictionary(const QString &word) if (!m_hunspell) { return; } - + m_hunspell->add(m_codec->fromUnicode(Utility::getSpellingSafeText(word)).constData()); } diff --git a/src/Sigil/Misc/Utility.cpp b/src/Sigil/Misc/Utility.cpp index dbe213c9b5..bb555409f3 100644 --- a/src/Sigil/Misc/Utility.cpp +++ b/src/Sigil/Misc/Utility.cpp @@ -59,7 +59,7 @@ // This is the same read buffer size used by Java and Perl. #define BUFF_SIZE 8192 -static QCodePage437Codec *cp437 = 0; +static QCodePage437Codec *cp437 = 0; #include "Misc/Utility.h" @@ -233,32 +233,31 @@ void Utility::CopyFiles(const QString &fullfolderpath_source, const QString &ful // // Delete a directory along with all of its contents. -// +// // \param dirName Path of directory to remove. // \return true on success; false on error. // bool Utility::removeDir(const QString &dirName) { - bool result = true; - QDir dir(dirName); - - if (dir.exists(dirName)) { - Q_FOREACH(QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) { - if (info.isDir()) { - result = removeDir(info.absoluteFilePath()); - } - else { - result = QFile::remove(info.absoluteFilePath()); - } - - if (!result) { - return result; - } + bool result = true; + QDir dir(dirName); + + if (dir.exists(dirName)) { + Q_FOREACH(QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) { + if (info.isDir()) { + result = removeDir(info.absoluteFilePath()); + } else { + result = QFile::remove(info.absoluteFilePath()); + } + + if (!result) { + return result; + } + } + result = dir.rmdir(dirName); } - result = dir.rmdir(dirName); - } - - return result; + + return result; } @@ -278,8 +277,8 @@ bool Utility::SDeleteFile(const QString &fullfilepath) // Copies File from full Inpath to full OutPath with overwrite if needed -bool Utility::ForceCopyFile(const QString &fullinpath, const QString& fulloutpath) -{ +bool Utility::ForceCopyFile(const QString &fullinpath, const QString &fulloutpath) +{ if (!QFileInfo(fullinpath).exists()) { return false; } @@ -573,13 +572,13 @@ bool Utility::use_filename_warning(const QString &filename) { if (has_non_ascii_chars(filename)) { return QMessageBox::Apply == QMessageBox::warning(QApplication::activeWindow(), - tr("Sigil"), - tr("The requested file name contains non-ASCII characters. " - "You should only use ASCII characters in filenames. " - "Using non-ASCII characters can prevent the EPUB from working " - "with some readers.\n\n" - "Continue using the requested filename?"), - QMessageBox::Cancel|QMessageBox::Apply); + tr("Sigil"), + tr("The requested file name contains non-ASCII characters. " + "You should only use ASCII characters in filenames. " + "Using non-ASCII characters can prevent the EPUB from working " + "with some readers.\n\n" + "Continue using the requested filename?"), + QMessageBox::Cancel|QMessageBox::Apply); } return true; } @@ -597,7 +596,7 @@ QString Utility::stdWStringToQString(const std::wstring &str) #endif -bool Utility::UnZip(const QString & zippath, const QString & destpath) +bool Utility::UnZip(const QString &zippath, const QString &destpath) { int res = 0; QDir dir(destpath); @@ -706,7 +705,7 @@ bool Utility::UnZip(const QString & zippath, const QString & destpath) return true; } -QStringList Utility::ZipInspect(const QString & zippath) +QStringList Utility::ZipInspect(const QString &zippath) { QStringList filelist; int res = 0; diff --git a/src/Sigil/Misc/Utility.h b/src/Sigil/Misc/Utility.h index ad01f3976a..7307de2547 100644 --- a/src/Sigil/Misc/Utility.h +++ b/src/Sigil/Misc/Utility.h @@ -77,12 +77,12 @@ class Utility static void CopyFiles(const QString &fullfolderpath_source, const QString &fullfolderpath_destination); // Johns own recursive directory removal code - static bool removeDir(const QString & dirName); + static bool removeDir(const QString &dirName); // Deletes the specified file if it exists static bool SDeleteFile(const QString &fullfilepath); - static bool ForceCopyFile(const QString &fullinpath, const QString& fulloutpath); + static bool ForceCopyFile(const QString &fullinpath, const QString &fulloutpath); static bool RenameFile(const QString &oldfilepath, const QString &newfilepath); @@ -159,8 +159,8 @@ class Utility static QString stdWStringToQString(const std::wstring &str); #endif - static bool UnZip(const QString & zippath, const QString & destdir); - static QStringList ZipInspect(const QString & zippath); + static bool UnZip(const QString &zippath, const QString &destdir); + static QStringList ZipInspect(const QString &zippath); }; #endif // UTILITY_H diff --git a/src/Sigil/Misc/XHTMLHighlighter.cpp b/src/Sigil/Misc/XHTMLHighlighter.cpp index 067fe6cbd3..d50666ed06 100644 --- a/src/Sigil/Misc/XHTMLHighlighter.cpp +++ b/src/Sigil/Misc/XHTMLHighlighter.cpp @@ -425,7 +425,7 @@ void XHTMLHighlighter::CheckSpelling(const QString &text) // at some zoom levels and often doesn't display at all. So we're using wave // underline since it's good enough for most people. format.setUnderlineStyle(QTextCharFormat::WaveUnderline); - QList< HTMLSpellCheck::MisspelledWord > misspelled_words = HTMLSpellCheck::GetMisspelledWords(text); + QList misspelled_words = HTMLSpellCheck::GetMisspelledWords(text); foreach(HTMLSpellCheck::MisspelledWord misspelled_word, misspelled_words) { setFormat(misspelled_word.offset, misspelled_word.length, format); } diff --git a/src/Sigil/Misc/XMLEntities.cpp b/src/Sigil/Misc/XMLEntities.cpp index 28cbbb19fb..6c02f96673 100644 --- a/src/Sigil/Misc/XMLEntities.cpp +++ b/src/Sigil/Misc/XMLEntities.cpp @@ -69,7 +69,9 @@ ushort XMLEntities::GetEntityCode(const QString name) root = root.mid(1); } int rcode = root.toUShort(&ok, base); - if (ok) code = rcode; + if (ok) { + code = rcode; + } } else { if (m_EntityCode.contains(root)) { code = m_EntityCode.value(root, 0); @@ -92,259 +94,259 @@ void XMLEntities::SetXMLEntities() QStringList data; data << - "34" << "quot" << tr("quotation mark") << - "38" << "amp" << tr("ampersand") << - "39" << "apos" << tr("apostrophe") << - "60" << "lt" << tr("less-than sign") << - "62" << "gt" << tr("greater-than sign") << - "160" << "nbsp" << tr("no-break space") << - "161" << "iexcl" << tr("inverted exclamation mark") << - "162" << "cent" << tr("cent sign") << - "163" << "pound" << tr("pound sign") << - "164" << "curren" << tr("currency sign") << - "165" << "yen" << tr("yen sign") << - "166" << "brvbar" << tr("broken bar") << - "167" << "sect" << tr("section sign") << - "168" << "uml" << tr("diaeresis") << - "169" << "copy" << tr("copyright symbol") << - "170" << "ordf" << tr("feminine ordinal indicator") << - "171" << "laquo" << tr("left-pointing double angle quotation mark") << - "172" << "not" << tr("not sign") << - "173" << "shy" << tr("soft hyphen") << - "174" << "reg" << tr("registered sign") << - "175" << "macr" << tr("macron") << - "176" << "deg" << tr("degree symbol") << - "177" << "plusmn" << tr("plus-minus sign") << - "178" << "sup2" << tr("superscript two") << - "179" << "sup3" << tr("superscript three") << - "180" << "acute" << tr("acute accent") << - "181" << "micro" << tr("micro sign") << - "182" << "para" << tr("pilcrow sign") << - "183" << "middot" << tr("middle dot") << - "184" << "cedil" << tr("cedilla") << - "185" << "sup1" << tr("superscript one") << - "186" << "ordm" << tr("masculine ordinal indicator") << - "187" << "raquo" << tr("right-pointing double angle quotation mark") << - "188" << "frac14" << tr("vulgar fraction one quarter") << - "189" << "frac12" << tr("vulgar fraction one half") << - "190" << "frac34" << tr("vulgar fraction three quarters") << - "191" << "iquest" << tr("inverted question mark") << - "192" << "Agrave" << tr("Latin capital letter A with grave accent") << - "193" << "Aacute" << tr("Latin capital letter A with acute accent") << - "194" << "Acirc" << tr("Latin capital letter A with circumflex") << - "195" << "Atilde" << tr("Latin capital letter A with tilde") << - "196" << "Auml" << tr("Latin capital letter A with diaeresis") << - "197" << "Aring" << tr("Latin capital letter A with ring above") << - "198" << "AElig" << tr("Latin capital letter AE") << - "199" << "Ccedil" << tr("Latin capital letter C with cedilla") << - "200" << "Egrave" << tr("Latin capital letter E with grave accent") << - "201" << "Eacute" << tr("Latin capital letter E with acute accent") << - "202" << "Ecirc" << tr("Latin capital letter E with circumflex") << - "203" << "Euml" << tr("Latin capital letter E with diaeresis") << - "204" << "Igrave" << tr("Latin capital letter I with grave accent") << - "205" << "Iacute" << tr("Latin capital letter I with acute accent") << - "206" << "Icirc" << tr("Latin capital letter I with circumflex") << - "207" << "Iuml" << tr("Latin capital letter I with diaeresis") << - "208" << "ETH" << tr("Latin capital letter Eth") << - "209" << "Ntilde" << tr("Latin capital letter N with tilde") << - "210" << "Ograve" << tr("Latin capital letter O with grave accent") << - "211" << "Oacute" << tr("Latin capital letter O with acute accent") << - "212" << "Ocirc" << tr("Latin capital letter O with circumflex") << - "213" << "Otilde" << tr("Latin capital letter O with tilde") << - "214" << "Ouml" << tr("Latin capital letter O with diaeresis") << - "215" << "times" << tr("multiplication sign") << - "216" << "Oslash" << tr("Latin capital letter O with stroke") << - "217" << "Ugrave" << tr("Latin capital letter U with grave accent") << - "218" << "Uacute" << tr("Latin capital letter U with acute accent") << - "219" << "Ucirc" << tr("Latin capital letter U with circumflex") << - "220" << "Uuml" << tr("Latin capital letter U with diaeresis") << - "221" << "Yacute" << tr("Latin capital letter Y with acute accent") << - "222" << "THORN" << tr("Latin capital letter THORN") << - "223" << "szlig" << tr("Latin small letter sharp s") << - "224" << "agrave" << tr("Latin small letter a with grave accent") << - "225" << "aacute" << tr("Latin small letter a with acute accent") << - "226" << "acirc" << tr("Latin small letter a with circumflex") << - "227" << "atilde" << tr("Latin small letter a with tilde") << - "228" << "auml" << tr("Latin small letter a with diaeresis") << - "229" << "aring" << tr("Latin small letter a with ring above") << - "230" << "aelig" << tr("Latin small letter ae") << - "231" << "ccedil" << tr("Latin small letter c with cedilla") << - "232" << "egrave" << tr("Latin small letter e with grave accent") << - "233" << "eacute" << tr("Latin small letter e with acute accent") << - "234" << "ecirc" << tr("Latin small letter e with circumflex") << - "235" << "euml" << tr("Latin small letter e with diaeresis") << - "236" << "igrave" << tr("Latin small letter i with grave accent") << - "237" << "iacute" << tr("Latin small letter i with acute accent") << - "238" << "icirc" << tr("Latin small letter i with circumflex") << - "239" << "iuml" << tr("Latin small letter i with diaeresis") << - "240" << "eth" << tr("Latin small letter eth") << - "241" << "ntilde" << tr("Latin small letter n with tilde") << - "242" << "ograve" << tr("Latin small letter o with grave accent") << - "243" << "oacute" << tr("Latin small letter o with acute accent") << - "244" << "ocirc" << tr("Latin small letter o with circumflex") << - "245" << "otilde" << tr("Latin small letter o with tilde") << - "246" << "ouml" << tr("Latin small letter o with diaeresis") << - "247" << "divide" << tr("division sign") << - "248" << "oslash" << tr("Latin small letter o with stroke") << - "249" << "ugrave" << tr("Latin small letter u with grave accent") << - "250" << "uacute" << tr("Latin small letter u with acute accent") << - "251" << "ucirc" << tr("Latin small letter u with circumflex") << - "252" << "uuml" << tr("Latin small letter u with diaeresis") << - "253" << "yacute" << tr("Latin small letter y with acute accent") << - "254" << "thorn" << tr("Latin small letter thorn") << - "255" << "yuml" << tr("Latin small letter y with diaeresis") << - "338" << "OElig" << tr("Latin capital ligature oe") << - "339" << "oelig" << tr("Latin small ligature oe") << - "352" << "Scaron" << tr("Latin capital letter s with caron") << - "353" << "scaron" << tr("Latin small letter s with caron") << - "376" << "Yuml" << tr("Latin capital letter y with diaeresis") << - "402" << "fnof" << tr("Latin small letter f with hook") << - "710" << "circ" << tr("modifier letter circumflex accent") << - "732" << "tilde" << tr("small tilde") << - "913" << "Alpha" << tr("Greek capital letter Alpha") << - "914" << "Beta" << tr("Greek capital letter Beta") << - "915" << "Gamma" << tr("Greek capital letter Gamma") << - "916" << "Delta" << tr("Greek capital letter Delta") << - "917" << "Epsilon" << tr("Greek capital letter Epsilon") << - "918" << "Zeta" << tr("Greek capital letter Zeta") << - "919" << "Eta" << tr("Greek capital letter Eta") << - "920" << "Theta" << tr("Greek capital letter Theta") << - "921" << "Iota" << tr("Greek capital letter Iota") << - "922" << "Kappa" << tr("Greek capital letter Kappa") << - "923" << "Lambda" << tr("Greek capital letter Lambda") << - "924" << "Mu" << tr("Greek capital letter Mu") << - "925" << "Nu" << tr("Greek capital letter Nu") << - "926" << "Xi" << tr("Greek capital letter Xi") << - "927" << "Omicron" << tr("Greek capital letter Omicron") << - "928" << "Pi" << tr("Greek capital letter Pi") << - "929" << "Rho" << tr("Greek capital letter Rho") << - "931" << "Sigma" << tr("Greek capital letter Sigma") << - "932" << "Tau" << tr("Greek capital letter Tau") << - "933" << "Upsilon" << tr("Greek capital letter Upsilon") << - "934" << "Phi" << tr("Greek capital letter Phi") << - "935" << "Chi" << tr("Greek capital letter Chi") << - "936" << "Psi" << tr("Greek capital letter Psi") << - "937" << "Omega" << tr("Greek capital letter Omega") << - "945" << "alpha" << tr("Greek small letter alpha") << - "946" << "beta" << tr("Greek small letter beta") << - "947" << "gamma" << tr("Greek small letter gamma") << - "948" << "delta" << tr("Greek small letter delta") << - "949" << "epsilon" << tr("Greek small letter epsilon") << - "950" << "zeta" << tr("Greek small letter zeta") << - "951" << "eta" << tr("Greek small letter eta") << - "952" << "theta" << tr("Greek small letter theta") << - "953" << "iota" << tr("Greek small letter iota") << - "954" << "kappa" << tr("Greek small letter kappa") << - "955" << "lambda" << tr("Greek small letter lambda") << - "956" << "mu" << tr("Greek small letter mu") << - "957" << "nu" << tr("Greek small letter nu") << - "958" << "xi" << tr("Greek small letter xi") << - "959" << "omicron" << tr("Greek small letter omicron") << - "960" << "pi" << tr("Greek small letter pi") << - "961" << "rho" << tr("Greek small letter rho") << - "962" << "sigmaf" << tr("Greek small letter final sigma") << - "963" << "sigma" << tr("Greek small letter sigma") << - "964" << "tau" << tr("Greek small letter tau") << - "965" << "upsilon" << tr("Greek small letter upsilon") << - "966" << "phi" << tr("Greek small letter phi") << - "967" << "chi" << tr("Greek small letter chi") << - "968" << "psi" << tr("Greek small letter psi") << - "969" << "omega" << tr("Greek small letter omega") << - "977" << "thetasym" << tr("Greek theta symbol") << - "978" << "upsih" << tr("Greek Upsilon with hook symbol") << - "982" << "piv" << tr("Greek pi symbol") << - "8194" << "ensp" << tr("en space") << - "8195" << "emsp" << tr("em space") << - "8201" << "thinsp" << tr("thin space") << - "8204" << "zwnj" << tr("zero-width non-joiner") << - "8205" << "zwj" << tr("zero-width joiner") << - "8206" << "lrm" << tr("left-to-right mark") << - "8207" << "rlm" << tr("right-to-left mark") << - "8211" << "ndash" << tr("en dash") << - "8212" << "mdash" << tr("em dash") << - "8216" << "lsquo" << tr("left single quotation mark") << - "8217" << "rsquo" << tr("right single quotation mark") << - "8218" << "sbquo" << tr("single low-9 quotation mark") << - "8220" << "ldquo" << tr("left double quotation mark") << - "8221" << "rdquo" << tr("right double quotation mark") << - "8222" << "bdquo" << tr("double low-9 quotation mark") << - "8224" << "dagger" << tr("dagger, obelisk") << - "8225" << "Dagger" << tr("double dagger, double obelisk") << - "8226" << "bull" << tr("bullet") << - "8230" << "hellip" << tr("horizontal ellipsis") << - "8240" << "permil" << tr("per mille sign") << - "8242" << "prime" << tr("prime") << - "8243" << "Prime" << tr("double prime") << - "8249" << "lsaquo" << tr("single left-pointing angle quotation mark") << - "8250" << "rsaquo" << tr("single right-pointing angle quotation mark") << - "8254" << "oline" << tr("overline") << - "8260" << "frasl" << tr("fraction slash") << - "8364" << "euro" << tr("euro sign") << - "8465" << "image" << tr("black-letter capital I") << - "8472" << "weierp" << tr("script capital P") << - "8476" << "real" << tr("black-letter capital R") << - "8482" << "trade" << tr("trademark symbol") << - "8501" << "alefsym" << tr("alef symbol") << - "8592" << "larr" << tr("leftwards arrow") << - "8593" << "uarr" << tr("upwards arrow") << - "8594" << "rarr" << tr("rightwards arrow") << - "8595" << "darr" << tr("downwards arrow") << - "8596" << "harr" << tr("left right arrow") << - "8629" << "crarr" << tr("downwards arrow with corner leftwards") << - "8656" << "lArr" << tr("leftwards double arrow") << - "8657" << "uArr" << tr("upwards double arrow") << - "8658" << "rArr" << tr("rightwards double arrow") << - "8659" << "dArr" << tr("downwards double arrow") << - "8660" << "hArr" << tr("left right double arrow") << - "8704" << "forall" << tr("for all") << - "8706" << "part" << tr("partial differential") << - "8707" << "exist" << tr("there exists") << - "8709" << "empty" << tr("empty set") << - "8711" << "nabla" << tr("nabla") << - "8712" << "isin" << tr("element of") << - "8713" << "notin" << tr("not an element of") << - "8715" << "ni" << tr("contains as member") << - "8719" << "prod" << tr("n-ary product") << - "8721" << "sum" << tr("n-ary summation") << - "8722" << "minus" << tr("minus sign") << - "8727" << "lowast" << tr("asterisk operator") << - "8730" << "radic" << tr("square root") << - "8733" << "prop" << tr("proportional to") << - "8734" << "infin" << tr("infinity") << - "8736" << "ang" << tr("angle") << - "8743" << "and" << tr("logical and") << - "8744" << "or" << tr("logical or") << - "8745" << "cap" << tr("intersection") << - "8746" << "cup" << tr("union") << - "8747" << "int" << tr("integral") << - "8756" << "there4" << tr("therefore sign") << - "8764" << "sim" << tr("tilde operator") << - "8773" << "cong" << tr("congruent to") << - "8776" << "asymp" << tr("almost equal to") << - "8800" << "ne" << tr("not equal to") << - "8801" << "equiv" << tr("identical to") << - "8804" << "le" << tr("less-than or equal to") << - "8805" << "ge" << tr("greater-than or equal to") << - "8834" << "sub" << tr("subset of") << - "8835" << "sup" << tr("superset of") << - "8836" << "nsub" << tr("not a subset of") << - "8838" << "sube" << tr("subset of or equal to") << - "8839" << "supe" << tr("superset of or equal to") << - "8853" << "oplus" << tr("circled plus") << - "8855" << "otimes" << tr("circled times") << - "8869" << "perp" << tr("up tack") << - "8901" << "sdot" << tr("dot operator") << - "8968" << "lceil" << tr("left ceiling") << - "8969" << "rceil" << tr("right ceiling") << - "8970" << "lfloor" << tr("left floor") << - "8971" << "rfloor" << tr("right floor") << - "9001" << "lang" << tr("left-pointing angle bracket") << - "9002" << "rang" << tr("right-pointing angle bracket") << - "9674" << "loz" << tr("lozenge") << - "9824" << "spades" << tr("black spade suit") << - "9827" << "clubs" << tr("black club suit") << - "9829" << "hearts" << tr("black heart suit") << - "9830" << "diams" << tr("black diamond suit"); + "34" << "quot" << tr("quotation mark") << + "38" << "amp" << tr("ampersand") << + "39" << "apos" << tr("apostrophe") << + "60" << "lt" << tr("less-than sign") << + "62" << "gt" << tr("greater-than sign") << + "160" << "nbsp" << tr("no-break space") << + "161" << "iexcl" << tr("inverted exclamation mark") << + "162" << "cent" << tr("cent sign") << + "163" << "pound" << tr("pound sign") << + "164" << "curren" << tr("currency sign") << + "165" << "yen" << tr("yen sign") << + "166" << "brvbar" << tr("broken bar") << + "167" << "sect" << tr("section sign") << + "168" << "uml" << tr("diaeresis") << + "169" << "copy" << tr("copyright symbol") << + "170" << "ordf" << tr("feminine ordinal indicator") << + "171" << "laquo" << tr("left-pointing double angle quotation mark") << + "172" << "not" << tr("not sign") << + "173" << "shy" << tr("soft hyphen") << + "174" << "reg" << tr("registered sign") << + "175" << "macr" << tr("macron") << + "176" << "deg" << tr("degree symbol") << + "177" << "plusmn" << tr("plus-minus sign") << + "178" << "sup2" << tr("superscript two") << + "179" << "sup3" << tr("superscript three") << + "180" << "acute" << tr("acute accent") << + "181" << "micro" << tr("micro sign") << + "182" << "para" << tr("pilcrow sign") << + "183" << "middot" << tr("middle dot") << + "184" << "cedil" << tr("cedilla") << + "185" << "sup1" << tr("superscript one") << + "186" << "ordm" << tr("masculine ordinal indicator") << + "187" << "raquo" << tr("right-pointing double angle quotation mark") << + "188" << "frac14" << tr("vulgar fraction one quarter") << + "189" << "frac12" << tr("vulgar fraction one half") << + "190" << "frac34" << tr("vulgar fraction three quarters") << + "191" << "iquest" << tr("inverted question mark") << + "192" << "Agrave" << tr("Latin capital letter A with grave accent") << + "193" << "Aacute" << tr("Latin capital letter A with acute accent") << + "194" << "Acirc" << tr("Latin capital letter A with circumflex") << + "195" << "Atilde" << tr("Latin capital letter A with tilde") << + "196" << "Auml" << tr("Latin capital letter A with diaeresis") << + "197" << "Aring" << tr("Latin capital letter A with ring above") << + "198" << "AElig" << tr("Latin capital letter AE") << + "199" << "Ccedil" << tr("Latin capital letter C with cedilla") << + "200" << "Egrave" << tr("Latin capital letter E with grave accent") << + "201" << "Eacute" << tr("Latin capital letter E with acute accent") << + "202" << "Ecirc" << tr("Latin capital letter E with circumflex") << + "203" << "Euml" << tr("Latin capital letter E with diaeresis") << + "204" << "Igrave" << tr("Latin capital letter I with grave accent") << + "205" << "Iacute" << tr("Latin capital letter I with acute accent") << + "206" << "Icirc" << tr("Latin capital letter I with circumflex") << + "207" << "Iuml" << tr("Latin capital letter I with diaeresis") << + "208" << "ETH" << tr("Latin capital letter Eth") << + "209" << "Ntilde" << tr("Latin capital letter N with tilde") << + "210" << "Ograve" << tr("Latin capital letter O with grave accent") << + "211" << "Oacute" << tr("Latin capital letter O with acute accent") << + "212" << "Ocirc" << tr("Latin capital letter O with circumflex") << + "213" << "Otilde" << tr("Latin capital letter O with tilde") << + "214" << "Ouml" << tr("Latin capital letter O with diaeresis") << + "215" << "times" << tr("multiplication sign") << + "216" << "Oslash" << tr("Latin capital letter O with stroke") << + "217" << "Ugrave" << tr("Latin capital letter U with grave accent") << + "218" << "Uacute" << tr("Latin capital letter U with acute accent") << + "219" << "Ucirc" << tr("Latin capital letter U with circumflex") << + "220" << "Uuml" << tr("Latin capital letter U with diaeresis") << + "221" << "Yacute" << tr("Latin capital letter Y with acute accent") << + "222" << "THORN" << tr("Latin capital letter THORN") << + "223" << "szlig" << tr("Latin small letter sharp s") << + "224" << "agrave" << tr("Latin small letter a with grave accent") << + "225" << "aacute" << tr("Latin small letter a with acute accent") << + "226" << "acirc" << tr("Latin small letter a with circumflex") << + "227" << "atilde" << tr("Latin small letter a with tilde") << + "228" << "auml" << tr("Latin small letter a with diaeresis") << + "229" << "aring" << tr("Latin small letter a with ring above") << + "230" << "aelig" << tr("Latin small letter ae") << + "231" << "ccedil" << tr("Latin small letter c with cedilla") << + "232" << "egrave" << tr("Latin small letter e with grave accent") << + "233" << "eacute" << tr("Latin small letter e with acute accent") << + "234" << "ecirc" << tr("Latin small letter e with circumflex") << + "235" << "euml" << tr("Latin small letter e with diaeresis") << + "236" << "igrave" << tr("Latin small letter i with grave accent") << + "237" << "iacute" << tr("Latin small letter i with acute accent") << + "238" << "icirc" << tr("Latin small letter i with circumflex") << + "239" << "iuml" << tr("Latin small letter i with diaeresis") << + "240" << "eth" << tr("Latin small letter eth") << + "241" << "ntilde" << tr("Latin small letter n with tilde") << + "242" << "ograve" << tr("Latin small letter o with grave accent") << + "243" << "oacute" << tr("Latin small letter o with acute accent") << + "244" << "ocirc" << tr("Latin small letter o with circumflex") << + "245" << "otilde" << tr("Latin small letter o with tilde") << + "246" << "ouml" << tr("Latin small letter o with diaeresis") << + "247" << "divide" << tr("division sign") << + "248" << "oslash" << tr("Latin small letter o with stroke") << + "249" << "ugrave" << tr("Latin small letter u with grave accent") << + "250" << "uacute" << tr("Latin small letter u with acute accent") << + "251" << "ucirc" << tr("Latin small letter u with circumflex") << + "252" << "uuml" << tr("Latin small letter u with diaeresis") << + "253" << "yacute" << tr("Latin small letter y with acute accent") << + "254" << "thorn" << tr("Latin small letter thorn") << + "255" << "yuml" << tr("Latin small letter y with diaeresis") << + "338" << "OElig" << tr("Latin capital ligature oe") << + "339" << "oelig" << tr("Latin small ligature oe") << + "352" << "Scaron" << tr("Latin capital letter s with caron") << + "353" << "scaron" << tr("Latin small letter s with caron") << + "376" << "Yuml" << tr("Latin capital letter y with diaeresis") << + "402" << "fnof" << tr("Latin small letter f with hook") << + "710" << "circ" << tr("modifier letter circumflex accent") << + "732" << "tilde" << tr("small tilde") << + "913" << "Alpha" << tr("Greek capital letter Alpha") << + "914" << "Beta" << tr("Greek capital letter Beta") << + "915" << "Gamma" << tr("Greek capital letter Gamma") << + "916" << "Delta" << tr("Greek capital letter Delta") << + "917" << "Epsilon" << tr("Greek capital letter Epsilon") << + "918" << "Zeta" << tr("Greek capital letter Zeta") << + "919" << "Eta" << tr("Greek capital letter Eta") << + "920" << "Theta" << tr("Greek capital letter Theta") << + "921" << "Iota" << tr("Greek capital letter Iota") << + "922" << "Kappa" << tr("Greek capital letter Kappa") << + "923" << "Lambda" << tr("Greek capital letter Lambda") << + "924" << "Mu" << tr("Greek capital letter Mu") << + "925" << "Nu" << tr("Greek capital letter Nu") << + "926" << "Xi" << tr("Greek capital letter Xi") << + "927" << "Omicron" << tr("Greek capital letter Omicron") << + "928" << "Pi" << tr("Greek capital letter Pi") << + "929" << "Rho" << tr("Greek capital letter Rho") << + "931" << "Sigma" << tr("Greek capital letter Sigma") << + "932" << "Tau" << tr("Greek capital letter Tau") << + "933" << "Upsilon" << tr("Greek capital letter Upsilon") << + "934" << "Phi" << tr("Greek capital letter Phi") << + "935" << "Chi" << tr("Greek capital letter Chi") << + "936" << "Psi" << tr("Greek capital letter Psi") << + "937" << "Omega" << tr("Greek capital letter Omega") << + "945" << "alpha" << tr("Greek small letter alpha") << + "946" << "beta" << tr("Greek small letter beta") << + "947" << "gamma" << tr("Greek small letter gamma") << + "948" << "delta" << tr("Greek small letter delta") << + "949" << "epsilon" << tr("Greek small letter epsilon") << + "950" << "zeta" << tr("Greek small letter zeta") << + "951" << "eta" << tr("Greek small letter eta") << + "952" << "theta" << tr("Greek small letter theta") << + "953" << "iota" << tr("Greek small letter iota") << + "954" << "kappa" << tr("Greek small letter kappa") << + "955" << "lambda" << tr("Greek small letter lambda") << + "956" << "mu" << tr("Greek small letter mu") << + "957" << "nu" << tr("Greek small letter nu") << + "958" << "xi" << tr("Greek small letter xi") << + "959" << "omicron" << tr("Greek small letter omicron") << + "960" << "pi" << tr("Greek small letter pi") << + "961" << "rho" << tr("Greek small letter rho") << + "962" << "sigmaf" << tr("Greek small letter final sigma") << + "963" << "sigma" << tr("Greek small letter sigma") << + "964" << "tau" << tr("Greek small letter tau") << + "965" << "upsilon" << tr("Greek small letter upsilon") << + "966" << "phi" << tr("Greek small letter phi") << + "967" << "chi" << tr("Greek small letter chi") << + "968" << "psi" << tr("Greek small letter psi") << + "969" << "omega" << tr("Greek small letter omega") << + "977" << "thetasym" << tr("Greek theta symbol") << + "978" << "upsih" << tr("Greek Upsilon with hook symbol") << + "982" << "piv" << tr("Greek pi symbol") << + "8194" << "ensp" << tr("en space") << + "8195" << "emsp" << tr("em space") << + "8201" << "thinsp" << tr("thin space") << + "8204" << "zwnj" << tr("zero-width non-joiner") << + "8205" << "zwj" << tr("zero-width joiner") << + "8206" << "lrm" << tr("left-to-right mark") << + "8207" << "rlm" << tr("right-to-left mark") << + "8211" << "ndash" << tr("en dash") << + "8212" << "mdash" << tr("em dash") << + "8216" << "lsquo" << tr("left single quotation mark") << + "8217" << "rsquo" << tr("right single quotation mark") << + "8218" << "sbquo" << tr("single low-9 quotation mark") << + "8220" << "ldquo" << tr("left double quotation mark") << + "8221" << "rdquo" << tr("right double quotation mark") << + "8222" << "bdquo" << tr("double low-9 quotation mark") << + "8224" << "dagger" << tr("dagger, obelisk") << + "8225" << "Dagger" << tr("double dagger, double obelisk") << + "8226" << "bull" << tr("bullet") << + "8230" << "hellip" << tr("horizontal ellipsis") << + "8240" << "permil" << tr("per mille sign") << + "8242" << "prime" << tr("prime") << + "8243" << "Prime" << tr("double prime") << + "8249" << "lsaquo" << tr("single left-pointing angle quotation mark") << + "8250" << "rsaquo" << tr("single right-pointing angle quotation mark") << + "8254" << "oline" << tr("overline") << + "8260" << "frasl" << tr("fraction slash") << + "8364" << "euro" << tr("euro sign") << + "8465" << "image" << tr("black-letter capital I") << + "8472" << "weierp" << tr("script capital P") << + "8476" << "real" << tr("black-letter capital R") << + "8482" << "trade" << tr("trademark symbol") << + "8501" << "alefsym" << tr("alef symbol") << + "8592" << "larr" << tr("leftwards arrow") << + "8593" << "uarr" << tr("upwards arrow") << + "8594" << "rarr" << tr("rightwards arrow") << + "8595" << "darr" << tr("downwards arrow") << + "8596" << "harr" << tr("left right arrow") << + "8629" << "crarr" << tr("downwards arrow with corner leftwards") << + "8656" << "lArr" << tr("leftwards double arrow") << + "8657" << "uArr" << tr("upwards double arrow") << + "8658" << "rArr" << tr("rightwards double arrow") << + "8659" << "dArr" << tr("downwards double arrow") << + "8660" << "hArr" << tr("left right double arrow") << + "8704" << "forall" << tr("for all") << + "8706" << "part" << tr("partial differential") << + "8707" << "exist" << tr("there exists") << + "8709" << "empty" << tr("empty set") << + "8711" << "nabla" << tr("nabla") << + "8712" << "isin" << tr("element of") << + "8713" << "notin" << tr("not an element of") << + "8715" << "ni" << tr("contains as member") << + "8719" << "prod" << tr("n-ary product") << + "8721" << "sum" << tr("n-ary summation") << + "8722" << "minus" << tr("minus sign") << + "8727" << "lowast" << tr("asterisk operator") << + "8730" << "radic" << tr("square root") << + "8733" << "prop" << tr("proportional to") << + "8734" << "infin" << tr("infinity") << + "8736" << "ang" << tr("angle") << + "8743" << "and" << tr("logical and") << + "8744" << "or" << tr("logical or") << + "8745" << "cap" << tr("intersection") << + "8746" << "cup" << tr("union") << + "8747" << "int" << tr("integral") << + "8756" << "there4" << tr("therefore sign") << + "8764" << "sim" << tr("tilde operator") << + "8773" << "cong" << tr("congruent to") << + "8776" << "asymp" << tr("almost equal to") << + "8800" << "ne" << tr("not equal to") << + "8801" << "equiv" << tr("identical to") << + "8804" << "le" << tr("less-than or equal to") << + "8805" << "ge" << tr("greater-than or equal to") << + "8834" << "sub" << tr("subset of") << + "8835" << "sup" << tr("superset of") << + "8836" << "nsub" << tr("not a subset of") << + "8838" << "sube" << tr("subset of or equal to") << + "8839" << "supe" << tr("superset of or equal to") << + "8853" << "oplus" << tr("circled plus") << + "8855" << "otimes" << tr("circled times") << + "8869" << "perp" << tr("up tack") << + "8901" << "sdot" << tr("dot operator") << + "8968" << "lceil" << tr("left ceiling") << + "8969" << "rceil" << tr("right ceiling") << + "8970" << "lfloor" << tr("left floor") << + "8971" << "rfloor" << tr("right floor") << + "9001" << "lang" << tr("left-pointing angle bracket") << + "9002" << "rang" << tr("right-pointing angle bracket") << + "9674" << "loz" << tr("lozenge") << + "9824" << "spades" << tr("black spade suit") << + "9827" << "clubs" << tr("black club suit") << + "9829" << "hearts" << tr("black heart suit") << + "9830" << "diams" << tr("black diamond suit"); for (int i = 0; i < data.count(); i++) { ushort code = data.at(i++).toInt(); diff --git a/src/Sigil/MiscEditors/ClipEditorModel.cpp b/src/Sigil/MiscEditors/ClipEditorModel.cpp index 5053e849dd..ffb1ce085b 100644 --- a/src/Sigil/MiscEditors/ClipEditorModel.cpp +++ b/src/Sigil/MiscEditors/ClipEditorModel.cpp @@ -209,8 +209,7 @@ void ClipEditorModel::UpdateFullName(QStandardItem *item) tooltip = fullname; if (item->data(IS_GROUP_ROLE).toBool()) { fullname.append("/"); - } - else { + } else { QStandardItem *text_item = parent_item->child(item->row(), 1); if (text_item) { tooltip += "\n\n" % text_item->text(); @@ -480,8 +479,7 @@ QStandardItem *ClipEditorModel::AddEntryToModel(ClipEditorModel::clipEntry *entr QString tooltip; if (entry->is_group) { tooltip = entry->fullname; - } - else { + } else { tooltip = entry->fullname % "\n\n" % entry->text; } rowItems[0]->setToolTip(tooltip); @@ -594,8 +592,7 @@ ClipEditorModel::clipEntry *ClipEditorModel::GetEntry(QStandardItem *item) QStandardItem *text_item = parent_item->child(item->row(), 1); if (text_item) { entry->text = text_item->text(); - } - else { + } else { entry->text = ""; } } diff --git a/src/Sigil/MiscEditors/IndexEditorModel.cpp b/src/Sigil/MiscEditors/IndexEditorModel.cpp index 2677621a04..6be0fabb86 100644 --- a/src/Sigil/MiscEditors/IndexEditorModel.cpp +++ b/src/Sigil/MiscEditors/IndexEditorModel.cpp @@ -186,8 +186,7 @@ void IndexEditorModel::LoadData(const QString &filename, QStandardItem *item) int tab_position = line.indexOf("\t"); entry->pattern = line.left(tab_position); entry->index_entry = line.right(line.length() - tab_position - 1); - } - else { + } else { entry->pattern = line; } AddFullNameEntry(entry, item); diff --git a/src/Sigil/MiscEditors/IndexHTMLWriter.cpp b/src/Sigil/MiscEditors/IndexHTMLWriter.cpp index 5298abe46b..77ed9282a0 100644 --- a/src/Sigil/MiscEditors/IndexHTMLWriter.cpp +++ b/src/Sigil/MiscEditors/IndexHTMLWriter.cpp @@ -35,7 +35,7 @@ static const QString TEMPLATE_BEGIN_TEXT = "\n" "\n" "Index\n" - "\n" + "\n" "\n" "\n"; @@ -88,7 +88,7 @@ void IndexHTMLWriter::WriteEntries(QStandardItem *parent_item) // entry then insert a special separator. QChar new_letter = item->text()[0].toLower(); if (new_letter != letter && parent_item == root_item) { - letter = new_letter; + letter = new_letter; m_IndexHTMLFile += "
"; m_IndexHTMLFile += QString(letter.toUpper()); m_IndexHTMLFile += "
"; @@ -109,7 +109,7 @@ void IndexHTMLWriter::WriteEntries(QStandardItem *parent_item) } m_IndexHTMLFile += "" % QString::number(ref_count) % ""; ref_count++; - + } } diff --git a/src/Sigil/PCRE/PCREReplaceTextBuilder.cpp b/src/Sigil/PCRE/PCREReplaceTextBuilder.cpp index f9d0f84dd4..168fa17e4f 100644 --- a/src/Sigil/PCRE/PCREReplaceTextBuilder.cpp +++ b/src/Sigil/PCRE/PCREReplaceTextBuilder.cpp @@ -33,7 +33,7 @@ PCREReplaceTextBuilder::PCREReplaceTextBuilder() bool PCREReplaceTextBuilder::BuildReplacementText(SPCRE &sre, const QString &text, - const QList > &capture_groups_offsets, + const QList> &capture_groups_offsets, const QString &replacement_pattern, QString &out) { diff --git a/src/Sigil/PCRE/PCREReplaceTextBuilder.h b/src/Sigil/PCRE/PCREReplaceTextBuilder.h index b8f5134644..5d09f4ad9d 100644 --- a/src/Sigil/PCRE/PCREReplaceTextBuilder.h +++ b/src/Sigil/PCRE/PCREReplaceTextBuilder.h @@ -56,7 +56,7 @@ class PCREReplaceTextBuilder */ bool BuildReplacementText(SPCRE &sre, const QString &text, - const QList > &capture_groups_offsets, + const QList> &capture_groups_offsets, const QString &replacement_pattern, QString &out); diff --git a/src/Sigil/PCRE/SPCRE.cpp b/src/Sigil/PCRE/SPCRE.cpp index 59b117aa89..6afec21cb3 100644 --- a/src/Sigil/PCRE/SPCRE.cpp +++ b/src/Sigil/PCRE/SPCRE.cpp @@ -205,7 +205,7 @@ SPCRE::MatchInfo SPCRE::getLastMatchInfo(const QString &text) } } -bool SPCRE::replaceText(const QString &text, const QList > &capture_groups_offsets, const QString &replacement_pattern, QString &out) +bool SPCRE::replaceText(const QString &text, const QList> &capture_groups_offsets, const QString &replacement_pattern, QString &out) { PCREReplaceTextBuilder builder; return builder.BuildReplacementText(*this, text, capture_groups_offsets, replacement_pattern, out); diff --git a/src/Sigil/PCRE/SPCRE.h b/src/Sigil/PCRE/SPCRE.h index ab0108565e..182f0ce0b7 100644 --- a/src/Sigil/PCRE/SPCRE.h +++ b/src/Sigil/PCRE/SPCRE.h @@ -64,7 +64,7 @@ class SPCRE // Each offset representes the porition of text that the capture // represents inside of the matched string. This is normalized so that // 0 represents the start of the string represented by offset. - QList > capture_groups_offsets; + QList> capture_groups_offsets; MatchInfo() { offset.first = -1; @@ -140,7 +140,7 @@ class SPCRE * * @return true if the replacement string was created successfully. */ - bool replaceText(const QString &text, const QList > &capture_groups_offsets, const QString &replacement_pattern, QString &out); + bool replaceText(const QString &text, const QList> &capture_groups_offsets, const QString &replacement_pattern, QString &out); private: MatchInfo generateMatchInfo(int ovector[], int ovector_count); diff --git a/src/Sigil/ResourceObjects/AudioResource.cpp b/src/Sigil/ResourceObjects/AudioResource.cpp index ae06238f2a..06978b6438 100644 --- a/src/Sigil/ResourceObjects/AudioResource.cpp +++ b/src/Sigil/ResourceObjects/AudioResource.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** -** Copyright (C) 2012 John Schember +** Copyright (C) 2012 John Schember ** ** This file is part of Sigil. ** diff --git a/src/Sigil/ResourceObjects/AudioResource.h b/src/Sigil/ResourceObjects/AudioResource.h index 32a6c6f165..28172e95bd 100644 --- a/src/Sigil/ResourceObjects/AudioResource.h +++ b/src/Sigil/ResourceObjects/AudioResource.h @@ -1,6 +1,6 @@ /************************************************************************ ** -** Copyright (C) 2012 John Schember +** Copyright (C) 2012 John Schember ** ** This file is part of Sigil. ** diff --git a/src/Sigil/ResourceObjects/CSSResource.cpp b/src/Sigil/ResourceObjects/CSSResource.cpp index 5adb82e105..8a5a20decd 100644 --- a/src/Sigil/ResourceObjects/CSSResource.cpp +++ b/src/Sigil/ResourceObjects/CSSResource.cpp @@ -49,7 +49,7 @@ static const QString W3C_HTML_FORM = "" CSSResource::CSSResource(const QString &mainfolder, const QString &fullfilepath, QObject *parent) : TextResource(mainfolder, fullfilepath, parent), - m_TemporaryValidationFiles(QList< QString >()) + m_TemporaryValidationFiles(QList()) { } diff --git a/src/Sigil/ResourceObjects/HTMLResource.cpp b/src/Sigil/ResourceObjects/HTMLResource.cpp index cd92ab6fa0..1a5cd3704e 100644 --- a/src/Sigil/ResourceObjects/HTMLResource.cpp +++ b/src/Sigil/ResourceObjects/HTMLResource.cpp @@ -43,7 +43,7 @@ const QString REPLACE_SPANS = ""; HTMLResource::HTMLResource(const QString &mainfolder, const QString &fullfilepath, - const QHash< QString, Resource * > &resources, + const QHash &resources, QObject *parent) : XMLResource(mainfolder, fullfilepath, parent), @@ -114,7 +114,7 @@ QStringList HTMLResource::GetPathsToLinkedResources() xc::DOMNodeList *elems = document.getElementsByTagName(QtoX(tag)); for (uint i = 0; i < elems->getLength(); ++i) { - xc::DOMElement &element = *static_cast< xc::DOMElement *>(elems->item(i)); + xc::DOMElement &element = *static_cast(elems->item(i)); Q_ASSERT(&element); // We skip the link elements that are not stylesheets diff --git a/src/Sigil/ResourceObjects/HTMLResource.h b/src/Sigil/ResourceObjects/HTMLResource.h index 25cf734076..6ed2edd2a7 100644 --- a/src/Sigil/ResourceObjects/HTMLResource.h +++ b/src/Sigil/ResourceObjects/HTMLResource.h @@ -54,7 +54,7 @@ class HTMLResource : public XMLResource * @param parent The object's parent. */ HTMLResource(const QString &mainfolder, const QString &fullfilepath, - const QHash< QString, Resource * > &resources, + const QHash &resources, QObject *parent = NULL); /** @@ -121,7 +121,7 @@ class HTMLResource : public XMLResource * The resource list from FolderKeeper. * @todo This is ugly as hell. Find a way to remove this. */ - const QHash< QString, Resource * > &m_Resources; + const QHash &m_Resources; }; #endif // HTMLRESOURCE_H diff --git a/src/Sigil/ResourceObjects/NCXResource.cpp b/src/Sigil/ResourceObjects/NCXResource.cpp index 6efb8e0253..20aa6cf046 100644 --- a/src/Sigil/ResourceObjects/NCXResource.cpp +++ b/src/Sigil/ResourceObjects/NCXResource.cpp @@ -115,13 +115,13 @@ bool NCXResource::GenerateNCXFromBookContents(const Book &book) void NCXResource::GenerateNCXFromTOCContents(const Book &book, NCXModel &ncx_model) { -// QByteArray raw_ncx; -// QBuffer buffer(&raw_ncx); -// buffer.open(QIODevice::WriteOnly); -// NCXWriter ncx(book, buffer, ncx_model.GetRootNCXEntry()); -// ncx.WriteXML(); -// buffer.close(); -// SetText(CleanSource::ProcessXML(QString::fromUtf8(raw_ncx.constData(), raw_ncx.size()))); + // QByteArray raw_ncx; + // QBuffer buffer(&raw_ncx); + // buffer.open(QIODevice::WriteOnly); + // NCXWriter ncx(book, buffer, ncx_model.GetRootNCXEntry()); + // ncx.WriteXML(); + // buffer.close(); + // SetText(CleanSource::ProcessXML(QString::fromUtf8(raw_ncx.constData(), raw_ncx.size()))); GenerateNCXFromTOCEntries(book, ncx_model.GetRootNCXEntry()); } diff --git a/src/Sigil/ResourceObjects/OPFResource.cpp b/src/Sigil/ResourceObjects/OPFResource.cpp index 86cb2d1814..51f596d114 100644 --- a/src/Sigil/ResourceObjects/OPFResource.cpp +++ b/src/Sigil/ResourceObjects/OPFResource.cpp @@ -96,7 +96,7 @@ Resource::ResourceType OPFResource::Type() const GuideSemantics::GuideSemanticType OPFResource::GetGuideSemanticTypeForResource(const Resource &resource) const { QReadLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); return GetGuideSemanticTypeForResource(resource, *document); } @@ -110,9 +110,9 @@ QHash OPFResource::GetGuideSemanticNameForPaths() QHash semantic_types; QReadLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); - QList< xc::DOMElement * > references = + QList references = XhtmlDoc::GetTagMatchingDescendants(*document, "reference", OPF_XML_NAMESPACE); foreach(xc::DOMElement *reference, references) { @@ -131,15 +131,15 @@ QHash OPFResource::GetGuideSemanticNameForPaths() QString cover_id = XtoQ(meta->getAttribute(QtoX("content"))); - QList< xc::DOMElement * > items = - XhtmlDoc::GetTagMatchingDescendants(*document, "item", OPF_XML_NAMESPACE); + QList items = + XhtmlDoc::GetTagMatchingDescendants(*document, "item", OPF_XML_NAMESPACE); foreach(xc::DOMElement *item, items) { QString id = XtoQ(item->getAttribute(QtoX("id"))); if (id == cover_id) { QString href = XtoQ(item->getAttribute(QtoX("href"))); GuideSemantics::GuideSemanticType type = - GuideSemantics::Instance().MapReferenceTypeToGuideEnum("cover"); + GuideSemantics::Instance().MapReferenceTypeToGuideEnum("cover"); semantic_types[href] = GuideSemantics::Instance().GetGuideName(type); } } @@ -148,14 +148,14 @@ QHash OPFResource::GetGuideSemanticNameForPaths() return semantic_types; } -QHash OPFResource::GetReadingOrderAll( const QList < Resource *> resources) +QHash OPFResource::GetReadingOrderAll( const QList resources) { QHash reading_order; QReadLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); - QList< xc::DOMElement * > itemrefs = + QList itemrefs = XhtmlDoc::GetTagMatchingDescendants(*document, "itemref", OPF_XML_NAMESPACE); QHash id_order; @@ -164,7 +164,7 @@ QHash OPFResource::GetReadingOrderAll( const QList < Resource id_order[idref] = i; } - QHash< Resource *, QString > id_mapping = GetResourceManifestIDMapping(resources, *document); + QHash id_mapping = GetResourceManifestIDMapping(resources, *document); foreach(Resource *resource, resources) { reading_order[resource] = id_order[id_mapping[resource]]; @@ -176,10 +176,10 @@ QHash OPFResource::GetReadingOrderAll( const QList < Resource int OPFResource::GetReadingOrder(const ::HTMLResource &html_resource) const { QReadLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); - const Resource &resource = *static_cast< const Resource * >(&html_resource); + shared_ptr document = GetDocument(); + const Resource &resource = *static_cast(&html_resource); QString resource_id = GetResourceManifestID(resource, *document); - QList< xc::DOMElement * > itemrefs = + QList itemrefs = XhtmlDoc::GetTagMatchingDescendants(*document, "itemref", OPF_XML_NAMESPACE); for (int i = 0; i < itemrefs.count(); ++i) { @@ -197,7 +197,7 @@ int OPFResource::GetReadingOrder(const ::HTMLResource &html_resource) const QString OPFResource::GetMainIdentifierValue() const { QReadLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); return XtoQ(GetMainIdentifier(*document).getTextContent()); } @@ -215,8 +215,8 @@ QString OPFResource::GetUUIDIdentifierValue() { EnsureUUIDIdentifierPresent(); QReadLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); - QList< xc::DOMElement * > identifiers = + shared_ptr document = GetDocument(); + QList identifiers = XhtmlDoc::GetTagMatchingDescendants(*document, "identifier", DUBLIN_CORE_NS); foreach(xc::DOMElement * identifier, identifiers) { QString value = XtoQ(identifier->getTextContent()).remove("urn:uuid:"); @@ -235,7 +235,7 @@ QString OPFResource::GetUUIDIdentifierValue() void OPFResource::EnsureUUIDIdentifierPresent() { QWriteLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); QList identifiers = XhtmlDoc::GetTagMatchingDescendants(*document, "identifier", DUBLIN_CORE_NS); foreach(xc::DOMElement *identifier, identifiers) { @@ -255,8 +255,8 @@ QString OPFResource::AddNCXItem(const QString &ncx_path) QWriteLocker locker(&GetLock()); QString path_to_oebps_folder = QFileInfo(GetFullPath()).absolutePath() + "/"; QString ncx_oebps_path = Utility::URLEncodePath(QString(ncx_path).remove(path_to_oebps_folder)); - shared_ptr< xc::DOMDocument > document = GetDocument(); - QHash< QString, QString > attributes; + shared_ptr document = GetDocument(); + QHash attributes; attributes[ "id" ] = GetUniqueID("ncx", *document); attributes[ "href" ] = Utility::URLEncodePath(ncx_oebps_path); attributes[ "media-type" ] = "application/x-dtbncx+xml"; @@ -274,7 +274,7 @@ QString OPFResource::AddNCXItem(const QString &ncx_path) void OPFResource::UpdateNCXOnSpine(const QString &new_ncx_id) { QWriteLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); xc::DOMElement *spine = GetSpineElement(*document); if (!spine) { return; @@ -290,7 +290,7 @@ void OPFResource::UpdateNCXOnSpine(const QString &new_ncx_id) void OPFResource::UpdateNCXLocationInManifest(const ::NCXResource &ncx) { QWriteLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); xc::DOMElement *spine = GetSpineElement(*document); QString ncx_id = XtoQ(spine->getAttribute(QtoX("toc"))); QList items = XhtmlDoc::GetTagMatchingDescendants(*document, "item", OPF_XML_NAMESPACE); @@ -309,8 +309,8 @@ void OPFResource::UpdateNCXLocationInManifest(const ::NCXResource &ncx) void OPFResource::AddSigilVersionMeta() { QWriteLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); - QList< xc::DOMElement * > metas = + shared_ptr document = GetDocument(); + QList metas = XhtmlDoc::GetTagMatchingDescendants(*document, "meta", OPF_XML_NAMESPACE); foreach(xc::DOMElement * meta, metas) { QString name = XtoQ(meta->getAttribute(QtoX("name"))); @@ -336,7 +336,7 @@ void OPFResource::AddSigilVersionMeta() bool OPFResource::IsCoverImage(const ::ImageResource &image_resource) const { QReadLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); return IsCoverImageCheck(image_resource, *document); } @@ -361,7 +361,7 @@ bool OPFResource::IsCoverImageCheck(QString resource_id, xc::DOMDocument &docume bool OPFResource::CoverImageExists() const { QReadLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); return GetCoverMeta(*document) != NULL; } @@ -376,16 +376,16 @@ void OPFResource::AutoFixWellFormedErrors() QStringList OPFResource::GetSpineOrderFilenames() const { QReadLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); - QList< xc::DOMElement * > items = + shared_ptr document = GetDocument(); + QList items = XhtmlDoc::GetTagMatchingDescendants(*document, "item", OPF_XML_NAMESPACE); - QHash< QString, QString > id_to_filename_mapping; + QHash id_to_filename_mapping; foreach(xc::DOMElement * item, items) { QString id = XtoQ(item->getAttribute(QtoX("id"))); QString href = XtoQ(item->getAttribute(QtoX("href"))); id_to_filename_mapping[ id ] = QFileInfo(href).fileName(); } - QList< xc::DOMElement * > itemrefs = + QList itemrefs = XhtmlDoc::GetTagMatchingDescendants(*document, "itemref", OPF_XML_NAMESPACE); QStringList filenames_in_reading_order; foreach(xc::DOMElement * itemref, itemrefs) { @@ -402,21 +402,21 @@ QStringList OPFResource::GetSpineOrderFilenames() const void OPFResource::SetSpineOrderFromFilenames(const QStringList spineOrder) { QWriteLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); - QList< xc::DOMElement * > items = + shared_ptr document = GetDocument(); + QList items = XhtmlDoc::GetTagMatchingDescendants(*document, "item", OPF_XML_NAMESPACE); - QHash< QString, QString > filename_to_id_mapping; + QHash filename_to_id_mapping; foreach(xc::DOMElement * item, items) { QString id = XtoQ(item->getAttribute(QtoX("id"))); QString href = XtoQ(item->getAttribute(QtoX("href"))); } - QList< xc::DOMElement * > itemrefs = + QList itemrefs = XhtmlDoc::GetTagMatchingDescendants(*document, "itemref", OPF_XML_NAMESPACE); - QList< xc::DOMElement * > newSpine; + QList newSpine; foreach(QString spineItem, spineOrder) { QString id = filename_to_id_mapping[ spineItem ]; bool found = false; - QListIterator< xc::DOMElement * > spineElementSearch(itemrefs); + QListIterator spineElementSearch(itemrefs); while (spineElementSearch.hasNext() && !found) { xc::DOMElement *spineElement = spineElementSearch.next(); @@ -442,13 +442,13 @@ void OPFResource::SetSpineOrderFromFilenames(const QStringList spineOrder) } -QList< Metadata::MetaElement > OPFResource::GetDCMetadata() const +QList OPFResource::GetDCMetadata() const { QReadLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); - QList< xc::DOMElement * > dc_elements = + shared_ptr document = GetDocument(); + QList dc_elements = XhtmlDoc::GetTagMatchingDescendants(*document, "*", DUBLIN_CORE_NS); - QList< Metadata::MetaElement > metadata; + QList metadata; foreach(xc::DOMElement * dc_element, dc_elements) { // Map the names in the OPF file to internal names Metadata::MetaElement book_meta = Metadata::Instance().MapToBookMetadata(*dc_element); @@ -461,9 +461,9 @@ QList< Metadata::MetaElement > OPFResource::GetDCMetadata() const } -QList< QVariant > OPFResource::GetDCMetadataValues(QString text) const +QList OPFResource::GetDCMetadataValues(QString text) const { - QList< QVariant > values; + QList values; foreach(Metadata::MetaElement meta, GetDCMetadata()) { if (meta.name == text) { values.append(meta.value); @@ -473,10 +473,10 @@ QList< QVariant > OPFResource::GetDCMetadataValues(QString text) const } -void OPFResource::SetDCMetadata(const QList< Metadata::MetaElement > &metadata) +void OPFResource::SetDCMetadata(const QList &metadata) { QWriteLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); RemoveDCElements(*document); foreach(Metadata::MetaElement book_meta, metadata) { MetadataDispatcher(book_meta, *document); @@ -489,8 +489,8 @@ void OPFResource::SetDCMetadata(const QList< Metadata::MetaElement > &metadata) void OPFResource::AddResource(const Resource &resource) { QWriteLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); - QHash< QString, QString > attributes; + shared_ptr document = GetDocument(); + QHash attributes; attributes[ "id" ] = GetUniqueID(GetValidID(resource.Filename()), *document); attributes[ "href" ] = Utility::URLEncodePath(resource.GetRelativePathToOEBPS()); attributes[ "media-type" ] = GetResourceMimetype(resource); @@ -529,7 +529,7 @@ void OPFResource::AddCoverMetaForImage(const Resource &resource, xc::DOMDocument if (meta) { meta->setAttribute(QtoX("content"), QtoX(resource_id)); } else { - QHash< QString, QString > attributes; + QHash attributes; attributes[ "name" ] = "cover"; attributes[ "content" ] = resource_id; xc::DOMElement *new_meta = XhtmlDoc::CreateElementInDocument( @@ -542,12 +542,12 @@ void OPFResource::AddCoverMetaForImage(const Resource &resource, xc::DOMDocument void OPFResource::RemoveResource(const Resource &resource) { QWriteLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); xc::DOMElement *manifest = GetManifestElement(*document); if (!manifest) { return; } - std::vector< xc::DOMElement * > children = xe::GetElementChildren(*manifest); + std::vector children = xe::GetElementChildren(*manifest); QString resource_oebps_path = Utility::URLEncodePath(resource.GetRelativePathToOEBPS()); QString item_id; @@ -580,7 +580,7 @@ void OPFResource::AddGuideSemanticType( GuideSemantics::GuideSemanticType new_type) { QWriteLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); GuideSemantics::GuideSemanticType current_type = GetGuideSemanticTypeForResource(html_resource, *document); if (current_type != new_type) { @@ -600,7 +600,7 @@ void OPFResource::AddGuideSemanticType( void OPFResource::SetResourceAsCoverImage(const ::ImageResource &image_resource) { QWriteLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); if (IsCoverImageCheck(image_resource, *document)) { RemoveCoverMetaForImage(image_resource, *document); @@ -612,11 +612,11 @@ void OPFResource::SetResourceAsCoverImage(const ::ImageResource &image_resource) } -void OPFResource::UpdateSpineOrder(const QList< ::HTMLResource * > html_files) +void OPFResource::UpdateSpineOrder(const QList<::HTMLResource *> html_files) { QWriteLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); - QHash< ::HTMLResource *, xc::DOMElement *> itemref_mapping = GetItemrefsForHTMLResources(html_files, *document); + shared_ptr document = GetDocument(); + QHash<::HTMLResource *, xc::DOMElement *> itemref_mapping = GetItemrefsForHTMLResources(html_files, *document); xc::DOMElement *spine = GetSpineElement(*document); if (!spine) { return; @@ -636,10 +636,10 @@ void OPFResource::UpdateSpineOrder(const QList< ::HTMLResource * > html_files) void OPFResource::ResourceRenamed(const Resource &resource, QString old_full_path) { QWriteLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); + shared_ptr document = GetDocument(); QString path_to_oebps_folder = QFileInfo(GetFullPath()).absolutePath() + "/"; QString resource_oebps_path = Utility::URLEncodePath(QString(old_full_path).remove(path_to_oebps_folder)); - QList< xc::DOMElement * > items = + QList items = XhtmlDoc::GetTagMatchingDescendants(*document, "item", OPF_XML_NAMESPACE); QString old_id; QString new_id; @@ -673,7 +673,7 @@ void OPFResource::ResourceRenamed(const Resource &resource, QString old_full_pat void OPFResource::AppendToSpine(const QString &id, xc::DOMDocument &document) { - QHash< QString, QString > attributes; + QHash attributes; attributes[ "idref" ] = id; xc::DOMElement *new_item = XhtmlDoc::CreateElementInDocument( "itemref", OPF_XML_NAMESPACE, document, attributes); @@ -691,7 +691,7 @@ void OPFResource::RemoveFromSpine(const QString &id, xc::DOMDocument &document) if (!spine) { return; } - std::vector< xc::DOMElement * > children = xe::GetElementChildren(*spine); + std::vector children = xe::GetElementChildren(*spine); foreach(xc::DOMElement * child, children) { QString idref = XtoQ(child->getAttribute(QtoX("idref"))); @@ -706,7 +706,7 @@ void OPFResource::RemoveFromSpine(const QString &id, xc::DOMDocument &document) void OPFResource::UpdateItemrefID(const QString &old_id, const QString &new_id, xc::DOMDocument &document) { xc::DOMElement *spine = GetSpineElement(document); - std::vector< xc::DOMElement * > children = xe::GetElementChildren(*spine); + std::vector children = xe::GetElementChildren(*spine); foreach(xc::DOMElement * child, children) { QString idref = XtoQ(child->getAttribute(QtoX("idref"))); @@ -718,13 +718,13 @@ void OPFResource::UpdateItemrefID(const QString &old_id, const QString &new_id, } -shared_ptr< xc::DOMDocument > OPFResource::GetDocument() const +shared_ptr OPFResource::GetDocument() const { // The call to ProcessXML is needed because even though we have well-formed // checks tied to "focus lost" events of the OPF tab, on Win XP those events // are sometimes not delivered at all. Blame MS. In the mean time, this // work-around makes sure we get valid XML into Xerces no matter what. - shared_ptr< xc::DOMDocument > document = + shared_ptr document = XhtmlDoc::LoadTextIntoDocument(CleanSource::ProcessXML(GetText())); if (!BasicStructurePresent(*document)) { @@ -795,7 +795,7 @@ xc::DOMElement *OPFResource::GetGuideElement(xc::DOMDocument &document) return guides[0]; } - xc::DOMElement *guide = XhtmlDoc::CreateElementInDocument("guide", OPF_XML_NAMESPACE, document, QHash< QString, QString >()); + xc::DOMElement *guide = XhtmlDoc::CreateElementInDocument("guide", OPF_XML_NAMESPACE, document, QHash()); xc::DOMElement &package = *document.getDocumentElement(); package.appendChild(guide); return guide; @@ -805,7 +805,7 @@ xc::DOMElement *OPFResource::GetGuideElement(xc::DOMDocument &document) xc::DOMElement *OPFResource::GetGuideReferenceForResource(const Resource &resource, const xc::DOMDocument &document) { QString resource_oebps_path = Utility::URLEncodePath(resource.GetRelativePathToOEBPS()); - QList< xc::DOMElement * > references = + QList references = XhtmlDoc::GetTagMatchingDescendants(document, "reference", OPF_XML_NAMESPACE); foreach(xc::DOMElement * reference, references) { const QString &href = XtoQ(reference->getAttribute(QtoX("href"))); @@ -862,7 +862,7 @@ void OPFResource::SetGuideSemanticTypeForResource( reference->setAttribute(QtoX("type"), QtoX(type_attribute)); reference->setAttribute(QtoX("title"), QtoX(title_attribute)); } else { - QHash< QString, QString > attributes; + QHash attributes; attributes[ "type" ] = type_attribute; attributes[ "title" ] = title_attribute; attributes[ "href" ] = Utility::URLEncodePath(resource.GetRelativePathToOEBPS()); @@ -910,21 +910,21 @@ void OPFResource::RemoveDuplicateGuideTypes( // attached to the spine element!). // Also, it's possible that a NULL will be set as an itemref for a resource // if that resource doesns't have an entry in the manifest. -QHash< ::HTMLResource *, xc::DOMElement * > OPFResource::GetItemrefsForHTMLResources( - const QList< ::HTMLResource * > html_files, +QHash<::HTMLResource *, xc::DOMElement *> OPFResource::GetItemrefsForHTMLResources( + const QList<::HTMLResource *> html_files, xc::DOMDocument &document) { - QList< xc::DOMElement * > itemrefs = + QList itemrefs = XhtmlDoc::GetTagMatchingDescendants(document, "itemref", OPF_XML_NAMESPACE); - QList< Resource * > resource_list; + QList resource_list; foreach(::HTMLResource * html_resource, html_files) { - resource_list.append(static_cast< Resource * >(html_resource)); + resource_list.append(static_cast(html_resource)); } - QHash< Resource *, QString > id_mapping = GetResourceManifestIDMapping(resource_list, document); - QList< Resource * > htmls_without_itemrefs; - QHash< ::HTMLResource *, xc::DOMElement * > itmeref_mapping; + QHash id_mapping = GetResourceManifestIDMapping(resource_list, document); + QList htmls_without_itemrefs; + QHash<::HTMLResource *, xc::DOMElement *> itmeref_mapping; foreach(Resource * resource, resource_list) { - ::HTMLResource *html_resource = qobject_cast< ::HTMLResource * >(resource); + ::HTMLResource *html_resource = qobject_cast<::HTMLResource *>(resource); QString resource_id = id_mapping.value(resource, ""); foreach(xc::DOMElement * itemref, itemrefs) { QString idref = XtoQ(itemref->getAttribute(QtoX("idref"))); @@ -940,9 +940,9 @@ QHash< ::HTMLResource *, xc::DOMElement * > OPFResource::GetItemrefsForHTMLResou } } foreach(Resource * resource, htmls_without_itemrefs) { - QHash< QString, QString > attributes; + QHash attributes; QString resource_id = id_mapping.value(resource, ""); - ::HTMLResource *html_resource = qobject_cast< ::HTMLResource * >(resource); + ::HTMLResource *html_resource = qobject_cast<::HTMLResource *>(resource); if (resource_id.isEmpty()) { itmeref_mapping[ html_resource ] = NULL; @@ -959,7 +959,7 @@ QHash< ::HTMLResource *, xc::DOMElement * > OPFResource::GetItemrefsForHTMLResou xc::DOMElement *OPFResource::GetCoverMeta(const xc::DOMDocument &document) { - QList< xc::DOMElement * > metas = + QList metas = XhtmlDoc::GetTagMatchingDescendants(document, "meta", OPF_XML_NAMESPACE); foreach(xc::DOMElement * meta, metas) { QString name = XtoQ(meta->getAttribute(QtoX("name"))); @@ -1003,7 +1003,7 @@ xc::DOMElement *OPFResource::GetMainIdentifierUnsafe(const xc::DOMDocument &docu QString OPFResource::GetResourceManifestID(const Resource &resource, const xc::DOMDocument &document) { QString oebps_path = Utility::URLEncodePath(resource.GetRelativePathToOEBPS()); - QList< xc::DOMElement * > items = + QList items = XhtmlDoc::GetTagMatchingDescendants(document, "item", OPF_XML_NAMESPACE); foreach(xc::DOMElement * item, items) { QString href = XtoQ(item->getAttribute(QtoX("href"))); @@ -1016,12 +1016,12 @@ QString OPFResource::GetResourceManifestID(const Resource &resource, const xc::D } -QHash< Resource *, QString > OPFResource::GetResourceManifestIDMapping( - const QList< Resource * > resources, +QHash OPFResource::GetResourceManifestIDMapping( + const QList resources, const xc::DOMDocument &document) { - QHash< Resource *, QString > id_mapping; - QList< xc::DOMElement * > items = + QHash id_mapping; + QList items = XhtmlDoc::GetTagMatchingDescendants(document, "item", OPF_XML_NAMESPACE); foreach(Resource * resource, resources) { QString oebps_path = Utility::URLEncodePath(resource->GetRelativePathToOEBPS()); @@ -1040,7 +1040,7 @@ QHash< Resource *, QString > OPFResource::GetResourceManifestIDMapping( void OPFResource::SetMetaElementsLast(xc::DOMDocument &document) { - QList< xc::DOMElement * > metas = + QList metas = XhtmlDoc::GetTagMatchingDescendants(document, "meta", OPF_XML_NAMESPACE); xc::DOMElement *metadata = GetMetadataElement(document); if (!metadata) { @@ -1056,7 +1056,7 @@ void OPFResource::SetMetaElementsLast(xc::DOMDocument &document) void OPFResource::RemoveDCElements(xc::DOMDocument &document) { - QList< xc::DOMElement * > dc_elements = XhtmlDoc::GetTagMatchingDescendants(document, "*", DUBLIN_CORE_NS); + QList dc_elements = XhtmlDoc::GetTagMatchingDescendants(document, "*", DUBLIN_CORE_NS); xc::DOMElement &main_identifier = GetMainIdentifier(document); foreach(xc::DOMElement * dc_element, dc_elements) { // We preserve the original main identifier. Users @@ -1192,8 +1192,8 @@ void OPFResource::AddModificationDateMeta() { QString date = QDate::currentDate().toString("yyyy-MM-dd"); QWriteLocker locker(&GetLock()); - shared_ptr< xc::DOMDocument > document = GetDocument(); - QList< xc::DOMElement * > metas = + shared_ptr document = GetDocument(); + QList metas = XhtmlDoc::GetTagMatchingDescendants(*document, "date", DUBLIN_CORE_NS); foreach(xc::DOMElement * meta, metas) { QString name = XtoQ(meta->getAttribute(QtoX("opf:event"))); @@ -1235,28 +1235,28 @@ void OPFResource::WriteDate( bool OPFResource::BasicStructurePresent(const xc::DOMDocument &document) { - QList< xc::DOMElement * > packages = + QList packages = XhtmlDoc::GetTagMatchingDescendants(document, "package", OPF_XML_NAMESPACE); if (packages.count() != 1) { return false; } - QList< xc::DOMElement * > metadatas = + QList metadatas = XhtmlDoc::GetTagMatchingDescendants(document, "metadata", OPF_XML_NAMESPACE); if (metadatas.count() != 1) { return false; } - QList< xc::DOMElement * > manifests = + QList manifests = XhtmlDoc::GetTagMatchingDescendants(document, "manifest", OPF_XML_NAMESPACE); if (manifests.count() != 1) { return false; } - QList< xc::DOMElement * > spines = + QList spines = XhtmlDoc::GetTagMatchingDescendants(document, "spine", OPF_XML_NAMESPACE); if (spines.count() != 1) { @@ -1270,7 +1270,7 @@ bool OPFResource::BasicStructurePresent(const xc::DOMDocument &document) return true; } -shared_ptr< xc::DOMDocument > OPFResource::CreateOPFFromScratch(const xc::DOMDocument *d) const +shared_ptr OPFResource::CreateOPFFromScratch(const xc::DOMDocument *d) const { xc::DOMElement *elem; QList children; @@ -1278,8 +1278,8 @@ shared_ptr< xc::DOMDocument > OPFResource::CreateOPFFromScratch(const xc::DOMDoc QString manifest; QString spine; QString metadata_content; - QList > manifest_file; - QList > manifest_recovered; + QList> manifest_file; + QList> manifest_recovered; QString manifest_content; QList ids_in_manifest; QList spine_file; @@ -1400,13 +1400,13 @@ shared_ptr< xc::DOMDocument > OPFResource::CreateOPFFromScratch(const xc::DOMDoc // Build the OPF. xml_source = GetOPFDefaultText(); xml_source.replace("", manifest_content + "") - .replace("", spine_content + "") - .replace("", metadata_content + "") - .replace("
", guide_content + "") - .replace("\n\n\n\n", ""); - - shared_ptr< xc::DOMDocument > document = XhtmlDoc::LoadTextIntoDocument(xml_source); + .replace("", spine_content + "") + .replace("", metadata_content + "") + .replace("", guide_content + "") + .replace("\n\n\n\n", ""); + + shared_ptr document = XhtmlDoc::LoadTextIntoDocument(xml_source); document->setXmlStandalone(true); return document; } diff --git a/src/Sigil/ResourceObjects/OPFResource.h b/src/Sigil/ResourceObjects/OPFResource.h index bfe4554154..a71c48d4dd 100644 --- a/src/Sigil/ResourceObjects/OPFResource.h +++ b/src/Sigil/ResourceObjects/OPFResource.h @@ -63,7 +63,7 @@ class OPFResource : public XMLResource QHash GetGuideSemanticNameForPaths(); int GetReadingOrder(const ::HTMLResource &html_resource) const; - QHash GetReadingOrderAll( const QList < Resource *> resources); + QHash GetReadingOrderAll( const QList resources); QString GetMainIdentifierValue() const; @@ -115,14 +115,14 @@ class OPFResource : public XMLResource * * @return The DC metadata, in the same format as the SetDCMetadata metadata parameter. */ - QList< Metadata::MetaElement > GetDCMetadata() const; + QList GetDCMetadata() const; /** * Returns the values for a specific metadata name. * * @return A list of values */ - QList< QVariant > GetDCMetadataValues(QString text) const; + QList GetDCMetadataValues(QString text) const; QString GetRelativePathToRoot() const; @@ -133,7 +133,7 @@ public slots: * * @param metadata A list with meta information about the book. */ - void SetDCMetadata(const QList< Metadata::MetaElement > &metadata); + void SetDCMetadata(const QList &metadata); void AddResource(const Resource &resource); @@ -147,7 +147,7 @@ public slots: void SetResourceAsCoverImage(const ImageResource &image_resource); - void UpdateSpineOrder(const QList< HTMLResource * > html_files); + void UpdateSpineOrder(const QList html_files); void ResourceRenamed(const Resource &resource, QString old_full_path); @@ -159,7 +159,7 @@ public slots: static void UpdateItemrefID(const QString &old_id, const QString &new_id, xc::DOMDocument &document); - boost::shared_ptr< xc::DOMDocument > GetDocument() const; + boost::shared_ptr GetDocument() const; static xc::DOMElement *GetPackageElement(const xc::DOMDocument &document); @@ -194,8 +194,8 @@ public slots: GuideSemantics::GuideSemanticType new_type, xc::DOMDocument &document); - static QHash< ::HTMLResource *, xc::DOMElement * > GetItemrefsForHTMLResources( - const QList< ::HTMLResource * > html_files, + static QHash<::HTMLResource *, xc::DOMElement *> GetItemrefsForHTMLResources( + const QList<::HTMLResource *> html_files, xc::DOMDocument &document); // CAN BE NULL! NULL means no cover meta element @@ -207,8 +207,8 @@ public slots: static QString GetResourceManifestID(const Resource &resource, const xc::DOMDocument &document); - static QHash< Resource *, QString > GetResourceManifestIDMapping( - const QList< Resource * > resources, + static QHash GetResourceManifestIDMapping( + const QList resources, const xc::DOMDocument &document); static void SetMetaElementsLast(xc::DOMDocument &document); @@ -265,7 +265,7 @@ public slots: static bool BasicStructurePresent(const xc::DOMDocument &document); - boost::shared_ptr< xc::DOMDocument > CreateOPFFromScratch(const xc::DOMDocument *document=NULL) const; + boost::shared_ptr CreateOPFFromScratch(const xc::DOMDocument *document=NULL) const; QStringList GetRelativePathsToAllFilesInOEPBS() const; @@ -292,7 +292,7 @@ public slots: * A mapping between file extensions * and appropriate MIME types. */ - QHash< QString, QString > m_Mimetypes; + QHash m_Mimetypes; }; diff --git a/src/Sigil/ResourceObjects/VideoResource.cpp b/src/Sigil/ResourceObjects/VideoResource.cpp index 36702d3b56..82522e9a0b 100644 --- a/src/Sigil/ResourceObjects/VideoResource.cpp +++ b/src/Sigil/ResourceObjects/VideoResource.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** -** Copyright (C) 2012 John Schember +** Copyright (C) 2012 John Schember ** ** This file is part of Sigil. ** diff --git a/src/Sigil/ResourceObjects/VideoResource.h b/src/Sigil/ResourceObjects/VideoResource.h index 57703251a4..24a240918d 100644 --- a/src/Sigil/ResourceObjects/VideoResource.h +++ b/src/Sigil/ResourceObjects/VideoResource.h @@ -1,6 +1,6 @@ /************************************************************************ ** -** Copyright (C) 2012 John Schember +** Copyright (C) 2012 John Schember ** ** This file is part of Sigil. ** diff --git a/src/Sigil/SourceUpdates/AnchorUpdates.cpp b/src/Sigil/SourceUpdates/AnchorUpdates.cpp index 423b19bb07..e5420eceb2 100644 --- a/src/Sigil/SourceUpdates/AnchorUpdates.cpp +++ b/src/Sigil/SourceUpdates/AnchorUpdates.cpp @@ -41,26 +41,26 @@ using boost::shared_ptr; using boost::tie; using boost::tuple; -void AnchorUpdates::UpdateAllAnchorsWithIDs(const QList< HTMLResource * > &html_resources) +void AnchorUpdates::UpdateAllAnchorsWithIDs(const QList &html_resources) { - const QHash< QString, QString > &ID_locations = GetIDLocations(html_resources); + const QHash &ID_locations = GetIDLocations(html_resources); QtConcurrent::blockingMap(html_resources, boost::bind(UpdateAnchorsInOneFile, _1, ID_locations)); } -void AnchorUpdates::UpdateExternalAnchors(const QList< HTMLResource * > &html_resources, const QString &originating_filename, const QList< HTMLResource * > new_files) +void AnchorUpdates::UpdateExternalAnchors(const QList &html_resources, const QString &originating_filename, const QList new_files) { - const QHash< QString, QString > &ID_locations = GetIDLocations(new_files); + const QHash &ID_locations = GetIDLocations(new_files); QtConcurrent::blockingMap(html_resources, boost::bind(UpdateExternalAnchorsInOneFile, _1, originating_filename, ID_locations)); } -void AnchorUpdates::UpdateAllAnchors(const QList< HTMLResource * > &html_resources, const QStringList &originating_filenames, HTMLResource *new_file) +void AnchorUpdates::UpdateAllAnchors(const QList &html_resources, const QStringList &originating_filenames, HTMLResource *new_file) { - QList< HTMLResource * > new_files; + QList new_files; new_files.append(new_file); - const QHash< QString, QString > &ID_locations = GetIDLocations(new_files); - QList< QString > originating_filename_links; + const QHash &ID_locations = GetIDLocations(new_files); + QList originating_filename_links; foreach(QString originating_filename, originating_filenames) { originating_filename_links.append("../" % TEXT_FOLDER_NAME % "/" % originating_filename); } @@ -69,13 +69,13 @@ void AnchorUpdates::UpdateAllAnchors(const QList< HTMLResource * > &html_resourc } -QHash< QString, QString > AnchorUpdates::GetIDLocations(const QList< HTMLResource * > &html_resources) +QHash AnchorUpdates::GetIDLocations(const QList &html_resources) { - const QList< tuple< QString, QList< QString > > > &IDs_in_files = QtConcurrent::blockingMapped(html_resources, GetOneFileIDs); - QHash< QString, QString > ID_locations; + const QList>> &IDs_in_files = QtConcurrent::blockingMapped(html_resources, GetOneFileIDs); + QHash ID_locations; for (int i = 0; i < IDs_in_files.count(); ++i) { - QList< QString > file_element_IDs; + QList file_element_IDs; QString resource_filename; tie(resource_filename, file_element_IDs) = IDs_in_files.at(i); @@ -88,7 +88,7 @@ QHash< QString, QString > AnchorUpdates::GetIDLocations(const QList< HTMLResourc } -tuple< QString, QList< QString > > AnchorUpdates::GetOneFileIDs(HTMLResource *html_resource) +tuple> AnchorUpdates::GetOneFileIDs(HTMLResource *html_resource) { Q_ASSERT(html_resource); QReadLocker locker(&html_resource->GetLock()); @@ -99,7 +99,7 @@ tuple< QString, QList< QString > > AnchorUpdates::GetOneFileIDs(HTMLResource *ht void AnchorUpdates::UpdateAnchorsInOneFile(HTMLResource *html_resource, - const QHash< QString, QString > ID_locations) + const QHash ID_locations) { Q_ASSERT(html_resource); QWriteLocker locker(&html_resource->GetLock()); @@ -110,7 +110,7 @@ void AnchorUpdates::UpdateAnchorsInOneFile(HTMLResource *html_resource, bool is_changed = false; for (uint i = 0; i < anchors->getLength(); ++i) { - xc::DOMElement &element = *static_cast< xc::DOMElement * >(anchors->item(i)); + xc::DOMElement &element = *static_cast(anchors->item(i)); Q_ASSERT(&element); if (element.hasAttribute(QtoX("href")) && @@ -143,7 +143,7 @@ void AnchorUpdates::UpdateAnchorsInOneFile(HTMLResource *html_resource, } -void AnchorUpdates::UpdateExternalAnchorsInOneFile(HTMLResource *html_resource, const QString &originating_filename, const QHash< QString, QString > ID_locations) +void AnchorUpdates::UpdateExternalAnchorsInOneFile(HTMLResource *html_resource, const QString &originating_filename, const QHash ID_locations) { Q_ASSERT(html_resource); QWriteLocker locker(&html_resource->GetLock()); @@ -154,7 +154,7 @@ void AnchorUpdates::UpdateExternalAnchorsInOneFile(HTMLResource *html_resource, bool is_changed = false; for (uint i = 0; i < anchors->getLength(); ++i) { - xc::DOMElement &element = *static_cast< xc::DOMElement * >(anchors->item(i)); + xc::DOMElement &element = *static_cast(anchors->item(i)); Q_ASSERT(&element); // We're only interested in hrefs of the form "originating_filename#fragment_id". @@ -187,8 +187,8 @@ void AnchorUpdates::UpdateExternalAnchorsInOneFile(HTMLResource *html_resource, void AnchorUpdates::UpdateAllAnchorsInOneFile(HTMLResource *html_resource, - const QList< QString > &originating_filename_links, - const QHash< QString, QString > ID_locations, + const QList &originating_filename_links, + const QHash ID_locations, const QString &new_filename) { Q_ASSERT(html_resource); @@ -199,7 +199,7 @@ void AnchorUpdates::UpdateAllAnchorsInOneFile(HTMLResource *html_resource, bool is_changed = false; for (uint i = 0; i < anchors->getLength(); ++i) { - xc::DOMElement &element = *static_cast< xc::DOMElement * >(anchors->item(i)); + xc::DOMElement &element = *static_cast(anchors->item(i)); Q_ASSERT(&element); // We find the hrefs that are relative and contain an href. @@ -237,10 +237,10 @@ void AnchorUpdates::UpdateAllAnchorsInOneFile(HTMLResource *html_resource, } -void AnchorUpdates::UpdateTOCEntries(NCXResource *ncx_resource, const QString &originating_filename, const QList< HTMLResource * > new_files) +void AnchorUpdates::UpdateTOCEntries(NCXResource *ncx_resource, const QString &originating_filename, const QList new_files) { Q_ASSERT(ncx_resource); - const QHash< QString, QString > &ID_locations = GetIDLocations(new_files); + const QHash &ID_locations = GetIDLocations(new_files); QWriteLocker locker(&ncx_resource->GetLock()); shared_ptr d = XhtmlDoc::LoadTextIntoDocument(ncx_resource->GetText()); xc::DOMDocument &document = *d.get(); @@ -248,7 +248,7 @@ void AnchorUpdates::UpdateTOCEntries(NCXResource *ncx_resource, const QString &o QString original_filename_with_relative_path = TEXT_FOLDER_NAME % "/" % originating_filename; for (uint i = 0; i < anchors->getLength(); ++i) { - xc::DOMElement &element = *static_cast< xc::DOMElement * >(anchors->item(i)); + xc::DOMElement &element = *static_cast(anchors->item(i)); Q_ASSERT(&element); // We're only interested in src links of the form "originating_filename#fragment_id". diff --git a/src/Sigil/SourceUpdates/AnchorUpdates.h b/src/Sigil/SourceUpdates/AnchorUpdates.h index 736aaabfb4..b332c3f67d 100644 --- a/src/Sigil/SourceUpdates/AnchorUpdates.h +++ b/src/Sigil/SourceUpdates/AnchorUpdates.h @@ -31,7 +31,7 @@ class AnchorUpdates public: - static void UpdateAllAnchorsWithIDs(const QList< HTMLResource * > &html_resources); + static void UpdateAllAnchorsWithIDs(const QList &html_resources); /** * Updates the anchors in html_resources that point to ids that were originally located in originating_filename @@ -41,7 +41,7 @@ class AnchorUpdates * @param originating_filename The name of the original file for which references need to be reconciled. * @param new_files A list of the new files created by splitting the originating_filename. */ - static void UpdateExternalAnchors(const QList< HTMLResource * > &html_resources, const QString &originating_filename, const QList< HTMLResource * > new_files); + static void UpdateExternalAnchors(const QList &html_resources, const QString &originating_filename, const QList new_files); /** * Updates the anchors in html_resources that point to ids that were originally located in originating_filenames @@ -51,7 +51,7 @@ class AnchorUpdates * @param originating_filenames The names of the original files for which references need to be reconciled. * @param new_file The new file created by merging the original files. */ - static void UpdateAllAnchors(const QList< HTMLResource * > &html_resources, const QStringList &originating_filenames, HTMLResource *new_file); + static void UpdateAllAnchors(const QList &html_resources, const QStringList &originating_filenames, HTMLResource *new_file); /** * Updates the src attributes of the content tags in the toc.ncx file that point to @@ -62,20 +62,20 @@ class AnchorUpdates * @param originating_filename The name of the original file for which references need to be reconciled. * @param new_files A list of the new files created by splitting the originating_filename. */ - static void UpdateTOCEntries(NCXResource *ncx_resource, const QString &originating_filename, const QList< HTMLResource * > new_files); + static void UpdateTOCEntries(NCXResource *ncx_resource, const QString &originating_filename, const QList new_files); private: - static QHash< QString, QString > GetIDLocations(const QList< HTMLResource * > &html_resources); + static QHash GetIDLocations(const QList &html_resources); - static tuple< QString, QList< QString > > GetOneFileIDs(HTMLResource *html_resource); + static tuple> GetOneFileIDs(HTMLResource *html_resource); static void UpdateAnchorsInOneFile(HTMLResource *html_resource, - const QHash< QString, QString > ID_locations); + const QHash ID_locations); - static void UpdateExternalAnchorsInOneFile(HTMLResource *html_resource, const QString &originating_filename, const QHash< QString, QString > ID_locations); + static void UpdateExternalAnchorsInOneFile(HTMLResource *html_resource, const QString &originating_filename, const QHash ID_locations); - static void UpdateAllAnchorsInOneFile(HTMLResource *html_resource, const QList< QString > &originating_filename_links, const QHash< QString, QString > ID_locations, const QString &new_filename); + static void UpdateAllAnchorsInOneFile(HTMLResource *html_resource, const QList &originating_filename_links, const QHash ID_locations, const QString &new_filename); }; #endif // ANCHORUPDATES_H diff --git a/src/Sigil/SourceUpdates/LinkUpdates.cpp b/src/Sigil/SourceUpdates/LinkUpdates.cpp index 53e8d2194f..9539bc7761 100644 --- a/src/Sigil/SourceUpdates/LinkUpdates.cpp +++ b/src/Sigil/SourceUpdates/LinkUpdates.cpp @@ -38,7 +38,7 @@ using boost::shared_ptr; static QString HTML_XML_NAMESPACE = "http://www.w3.org/1999/xhtml"; -void LinkUpdates::UpdateLinksInAllFiles(const QList< HTMLResource * > &html_resources, const QList new_stylesheets) +void LinkUpdates::UpdateLinksInAllFiles(const QList &html_resources, const QList new_stylesheets) { QtConcurrent::blockingMap(html_resources, boost::bind(UpdateLinksInOneFile, _1, new_stylesheets)); } @@ -51,7 +51,7 @@ void LinkUpdates::UpdateLinksInOneFile(HTMLResource *html_resource, QList(heads->item(0)); + xc::DOMElement &head_element = *static_cast(heads->item(0)); // We only want links in the head xc::DOMNodeList *links = head_element.getElementsByTagName(QtoX("link")); // Remove the old stylesheet links @@ -60,7 +60,7 @@ void LinkUpdates::UpdateLinksInOneFile(HTMLResource *html_resource, QList(links->item(0)); + xc::DOMElement &element = *static_cast(links->item(0)); Q_ASSERT(&element); if (element.hasAttribute(QtoX("type")) && diff --git a/src/Sigil/SourceUpdates/LinkUpdates.h b/src/Sigil/SourceUpdates/LinkUpdates.h index f7d2af93cd..f95cd69e6f 100644 --- a/src/Sigil/SourceUpdates/LinkUpdates.h +++ b/src/Sigil/SourceUpdates/LinkUpdates.h @@ -39,7 +39,7 @@ class LinkUpdates * @param new_stylesheets A list of the new links to add */ - static void UpdateLinksInAllFiles(const QList< HTMLResource * > &html_resources, const QList new_stylesheets); + static void UpdateLinksInAllFiles(const QList &html_resources, const QList new_stylesheets); private: diff --git a/src/Sigil/SourceUpdates/PerformCSSUpdates.cpp b/src/Sigil/SourceUpdates/PerformCSSUpdates.cpp index 2d57eef77b..b6e933aac3 100644 --- a/src/Sigil/SourceUpdates/PerformCSSUpdates.cpp +++ b/src/Sigil/SourceUpdates/PerformCSSUpdates.cpp @@ -26,7 +26,7 @@ #include "SourceUpdates/PerformCSSUpdates.h" -PerformCSSUpdates::PerformCSSUpdates(const QString &source, const QHash< QString, QString > &css_updates) +PerformCSSUpdates::PerformCSSUpdates(const QString &source, const QHash &css_updates) : m_Source(source), m_CSSUpdates(css_updates) @@ -36,7 +36,7 @@ PerformCSSUpdates::PerformCSSUpdates(const QString &source, const QHash< QString QString PerformCSSUpdates::operator()() { - const QList< QString > &keys = m_CSSUpdates.keys(); + const QList &keys = m_CSSUpdates.keys(); int num_keys = keys.count(); for (int i = 0; i < num_keys; ++i) { @@ -47,15 +47,15 @@ QString PerformCSSUpdates::operator()() + QRegularExpression::escape(filename) + "|" + QRegularExpression::escape(filename); QRegularExpression reference( - "(?:(?:src|background|background-image)\\s*:|@import)\\s*" - "[^;\\}\\(\"']*" - "(?:" - "url\\([\"']?(" + filename_regex_part + ")[\"']?\\)" - "|" - "[\"'](" + filename_regex_part + ")[\"']" - ")" - "[^;\\}]*" - "(?:;|\\})"); + "(?:(?:src|background|background-image)\\s*:|@import)\\s*" + "[^;\\}\\(\"']*" + "(?:" + "url\\([\"']?(" + filename_regex_part + ")[\"']?\\)" + "|" + "[\"'](" + filename_regex_part + ")[\"']" + ")" + "[^;\\}]*" + "(?:;|\\})"); int start_index = 0; QRegularExpressionMatch mo = reference.match(m_Source, start_index); do { diff --git a/src/Sigil/SourceUpdates/PerformCSSUpdates.h b/src/Sigil/SourceUpdates/PerformCSSUpdates.h index f86032e1bc..50c065015e 100644 --- a/src/Sigil/SourceUpdates/PerformCSSUpdates.h +++ b/src/Sigil/SourceUpdates/PerformCSSUpdates.h @@ -32,7 +32,7 @@ class PerformCSSUpdates public: - PerformCSSUpdates(const QString &source, const QHash< QString, QString > &css_updates); + PerformCSSUpdates(const QString &source, const QHash &css_updates); QString operator()(); @@ -44,7 +44,7 @@ class PerformCSSUpdates QString m_Source; - const QHash< QString, QString > &m_CSSUpdates; + const QHash &m_CSSUpdates; }; #endif // PERFORMCSSUPDATES_H diff --git a/src/Sigil/SourceUpdates/PerformHTMLUpdates.cpp b/src/Sigil/SourceUpdates/PerformHTMLUpdates.cpp index c0ef69ea0c..299944b342 100644 --- a/src/Sigil/SourceUpdates/PerformHTMLUpdates.cpp +++ b/src/Sigil/SourceUpdates/PerformHTMLUpdates.cpp @@ -26,8 +26,8 @@ PerformHTMLUpdates::PerformHTMLUpdates(const QString &source, - const QHash< QString, QString > &html_updates, - const QHash< QString, QString > &css_updates) + const QHash &html_updates, + const QHash &css_updates) : PerformXMLUpdates(source, html_updates), m_CSSUpdates(css_updates) @@ -37,8 +37,8 @@ PerformHTMLUpdates::PerformHTMLUpdates(const QString &source, PerformHTMLUpdates::PerformHTMLUpdates(const xc::DOMDocument &document, - const QHash< QString, QString > &html_updates, - const QHash< QString, QString > &css_updates) + const QHash &html_updates, + const QHash &css_updates) : PerformXMLUpdates(document, html_updates), m_CSSUpdates(css_updates) @@ -47,7 +47,7 @@ PerformHTMLUpdates::PerformHTMLUpdates(const xc::DOMDocument &document, } -shared_ptr< xc::DOMDocument > PerformHTMLUpdates::operator()() +shared_ptr PerformHTMLUpdates::operator()() { UpdateXMLReferences(); diff --git a/src/Sigil/SourceUpdates/PerformHTMLUpdates.h b/src/Sigil/SourceUpdates/PerformHTMLUpdates.h index 4230aaa5c8..1f105d093c 100644 --- a/src/Sigil/SourceUpdates/PerformHTMLUpdates.h +++ b/src/Sigil/SourceUpdates/PerformHTMLUpdates.h @@ -31,14 +31,14 @@ class PerformHTMLUpdates : public PerformXMLUpdates public: PerformHTMLUpdates(const QString &source, - const QHash< QString, QString > &html_updates, - const QHash< QString, QString > &css_updates); + const QHash &html_updates, + const QHash &css_updates); PerformHTMLUpdates(const xc::DOMDocument &document, - const QHash< QString, QString > &html_updates, - const QHash< QString, QString > &css_updates); + const QHash &html_updates, + const QHash &css_updates); - shared_ptr< xc::DOMDocument > operator()(); + shared_ptr operator()(); private: @@ -49,7 +49,7 @@ class PerformHTMLUpdates : public PerformXMLUpdates // PRIVATE MEMBER VARIABLES /////////////////////////////// - const QHash< QString, QString > &m_CSSUpdates; + const QHash &m_CSSUpdates; }; #endif // PERFORMHTMLUPDATES_H diff --git a/src/Sigil/SourceUpdates/PerformNCXUpdates.cpp b/src/Sigil/SourceUpdates/PerformNCXUpdates.cpp index 91e5b3160a..d54307a4d9 100644 --- a/src/Sigil/SourceUpdates/PerformNCXUpdates.cpp +++ b/src/Sigil/SourceUpdates/PerformNCXUpdates.cpp @@ -22,7 +22,7 @@ #include "SourceUpdates/PerformNCXUpdates.h" PerformNCXUpdates::PerformNCXUpdates(const QString &source, - const QHash< QString, QString > &xml_updates) + const QHash &xml_updates) : PerformXMLUpdates(source, xml_updates) { InitPathTags(); @@ -30,7 +30,7 @@ PerformNCXUpdates::PerformNCXUpdates(const QString &source, PerformNCXUpdates::PerformNCXUpdates(const xc::DOMDocument &document, - const QHash< QString, QString > &xml_updates) + const QHash &xml_updates) : PerformXMLUpdates(document, xml_updates) { InitPathTags(); diff --git a/src/Sigil/SourceUpdates/PerformNCXUpdates.h b/src/Sigil/SourceUpdates/PerformNCXUpdates.h index af0fea81f3..cfba4c0c42 100644 --- a/src/Sigil/SourceUpdates/PerformNCXUpdates.h +++ b/src/Sigil/SourceUpdates/PerformNCXUpdates.h @@ -31,10 +31,10 @@ class PerformNCXUpdates : public PerformXMLUpdates public: PerformNCXUpdates(const QString &source, - const QHash< QString, QString > &xml_updates); + const QHash &xml_updates); PerformNCXUpdates(const xc::DOMDocument &document, - const QHash< QString, QString > &xml_updates); + const QHash &xml_updates); private: diff --git a/src/Sigil/SourceUpdates/PerformOPFUpdates.cpp b/src/Sigil/SourceUpdates/PerformOPFUpdates.cpp index 0eff0ee777..ecc12cca76 100644 --- a/src/Sigil/SourceUpdates/PerformOPFUpdates.cpp +++ b/src/Sigil/SourceUpdates/PerformOPFUpdates.cpp @@ -24,7 +24,7 @@ #include "SourceUpdates/PerformOPFUpdates.h" PerformOPFUpdates::PerformOPFUpdates(const QString &source, - const QHash< QString, QString > &xml_updates) + const QHash &xml_updates) : PerformXMLUpdates(source, xml_updates) { InitPathTags(); @@ -32,7 +32,7 @@ PerformOPFUpdates::PerformOPFUpdates(const QString &source, PerformOPFUpdates::PerformOPFUpdates(const xc::DOMDocument &document, - const QHash< QString, QString > &xml_updates) + const QHash &xml_updates) : PerformXMLUpdates(document, xml_updates) { InitPathTags(); diff --git a/src/Sigil/SourceUpdates/PerformOPFUpdates.h b/src/Sigil/SourceUpdates/PerformOPFUpdates.h index 2d8d062406..ab223b99de 100644 --- a/src/Sigil/SourceUpdates/PerformOPFUpdates.h +++ b/src/Sigil/SourceUpdates/PerformOPFUpdates.h @@ -31,10 +31,10 @@ class PerformOPFUpdates : public PerformXMLUpdates public: PerformOPFUpdates(const QString &source, - const QHash< QString, QString > &xml_updates); + const QHash &xml_updates); PerformOPFUpdates(const xc::DOMDocument &document, - const QHash< QString, QString > &xml_updates); + const QHash &xml_updates); private: diff --git a/src/Sigil/SourceUpdates/PerformXMLUpdates.cpp b/src/Sigil/SourceUpdates/PerformXMLUpdates.cpp index 0d0ba0c1a8..bf8669cca4 100644 --- a/src/Sigil/SourceUpdates/PerformXMLUpdates.cpp +++ b/src/Sigil/SourceUpdates/PerformXMLUpdates.cpp @@ -35,7 +35,7 @@ static const QString DOT = "."; static const QString DOT_DOT = ".."; PerformXMLUpdates::PerformXMLUpdates(const QString &source, - const QHash< QString, QString > &xml_updates) + const QHash &xml_updates) : m_XMLUpdates(xml_updates) { @@ -45,7 +45,7 @@ PerformXMLUpdates::PerformXMLUpdates(const QString &source, PerformXMLUpdates::PerformXMLUpdates(const xc::DOMDocument &document, - const QHash< QString, QString > &xml_updates) + const QHash &xml_updates) : m_XMLUpdates(xml_updates) { @@ -54,7 +54,7 @@ PerformXMLUpdates::PerformXMLUpdates(const xc::DOMDocument &document, } -shared_ptr< xc::DOMDocument > PerformXMLUpdates::operator()() +shared_ptr PerformXMLUpdates::operator()() { UpdateXMLReferences(); return m_Document; @@ -69,7 +69,7 @@ void PerformXMLUpdates::UpdateXMLReferences() boost_throw(ErrorBuildingDOM()); } - QList< xc::DOMElement * > nodes = XhtmlDoc::GetTagMatchingDescendants(*document_element, m_PathTags); + QList nodes = XhtmlDoc::GetTagMatchingDescendants(*document_element, m_PathTags); int node_count = nodes.count(); for (int i = 0; i < node_count; ++i) { @@ -85,11 +85,11 @@ void PerformXMLUpdates::UpdateReferenceInNode(xc::DOMElement *node) { xc::DOMNamedNodeMap &attributes = *node->getAttributes(); int num_attributes = attributes.getLength(); - const QList< QString > &keys = m_XMLUpdates.keys(); + const QList &keys = m_XMLUpdates.keys(); int num_keys = keys.count(); for (int i = 0; i < num_attributes; ++i) { - xc::DOMAttr &attribute = *static_cast< xc::DOMAttr * >(attributes.item(i)); + xc::DOMAttr &attribute = *static_cast(attributes.item(i)); Q_ASSERT(&attribute); if (!m_PathAttributes.contains(XhtmlDoc::GetAttributeName(attribute), Qt::CaseInsensitive)) { diff --git a/src/Sigil/SourceUpdates/PerformXMLUpdates.h b/src/Sigil/SourceUpdates/PerformXMLUpdates.h index 28a01a96f4..14ce58ae22 100644 --- a/src/Sigil/SourceUpdates/PerformXMLUpdates.h +++ b/src/Sigil/SourceUpdates/PerformXMLUpdates.h @@ -50,7 +50,7 @@ class PerformXMLUpdates * @param xml_updates The path updates. */ PerformXMLUpdates(const QString &source, - const QHash< QString, QString > &xml_updates); + const QHash &xml_updates); /** * Constructor. @@ -59,14 +59,14 @@ class PerformXMLUpdates * @param xml_updates The path updates. */ PerformXMLUpdates(const xc::DOMDocument &document, - const QHash< QString, QString > &xml_updates); + const QHash &xml_updates); /** * Performs the updates. * * @return The updated DOM of the provided XML file. */ - virtual shared_ptr< xc::DOMDocument > operator()(); + virtual shared_ptr operator()(); protected: @@ -93,7 +93,7 @@ class PerformXMLUpdates /** * The parsed DOM document */ - shared_ptr< xc::DOMDocument > m_Document; + shared_ptr m_Document; private: @@ -117,7 +117,7 @@ class PerformXMLUpdates * The updates that need to be performed. Keys are old paths, * values are new paths. */ - const QHash< QString, QString > &m_XMLUpdates; + const QHash &m_XMLUpdates; }; #endif // PERFORMXMLUPDATES_H diff --git a/src/Sigil/SourceUpdates/UniversalUpdates.cpp b/src/Sigil/SourceUpdates/UniversalUpdates.cpp index ca321de4d6..8167405f00 100644 --- a/src/Sigil/SourceUpdates/UniversalUpdates.cpp +++ b/src/Sigil/SourceUpdates/UniversalUpdates.cpp @@ -54,16 +54,16 @@ using boost::tuple; #define NON_WELL_FORMED_MESSAGE "Cannot perform HTML updates since the file is not well formed" QStringList UniversalUpdates::PerformUniversalUpdates(bool resources_already_loaded, - const QList< Resource * > &resources, - const QHash< QString, QString > &updates, + const QList &resources, + const QHash &updates, const QList &non_well_formed) { - QHash< QString, QString > html_updates; - QHash< QString, QString > css_updates; - QHash< QString, QString > xml_updates; + QHash html_updates; + QHash css_updates; + QHash xml_updates; tie(html_updates, css_updates, xml_updates) = SeparateHtmlCssXmlUpdates(updates); - QList< HTMLResource * > html_resources; - QList< CSSResource * > css_resources; + QList html_resources; + QList css_resources; OPFResource *opf_resource = NULL; NCXResource *ncx_resource = NULL; int num_files = resources.count(); @@ -72,19 +72,19 @@ QStringList UniversalUpdates::PerformUniversalUpdates(bool resources_already_loa Resource *resource = resources.at(i); if (resource->Type() == Resource::HTMLResourceType) { - html_resources.append(qobject_cast< HTMLResource * >(resource)); + html_resources.append(qobject_cast(resource)); } else if (resource->Type() == Resource::CSSResourceType) { - css_resources.append(qobject_cast< CSSResource * >(resource)); + css_resources.append(qobject_cast(resource)); } else if (resource->Type() == Resource::OPFResourceType) { - opf_resource = qobject_cast< OPFResource * >(resource); + opf_resource = qobject_cast(resource); } else if (resource->Type() == Resource::NCXResourceType) { - ncx_resource = qobject_cast< NCXResource * >(resource); + ncx_resource = qobject_cast(resource); } } QFutureSynchronizer sync; - QFuture< QString > html_future; - QFuture< void > css_future; + QFuture html_future; + QFuture css_future; if (resources_already_loaded) { html_future = QtConcurrent::mapped(html_resources, boost::bind(UpdateOneHTMLFile, _1, html_updates, css_updates)); @@ -126,15 +126,15 @@ QStringList UniversalUpdates::PerformUniversalUpdates(bool resources_already_loa } -tuple < QHash< QString, QString >, - QHash< QString, QString >, - QHash< QString, QString > > - UniversalUpdates::SeparateHtmlCssXmlUpdates(const QHash< QString, QString > &updates) +tuple , + QHash, + QHash> + UniversalUpdates::SeparateHtmlCssXmlUpdates(const QHash &updates) { - QHash< QString, QString > html_updates = updates; - QHash< QString, QString > css_updates; - QHash< QString, QString > xml_updates; - QList< QString > keys = updates.keys(); + QHash html_updates = updates; + QHash css_updates; + QHash xml_updates; + QList keys = updates.keys(); int num_keys = keys.count(); for (int i = 0; i < num_keys; ++i) { @@ -162,8 +162,8 @@ tuple < QHash< QString, QString >, QString UniversalUpdates::UpdateOneHTMLFile(HTMLResource *html_resource, - const QHash< QString, QString > &html_updates, - const QHash< QString, QString > &css_updates) + const QHash &html_updates, + const QHash &css_updates) { if (!html_resource) { return QString(); @@ -185,7 +185,7 @@ QString UniversalUpdates::UpdateOneHTMLFile(HTMLResource *html_resource, void UniversalUpdates::UpdateOneCSSFile(CSSResource *css_resource, - const QHash< QString, QString > &css_updates) + const QHash &css_updates) { if (!css_resource) { return; @@ -197,8 +197,8 @@ void UniversalUpdates::UpdateOneCSSFile(CSSResource *css_resource, } QString UniversalUpdates::LoadAndUpdateOneHTMLFile(HTMLResource *html_resource, - const QHash< QString, QString > &html_updates, - const QHash< QString, QString > &css_updates, + const QHash &html_updates, + const QHash &css_updates, const QList &non_well_formed) { SettingsStore ss; @@ -249,7 +249,7 @@ QString UniversalUpdates::LoadAndUpdateOneHTMLFile(HTMLResource *html_resource, void UniversalUpdates::LoadAndUpdateOneCSSFile(CSSResource *css_resource, - const QHash< QString, QString > &css_updates) + const QHash &css_updates) { if (!css_resource) { return; @@ -262,7 +262,7 @@ void UniversalUpdates::LoadAndUpdateOneCSSFile(CSSResource *css_resource, QString UniversalUpdates::UpdateOPFFile(OPFResource *opf_resource, - const QHash< QString, QString > &xml_updates) + const QHash &xml_updates) { if (!opf_resource) { return QString(); @@ -272,7 +272,7 @@ QString UniversalUpdates::UpdateOPFFile(OPFResource *opf_resource, const QString &source = opf_resource->GetText(); try { - shared_ptr< xc::DOMDocument > document = PerformOPFUpdates(source, xml_updates)(); + shared_ptr document = PerformOPFUpdates(source, xml_updates)(); opf_resource->SetText(XhtmlDoc::GetDomDocumentAsString(*document.get())); return QString(); } catch (const ErrorBuildingDOM &) { @@ -285,7 +285,7 @@ QString UniversalUpdates::UpdateOPFFile(OPFResource *opf_resource, QString UniversalUpdates::UpdateNCXFile(NCXResource *ncx_resource, - const QHash< QString, QString > &xml_updates) + const QHash &xml_updates) { if (!ncx_resource) { return QString(); @@ -295,7 +295,7 @@ QString UniversalUpdates::UpdateNCXFile(NCXResource *ncx_resource, const QString &source = ncx_resource->GetText(); try { - shared_ptr< xc::DOMDocument > document = PerformNCXUpdates(source, xml_updates)(); + shared_ptr document = PerformNCXUpdates(source, xml_updates)(); ncx_resource->SetText(CleanSource::PrettifyDOCTYPEHeader(XhtmlDoc::GetDomDocumentAsString(*document.get()))); return QString(); } catch (const ErrorBuildingDOM &) { diff --git a/src/Sigil/SourceUpdates/UniversalUpdates.h b/src/Sigil/SourceUpdates/UniversalUpdates.h index 466b1e6f5f..aee042ab90 100644 --- a/src/Sigil/SourceUpdates/UniversalUpdates.h +++ b/src/Sigil/SourceUpdates/UniversalUpdates.h @@ -38,37 +38,37 @@ class UniversalUpdates // Returns a list of errors if any that occurred while loading. static QStringList PerformUniversalUpdates(bool resources_already_loaded, - const QList< Resource * > &resources, - const QHash< QString, QString > &updates, + const QList &resources, + const QHash &updates, const QList &non_well_formed=QList()); - static tuple < QHash< QString, QString >, - QHash< QString, QString >, - QHash< QString, QString > > SeparateHtmlCssXmlUpdates(const QHash< QString, QString > &updates); + static tuple , + QHash, + QHash> SeparateHtmlCssXmlUpdates(const QHash &updates); // Made public so that ImportHTML can use it static void LoadAndUpdateOneCSSFile(CSSResource *css_resource, - const QHash< QString, QString > &css_updates); + const QHash &css_updates); private: static QString UpdateOneHTMLFile(HTMLResource *html_resource, - const QHash< QString, QString > &html_updates, - const QHash< QString, QString > &css_updates); + const QHash &html_updates, + const QHash &css_updates); static void UpdateOneCSSFile(CSSResource *css_resource, - const QHash< QString, QString > &css_updates); + const QHash &css_updates); static QString LoadAndUpdateOneHTMLFile(HTMLResource *html_resource, - const QHash< QString, QString > &html_updates, - const QHash< QString, QString > &css_updates, + const QHash &html_updates, + const QHash &css_updates, const QList &non_well_formed=QList()); static QString UpdateOPFFile(OPFResource *opf_resource, - const QHash< QString, QString > &xml_updates); + const QHash &xml_updates); static QString UpdateNCXFile(NCXResource *ncx_resource, - const QHash< QString, QString > &xml_updates); + const QHash &xml_updates); }; #endif // UNIVERSALUPDATES_H diff --git a/src/Sigil/SourceUpdates/WordUpdates.cpp b/src/Sigil/SourceUpdates/WordUpdates.cpp index bebe0e2879..a5740ca0bf 100644 --- a/src/Sigil/SourceUpdates/WordUpdates.cpp +++ b/src/Sigil/SourceUpdates/WordUpdates.cpp @@ -29,7 +29,7 @@ #include "ResourceObjects/HTMLResource.h" #include "SourceUpdates/WordUpdates.h" -void WordUpdates::UpdateWordInAllFiles(const QList< HTMLResource * > &html_resources, const QString old_word, QString new_word) +void WordUpdates::UpdateWordInAllFiles(const QList &html_resources, const QString old_word, QString new_word) { QtConcurrent::blockingMap(html_resources, boost::bind(UpdateWordsInOneFile, _1, old_word, new_word)); } @@ -39,8 +39,8 @@ void WordUpdates::UpdateWordsInOneFile(HTMLResource *html_resource, QString old_ Q_ASSERT(html_resource); QWriteLocker locker(&html_resource->GetLock()); QString text = html_resource->GetText(); - QList< HTMLSpellCheck::MisspelledWord > words = HTMLSpellCheck::GetWords(text); - + QList words = HTMLSpellCheck::GetWords(text); + // Change in reverse to preserve location information for (int i = words.count() - 1; i >= 0; i--) { HTMLSpellCheck::MisspelledWord word = words[i]; diff --git a/src/Sigil/SourceUpdates/WordUpdates.h b/src/Sigil/SourceUpdates/WordUpdates.h index f0eeaf3ebd..0b4b12fcc1 100644 --- a/src/Sigil/SourceUpdates/WordUpdates.h +++ b/src/Sigil/SourceUpdates/WordUpdates.h @@ -30,7 +30,7 @@ class WordUpdates public: - static void UpdateWordInAllFiles(const QList< HTMLResource * > &html_resources, const QString old_word, QString new_word); + static void UpdateWordInAllFiles(const QList &html_resources, const QString old_word, QString new_word); private: static void UpdateWordsInOneFile(HTMLResource *html_resource, QString old_word, QString new_word); diff --git a/src/Sigil/Tabs/AVTab.cpp b/src/Sigil/Tabs/AVTab.cpp index afc35b2142..e8fb7fe937 100644 --- a/src/Sigil/Tabs/AVTab.cpp +++ b/src/Sigil/Tabs/AVTab.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** -** Copyright (C) 2012 John Schember +** Copyright (C) 2012 John Schember ** ** This file is part of Sigil. ** diff --git a/src/Sigil/Tabs/AVTab.h b/src/Sigil/Tabs/AVTab.h index 7f0ab3dddf..b4325e7352 100644 --- a/src/Sigil/Tabs/AVTab.h +++ b/src/Sigil/Tabs/AVTab.h @@ -1,6 +1,6 @@ /************************************************************************ ** -** Copyright (C) 2012 John Schember +** Copyright (C) 2012 John Schember ** ** This file is part of Sigil. ** diff --git a/src/Sigil/Tabs/ContentTab.h b/src/Sigil/Tabs/ContentTab.h index 2e533428a0..eb3ee287d6 100644 --- a/src/Sigil/Tabs/ContentTab.h +++ b/src/Sigil/Tabs/ContentTab.h @@ -314,7 +314,7 @@ class ContentTab : public QWidget, public Zoomable return ""; } - virtual bool MarkSelection() { + virtual bool MarkSelection() { return false; } diff --git a/src/Sigil/Tabs/FlowTab.cpp b/src/Sigil/Tabs/FlowTab.cpp index 07977145a5..4a45b65064 100644 --- a/src/Sigil/Tabs/FlowTab.cpp +++ b/src/Sigil/Tabs/FlowTab.cpp @@ -662,7 +662,7 @@ bool FlowTab::ViewStatesEnabled() return false; } -void FlowTab::GoToCaretLocation(QList< ViewEditor::ElementIndex > location) +void FlowTab::GoToCaretLocation(QList location) { if (location.isEmpty()) { return; @@ -670,19 +670,17 @@ void FlowTab::GoToCaretLocation(QList< ViewEditor::ElementIndex > location) if (m_ViewState == MainWindow::ViewState_BookView) { m_wBookView->StoreCaretLocationUpdate(location); m_wBookView->ExecuteCaretUpdate(); - } - else if (m_ViewState == MainWindow::ViewState_CodeView) { + } else if (m_ViewState == MainWindow::ViewState_CodeView) { m_wCodeView->StoreCaretLocationUpdate(location); m_wCodeView->ExecuteCaretUpdate(); } } -QList< ViewEditor::ElementIndex > FlowTab::GetCaretLocation() +QList FlowTab::GetCaretLocation() { if (m_ViewState == MainWindow::ViewState_BookView) { return m_wBookView->GetCaretLocation(); - } - else if (m_ViewState == MainWindow::ViewState_CodeView) { + } else if (m_ViewState == MainWindow::ViewState_CodeView) { return m_wCodeView->GetCaretLocation(); } @@ -711,8 +709,7 @@ QString FlowTab::GetText() { if (m_ViewState == MainWindow::ViewState_CodeView) { return m_wCodeView->toPlainText(); - } - else if (m_ViewState == MainWindow::ViewState_BookView) { + } else if (m_ViewState == MainWindow::ViewState_BookView) { return m_wBookView->GetHtml(); } @@ -1454,8 +1451,7 @@ bool FlowTab::PasteClipNumber(int clip_number) { if (m_ViewState == MainWindow::ViewState_BookView) { return m_wBookView->PasteClipNumber(clip_number); - } - else if (m_ViewState == MainWindow::ViewState_CodeView) { + } else if (m_ViewState == MainWindow::ViewState_CodeView) { return m_wCodeView->PasteClipNumber(clip_number); } return false; @@ -1465,8 +1461,7 @@ bool FlowTab::PasteClipEntries(QListclips) { if (m_ViewState == MainWindow::ViewState_BookView) { return m_wBookView->PasteClipEntries(clips); - } - else if (m_ViewState == MainWindow::ViewState_CodeView) { + } else if (m_ViewState == MainWindow::ViewState_CodeView) { return m_wCodeView->PasteClipEntries(clips); } return false; diff --git a/src/Sigil/Tabs/FlowTab.h b/src/Sigil/Tabs/FlowTab.h index c0777ba12b..4e2ae5e4fe 100644 --- a/src/Sigil/Tabs/FlowTab.h +++ b/src/Sigil/Tabs/FlowTab.h @@ -107,9 +107,9 @@ class FlowTab : public ContentTab, public WellFormedContent bool ViewStatesEnabled(); - QList< ViewEditor::ElementIndex > GetCaretLocation(); + QList GetCaretLocation(); QString GetCaretLocationUpdate() const; - void GoToCaretLocation(QList< ViewEditor::ElementIndex > location); + void GoToCaretLocation(QList location); QString GetDisplayedCharacters(); QString GetText(); diff --git a/src/Sigil/Tabs/TabManager.cpp b/src/Sigil/Tabs/TabManager.cpp index e2a0736cba..ba4bf9ce19 100644 --- a/src/Sigil/Tabs/TabManager.cpp +++ b/src/Sigil/Tabs/TabManager.cpp @@ -64,7 +64,7 @@ ContentTab &TabManager::GetCurrentContentTab() // TODO: turn on this assert after you make sure a tab // is created before this is called in MainWindow constructor //Q_ASSERT( widget != NULL ); - return *qobject_cast< ContentTab * >(widget); + return *qobject_cast(widget); } QList TabManager::GetContentTabs() @@ -163,7 +163,7 @@ void TabManager::ReopenTabs(MainWindow::ViewState view_state) void TabManager::SaveTabData() { for (int i = 0; i < count(); ++i) { - ContentTab *tab = qobject_cast< ContentTab * >(widget(i)); + ContentTab *tab = qobject_cast(widget(i)); if (tab) { tab->SaveTabContent(); @@ -301,11 +301,11 @@ void TabManager::MakeCentralTab(ContentTab *tab) void TabManager::EmitTabChanged() { - ContentTab *current_tab = qobject_cast< ContentTab * >(currentWidget()); + ContentTab *current_tab = qobject_cast(currentWidget()); if (m_LastContentTab.data() != current_tab) { emit TabChanged(m_LastContentTab.data(), current_tab); - m_LastContentTab = QPointer< ContentTab >(current_tab); + m_LastContentTab = QPointer(current_tab); } } @@ -351,7 +351,7 @@ void TabManager::SetFocusInTab() WellFormedContent *TabManager::GetWellFormedContent(int index) { - return dynamic_cast< WellFormedContent * >(widget(index)); + return dynamic_cast(widget(index)); } @@ -363,7 +363,7 @@ int TabManager::ResourceTabIndex(const Resource &resource) const int index = -1; for (int i = 0; i < count(); ++i) { - ContentTab *tab = qobject_cast< ContentTab * >(widget(i)); + ContentTab *tab = qobject_cast(widget(i)); if (tab && tab->GetLoadedResource().GetIdentifier() == identifier) { index = i; @@ -390,7 +390,7 @@ bool TabManager::SwitchedToExistingTab(Resource &resource, QWidget *tab = widget(resource_index); Q_ASSERT(tab); tab->setFocus(); - FlowTab *flow_tab = qobject_cast< FlowTab * >(tab); + FlowTab *flow_tab = qobject_cast(tab); if (flow_tab != NULL) { if (!caret_location_to_scroll_to.isEmpty()) { @@ -406,14 +406,14 @@ bool TabManager::SwitchedToExistingTab(Resource &resource, return true; } - TextTab *text_tab = qobject_cast< TextTab * >(tab); + TextTab *text_tab = qobject_cast(tab); if (text_tab != NULL) { text_tab->ScrollToLine(line_to_scroll_to); return true; } - ImageTab *image_tab = qobject_cast< ImageTab * >(tab); + ImageTab *image_tab = qobject_cast(tab); if (image_tab != NULL) { return true; @@ -455,42 +455,42 @@ ContentTab *TabManager::CreateTabForResource(Resource &resource, } case Resource::CSSResourceType: { - tab = new CSSTab(*(qobject_cast< CSSResource * >(&resource)), line_to_scroll_to, this); + tab = new CSSTab(*(qobject_cast(&resource)), line_to_scroll_to, this); break; } case Resource::ImageResourceType: { - tab = new ImageTab(*(qobject_cast< ImageResource * >(&resource)), this); + tab = new ImageTab(*(qobject_cast(&resource)), this); break; } case Resource::MiscTextResourceType: { - tab = new MiscTextTab(*(qobject_cast< MiscTextResource * >(&resource)), line_to_scroll_to, this); + tab = new MiscTextTab(*(qobject_cast(&resource)), line_to_scroll_to, this); break; } case Resource::SVGResourceType: { - tab = new SVGTab(*(qobject_cast< SVGResource * >(&resource)), line_to_scroll_to, this); + tab = new SVGTab(*(qobject_cast(&resource)), line_to_scroll_to, this); break; } case Resource::OPFResourceType: { - tab = new OPFTab(*(qobject_cast< OPFResource * >(&resource)), line_to_scroll_to, this); + tab = new OPFTab(*(qobject_cast(&resource)), line_to_scroll_to, this); break; } case Resource::NCXResourceType: { - tab = new NCXTab(*(qobject_cast< NCXResource * >(&resource)), line_to_scroll_to, this); + tab = new NCXTab(*(qobject_cast(&resource)), line_to_scroll_to, this); break; } case Resource::XMLResourceType: { - tab = new XMLTab(*(qobject_cast< XMLResource * >(&resource)), line_to_scroll_to, this); + tab = new XMLTab(*(qobject_cast(&resource)), line_to_scroll_to, this); break; } case Resource::TextResourceType: { - tab = new TextTab(*(qobject_cast< TextResource * >(&resource)), CodeViewEditor::Highlight_NONE, line_to_scroll_to, this); + tab = new TextTab(*(qobject_cast(&resource)), CodeViewEditor::Highlight_NONE, line_to_scroll_to, this); break; } @@ -505,7 +505,7 @@ ContentTab *TabManager::CreateTabForResource(Resource &resource, } // Set whether to inform or auto correct well-formed errors. - WellFormedContent *wtab = dynamic_cast< WellFormedContent * >(tab); + WellFormedContent *wtab = dynamic_cast(tab); if (wtab) { // In case of well-formed errors we want the tab to be focused. diff --git a/src/Sigil/Tabs/TabManager.h b/src/Sigil/Tabs/TabManager.h index d81de56204..230b4dbf01 100644 --- a/src/Sigil/Tabs/TabManager.h +++ b/src/Sigil/Tabs/TabManager.h @@ -285,7 +285,7 @@ private slots: * Stores a reference to the tab used before the current one. * Needed for the TabChanged signal. */ - QPointer< ContentTab > m_LastContentTab; + QPointer m_LastContentTab; bool m_CheckWellFormedErrors; diff --git a/src/Sigil/ViewEditors/BookViewEditor.cpp b/src/Sigil/ViewEditors/BookViewEditor.cpp index ea29c8146e..755b217e78 100644 --- a/src/Sigil/ViewEditors/BookViewEditor.cpp +++ b/src/Sigil/ViewEditors/BookViewEditor.cpp @@ -634,11 +634,11 @@ void BookViewEditor::paste() { QClipboard *clipboard = QApplication::clipboard(); - if (clipboard->mimeData()->hasHtml()) { + if (clipboard->mimeData()->hasHtml()) { QMessageBox msgBox(QMessageBox::Question, - tr("Clipboard contains HTML formatting"), - tr("Do you want to paste clipboard data as plain text?"), - QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel); + tr("Clipboard contains HTML formatting"), + tr("Do you want to paste clipboard data as plain text?"), + QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Yes); // populate the detailed text window - by HTML not by the text @@ -646,15 +646,15 @@ void BookViewEditor::paste() // show message box switch (msgBox.exec()) { - case QMessageBox::Yes: - page()->triggerAction(QWebPage::PasteAndMatchStyle); - break; - case QMessageBox::No: - page()->triggerAction(QWebPage::Paste); - break; - default: - // Cancel was clicked - do nothing - break; + case QMessageBox::Yes: + page()->triggerAction(QWebPage::PasteAndMatchStyle); + break; + case QMessageBox::No: + page()->triggerAction(QWebPage::Paste); + break; + default: + // Cancel was clicked - do nothing + break; } } else { page()->triggerAction(QWebPage::Paste); @@ -907,7 +907,7 @@ void BookViewEditor::AddClipContextMenu(QMenu *menu) menu->insertMenu(topAction, clips_menu); } else { menu->addMenu(clips_menu); - } + } CreateMenuEntries(clips_menu, 0, ClipEditorModel::instance()->invisibleRootItem()); diff --git a/src/Sigil/ViewEditors/BookViewPreview.cpp b/src/Sigil/ViewEditors/BookViewPreview.cpp index 87716e08ea..c722922899 100644 --- a/src/Sigil/ViewEditors/BookViewPreview.cpp +++ b/src/Sigil/ViewEditors/BookViewPreview.cpp @@ -346,7 +346,7 @@ void BookViewPreview::UpdateFinishedState(int progress) } else { m_isLoadFinished = false; } -} +} void BookViewPreview::HighlightPosition() { @@ -436,10 +436,10 @@ int BookViewPreview::GetLocalSelectionOffset(bool start_of_selection) } int BookViewPreview::GetSelectionOffset(const xc::DOMDocument &document, - const QMap< int, xc::DOMNode * > &node_offsets, + const QMap &node_offsets, Searchable::Direction search_direction) { - QList< ViewEditor::ElementIndex > cl = GetCaretLocation(); + QList cl = GetCaretLocation(); xc::DOMNode *caret_node = XhtmlDoc::GetNodeFromHierarchy(document, cl); bool searching_down = search_direction == Searchable::Direction_Down ? true : false; int local_offset = GetLocalSelectionOffset(!searching_down); @@ -453,8 +453,8 @@ BookViewPreview::SearchTools BookViewPreview::GetSearchTools() const SearchTools search_tools; search_tools.fulltext = ""; search_tools.document = XhtmlDoc::LoadTextIntoDocument(page()->mainFrame()->toHtml()); - QList< xc::DOMNode * > text_nodes = XhtmlDoc::GetVisibleTextNodes( - *(search_tools.document->getElementsByTagName(QtoX("body"))->item(0))); + QList text_nodes = XhtmlDoc::GetVisibleTextNodes( + *(search_tools.document->getElementsByTagName(QtoX("body"))->item(0))); xc::DOMNode *current_block_ancestor = NULL; // We concatenate all text nodes that have the same @@ -479,7 +479,7 @@ BookViewPreview::SearchTools BookViewPreview::GetSearchTools() const } -QString BookViewPreview::GetElementSelectingJS_NoTextNodes(const QList< ViewEditor::ElementIndex > &hierarchy) const +QString BookViewPreview::GetElementSelectingJS_NoTextNodes(const QList &hierarchy) const { // TODO: see if replacing jQuery with pure JS will speed up // caret location scrolling... note the children()/contents() difference: @@ -509,12 +509,12 @@ QString BookViewPreview::GetElementSelectingJS_NoTextNodes(const QList< ViewEdit return element_selector; } -QList< ViewEditor::ElementIndex > BookViewPreview::GetCaretLocation() +QList BookViewPreview::GetCaretLocation() { // The location element hierarchy encoded in a string QString location_string = EvaluateJavascript(c_GetCaretLocation).toString(); QStringList elements = location_string.split(",", QString::SkipEmptyParts); - QList< ElementIndex > caret_location; + QList caret_location; foreach(QString element, elements) { ElementIndex new_element; new_element.name = element.split(" ")[ 0 ]; @@ -533,7 +533,7 @@ void BookViewPreview::StoreCurrentCaretLocation() } } -void BookViewPreview::StoreCaretLocationUpdate(const QList< ViewEditor::ElementIndex > &hierarchy) +void BookViewPreview::StoreCaretLocationUpdate(const QList &hierarchy) { QString caret_location = "var element = " + GetElementSelectingJS_NoTextNodes(hierarchy) + ";"; // We scroll to the element and center the screen on it @@ -542,7 +542,7 @@ void BookViewPreview::StoreCaretLocationUpdate(const QList< ViewEditor::ElementI m_CaretLocationUpdate = caret_location + scroll + SET_CURSOR_JS; } -QString BookViewPreview::GetElementSelectingJS_WithTextNode(const QList< ViewEditor::ElementIndex > &hierarchy) const +QString BookViewPreview::GetElementSelectingJS_WithTextNode(const QList &hierarchy) const { QString element_selector = "$('html')"; @@ -557,7 +557,7 @@ QString BookViewPreview::GetElementSelectingJS_WithTextNode(const QList< ViewEdi QWebElement BookViewPreview::DomNodeToQWebElement(const xc::DOMNode &node) { - const QList< ViewEditor::ElementIndex > &hierarchy = XhtmlDoc::GetHierarchyFromNode(node); + const QList &hierarchy = XhtmlDoc::GetHierarchyFromNode(node); QWebElement element = page()->mainFrame()->documentElement(); element.findFirst("html"); @@ -600,12 +600,12 @@ bool BookViewPreview::ExecuteCaretUpdate(const QString &caret_update) return false; } -BookViewPreview::SelectRangeInputs BookViewPreview::GetRangeInputs(const QMap< int, xc::DOMNode * > &node_offsets, +BookViewPreview::SelectRangeInputs BookViewPreview::GetRangeInputs(const QMap &node_offsets, int string_start, int string_length) const { SelectRangeInputs input; - QList< int > offsets = node_offsets.keys(); + QList offsets = node_offsets.keys(); int last_offset = offsets.first(); for (int i = 0; i < offsets.length(); ++i) { diff --git a/src/Sigil/ViewEditors/BookViewPreview.h b/src/Sigil/ViewEditors/BookViewPreview.h index 6237bbd02d..afc39aa034 100644 --- a/src/Sigil/ViewEditors/BookViewPreview.h +++ b/src/Sigil/ViewEditors/BookViewPreview.h @@ -101,10 +101,10 @@ class BookViewPreview : public QWebView, public ViewEditor void GrabFocus(); // inherited - QList< ViewEditor::ElementIndex > GetCaretLocation(); + QList GetCaretLocation(); // inherited - void StoreCaretLocationUpdate(const QList< ViewEditor::ElementIndex > &hierarchy); + void StoreCaretLocationUpdate(const QList &hierarchy); // inherited bool ExecuteCaretUpdate(); @@ -215,7 +215,7 @@ private slots: * * @return The element-selecting JavaScript code. */ - QString GetElementSelectingJS_NoTextNodes(const QList< ViewEditor::ElementIndex > &hierarchy) const; + QString GetElementSelectingJS_NoTextNodes(const QList &hierarchy) const; /** * Builds the element-selecting JavaScript code, ignoring all the @@ -225,7 +225,7 @@ private slots: * * @return The element-selecting JavaScript code. */ - QString GetElementSelectingJS_WithTextNode(const QList< ViewEditor::ElementIndex > &hierarchy) const; + QString GetElementSelectingJS_WithTextNode(const QList &hierarchy) const; /** * Converts a DomNode from a Dom of the current page @@ -254,7 +254,7 @@ private slots: * @return The offset. */ int GetSelectionOffset(const xc::DOMDocument &document, - const QMap< int, xc::DOMNode * > &node_offsets, + const QMap &node_offsets, Searchable::Direction search_direction); /** @@ -270,12 +270,12 @@ private slots: * A map with text node starting offsets as keys, * and those text nodes as values. */ - QMap< int, xc::DOMNode * > node_offsets; + QMap node_offsets; /** * A DOM document with the loaded text. */ - shared_ptr< xc::DOMDocument > document; + shared_ptr document; }; /** @@ -333,7 +333,7 @@ private slots: * @return The inputs for a \c range object. * @see SearchTools */ - SelectRangeInputs GetRangeInputs(const QMap< int, xc::DOMNode * > &node_offsets, + SelectRangeInputs GetRangeInputs(const QMap &node_offsets, int string_start, int string_length) const; diff --git a/src/Sigil/ViewEditors/CodeViewEditor.cpp b/src/Sigil/ViewEditors/CodeViewEditor.cpp index 9df001eab2..1f050ae72e 100644 --- a/src/Sigil/ViewEditors/CodeViewEditor.cpp +++ b/src/Sigil/ViewEditors/CodeViewEditor.cpp @@ -85,7 +85,7 @@ CodeViewEditor::CodeViewEditor(HighlighterType high_type, bool check_spelling, Q m_ScrollOneLineDown(*(new QShortcut(QKeySequence(Qt::ControlModifier + Qt::Key_Down), this, 0, 0, Qt::WidgetShortcut))), m_isLoadFinished(false), m_DelayedCursorScreenCenteringRequired(false), - m_CaretUpdate(QList< ViewEditor::ElementIndex >()), + m_CaretUpdate(QList()), m_checkSpelling(check_spelling), m_reformatCSSEnabled(false), m_reformatHTMLEnabled(false), @@ -188,7 +188,7 @@ void CodeViewEditor::HighlightMarkedText() { QTextCharFormat format; - QList< QTextEdit::ExtraSelection > extraSelections; + QList extraSelections; QTextEdit::ExtraSelection selection; selection.cursor = textCursor(); @@ -234,8 +234,7 @@ bool CodeViewEditor::MoveToMarkedText(Searchable::Direction direction, bool wrap pos = m_MarkedTextEnd; moved = true; } - } - else { + } else { if (wrap || pos < m_MarkedTextStart) { pos = m_MarkedTextStart; moved = true; @@ -386,7 +385,7 @@ QString CodeViewEditor::SplitSection() cursor.beginEditBlock(); - // Prevent current file from having an empty body which + // Prevent current file from having an empty body which // causes Book View to insert text outside the body. text = toPlainText(); QRegularExpression empty_body_search("\\s"); @@ -721,7 +720,7 @@ bool CodeViewEditor::FindNext(const QString &search_regex, start = m_MarkedTextStart; end = m_MarkedTextEnd; start_offset = m_MarkedTextStart; - } + } int selection_offset = GetSelectionOffset(search_direction, ignore_selection_offset, marked_text); if (search_direction == Searchable::Direction_Up) { @@ -743,7 +742,7 @@ bool CodeViewEditor::FindNext(const QString &search_regex, if (marked_text) { // If not in marked text it's not a real match. if (match_info.offset.second + start_offset > m_MarkedTextEnd || - match_info.offset.first + start_offset < m_MarkedTextStart) { + match_info.offset.first + start_offset < m_MarkedTextStart) { match_info.offset.first = -1; } } @@ -791,8 +790,7 @@ int CodeViewEditor::Count(const QString &search_regex, Searchable::Direction dir } else { text = Utility::Substring(textCursor().position(), end, text); } - } - else if (marked_text) { + } else if (marked_text) { text = Utility::Substring(start, end, text); } return spcre->getEveryMatchInfo(text).count(); @@ -888,7 +886,7 @@ int CodeViewEditor::ReplaceAll(const QString &search_regex, // Restrict replace to the marked area. text = Utility::Substring(m_MarkedTextStart, m_MarkedTextEnd, text); position = original_position - m_MarkedTextStart; - } + } int marked_text_length = text.length(); SPCRE *spcre = PCRECache::instance()->getObject(search_regex); @@ -904,7 +902,7 @@ int CodeViewEditor::ReplaceAll(const QString &search_regex, if (match_info.at(i).offset.first > position) { break; } - } else if (!wrap){ + } else if (!wrap) { if (match_info.at(i).offset.second < position) { break; } @@ -1522,11 +1520,10 @@ void CodeViewEditor::GoToLinkOrStyle() if (!url_name.isEmpty()) { QUrl url = QUrl(url_name); QString extension = url_name.right(url_name.length() - url_name.lastIndexOf('.') - 1).toLower(); - + if (IMAGE_EXTENSIONS.contains(extension)) { emit ViewImage(QUrl(url_name)); - } - else { + } else { emit LinkClicked(QUrl(url_name)); } } else if (IsPositionInOpeningTag()) { @@ -1883,7 +1880,7 @@ void CodeViewEditor::UpdateLineNumberArea(const QRect &area_to_update, int verti void CodeViewEditor::HighlightCurrentLine() { - QList< QTextEdit::ExtraSelection > extraSelections; + QList extraSelections; // Draw the full width line color. QTextEdit::ExtraSelection selection_line; @@ -2113,24 +2110,20 @@ int CodeViewEditor::GetSelectionOffset(Searchable::Direction search_direction, b if (ignore_selection_offset) { if (marked_text) { offset = m_MarkedTextEnd; - } - else { + } else { offset = toPlainText().length(); } - } - else { + } else { offset = textCursor().selectionStart(); } } else { if (ignore_selection_offset) { if (marked_text) { offset = m_MarkedTextStart; - } - else { + } else { offset = 0; } - } - else { + } else { offset = textCursor().selectionEnd(); } } @@ -2155,7 +2148,7 @@ void CodeViewEditor::ScrollByLine(bool down) } -QList< ViewEditor::ElementIndex > CodeViewEditor::GetCaretLocation() +QList CodeViewEditor::GetCaretLocation() { // We search for the first opening tag *behind* the caret. // This specifies the element the caret is located in. @@ -2180,17 +2173,17 @@ QList< ViewEditor::ElementIndex > CodeViewEditor::GetCaretLocation() } -void CodeViewEditor::StoreCaretLocationUpdate(const QList< ViewEditor::ElementIndex > &hierarchy) +void CodeViewEditor::StoreCaretLocationUpdate(const QList &hierarchy) { m_CaretUpdate = hierarchy; } -QStack< CodeViewEditor::StackElement > CodeViewEditor::GetCaretLocationStack(int offset) const +QStack CodeViewEditor::GetCaretLocationStack(int offset) const { QString source = toPlainText(); QXmlStreamReader reader(source); - QStack< StackElement > stack; + QStack stack; while (!reader.atEnd()) { reader.readNext(); @@ -2224,16 +2217,16 @@ QStack< CodeViewEditor::StackElement > CodeViewEditor::GetCaretLocationStack(int if (reader.hasError()) { // Just return an empty location. // Maybe we could return the stack we currently have? - return QStack< StackElement >(); + return QStack(); } return stack; } -QList< ViewEditor::ElementIndex > CodeViewEditor::ConvertStackToHierarchy(const QStack< StackElement > stack) const +QList CodeViewEditor::ConvertStackToHierarchy(const QStack stack) const { - QList< ViewEditor::ElementIndex > hierarchy; + QList hierarchy; foreach(StackElement stack_element, stack) { ViewEditor::ElementIndex new_element; new_element.name = stack_element.name; @@ -2244,9 +2237,9 @@ QList< ViewEditor::ElementIndex > CodeViewEditor::ConvertStackToHierarchy(const } -tuple< int, int > CodeViewEditor::ConvertHierarchyToCaretMove(const QList< ViewEditor::ElementIndex > &hierarchy) const +tuple CodeViewEditor::ConvertHierarchyToCaretMove(const QList &hierarchy) const { - shared_ptr< xc::DOMDocument > dom = XhtmlDoc::LoadTextIntoDocument(toPlainText()); + shared_ptr dom = XhtmlDoc::LoadTextIntoDocument(toPlainText()); xc::DOMNode *end_node = XhtmlDoc::GetNodeFromHierarchy(*dom, hierarchy); QTextCursor cursor(document()); @@ -3140,7 +3133,7 @@ void CodeViewEditor::FormatStyle(const QString &property_name, const QString &pr } else { // We have an existing style attribute on this tag, need to parse it to rewrite it. // Apply the name=value replacement getting a list of our new property pairs - QList< CSSInfo::CSSProperty * > css_properties = CSSInfo::getCSSProperties(style_attribute_value, 0, style_attribute_value.length()); + QList css_properties = CSSInfo::getCSSProperties(style_attribute_value, 0, style_attribute_value.length()); // Apply our property value, adding if not present currently, toggling if it is. ApplyChangeToProperties(css_properties, property_name, property_value); @@ -3215,7 +3208,7 @@ void CodeViewEditor::FormatCSSStyle(const QString &property_name, const QString } // Now parse the CSS style content - QList< CSSInfo::CSSProperty * > css_properties = CSSInfo::getCSSProperties(text, bracket_start + 1, bracket_end); + QList css_properties = CSSInfo::getCSSProperties(text, bracket_start + 1, bracket_end); // Apply our property value, adding if not present currently, toggling if it is. ApplyChangeToProperties(css_properties, property_name, property_value); // Figure out the formatting to be applied to these style properties to write prettily @@ -3235,7 +3228,7 @@ void CodeViewEditor::FormatCSSStyle(const QString &property_name, const QString setTextCursor(cursor); } -void CodeViewEditor::ApplyChangeToProperties(QList< CSSInfo::CSSProperty * > &css_properties, const QString &property_name, const QString &property_value) +void CodeViewEditor::ApplyChangeToProperties(QList &css_properties, const QString &property_name, const QString &property_value) { // Apply our property value, adding if not present currently, toggling if it is. bool has_property = false; diff --git a/src/Sigil/ViewEditors/CodeViewEditor.h b/src/Sigil/ViewEditors/CodeViewEditor.h index 41d47a09ad..0320659e4a 100644 --- a/src/Sigil/ViewEditors/CodeViewEditor.h +++ b/src/Sigil/ViewEditors/CodeViewEditor.h @@ -251,10 +251,10 @@ class CodeViewEditor : public QPlainTextEdit, public ViewEditor, public PasteTar void SetDelayedCursorScreenCenteringRequired(); // inherited - QList< ViewEditor::ElementIndex > GetCaretLocation(); + QList GetCaretLocation(); // inherited - void StoreCaretLocationUpdate(const QList< ViewEditor::ElementIndex > &hierarchy); + void StoreCaretLocationUpdate(const QList &hierarchy); // inherited bool ExecuteCaretUpdate(bool default_to_top = false); @@ -626,7 +626,7 @@ private slots: * the start tag of the element the caret is residing in. * @return The element location stack. */ - QStack< StackElement > GetCaretLocationStack(int offset) const; + QStack GetCaretLocationStack(int offset) const; /** * Takes the stack provided by GetCaretLocationStack() @@ -636,7 +636,7 @@ private slots: * @param stack The StackElement stack. * @return The converted ElementIndex hierarchy. */ - QList< ElementIndex > ConvertStackToHierarchy(const QStack< StackElement > stack) const; + QList ConvertStackToHierarchy(const QStack stack) const; /** * Converts a ViewEditor element hierarchy to a tuple describing necessary caret moves. @@ -645,7 +645,7 @@ private slots: * @param hierarchy The caret location as ElementIndex hierarchy. * @return The info needed to move the caret to the new location. */ - boost::tuple< int, int > ConvertHierarchyToCaretMove(const QList< ViewEditor::ElementIndex > &hierarchy) const; + boost::tuple ConvertHierarchyToCaretMove(const QList &hierarchy) const; /** * Insert HTML tags around the current selection. @@ -696,7 +696,7 @@ private slots: * Given a list of CSS properties perform any pruning/replacing/adding as necessary to * ensure that property_name:property_value is added (or removed if it already exists). */ - void ApplyChangeToProperties(QList< CSSInfo::CSSProperty * > &css_properties, const QString &property_name, const QString &property_value); + void ApplyChangeToProperties(QList &css_properties, const QString &property_name, const QString &property_value); void ReformatCSS(bool multiple_line_format); @@ -770,7 +770,7 @@ private slots: * Stores the update for the caret location * when switching from BookView to CodeView. */ - QList< ViewEditor::ElementIndex > m_CaretUpdate; + QList m_CaretUpdate; /** * Whether spell checking is enabled on this view. diff --git a/src/Sigil/ViewEditors/ViewEditor.h b/src/Sigil/ViewEditors/ViewEditor.h index 2f71f7131d..b6da8f79c7 100644 --- a/src/Sigil/ViewEditors/ViewEditor.h +++ b/src/Sigil/ViewEditors/ViewEditor.h @@ -102,8 +102,8 @@ class ViewEditor : public Searchable, public Zoomable * * @return The element selecting list. */ - virtual QList< ElementIndex > GetCaretLocation() { - return QList< ViewEditor::ElementIndex >(); + virtual QList GetCaretLocation() { + return QList(); } /** @@ -113,7 +113,7 @@ class ViewEditor : public Searchable, public Zoomable * * @param hierarchy The element selecting list. */ - virtual void StoreCaretLocationUpdate(const QList< ElementIndex > &hierarchy) {} + virtual void StoreCaretLocationUpdate(const QList &hierarchy) {} virtual QString GetCaretLocationUpdate() { return QString(); diff --git a/src/Sigil/main.cpp b/src/Sigil/main.cpp index 531b067adb..1c024a88bb 100644 --- a/src/Sigil/main.cpp +++ b/src/Sigil/main.cpp @@ -64,8 +64,7 @@ static MainWindow *GetMainWindow(const QStringList &arguments) // We use the first argument // as the file to load after starting if (arguments.size() > 1 && - Utility::IsFileReadable(arguments.at(1))) - { + Utility::IsFileReadable(arguments.at(1))) { return new MainWindow(arguments.at(1)); } else { return new MainWindow(); @@ -91,11 +90,11 @@ static void file_open() // "All Files (*.*)" is the default QString default_filter = load_filters.value("epub"); QString filename = QFileDialog::getOpenFileName(0, - "Open File", - "~", - filter_string, - &default_filter - ); + "Open File", + "~", + filter_string, + &default_filter + ); if (!filename.isEmpty()) { MainWindow *w = GetMainWindow(QStringList() << "" << filename); @@ -127,11 +126,11 @@ void MessageHandler(QtMsgType type, const QMessageLogContext &context, const QSt QString error_message; switch (type) { - // TODO: should go to a log + // TODO: should go to a log case QtDebugMsg: fprintf(stderr, "Debug: %s\n", message.toLatin1().constData()); break; - // TODO: should go to a log + // TODO: should go to a log case QtWarningMsg: fprintf(stderr, "Warning: %s\n", message.toLatin1().constData()); break; diff --git a/src/Sigil/sigil_exception.h b/src/Sigil/sigil_exception.h index 437a851893..77ca0d9ade 100644 --- a/src/Sigil/sigil_exception.h +++ b/src/Sigil/sigil_exception.h @@ -40,13 +40,13 @@ struct ExceptionBase: virtual std::exception, virtual boost::exception {}; * Thrown when a file does not exist. */ struct FileDoesNotExist : virtual ExceptionBase {}; -typedef boost::error_info< struct file_name, std::string > errinfo_file_name; +typedef boost::error_info errinfo_file_name; /** * Thrown when a resource object does not exist. */ struct ResourceDoesNotExist : virtual ExceptionBase {}; -typedef boost::error_info< struct resource_name, std::string > errinfo_resource_name; +typedef boost::error_info errinfo_resource_name; /** * Thrown when the book has no HTML files. @@ -57,28 +57,28 @@ struct NoHTMLFiles : virtual ExceptionBase {}; * Thrown for XML parsing errors. */ struct ErrorParsingXml : virtual ExceptionBase {}; -typedef boost::error_info< struct error_string, std::string > errinfo_XML_parsing_error_string; -typedef boost::error_info< struct line_number, qint64 > errinfo_XML_parsing_line_number; -typedef boost::error_info< struct column_number, qint64 > errinfo_XML_parsing_column_number; +typedef boost::error_info errinfo_XML_parsing_error_string; +typedef boost::error_info errinfo_XML_parsing_line_number; +typedef boost::error_info errinfo_XML_parsing_column_number; /** * Wrapper for CZipExceptions. */ struct CZipExceptionWrapper : virtual ExceptionBase {}; -typedef boost::error_info< struct zip_info, std::string > errinfo_zip_info_msg; -typedef boost::error_info< struct zip_iCause, int > errinfo_zip_error_id; +typedef boost::error_info errinfo_zip_info_msg; +typedef boost::error_info errinfo_zip_error_id; /** * Thrown when a file cannot be read. */ struct CannotReadFile : virtual ExceptionBase {}; -typedef boost::error_info< struct file_fullpath, std::string > errinfo_file_fullpath; +typedef boost::error_info errinfo_file_fullpath; /** * Thrown when a file cannot be opened. */ struct CannotOpenFile : virtual ExceptionBase {}; -typedef boost::error_info< struct file_errorstring, std::string > errinfo_file_errorstring; +typedef boost::error_info errinfo_file_errorstring; /** * Thrown when a file cannot be put into an archive. @@ -89,13 +89,13 @@ struct CannotStoreFile : virtual ExceptionBase {}; * Thrown when a file cannot be copied. */ struct CannotCopyFile : virtual ExceptionBase {}; -typedef boost::error_info< struct file_copypath, std::string > errinfo_file_copypath; +typedef boost::error_info errinfo_file_copypath; /** * Thrown when a file cannot be written. */ struct CannotWriteFile : virtual ExceptionBase {}; -typedef boost::error_info< struct file_errorstring, std::string > errinfo_file_errorstring; +typedef boost::error_info errinfo_file_errorstring; /** * Thrown when a file cannot be removed. @@ -111,9 +111,9 @@ struct FileEncryptedWithDrm : virtual ExceptionBase {}; * Thrown for XML parsing errors. */ struct FontObfuscationError : virtual ExceptionBase {}; -typedef boost::error_info< struct font_filepath, std::string > errinfo_font_filepath; -typedef boost::error_info< struct algorithm, std::string > errinfo_font_obfuscation_algorithm; -typedef boost::error_info< struct key, std::string > errinfo_font_obfuscation_key; +typedef boost::error_info errinfo_font_filepath; +typedef boost::error_info errinfo_font_obfuscation_algorithm; +typedef boost::error_info errinfo_font_obfuscation_key; /** * Thrown when the document has no root document element. @@ -124,7 +124,7 @@ struct ErrorBuildingDOM : virtual ExceptionBase {}; * Thrown for Invalid EPUB errors while loading and parsing content files. */ struct EPUBLoadParseError : virtual ExceptionBase {}; -typedef boost::error_info< struct parse_errors, std::string > errinfo_epub_load_parse_errors; +typedef boost::error_info errinfo_epub_load_parse_errors; #endif // SG_EXCEPTION_H