summaryrefslogtreecommitdiffstats
path: root/tools/designer/src
diff options
context:
space:
mode:
Diffstat (limited to 'tools/designer/src')
-rw-r--r--tools/designer/src/components/buddyeditor/buddyeditor.cpp4
-rw-r--r--tools/designer/src/components/buddyeditor/buddyeditor_plugin.cpp4
-rw-r--r--tools/designer/src/components/buddyeditor/buddyeditor_tool.cpp4
-rw-r--r--tools/designer/src/components/formeditor/embeddedoptionspage.cpp4
-rw-r--r--tools/designer/src/components/formeditor/formwindow.cpp9
-rw-r--r--tools/designer/src/components/formeditor/formwindowcursor.cpp4
-rw-r--r--tools/designer/src/components/formeditor/formwindowmanager.cpp4
-rw-r--r--tools/designer/src/components/formeditor/qdesigner_resource.cpp121
-rw-r--r--tools/designer/src/components/formeditor/tool_widgeteditor.cpp4
-rw-r--r--tools/designer/src/components/objectinspector/objectinspector.cpp4
-rw-r--r--tools/designer/src/components/objectinspector/objectinspectormodel.cpp4
-rw-r--r--tools/designer/src/components/propertyeditor/designerpropertymanager.cpp3
-rw-r--r--tools/designer/src/components/propertyeditor/paletteeditor.cpp7
-rw-r--r--tools/designer/src/components/propertyeditor/paletteeditorbutton.cpp4
-rw-r--r--tools/designer/src/components/propertyeditor/previewframe.cpp4
-rw-r--r--tools/designer/src/components/propertyeditor/propertyeditor.cpp9
-rw-r--r--tools/designer/src/components/propertyeditor/stringlisteditorbutton.cpp4
-rw-r--r--tools/designer/src/components/signalsloteditor/signalsloteditor_plugin.cpp4
-rw-r--r--tools/designer/src/components/signalsloteditor/signalsloteditor_tool.cpp4
-rw-r--r--tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp4
-rw-r--r--tools/designer/src/components/tabordereditor/tabordereditor_plugin.cpp4
-rw-r--r--tools/designer/src/components/tabordereditor/tabordereditor_tool.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/button_taskmenu.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/combobox_taskmenu.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/containerwidget_taskmenu.cpp5
-rw-r--r--tools/designer/src/components/taskmenu/groupbox_taskmenu.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/label_taskmenu.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/layouttaskmenu.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/lineedit_taskmenu.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/listwidget_taskmenu.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/listwidgeteditor.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/menutaskmenu.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/tablewidget_taskmenu.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/tablewidgeteditor.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/textedit_taskmenu.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/toolbar_taskmenu.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/treewidget_taskmenu.cpp4
-rw-r--r--tools/designer/src/components/taskmenu/treewidgeteditor.cpp4
-rw-r--r--tools/designer/src/designer/qdesigner_actions.cpp2
-rw-r--r--tools/designer/src/designer/versiondialog.cpp6
-rw-r--r--tools/designer/src/lib/sdk/abstractformeditor.cpp12
-rw-r--r--tools/designer/src/lib/shared/actioneditor.cpp4
-rw-r--r--tools/designer/src/lib/shared/codedialog.cpp4
-rw-r--r--tools/designer/src/lib/shared/csshighlighter.cpp4
-rw-r--r--tools/designer/src/lib/shared/formwindowbase.cpp4
-rw-r--r--tools/designer/src/lib/shared/newformwidget.cpp5
-rw-r--r--tools/designer/src/lib/shared/orderdialog.cpp4
-rw-r--r--tools/designer/src/lib/shared/plaintexteditor.cpp4
-rw-r--r--tools/designer/src/lib/shared/pluginmanager.cpp122
-rw-r--r--tools/designer/src/lib/shared/pluginmanager_p.h8
-rw-r--r--tools/designer/src/lib/shared/previewconfigurationwidget.cpp28
-rw-r--r--tools/designer/src/lib/shared/previewmanager.cpp171
-rw-r--r--tools/designer/src/lib/shared/promotionmodel.cpp4
-rw-r--r--tools/designer/src/lib/shared/qdesigner_formbuilder.cpp14
-rw-r--r--tools/designer/src/lib/shared/qdesigner_formbuilder_p.h17
-rw-r--r--tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp4
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertyeditor.cpp104
-rw-r--r--tools/designer/src/lib/shared/qdesigner_taskmenu.cpp4
-rw-r--r--tools/designer/src/lib/shared/qdesigner_toolbar.cpp17
-rw-r--r--tools/designer/src/lib/shared/qdesigner_widgetbox.cpp4
-rw-r--r--tools/designer/src/lib/shared/qsimpleresource.cpp133
-rw-r--r--tools/designer/src/lib/shared/qsimpleresource_p.h17
-rw-r--r--tools/designer/src/lib/shared/qtresourceview.cpp189
-rw-r--r--tools/designer/src/lib/shared/qtresourceview_p.h1
-rw-r--r--tools/designer/src/lib/shared/richtexteditor.cpp4
-rw-r--r--tools/designer/src/lib/shared/scriptdialog.cpp4
-rw-r--r--tools/designer/src/lib/shared/scripterrordialog.cpp4
-rw-r--r--tools/designer/src/lib/shared/stylesheeteditor.cpp4
-rw-r--r--tools/designer/src/lib/shared/widgetfactory.cpp4
-rw-r--r--tools/designer/src/lib/shared/zoomwidget.cpp22
-rw-r--r--tools/designer/src/lib/shared/zoomwidget_p.h9
-rw-r--r--tools/designer/src/lib/uilib/abstractformbuilder.cpp7
-rw-r--r--tools/designer/src/lib/uilib/formbuilder.cpp25
-rw-r--r--tools/designer/src/lib/uilib/formbuilderextra.cpp18
-rw-r--r--tools/designer/src/lib/uilib/formbuilderextra_p.h8
-rw-r--r--tools/designer/src/lib/uilib/ui4.cpp245
-rw-r--r--tools/designer/src/lib/uilib/ui4_p.h97
-rw-r--r--tools/designer/src/uitools/quiloader.cpp3
78 files changed, 1110 insertions, 512 deletions
diff --git a/tools/designer/src/components/buddyeditor/buddyeditor.cpp b/tools/designer/src/components/buddyeditor/buddyeditor.cpp
index f5c93fa..43348d2 100644
--- a/tools/designer/src/components/buddyeditor/buddyeditor.cpp
+++ b/tools/designer/src/components/buddyeditor/buddyeditor.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::BuddyEditor
-*/
-
#include "buddyeditor.h"
#include <QtDesigner/QDesignerFormWindowInterface>
diff --git a/tools/designer/src/components/buddyeditor/buddyeditor_plugin.cpp b/tools/designer/src/components/buddyeditor/buddyeditor_plugin.cpp
index 98fff8c..9319916 100644
--- a/tools/designer/src/components/buddyeditor/buddyeditor_plugin.cpp
+++ b/tools/designer/src/components/buddyeditor/buddyeditor_plugin.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::BuddyEditorPlugin
-*/
-
#include <QtGui/QAction>
#include "buddyeditor_plugin.h"
diff --git a/tools/designer/src/components/buddyeditor/buddyeditor_tool.cpp b/tools/designer/src/components/buddyeditor/buddyeditor_tool.cpp
index 68a6030..cf7f250 100644
--- a/tools/designer/src/components/buddyeditor/buddyeditor_tool.cpp
+++ b/tools/designer/src/components/buddyeditor/buddyeditor_tool.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::BuddyEditorTool
-*/
-
#include "buddyeditor_tool.h"
#include "buddyeditor.h"
diff --git a/tools/designer/src/components/formeditor/embeddedoptionspage.cpp b/tools/designer/src/components/formeditor/embeddedoptionspage.cpp
index bf3f3f1..1a41985 100644
--- a/tools/designer/src/components/formeditor/embeddedoptionspage.cpp
+++ b/tools/designer/src/components/formeditor/embeddedoptionspage.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::EmbeddedOptionsControl
-*/
-
#include "embeddedoptionspage.h"
#include "deviceprofiledialog.h"
#include "widgetfactory_p.h"
diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp
index 48efcde..66bab9b 100644
--- a/tools/designer/src/components/formeditor/formwindow.cpp
+++ b/tools/designer/src/components/formeditor/formwindow.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::FormWindow
-*/
-
#include "formwindow.h"
#include "formeditor.h"
#include "formwindow_dnditem.h"
@@ -2140,7 +2136,10 @@ void FormWindow::layoutContainer(QWidget *w, int type)
bool FormWindow::hasInsertedChildren(QWidget *widget) const // ### move
{
if (QDesignerContainerExtension *container = qt_extension<QDesignerContainerExtension*>(core()->extensionManager(), widget)) {
- widget = container->widget(container->currentIndex());
+ const int index = container->currentIndex();
+ if (index < 0)
+ return false;
+ widget = container->widget(index);
}
const QWidgetList l = widgets(widget);
diff --git a/tools/designer/src/components/formeditor/formwindowcursor.cpp b/tools/designer/src/components/formeditor/formwindowcursor.cpp
index 5b4aee1..fb30885 100644
--- a/tools/designer/src/components/formeditor/formwindowcursor.cpp
+++ b/tools/designer/src/components/formeditor/formwindowcursor.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::FormWindowCursor
-*/
-
#include "formwindowcursor.h"
#include "formwindow.h"
diff --git a/tools/designer/src/components/formeditor/formwindowmanager.cpp b/tools/designer/src/components/formeditor/formwindowmanager.cpp
index 69fb4a3..ea8d128 100644
--- a/tools/designer/src/components/formeditor/formwindowmanager.cpp
+++ b/tools/designer/src/components/formeditor/formwindowmanager.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::FormWindowManager
-*/
-
// components/formeditor
#include "formwindowmanager.h"
#include "formwindow_dnditem.h"
diff --git a/tools/designer/src/components/formeditor/qdesigner_resource.cpp b/tools/designer/src/components/formeditor/qdesigner_resource.cpp
index 064da9b..f94fb5c 100644
--- a/tools/designer/src/components/formeditor/qdesigner_resource.cpp
+++ b/tools/designer/src/components/formeditor/qdesigner_resource.cpp
@@ -753,26 +753,6 @@ void QDesignerResource::setSaveRelative(bool relative)
m_resourceBuilder->setSaveRelative(relative);
}
-static bool addFakeMethods(const DomSlots *domSlots, QStringList &fakeSlots, QStringList &fakeSignals)
-{
- if (!domSlots)
- return false;
-
- bool rc = false;
- foreach (const QString &fakeSlot, domSlots->elementSlot())
- if (fakeSlots.indexOf(fakeSlot) == -1) {
- fakeSlots += fakeSlot;
- rc = true;
- }
-
- foreach (const QString &fakeSignal, domSlots->elementSignal())
- if (fakeSignals.indexOf(fakeSignal) == -1) {
- fakeSignals += fakeSignal;
- rc = true;
- }
- return rc;
-}
-
QWidget *QDesignerResource::create(DomUI *ui, QWidget *parentWidget)
{
// Load extra info extension. This is used by Jambi for preventing
@@ -1435,108 +1415,9 @@ DomLayoutItem *QDesignerResource::createDom(QLayoutItem *item, DomLayout *ui_lay
return ui_item;
}
-static void addFakeMethodsToWidgetDataBase(const DomCustomWidget *domCustomWidget, WidgetDataBaseItem *item)
-{
- const DomSlots *domSlots = domCustomWidget->elementSlots();
- if (!domSlots)
- return;
-
- // Merge in new slots, signals
- QStringList fakeSlots = item->fakeSlots();
- QStringList fakeSignals = item->fakeSignals();
- if (addFakeMethods(domSlots, fakeSlots, fakeSignals)) {
- item->setFakeSlots(fakeSlots);
- item->setFakeSignals(fakeSignals);
- }
-}
-
-void QDesignerResource::addCustomWidgetsToWidgetDatabase(DomCustomWidgetList& custom_widget_list)
-{
- // Perform one iteration of adding the custom widgets to the database,
- // looking up the base class and inheriting its data.
- // Remove the succeeded custom widgets from the list.
- // Classes whose base class could not be found are left in the list.
- QDesignerWidgetDataBaseInterface *db = m_formWindow->core()->widgetDataBase();
- for (int i=0; i < custom_widget_list.size(); ) {
- bool classInserted = false;
- DomCustomWidget *custom_widget = custom_widget_list[i];
- const QString customClassName = custom_widget->elementClass();
- const QString base_class = custom_widget->elementExtends();
- QString includeFile;
- IncludeType includeType = IncludeLocal;
- if (const DomHeader *header = custom_widget->elementHeader()) {
- includeFile = header->text();
- if (header->hasAttributeLocation() && header->attributeLocation() == QLatin1String("global"))
- includeType = IncludeGlobal;
- }
- const bool domIsContainer = custom_widget->elementContainer();
- // Append a new item
- if (base_class.isEmpty()) {
- WidgetDataBaseItem *item = new WidgetDataBaseItem(customClassName);
- item->setPromoted(false);
- item->setGroup(QApplication::translate("Designer", "Custom Widgets"));
- item->setIncludeFile(buildIncludeFile(includeFile, includeType));
- item->setContainer(domIsContainer);
- item->setCustom(true);
- addFakeMethodsToWidgetDataBase(custom_widget, item);
- db->append(item);
- custom_widget_list.removeAt(i);
- classInserted = true;
- } else {
- // Create a new entry cloned from base class. Note that this will ignore existing
- // classes, eg, plugin custom widgets.
- QDesignerWidgetDataBaseItemInterface *item =
- appendDerived(db, customClassName, QApplication::translate("Designer", "Promoted Widgets"),
- base_class,
- buildIncludeFile(includeFile, includeType),
- true,true);
- // Ok, base class found.
- if (item) {
- // Hack to accommodate for old UI-files in which "contains" is not set properly:
- // Apply "contains" from DOM only if true (else, eg classes from QFrame might not accept
- // dropping child widgets on them as container=false). This also allows for
- // QWidget-derived stacked pages.
- if (domIsContainer)
- item->setContainer(domIsContainer);
-
- addFakeMethodsToWidgetDataBase(custom_widget, static_cast<WidgetDataBaseItem*>(item));
- custom_widget_list.removeAt(i);
- classInserted = true;
- }
- }
- // Skip failed item.
- if (!classInserted)
- i++;
- }
-
-}
void QDesignerResource::createCustomWidgets(DomCustomWidgets *dom_custom_widgets)
{
- if (dom_custom_widgets == 0)
- return;
- DomCustomWidgetList custom_widget_list = dom_custom_widgets->elementCustomWidget();
- // Attempt to insert each item derived from its base class.
- // This should at most require two iterations in the event that the classes are out of order
- // (derived first, max depth: promoted custom plugin = 2)
- for (int iteration = 0; iteration < 2; iteration++) {
- addCustomWidgetsToWidgetDatabase(custom_widget_list);
- if (custom_widget_list.empty())
- return;
- }
- // Oops, there are classes left whose base class could not be found.
- // Default them to QWidget with warnings.
- const QString fallBackBaseClass = QLatin1String("QWidget");
- for (int i=0; i < custom_widget_list.size(); i++ ) {
- DomCustomWidget *custom_widget = custom_widget_list[i];
- const QString customClassName = custom_widget->elementClass();
- const QString base_class = custom_widget->elementExtends();
- qDebug() << "** WARNING The base class " << base_class << " of the custom widget class " << customClassName
- << " could not be found. Defaulting to " << fallBackBaseClass << '.';
- custom_widget->setElementExtends(fallBackBaseClass);
- }
- // One more pass.
- addCustomWidgetsToWidgetDatabase(custom_widget_list);
- Q_ASSERT(custom_widget_list.empty());
+ QSimpleResource::handleDomCustomWidgets(core(), dom_custom_widgets);
}
DomTabStops *QDesignerResource::saveTabStops()
diff --git a/tools/designer/src/components/formeditor/tool_widgeteditor.cpp b/tools/designer/src/components/formeditor/tool_widgeteditor.cpp
index 3a59543..aed7e80 100644
--- a/tools/designer/src/components/formeditor/tool_widgeteditor.cpp
+++ b/tools/designer/src/components/formeditor/tool_widgeteditor.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::WidgetEditorTool
-*/
-
#include "tool_widgeteditor.h"
#include "formwindow.h"
diff --git a/tools/designer/src/components/objectinspector/objectinspector.cpp b/tools/designer/src/components/objectinspector/objectinspector.cpp
index 4e515be..cb90d2a 100644
--- a/tools/designer/src/components/objectinspector/objectinspector.cpp
+++ b/tools/designer/src/components/objectinspector/objectinspector.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::ObjectInspector
-*/
-
#include "objectinspector.h"
#include "objectinspectormodel_p.h"
#include "formwindow.h"
diff --git a/tools/designer/src/components/objectinspector/objectinspectormodel.cpp b/tools/designer/src/components/objectinspector/objectinspectormodel.cpp
index bc1ac0c..1e20ec3 100644
--- a/tools/designer/src/components/objectinspector/objectinspectormodel.cpp
+++ b/tools/designer/src/components/objectinspector/objectinspectormodel.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::ObjectInspector
-*/
-
#include "objectinspectormodel_p.h"
#include <qlayout_widget_p.h>
diff --git a/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp b/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp
index 346da18..1dd5bd6 100644
--- a/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp
+++ b/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp
@@ -2455,6 +2455,9 @@ void DesignerEditorFactory::slotStringTextChanged(const QString &value)
if (val.userType() == DesignerPropertyManager::designerStringTypeId()) {
PropertySheetStringValue strVal = qVariantValue<PropertySheetStringValue>(val);
strVal.setValue(value);
+ // Disable translation if no translation subproperties exist.
+ if (varProp->subProperties().empty())
+ strVal.setTranslatable(false);
val = qVariantFromValue(strVal);
} else {
val = QVariant(value);
diff --git a/tools/designer/src/components/propertyeditor/paletteeditor.cpp b/tools/designer/src/components/propertyeditor/paletteeditor.cpp
index b0dc82b..4c60941 100644
--- a/tools/designer/src/components/propertyeditor/paletteeditor.cpp
+++ b/tools/designer/src/components/propertyeditor/paletteeditor.cpp
@@ -39,13 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::PaletteEditor
-*/
-/*
-TRANSLATOR qdesigner_internal::PaletteModel
-*/
-
#include "paletteeditor.h"
#include <iconloader_p.h>
diff --git a/tools/designer/src/components/propertyeditor/paletteeditorbutton.cpp b/tools/designer/src/components/propertyeditor/paletteeditorbutton.cpp
index d7a76b9..c425e18 100644
--- a/tools/designer/src/components/propertyeditor/paletteeditorbutton.cpp
+++ b/tools/designer/src/components/propertyeditor/paletteeditorbutton.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::PaletteEditorButton
-*/
-
#include "paletteeditorbutton.h"
#include "paletteeditor.h"
diff --git a/tools/designer/src/components/propertyeditor/previewframe.cpp b/tools/designer/src/components/propertyeditor/previewframe.cpp
index 95d533d..e94ace0 100644
--- a/tools/designer/src/components/propertyeditor/previewframe.cpp
+++ b/tools/designer/src/components/propertyeditor/previewframe.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::PreviewWorkspace
-*/
-
#include "previewframe.h"
#include "previewwidget.h"
diff --git a/tools/designer/src/components/propertyeditor/propertyeditor.cpp b/tools/designer/src/components/propertyeditor/propertyeditor.cpp
index 806e1dd..eab7a12 100644
--- a/tools/designer/src/components/propertyeditor/propertyeditor.cpp
+++ b/tools/designer/src/components/propertyeditor/propertyeditor.cpp
@@ -137,13 +137,8 @@ void PropertyEditor::setupStringProperty(QtVariantProperty *property, bool isMai
const bool hasComment = params.second;
property->setAttribute(m_strings.m_validationModeAttribute, params.first);
// assuming comment cannot appear or disappear for the same property in different object instance
- if (!hasComment) {
- QList<QtProperty *> commentProperties = property->subProperties();
- if (commentProperties.count() > 0)
- delete commentProperties.at(0);
- if (commentProperties.count() > 1)
- delete commentProperties.at(1);
- }
+ if (!hasComment)
+ qDeleteAll(property->subProperties());
}
void PropertyEditor::setupPaletteProperty(QtVariantProperty *property)
diff --git a/tools/designer/src/components/propertyeditor/stringlisteditorbutton.cpp b/tools/designer/src/components/propertyeditor/stringlisteditorbutton.cpp
index 440015c..32a8c78 100644
--- a/tools/designer/src/components/propertyeditor/stringlisteditorbutton.cpp
+++ b/tools/designer/src/components/propertyeditor/stringlisteditorbutton.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::StringListEditorButton
-*/
-
#include "stringlisteditorbutton.h"
#include "stringlisteditor.h"
diff --git a/tools/designer/src/components/signalsloteditor/signalsloteditor_plugin.cpp b/tools/designer/src/components/signalsloteditor/signalsloteditor_plugin.cpp
index 311c843..a6f4969 100644
--- a/tools/designer/src/components/signalsloteditor/signalsloteditor_plugin.cpp
+++ b/tools/designer/src/components/signalsloteditor/signalsloteditor_plugin.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::SignalSlotEditorPlugin
-*/
-
#include "signalsloteditor_plugin.h"
#include "signalsloteditor_tool.h"
diff --git a/tools/designer/src/components/signalsloteditor/signalsloteditor_tool.cpp b/tools/designer/src/components/signalsloteditor/signalsloteditor_tool.cpp
index 973105c..311ec36 100644
--- a/tools/designer/src/components/signalsloteditor/signalsloteditor_tool.cpp
+++ b/tools/designer/src/components/signalsloteditor/signalsloteditor_tool.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::SignalSlotEditorTool
-*/
-
#include "signalsloteditor_tool.h"
#include "signalsloteditor.h"
#include "ui4_p.h"
diff --git a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp
index dc6b3c3..c916af8 100644
--- a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp
+++ b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::ConnectionModel
-*/
-
#include "signalsloteditorwindow.h"
#include "signalsloteditor_p.h"
#include "signalsloteditor.h"
diff --git a/tools/designer/src/components/tabordereditor/tabordereditor_plugin.cpp b/tools/designer/src/components/tabordereditor/tabordereditor_plugin.cpp
index 46bf378..abe882b 100644
--- a/tools/designer/src/components/tabordereditor/tabordereditor_plugin.cpp
+++ b/tools/designer/src/components/tabordereditor/tabordereditor_plugin.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::TabOrderEditorPlugin
-*/
-
#include <QtGui/QAction>
#include "tabordereditor_plugin.h"
diff --git a/tools/designer/src/components/tabordereditor/tabordereditor_tool.cpp b/tools/designer/src/components/tabordereditor/tabordereditor_tool.cpp
index 4f291a1..75304ee 100644
--- a/tools/designer/src/components/tabordereditor/tabordereditor_tool.cpp
+++ b/tools/designer/src/components/tabordereditor/tabordereditor_tool.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::TabOrderEditorTool
-*/
-
#include "tabordereditor_tool.h"
#include "tabordereditor.h"
diff --git a/tools/designer/src/components/taskmenu/button_taskmenu.cpp b/tools/designer/src/components/taskmenu/button_taskmenu.cpp
index ced32ce..c2816a2 100644
--- a/tools/designer/src/components/taskmenu/button_taskmenu.cpp
+++ b/tools/designer/src/components/taskmenu/button_taskmenu.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::ButtonTaskMenu
-*/
-
#include "button_taskmenu.h"
#include "inplace_editor.h"
#include <qdesigner_formwindowcommand_p.h>
diff --git a/tools/designer/src/components/taskmenu/combobox_taskmenu.cpp b/tools/designer/src/components/taskmenu/combobox_taskmenu.cpp
index e3364cc..908cb61 100644
--- a/tools/designer/src/components/taskmenu/combobox_taskmenu.cpp
+++ b/tools/designer/src/components/taskmenu/combobox_taskmenu.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::ComboBoxTaskMenu
-*/
-
#include "combobox_taskmenu.h"
#include "listwidgeteditor.h"
#include "qdesigner_utils_p.h"
diff --git a/tools/designer/src/components/taskmenu/containerwidget_taskmenu.cpp b/tools/designer/src/components/taskmenu/containerwidget_taskmenu.cpp
index b182ddf..c6673e3 100644
--- a/tools/designer/src/components/taskmenu/containerwidget_taskmenu.cpp
+++ b/tools/designer/src/components/taskmenu/containerwidget_taskmenu.cpp
@@ -39,13 +39,8 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::ContainerWidgetTaskMenu
-*/
-
#include "containerwidget_taskmenu.h"
-
#include <QtDesigner/QDesignerFormEditorInterface>
#include <QtDesigner/QDesignerFormWindowInterface>
#include <QtDesigner/QExtensionManager>
diff --git a/tools/designer/src/components/taskmenu/groupbox_taskmenu.cpp b/tools/designer/src/components/taskmenu/groupbox_taskmenu.cpp
index bb97342..18b6612 100644
--- a/tools/designer/src/components/taskmenu/groupbox_taskmenu.cpp
+++ b/tools/designer/src/components/taskmenu/groupbox_taskmenu.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::GroupBoxTaskMenu
-*/
-
#include "groupbox_taskmenu.h"
#include "inplace_editor.h"
diff --git a/tools/designer/src/components/taskmenu/label_taskmenu.cpp b/tools/designer/src/components/taskmenu/label_taskmenu.cpp
index 77e5ed9..f85df33 100644
--- a/tools/designer/src/components/taskmenu/label_taskmenu.cpp
+++ b/tools/designer/src/components/taskmenu/label_taskmenu.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::LabelTaskMenu
-*/
-
#include "label_taskmenu.h"
#include "inplace_editor.h"
diff --git a/tools/designer/src/components/taskmenu/layouttaskmenu.cpp b/tools/designer/src/components/taskmenu/layouttaskmenu.cpp
index 4a3aeec..0bfe607 100644
--- a/tools/designer/src/components/taskmenu/layouttaskmenu.cpp
+++ b/tools/designer/src/components/taskmenu/layouttaskmenu.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::LayoutWidgetTaskMenu
-*/
-
#include "layouttaskmenu.h"
#include <formlayoutmenu_p.h>
#include <morphmenu_p.h>
diff --git a/tools/designer/src/components/taskmenu/lineedit_taskmenu.cpp b/tools/designer/src/components/taskmenu/lineedit_taskmenu.cpp
index baf4785..a88246a 100644
--- a/tools/designer/src/components/taskmenu/lineedit_taskmenu.cpp
+++ b/tools/designer/src/components/taskmenu/lineedit_taskmenu.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::LineEditTaskMenu
-*/
-
#include "lineedit_taskmenu.h"
#include "inplace_editor.h"
diff --git a/tools/designer/src/components/taskmenu/listwidget_taskmenu.cpp b/tools/designer/src/components/taskmenu/listwidget_taskmenu.cpp
index 1a9ba36..10e004d 100644
--- a/tools/designer/src/components/taskmenu/listwidget_taskmenu.cpp
+++ b/tools/designer/src/components/taskmenu/listwidget_taskmenu.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::ListWidgetTaskMenu
-*/
-
#include "listwidget_taskmenu.h"
#include "listwidgeteditor.h"
#include "qdesigner_utils_p.h"
diff --git a/tools/designer/src/components/taskmenu/listwidgeteditor.cpp b/tools/designer/src/components/taskmenu/listwidgeteditor.cpp
index 2a8de52..4c3ede9 100644
--- a/tools/designer/src/components/taskmenu/listwidgeteditor.cpp
+++ b/tools/designer/src/components/taskmenu/listwidgeteditor.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::ListWidgetEditor
-*/
-
#include "listwidgeteditor.h"
#include <designerpropertymanager.h>
#include <abstractformbuilder.h>
diff --git a/tools/designer/src/components/taskmenu/menutaskmenu.cpp b/tools/designer/src/components/taskmenu/menutaskmenu.cpp
index 52320ac..093a1fe 100644
--- a/tools/designer/src/components/taskmenu/menutaskmenu.cpp
+++ b/tools/designer/src/components/taskmenu/menutaskmenu.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::MenuTaskMenu
-*/
-
#include "menutaskmenu.h"
#include <promotiontaskmenu_p.h>
diff --git a/tools/designer/src/components/taskmenu/tablewidget_taskmenu.cpp b/tools/designer/src/components/taskmenu/tablewidget_taskmenu.cpp
index 5ef1f9c..dce9f97 100644
--- a/tools/designer/src/components/taskmenu/tablewidget_taskmenu.cpp
+++ b/tools/designer/src/components/taskmenu/tablewidget_taskmenu.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::TableWidgetTaskMenu
-*/
-
#include "tablewidget_taskmenu.h"
#include "tablewidgeteditor.h"
diff --git a/tools/designer/src/components/taskmenu/tablewidgeteditor.cpp b/tools/designer/src/components/taskmenu/tablewidgeteditor.cpp
index 0863847..be1f89a 100644
--- a/tools/designer/src/components/taskmenu/tablewidgeteditor.cpp
+++ b/tools/designer/src/components/taskmenu/tablewidgeteditor.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::TableWidgetEditor
-*/
-
#include "tablewidgeteditor.h"
#include <abstractformbuilder.h>
#include <iconloader_p.h>
diff --git a/tools/designer/src/components/taskmenu/textedit_taskmenu.cpp b/tools/designer/src/components/taskmenu/textedit_taskmenu.cpp
index feaec2c..a9a2a96 100644
--- a/tools/designer/src/components/taskmenu/textedit_taskmenu.cpp
+++ b/tools/designer/src/components/taskmenu/textedit_taskmenu.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::TextEditTaskMenu
-*/
-
#include "textedit_taskmenu.h"
#include <QtDesigner/QDesignerFormWindowInterface>
diff --git a/tools/designer/src/components/taskmenu/toolbar_taskmenu.cpp b/tools/designer/src/components/taskmenu/toolbar_taskmenu.cpp
index a15cd8a..d841b87 100644
--- a/tools/designer/src/components/taskmenu/toolbar_taskmenu.cpp
+++ b/tools/designer/src/components/taskmenu/toolbar_taskmenu.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::ToolBarTaskMenu
-*/
-
#include "toolbar_taskmenu.h"
#include "qdesigner_toolbar_p.h"
diff --git a/tools/designer/src/components/taskmenu/treewidget_taskmenu.cpp b/tools/designer/src/components/taskmenu/treewidget_taskmenu.cpp
index b1c8c28..34d883a 100644
--- a/tools/designer/src/components/taskmenu/treewidget_taskmenu.cpp
+++ b/tools/designer/src/components/taskmenu/treewidget_taskmenu.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::TreeWidgetTaskMenu
-*/
-
#include "treewidget_taskmenu.h"
#include "treewidgeteditor.h"
diff --git a/tools/designer/src/components/taskmenu/treewidgeteditor.cpp b/tools/designer/src/components/taskmenu/treewidgeteditor.cpp
index faf00f2..e97ebde 100644
--- a/tools/designer/src/components/taskmenu/treewidgeteditor.cpp
+++ b/tools/designer/src/components/taskmenu/treewidgeteditor.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::TreeWidgetEditor
-*/
-
#include "treewidgeteditor.h"
#include <formwindowbase_p.h>
#include <iconloader_p.h>
diff --git a/tools/designer/src/designer/qdesigner_actions.cpp b/tools/designer/src/designer/qdesigner_actions.cpp
index 65e5937..d5d01f4 100644
--- a/tools/designer/src/designer/qdesigner_actions.cpp
+++ b/tools/designer/src/designer/qdesigner_actions.cpp
@@ -280,7 +280,7 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench)
m_fileActions->addAction(createSeparator(this));
- m_quitAction->setShortcut(tr("CTRL+Q"));
+ m_quitAction->setShortcuts(QKeySequence::Quit);
m_quitAction->setMenuRole(QAction::QuitRole);
connect(m_quitAction, SIGNAL(triggered()), this, SLOT(shutdown()));
m_fileActions->addAction(m_quitAction);
diff --git a/tools/designer/src/designer/versiondialog.cpp b/tools/designer/src/designer/versiondialog.cpp
index c21912b..97dc5a1 100644
--- a/tools/designer/src/designer/versiondialog.cpp
+++ b/tools/designer/src/designer/versiondialog.cpp
@@ -172,15 +172,11 @@ VersionDialog::VersionDialog(QWidget *parent)
version = version.arg(tr("Qt Designer")).arg(QLatin1String(QT_VERSION_STR));
version.append(tr("<br/>Qt Designer is a graphical user interface designer for Qt applications.<br/>"));
- // TODO: Remove this variable for 4.6.0. Must keep this way for 4.5.x due to string freeze
- QString edition;
-
lbl->setText(tr("%1"
- "<br/>%2"
"<br/>Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)."
"<br/><br/>The program is provided AS IS with NO WARRANTY OF ANY KIND,"
" INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A"
- " PARTICULAR PURPOSE.<br/> ").arg(version).arg(edition));
+ " PARTICULAR PURPOSE.<br/> ").arg(version));
lbl->setWordWrap(true);
lbl->setOpenExternalLinks(true);
diff --git a/tools/designer/src/lib/sdk/abstractformeditor.cpp b/tools/designer/src/lib/sdk/abstractformeditor.cpp
index 17e93e7..09d6976 100644
--- a/tools/designer/src/lib/sdk/abstractformeditor.cpp
+++ b/tools/designer/src/lib/sdk/abstractformeditor.cpp
@@ -66,9 +66,21 @@
#include <grid_p.h>
#include <QtDesigner/QDesignerPromotionInterface>
+// Must be done outside of the Qt namespace
static void initResources()
{
Q_INIT_RESOURCE(shared);
+ Q_INIT_RESOURCE(ClamshellPhone);
+ Q_INIT_RESOURCE(PDAPhone);
+ Q_INIT_RESOURCE(PortableMedia);
+ Q_INIT_RESOURCE(S60_nHD_Touchscreen);
+ Q_INIT_RESOURCE(S60_QVGA_Candybar);
+ Q_INIT_RESOURCE(SmartPhone2);
+ Q_INIT_RESOURCE(SmartPhone);
+ Q_INIT_RESOURCE(SmartPhoneWithButtons);
+ Q_INIT_RESOURCE(TouchscreenPhone);
+ Q_INIT_RESOURCE(Trolltech_Keypad);
+ Q_INIT_RESOURCE(Trolltech_Touchscreen);
}
QT_BEGIN_NAMESPACE
diff --git a/tools/designer/src/lib/shared/actioneditor.cpp b/tools/designer/src/lib/shared/actioneditor.cpp
index 7f96a15..e60b212 100644
--- a/tools/designer/src/lib/shared/actioneditor.cpp
+++ b/tools/designer/src/lib/shared/actioneditor.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::ActionEditor
-*/
-
#include "actioneditor_p.h"
#include "filterwidget_p.h"
#include "actionrepository_p.h"
diff --git a/tools/designer/src/lib/shared/codedialog.cpp b/tools/designer/src/lib/shared/codedialog.cpp
index 5a2db33..0b18f5e 100644
--- a/tools/designer/src/lib/shared/codedialog.cpp
+++ b/tools/designer/src/lib/shared/codedialog.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::CodeDialog
-*/
-
#include "codedialog_p.h"
#include "qdesigner_utils_p.h"
#include "iconloader_p.h"
diff --git a/tools/designer/src/lib/shared/csshighlighter.cpp b/tools/designer/src/lib/shared/csshighlighter.cpp
index d5e045b..f7144c5 100644
--- a/tools/designer/src/lib/shared/csshighlighter.cpp
+++ b/tools/designer/src/lib/shared/csshighlighter.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::StyleSheetEditorDialog
-*/
-
#include "csshighlighter_p.h"
QT_BEGIN_NAMESPACE
diff --git a/tools/designer/src/lib/shared/formwindowbase.cpp b/tools/designer/src/lib/shared/formwindowbase.cpp
index b569b51..377ae43 100644
--- a/tools/designer/src/lib/shared/formwindowbase.cpp
+++ b/tools/designer/src/lib/shared/formwindowbase.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::FormWindowBase
-*/
-
#include "formwindowbase_p.h"
#include "connectionedit_p.h"
#include "qdesigner_command_p.h"
diff --git a/tools/designer/src/lib/shared/newformwidget.cpp b/tools/designer/src/lib/shared/newformwidget.cpp
index d79d77a..503e597 100644
--- a/tools/designer/src/lib/shared/newformwidget.cpp
+++ b/tools/designer/src/lib/shared/newformwidget.cpp
@@ -310,9 +310,8 @@ QImage NewFormWidget::grabForm(QDesignerFormEditorInterface *core,
const QString &workingDir,
const qdesigner_internal::DeviceProfile &dp)
{
- qdesigner_internal::QDesignerFormBuilder formBuilder(core,
- qdesigner_internal::QDesignerFormBuilder::DisableScripts,
- dp);
+ qdesigner_internal::NewFormWidgetFormBuilder
+ formBuilder(core, qdesigner_internal::QDesignerFormBuilder::DisableScripts, dp);
if (!workingDir.isEmpty())
formBuilder.setWorkingDirectory(workingDir);
diff --git a/tools/designer/src/lib/shared/orderdialog.cpp b/tools/designer/src/lib/shared/orderdialog.cpp
index 3f14ca6..0df3866 100644
--- a/tools/designer/src/lib/shared/orderdialog.cpp
+++ b/tools/designer/src/lib/shared/orderdialog.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::OrderDialog
-*/
-
#include "orderdialog_p.h"
#include "iconloader_p.h"
#include "ui_orderdialog.h"
diff --git a/tools/designer/src/lib/shared/plaintexteditor.cpp b/tools/designer/src/lib/shared/plaintexteditor.cpp
index ce5cd5b..f30df3d 100644
--- a/tools/designer/src/lib/shared/plaintexteditor.cpp
+++ b/tools/designer/src/lib/shared/plaintexteditor.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::PlainTextEditorDialog
-*/
-
#include "plaintexteditor_p.h"
#include "abstractsettings_p.h"
diff --git a/tools/designer/src/lib/shared/pluginmanager.cpp b/tools/designer/src/lib/shared/pluginmanager.cpp
index 9dc8c7b..100a088 100644
--- a/tools/designer/src/lib/shared/pluginmanager.cpp
+++ b/tools/designer/src/lib/shared/pluginmanager.cpp
@@ -16,6 +16,8 @@
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
+What usually causes this mess is specifying a Z-order (raise/lower) widget or changing the tab order and then deleting the widget. Designer did not delete the widget from those settings, causing uic to report this when applying them. I believe we fixed that 4.5.
+
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
@@ -72,6 +74,11 @@ static const char *classAttributeC = "class";
static const char *customwidgetElementC = "customwidget";
static const char *extendsElementC = "extends";
static const char *addPageMethodC = "addpagemethod";
+static const char *propertySpecsC = "propertyspecifications";
+static const char *stringPropertySpecC = "stringpropertyspecification";
+static const char *stringPropertyNameAttrC = "name";
+static const char *stringPropertyTypeAttrC = "type";
+static const char *stringPropertyNoTrAttrC = "notr";
static const char *jambiLanguageC = "jambi";
enum { debugPluginManager = 0 };
@@ -141,6 +148,10 @@ static inline QString getDesignerLanguage(QDesignerFormEditorInterface *core)
class QDesignerCustomWidgetSharedData : public QSharedData {
public:
+ // Type of a string property
+ typedef QPair<qdesigner_internal::TextPropertyValidationMode, bool> StringPropertyType;
+ typedef QHash<QString, StringPropertyType> StringPropertyTypeMap;
+
explicit QDesignerCustomWidgetSharedData(const QString &thePluginPath) : pluginPath(thePluginPath) {}
void clearXML();
@@ -152,6 +163,7 @@ public:
QString xmlAddPageMethod;
QString xmlExtends;
+ StringPropertyTypeMap xmlStringPropertyTypeMap;
};
void QDesignerCustomWidgetSharedData::clearXML()
@@ -161,6 +173,7 @@ void QDesignerCustomWidgetSharedData::clearXML()
xmlLanguage.clear();
xmlAddPageMethod.clear();
xmlExtends.clear();
+ xmlStringPropertyTypeMap.clear();
}
// ---------------- QDesignerCustomWidgetData
@@ -220,6 +233,17 @@ QString QDesignerCustomWidgetData::pluginPath() const
return m_d->pluginPath;
}
+bool QDesignerCustomWidgetData::xmlStringPropertyType(const QString &name, StringPropertyType *type) const
+{
+ QDesignerCustomWidgetSharedData::StringPropertyTypeMap::const_iterator it = m_d->xmlStringPropertyTypeMap.constFind(name);
+ if (it == m_d->xmlStringPropertyTypeMap.constEnd()) {
+ *type = StringPropertyType(qdesigner_internal::ValidationRichText, true);
+ return false;
+ }
+ *type = it.value();
+ return true;
+}
+
// Wind a QXmlStreamReader until it finds an element. Returns index or one of FindResult
enum FindResult { FindError = -2, ElementNotFound = -1 };
@@ -249,6 +273,82 @@ static inline QString msgXmlError(const QString &name, const QString &errorMessa
return QDesignerPluginManager::tr("An XML error was encountered when parsing the XML of the custom widget %1: %2").arg(name, errorMessage);
}
+static inline QString msgAttributeMissing(const QString &name)
+{
+ return QDesignerPluginManager::tr("A required attribute ('%1') is missing.").arg(name);
+}
+
+static qdesigner_internal::TextPropertyValidationMode typeStringToType(const QString &v, bool *ok)
+{
+ *ok = true;
+ if (v == QLatin1String("multiline"))
+ return qdesigner_internal::ValidationMultiLine;
+ if (v == QLatin1String("richtext"))
+ return qdesigner_internal::ValidationRichText;
+ if (v == QLatin1String("stylesheet"))
+ return qdesigner_internal::ValidationStyleSheet;
+ if (v == QLatin1String("singleline"))
+ return qdesigner_internal::ValidationSingleLine;
+ if (v == QLatin1String("objectname"))
+ return qdesigner_internal::ValidationObjectName;
+ if (v == QLatin1String("objectnamescope"))
+ return qdesigner_internal::ValidationObjectNameScope;
+ if (v == QLatin1String("url"))
+ return qdesigner_internal::ValidationURL;
+ *ok = false;
+ return qdesigner_internal::ValidationRichText;
+}
+
+static bool parsePropertySpecs(QXmlStreamReader &sr,
+ QDesignerCustomWidgetSharedData::StringPropertyTypeMap *rc,
+ QString *errorMessage)
+{
+ const QString propertySpecs = QLatin1String(propertySpecsC);
+ const QString stringPropertySpec = QLatin1String(stringPropertySpecC);
+ const QString stringPropertyTypeAttr = QLatin1String(stringPropertyTypeAttrC);
+ const QString stringPropertyNoTrAttr = QLatin1String(stringPropertyNoTrAttrC);
+ const QString stringPropertyNameAttr = QLatin1String(stringPropertyNameAttrC);
+
+ while (!sr.atEnd()) {
+ switch(sr.readNext()) {
+ case QXmlStreamReader::StartElement: {
+ if (sr.name() != stringPropertySpec) {
+ *errorMessage = QDesignerPluginManager::tr("An invalid property specification ('%1') was encountered. Supported types: %2").arg(sr.name().toString(), stringPropertySpec);
+ return false;
+ }
+ const QXmlStreamAttributes atts = sr.attributes();
+ const QString name = atts.value(stringPropertyNameAttr).toString();
+ const QString type = atts.value(stringPropertyTypeAttr).toString();
+ const QString notrS = atts.value(stringPropertyNoTrAttr).toString(); //Optional
+
+ if (type.isEmpty()) {
+ *errorMessage = msgAttributeMissing(stringPropertyTypeAttr);
+ return false;
+ }
+ if (name.isEmpty()) {
+ *errorMessage = msgAttributeMissing(stringPropertyNameAttr);
+ return false;
+ }
+ bool typeOk;
+ const bool noTr = notrS == QLatin1String("true") || notrS == QLatin1String("1");
+ QDesignerCustomWidgetSharedData::StringPropertyType v(typeStringToType(type, &typeOk), !noTr);
+ if (!typeOk) {
+ *errorMessage = QDesignerPluginManager::tr("'%1' is not a valid string property specification!").arg(type);
+ return false;
+ }
+ rc->insert(name, v);
+ }
+ break;
+ case QXmlStreamReader::EndElement: // Outer </stringproperties>
+ if (sr.name() == propertySpecs)
+ return true;
+ default:
+ break;
+ }
+ }
+ return true;
+}
+
QDesignerCustomWidgetData::ParseResult
QDesignerCustomWidgetData::parseXml(const QString &xml, const QString &name, QString *errorMessage)
{
@@ -311,10 +411,11 @@ QDesignerCustomWidgetData::ParseResult
default:
break;
}
- // Find <extends>, <addPageMethod>
+ // Find <extends>, <addPageMethod>, <stringproperties>
elements.clear();
elements.push_back(QLatin1String(extendsElementC));
elements.push_back(QLatin1String(addPageMethodC));
+ elements.push_back(QLatin1String(propertySpecsC));
while (true) {
switch (findElement(elements, sr)) {
case FindError:
@@ -336,6 +437,12 @@ QDesignerCustomWidgetData::ParseResult
return ParseError;
}
break;
+ case 2: // <stringproperties>
+ if (!parsePropertySpecs(sr, &m_d->xmlStringPropertyTypeMap, errorMessage)) {
+ *errorMessage = msgXmlError(name, *errorMessage);
+ return ParseError;
+ }
+ break;
}
}
return rc;
@@ -345,6 +452,8 @@ QDesignerCustomWidgetData::ParseResult
class QDesignerPluginManagerPrivate {
public:
+ typedef QPair<QString, QString> ClassNamePropertyNameKey;
+
QDesignerPluginManagerPrivate(QDesignerFormEditorInterface *core);
void clearCustomWidgets();
@@ -562,7 +671,7 @@ bool QDesignerPluginManager::registerNewPlugins()
const int before = m_d->m_registeredPlugins.size();
foreach (const QString &path, m_d->m_pluginPaths)
- registerPath(path);
+ registerPath(path);
const bool newPluginsFound = m_d->m_registeredPlugins.size() > before;
// We force a re-initialize as Jambi collection might return
// different widget lists when switching projects.
@@ -654,6 +763,15 @@ QDesignerCustomWidgetData QDesignerPluginManager::customWidgetData(QDesignerCust
return m_d->m_customWidgetData.at(index);
}
+QDesignerCustomWidgetData QDesignerPluginManager::customWidgetData(const QString &name) const
+{
+ const int count = m_d->m_customWidgets.size();
+ for (int i = 0; i < count; i++)
+ if (m_d->m_customWidgets.at(i)->name() == name)
+ return m_d->m_customWidgetData.at(i);
+ return QDesignerCustomWidgetData();
+}
+
QObjectList QDesignerPluginManager::instances() const
{
QStringList plugins = registeredPlugins();
diff --git a/tools/designer/src/lib/shared/pluginmanager_p.h b/tools/designer/src/lib/shared/pluginmanager_p.h
index e374f42..f73bc74 100644
--- a/tools/designer/src/lib/shared/pluginmanager_p.h
+++ b/tools/designer/src/lib/shared/pluginmanager_p.h
@@ -54,9 +54,11 @@
#define PLUGINMANAGER_H
#include "shared_global_p.h"
+#include "shared_enums_p.h"
#include <QtCore/QSharedDataPointer>
#include <QtCore/QMap>
+#include <QtCore/QPair>
#include <QtCore/QStringList>
QT_BEGIN_NAMESPACE
@@ -70,6 +72,9 @@ class QDesignerCustomWidgetSharedData;
/* Information contained in the Dom XML of a custom widget. */
class QDESIGNER_SHARED_EXPORT QDesignerCustomWidgetData {
public:
+ // StringPropertyType: validation mode and translatable flag.
+ typedef QPair<qdesigner_internal::TextPropertyValidationMode, bool> StringPropertyType;
+
explicit QDesignerCustomWidgetData(const QString &pluginPath = QString());
enum ParseResult { ParseOk, ParseWarning, ParseError };
@@ -93,6 +98,8 @@ public:
QString xmlExtends() const;
// Optional. The name to be used in the widget box.
QString xmlDisplayName() const;
+ // Type of a string property
+ bool xmlStringPropertyType(const QString &name, StringPropertyType *type) const;
private:
QSharedDataPointer<QDesignerCustomWidgetSharedData> m_d;
@@ -128,6 +135,7 @@ public:
CustomWidgetList registeredCustomWidgets() const;
QDesignerCustomWidgetData customWidgetData(QDesignerCustomWidgetInterface *w) const;
+ QDesignerCustomWidgetData customWidgetData(const QString &className) const;
bool registerNewPlugins();
diff --git a/tools/designer/src/lib/shared/previewconfigurationwidget.cpp b/tools/designer/src/lib/shared/previewconfigurationwidget.cpp
index 2cf362f..2b45759 100644
--- a/tools/designer/src/lib/shared/previewconfigurationwidget.cpp
+++ b/tools/designer/src/lib/shared/previewconfigurationwidget.cpp
@@ -65,43 +65,27 @@
#include <QtCore/QFileInfo>
#include <QtCore/QSharedData>
-// #define DEFAULT_SKINS_FROM_RESOURCE
-#ifdef DEFAULT_SKINS_FROM_RESOURCE
-QT_BEGIN_NAMESPACE
+
static const char *skinResourcePathC = ":/skins/";
-QT_END_NAMESPACE
-#else
-# include <QtCore/QLibraryInfo>
-#endif
QT_BEGIN_NAMESPACE
static const char *skinExtensionC = "skin";
-namespace {
- // Pair of skin name, path
- typedef QPair<QString, QString> SkinNamePath;
- typedef QList<SkinNamePath> Skins;
- enum { SkinComboNoneIndex = 0 };
-}
+// Pair of skin name, path
+typedef QPair<QString, QString> SkinNamePath;
+typedef QList<SkinNamePath> Skins;
+enum { SkinComboNoneIndex = 0 };
// find default skins (resources)
static const Skins &defaultSkins() {
static Skins rc;
if (rc.empty()) {
-#ifdef DEFAULT_SKINS_FROM_RESOURCE
const QString skinPath = QLatin1String(skinResourcePathC);
-#else
- QString skinPath = QLibraryInfo::location(QLibraryInfo::PrefixPath);
- skinPath += QDir::separator();
- skinPath += QLatin1String("tools");
- skinPath += QDir::separator();
- skinPath += QLatin1String("qvfb");
-#endif
QString pattern = QLatin1String("*.");
pattern += QLatin1String(skinExtensionC);
const QDir dir(skinPath, pattern);
- const QFileInfoList list = dir.entryInfoList();
+ const QFileInfoList list = dir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot, QDir::Name);
if (list.empty())
return rc;
const QFileInfoList::const_iterator lcend = list.constEnd();
diff --git a/tools/designer/src/lib/shared/previewmanager.cpp b/tools/designer/src/lib/shared/previewmanager.cpp
index 8ed1772..ac16741 100644
--- a/tools/designer/src/lib/shared/previewmanager.cpp
+++ b/tools/designer/src/lib/shared/previewmanager.cpp
@@ -67,6 +67,7 @@
#include <QtGui/QAction>
#include <QtGui/QActionGroup>
#include <QtGui/QCursor>
+#include <QtGui/QMatrix>
#include <QtCore/QMap>
#include <QtCore/QDebug>
@@ -149,11 +150,16 @@ QGraphicsProxyWidget *DesignerZoomWidget::createProxyWidget(QGraphicsItem *paren
return new DesignerZoomProxyWidget(parent, wFlags);
}
-// --------- Widget Preview skin: Forward the key events to the window
+// PreviewDeviceSkin: Forwards the key events to the window and
+// provides context menu with rotation options. Derived class
+// can apply additional transformations to the skin.
+
class PreviewDeviceSkin : public DeviceSkin
{
Q_OBJECT
public:
+ enum Direction { DirectionUp, DirectionLeft, DirectionRight };
+
explicit PreviewDeviceSkin(const DeviceSkinParameters &parameters, QWidget *parent);
virtual void setPreview(QWidget *w);
QSize screenSize() const { return m_screenSize; }
@@ -164,15 +170,36 @@ private slots:
void slotPopupMenu();
protected:
- virtual void populateContextMenu(QMenu *m);
+ virtual void populateContextMenu(QMenu *) {}
+
+private slots:
+ void slotDirection(QAction *);
+
+protected:
+ // Fit the widget in case the orientation changes (transposing screensize)
+ virtual void fitWidget(const QSize &size);
+ // Calculate the complete transformation for the skin
+ // (base class implementation provides rotation).
+ virtual QMatrix skinTransform() const;
private:
const QSize m_screenSize;
+ Direction m_direction;
+
+ QAction *m_directionUpAction;
+ QAction *m_directionLeftAction;
+ QAction *m_directionRightAction;
+ QAction *m_closeAction;
};
PreviewDeviceSkin::PreviewDeviceSkin(const DeviceSkinParameters &parameters, QWidget *parent) :
- DeviceSkin(parameters, parent),
- m_screenSize(parameters.screenSize())
+ DeviceSkin(parameters, parent),
+ m_screenSize(parameters.screenSize()),
+ m_direction(DirectionUp),
+ m_directionUpAction(0),
+ m_directionLeftAction(0),
+ m_directionRightAction(0),
+ m_closeAction(0)
{
connect(this, SIGNAL(skinKeyPressEvent(int,QString,bool)),
this, SLOT(slotSkinKeyPressEvent(int,QString,bool)));
@@ -195,7 +222,6 @@ void PreviewDeviceSkin::slotSkinKeyPressEvent(int code, const QString& text, boo
QKeyEvent e(QEvent::KeyPress,code,0,text,autorep);
QApplication::sendEvent(focusWidget, &e);
}
-
}
void PreviewDeviceSkin::slotSkinKeyReleaseEvent(int code, const QString& text, bool autorep)
@@ -206,16 +232,83 @@ void PreviewDeviceSkin::slotSkinKeyReleaseEvent(int code, const QString& text, b
}
}
+// Create a checkable action with integer data and
+// set it checked if it matches the currentState.
+static inline QAction
+ *createCheckableActionIntData(const QString &label,
+ int actionValue, int currentState,
+ QActionGroup *ag, QObject *parent)
+{
+ QAction *a = new QAction(label, parent);
+ a->setData(actionValue);
+ a->setCheckable(true);
+ if (actionValue == currentState)
+ a->setChecked(true);
+ ag->addAction(a);
+ return a;
+}
+
void PreviewDeviceSkin::slotPopupMenu()
{
QMenu menu(this);
+ // Create actions
+ if (!m_directionUpAction) {
+ QActionGroup *directionGroup = new QActionGroup(this);
+ connect(directionGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotDirection(QAction*)));
+ directionGroup->setExclusive(true);
+ m_directionUpAction = createCheckableActionIntData(tr("&Portrait"), DirectionUp, m_direction, directionGroup, this);
+ m_directionLeftAction = createCheckableActionIntData(tr("Landscape (&CCW)"), DirectionLeft, m_direction, directionGroup, this);
+ m_directionRightAction = createCheckableActionIntData(tr("&Landscape (CW)"), DirectionRight, m_direction, directionGroup, this);
+ m_closeAction = new QAction(tr("&Close"), this);
+ connect(m_closeAction, SIGNAL(triggered()), parentWidget(), SLOT(close()));
+ }
+ menu.addAction(m_directionUpAction);
+ menu.addAction(m_directionLeftAction);
+ menu.addAction(m_directionRightAction);
+ menu.addSeparator();
populateContextMenu(&menu);
+ menu.addAction(m_closeAction);
menu.exec(QCursor::pos());
}
-void PreviewDeviceSkin::populateContextMenu(QMenu *menu)
+void PreviewDeviceSkin::slotDirection(QAction *a)
+{
+ const Direction newDirection = static_cast<Direction>(a->data().toInt());
+ if (m_direction == newDirection)
+ return;
+ const Qt::Orientation newOrientation = newDirection == DirectionUp ? Qt::Vertical : Qt::Horizontal;
+ const Qt::Orientation oldOrientation = m_direction == DirectionUp ? Qt::Vertical : Qt::Horizontal;
+ m_direction = newDirection;
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+ if (oldOrientation != newOrientation) {
+ QSize size = screenSize();
+ if (newOrientation == Qt::Horizontal)
+ size.transpose();
+ fitWidget(size);
+ }
+ setTransform(skinTransform());
+ QApplication::restoreOverrideCursor();
+}
+
+void PreviewDeviceSkin::fitWidget(const QSize &size)
+{
+ view()->setFixedSize(size);
+}
+
+QMatrix PreviewDeviceSkin::skinTransform() const
{
- connect(menu->addAction(tr("&Close")), SIGNAL(triggered()), parentWidget(), SLOT(close()));
+ QMatrix newTransform;
+ switch (m_direction) {
+ case DirectionUp:
+ break;
+ case DirectionLeft:
+ newTransform.rotate(270.0);
+ break;
+ case DirectionRight:
+ newTransform.rotate(90.0);
+ break;
+ }
+ return newTransform;
}
// ------------ PreviewConfigurationPrivate
@@ -257,16 +350,20 @@ signals:
void zoomPercentChanged(int);
protected:
- virtual void populateContextMenu(QMenu *m);
+ virtual void populateContextMenu(QMenu *m);
+ virtual QMatrix skinTransform() const;
+ virtual void fitWidget(const QSize &size);
private:
ZoomMenu *m_zoomMenu;
+ QAction *m_zoomSubMenuAction;
ZoomWidget *m_zoomWidget;
};
ZoomablePreviewDeviceSkin::ZoomablePreviewDeviceSkin(const DeviceSkinParameters &parameters, QWidget *parent) :
PreviewDeviceSkin(parameters, parent),
m_zoomMenu(new ZoomMenu(this)),
+ m_zoomSubMenuAction(0),
m_zoomWidget(new DesignerZoomWidget)
{
connect(m_zoomMenu, SIGNAL(zoomChanged(int)), this, SLOT(setZoomPercent(int)));
@@ -279,10 +376,20 @@ ZoomablePreviewDeviceSkin::ZoomablePreviewDeviceSkin(const DeviceSkinParameters
setView(m_zoomWidget);
}
-void ZoomablePreviewDeviceSkin::setPreview(QWidget *formWidget)
+static inline qreal zoomFactor(int percent)
{
- formWidget->setFixedSize(screenSize());
+ return qreal(percent) / 100.0;
+}
+
+static inline QSize scaleSize(int zoomPercent, const QSize &size)
+{
+ return zoomPercent == 100 ? size : (QSizeF(size) * zoomFactor(zoomPercent)).toSize();
+}
+
+void ZoomablePreviewDeviceSkin::setPreview(QWidget *formWidget)
+{
m_zoomWidget->setWidget(formWidget);
+ m_zoomWidget->resize(scaleSize(zoomPercent(), screenSize()));
}
int ZoomablePreviewDeviceSkin::zoomPercent() const
@@ -290,32 +397,50 @@ int ZoomablePreviewDeviceSkin::zoomPercent() const
return m_zoomWidget->zoom();
}
-void ZoomablePreviewDeviceSkin::setZoomPercent(int z)
+void ZoomablePreviewDeviceSkin::setZoomPercent(int zp)
{
- if (z == zoomPercent())
+ if (zp == zoomPercent())
return;
// If not triggered by the menu itself: Update it
- if (m_zoomMenu->zoom() != z)
- m_zoomMenu->setZoom(z);
+ if (m_zoomMenu->zoom() != zp)
+ m_zoomMenu->setZoom(zp);
- const QCursor oldCursor = cursor();
- QApplication::setOverrideCursor(Qt::WaitCursor);
- // DeviceSkin has double, not qreal.
- const double hundred = 100.0;
- setZoom(static_cast<double>(z) / hundred);
- m_zoomWidget->setZoom(z);
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+ m_zoomWidget->setZoom(zp);
+ setTransform(skinTransform());
QApplication::restoreOverrideCursor();
}
void ZoomablePreviewDeviceSkin::populateContextMenu(QMenu *menu)
{
- m_zoomMenu->addActions(menu);
- menu->addSeparator();
- PreviewDeviceSkin::populateContextMenu(menu);
+ if (!m_zoomSubMenuAction) {
+ m_zoomSubMenuAction = new QAction(tr("&Zoom"), this);
+ QMenu *zoomSubMenu = new QMenu;
+ m_zoomSubMenuAction->setMenu(zoomSubMenu);
+ m_zoomMenu->addActions(zoomSubMenu);
+ }
+ menu->addAction(m_zoomSubMenuAction);
menu->addSeparator();
}
+QMatrix ZoomablePreviewDeviceSkin::skinTransform() const
+{
+ // Complete transformation consisting of base class rotation and zoom.
+ QMatrix rc = PreviewDeviceSkin::skinTransform();
+ const int zp = zoomPercent();
+ if (zp != 100) {
+ const qreal factor = zoomFactor(zp);
+ rc.scale(factor, factor);
+ }
+ return rc;
+}
+
+void ZoomablePreviewDeviceSkin::fitWidget(const QSize &size)
+{
+ m_zoomWidget->resize(scaleSize(zoomPercent(), size));
+}
+
// ------------- PreviewConfiguration
static const char *styleKey = "Style";
diff --git a/tools/designer/src/lib/shared/promotionmodel.cpp b/tools/designer/src/lib/shared/promotionmodel.cpp
index 77d0bbb..1df9cbe 100644
--- a/tools/designer/src/lib/shared/promotionmodel.cpp
+++ b/tools/designer/src/lib/shared/promotionmodel.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::PromotionModel
-*/
-
#include "promotionmodel_p.h"
#include "widgetdatabase_p.h"
diff --git a/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp b/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp
index 6394847..b92a48d 100644
--- a/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp
@@ -473,6 +473,20 @@ QPixmap QDesignerFormBuilder::createPreviewPixmap(const QDesignerFormWindowInter
return rc;
}
+// ---------- NewFormWidgetFormBuilder
+
+NewFormWidgetFormBuilder::NewFormWidgetFormBuilder(QDesignerFormEditorInterface *core,
+ Mode mode,
+ const DeviceProfile &deviceProfile) :
+ QDesignerFormBuilder(core, mode, deviceProfile)
+{
+}
+
+void NewFormWidgetFormBuilder::createCustomWidgets(DomCustomWidgets *dc)
+{
+ QSimpleResource::handleDomCustomWidgets(core(), dc);
+}
+
} // namespace qdesigner_internal
QT_END_NAMESPACE
diff --git a/tools/designer/src/lib/shared/qdesigner_formbuilder_p.h b/tools/designer/src/lib/shared/qdesigner_formbuilder_p.h
index b982e1c..ee40085 100644
--- a/tools/designer/src/lib/shared/qdesigner_formbuilder_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_formbuilder_p.h
@@ -75,7 +75,7 @@ namespace qdesigner_internal {
class DesignerPixmapCache;
class DesignerIconCache;
-/* Form builder used for previewing forms, widget box and new form dialog.
+/* Form builder used for previewing forms and widget box.
* It applies the system settings to its toplevel window. */
class QDESIGNER_SHARED_EXPORT QDesignerFormBuilder: public QFormBuilder
@@ -159,6 +159,21 @@ private:
bool m_mainWidget;
};
+// Form builder for a new form widget (preview). To allow for promoted
+// widgets in the template, it implements the handling of custom widgets
+// (adding of them to the widget database).
+
+class QDESIGNER_SHARED_EXPORT NewFormWidgetFormBuilder: public QDesignerFormBuilder {
+public:
+ NewFormWidgetFormBuilder(QDesignerFormEditorInterface *core,
+ Mode mode,
+ const DeviceProfile &deviceProfile = DeviceProfile());
+
+protected:
+ virtual void createCustomWidgets(DomCustomWidgets *);
+};
+
+
} // namespace qdesigner_internal
QT_END_NAMESPACE
diff --git a/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp b/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp
index 8453c16..a1c47d2 100644
--- a/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::QDesignerPromotionDialog
-*/
-
#include "qdesigner_promotiondialog_p.h"
#include "promotionmodel_p.h"
#include "iconloader_p.h"
diff --git a/tools/designer/src/lib/shared/qdesigner_propertyeditor.cpp b/tools/designer/src/lib/shared/qdesigner_propertyeditor.cpp
index 7c7d9d7..3875d0e 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertyeditor.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_propertyeditor.cpp
@@ -40,16 +40,56 @@
****************************************************************************/
#include "qdesigner_propertyeditor_p.h"
-#ifdef Q_OS_WIN
-# include <widgetfactory_p.h>
-#endif
-#include <QAction>
-#include <QLineEdit>
-#include <QAbstractButton>
+#include "pluginmanager_p.h"
+
+#include <QtDesigner/QDesignerFormEditorInterface>
+#include <widgetfactory_p.h>
+#include <QtGui/QAction>
+#include <QtGui/QLineEdit>
+#include <QtGui/QAbstractButton>
QT_BEGIN_NAMESPACE
namespace qdesigner_internal {
+typedef QDesignerPropertyEditor::StringPropertyParameters StringPropertyParameters;
+// A map of property name to type
+typedef QHash<QString, StringPropertyParameters> PropertyNameTypeMap;
+
+// Compile a map of hard-coded string property types
+static const PropertyNameTypeMap &stringPropertyTypes()
+{
+ static PropertyNameTypeMap propertyNameTypeMap;
+ if (propertyNameTypeMap.empty()) {
+ const StringPropertyParameters richtext(ValidationRichText, true);
+ // Accessibility. Both are texts the narrator reads
+ propertyNameTypeMap.insert(QLatin1String("accessibleDescription"), richtext);
+ propertyNameTypeMap.insert(QLatin1String("accessibleName"), richtext);
+ // object names
+ const StringPropertyParameters objectName(ValidationObjectName, false);
+ propertyNameTypeMap.insert(QLatin1String("buddy"), objectName);
+ propertyNameTypeMap.insert(QLatin1String("currentItemName"), objectName);
+ propertyNameTypeMap.insert(QLatin1String("currentPageName"), objectName);
+ propertyNameTypeMap.insert(QLatin1String("currentTabName"), objectName);
+ propertyNameTypeMap.insert(QLatin1String("layoutName"), objectName);
+ propertyNameTypeMap.insert(QLatin1String("spacerName"), objectName);
+ // Style sheet
+ propertyNameTypeMap.insert(QLatin1String("styleSheet"), StringPropertyParameters(ValidationStyleSheet, false));
+ // Buttons/ QCommandLinkButton
+ const StringPropertyParameters multiline(ValidationMultiLine, true);
+ propertyNameTypeMap.insert(QLatin1String("description"), multiline);
+ propertyNameTypeMap.insert(QLatin1String("iconText"), multiline);
+ // Tooltips, etc.
+ propertyNameTypeMap.insert(QLatin1String("toolTip"), richtext);
+ propertyNameTypeMap.insert(QLatin1String("whatsThis"), richtext);
+ propertyNameTypeMap.insert(QLatin1String("windowIconText"), richtext);
+ propertyNameTypeMap.insert(QLatin1String("html"), richtext);
+ // A QWizard page id
+ propertyNameTypeMap.insert(QLatin1String("pageId"), StringPropertyParameters(ValidationSingleLine, false));
+ // QPlainTextEdit
+ propertyNameTypeMap.insert(QLatin1String("plainText"), StringPropertyParameters(ValidationMultiLine, true));
+ }
+ return propertyNameTypeMap;
+}
QDesignerPropertyEditor::QDesignerPropertyEditor(QWidget *parent, Qt::WindowFlags flags) :
QDesignerPropertyEditorInterface(parent, flags)
@@ -68,33 +108,19 @@ QDesignerPropertyEditor::StringPropertyParameters QDesignerPropertyEditor::textP
return StringPropertyParameters(vm, false);
}
- // Accessibility. Both are texts the narrator reads
- if (propertyName == QLatin1String("accessibleDescription") || propertyName == QLatin1String("accessibleName"))
- return StringPropertyParameters(ValidationRichText, true);
-
- // Names
- if (propertyName == QLatin1String("buddy")
- || propertyName == QLatin1String("currentItemName")
- || propertyName == QLatin1String("currentPageName")
- || propertyName == QLatin1String("currentTabName")
- || propertyName == QLatin1String("layoutName")
- || propertyName == QLatin1String("spacerName"))
- return StringPropertyParameters(ValidationObjectName, false);
-
- if (propertyName.endsWith(QLatin1String("Name")))
- return StringPropertyParameters(ValidationSingleLine, true);
-
- // Multi line?
- if (propertyName == QLatin1String("styleSheet"))
- return StringPropertyParameters(ValidationStyleSheet, false);
-
- if (propertyName == QLatin1String("description") || propertyName == QLatin1String("iconText")) // QCommandLinkButton
- return StringPropertyParameters(ValidationMultiLine, true);
+ // Check custom widgets by class.
+ const QString className = WidgetFactory::classNameOf(core, object);
+ const QDesignerCustomWidgetData customData = core->pluginManager()->customWidgetData(className);
+ if (!customData.isNull()) {
+ StringPropertyParameters customType;
+ if (customData.xmlStringPropertyType(propertyName, &customType))
+ return customType;
+ }
- if (propertyName == QLatin1String("toolTip") || propertyName.endsWith(QLatin1String("ToolTip")) ||
- propertyName == QLatin1String("whatsThis") ||
- propertyName == QLatin1String("windowIconText") || propertyName == QLatin1String("html"))
- return StringPropertyParameters(ValidationRichText, true);
+ // Check hardcoded property ames
+ const PropertyNameTypeMap::const_iterator hit = stringPropertyTypes().constFind(propertyName);
+ if (hit != stringPropertyTypes().constEnd())
+ return hit.value();
// text: Check according to widget type.
if (propertyName == QLatin1String("text")) {
@@ -104,17 +130,17 @@ QDesignerPropertyEditor::StringPropertyParameters QDesignerPropertyEditor::textP
return StringPropertyParameters(ValidationMultiLine, true);
return StringPropertyParameters(ValidationRichText, true);
}
- if (propertyName == QLatin1String("pageId")) // A QWizard page id
- return StringPropertyParameters(ValidationSingleLine, false);
- if (propertyName == QLatin1String("plainText")) // QPlainTextEdit
- return StringPropertyParameters(ValidationMultiLine, true);
+ // Fuzzy matching
+ if (propertyName.endsWith(QLatin1String("Name")))
+ return StringPropertyParameters(ValidationSingleLine, true);
+
+ if (propertyName.endsWith(QLatin1String("ToolTip")))
+ return StringPropertyParameters(ValidationRichText, true);
#ifdef Q_OS_WIN // No translation for the active X "control" property
- if (propertyName == QLatin1String("control") && WidgetFactory::classNameOf(core, object) == QLatin1String("QAxWidget"))
+ if (propertyName == QLatin1String("control") && className == QLatin1String("QAxWidget"))
return StringPropertyParameters(ValidationSingleLine, false);
-#else
- Q_UNUSED(core);
#endif
// default to single
diff --git a/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp b/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp
index cce0528..d85e18f 100644
--- a/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::QDesignerTaskMenu
-*/
-
#include "qdesigner_taskmenu_p.h"
#include "qdesigner_command_p.h"
#include "richtexteditor_p.h"
diff --git a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
index cb77801..898be1e 100644
--- a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::Sentinel
-*/
-
#include "qdesigner_toolbar_p.h"
#include "qdesigner_command_p.h"
#include "actionrepository_p.h"
@@ -65,7 +61,6 @@ TRANSLATOR qdesigner_internal::Sentinel
#include <QtGui/QMenu>
#include <QtGui/qevent.h>
#include <QtGui/QApplication>
-#include <QtGui/private/qtoolbarlayout_p.h>
#include <QtCore/QDebug>
Q_DECLARE_METATYPE(QAction*)
@@ -445,11 +440,17 @@ QAction *ToolBarEventFilter::actionAt(const QToolBar *tb, const QPoint &pos)
return tb->actions().at(index);
}
+//that's a trick to get acces to the initStyleOption which is a protected member
+class FriendlyToolBar : public QToolBar {
+public:
+ friend class ToolBarEventFilter;
+};
+
QRect ToolBarEventFilter::handleArea(const QToolBar *tb)
{
- const QToolBarLayout *tbl = qobject_cast<QToolBarLayout *>(tb->layout());
- Q_ASSERT(tbl);
- return tbl->handleRect();
+ QStyleOptionToolBar opt;
+ static_cast<const FriendlyToolBar*>(tb)->initStyleOption(&opt);
+ return tb->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, tb);
}
bool ToolBarEventFilter::withinHandleArea(const QToolBar *tb, const QPoint &pos)
diff --git a/tools/designer/src/lib/shared/qdesigner_widgetbox.cpp b/tools/designer/src/lib/shared/qdesigner_widgetbox.cpp
index 5ba8ad7..d94a397 100644
--- a/tools/designer/src/lib/shared/qdesigner_widgetbox.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_widgetbox.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::QDesignerWidgetBox
-*/
-
#include "qdesigner_widgetbox_p.h"
#include "qdesigner_utils_p.h"
diff --git a/tools/designer/src/lib/shared/qsimpleresource.cpp b/tools/designer/src/lib/shared/qsimpleresource.cpp
index 8d29002..69d48fd 100644
--- a/tools/designer/src/lib/shared/qsimpleresource.cpp
+++ b/tools/designer/src/lib/shared/qsimpleresource.cpp
@@ -41,6 +41,7 @@
#include "qsimpleresource_p.h"
#include "widgetfactory_p.h"
+#include "widgetdatabase_p.h"
#include <formscriptrunner_p.h>
#include <properties_p.h>
@@ -57,6 +58,8 @@
#include <QtGui/QWidget>
#include <QtGui/QAction>
#include <QtCore/QDebug>
+#include <QtCore/QCoreApplication>
+
QT_BEGIN_NAMESPACE
@@ -267,6 +270,136 @@ bool QSimpleResource::warningsEnabled()
return m_warningsEnabled;
}
+// Custom widgets handling helpers
+
+// Add unique fake slots and signals to lists
+bool QSimpleResource::addFakeMethods(const DomSlots *domSlots, QStringList &fakeSlots, QStringList &fakeSignals)
+{
+ if (!domSlots)
+ return false;
+
+ bool rc = false;
+ foreach (const QString &fakeSlot, domSlots->elementSlot())
+ if (fakeSlots.indexOf(fakeSlot) == -1) {
+ fakeSlots += fakeSlot;
+ rc = true;
+ }
+
+ foreach (const QString &fakeSignal, domSlots->elementSignal())
+ if (fakeSignals.indexOf(fakeSignal) == -1) {
+ fakeSignals += fakeSignal;
+ rc = true;
+ }
+ return rc;
+}
+
+void QSimpleResource::addFakeMethodsToWidgetDataBase(const DomCustomWidget *domCustomWidget, WidgetDataBaseItem *item)
+{
+ const DomSlots *domSlots = domCustomWidget->elementSlots();
+ if (!domSlots)
+ return;
+
+ // Merge in new slots, signals
+ QStringList fakeSlots = item->fakeSlots();
+ QStringList fakeSignals = item->fakeSignals();
+ if (addFakeMethods(domSlots, fakeSlots, fakeSignals)) {
+ item->setFakeSlots(fakeSlots);
+ item->setFakeSignals(fakeSignals);
+ }
+}
+
+// Perform one iteration of adding the custom widgets to the database,
+// looking up the base class and inheriting its data.
+// Remove the succeeded custom widgets from the list.
+// Classes whose base class could not be found are left in the list.
+
+void QSimpleResource::addCustomWidgetsToWidgetDatabase(const QDesignerFormEditorInterface *core,
+ QList<DomCustomWidget*>& custom_widget_list)
+{
+ QDesignerWidgetDataBaseInterface *db = core->widgetDataBase();
+ for (int i=0; i < custom_widget_list.size(); ) {
+ bool classInserted = false;
+ DomCustomWidget *custom_widget = custom_widget_list[i];
+ const QString customClassName = custom_widget->elementClass();
+ const QString base_class = custom_widget->elementExtends();
+ QString includeFile;
+ IncludeType includeType = IncludeLocal;
+ if (const DomHeader *header = custom_widget->elementHeader()) {
+ includeFile = header->text();
+ if (header->hasAttributeLocation() && header->attributeLocation() == QLatin1String("global"))
+ includeType = IncludeGlobal;
+ }
+ const bool domIsContainer = custom_widget->elementContainer();
+ // Append a new item
+ if (base_class.isEmpty()) {
+ WidgetDataBaseItem *item = new WidgetDataBaseItem(customClassName);
+ item->setPromoted(false);
+ item->setGroup(QCoreApplication::translate("Designer", "Custom Widgets"));
+ item->setIncludeFile(buildIncludeFile(includeFile, includeType));
+ item->setContainer(domIsContainer);
+ item->setCustom(true);
+ addFakeMethodsToWidgetDataBase(custom_widget, item);
+ db->append(item);
+ custom_widget_list.removeAt(i);
+ classInserted = true;
+ } else {
+ // Create a new entry cloned from base class. Note that this will ignore existing
+ // classes, eg, plugin custom widgets.
+ QDesignerWidgetDataBaseItemInterface *item =
+ appendDerived(db, customClassName, QCoreApplication::translate("Designer", "Promoted Widgets"),
+ base_class,
+ buildIncludeFile(includeFile, includeType),
+ true,true);
+ // Ok, base class found.
+ if (item) {
+ // Hack to accommodate for old UI-files in which "container" is not set properly:
+ // Apply "container" from DOM only if true (else, eg classes from QFrame might not accept
+ // dropping child widgets on them as container=false). This also allows for
+ // QWidget-derived stacked pages.
+ if (domIsContainer)
+ item->setContainer(domIsContainer);
+
+ addFakeMethodsToWidgetDataBase(custom_widget, static_cast<WidgetDataBaseItem*>(item));
+ custom_widget_list.removeAt(i);
+ classInserted = true;
+ }
+ }
+ // Skip failed item.
+ if (!classInserted)
+ i++;
+ }
+
+}
+
+void QSimpleResource::handleDomCustomWidgets(const QDesignerFormEditorInterface *core,
+ const DomCustomWidgets *dom_custom_widgets)
+{
+ if (dom_custom_widgets == 0)
+ return;
+ QList<DomCustomWidget*> custom_widget_list = dom_custom_widgets->elementCustomWidget();
+ // Attempt to insert each item derived from its base class.
+ // This should at most require two iterations in the event that the classes are out of order
+ // (derived first, max depth: promoted custom plugin = 2)
+ for (int iteration = 0; iteration < 2; iteration++) {
+ addCustomWidgetsToWidgetDatabase(core, custom_widget_list);
+ if (custom_widget_list.empty())
+ return;
+ }
+ // Oops, there are classes left whose base class could not be found.
+ // Default them to QWidget with warnings.
+ const QString fallBackBaseClass = QLatin1String("QWidget");
+ for (int i=0; i < custom_widget_list.size(); i++ ) {
+ DomCustomWidget *custom_widget = custom_widget_list[i];
+ const QString customClassName = custom_widget->elementClass();
+ const QString base_class = custom_widget->elementExtends();
+ qDebug() << "** WARNING The base class " << base_class << " of the custom widget class " << customClassName
+ << " could not be found. Defaulting to " << fallBackBaseClass << '.';
+ custom_widget->setElementExtends(fallBackBaseClass);
+ }
+ // One more pass.
+ addCustomWidgetsToWidgetDatabase(core, custom_widget_list);
+}
+
// ------------ FormBuilderClipboard
FormBuilderClipboard::FormBuilderClipboard(QWidget *w)
diff --git a/tools/designer/src/lib/shared/qsimpleresource_p.h b/tools/designer/src/lib/shared/qsimpleresource_p.h
index 8d45c3c..a25cb88 100644
--- a/tools/designer/src/lib/shared/qsimpleresource_p.h
+++ b/tools/designer/src/lib/shared/qsimpleresource_p.h
@@ -55,15 +55,21 @@
#include "shared_global_p.h"
#include "abstractformbuilder.h"
+#include <QtCore/QStringList>
QT_BEGIN_NAMESPACE
class DomScript;
+class DomCustomWidgets;
+class DomCustomWidget;
+class DomSlots;
class QDesignerFormEditorInterface;
namespace qdesigner_internal {
+class WidgetDataBaseItem;
+
class QDESIGNER_SHARED_EXPORT QSimpleResource : public QAbstractFormBuilder
{
public:
@@ -92,6 +98,11 @@ public:
static QString customWidgetScript(QDesignerFormEditorInterface *core, const QString &className);
static bool hasCustomWidgetScript(QDesignerFormEditorInterface *core, QObject *object);
+ // Implementation for FormBuilder::createDomCustomWidgets() that adds
+ // the custom widgets to the widget database
+ static void handleDomCustomWidgets(const QDesignerFormEditorInterface *core,
+ const DomCustomWidgets *dom_custom_widgets);
+
protected:
virtual QIcon nameToIcon(const QString &filePath, const QString &qrcPath);
virtual QString iconToFilePath(const QIcon &pm) const;
@@ -105,7 +116,13 @@ protected:
typedef QList<DomScript*> DomScripts;
static void addScript(const QString &script, ScriptSource source, DomScripts &domScripts);
+ static bool addFakeMethods(const DomSlots *domSlots, QStringList &fakeSlots, QStringList &fakeSignals);
+
private:
+ static void addCustomWidgetsToWidgetDatabase(const QDesignerFormEditorInterface *core,
+ QList<DomCustomWidget*>& custom_widget_list);
+ static void addFakeMethodsToWidgetDataBase(const DomCustomWidget *domCustomWidget, WidgetDataBaseItem *item);
+
static bool m_warningsEnabled;
QDesignerFormEditorInterface *m_core;
};
diff --git a/tools/designer/src/lib/shared/qtresourceview.cpp b/tools/designer/src/lib/shared/qtresourceview.cpp
index 22439a2..34087ee 100644
--- a/tools/designer/src/lib/shared/qtresourceview.cpp
+++ b/tools/designer/src/lib/shared/qtresourceview.cpp
@@ -44,6 +44,7 @@
#include "qtresourcemodel_p.h"
#include "qtresourceeditordialog_p.h"
#include "iconloader_p.h"
+#include "filterwidget_p.h" // For FilterWidget
#include <QtDesigner/QDesignerFormEditorInterface>
@@ -144,6 +145,7 @@ public:
void slotReloadResources();
void slotCopyResourcePath();
void slotListWidgetContextMenuRequested(const QPoint &pos);
+ void slotFilterChanged(const QString &pattern);
void createPaths();
QTreeWidgetItem *createPath(const QString &path, QTreeWidgetItem *parent);
void createResources(const QString &path);
@@ -152,16 +154,20 @@ public:
void restoreSettings();
void saveSettings();
void updateActions();
+ void filterOutResources();
QPixmap makeThumbnail(const QPixmap &pix) const;
QDesignerFormEditorInterface *m_core;
QtResourceModel *m_resourceModel;
QToolBar *m_toolBar;
+ qdesigner_internal::FilterWidget *m_filterWidget;
QTreeWidget *m_treeWidget;
QListWidget *m_listWidget;
QSplitter *m_splitter;
- QMap<QString, QStringList> m_pathToContents; // full path to contents file names
+ QMap<QString, QStringList> m_pathToContents; // full path to contents file names (full path to its resource filenames)
+ QMap<QString, QString> m_pathToParentPath; // full path to full parent path
+ QMap<QString, QStringList> m_pathToSubPaths; // full path to full sub paths
QMap<QString, QTreeWidgetItem *> m_pathToItem;
QMap<QTreeWidgetItem *, QString> m_itemToPath;
QMap<QString, QListWidgetItem *> m_resourceToItem;
@@ -175,6 +181,7 @@ public:
bool m_ignoreGuiSignals;
QString m_settingsKey;
bool m_resourceEditingEnabled;
+ QString m_filterPattern;
};
QtResourceViewPrivate::QtResourceViewPrivate(QDesignerFormEditorInterface *core) :
@@ -251,6 +258,12 @@ void QtResourceViewPrivate::slotListWidgetContextMenuRequested(const QPoint &pos
menu.exec(m_listWidget->mapToGlobal(pos));
}
+void QtResourceViewPrivate::slotFilterChanged(const QString &pattern)
+{
+ m_filterPattern = pattern;
+ filterOutResources();
+}
+
void QtResourceViewPrivate::storeExpansionState()
{
QMapIterator<QString, QTreeWidgetItem *> it(m_pathToItem);
@@ -294,6 +307,7 @@ void QtResourceViewPrivate::updateActions()
m_editResourcesAction->setVisible(m_resourceEditingEnabled);
m_editResourcesAction->setEnabled(resourceActive);
m_reloadResourcesAction->setEnabled(resourceActive);
+ m_filterWidget->setEnabled(resourceActive);
}
void QtResourceViewPrivate::slotResourceSetActivated(QtResourceSet *resourceSet)
@@ -307,6 +321,8 @@ void QtResourceViewPrivate::slotResourceSetActivated(QtResourceSet *resourceSet)
const QString currentResource = m_itemToResource.value(m_listWidget->currentItem());
m_treeWidget->clear();
m_pathToContents.clear();
+ m_pathToParentPath.clear();
+ m_pathToSubPaths.clear();
m_pathToItem.clear();
m_itemToPath.clear();
m_listWidget->clear();
@@ -320,6 +336,7 @@ void QtResourceViewPrivate::slotResourceSetActivated(QtResourceSet *resourceSet)
q_ptr->selectResource(currentResource);
else if (!currentPath.isEmpty())
q_ptr->selectResource(currentPath);
+ filterOutResources();
}
void QtResourceViewPrivate::slotCurrentPathChanged(QTreeWidgetItem *item)
@@ -362,9 +379,6 @@ void QtResourceViewPrivate::createPaths()
const QString root(QLatin1Char(':'));
- QMap<QString, QString> pathToParentPath; // full path to full parent path
- QMap<QString, QStringList> pathToSubPaths; // full path to full sub paths
-
QMap<QString, QString> contents = m_resourceModel->contents();
QMapIterator<QString, QString> itContents(contents);
while (itContents.hasNext()) {
@@ -372,11 +386,11 @@ void QtResourceViewPrivate::createPaths()
const QFileInfo fi(filePath);
QString dirPath = fi.absolutePath();
m_pathToContents[dirPath].append(fi.fileName());
- while (!pathToParentPath.contains(dirPath) && dirPath != root) {
+ while (!m_pathToParentPath.contains(dirPath) && dirPath != root) { // create all parent paths
const QFileInfo fd(dirPath);
const QString parentDirPath = fd.absolutePath();
- pathToParentPath[dirPath] = parentDirPath;
- pathToSubPaths[parentDirPath].append(dirPath);
+ m_pathToParentPath[dirPath] = parentDirPath;
+ m_pathToSubPaths[parentDirPath].append(dirPath);
dirPath = parentDirPath;
}
}
@@ -387,13 +401,126 @@ void QtResourceViewPrivate::createPaths()
QPair<QString, QTreeWidgetItem *> pathToParentItem = pathToParentItemQueue.dequeue();
const QString path = pathToParentItem.first;
QTreeWidgetItem *item = createPath(path, pathToParentItem.second);
- QStringList subPaths = pathToSubPaths.value(path);
+ QStringList subPaths = m_pathToSubPaths.value(path);
QStringListIterator itSubPaths(subPaths);
while (itSubPaths.hasNext())
pathToParentItemQueue.enqueue(qMakePair(itSubPaths.next(), item));
}
}
+void QtResourceViewPrivate::filterOutResources()
+{
+ QMap<QString, bool> pathToMatchingContents; // true means the path has any matching contents
+ QMap<QString, bool> pathToVisible; // true means the path has to be shown
+
+ // 1) we go from root path recursively.
+ // 2) we check every path if it contains at least one matching resource - if empty we add it
+ // to pathToMatchingContents and pathToVisible with false, if non empty
+ // we add it with true and change every parent path in pathToVisible to true.
+ // 3) we hide these items which has pathToVisible value false.
+
+ const bool matchAll = m_filterPattern.isEmpty();
+ const QString root(QLatin1Char(':'));
+
+ QQueue<QString> pathQueue;
+ pathQueue.enqueue(root);
+ while (!pathQueue.isEmpty()) {
+ const QString path = pathQueue.dequeue();
+
+ QStringList fileNames = m_pathToContents.value(path);
+ QStringListIterator it(fileNames);
+ bool hasContents = matchAll;
+ if (!matchAll) { // the case filter is not empty - we check if the path contains anything
+ while (it.hasNext()) {
+ QString fileName = it.next();
+ hasContents = fileName.contains(m_filterPattern, Qt::CaseInsensitive);
+ if (hasContents) // the path contains at least one resource which matches the filter
+ break;
+ }
+ }
+
+ pathToMatchingContents[path] = hasContents;
+ pathToVisible[path] = hasContents;
+
+ if (hasContents) { // if the path is going to be shown we need to show all its parent paths
+ QString parentPath = m_pathToParentPath.value(path);
+ while (!parentPath.isEmpty()) {
+ QString p = parentPath;
+ if (pathToVisible.value(p)) // parent path is already shown, we break the loop
+ break;
+ pathToVisible[p] = true;
+ parentPath = m_pathToParentPath.value(p);
+ }
+ }
+
+ QStringList subPaths = m_pathToSubPaths.value(path); // we do the same for children paths
+ QStringListIterator itSubPaths(subPaths);
+ while (itSubPaths.hasNext())
+ pathQueue.enqueue(itSubPaths.next());
+ }
+
+ // we setup here new path and resource to be activated
+ const QString currentPath = m_itemToPath.value(m_treeWidget->currentItem());
+ QString newCurrentPath = currentPath;
+ QString currentResource = m_itemToResource.value(m_listWidget->currentItem());
+ if (!matchAll) {
+ bool searchForNewPathWithContents = true;
+
+ if (!currentPath.isEmpty()) { // if the currentPath is empty we will search for a new path too
+ QMap<QString, bool>::ConstIterator it = pathToMatchingContents.constFind(currentPath);
+ if (it != pathToMatchingContents.constEnd() && it.value()) // the current item has contents, we don't need to search for another path
+ searchForNewPathWithContents = false;
+ }
+
+ if (searchForNewPathWithContents) {
+ // we find the first path with the matching contents
+ QMap<QString, bool>::ConstIterator itContents = pathToMatchingContents.constBegin();
+ while (itContents != pathToMatchingContents.constEnd()) {
+ if (itContents.value()) {
+ newCurrentPath = itContents.key(); // the new path will be activated
+ break;
+ }
+
+ itContents++;
+ }
+ }
+
+ QFileInfo fi(currentResource);
+ if (!fi.fileName().contains(m_filterPattern, Qt::CaseInsensitive)) { // the case when the current resource is filtered out
+ const QStringList fileNames = m_pathToContents.value(newCurrentPath);
+ QStringListIterator it(fileNames);
+ while (it.hasNext()) { // we try to select the first matching resource from the newCurrentPath
+ QString fileName = it.next();
+ if (fileName.contains(m_filterPattern, Qt::CaseInsensitive)) {
+ QDir dirPath(newCurrentPath);
+ currentResource = dirPath.absoluteFilePath(fileName); // the new resource inside newCurrentPath will be activated
+ break;
+ }
+ }
+ }
+ }
+
+ QTreeWidgetItem *newCurrentItem = m_pathToItem.value(newCurrentPath);
+ if (currentPath != newCurrentPath)
+ m_treeWidget->setCurrentItem(newCurrentItem);
+ else
+ slotCurrentPathChanged(newCurrentItem); // trigger filtering on the current path
+
+ QListWidgetItem *currentResourceItem = m_resourceToItem.value(currentResource);
+ if (currentResourceItem) {
+ m_listWidget->setCurrentItem(currentResourceItem);
+ m_listWidget->scrollToItem(currentResourceItem);
+ }
+
+ QMapIterator<QString, bool> it(pathToVisible); // hide all paths filtered out
+ while (it.hasNext()) {
+ const QString path = it.next().key();
+ QTreeWidgetItem *item = m_pathToItem.value(path);
+ if (item)
+ item->setHidden(!it.value());
+ }
+}
+
QTreeWidgetItem *QtResourceViewPrivate::createPath(const QString &path, QTreeWidgetItem *parent)
{
QTreeWidgetItem *item = 0;
@@ -417,27 +544,32 @@ QTreeWidgetItem *QtResourceViewPrivate::createPath(const QString &path, QTreeWid
void QtResourceViewPrivate::createResources(const QString &path)
{
+ const bool matchAll = m_filterPattern.isEmpty();
+
QDir dir(path);
- QStringList files = m_pathToContents.value(path);
- QStringListIterator it(files);
+ QStringList fileNames = m_pathToContents.value(path);
+ QStringListIterator it(fileNames);
while (it.hasNext()) {
- QString file = it.next();
- QString filePath = dir.absoluteFilePath(file);
- QFileInfo fi(filePath);
- if (fi.isFile()) {
- QListWidgetItem *item = new QListWidgetItem(fi.fileName(), m_listWidget);
- const QPixmap pix = QPixmap(filePath);
- if (pix.isNull()) {
- item->setToolTip(filePath);
- } else {
- item->setIcon(QIcon(makeThumbnail(pix)));
- const QSize size = pix.size();
- item->setToolTip(QtResourceView::tr("Size: %1 x %2\n%3").arg(size.width()).arg(size.height()).arg(filePath));
+ QString fileName = it.next();
+ const bool showProperty = matchAll || fileName.contains(m_filterPattern, Qt::CaseInsensitive);
+ if (showProperty) {
+ QString filePath = dir.absoluteFilePath(fileName);
+ QFileInfo fi(filePath);
+ if (fi.isFile()) {
+ QListWidgetItem *item = new QListWidgetItem(fi.fileName(), m_listWidget);
+ const QPixmap pix = QPixmap(filePath);
+ if (pix.isNull()) {
+ item->setToolTip(filePath);
+ } else {
+ item->setIcon(QIcon(makeThumbnail(pix)));
+ const QSize size = pix.size();
+ item->setToolTip(QtResourceView::tr("Size: %1 x %2\n%3").arg(size.width()).arg(size.height()).arg(filePath));
+ }
+ item->setFlags(item->flags() | Qt::ItemIsDragEnabled);
+ item->setData(Qt::UserRole, filePath);
+ m_itemToResource[item] = filePath;
+ m_resourceToItem[filePath] = item;
}
- item->setFlags(item->flags() | Qt::ItemIsDragEnabled);
- item->setData(Qt::UserRole, filePath);
- m_itemToResource[item] = filePath;
- m_resourceToItem[filePath] = item;
}
}
}
@@ -464,6 +596,11 @@ QtResourceView::QtResourceView(QDesignerFormEditorInterface *core, QWidget *pare
connect(d_ptr->m_copyResourcePathAction, SIGNAL(triggered()), this, SLOT(slotCopyResourcePath()));
d_ptr->m_copyResourcePathAction->setEnabled(false);
+ //d_ptr->m_filterWidget = new qdesigner_internal::FilterWidget(0, qdesigner_internal::FilterWidget::LayoutAlignNone);
+ d_ptr->m_filterWidget = new qdesigner_internal::FilterWidget(d_ptr->m_toolBar);
+ d_ptr->m_toolBar->addWidget(d_ptr->m_filterWidget);
+ connect(d_ptr->m_filterWidget, SIGNAL(filterChanged(QString)), this, SLOT(slotFilterChanged(QString)));
+
d_ptr->m_splitter = new QSplitter;
d_ptr->m_splitter->setChildrenCollapsible(false);
d_ptr->m_splitter->addWidget(d_ptr->m_treeWidget);
diff --git a/tools/designer/src/lib/shared/qtresourceview_p.h b/tools/designer/src/lib/shared/qtresourceview_p.h
index 1d3a1b0..7a96ddb 100644
--- a/tools/designer/src/lib/shared/qtresourceview_p.h
+++ b/tools/designer/src/lib/shared/qtresourceview_p.h
@@ -113,6 +113,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void slotReloadResources())
Q_PRIVATE_SLOT(d_func(), void slotCopyResourcePath())
Q_PRIVATE_SLOT(d_func(), void slotListWidgetContextMenuRequested(const QPoint &pos))
+ Q_PRIVATE_SLOT(d_func(), void slotFilterChanged(const QString &pattern))
};
class QDESIGNER_SHARED_EXPORT QtResourceViewDialog : public QDialog
diff --git a/tools/designer/src/lib/shared/richtexteditor.cpp b/tools/designer/src/lib/shared/richtexteditor.cpp
index 8aa036b..42cf449 100644
--- a/tools/designer/src/lib/shared/richtexteditor.cpp
+++ b/tools/designer/src/lib/shared/richtexteditor.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::RichTextEditorDialog
-*/
-
#include "richtexteditor_p.h"
#include "htmlhighlighter_p.h"
#include "iconselector_p.h"
diff --git a/tools/designer/src/lib/shared/scriptdialog.cpp b/tools/designer/src/lib/shared/scriptdialog.cpp
index 616f0c9..ef4d08f 100644
--- a/tools/designer/src/lib/shared/scriptdialog.cpp
+++ b/tools/designer/src/lib/shared/scriptdialog.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::ScriptDialog
-*/
-
#include "scriptdialog_p.h"
#include "qscripthighlighter_p.h"
diff --git a/tools/designer/src/lib/shared/scripterrordialog.cpp b/tools/designer/src/lib/shared/scripterrordialog.cpp
index c4a7e07..326cba2 100644
--- a/tools/designer/src/lib/shared/scripterrordialog.cpp
+++ b/tools/designer/src/lib/shared/scripterrordialog.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::ScriptErrorDialog
-*/
-
#include "scripterrordialog_p.h"
#include <QtGui/QTextEdit>
diff --git a/tools/designer/src/lib/shared/stylesheeteditor.cpp b/tools/designer/src/lib/shared/stylesheeteditor.cpp
index 2056fcf..de64135 100644
--- a/tools/designer/src/lib/shared/stylesheeteditor.cpp
+++ b/tools/designer/src/lib/shared/stylesheeteditor.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::StyleSheetEditorDialog
-*/
-
#include "stylesheeteditor_p.h"
#include "csshighlighter_p.h"
#include "iconselector_p.h"
diff --git a/tools/designer/src/lib/shared/widgetfactory.cpp b/tools/designer/src/lib/shared/widgetfactory.cpp
index 3822fec..56a1744 100644
--- a/tools/designer/src/lib/shared/widgetfactory.cpp
+++ b/tools/designer/src/lib/shared/widgetfactory.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
-TRANSLATOR qdesigner_internal::WidgetFactory
-*/
-
#include "widgetfactory_p.h"
#include "widgetdatabase_p.h"
#include "metadatabase_p.h"
diff --git a/tools/designer/src/lib/shared/zoomwidget.cpp b/tools/designer/src/lib/shared/zoomwidget.cpp
index f4ab48e..a404dcb 100644
--- a/tools/designer/src/lib/shared/zoomwidget.cpp
+++ b/tools/designer/src/lib/shared/zoomwidget.cpp
@@ -143,9 +143,10 @@ ZoomView::ZoomView(QWidget *parent) :
m_zoom(100),
m_zoomFactor(1.0),
m_zoomContextMenuEnabled(false),
- m_autoScrollSuppressed(true),
m_zoomMenu(0)
{
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setFrameShape(QFrame::NoFrame);
setScene(m_scene);
if (debugZoomWidget)
@@ -187,8 +188,6 @@ void ZoomView::setZoom(int percent)
resetTransform();
scale(m_zoomFactor, m_zoomFactor);
- if (m_autoScrollSuppressed)
- scrollToOrigin();
}
void ZoomView::applyZoom()
@@ -210,16 +209,6 @@ void ZoomView::setZoomContextMenuEnabled(bool e)
m_zoomContextMenuEnabled = e;
}
-bool ZoomView::isAutoScrollSuppressed() const
-{
- return m_autoScrollSuppressed;
-}
-
-void ZoomView::setAutoScrollSuppressed(bool s)
-{
- m_autoScrollSuppressed = s;
-}
-
ZoomMenu *ZoomView::zoomMenu()
{
if (!m_zoomMenu) {
@@ -469,13 +458,16 @@ void ZoomWidget::resizeEvent(QResizeEvent *event)
* and the use the size ZoomView::resizeEvent(event); */
if (m_proxy && !m_viewResizeBlocked) {
if (debugZoomWidget > 1)
- qDebug() << ">ZoomWidget (" << size() << ")::resizeEvent from " << event->oldSize() << " to " << event->size();
+ qDebug() << '>' << Q_FUNC_INFO << size() << ")::resizeEvent from " << event->oldSize() << " to " << event->size();
const QSizeF newViewPortSize = size() - viewPortMargin();
const QSizeF widgetSizeF = newViewPortSize / zoomFactor() - widgetDecorationSizeF();
m_widgetResizeBlocked = true;
m_proxy->widget()->resize(widgetSizeF.toSize());
+ setSceneRect(QRectF(QPointF(0, 0), widgetSizeF));
scrollToOrigin();
m_widgetResizeBlocked = false;
+ if (debugZoomWidget > 1)
+ qDebug() << '<' << Q_FUNC_INFO << widgetSizeF << m_proxy->widget()->size() << m_proxy->size();
}
}
@@ -559,7 +551,7 @@ QGraphicsProxyWidget *ZoomWidget::createProxyWidget(QGraphicsItem *parent, Qt::W
void ZoomWidget::dump() const
{
- qDebug() << "ZoomWidget " << geometry() << " Viewport " << viewport()->geometry()
+ qDebug() << "ZoomWidget::dump " << geometry() << " Viewport " << viewport()->geometry()
<< "Scroll: " << scrollPosition() << "Matrix: " << matrix() << " SceneRect: " << sceneRect();
if (m_proxy) {
qDebug() << "Proxy Pos: " << m_proxy->pos() << "Proxy " << m_proxy->size()
diff --git a/tools/designer/src/lib/shared/zoomwidget_p.h b/tools/designer/src/lib/shared/zoomwidget_p.h
index fe850f7..92c857e 100644
--- a/tools/designer/src/lib/shared/zoomwidget_p.h
+++ b/tools/designer/src/lib/shared/zoomwidget_p.h
@@ -104,8 +104,6 @@ class QDESIGNER_SHARED_EXPORT ZoomView : public QGraphicsView
{
Q_PROPERTY(int zoom READ zoom WRITE setZoom DESIGNABLE true SCRIPTABLE true)
Q_PROPERTY(bool zoomContextMenuEnabled READ isZoomContextMenuEnabled WRITE setZoomContextMenuEnabled DESIGNABLE true SCRIPTABLE true)
- Q_PROPERTY(bool autoScrollSuppressed READ isAutoScrollSuppressed WRITE setAutoScrollSuppressed DESIGNABLE true SCRIPTABLE true)
-
Q_OBJECT
Q_DISABLE_COPY(ZoomView)
public:
@@ -120,10 +118,6 @@ public:
bool isZoomContextMenuEnabled() const;
void setZoomContextMenuEnabled(bool e);
- // Suppress scrolling when changing zoom. Default: on
- bool isAutoScrollSuppressed() const;
- void setAutoScrollSuppressed(bool s);
-
QGraphicsScene &scene() { return *m_scene; }
const QGraphicsScene &scene() const { return *m_scene; }
@@ -149,8 +143,7 @@ private:
int m_zoom;
qreal m_zoomFactor;
- bool m_zoomContextMenuEnabled;
- bool m_autoScrollSuppressed;
+ bool m_zoomContextMenuEnabled;
bool m_resizeBlocked;
ZoomMenu *m_zoomMenu;
};
diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp
index f819f05..4a91c51 100644
--- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp
+++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp
@@ -403,6 +403,7 @@ QAction *QAbstractFormBuilder::create(DomAction *ui_action, QObject *parent)
if (!a)
return 0;
+ m_actions.insert(ui_action->attributeName(), a);
applyProperties(a, ui_action->elementProperty());
return a;
}
@@ -415,7 +416,7 @@ QActionGroup *QAbstractFormBuilder::create(DomActionGroup *ui_action_group, QObj
QActionGroup *a = createActionGroup(parent, ui_action_group->attributeName());
if (!a)
return 0;
-
+ m_actionGroups.insert(ui_action_group->attributeName(), a);
applyProperties(a, ui_action_group->elementProperty());
foreach (DomAction *ui_action, ui_action_group->elementAction()) {
@@ -1184,8 +1185,6 @@ QAction *QAbstractFormBuilder::createAction(QObject *parent, const QString &name
{
QAction *action = new QAction(parent);
action->setObjectName(name);
- m_actions.insert(name, action);
-
return action;
}
@@ -1196,8 +1195,6 @@ QActionGroup *QAbstractFormBuilder::createActionGroup(QObject *parent, const QSt
{
QActionGroup *g = new QActionGroup(parent);
g->setObjectName(name);
- m_actionGroups.insert(name, g);
-
return g;
}
diff --git a/tools/designer/src/lib/uilib/formbuilder.cpp b/tools/designer/src/lib/uilib/formbuilder.cpp
index 414eb14..53d1e9d 100644
--- a/tools/designer/src/lib/uilib/formbuilder.cpp
+++ b/tools/designer/src/lib/uilib/formbuilder.cpp
@@ -120,7 +120,10 @@ QFormBuilder::~QFormBuilder()
*/
QWidget *QFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget)
{
- QFormBuilderExtra::instance(this)->setProcessingLayoutWidget(false);
+ QFormBuilderExtra *fb = QFormBuilderExtra::instance(this);
+ if (!fb->parentWidgetIsSet())
+ fb->setParentWidget(parentWidget);
+ fb->setProcessingLayoutWidget(false);
if (ui_widget->attributeClass() == QFormBuilderStrings::instance().qWidgetClass && !ui_widget->hasAttributeNative()
&& parentWidget
#ifndef QT_NO_MAINWINDOW
@@ -145,7 +148,7 @@ QWidget *QFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget)
&& !qobject_cast<QDockWidget *>(parentWidget)
#endif
)
- QFormBuilderExtra::instance(this)->setProcessingLayoutWidget(true);
+ fb->setProcessingLayoutWidget(true);
return QAbstractFormBuilder::create(ui_widget, parentWidget);
}
@@ -228,9 +231,6 @@ QWidget *QFormBuilder::createWidget(const QString &widgetName, QWidget *parentWi
if (qobject_cast<QDialog *>(w))
w->setParent(parentWidget);
- if (!fb->rootWidget())
- fb->setRootWidget(w);
-
return w;
}
@@ -369,9 +369,10 @@ QWidget *QFormBuilder::create(DomUI *ui, QWidget *parentWidget)
*/
QLayout *QFormBuilder::create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget)
{
+ QFormBuilderExtra *fb = QFormBuilderExtra::instance(this);
// Is this a temporary layout widget used to represent QLayout hierarchies in Designer?
// Set its margins to 0.
- bool layoutWidget = QFormBuilderExtra::instance(this)->processingLayoutWidget();
+ bool layoutWidget = fb->processingLayoutWidget();
QLayout *l = QAbstractFormBuilder::create(ui_layout, layout, parentWidget);
if (layoutWidget) {
const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
@@ -392,7 +393,7 @@ QLayout *QFormBuilder::create(DomLayout *ui_layout, QLayout *layout, QWidget *pa
bottom = prop->elementNumber();
l->setContentsMargins(left, top, right, bottom);
- QFormBuilderExtra::instance(this)->setProcessingLayoutWidget(false);
+ fb->setProcessingLayoutWidget(false);
}
return l;
}
@@ -525,6 +526,7 @@ QList<QDesignerCustomWidgetInterface*> QFormBuilder::customWidgets() const
/*!
\internal
*/
+
void QFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties)
{
typedef QList<DomProperty*> DomPropertyList;
@@ -542,11 +544,12 @@ void QFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &proper
continue;
const QString attributeName = (*it)->attributeName();
- if (o == fb->rootWidget() && attributeName == strings.geometryProperty) {
- // apply only the size for the rootWidget
- fb->rootWidget()->resize(qvariant_cast<QRect>(v).size());
+ const bool isWidget = o->isWidgetType();
+ if (isWidget && o->parent() == fb->parentWidget() && attributeName == strings.geometryProperty) {
+ // apply only the size part of a geometry for the root widget
+ static_cast<QWidget*>(o)->resize(qvariant_cast<QRect>(v).size());
} else if (fb->applyPropertyInternally(o, attributeName, v)) {
- } else if (!qstrcmp("QFrame", o->metaObject()->className ()) && attributeName == strings.orientationProperty) {
+ } else if (isWidget && !qstrcmp("QFrame", o->metaObject()->className ()) && attributeName == strings.orientationProperty) {
// ### special-casing for Line (QFrame) -- try to fix me
o->setProperty("frameShape", v); // v is of QFrame::Shape enum
} else {
diff --git a/tools/designer/src/lib/uilib/formbuilderextra.cpp b/tools/designer/src/lib/uilib/formbuilderextra.cpp
index cb82967..38fe2ae 100644
--- a/tools/designer/src/lib/uilib/formbuilderextra.cpp
+++ b/tools/designer/src/lib/uilib/formbuilderextra.cpp
@@ -81,7 +81,8 @@ QFormBuilderExtra::~QFormBuilderExtra()
void QFormBuilderExtra::clear()
{
m_buddies.clear();
- m_rootWidget = 0;
+ m_parentWidget = 0;
+ m_parentWidgetIsSet = false;
#ifndef QT_FORMBUILDER_NO_SCRIPT
m_FormScriptRunner.clearErrors();
m_customWidgetScriptHash.clear();
@@ -136,14 +137,21 @@ bool QFormBuilderExtra::applyBuddy(const QString &buddyName, BuddyMode applyMode
return false;
}
-const QPointer<QWidget> &QFormBuilderExtra::rootWidget() const
+const QPointer<QWidget> &QFormBuilderExtra::parentWidget() const
{
- return m_rootWidget;
+ return m_parentWidget;
}
-void QFormBuilderExtra::setRootWidget(const QPointer<QWidget> &w)
+bool QFormBuilderExtra::parentWidgetIsSet() const
{
- m_rootWidget = w;
+ return m_parentWidgetIsSet;
+}
+
+void QFormBuilderExtra::setParentWidget(const QPointer<QWidget> &w)
+{
+ // Parent widget requires special handling of the geometry property.
+ m_parentWidget = w;
+ m_parentWidgetIsSet = true;
}
#ifndef QT_FORMBUILDER_NO_SCRIPT
diff --git a/tools/designer/src/lib/uilib/formbuilderextra_p.h b/tools/designer/src/lib/uilib/formbuilderextra_p.h
index f357239..9166c48 100644
--- a/tools/designer/src/lib/uilib/formbuilderextra_p.h
+++ b/tools/designer/src/lib/uilib/formbuilderextra_p.h
@@ -101,8 +101,9 @@ public:
void applyInternalProperties() const;
static bool applyBuddy(const QString &buddyName, BuddyMode applyMode, QLabel *label);
- const QPointer<QWidget> &rootWidget() const;
- void setRootWidget(const QPointer<QWidget> &w);
+ const QPointer<QWidget> &parentWidget() const;
+ bool parentWidgetIsSet() const;
+ void setParentWidget(const QPointer<QWidget> &w);
#ifndef QT_FORMBUILDER_NO_SCRIPT
QFormScriptRunner &formScriptRunner();
@@ -182,7 +183,8 @@ private:
QResourceBuilder *m_resourceBuilder;
QTextBuilder *m_textBuilder;
- QPointer<QWidget> m_rootWidget;
+ QPointer<QWidget> m_parentWidget;
+ bool m_parentWidgetIsSet;
};
void uiLibWarning(const QString &message);
diff --git a/tools/designer/src/lib/uilib/ui4.cpp b/tools/designer/src/lib/uilib/ui4.cpp
index 2047739..72c7f50 100644
--- a/tools/designer/src/lib/uilib/ui4.cpp
+++ b/tools/designer/src/lib/uilib/ui4.cpp
@@ -2368,6 +2368,7 @@ void DomCustomWidget::clear(bool clear_all)
delete m_script;
delete m_properties;
delete m_slots;
+ delete m_propertyspecifications;
if (clear_all) {
m_text.clear();
@@ -2381,6 +2382,7 @@ void DomCustomWidget::clear(bool clear_all)
m_script = 0;
m_properties = 0;
m_slots = 0;
+ m_propertyspecifications = 0;
}
DomCustomWidget::DomCustomWidget()
@@ -2393,6 +2395,7 @@ DomCustomWidget::DomCustomWidget()
m_script = 0;
m_properties = 0;
m_slots = 0;
+ m_propertyspecifications = 0;
}
DomCustomWidget::~DomCustomWidget()
@@ -2403,6 +2406,7 @@ DomCustomWidget::~DomCustomWidget()
delete m_script;
delete m_properties;
delete m_slots;
+ delete m_propertyspecifications;
}
void DomCustomWidget::read(QXmlStreamReader &reader)
@@ -2468,6 +2472,12 @@ void DomCustomWidget::read(QXmlStreamReader &reader)
setElementSlots(v);
continue;
}
+ if (tag == QLatin1String("propertyspecifications")) {
+ DomPropertySpecifications *v = new DomPropertySpecifications();
+ v->read(reader);
+ setElementPropertyspecifications(v);
+ continue;
+ }
reader.raiseError(QLatin1String("Unexpected element ") + tag);
}
break;
@@ -2548,6 +2558,12 @@ void DomCustomWidget::read(const QDomElement &node)
setElementSlots(v);
continue;
}
+ if (tag == QLatin1String("propertyspecifications")) {
+ DomPropertySpecifications *v = new DomPropertySpecifications();
+ v->read(e);
+ setElementPropertyspecifications(v);
+ continue;
+ }
}
m_text.clear();
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
@@ -2605,6 +2621,10 @@ void DomCustomWidget::write(QXmlStreamWriter &writer, const QString &tagName) co
m_slots->write(writer, QLatin1String("slots"));
}
+ if (m_children & Propertyspecifications) {
+ m_propertyspecifications->write(writer, QLatin1String("propertyspecifications"));
+ }
+
if (!m_text.isEmpty())
writer.writeCharacters(m_text);
@@ -2731,6 +2751,21 @@ void DomCustomWidget::setElementSlots(DomSlots* a)
m_slots = a;
}
+DomPropertySpecifications* DomCustomWidget::takeElementPropertyspecifications()
+{
+ DomPropertySpecifications* a = m_propertyspecifications;
+ m_propertyspecifications = 0;
+ m_children ^= Propertyspecifications;
+ return a;
+}
+
+void DomCustomWidget::setElementPropertyspecifications(DomPropertySpecifications* a)
+{
+ delete m_propertyspecifications;
+ m_children |= Propertyspecifications;
+ m_propertyspecifications = a;
+}
+
void DomCustomWidget::clearElementClass()
{
m_children &= ~Class;
@@ -2798,6 +2833,13 @@ void DomCustomWidget::clearElementSlots()
m_children &= ~Slots;
}
+void DomCustomWidget::clearElementPropertyspecifications()
+{
+ delete m_propertyspecifications;
+ m_propertyspecifications = 0;
+ m_children &= ~Propertyspecifications;
+}
+
void DomProperties::clear(bool clear_all)
{
qDeleteAll(m_property);
@@ -10883,5 +10925,208 @@ void DomSlots::setElementSlot(const QStringList& a)
m_slot = a;
}
+void DomPropertySpecifications::clear(bool clear_all)
+{
+ qDeleteAll(m_stringpropertyspecification);
+ m_stringpropertyspecification.clear();
+
+ if (clear_all) {
+ m_text.clear();
+ }
+
+ m_children = 0;
+}
+
+DomPropertySpecifications::DomPropertySpecifications()
+{
+ m_children = 0;
+}
+
+DomPropertySpecifications::~DomPropertySpecifications()
+{
+ qDeleteAll(m_stringpropertyspecification);
+ m_stringpropertyspecification.clear();
+}
+
+void DomPropertySpecifications::read(QXmlStreamReader &reader)
+{
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("stringpropertyspecification")) {
+ DomStringPropertySpecification *v = new DomStringPropertySpecification();
+ v->read(reader);
+ m_stringpropertyspecification.append(v);
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ }
+ break;
+ case QXmlStreamReader::EndElement :
+ finished = true;
+ break;
+ case QXmlStreamReader::Characters :
+ if (!reader.isWhitespace())
+ m_text.append(reader.text().toString());
+ break;
+ default :
+ break;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomPropertySpecifications::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("stringpropertyspecification")) {
+ DomStringPropertySpecification *v = new DomStringPropertySpecification();
+ v->read(e);
+ m_stringpropertyspecification.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomPropertySpecifications::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("propertyspecifications") : tagName.toLower());
+
+ for (int i = 0; i < m_stringpropertyspecification.size(); ++i) {
+ DomStringPropertySpecification* v = m_stringpropertyspecification[i];
+ v->write(writer, QLatin1String("stringpropertyspecification"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomPropertySpecifications::setElementStringpropertyspecification(const QList<DomStringPropertySpecification*>& a)
+{
+ m_children |= Stringpropertyspecification;
+ m_stringpropertyspecification = a;
+}
+
+void DomStringPropertySpecification::clear(bool clear_all)
+{
+
+ if (clear_all) {
+ m_text.clear();
+ m_has_attr_name = false;
+ m_has_attr_type = false;
+ m_has_attr_notr = false;
+ }
+
+ m_children = 0;
+}
+
+DomStringPropertySpecification::DomStringPropertySpecification()
+{
+ m_children = 0;
+ m_has_attr_name = false;
+ m_has_attr_type = false;
+ m_has_attr_notr = false;
+}
+
+DomStringPropertySpecification::~DomStringPropertySpecification()
+{
+}
+
+void DomStringPropertySpecification::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("name")) {
+ setAttributeName(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("type")) {
+ setAttributeType(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("notr")) {
+ setAttributeNotr(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ }
+ break;
+ case QXmlStreamReader::EndElement :
+ finished = true;
+ break;
+ case QXmlStreamReader::Characters :
+ if (!reader.isWhitespace())
+ m_text.append(reader.text().toString());
+ break;
+ default :
+ break;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomStringPropertySpecification::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
+ if (node.hasAttribute(QLatin1String("type")))
+ setAttributeType(node.attribute(QLatin1String("type")));
+ if (node.hasAttribute(QLatin1String("notr")))
+ setAttributeNotr(node.attribute(QLatin1String("notr")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomStringPropertySpecification::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("stringpropertyspecification") : tagName.toLower());
+
+ if (hasAttributeName())
+ writer.writeAttribute(QLatin1String("name"), attributeName());
+
+ if (hasAttributeType())
+ writer.writeAttribute(QLatin1String("type"), attributeType());
+
+ if (hasAttributeNotr())
+ writer.writeAttribute(QLatin1String("notr"), attributeNotr());
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
QT_END_NAMESPACE
diff --git a/tools/designer/src/lib/uilib/ui4_p.h b/tools/designer/src/lib/uilib/ui4_p.h
index df02a39..fa70573 100644
--- a/tools/designer/src/lib/uilib/ui4_p.h
+++ b/tools/designer/src/lib/uilib/ui4_p.h
@@ -161,6 +161,8 @@ class DomScript;
class DomWidgetData;
class DomDesignerData;
class DomSlots;
+class DomPropertySpecifications;
+class DomStringPropertySpecification;
/*******************************************************************************
** Declarations
@@ -1015,6 +1017,12 @@ public:
inline bool hasElementSlots() const { return m_children & Slots; }
void clearElementSlots();
+ inline DomPropertySpecifications* elementPropertyspecifications() const { return m_propertyspecifications; }
+ DomPropertySpecifications* takeElementPropertyspecifications();
+ void setElementPropertyspecifications(DomPropertySpecifications* a);
+ inline bool hasElementPropertyspecifications() const { return m_children & Propertyspecifications; }
+ void clearElementPropertyspecifications();
+
private:
QString m_text;
void clear(bool clear_all = true);
@@ -1033,6 +1041,7 @@ private:
DomScript* m_script;
DomProperties* m_properties;
DomSlots* m_slots;
+ DomPropertySpecifications* m_propertyspecifications;
enum Child {
Class = 1,
Extends = 2,
@@ -1044,7 +1053,8 @@ private:
Pixmap = 128,
Script = 256,
Properties = 512,
- Slots = 1024
+ Slots = 1024,
+ Propertyspecifications = 2048
};
DomCustomWidget(const DomCustomWidget &other);
@@ -3686,6 +3696,91 @@ private:
void operator = (const DomSlots&other);
};
+class QDESIGNER_UILIB_EXPORT DomPropertySpecifications {
+public:
+ DomPropertySpecifications();
+ ~DomPropertySpecifications();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const;
+ inline QString text() const { return m_text; }
+ inline void setText(const QString &s) { m_text = s; }
+
+ // attribute accessors
+ // child element accessors
+ inline QList<DomStringPropertySpecification*> elementStringpropertyspecification() const { return m_stringpropertyspecification; }
+ void setElementStringpropertyspecification(const QList<DomStringPropertySpecification*>& a);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ // child element data
+ uint m_children;
+ QList<DomStringPropertySpecification*> m_stringpropertyspecification;
+ enum Child {
+ Stringpropertyspecification = 1
+ };
+
+ DomPropertySpecifications(const DomPropertySpecifications &other);
+ void operator = (const DomPropertySpecifications&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomStringPropertySpecification {
+public:
+ DomStringPropertySpecification();
+ ~DomStringPropertySpecification();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const;
+ inline QString text() const { return m_text; }
+ inline void setText(const QString &s) { m_text = s; }
+
+ // attribute accessors
+ inline bool hasAttributeName() const { return m_has_attr_name; }
+ inline QString attributeName() const { return m_attr_name; }
+ inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; }
+ inline void clearAttributeName() { m_has_attr_name = false; }
+
+ inline bool hasAttributeType() const { return m_has_attr_type; }
+ inline QString attributeType() const { return m_attr_type; }
+ inline void setAttributeType(const QString& a) { m_attr_type = a; m_has_attr_type = true; }
+ inline void clearAttributeType() { m_has_attr_type = false; }
+
+ inline bool hasAttributeNotr() const { return m_has_attr_notr; }
+ inline QString attributeNotr() const { return m_attr_notr; }
+ inline void setAttributeNotr(const QString& a) { m_attr_notr = a; m_has_attr_notr = true; }
+ inline void clearAttributeNotr() { m_has_attr_notr = false; }
+
+ // child element accessors
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ QString m_attr_name;
+ bool m_has_attr_name;
+
+ QString m_attr_type;
+ bool m_has_attr_type;
+
+ QString m_attr_notr;
+ bool m_has_attr_notr;
+
+ // child element data
+ uint m_children;
+
+ DomStringPropertySpecification(const DomStringPropertySpecification &other);
+ void operator = (const DomStringPropertySpecification&other);
+};
+
#ifdef QFORMINTERNAL_NAMESPACE
}
diff --git a/tools/designer/src/uitools/quiloader.cpp b/tools/designer/src/uitools/quiloader.cpp
index 9e904d4..79f4504 100644
--- a/tools/designer/src/uitools/quiloader.cpp
+++ b/tools/designer/src/uitools/quiloader.cpp
@@ -613,8 +613,7 @@ void QUiLoaderPrivate::setupWidgetMap() const
reason, you can subclass the QUiLoader class and reimplement these
functions to intervene the process of constructing a user interface. For
example, you might want to have a list of the actions created when loading
- a form or creating a custom widget. However, in your reimplementation, you
- must call QUiLoader's original implementation of these functions first.
+ a form or creating a custom widget.
For a complete example using the QUiLoader class, see the
\l{Calculator Builder Example}.