Commit 8c94419a authored by Eike Ziller's avatar Eike Ziller
Browse files

Help: Remove unnecessary QLatin1Strings



Change-Id: Ia5c83d5e2c392873f400f3db396b9c355cdd4192
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent c512f5d7
......@@ -134,7 +134,7 @@ DocSettingsPage::DocSettingsPage()
setDisplayName(tr("Documentation"));
setCategory(Help::Constants::HELP_CATEGORY);
setDisplayCategory(QCoreApplication::translate("Help", Help::Constants::HELP_TR_CATEGORY));
setCategoryIcon(QLatin1String(Help::Constants::HELP_CATEGORY_ICON));
setCategoryIcon(Help::Constants::HELP_CATEGORY_ICON);
}
QWidget *DocSettingsPage::widget()
......@@ -189,8 +189,7 @@ void DocSettingsPage::addDocumentation()
const QString filePath = QDir::cleanPath(file);
const QString &nameSpace = HelpManager::namespaceFromFile(filePath);
if (nameSpace.isEmpty()) {
docsUnableToRegister.insertMulti(QLatin1String("UnknownNamespace"),
QDir::toNativeSeparators(filePath));
docsUnableToRegister.insertMulti("UnknownNamespace", QDir::toNativeSeparators(filePath));
continue;
}
......@@ -222,12 +221,12 @@ void DocSettingsPage::addDocumentation()
}
QString formatedFail;
if (docsUnableToRegister.contains(QLatin1String("UnknownNamespace"))) {
if (docsUnableToRegister.contains("UnknownNamespace")) {
formatedFail += QString::fromLatin1("<ul><li><b>%1</b>").arg(tr("Invalid documentation file:"));
foreach (const QString &value, docsUnableToRegister.values(QLatin1String("UnknownNamespace")))
foreach (const QString &value, docsUnableToRegister.values("UnknownNamespace"))
formatedFail += QString::fromLatin1("<ul><li>%2</li></ul>").arg(value);
formatedFail += QLatin1String("</li></ul>");
docsUnableToRegister.remove(QLatin1String("UnknownNamespace"));
formatedFail += "</li></ul>";
docsUnableToRegister.remove("UnknownNamespace");
}
if (!docsUnableToRegister.isEmpty()) {
......@@ -236,7 +235,7 @@ void DocSettingsPage::addDocumentation()
for (NameSpaceToPathHash::ConstIterator it = docsUnableToRegister.constBegin(); it != cend; ++it) {
formatedFail += QString::fromLatin1("<ul><li>%1 - %2</li></ul>").arg(it.key(), it.value());
}
formatedFail += QLatin1String("</li></ul>");
formatedFail += "</li></ul>";
}
if (!formatedFail.isEmpty()) {
......
......@@ -44,7 +44,7 @@ FilterSettingsPage::FilterSettingsPage()
setDisplayName(tr("Filters"));
setCategory(Help::Constants::HELP_CATEGORY);
setDisplayCategory(QCoreApplication::translate("Help", Help::Constants::HELP_TR_CATEGORY));
setCategoryIcon(QLatin1String(Help::Constants::HELP_CATEGORY_ICON));
setCategoryIcon(Help::Constants::HELP_CATEGORY_ICON);
}
QWidget *FilterSettingsPage::widget()
......@@ -243,7 +243,7 @@ QString FilterSettingsPage::msgFilterLabel(const QString &filter) const
return tr("The filter \"%1\" will only show documentation files that"
" have the attributes %2 specified.").
arg(filter, checkedList.join(QLatin1String(", ")));
arg(filter, checkedList.join(", "));
}
void FilterSettingsPage::updateFilterDescription(const QString &filter)
......
......@@ -60,7 +60,7 @@ GeneralSettingsPage::GeneralSettingsPage()
setDisplayName(tr("General"));
setCategory(Help::Constants::HELP_CATEGORY);
setDisplayCategory(QCoreApplication::translate("Help", Help::Constants::HELP_TR_CATEGORY));
setCategoryIcon(QLatin1String(Help::Constants::HELP_CATEGORY_ICON));
setCategoryIcon(Help::Constants::HELP_CATEGORY_ICON);
}
QWidget *GeneralSettingsPage::widget()
......@@ -209,7 +209,7 @@ void GeneralSettingsPage::exportBookmarks()
m_ui->errorLabel->setVisible(false);
QString fileName = QFileDialog::getSaveFileName(ICore::dialogParent(),
tr("Save File"), QLatin1String("untitled.xbel"), tr("Files (*.xbel)"));
tr("Save File"), "untitled.xbel", tr("Files (*.xbel)"));
QLatin1String suffix(".xbel");
if (!fileName.endsWith(suffix))
......@@ -265,7 +265,7 @@ void GeneralSettingsPage::updateFontStyleSelector()
if (!styles.empty()) {
int normalIndex = -1;
const QString normalStyle = QLatin1String("Normal");
const QString normalStyle = "Normal";
foreach (const QString &style, styles) {
// try to maintain selection or select 'normal' preferably
const int newIndex = m_ui->styleComboBox->count();
......@@ -299,14 +299,14 @@ void GeneralSettingsPage::updateFont()
fontSize = m_ui->sizeComboBox->itemData(currentIndex).toInt();
m_font.setPointSize(fontSize);
QString fontStyle = QLatin1String("Normal");
QString fontStyle = "Normal";
currentIndex = m_ui->styleComboBox->currentIndex();
if (currentIndex != -1)
fontStyle = m_ui->styleComboBox->itemText(currentIndex);
m_font.setBold(m_fontDatabase.bold(family, fontStyle));
if (fontStyle.contains(QLatin1String("Italic")))
if (fontStyle.contains("Italic"))
m_font.setStyle(QFont::StyleItalic);
else if (fontStyle.contains(QLatin1String("Oblique")))
else if (fontStyle.contains("Oblique"))
m_font.setStyle(QFont::StyleOblique);
else
m_font.setStyle(QFont::StyleNormal);
......
......@@ -35,7 +35,7 @@ using namespace Help::Internal;
HelpMode::HelpMode(QObject *parent)
: Core::IMode(parent)
{
setObjectName(QLatin1String("HelpMode"));
setObjectName("HelpMode");
setContext(Core::Context(Constants::C_MODE_HELP));
setIcon(Utils::Icon::modeIcon(Icons::MODE_HELP_CLASSIC,
Icons::MODE_HELP_FLAT, Icons::MODE_HELP_FLAT_ACTIVE));
......
......@@ -132,8 +132,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
if (!locale.isEmpty()) {
QTranslator *qtr = new QTranslator(this);
QTranslator *qhelptr = new QTranslator(this);
const QString &creatorTrPath = ICore::resourcePath()
+ QLatin1String("/translations");
const QString &creatorTrPath = ICore::resourcePath() + "/translations";
const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
const QString &trFile = QLatin1String("assistant_") + locale;
const QString &helpTrFile = QLatin1String("qt_help_") + locale;
......@@ -181,7 +180,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
QAction *action;
// Add Contents, Index, and Context menu items
action = new QAction(QIcon::fromTheme(QLatin1String("help-contents")),
action = new QAction(QIcon::fromTheme("help-contents"),
tr(Constants::SB_CONTENTS), this);
cmd = ActionManager::registerAction(action, "Help.ContentsMenu");
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
......@@ -240,7 +239,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
connect(remoteHelpFilter, &RemoteHelpFilter::linkActivated, this,
&HelpPlugin::showLinkInHelpMode);
QDesktopServices::setUrlHandler(QLatin1String("qthelp"), HelpManager::instance(), "handleHelpRequest");
QDesktopServices::setUrlHandler("qthelp", HelpManager::instance(), "handleHelpRequest");
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
this, &HelpPlugin::modeChanged);
......@@ -255,7 +254,7 @@ void HelpPlugin::extensionsInitialized()
{
QStringList filesToRegister;
// we might need to register creators inbuild help
filesToRegister.append(ICore::documentationPath() + QLatin1String("/qtcreator.qch"));
filesToRegister.append(ICore::documentationPath() + "/qtcreator.qch");
HelpManager::registerDocumentation(filesToRegister);
}
......@@ -274,7 +273,7 @@ void HelpPlugin::resetFilter()
{
const QString &filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3")
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
QRegExp filterRegExp(QLatin1String("Qt Creator \\d*\\.\\d*\\.\\d*"));
QRegExp filterRegExp("Qt Creator \\d*\\.\\d*\\.\\d*");
QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
const QStringList &filters = engine->customFilters();
......@@ -310,8 +309,7 @@ void HelpPlugin::saveExternalWindowSettings()
return;
m_externalWindowState = m_externalWindow->geometry();
QSettings *settings = ICore::settings();
settings->setValue(QLatin1String(kExternalWindowStateKey),
qVariantFromValue(m_externalWindowState));
settings->setValue(kExternalWindowStateKey, qVariantFromValue(m_externalWindowState));
}
HelpWidget *HelpPlugin::createHelpWidget(const Context &context, HelpWidget::WidgetStyle style)
......@@ -351,7 +349,7 @@ HelpViewer *HelpPlugin::externalHelpViewer()
HelpWidget::ExternalWindow);
if (m_externalWindowState.isNull()) {
QSettings *settings = ICore::settings();
m_externalWindowState = settings->value(QLatin1String(kExternalWindowStateKey)).toRect();
m_externalWindowState = settings->value(kExternalWindowStateKey).toRect();
}
if (m_externalWindowState.isNull())
m_externalWindow->resize(650, 700);
......@@ -533,11 +531,11 @@ static QUrl findBestLink(const QMap<QString, QUrl> &links, QString *highlightId)
QUrl source = links.constBegin().value();
// workaround to show the latest Qt version
int version = 0;
QRegExp exp(QLatin1String("(\\d+)"));
QRegExp exp("(\\d+)");
foreach (const QUrl &link, links) {
const QString &authority = link.authority();
if (authority.startsWith(QLatin1String("com.trolltech."))
|| authority.startsWith(QLatin1String("org.qt-project."))) {
if (authority.startsWith("com.trolltech.")
|| authority.startsWith("org.qt-project.")) {
if (exp.indexIn(authority) >= 0) {
const int tmpVersion = exp.cap(1).toInt();
if (tmpVersion > version) {
......@@ -593,13 +591,13 @@ void HelpPlugin::showContextHelp()
void HelpPlugin::activateIndex()
{
activateHelpMode();
m_centralWidget->activateSideBarItem(QLatin1String(Constants::HELP_INDEX));
m_centralWidget->activateSideBarItem(Constants::HELP_INDEX);
}
void HelpPlugin::activateContents()
{
activateHelpMode();
m_centralWidget->activateSideBarItem(QLatin1String(Constants::HELP_CONTENTS));
m_centralWidget->activateSideBarItem(Constants::HELP_CONTENTS);
}
void HelpPlugin::highlightSearchTermsInContextHelp()
......@@ -619,15 +617,15 @@ void HelpPlugin::handleHelpRequest(const QUrl &url, HelpManager::HelpViewerLocat
QString address = url.toString();
if (!HelpManager::findFile(url).isValid()) {
if (address.startsWith(QLatin1String("qthelp://org.qt-project."))
|| address.startsWith(QLatin1String("qthelp://com.nokia."))
|| address.startsWith(QLatin1String("qthelp://com.trolltech."))) {
if (address.startsWith("qthelp://org.qt-project.")
|| address.startsWith("qthelp://com.nokia.")
|| address.startsWith("qthelp://com.trolltech.")) {
// local help not installed, resort to external web help
QString urlPrefix = QLatin1String("http://doc.qt.io/");
if (url.authority() == QLatin1String("org.qt-project.qtcreator"))
QString urlPrefix = "http://doc.qt.io/";
if (url.authority() == "org.qt-project.qtcreator")
urlPrefix.append(QString::fromLatin1("qtcreator"));
else
urlPrefix.append(QLatin1String("latest"));
urlPrefix.append("latest");
address = urlPrefix + address.mid(address.lastIndexOf(QLatin1Char('/')));
}
}
......@@ -641,12 +639,12 @@ void HelpPlugin::handleHelpRequest(const QUrl &url, HelpManager::HelpViewerLocat
void HelpPlugin::slotOpenSupportPage()
{
showLinkInHelpMode(QUrl(QLatin1String("qthelp://org.qt-project.qtcreator/doc/technical-support.html")));
showLinkInHelpMode(QUrl("qthelp://org.qt-project.qtcreator/doc/technical-support.html"));
}
void HelpPlugin::slotReportBug()
{
QDesktopServices::openUrl(QUrl(QLatin1String("https://bugreports.qt.io")));
QDesktopServices::openUrl(QUrl("https://bugreports.qt.io"));
}
void HelpPlugin::doSetupIfNeeded()
......
......@@ -88,8 +88,8 @@ HelpViewer::HelpViewer(QWidget *parent)
bool HelpViewer::isLocalUrl(const QUrl &url)
{
return url.scheme() == QLatin1String("about") // "No documenation available"
|| url.scheme() == QLatin1String("qthelp");
return url.scheme() == "about" // "No documenation available"
|| url.scheme() == "qthelp";
}
bool HelpViewer::canOpenPage(const QString &url)
......@@ -109,7 +109,7 @@ QString HelpViewer::mimeFromUrl(const QUrl &url)
return QLatin1String(e->mimeType);
++e;
}
return QLatin1String("");
return "";
}
bool HelpViewer::launchWithExternalApp(const QUrl &url)
......@@ -123,7 +123,7 @@ bool HelpViewer::launchWithExternalApp(const QUrl &url)
const QString& path = resolvedUrl.path();
if (!canOpenPage(path)) {
Utils::TempFileSaver saver(QDir::tempPath()
+ QLatin1String("/qtchelp_XXXXXX.") + QFileInfo(path).completeSuffix());
+ "/qtchelp_XXXXXX." + QFileInfo(path).completeSuffix());
saver.setAutoRemove(false);
if (!saver.hasError())
saver.write(helpEngine.fileData(resolvedUrl));
......
......@@ -296,7 +296,7 @@ void HelpWidget::addSideBar()
bool supportsNewPages = (m_style == ModeWidget);
auto contentWindow = new ContentWindow;
auto contentItem = new Core::SideBarItem(contentWindow, QLatin1String(Constants::HELP_CONTENTS));
auto contentItem = new Core::SideBarItem(contentWindow, Constants::HELP_CONTENTS);
contentWindow->setOpenInNewPageActionVisible(supportsNewPages);
contentWindow->setWindowTitle(HelpPlugin::tr(Constants::SB_CONTENTS));
connect(contentWindow, &ContentWindow::linkActivated,
......@@ -305,10 +305,10 @@ void HelpWidget::addSideBar()
cmd = Core::ActionManager::registerAction(m_contentsAction, Constants::HELP_CONTENTS, m_context->context());
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Shift+C")
: tr("Ctrl+Shift+C")));
shortcutMap.insert(QLatin1String(Constants::HELP_CONTENTS), cmd);
shortcutMap.insert(Constants::HELP_CONTENTS, cmd);
auto indexWindow = new IndexWindow();
auto indexItem = new Core::SideBarItem(indexWindow, QLatin1String(Constants::HELP_INDEX));
auto indexItem = new Core::SideBarItem(indexWindow, Constants::HELP_INDEX);
indexWindow->setOpenInNewPageActionVisible(supportsNewPages);
indexWindow->setWindowTitle(HelpPlugin::tr(Constants::SB_INDEX));
connect(indexWindow, &IndexWindow::linkActivated,
......@@ -319,20 +319,19 @@ void HelpWidget::addSideBar()
cmd = Core::ActionManager::registerAction(m_indexAction, Constants::HELP_INDEX, m_context->context());
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+I")
: tr("Ctrl+Shift+I")));
shortcutMap.insert(QLatin1String(Constants::HELP_INDEX), cmd);
shortcutMap.insert(Constants::HELP_INDEX, cmd);
auto bookmarkWidget = new BookmarkWidget(&LocalHelpManager::bookmarkManager());
bookmarkWidget->setWindowTitle(HelpPlugin::tr(Constants::SB_BOOKMARKS));
bookmarkWidget->setOpenInNewPageActionVisible(supportsNewPages);
auto bookmarkItem = new Core::SideBarItem(bookmarkWidget,
QLatin1String(Constants::HELP_BOOKMARKS));
auto bookmarkItem = new Core::SideBarItem(bookmarkWidget, Constants::HELP_BOOKMARKS);
connect(bookmarkWidget, &BookmarkWidget::linkActivated, this, &HelpWidget::setSource);
m_bookmarkAction = new QAction(tr("Activate Help Bookmarks View"), this);
cmd = Core::ActionManager::registerAction(m_bookmarkAction, Constants::HELP_BOOKMARKS,
m_context->context());
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Alt+Meta+M")
: tr("Ctrl+Shift+B")));
shortcutMap.insert(QLatin1String(Constants::HELP_BOOKMARKS), cmd);
shortcutMap.insert(Constants::HELP_BOOKMARKS, cmd);
auto searchItem = new SearchSideBarItem;
connect(searchItem, &SearchSideBarItem::linkActivated, this, &HelpWidget::openFromSearch);
......@@ -341,20 +340,19 @@ void HelpWidget::addSideBar()
m_context->context());
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+/")
: tr("Ctrl+Shift+/")));
shortcutMap.insert(QLatin1String(Constants::HELP_SEARCH), cmd);
shortcutMap.insert(Constants::HELP_SEARCH, cmd);
Core::SideBarItem *openPagesItem = 0;
if (m_style == ModeWidget) {
QWidget *openPagesWidget = OpenPagesManager::instance().openPagesWidget();
openPagesWidget->setWindowTitle(HelpPlugin::tr(Constants::SB_OPENPAGES));
openPagesItem = new Core::SideBarItem(openPagesWidget,
QLatin1String(Constants::HELP_OPENPAGES));
openPagesItem = new Core::SideBarItem(openPagesWidget, Constants::HELP_OPENPAGES);
m_openPagesAction = new QAction(tr("Activate Open Help Pages View"), this);
cmd = Core::ActionManager::registerAction(m_openPagesAction, Constants::HELP_OPENPAGES,
m_context->context());
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+O")
: tr("Ctrl+Shift+O")));
shortcutMap.insert(QLatin1String(Constants::HELP_OPENPAGES), cmd);
shortcutMap.insert(Constants::HELP_OPENPAGES, cmd);
}
QList<Core::SideBarItem *> itemList;
......@@ -376,20 +374,20 @@ void HelpWidget::addSideBar()
m_sideBarSplitter->setSizes(QList<int>() << m_sideBar->size().width() << 300);
connect(m_contentsAction, &QAction::triggered, m_sideBar, [this]() {
m_sideBar->activateItem(QLatin1String(Constants::HELP_CONTENTS));
m_sideBar->activateItem(Constants::HELP_CONTENTS);
});
connect(m_indexAction, &QAction::triggered, m_sideBar, [this]() {
m_sideBar->activateItem(QLatin1String(Constants::HELP_INDEX));
m_sideBar->activateItem(Constants::HELP_INDEX);
});
connect(m_bookmarkAction, &QAction::triggered, m_sideBar, [this]() {
m_sideBar->activateItem(QLatin1String(Constants::HELP_BOOKMARKS));
m_sideBar->activateItem(Constants::HELP_BOOKMARKS);
});
connect(m_searchAction, &QAction::triggered, m_sideBar, [this]() {
m_sideBar->activateItem(QLatin1String(Constants::HELP_SEARCH));
m_sideBar->activateItem(Constants::HELP_SEARCH);
});
if (m_openPagesAction) {
connect(m_openPagesAction, &QAction::triggered, m_sideBar, [this]() {
m_sideBar->activateItem(QLatin1String(Constants::HELP_OPENPAGES));
m_sideBar->activateItem(Constants::HELP_OPENPAGES);
});
}
}
......@@ -398,9 +396,9 @@ QString HelpWidget::sideBarSettingsKey() const
{
switch (m_style) {
case ModeWidget:
return QLatin1String(kModeSideBarSettingsKey);
return kModeSideBarSettingsKey;
case ExternalWindow:
return QLatin1String(kWindowSideBarSettingsKey);
return kWindowSideBarSettingsKey;
case SideBarWidget:
QTC_CHECK(false);
break;
......
......@@ -75,10 +75,10 @@ static const int kDefaultFallbackFontSize = 14;
static QString defaultFallbackFontFamily()
{
if (Utils::HostOsInfo::isMacHost())
return QLatin1String("Helvetica");
return "Helvetica";
if (Utils::HostOsInfo::isAnyUnixHost())
return QLatin1String("sans-serif");
return QLatin1String("Arial");
return "sans-serif";
return "Arial";
}
template <typename T>
......@@ -126,22 +126,21 @@ QString LocalHelpManager::defaultHomePage()
QString LocalHelpManager::homePage()
{
return Core::ICore::settings()->value(QLatin1String(kHelpHomePageKey),
defaultHomePage()).toString();
return Core::ICore::settings()->value(kHelpHomePageKey, defaultHomePage()).toString();
}
void LocalHelpManager::setHomePage(const QString &page)
{
Core::ICore::settings()->setValue(QLatin1String(kHelpHomePageKey), page);
Core::ICore::settings()->setValue(kHelpHomePageKey, page);
}
QFont LocalHelpManager::fallbackFont()
{
QSettings *settings = Core::ICore::settings();
const QString family = settings->value(QLatin1String(kFontFamilyKey), defaultFallbackFontFamily()).toString();
const QFont::Style style = QFont::Style(settings->value(QLatin1String(kFontStyleKey), kDefaultFallbackFontStyle).toInt());
const int weight = settings->value(QLatin1String(kFontWeightKey), kDefaultFallbackFontWeight).toInt();
const int size = settings->value(QLatin1String(kFontSizeKey), kDefaultFallbackFontSize).toInt();
const QString family = settings->value(kFontFamilyKey, defaultFallbackFontFamily()).toString();
const QFont::Style style = QFont::Style(settings->value(kFontStyleKey, kDefaultFallbackFontStyle).toInt());
const int weight = settings->value(kFontWeightKey, kDefaultFallbackFontWeight).toInt();
const int size = settings->value(kFontSizeKey, kDefaultFallbackFontSize).toInt();
QFont font(family, size, weight);
font.setStyle(style);
return font;
......@@ -158,8 +157,7 @@ void LocalHelpManager::setFallbackFont(const QFont &font)
LocalHelpManager::StartOption LocalHelpManager::startOption()
{
const QVariant value = Core::ICore::settings()->value(QLatin1String(kStartOptionKey),
ShowLastPages);
const QVariant value = Core::ICore::settings()->value(kStartOptionKey, ShowLastPages);
bool ok;
int optionValue = value.toInt(&ok);
if (!ok)
......@@ -179,12 +177,12 @@ LocalHelpManager::StartOption LocalHelpManager::startOption()
void LocalHelpManager::setStartOption(LocalHelpManager::StartOption option)
{
Core::ICore::settings()->setValue(QLatin1String(kStartOptionKey), option);
Core::ICore::settings()->setValue(kStartOptionKey, option);
}
Core::HelpManager::HelpViewerLocation LocalHelpManager::contextHelpOption()
{
const QVariant value = Core::ICore::settings()->value(QLatin1String(kContextHelpOptionKey),
const QVariant value = Core::ICore::settings()->value(kContextHelpOptionKey,
Core::HelpManager::SideBySideIfPossible);
bool ok;
int optionValue = value.toInt(&ok);
......@@ -207,38 +205,35 @@ Core::HelpManager::HelpViewerLocation LocalHelpManager::contextHelpOption()
void LocalHelpManager::setContextHelpOption(Core::HelpManager::HelpViewerLocation location)
{
Core::ICore::settings()->setValue(QLatin1String(kContextHelpOptionKey), location);
Core::ICore::settings()->setValue(kContextHelpOptionKey, location);
}
bool LocalHelpManager::returnOnClose()
{
const QVariant value = Core::ICore::settings()->value(QLatin1String(kReturnOnCloseKey), false);
const QVariant value = Core::ICore::settings()->value(kReturnOnCloseKey, false);
return value.toBool();
}
void LocalHelpManager::setReturnOnClose(bool returnOnClose)
{
Core::ICore::settings()->setValue(QLatin1String(kReturnOnCloseKey), returnOnClose);
Core::ICore::settings()->setValue(kReturnOnCloseKey, returnOnClose);
emit m_instance->returnOnCloseChanged();
}
QStringList LocalHelpManager::lastShownPages()
{
const QVariant value = Core::ICore::settings()->value(QLatin1String(kLastShownPagesKey),
QVariant());
const QVariant value = Core::ICore::settings()->value(kLastShownPagesKey, QVariant());
return value.toString().split(Constants::ListSeparator, QString::SkipEmptyParts);
}
void LocalHelpManager::setLastShownPages(const QStringList &pages)
{
Core::ICore::settings()->setValue(QLatin1String(kLastShownPagesKey),
pages.join(Constants::ListSeparator));
Core::ICore::settings()->setValue(kLastShownPagesKey, pages.join(Constants::ListSeparator));
}
QList<float> LocalHelpManager::lastShownPagesZoom()
{
const QVariant value = Core::ICore::settings()->value(QLatin1String(kLastShownPagesZoomKey),
QVariant());
const QVariant value = Core::ICore::settings()->value(kLastShownPagesZoomKey, QVariant());
const QStringList stringValues = value.toString().split(Constants::ListSeparator,
QString::SkipEmptyParts);
return Utils::transform(stringValues, [](const QString &str) { return str.toFloat(); });
......@@ -248,19 +243,19 @@ void LocalHelpManager::setLastShownPagesZoom(const QList<float> &zoom)
{
const QStringList stringValues = Utils::transform(zoom,
[](float z) { return QString::number(z); });
Core::ICore::settings()->setValue(QLatin1String(kLastShownPagesZoomKey),
Core::ICore::settings()->setValue(kLastShownPagesZoomKey,
stringValues.join(Constants::ListSeparator));
}
int LocalHelpManager::lastSelectedTab()
{
const QVariant value = Core::ICore::settings()->value(QLatin1String(kLastSelectedTabKey), 0);
const QVariant value = Core::ICore::settings()->value(kLastSelectedTabKey, 0);
return value.toInt();
}
void LocalHelpManager::setLastSelectedTab(int index)
{
Core::ICore::settings()->setValue(QLatin1String(kLastSelectedTabKey), index);
Core::ICore::settings()->setValue(kLastSelectedTabKey, index);
}
void LocalHelpManager::setupGuiHelpEngine()
......@@ -314,11 +309,11 @@ bool LocalHelpManager::isValidUrl(const QString &link)
if (!url.isValid())
return false;
const QString scheme = url.scheme();
return (scheme == QLatin1String("qthelp")
|| scheme == QLatin1String("about")
|| scheme == QLatin1String("file")
|| scheme == QLatin1String("http")
|| scheme == QLatin1String("https"));
return (scheme == "qthelp"
|| scheme == "about"
|| scheme == "file"
|| scheme == "http"
|| scheme == "https");
}
QByteArray LocalHelpManager::loadErrorMessage(const QUrl &url, const QString &errorString)
......@@ -395,11 +390,11 @@ LocalHelpManager::HelpData LocalHelpManager::helpData(const QUrl &url)
data.data = engine.fileData(data.resolvedUrl);
data.mimeType = HelpViewer::mimeFromUrl(data.resolvedUrl);
if (data.mimeType.isEmpty())
data.mimeType = QLatin1String("application/octet-stream");
data.mimeType = "application/octet-stream";
} else {
data.data = loadErrorMessage(url, QCoreApplication::translate(
"Help", "The page could not be found"));
data.mimeType = QLatin1String("text/html");
data.mimeType = "text/html";
}
return data;
}
......
......@@ -57,7 +57,7 @@ QVariant OpenPagesModel::data(const QModelIndex &index, int role) const
return m_pages.at(index.row())->source().toString();
case Qt::DisplayRole: {
QString title = m_pages.at(index.row())->title();
title.replace(QLatin1Char('&'), QLatin1String("&&"));
title.replace('&', "&&");
return title.isEmpty() ? tr("(Untitled)") : title;
}
default:
......
......@@ -476,11 +476,11 @@ void QtWebKitHelpViewer::highlightId(const QString &id)
if (m_oldHighlightId == id)
return;
const QWebElement &document = m_webView->page()->mainFrame()->documentElement();
const QWebElementCollection &collection = document.findAll(QLatin1String("h3.fn a"));
const QWebElementCollection &collection = document.findAll("h3.fn a");
const QLatin1String property("background-color");
foreach (const QWebElement &element, collection) {
const QString &name = element.attribute(QLatin1String("name"));
const QString &name = element.attribute("name");
if (name.isEmpty())
continue;
......@@ -495,7 +495,7 @@ void QtWebKitHelpViewer::highlightId(const QString &id)
QWebElement parent = element.parent();
m_oldHighlightStyle = parent.styleProperty(property,
QWebElement::ComputedStyle);
parent.setStyleProperty(property, QLatin1String("yellow"));
parent.setStyleProperty(property, "yellow");
}
}
m_oldHighlightId = id;
......@@ -575,7 +575,7 @@ bool QtWebKitHelpViewer::findText(const QString &text, FindFlags flags,
*wrapped = true;
}
options = QWebPage::HighlightAllOccurrences;
m_webView->findText(QLatin1String(""), options); // clear first
m_webView->findText("", options); // clear first
m_webView->findText(text, options); // force highlighting of all other matches