changeset 8:c63d67895cbe

layout designer: first draft
author Goffi <goffi@goffi.org>
date Wed, 24 Aug 2011 20:38:55 +0200
parents 017925589d4c
children 0d7875c26974
files bellaciao.pro layout_builder.cpp layout_builder.h layout_builder.ui layout_builder_widgets.cpp layout_designer.cpp layout_designer.h layout_designer.ui layout_view.cpp layout_view.h layout_widget.cpp layout_widget.h settings.cpp settings.h settings.ui
diffstat 15 files changed, 810 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/bellaciao.pro	Sun Aug 14 18:03:54 2011 +0200
+++ b/bellaciao.pro	Wed Aug 24 20:38:55 2011 +0200
@@ -10,6 +10,6 @@
 CONFIG += debug
 
 # Input
-HEADERS += bellaciao.h contact_list.h dbus_bridge.h dbus_types.h bridge.h settings.h session.h contact.h jid.h
-SOURCES += main.cpp bellaciao.cpp contact_list.cpp dbus_bridge.cpp dbus_types.cpp bridge.cpp settings.cpp session.cpp contact.cpp jid.cpp
-FORMS += main_win.ui settings.ui
+HEADERS += bellaciao.h contact_list.h dbus_bridge.h dbus_types.h bridge.h settings.h session.h contact.h jid.h layout_designer.h layout_builder.h layout_widget.h layout_view.h
+SOURCES += main.cpp bellaciao.cpp contact_list.cpp dbus_bridge.cpp dbus_types.cpp bridge.cpp settings.cpp session.cpp contact.cpp jid.cpp layout_designer.cpp layout_builder.cpp layout_widget.cpp layout_view.cpp
+FORMS += main_win.ui settings.ui layout_designer.ui layout_builder.ui
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layout_builder.cpp	Wed Aug 24 20:38:55 2011 +0200
@@ -0,0 +1,72 @@
+/*
+Bellaciao: a Salut à Toi frontend
+Copyright (C) 2011  Jérôme Poisson (goffi@goffi.org)
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "layout_builder.h"
+
+
+LayoutBuilder::LayoutBuilder(QWidget* parent)
+    : QWidget(parent)
+{
+    setupUi(this);
+    LayoutWidgetModel* model = new LayoutWidgetModel(this);
+    widgetsList->setModel(model);
+}
+
+LayoutBuilder::~LayoutBuilder()
+{
+    qDebug() << "Destructeur de LayoutBuilder";
+}
+
+const QHash<QString, LayoutWidget*>& LayoutBuilder::getLayoutWidgetsDict()
+{
+    return dynamic_cast<LayoutWidgetModel*>(widgetsList->model())->getLayoutWidgetsDict();
+}
+
+void LayoutBuilder::addWidget(LayoutWidget* widget)
+{
+    dynamic_cast<LayoutWidgetModel*>(widgetsList->model())->append(widget);
+}
+
+LayoutBuilderContactList::LayoutBuilderContactList(QWidget* parent)
+    : LayoutBuilder(parent)
+{
+    qDebug() << "constructeur de LayoutBuilderContactList";
+    addWidget(new LayoutWidget("List"));
+    addWidget(new LayoutWidget("Box"));
+    layoutView->setLayoutWidgets(getLayoutWidgetsDict());
+}
+
+LayoutBuilderContactList::~LayoutBuilderContactList()
+{
+    qDebug() << "Destructeur de LayoutBuilderContactList";
+}
+
+LayoutBuilder* LayoutBuilderFactory::Create(LayoutType type, QWidget* parent)
+{
+    switch (type) {
+        case CONTACT_LIST:
+            return new LayoutBuilderContactList(parent);
+            break;
+        case CONTACT_ITEM:
+            break;
+        default:
+            qCritical() << "Unknwon LayoutBuilder type";
+    }
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layout_builder.h	Wed Aug 24 20:38:55 2011 +0200
@@ -0,0 +1,64 @@
+/*
+Bellaciao: a Salut à Toi frontend
+Copyright (C) 2011  Jérôme Poisson (goffi@goffi.org)
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef LAYOUT_BUILDER_H
+#define LAYOUT_BUILDER_H
+
+
+#include <QtGui>
+#include "ui_layout_builder.h"
+#include "layout_widget.h"
+
+typedef enum
+{
+    CONTACT_LIST, CONTACT_ITEM
+} LayoutType;
+
+class LayoutBuilder : public QWidget, protected Ui::LayoutBuilderUI
+{
+    Q_OBJECT
+
+    public:
+        LayoutBuilder(QWidget* parent=0);
+        virtual ~LayoutBuilder();
+        const QHash<QString, LayoutWidget*>& getLayoutWidgetsDict();
+
+    protected:
+        void addWidget(LayoutWidget* widget);
+
+};
+
+class LayoutBuilderContactList : public LayoutBuilder
+{
+    Q_OBJECT
+
+    public:
+        LayoutBuilderContactList(QWidget* parent=0);
+        ~LayoutBuilderContactList();
+};
+
+class LayoutBuilderFactory
+{
+    public:
+        LayoutBuilder* Create(LayoutType type=CONTACT_ITEM, QWidget* parent=0);
+
+};
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layout_builder.ui	Wed Aug 24 20:38:55 2011 +0200
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LayoutBuilderUI</class>
+ <widget class="QWidget" name="LayoutBuilderUI">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>456</width>
+    <height>495</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_3">
+   <item>
+    <widget class="QSplitter" name="splitter">
+     <property name="frameShadow">
+      <enum>QFrame::Plain</enum>
+     </property>
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="childrenCollapsible">
+      <bool>false</bool>
+     </property>
+     <widget class="QGroupBox" name="groupBox">
+      <property name="maximumSize">
+       <size>
+        <width>250</width>
+        <height>16777215</height>
+       </size>
+      </property>
+      <property name="title">
+       <string>Widgets</string>
+      </property>
+      <property name="flat">
+       <bool>false</bool>
+      </property>
+      <property name="checkable">
+       <bool>false</bool>
+      </property>
+      <layout class="QVBoxLayout" name="verticalLayout">
+       <item>
+        <widget class="QListView" name="widgetsList">
+         <property name="dragEnabled">
+          <bool>true</bool>
+         </property>
+         <property name="dragDropMode">
+          <enum>QAbstractItemView::DragOnly</enum>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="widget" native="true">
+      <property name="minimumSize">
+       <size>
+        <width>150</width>
+        <height>0</height>
+       </size>
+      </property>
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <item>
+        <widget class="QSplitter" name="splitter_2">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <widget class="QScrollArea" name="scrollArea">
+          <property name="minimumSize">
+           <size>
+            <width>0</width>
+            <height>150</height>
+           </size>
+          </property>
+          <property name="widgetResizable">
+           <bool>true</bool>
+          </property>
+          <widget class="QWidget" name="scrollAreaWidgetContents">
+           <property name="geometry">
+            <rect>
+             <x>0</x>
+             <y>0</y>
+             <width>181</width>
+             <height>144</height>
+            </rect>
+           </property>
+           <layout class="QVBoxLayout" name="verticalLayout_4">
+            <item>
+             <widget class="LayoutView" name="layoutView" native="true"/>
+            </item>
+           </layout>
+          </widget>
+         </widget>
+         <widget class="QGroupBox" name="groupBox_2">
+          <property name="minimumSize">
+           <size>
+            <width>0</width>
+            <height>150</height>
+           </size>
+          </property>
+          <property name="title">
+           <string>Properties</string>
+          </property>
+          <property name="flat">
+           <bool>false</bool>
+          </property>
+         </widget>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>LayoutView</class>
+   <extends>QWidget</extends>
+   <header>layout_view.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layout_builder_widgets.cpp	Wed Aug 24 20:38:55 2011 +0200
@@ -0,0 +1,47 @@
+/*
+Bellaciao: a Salut à Toi frontend
+Copyright (C) 2011  Jérôme Poisson (goffi@goffi.org)
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "layout_widgets.h"
+#include <QDebug>
+
+WidgetProperty::WidgetProperty(const QString& name, const QString& tooltip)
+    : m_name(name), m_type(NONE)
+{
+}
+
+WidgetProperty::~WidgetProperty()
+{
+}
+
+WidgetPropertyBool::WidgetPropertyBool(const QString& name, bool checked, const QString& tooltip)
+    : WidgetProperty(name, tooltip), m_checked(checked), m_type(BOOL) 
+{
+}
+
+LayoutWidget::LayoutWidget(const QString& name, const QString& icon)
+    : m_name(name), m_icon(icon)
+{
+    qDebug() << "LayoutWidget constructeur (" << name <<")";
+
+}
+
+LayoutWidget::~LayoutWidget()
+{
+    qDebug() << "LayoutWidget destructeur";
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layout_designer.cpp	Wed Aug 24 20:38:55 2011 +0200
@@ -0,0 +1,31 @@
+/*
+Bellaciao: a Salut à Toi frontend
+Copyright (C) 2011  Jérôme Poisson (goffi@goffi.org)
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "layout_designer.h"
+
+LayoutDesigner::LayoutDesigner(QWidget* parent)
+    : QWidget(parent)
+{
+    setupUi(this);
+    centralTabs->addTab(layoutBuilder_factory.Create(CONTACT_LIST), tr("Contact list"));
+}
+
+LayoutDesigner::~LayoutDesigner()
+{
+    qDebug() << "Destructeur de LayoutDesigner";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layout_designer.h	Wed Aug 24 20:38:55 2011 +0200
@@ -0,0 +1,40 @@
+/*
+Bellaciao: a Salut à Toi frontend
+Copyright (C) 2011  Jérôme Poisson (goffi@goffi.org)
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef LAYOUT_DESIGNER_H
+#define LAYOUT_DESIGNER_H
+
+
+#include <QtGui>
+#include "ui_layout_designer.h"
+#include "layout_builder.h"
+
+class LayoutDesigner : public QWidget, private Ui::LayoutDesignerUI
+{
+    Q_OBJECT
+
+    public:
+        LayoutDesigner(QWidget* parent=0);
+        ~LayoutDesigner();
+
+    private:
+        LayoutBuilderFactory layoutBuilder_factory;
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layout_designer.ui	Wed Aug 24 20:38:55 2011 +0200
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LayoutDesignerUI</class>
+ <widget class="QWidget" name="LayoutDesignerUI">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>402</width>
+    <height>425</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QTabWidget" name="centralTabs">
+     <property name="tabPosition">
+      <enum>QTabWidget::South</enum>
+     </property>
+     <property name="tabShape">
+      <enum>QTabWidget::Rounded</enum>
+     </property>
+     <property name="currentIndex">
+      <number>-1</number>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QWidget" name="widget" native="true">
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <item>
+       <widget class="QPushButton" name="buttonNewContactLayout">
+        <property name="text">
+         <string>New contact layout</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QPushButton" name="buttonDeleteLayout">
+        <property name="text">
+         <string>Delete layout</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layout_view.cpp	Wed Aug 24 20:38:55 2011 +0200
@@ -0,0 +1,81 @@
+/*
+Bellaciao: a Salut à Toi frontend
+Copyright (C) 2011  Jérôme Poisson (goffi@goffi.org)
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "layout_view.h"
+#include <QDebug>
+
+LayoutView::LayoutView(QWidget* parent)
+{
+    setAcceptDrops(true);
+    m_layout = new QVBoxLayout;
+    setLayout(m_layout);
+    m_layout->addStretch();
+    setStyleSheet("QLabel {border: 1px solid black; \
+                           border-radius: 5px; \
+                           text-align: center; \
+                           background-color: white; \
+                           min-height: 20px; \
+                           max-height: 20px; \
+                           margin: 2px; \
+                           }");
+}
+
+LayoutView::~LayoutView()
+{
+}
+        
+void LayoutView::setLayoutWidgets(const QHash<QString, LayoutWidget*>& layout_widgets)
+{
+    m_layout_widgets = layout_widgets;
+}
+        
+void LayoutView::dragEnterEvent (QDragEnterEvent* event )
+{
+    qDebug() << "Drag enter: " << event->pos();
+    if (event->mimeData()->hasFormat(LAYOUT_WIDGET_MIME))
+        event->acceptProposedAction();
+}
+        
+void LayoutView::dragMoveEvent (QDragMoveEvent* event )
+{
+    qDebug() << "Drag move: " << event->pos();
+    QWidget* _wid = childAt(event->pos());
+    if (_wid)
+        qDebug() << "Object: " << _wid->metaObject()->className();
+}
+
+void LayoutView::dropEvent (QDropEvent* event)
+{
+    const QMimeData *data = event->mimeData();
+    QByteArray encodedData = data->data(LAYOUT_WIDGET_MIME);
+    QDataStream stream(&encodedData, QIODevice::ReadOnly);
+    while (!stream.atEnd()) {
+        QString widget_name;
+        stream >> widget_name;
+        addWidget(widget_name);
+    } 
+}
+
+void LayoutView::addWidget(const QString& name)
+{
+    LayoutWidget* _widget = m_layout_widgets[name];
+    qDebug() << "Adding: " << name;
+    QLabel* _label = new QLabel(name);
+    _label->setAlignment(Qt::AlignCenter);
+    m_layout->insertWidget(qMax(0, m_layout->count()-1), _label, 0, Qt::AlignTop);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layout_view.h	Wed Aug 24 20:38:55 2011 +0200
@@ -0,0 +1,47 @@
+/*
+Bellaciao: a Salut à Toi frontend
+Copyright (C) 2011  Jérôme Poisson (goffi@goffi.org)
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef LAYOUT_VIEW_H
+#define LAYOUT_VIEW_H
+
+#include <QWidget>
+#include <QDragEnterEvent>
+#include "layout_widget.h"
+
+#define LAYOUT_WIDGET_MIME "application/x-bellaciao-widget"
+
+
+class LayoutView : public QWidget
+{
+    Q_OBJECT
+
+    public:
+        LayoutView(QWidget* parent=0);
+        ~LayoutView();
+        void setLayoutWidgets(const QHash<QString, LayoutWidget*>& layout_widgets);
+        void dragEnterEvent (QDragEnterEvent* event );
+        void dragMoveEvent (QDragMoveEvent* event );
+        void dropEvent (QDropEvent * event);
+    protected:
+        void addWidget(const QString& name);
+    private:
+        QHash<QString, LayoutWidget*> m_layout_widgets;
+        QList<LayoutWidget> m_widgets_list;
+        QVBoxLayout* m_layout;
+};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layout_widget.cpp	Wed Aug 24 20:38:55 2011 +0200
@@ -0,0 +1,140 @@
+/*
+Bellaciao: a Salut à Toi frontend
+Copyright (C) 2011  Jérôme Poisson (goffi@goffi.org)
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "layout_widget.h"
+
+WidgetProperty::WidgetProperty(const QString& name, const QString& tooltip)
+    : m_name(name), m_type(NONE)
+{
+}
+
+WidgetPropertyBool::WidgetPropertyBool(const QString& name, bool checked, const QString& tooltip)
+    : WidgetProperty(name, tooltip), m_checked(checked)
+{
+    m_type = BOOL;
+}
+
+LayoutWidget::LayoutWidget(const QString& name, const QString& icon)
+    : m_name(name), m_icon(icon)
+{
+    qDebug() << "LayoutWidget constructeur (" << name <<")";
+
+}
+
+LayoutWidget::~LayoutWidget()
+{
+    qDebug() << "LayoutWidget destructeur";
+
+}
+
+const QString& LayoutWidget::getName() const
+{
+    return m_name;
+}
+
+LayoutWidgetModel::LayoutWidgetModel(QObject* parent)
+    : QAbstractListModel(parent)
+{
+}
+
+LayoutWidgetModel::~LayoutWidgetModel()
+{
+
+    qDebug() << "Destructeur de LayoutWidgetModel";
+    while (!m_layout_widgets.isEmpty())
+        delete m_layout_widgets.takeFirst();
+    qDebug() << "Fin Destructeur de LayoutWidgetModel";
+}
+
+int LayoutWidgetModel::rowCount(const QModelIndex &parent) const
+{
+    return m_layout_widgets.size();
+}
+
+QVariant LayoutWidgetModel::data(const QModelIndex &index, int role) const
+{
+    if (!index.isValid())
+        return QVariant();
+
+    if (index.row() >= m_layout_widgets.size())
+        return QVariant();
+
+    if (role == Qt::DisplayRole)
+        return m_layout_widgets[index.row()]->getName();
+
+    return QVariant();
+}
+
+Qt::ItemFlags LayoutWidgetModel::flags (const QModelIndex& index) const
+{
+    Qt::ItemFlags default_flags = QAbstractListModel::flags(index);
+
+    if (index.isValid())
+        return default_flags | Qt::ItemIsDragEnabled;
+    return default_flags;
+}
+
+QStringList LayoutWidgetModel::mimeTypes() const
+{
+    QStringList types;
+    types << LAYOUT_WIDGET_MIME;
+    return types;
+}
+
+QMimeData* LayoutWidgetModel::mimeData (const QModelIndexList& indexes ) const
+{
+    QMimeData *mimeData = new QMimeData();
+    QByteArray encodedData;
+
+    QDataStream stream(&encodedData, QIODevice::WriteOnly);
+
+    foreach (const QModelIndex &index, indexes) {
+        if (index.isValid()) {
+            QString text = m_layout_widgets[index.row()]->getName();
+            stream << text;
+        }
+    }
+
+    mimeData->setData(LAYOUT_WIDGET_MIME, encodedData);
+    return mimeData;
+}
+
+void LayoutWidgetModel::append(LayoutWidget* layout_widget)
+{
+    if (m_layout_widgets_dict.contains(layout_widget->getName()))
+    {
+        qWarning() << "Layout widget of this name already exists, can't add an other one: " << layout_widget->getName();
+        delete layout_widget;
+        return;
+    }
+    beginInsertRows(QModelIndex(), m_layout_widgets.size(), m_layout_widgets.size()+1);
+    m_layout_widgets.append(layout_widget);
+    m_layout_widgets_dict.insert(layout_widget->getName(), layout_widget);
+    endInsertRows();
+}
+
+
+const QList<LayoutWidget*>& LayoutWidgetModel::getLayoutWidgets() const
+{
+    return m_layout_widgets;
+}
+
+const QHash<QString, LayoutWidget*>& LayoutWidgetModel::getLayoutWidgetsDict() const
+{
+    return m_layout_widgets_dict;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layout_widget.h	Wed Aug 24 20:38:55 2011 +0200
@@ -0,0 +1,83 @@
+/*
+Bellaciao: a Salut à Toi frontend
+Copyright (C) 2011  Jérôme Poisson (goffi@goffi.org)
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef LAYOUT_WIDGETS_H
+#define LAYOUT_WIDGETS_H
+
+#include <QtGui>
+
+#define LAYOUT_WIDGET_MIME "application/x-bellaciao-widget"
+
+typedef enum {
+    NONE, BOOL, LIST
+} WidgetPropertyType;
+
+class WidgetProperty
+{
+    public:
+        WidgetProperty(const QString& name, const QString& tooltip);
+
+    protected:
+        QString m_name, m_tooltip;
+        WidgetPropertyType m_type;
+
+};
+
+class WidgetPropertyBool: public WidgetProperty
+{
+    public:
+        WidgetPropertyBool(const QString& name, bool checked=false, const QString& tooltip = QString());
+    
+    protected:
+        bool m_checked;
+};
+
+
+
+class LayoutWidget
+{
+    public:
+        LayoutWidget(const QString &name, const QString& icon="");
+        ~LayoutWidget();
+        const QString& getName() const;
+
+    private:
+        QString m_name, m_icon;
+        QList<WidgetProperty> m_properties;
+};
+
+class LayoutWidgetModel: public QAbstractListModel
+{
+    Q_OBJECT
+
+    public:
+        LayoutWidgetModel(QObject* parent=0);
+        ~LayoutWidgetModel();
+        int rowCount(const QModelIndex &parent = QModelIndex()) const;
+        QVariant data(const QModelIndex &index, int role) const;
+        Qt::ItemFlags flags (const QModelIndex& index) const;
+        QStringList mimeTypes() const;
+        QMimeData* mimeData (const QModelIndexList& indexes ) const;
+        void append(LayoutWidget* layout_widget);
+        const QList<LayoutWidget*>& getLayoutWidgets() const;
+        const QHash<QString, LayoutWidget*>& getLayoutWidgetsDict() const;
+    private:
+        QList<LayoutWidget*> m_layout_widgets;
+        QHash<QString, LayoutWidget*> m_layout_widgets_dict;
+};
+#endif
--- a/settings.cpp	Sun Aug 14 18:03:54 2011 +0200
+++ b/settings.cpp	Wed Aug 24 20:38:55 2011 +0200
@@ -18,6 +18,7 @@
 
 #include "settings.h"
 #include "bellaciao.h"
+#include "layout_designer.h"
 
 using namespace Qt;
 
@@ -48,6 +49,15 @@
 
     this->setAttribute(WA_DeleteOnClose);
 
+    //We add the settings in tabs
+
+    // Contact list Layout
+    QVBoxLayout *layout =  new QVBoxLayout;
+    LayoutDesigner* contact_list_layout = new LayoutDesigner;
+    layout->addWidget(contact_list_layout);
+    contactListLayoutTab->setLayout(layout);
+    
+
     //We fill the profiles list
     m_bridge = Bridge::getBridge();
     m_session = Session::getSession();
--- a/settings.h	Sun Aug 14 18:03:54 2011 +0200
+++ b/settings.h	Wed Aug 24 20:38:55 2011 +0200
@@ -35,7 +35,7 @@
         QString m_profile;
 };
 
-class Settings : public QWidget, private Ui::SettingsDlg
+class Settings : public QWidget, private Ui::SettingsUI
 {
     Q_OBJECT
 
--- a/settings.ui	Sun Aug 14 18:03:54 2011 +0200
+++ b/settings.ui	Wed Aug 24 20:38:55 2011 +0200
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
- <class>SettingsDlg</class>
- <widget class="QWidget" name="SettingsDlg">
+ <class>SettingsUI</class>
+ <widget class="QWidget" name="SettingsUI">
   <property name="geometry">
    <rect>
     <x>0</x>
@@ -11,11 +11,11 @@
    </rect>
   </property>
   <property name="windowTitle">
-   <string>Form</string>
+   <string>Bellaciao settings</string>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
-    <widget class="QTabWidget" name="tabWidget">
+    <widget class="QTabWidget" name="profilesTab">
      <property name="currentIndex">
       <number>0</number>
      </property>
@@ -33,7 +33,7 @@
              <item>
               <widget class="QLabel" name="label_3">
                <property name="text">
-                <string>Check profiles you want to use</string>
+                <string>Tick profiles you want to use</string>
                </property>
                <property name="alignment">
                 <set>Qt::AlignCenter</set>
@@ -53,6 +53,9 @@
           <item>
            <widget class="QWidget" name="widget_2" native="true">
             <layout class="QVBoxLayout" name="verticalLayout_3">
+             <property name="margin">
+              <number>0</number>
+             </property>
              <item>
               <widget class="QWidget" name="profileData" native="true">
                <property name="enabled">
@@ -194,7 +197,7 @@
        </item>
       </layout>
      </widget>
-     <widget class="QWidget" name="tab_2">
+     <widget class="QWidget" name="contactListLayoutTab">
       <attribute name="title">
        <string>Contact list layout</string>
       </attribute>