Removed conditional code.

This commit is contained in:
Martin Rotter 2016-03-22 13:55:50 +01:00
parent b871716d61
commit ff286f3d62
19 changed files with 2 additions and 144 deletions

View File

@ -234,7 +234,7 @@ message(STATUS "[${APP_LOW_NAME}] Enabling fast QString concatenation.")
add_definitions(-DQT_USE_FAST_CONCATENATION)
add_definitions(-DQT_USE_FAST_OPERATOR_PLUS)
# Configure executable "properties" for Windows or OS2.
# Configure executable "properties" for Windows.
if(WIN32)
message(STATUS "[${APP_LOW_NAME}] Generating executable file properties for Windows.")
configure_file (
@ -248,7 +248,7 @@ if(WIN32 AND MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,5.01" )
endif(WIN32 AND MSVC)
# Compile application icon if compiling with MinGW on WIN32 or with OS2.
# Compile application icon if compiling with MinGW on WIN32.
if(WIN32 AND MINGW)
enable_language(RC)
set(CMAKE_RC_COMPILER_INIT windres)

View File

@ -162,12 +162,7 @@ void MessagesModel::setupHeaderData() {
Qt::ItemFlags MessagesModel::flags(const QModelIndex &index) const {
Q_UNUSED(index)
#if QT_VERSION >= 0x050000
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemNeverHasChildren;
#else
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;
#endif
}
QVariant MessagesModel::data(int row, int column, int role) const {

View File

@ -152,16 +152,12 @@
#define APP_THEME_SUFFIX ".png"
#ifndef QSL
#if QT_VERSION >= 0x050000
// Thin macro wrapper for literal strings.
// They are much more memory efficient and faster.
// Use it for all literals except for two cases:
// a) Methods which take QLatin1String (use QLatin1String for literal argument too),
// b) Construction of empty literals "", use QString() instead of QStringLiteral("").
#define QSL(x) QStringLiteral(x)
#else
#define QSL(x) QLatin1String(x)
#endif
#endif
#ifndef QL1S

View File

@ -85,7 +85,6 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form
<< tr("Author")
<< tr("E-mail"));
#if QT_VERSION >= 0x050000
// Setup languages.
m_ui->m_treeLanguages->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
m_ui->m_treeLanguages->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
@ -98,20 +97,6 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form
m_ui->m_treeSkins->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
m_ui->m_treeSkins->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
m_ui->m_treeSkins->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
#else
// Setup languages.
m_ui->m_treeLanguages->header()->setResizeMode(0, QHeaderView::ResizeToContents);
m_ui->m_treeLanguages->header()->setResizeMode(1, QHeaderView::ResizeToContents);
m_ui->m_treeLanguages->header()->setResizeMode(2, QHeaderView::ResizeToContents);
m_ui->m_treeLanguages->header()->setResizeMode(3, QHeaderView::ResizeToContents);
m_ui->m_treeLanguages->header()->setResizeMode(4, QHeaderView::ResizeToContents);
// Setup skins.
m_ui->m_treeSkins->header()->setResizeMode(0, QHeaderView::ResizeToContents);
m_ui->m_treeSkins->header()->setResizeMode(1, QHeaderView::ResizeToContents);
m_ui->m_treeSkins->header()->setResizeMode(2, QHeaderView::ResizeToContents);
m_ui->m_treeSkins->header()->setResizeMode(3, QHeaderView::ResizeToContents);
#endif
// Establish needed connections.
connect(m_ui->m_buttonBox, SIGNAL(accepted()), this, SLOT(saveSettings()));
@ -749,15 +734,7 @@ void FormSettings::loadInterface() {
m_ui->m_cmbIconTheme->setCurrentIndex(0);
}
else {
#if QT_VERSION >= 0x050000
m_ui->m_cmbIconTheme->setCurrentText(current_theme);
#else
int theme_index = m_ui->m_cmbIconTheme->findText(current_theme);
if (theme_index >= 0) {
m_ui->m_cmbIconTheme->setCurrentIndex(theme_index);
}
#endif
}
// Load skin.

View File

@ -433,15 +433,9 @@ QMenu *FeedsView::initializeContextMenuOtherItem(RootItem *clicked_item) {
}
void FeedsView::setupAppearance() {
#if QT_VERSION >= 0x050000
// Setup column resize strategies.
header()->setSectionResizeMode(FDS_MODEL_TITLE_INDEX, QHeaderView::Stretch);
header()->setSectionResizeMode(FDS_MODEL_COUNTS_INDEX, QHeaderView::ResizeToContents);
#else
// Setup column resize strategies.
header()->setResizeMode(FDS_MODEL_TITLE_INDEX, QHeaderView::Stretch);
header()->setResizeMode(FDS_MODEL_COUNTS_INDEX, QHeaderView::ResizeToContents);
#endif
setUniformRowHeights(true);
setAnimated(true);

View File

@ -231,13 +231,11 @@ void MessagesView::loadItem(RootItem *item) {
m_sourceModel->setSort(col, ord);
m_sourceModel->loadMessages(item);
#if QT_VERSION >= 0x050000
// Messages are loaded, make sure that previously
// active message is not shown in browser.
// BUG: Qt 5 is probably bugged here. Selections
// should be cleared automatically when SQL model is reset.
emit currentMessagesRemoved();
#endif
}
void MessagesView::openSelectedSourceMessagesExternally() {
@ -506,7 +504,6 @@ void MessagesView::adjustColumns() {
if (header()->count() > 0 && !m_columnsAdjusted) {
m_columnsAdjusted = true;
#if QT_VERSION >= 0x050000
// Setup column resize strategies.
header()->setSectionResizeMode(MSG_DB_ID_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_READ_INDEX, QHeaderView::ResizeToContents);
@ -519,20 +516,6 @@ void MessagesView::adjustColumns() {
header()->setSectionResizeMode(MSG_DB_DCREATED_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_CONTENTS_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_PDELETED_INDEX, QHeaderView::Interactive);
#else
// Setup column resize strategies.
header()->setResizeMode(MSG_DB_ID_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_READ_INDEX, QHeaderView::ResizeToContents);
header()->setResizeMode(MSG_DB_DELETED_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_IMPORTANT_INDEX, QHeaderView::ResizeToContents);
header()->setResizeMode(MSG_DB_FEED_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_TITLE_INDEX, QHeaderView::Stretch);
header()->setResizeMode(MSG_DB_URL_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_AUTHOR_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_DCREATED_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_CONTENTS_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_PDELETED_INDEX, QHeaderView::Interactive);
#endif
// Hide columns.
hideColumn(MSG_DB_ID_INDEX);

View File

@ -221,11 +221,7 @@ void Notification::paintEvent(QPaintEvent *event) {
}
// Draw background.
#if QT_VERSION >= 0x050000
painter.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::Qt4CompatiblePainting);
#else
painter.setRenderHints(QPainter::HighQualityAntialiasing);
#endif
painter.setBrush(m_backgroundColor);
painter.setPen(Qt::NoPen);
@ -287,9 +283,7 @@ void Notification::setupWidget() {
Qt::WindowFlags window_flags = Qt::FramelessWindowHint | Qt::WindowSystemMenuHint |
Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint;
#if QT_VERSION >= 0x050000
window_flags |= Qt::WindowDoesNotAcceptFocus;
#endif
#if defined (Q_OS_MAC)
window_flags |= Qt::SubWindow;

View File

@ -56,11 +56,7 @@ int main(int argc, char *argv[]) {
#endif
// Setup debug output system.
#if QT_VERSION >= 0x050000
qInstallMessageHandler(Debugging::debugHandler);
#else
qInstallMsgHandler(Debugging::debugHandler);
#endif
// Instantiate base application object.
Application application(APP_LOW_NAME, argc, argv);

View File

@ -62,7 +62,6 @@ const char *Debugging::typeToString(QtMsgType type) {
}
}
#if QT_VERSION >= 0x050000
void Debugging::debugHandler(QtMsgType type, const QMessageLogContext &placement, const QString &message) {
#ifndef QT_NO_DEBUG_OUTPUT
performLog(qPrintable(message), type, placement.file, placement.function, placement.line);
@ -72,13 +71,3 @@ void Debugging::debugHandler(QtMsgType type, const QMessageLogContext &placement
Q_UNUSED(message)
#endif
}
#else
void Debugging::debugHandler(QtMsgType type, const char *message) {
#ifndef QT_NO_DEBUG_OUTPUT
performLog(message, type);
#else
Q_UNUSED(type)
Q_UNUSED(message)
#endif
}
#endif

View File

@ -25,12 +25,7 @@ class Debugging {
public:
// Specifies format of output console messages.
// NOTE: QT_NO_DEBUG_OUTPUT - disables debug outputs completely!!!
#if QT_VERSION >= 0x050000
static void debugHandler(QtMsgType type, const QMessageLogContext &placement, const QString &message);
#else
static void debugHandler(QtMsgType type, const char *message);
#endif
static void performLog(const char *message, QtMsgType type, const char *file = 0, const char *function = 0, int line = -1);
static const char *typeToString(QtMsgType type);

View File

@ -31,11 +31,7 @@ IOFactory::IOFactory() {
}
QString IOFactory::getSystemFolder(SYSTEM_FOLDER_ENUM::StandardLocation location) {
#if QT_VERSION >= 0x050000
return SYSTEM_FOLDER_ENUM::writableLocation(location);
#else
return SYSTEM_FOLDER_ENUM::storageLocation(location);
#endif
}
QString IOFactory::ensureUniqueFilename(const QString &name, const QString &append_format) {

View File

@ -22,13 +22,8 @@
#include "definitions/definitions.h"
#if QT_VERSION >= 0x050000
#include <QStandardPaths>
#define SYSTEM_FOLDER_ENUM QStandardPaths
#else
#include <QDesktopServices>
#define SYSTEM_FOLDER_ENUM QDesktopServices
#endif
class IOFactory {

View File

@ -76,12 +76,7 @@ QList<Language> Localization::installedLanguages() const {
new_language.m_version = translator.translate("QObject", "LANG_VERSION");
new_language.m_author = translator.translate("QObject", "LANG_AUTHOR");
new_language.m_email = translator.translate("QObject", "LANG_EMAIL");
#if QT_VERSION >= 0x040800
new_language.m_name = QLocale(new_language.m_code).nativeLanguageName();
#else
new_language.m_name = translator.translate("QObject", "LANG_NAME");
#endif
languages << new_language;
}

View File

@ -33,12 +33,7 @@
#include <QDomAttr>
#include <QFuture>
#include <QFutureWatcher>
#if QT_VERSION >= 0x050000
#include <QtConcurrent/QtConcurrentRun>
#else
#include <QtConcurrentRun>
#endif
typedef QPair<UpdateInfo, QNetworkReply::NetworkError> UpdateCheck;

View File

@ -132,11 +132,7 @@ QNetworkReply::NetworkError NetworkFactory::downloadIcon(const QList<QString> &u
QNetworkReply::NetworkError network_result;
foreach (const QString &url, urls) {
#if QT_VERSION >= 0x050000
const QString google_s2_with_url = QString("http://www.google.com/s2/favicons?domain=%1").arg(url.toHtmlEscaped());
#else
const QString google_s2_with_url = QString("http://www.google.com/s2/favicons?domain=%1").arg(Qt::escape(url));
#endif
QByteArray icon_data;
network_result = downloadFile(google_s2_with_url, timeout, icon_data).first;

View File

@ -146,7 +146,6 @@ QString WebFactory::deEscapeHtml(const QString &text) {
}
QString WebFactory::toSecondLevelDomain(const QUrl &url) {
#if QT_VERSION >= 0x040800
const QString top_level_domain = url.topLevelDomain();
const QString url_host = url.host();
@ -165,19 +164,6 @@ QString WebFactory::toSecondLevelDomain(const QUrl &url) {
}
return domain + top_level_domain;
#else
QString domain = url.host();
if (domain.count(QL1C('.')) == 0) {
return QString();
}
while (domain.count(QL1C('.')) != 1) {
domain = domain.mid(domain.indexOf(QL1C('.')) + 1);
}
return domain;
#endif
}
void WebFactory::generetaEscapes() {

View File

@ -37,12 +37,7 @@
#include <QDateTime>
#include <QClipboard>
#include <QFileDialog>
#if QT_VERSION >= 0x050000
#include <QtPrintSupport/QPrintPreviewDialog>
#else
#include <QPrintPreviewDialog>
#endif
WebView::WebView(QWidget *parent)
@ -168,11 +163,7 @@ void WebView::setupIcons() {
m_actionCopyImage->setIcon(qApp->icons()->fromTheme(QSL("edit-copy-image")));
m_actionSaveHyperlinkAs->setIcon(qApp->icons()->fromTheme(QSL("document-download")));
m_actionSaveImageAs->setIcon(qApp->icons()->fromTheme(QSL("document-download")));
#if QT_VERSION >= 0x040800
m_actionCopyImageUrl->setIcon(qApp->icons()->fromTheme(QSL("edit-copy")));
#endif
m_actionOpenLinkThisTab->setIcon(qApp->icons()->fromTheme(QSL("item-open-internal")));
m_actionOpenLinkNewTab->setIcon(qApp->icons()->fromTheme(QSL("item-open-internal")));
m_actionOpenLinkExternally->setIcon(qApp->icons()->fromTheme(QSL("item-open-external")));
@ -192,11 +183,6 @@ void WebView::initializeActions() {
m_actionCopySelectedItem = pageAction(QWebEnginePage::Copy);
m_actionCopySelectedItem->setParent(this);
#if defined(Q_OS_OS2)
m_actionCopySelectedItem->setShortcut(QKeySequence::Copy);
addAction(m_actionCopySelectedItem);
#endif
m_actionSaveHyperlinkAs = pageAction(QWebEnginePage::DownloadLinkToDisk);
m_actionSaveHyperlinkAs->setParent(this);
@ -210,10 +196,8 @@ void WebView::initializeActions() {
m_actionSaveImageAs->setParent(this);
m_actionSavePageAs = new QAction(qApp->icons()->fromTheme(QSL("document-download")), tr("Save page as..."), this);
#if QT_VERSION >= 0x040800
m_actionCopyImageUrl = pageAction(QWebEnginePage::CopyImageUrlToClipboard);
m_actionCopyImageUrl->setParent(this);
#endif
m_actionOpenLinkNewTab = pageAction(QWebEnginePage::OpenLinkInNewTab);
m_actionOpenLinkNewTab->setParent(this);
@ -244,10 +228,8 @@ void WebView::setActionTexts() {
m_actionSaveImageAs->setText(tr("Save image as..."));
m_actionSaveImageAs->setToolTip(tr("Save image to disk."));
#if QT_VERSION >= 0x040800
m_actionCopyImageUrl->setText(tr("Copy image url"));
m_actionCopyImageUrl->setToolTip(tr("Copy image url to clipboard."));
#endif
m_actionOpenLinkNewTab->setText(tr("Open link in new tab"));
m_actionOpenLinkNewTab->setToolTip(tr("Open this hyperlink in new tab."));

View File

@ -104,11 +104,7 @@ class WebView : public QWebEngineView {
QAction *m_actionSavePageAs;
QAction *m_actionSaveHyperlinkAs;
QAction *m_actionSaveImageAs;
#if QT_VERSION >= 0x040800
QAction *m_actionCopyImageUrl;
#endif
QAction *m_actionOpenLinkThisTab;
QAction *m_actionOpenLinkNewTab;
QAction *m_actionOpenLinkExternally;

View File

@ -222,9 +222,7 @@ int Feed::updateMessages(const QList<Message> &messages) {
QString new_message_url = QUrl(url()).toString(QUrl::RemoveUserInfo |
QUrl::RemovePath |
QUrl::RemoveQuery |
#if QT_VERSION >= 0x050000
QUrl::RemoveFilename |
#endif
QUrl::StripTrailingSlash);
new_message_url += message.m_url;