< Kexi
Revision as of 22:00, 10 April 2012 by Piggz (talk | contribs) (Added q3 include list)

Kexi/Porting to Qt&KDE 4

Original document on kexi-project.org. We'll want to integrate the notes in a single page one day...


Forms Porting

Status: mostly DONE, some QPalette porting remains
  • WidgetList -> QWidgetList, WidgetListIterator -> QWidgetList::Iterator/QWidgetList::ConstIterator/QMutableListIterator<QWidget*>
  • standard widgets: List View -> List Widget (and QListView -> QListWidget)
  • WidgetInfo::Dict -> WidgetInfo::Hash
  • K3ListBox support removed: rarely used before
  • K3ListView support removed, TODO: use QTreeWidget or QTreeView
  • Container factory:
    • stacked widget's property "id" replaced with "stackIndex" property (int).
    • tab widget: currentPage property (QWidget*) -> currentIndex (int)

Forms Refactoring

1st Phase

Started by Jstaniek on 3 Jan 2009, finished on 18 Feb 2009

Status: formeditor/ & plugins/forms/ done

Reasons for refactoring:

  • The process of instantiating a form (the Form class) is very complicated now what makes it very hard to properly implement subforms
  • The code full of interdependencies and thus is fragile when adding new functionality or fixing bugs
  • The FormManager class centralizes a number of operations that shall belong to Form itself
  • The naming of methods and classes can be improved, e.g. Form -> FormController
  • The ObjectTree* classes introduce redundancy as we already have QWidget hierarchy, and extensible property system; this complicates the code


  • Form and FormManager:
    • FormManager removed. Most facilities of FormManager merged into Form. Thus we are no longer track 'active form' on switching between forms; instead each Form object keeps necessary information.
    • void FormManager::insertWidget(const QByteArray &classname) moved
    • void FormManager::stopInsert() moved as abortWidgetInserting()
    • void FormManager::enterConnectingState() moved as enterConnectingState()
    • void FormManager::stopCreatingConnection() moved as abortCreatingConnection()
    • void FormManager::slotPointerClicked() moved as enterWidgetSelectingState()
    • Form::State enum defined instead of multiple boolean attributes of FormManager
    • FormManager::isInserting() and FormManager::isCreatingConnection() removed, Form::state() is used instead
    • Design or View mode is expressed using Mode enum value, not boolean flag
    • Form::setSelectedWidget(QWidget *w, bool add, bool dontRaise, bool moreWillBeSelected) replaced with Form::selectWidget(QWidget *w, Form::WidgetSelectionFlags)
    • Form::deSelectWidget(QWidget*) replaced with Form::deselectWidget(QWidget*)
    • bool FormManager::isTopLevel(QWidget*) moved to Form::isTopLevelWidget(QWidget*)
    • FormManager::selectedClass() removed
    • WidgetLibrary* FormManager::createWidgetLibrary(FormManager* m, const QStringList& supportedFactoryGroups) removed, WidgetLibrary is instantiated directly by KexiFormPart
    • FormManager::dirty(KFormDesigner::Form *form, bool isDirty = true) signal moved to Form::modified() signal
    • FormManager::showFormUICode() moved to KexiFormManager
    • FormManager::m_emitSelectionSignalsUpdatesPropertySet removed since we're not using windowChanged() (??)
    • void FormManager::setObjectTreeView(ObjectTreeView *treeview) moved to KexiFormManager::init()
  • WidgetPropertySet
    • removed, its code moved to Form
    • emitWidgetPropertyChanged() removed
  • Added #ifdef KFD_SIGSLOTS to disable code related to visual handling signal/slots connection
  • FormWidget
    • code moved to FormWidget.h and FormWidget.cpp
    • clearForm() removed (let's hopw QWidget update() is enough)
  • Commands:
    • Paste/Cut/Copy commands use QApplication::clipboard() now instead of FormManager::self()->m_domDoc, which has been removed
    • PropertyCommand::property() renamed to PropertyCommand::propertyName()
    • added operator<< for kDebug()
  • Container:
    • void setSelectedWidget(QWidget *selected, bool add, bool dontRaise = false, bool moreWillBeSelected = false) -> selectWidget(QWidget *w, Form::WidgetSelectionFlags flags = Form::DefaultWidgetSelectionFlags)
    • LayoutType enum moved to Form
    • setLayout() -> setLayoutType()
  • KexiFormPart
    • slotPropertyChanged() moved to Form::handleWidgetPropertyChanged(), so Form::widgetPropertyChanged() signal can be now removed
    • slotAutoTabStopsSet()'s code moved to Form::editTabOrder() itself
    • KexiFormPart::static_formsLibrary moved to KexiFormManger
    • slotWidgetCreatedByFormsLibrary(QWidget*) moved to KexiFormManger
    • WidgetLibrary* KexiFormPart::library() moved to KexiFormManager
    • assignAction() moved to KexiFormManager
  • KexiFormManger
    • added static self()
    • is initialized by KexiFormPart

2nd Phase

Jstaniek, 2009-04-25..2009-05-10

Status: DONE

  • WidgetFactory refactored
    • the main change is that we do not keep pointer to a currently handled container/widget/inline-editor in per-factory manner, this is kept per-form, so WidgetFactory::editor(), setEditor(), widget(), setWidget() have been removed
    • added:
      • InlineEditorCreationArgument class - arguments used by Form::createInlineEditor() and WidgetFactory::startInlineEditing()
    • renamed:
      • virtual bool startEditing(const QByteArray &classname, QWidget *w, Container *container) = 0 to virtual bool startInlineEditing(InlineEditorCreationArguments& args) = 0
      • resizeEditor() made public
      • virtual bool changeText(const QString &newText) renamed to virtual bool changeInlineText(Form *form, QWidget *widget, const QString& text);
      • void changeProperty(const char *name, const QVariant &value, Form *form) renamed to void changeProperty(Form *form, QWidget *widget, const char *name, const QVariant &value);
    • moved:
      • void createEditor(const QByteArray &classname, const QString &text, QWidget *w, Container *container, QRect geometry, Qt::Alignment alignment, bool useFrame = false, bool multiLine = false, Qt::BackgroundMode background = Qt::NoBackground) moved to void Form::createInlineEditor(const KFormDesigner::WidgetFactory::InlineEditorCreationArguments& args);
      • contents of disableFilter() moved to Form
      • eventFilter() moved to Form::eventFilter()
      • resetEditor() moved to Form::resetInlineEditor()
      • disableFilter() moved to Form::disableFilter()
      • changeInlineTextInternal() moved to Form::changeInlineTextInternal()
        • now uses InlineTextEditingCommand
      • inlineEditorDeleted() moved to
      • slotTextChanged() moved to Form::slotInlineTextChanged()
      • editorDeleted() moved to Form::editorDeleted()
      • widgetDestroyed() moved to Form::widgetDestroyed()
      • editorText() moved to Form::inlineEditorText()
      • setEditorText() moved to Form::setInlineEditorText()
      • m_editedWidgetClass moved to Form::Private::editedWidgetClass
      • m_firstText moved to Form::Private::originalInlineText
      • m_editor moved to Form::Private::inlineEditor
      • m_container moved to Form::Private::inlineEditorContainer;
    • removed:
      • void setEditor(QWidget *widget, QWidget *editor);
      • QWidget *editor(QWidget *widget) const;
      • void setWidget(QWidget *widget, Container *container);
      • QWidget *widget() const;
      • QPointer<ResizeHandleSet> m_handles;
      • QPointer<QWidget> m_widget;
  • ContainerFactory:
    • addTabPage() moved to internal AddTabAction, so context (container, widget) is no longer kept globally
    • similarly, renameTabPage() moved to internal RenameTabAction
    • similarly, removeTabPage() moved to internal RemoveTabAction
    • similarly, addStackPage() moved to internal AddStackPageAction
    • similarly, removeStackPage() moved to internal RemoveStackPageAction
    • similarly, nextStackPage() and prevStackPage() moved to internal GoToStackPageAction
  • ResizeHandleSet:
    • added Form* form() const
  • Commands:
  • use InlineTextEditingCommand in Form::changeInlineTextInternal() to get undo/redo functionality for inline editing
  • KexiDBFactory updated for the new API
  • ported code from void FormManager::initForm(Form *form) to KexiFormView::initForm()

3rd Phase

Jstaniek, 2010-09-01..

  • ObjectTreeView/ObjectTreeViewItem renamed to WidgetTreeWidget/WidgetTreeWidgetItem and ported to QTreeWidget/QTreeWidgetItem


  • ...

Additional notes

  • Reimplement QWidget::showEvent(QEvent*) [virtual protected] instead of QWidget::show() [virtual public]. Also add if (!event->spontanous()) condition, as we're most often not interested in handling spontaneous events. Do the same for QWidget::hide()/QWidget::hideEvent(QEvent*).
    • Note: TODO in Kexi!
  • Use QRubberBand instead of painting using XOR
    • already used in KexiTableView and the query designer for drag indicators
    • TODO: use it in forms for displaying rectangles when inserting or resizing widgets

See also http://trolltech.com/developer/faqs/517/

Q3 Usage

Location Class Notes
formeditor/kexiactionselectiondialog.cpp #include <Q3Header>
formeditor/factories/containerfactory.cpp #include <Q3ScrollView>
formeditor/editlistviewdialog.cpp #include <q3header.h>
formeditor/editlistviewdialog.cpp #include <Q3VBoxLayout>
formeditor/editlistviewdialog.cpp #include <Q3HBoxLayout>
kexiutils/debuggui.cpp #include <q3header.h>
main/printing/kexisimpleprintingengine.cpp #include <q3paintdevicemetrics.h>
main/printing/kexisimpleprintpreviewwindow.cpp #include <q3accel.h>
main/printing/kexisimpleprintpreviewwindow.cpp #include <Q3Frame>
main/printing/kexisimpleprintpreviewwindow.cpp #include <Q3VBoxLayout>
main/printing/kexisimpleprintingengine.h #include <q3paintdevicemetrics.h>
main/printing/kexisimpleprintingpagesetup.cpp #include <q3whatsthis.h>
main/printing/kexisimpleprintingpagesetup.cpp #include <Q3VBoxLayout>
main/printing/kexisimpleprintingpagesetup.cpp #include <Q3ValueList>
main/startup/KexiStartupDialogTemplatesPage.cpp #include <Q3Header>
main/startup/KexiStartupFileDialogBase_win.h #include <q3filedialog.h>
plugins/forms/kexidbfactory.cpp //#include <q3scrollview.h>
plugins/forms/kexidbfactorybase.cpp #include <q3scrollview.h>
plugins/forms/widgets/kexidbdatetimeedit.h #include <q3datetimeedit.h>
plugins/forms/widgets/kexidbtimeedit.h #include <q3datetimeedit.h>
plugins/forms/widgets/kexidbsubform.cpp #include <Q3Frame>
plugins/forms/widgets/kexidbsubform.h #include <q3scrollview.h>
plugins/forms/widgets/kexidbdateedit.h #include <q3datetimeedit.h>
plugins/importexport/csv/kexicsvimportdialog.cpp #include <q3table.h>
plugins/scripting/kexiscripting/kexiscriptdesignview.cpp #include <q3stylesheet.h>
plugins/queries/kexiquerydesignersqlhistory.h #include <q3scrollview.h>
plugins/queries/kexiquerydesignersql.cpp //Qt4#include <Q3SimpleRichText>
tests/widgets/kexidbdrivercombotest.cpp #include <Q3VBoxLayout>
widget/pixmapcollection.h #include <q3intdict.h>
widget/relations/KexiRelationsTableContainer_p.cpp #include <q3header.h>
widget/relations/KexiRelationsScrollArea.cpp #include <q3header.h>
widget/kexiscrollview.h #include <Q3ScrollView>
widget/utils/kexirecordnavigator.cpp #include <Q3ScrollView>
widget/utils/kexigradientwidget.h #include <Q3PtrList>
widget/tableview/kexitimetableedit.cpp #include <q3datetimeedit.h>
widget/tableview/kexitableedit.h #include <q3scrollview.h>
widget/tableview/kexitableview.cpp #include <Q3WhatsThis>
widget/tableview/kexitableviewheader.h #include <Q3Header>
widget/tableview/kexitableview.h #include <Q3ScrollView>
widget/tableview/kexitableview.h #include <q3header.h>
widget/navigator/KexiProjectListView.cpp #include <q3header.h>
widget/kexiscrollview.cpp #include <Q3Frame>

K3 Usage

This page was last edited on 28 February 2015, at 08:53. Content is available under Creative Commons License SA 4.0 unless otherwise noted.