Browse Source

Remove remaining QBT_USES_QT5 defines.

Fixup of e64bb1de8c.
adaptive-webui-19844
Chocobo1 8 years ago
parent
commit
7539bee5c5
  1. 1
      src/CMakeLists.txt
  2. 8
      src/base/preferences.cpp
  3. 26
      src/base/utils/string.cpp
  4. 15
      src/gui/categoryfilterwidget.cpp

1
src/CMakeLists.txt

@ -66,7 +66,6 @@ endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(QBT_USE_GUI ${GUI}) set(QBT_USE_GUI ${GUI})
set(QBT_USE_WEBUI ${WEBUI}) set(QBT_USE_WEBUI ${WEBUI})
set(QBT_USES_QT5 ${QT5})
configure_file(config.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/config.h) configure_file(config.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/config.h)

8
src/base/preferences.cpp

@ -1271,20 +1271,12 @@ void Preferences::setRssMainSplitterState(const QByteArray &state)
QByteArray Preferences::getSearchTabHeaderState() const QByteArray Preferences::getSearchTabHeaderState() const
{ {
#ifdef QBT_USES_QT5
return value("SearchTab/qt5/HeaderState").toByteArray(); return value("SearchTab/qt5/HeaderState").toByteArray();
#else
return value("SearchTab/HeaderState").toByteArray();
#endif
} }
void Preferences::setSearchTabHeaderState(const QByteArray &state) void Preferences::setSearchTabHeaderState(const QByteArray &state)
{ {
#ifdef QBT_USES_QT5
setValue("SearchTab/qt5/HeaderState", state); setValue("SearchTab/qt5/HeaderState", state);
#else
setValue("SearchTab/HeaderState", state);
#endif
} }
QStringList Preferences::getSearchEngDisabled() const QStringList Preferences::getSearchEngDisabled() const

26
src/base/utils/string.cpp

@ -159,12 +159,7 @@ QString Utils::String::fromStdString(const std::string &str)
std::string Utils::String::toStdString(const QString &str) std::string Utils::String::toStdString(const QString &str)
{ {
#ifdef QBT_USES_QT5
return str.toStdString(); return str.toStdString();
#else
QByteArray utf8 = str.toUtf8();
return std::string(utf8.constData(), utf8.length());
#endif
} }
// to send numbers instead of strings with suffixes // to send numbers instead of strings with suffixes
@ -196,26 +191,5 @@ bool Utils::String::slowEquals(const QByteArray &a, const QByteArray &b)
QString Utils::String::toHtmlEscaped(const QString &str) QString Utils::String::toHtmlEscaped(const QString &str)
{ {
#ifdef QBT_USES_QT5
return str.toHtmlEscaped(); return str.toHtmlEscaped();
#else
// code from Qt
QString rich;
const int len = str.length();
rich.reserve(int(len * 1.1));
for (int i = 0; i < len; ++i) {
if (str.at(i) == QLatin1Char('<'))
rich += QLatin1String("&lt;");
else if (str.at(i) == QLatin1Char('>'))
rich += QLatin1String("&gt;");
else if (str.at(i) == QLatin1Char('&'))
rich += QLatin1String("&amp;");
else if (str.at(i) == QLatin1Char('"'))
rich += QLatin1String("&quot;");
else
rich += str.at(i);
}
rich.squeeze();
return rich;
#endif
} }

15
src/gui/categoryfilterwidget.cpp

@ -161,22 +161,7 @@ void CategoryFilterWidget::callUpdateGeometry()
QSize CategoryFilterWidget::sizeHint() const QSize CategoryFilterWidget::sizeHint() const
{ {
#ifdef QBT_USES_QT5
return viewportSizeHint(); return viewportSizeHint();
#else
int lastRow = model()->rowCount() - 1;
QModelIndex last = model()->index(lastRow, 0);
while ((lastRow >= 0) && isExpanded(last)) {
lastRow = model()->rowCount(last) - 1;
last = model()->index(lastRow, 0, last);
}
const QRect deepestRect = visualRect(last);
if (!deepestRect.isValid())
return viewport()->sizeHint();
return QSize(header()->length(), deepestRect.bottom() + 1);
#endif
} }
QSize CategoryFilterWidget::minimumSizeHint() const QSize CategoryFilterWidget::minimumSizeHint() const

Loading…
Cancel
Save