Commit 208865dd authored by hjk's avatar hjk Committed by Eike Ziller

Designer: Remove compatibility code for Qt < 5.0

Change-Id: I3ebe69b2c56635d1978da994fc772536a2839304
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 48157ccb
......@@ -31,12 +31,7 @@
#include "formeditorw.h"
#include <QDesignerFormEditorInterface>
#if QT_VERSION >= 0x050000
# include <QDesignerIntegration>
#else
# include "qt_private/qdesigner_integration_p.h"
#endif
#include <QDesignerIntegration>
#include <QWidget>
#include <QDebug>
......@@ -57,17 +52,7 @@ DesignerContext::DesignerContext(const Core::Context &context,
QString DesignerContext::contextHelpId() const
{
const QDesignerFormEditorInterface *core = FormEditorW::instance()->designerEditor();
#if QT_VERSION >= 0x050000
return core->integration()->contextHelpId();
#else
QString helpId;
// Present from Qt 4.5.1 onwards. This will show the class documentation
// scrolled to the current property.
if (const qdesigner_internal::QDesignerIntegration *integration =
qobject_cast<const qdesigner_internal::QDesignerIntegration*>(core->integration()))
helpId = integration->contextHelpId();
return helpId;
#endif
}
} // namespace Internal
......
......@@ -54,16 +54,7 @@
#include <QDesignerFormEditorPluginInterface>
#include <QDesignerFormEditorInterface>
#include <QDesignerComponents>
#if QT_VERSION >= 0x050000
# include <QDesignerFormWindowManagerInterface>
#else
# include "qt_private/pluginmanager_p.h"
# include "qt_private/iconloader_p.h" // createIconSet
# include "qt_private/qdesigner_formwindowmanager_p.h"
# include "qt_private/formwindowbase_p.h"
#endif
#include <QDesignerFormWindowManagerInterface>
#include <QDesignerWidgetBoxInterface>
#include <abstractobjectinspector.h>
#include <QDesignerPropertyEditorInterface>
......@@ -101,11 +92,7 @@ static const char settingsGroupC[] = "Designer";
static inline QIcon designerIcon(const QString &iconName)
{
#if QT_VERSION >= 0x050000
const QIcon icon = QDesignerFormEditorInterface::createIcon(iconName);
#else
const QIcon icon = qdesigner_internal::createIconSet(iconName);
#endif
if (icon.isNull())
qWarning() << "Unable to locate " << iconName;
return icon;
......@@ -151,11 +138,7 @@ FormEditorW::FormEditorW() :
m_formeditor->setTopLevel(ICore::mainWindow());
m_formeditor->setSettingsManager(new SettingsManager());
#if QT_VERSION >= 0x050000
m_fwm = m_formeditor->formWindowManager();
#else
m_fwm = qobject_cast<qdesigner_internal::QDesignerFormWindowManager*>(m_formeditor->formWindowManager());
#endif
QTC_ASSERT(m_fwm, return);
m_contexts.add(Designer::Constants::C_FORMEDITOR);
......@@ -261,11 +244,7 @@ void FormEditorW::fullInit()
* This will initialize our TabOrder, Signals and slots and Buddy editors.
*/
QList<QObject*> plugins = QPluginLoader::staticInstances();
#if QT_VERSION >= 0x050000
plugins += m_formeditor->pluginInstances();
#else
plugins += m_formeditor->pluginManager()->instances();
#endif
foreach (QObject *plugin, plugins) {
if (QDesignerFormEditorPluginInterface *formEditorPlugin = qobject_cast<QDesignerFormEditorPluginInterface*>(plugin)) {
if (!formEditorPlugin->isInitialized())
......@@ -490,20 +469,12 @@ void FormEditorW::setupActions()
// Commands that do not go into the editor toolbar
mformtools->addSeparator(m_contexts);
#if QT_VERSION >= 0x050000
m_actionPreview = m_fwm->action(QDesignerFormWindowManagerInterface::DefaultPreviewAction);
#else
m_actionPreview = m_fwm->actionDefaultPreview();
#endif
QTC_ASSERT(m_actionPreview, return);
addToolAction(m_actionPreview, m_contexts, "FormEditor.Preview", mformtools, tr("Alt+Shift+R"));
// Preview in style...
#if QT_VERSION >= 0x050000
m_actionGroupPreviewInStyle = m_fwm->actionGroup(QDesignerFormWindowManagerInterface::StyledPreviewActionGroup);
#else
m_actionGroupPreviewInStyle = m_fwm->actionGroupPreviewInStyle();
#endif
ActionContainer *previewAC = createPreviewStyleMenu(m_actionGroupPreviewInStyle);
m_previewInStyleMenu = previewAC->menu();
......@@ -516,11 +487,7 @@ void FormEditorW::setupActions()
mformtools->addSeparator(m_contexts);
mformtools->addSeparator(m_contexts, Core::Constants::G_DEFAULT_THREE);
#if QT_VERSION >= 0x050000
QAction *actionFormSettings = m_fwm->action(QDesignerFormWindowManagerInterface::FormWindowSettingsDialogAction);
#else
QAction *actionFormSettings = m_fwm->actionShowFormWindowSettingsDialog();
#endif
addToolAction(actionFormSettings, m_contexts, "FormEditor.FormSettings", mformtools,
QString(), Core::Constants::G_DEFAULT_THREE);
......@@ -529,13 +496,7 @@ void FormEditorW::setupActions()
m_actionAboutPlugins->setMenuRole(QAction::NoRole);
addToolAction(m_actionAboutPlugins, m_contexts, "FormEditor.AboutPlugins", mformtools,
QString(), Core::Constants::G_DEFAULT_THREE);
connect(m_actionAboutPlugins, SIGNAL(triggered()), m_fwm,
#if QT_VERSION >= 0x050000
SLOT(showPluginDialog())
#else
SLOT(aboutPlugins())
#endif
);
connect(m_actionAboutPlugins, SIGNAL(triggered()), m_fwm, SLOT(showPluginDialog()));
m_actionAboutPlugins->setEnabled(false);
// FWM
......@@ -669,18 +630,10 @@ EditorData FormEditorW::createEditor()
// Create and associate form and text editor.
EditorData data;
m_fwm->closeAllPreviews();
#if QT_VERSION >= 0x050000
QDesignerFormWindowInterface *form = m_fwm->createFormWindow(0);
#else
qdesigner_internal::FormWindowBase *form = qobject_cast<qdesigner_internal::FormWindowBase *>(m_fwm->createFormWindow(0));
#endif
QTC_ASSERT(form, return data);
connect(form, SIGNAL(toolChanged(int)), this, SLOT(toolChanged(int)));
ResourceHandler *resourceHandler = new ResourceHandler(form);
#if QT_VERSION < 0x050000
form->setDesignerGrid(qdesigner_internal::FormWindowBase::defaultDesignerGrid());
qdesigner_internal::FormWindowBase::setupDefaultAction(form);
#endif
data.widgetHost = new SharedTools::WidgetHost( /* parent */ 0, form);
DesignerXmlEditorWidget *xmlEditor = new DesignerXmlEditorWidget(form);
data.formWindowEditor = xmlEditor->designerEditor();
......@@ -783,11 +736,7 @@ void FormEditorW::print()
do {
// Grab the image to be able to a suggest suitable orientation
QString errorMessage;
#if QT_VERSION >= 0x050000
const QPixmap pixmap = m_fwm->createPreviewPixmap();
#else
const QPixmap pixmap = m_fwm->createPreviewPixmap(&errorMessage);
#endif
if (pixmap.isNull()) {
critical(tr("The image could not be created: %1").arg(errorMessage));
break;
......
......@@ -43,6 +43,7 @@ QT_BEGIN_NAMESPACE
class QDesignerIntegrationInterface;
class QDesignerFormEditorInterface;
class QDesignerFormWindowInterface;
class QDesignerFormWindowManagerInterface;
class QAction;
class QActionGroup;
......@@ -51,12 +52,6 @@ class QSignalMapper;
class QSettings;
class QToolBar;
#if QT_VERSION >= 0x050000
class QDesignerFormWindowManagerInterface;
#else
namespace qdesigner_internal { class QDesignerFormWindowManager; }
#endif
QT_END_NAMESPACE
namespace Core {
......@@ -167,12 +162,7 @@ private:
QDesignerFormEditorInterface *m_formeditor;
QDesignerIntegrationInterface *m_integration;
#if QT_VERSION >= 0x050000
QDesignerFormWindowManagerInterface *m_fwm;
#else
qdesigner_internal::QDesignerFormWindowManager *m_fwm;
#endif
InitializationStage m_initStage;
QWidget *m_designerSubWindows[Designer::Constants::DesignerSubWindowCount];
......
......@@ -32,12 +32,7 @@
#include <utils/wizard.h>
#if QT_VERSION >= 0x050000
# include <QDesignerNewFormWidgetInterface>
#else
# include "qt_private/abstractnewformwidget_p.h"
#endif
#include <QDesignerNewFormWidgetInterface>
#include <QDebug>
#include <QXmlStreamReader>
#include <QXmlStreamAttributes>
......
......@@ -93,18 +93,12 @@ bool FormWindowEditor::open(QString *errorString, const QString &fileName, const
return false;
form->setFileName(absfileName);
#if QT_VERSION >= 0x050000
const QByteArray contentsBA = contents.toUtf8();
QBuffer str;
str.setData(contentsBA);
str.open(QIODevice::ReadOnly);
if (!form->setContents(&str, errorString))
return false;
#else
form->setContents(contents);
if (!form->mainContainer())
return false;
#endif
form->setDirty(fileName != realFileName);
d->m_widget->formWindowFile()->syncXmlFromFormWindow();
......
......@@ -36,14 +36,8 @@
#include <QDesignerFormWindowInterface>
#include <QDesignerFormWindowManagerInterface>
#include <QDesignerFormEditorInterface>
#if QT_VERSION < 0x050000
# include "qt_private/qsimpleresource_p.h"
# include "qt_private/formwindowbase_p.h"
#endif
#include <QTextDocument>
#include <QUndoStack>
#include <QFileInfo>
#include <QDebug>
#include <QTextCodec>
......@@ -84,13 +78,7 @@ bool FormWindowFile::save(QString *errorString, const QString &name, bool autoSa
const QString oldFormName = m_formWindow->fileName();
if (!autoSave)
m_formWindow->setFileName(fi.absoluteFilePath());
#if QT_VERSION >= 0x050000
const bool writeOK = writeFile(actualName, errorString);
#else
const bool warningsEnabled = qdesigner_internal::QSimpleResource::setWarningsEnabled(false);
const bool writeOK = writeFile(actualName, errorString);
qdesigner_internal::QSimpleResource::setWarningsEnabled(warningsEnabled);
#endif
m_shouldAutoSave = false;
if (autoSave)
return writeOK;
......@@ -128,12 +116,7 @@ bool FormWindowFile::setContents(const QByteArray &contents)
QApplication::restoreOverrideCursor();
}
#if QT_VERSION >= 0x050000
const bool success = m_formWindow->setContents(QString::fromUtf8(contents));
#else
m_formWindow->setContents(QString::fromUtf8(contents));
const bool success = m_formWindow->mainContainer() != 0;
#endif
if (hasOverrideCursor)
QApplication::setOverrideCursor(overrideCursor);
......
......@@ -29,9 +29,6 @@
#include "formeditorplugin.h"
#if QT_VERSION < 0x050000
#include <QtTest>
#else
#include "formeditorw.h"
#include <coreplugin/editormanager/editormanager.h>
......@@ -228,23 +225,17 @@ public:
};
} // anonymous namespace
#endif
/// Check: Executes "Go To Slot..." on a QPushButton in a *.ui file and checks if the respective
/// header and source files are correctly updated.
void Designer::Internal::FormEditorPlugin::test_gotoslot()
{
#if QT_VERSION >= 0x050000
QFETCH(QStringList, files);
(GoToSlotTestCase(files));
#else
QSKIP("Available only with >= Qt5", SkipSingle);
#endif
}
void Designer::Internal::FormEditorPlugin::test_gotoslot_data()
{
#if QT_VERSION >= 0x050000
typedef QLatin1String _;
QTest::addColumn<QStringList>("files");
......@@ -282,5 +273,4 @@ void Designer::Internal::FormEditorPlugin::test_gotoslot_data()
<< testDataDir.file(_("form.cpp"))
<< testDataDir.file(_("form.h"))
<< testDataDir.file(_("form.ui")));
#endif
}
......@@ -77,24 +77,14 @@ static QString msgClassNotFound(const QString &uiClassName, const QList<Document
}
QtCreatorIntegration::QtCreatorIntegration(QDesignerFormEditorInterface *core, FormEditorW *parent) :
#if QT_VERSION >= 0x050000
QDesignerIntegration(core, parent),
#else
qdesigner_internal::QDesignerIntegration(core, parent),
#endif
m_few(parent)
{
#if QT_VERSION >= 0x050000
setResourceFileWatcherBehaviour(ReloadResourceFileSilently);
Feature f = features();
f |= SlotNavigationFeature;
f &= ~ResourceEditorFeature;
setFeatures(f);
#else
setResourceFileWatcherBehaviour(QDesignerIntegration::ReloadSilently);
setResourceEditingEnabled(false);
setSlotNavigationEnabled(true);
#endif
connect(this, SIGNAL(navigateToSlot(QString,QString,QStringList)),
this, SLOT(slotNavigateToSlot(QString,QString,QStringList)));
connect(this, SIGNAL(helpRequested(QString,QString)),
......@@ -115,11 +105,7 @@ void QtCreatorIntegration::updateSelection()
{
if (const EditorData ed = m_few->activeEditor())
ed.widgetHost->updateFormWindowSelectionHandles(true);
#if QT_VERSION >= 0x050000
QDesignerIntegration::updateSelection();
#else
qdesigner_internal::QDesignerIntegration::updateSelection();
#endif
}
QWidget *QtCreatorIntegration::containerWindow(QWidget * /*widget*/) const
......
......@@ -31,12 +31,7 @@
#define QTCREATORINTEGRATION_H
#include <QtGlobal>
#if QT_VERSION >= 0x050000
# include <QDesignerIntegration>
#else
# include "qt_private/qdesigner_integration_p.h"
#endif
#include <QDesignerIntegration>
QT_FORWARD_DECLARE_CLASS(QUrl)
......@@ -45,12 +40,8 @@ namespace Internal {
class FormEditorW;
class QtCreatorIntegration :
#if QT_VERSION >= 0x050000
public QDesignerIntegration {
#else
public qdesigner_internal::QDesignerIntegration {
#endif
class QtCreatorIntegration : public QDesignerIntegration
{
Q_OBJECT
public:
explicit QtCreatorIntegration(QDesignerFormEditorInterface *core, FormEditorW *parent = 0);
......
......@@ -37,12 +37,7 @@
#include <projectexplorer/session.h>
#include <resourceeditor/resourcenode.h>
#if QT_VERSION >= 0x050000
# include <QDesignerFormWindowInterface>
#else
# include "qt_private/formwindowbase_p.h"
# include "qt_private/qtresourcemodel_p.h"
#endif
#include <QDesignerFormWindowInterface>
#include <utils/qtcassert.h>
......@@ -84,11 +79,7 @@ void QrcFilesVisitor::visitFolderNode(FolderNode *folderNode)
}
// ------------ ResourceHandler
#if QT_VERSION >= 0x050000
ResourceHandler::ResourceHandler(QDesignerFormWindowInterface *fw) :
#else
ResourceHandler::ResourceHandler(qdesigner_internal::FormWindowBase *fw) :
#endif
QObject(fw),
m_form(fw),
m_sessionNode(0),
......@@ -110,11 +101,7 @@ void ResourceHandler::ensureInitialized()
connect(m_sessionWatcher, SIGNAL(foldersAdded()), this, SLOT(updateResources()));
connect(m_sessionWatcher, SIGNAL(foldersRemoved()), this, SLOT(updateResources()));
m_sessionNode->registerWatcher(m_sessionWatcher);
#if QT_VERSION >= 0x050000
m_originalUiQrcPaths = m_form->activeResourceFilePaths();
#else
m_originalUiQrcPaths = m_form->resourceSet()->activeQrcPaths();
#endif
if (Designer::Constants::Internal::debug)
qDebug() << "ResourceHandler::ensureInitialized() origPaths=" << m_originalUiQrcPaths;
}
......@@ -169,26 +156,16 @@ void ResourceHandler::updateResources(bool updateProjectResources)
}
}
#if QT_VERSION >= 0x050000
m_form->activateResourceFilePaths(projectQrcFiles);
m_form->setResourceFileSaveMode(QDesignerFormWindowInterface::SaveOnlyUsedResourceFiles);
#else
m_form->resourceSet()->activateQrcPaths(projectQrcFiles);
m_form->setSaveResourcesBehaviour(qdesigner_internal::FormWindowBase::SaveOnlyUsedQrcFiles);
#endif
if (Designer::Constants::Internal::debug)
qDebug() << "ResourceHandler::updateResources()" << fileName
<< " associated with project" << project->rootProjectNode()->path()
<< " using project qrc files" << projectQrcFiles.size();
} else {
// Use resource file originally used in form
#if QT_VERSION >= 0x050000
m_form->activateResourceFilePaths(m_originalUiQrcPaths);
m_form->setResourceFileSaveMode(QDesignerFormWindowInterface::SaveAllResourceFiles);
#else
m_form->resourceSet()->activateQrcPaths(m_originalUiQrcPaths);
m_form->setSaveResourcesBehaviour(qdesigner_internal::FormWindowBase::SaveAll);
#endif
if (Designer::Constants::Internal::debug)
qDebug() << "ResourceHandler::updateResources()" << fileName << " not associated with project, using loaded qrc files.";
}
......
......@@ -34,11 +34,7 @@
#include <QStringList>
QT_BEGIN_NAMESPACE
#if QT_VERSION >= 0x050000
class QDesignerFormWindowInterface;
#else
namespace qdesigner_internal { class FormWindowBase; }
#endif
QT_END_NAMESPACE
namespace ProjectExplorer {
......@@ -63,11 +59,7 @@ class ResourceHandler : public QObject
{
Q_OBJECT
public:
#if QT_VERSION >= 0x050000
explicit ResourceHandler(QDesignerFormWindowInterface *fw);
#else
explicit ResourceHandler(qdesigner_internal::FormWindowBase *fw);
#endif
explicit ResourceHandler(QDesignerFormWindowInterface *fw);
virtual ~ResourceHandler();
public slots:
......@@ -75,11 +67,7 @@ public slots:
private:
void ensureInitialized();
#if QT_VERSION >= 0x050000
QDesignerFormWindowInterface * const m_form;
#else
qdesigner_internal::FormWindowBase * const m_form;
#endif
QStringList m_originalUiQrcPaths;
ProjectExplorer::SessionNode *m_sessionNode;
ProjectExplorer::NodesWatcher *m_sessionWatcher;
......
......@@ -30,11 +30,7 @@
#ifndef SETTINGSMANAGER_H
#define SETTINGSMANAGER_H
#if QT_VERSION >= 0x050000
# include <QDesignerSettingsInterface>
#else
# include "qt_private/abstractsettings_p.h"
#endif
#include <QDesignerSettingsInterface>
namespace Designer {
namespace Internal {
......
......@@ -30,12 +30,7 @@
#include "settingspage.h"
#include "formeditorw.h"
#if QT_VERSION >= 0x050000
# include <QDesignerOptionsPageInterface>
#else
# include "qt_private/abstractoptionspage_p.h"
#endif
#include <QDesignerOptionsPageInterface>
#include <QCoreApplication>
using namespace Designer::Internal;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment