Kexi/Porting to Qt&KDE 4

From KDE Community Wiki
Revision as of 17:57, 6 December 2010 by Cyrille (talk | contribs) (Created page with '[http://kexi-project.org/wiki/wikiview/index.php@Porting%20to%20Qt4.html Original document on kexi-project.org]. We'll want to integrate the notes in a single page one day... ==...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

Forms

Forms Porting

Status: mostly DONE, 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

Details:

  • 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

TODO

  • ...

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/