[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/style-Model-moji] plugins/textshape: tempo
From:       Pierre Stirnweiss <pstirnweiss () googlemail ! com>
Date:       2012-10-21 20:18:50
Message-ID: 20121021201850.E608DA60D4 () git ! kde ! org
[Download RAW message or body]

Git commit 847e097a81ca6a2ea2c6683c886978f474343629 by Pierre Stirnweiss.
Committed on 21/10/2012 at 22:14.
Pushed by pstirnweiss into branch 'style-Model-moji'.

tempo

M  +13   -2    plugins/textshape/CMakeLists.txt
M  +12   -2    plugins/textshape/TextTool.cpp
A  +63   -0    plugins/textshape/dialogs/GeneralStylesTab.cpp     [License: LGPL \
(v2+)] A  +89   -0    plugins/textshape/dialogs/GeneralStylesTab.h     [License: LGPL \
(v2+)] A  +94   -0    plugins/textshape/dialogs/GeneralStylesTab.ui
M  +4    -1    plugins/textshape/dialogs/StyleManager.ui
M  +1    -2    plugins/textshape/dialogs/StylesDelegate.cpp
A  +228  -0    plugins/textshape/dialogs/StylesGeneralTab.cpp     [License: LGPL \
(v2+)] A  +78   -0    plugins/textshape/dialogs/StylesGeneralTab.h     [License: LGPL \
(v2+)] A  +102  -0    plugins/textshape/dialogs/StylesGeneralTab.ui
A  +259  -0    plugins/textshape/dialogs/StylesManager.cpp     [License: LGPL (v2+)]
A  +89   -0    plugins/textshape/dialogs/StylesManager.h     [License: LGPL (v2+)]
A  +175  -0    plugins/textshape/dialogs/StylesManager.ui
A  +128  -0    plugins/textshape/dialogs/StylesManagerStylesListItemDelegate.cpp     \
[License: LGPL (v2+)] A  +52   -0    \
plugins/textshape/dialogs/StylesManagerStylesListItemDelegate.h     [License: LGPL \
(v2+)] A  +278  -0    plugins/textshape/dialogs/StylesManagerStylesListModel.cpp     \
[License: LGPL (v2+)] A  +72   -0    \
plugins/textshape/dialogs/StylesManagerStylesListModel.h     [License: LGPL (v2+)] A  \
+170  -0    plugins/textshape/dialogs/StylesManagerStylesModel.cpp     [License: LGPL \
(v2+)] A  +65   -0    plugins/textshape/dialogs/StylesManagerStylesModel.h     \
[License: LGPL (v2+)] M  +13   -0    plugins/textshape/dialogs/StylesModel.cpp
C  +61   -52   plugins/textshape/dialogs/StylesModelV1.cpp [from: \
plugins/textshape/dialogs/StylesModel.cpp - 085% similarity] A  +175  -0    \
plugins/textshape/dialogs/StylesModelV1.h     [License: LGPL (v2+)]

http://commits.kde.org/calligra/847e097a81ca6a2ea2c6683c886978f474343629

diff --git a/plugins/textshape/CMakeLists.txt b/plugins/textshape/CMakeLists.txt
index 3e74283..dfd2eb1 100644
--- a/plugins/textshape/CMakeLists.txt
+++ b/plugins/textshape/CMakeLists.txt
@@ -62,6 +62,14 @@ SET ( textshape_SRCS
     dialogs/ValidParentStylesProxyModel.cpp
     dialogs/StylesDelegate.cpp
     dialogs/StyleManager.cpp
+
+    dialogs/StylesManager.cpp
+    dialogs/StylesGeneralTab.cpp
+    dialogs/StylesManagerStylesModel.cpp
+    dialogs/StylesManagerStylesListModel.cpp
+    dialogs/StylesManagerStylesListItemDelegate.cpp
+    dialogs/StylesModelV1.cpp
+
     dialogs/StyleManagerDialog.cpp
     dialogs/ParagraphGeneral.cpp
     dialogs/CharacterGeneral.cpp
@@ -116,7 +124,7 @@ kde4_add_ui_files(textshape_SRCS
     dialogs/ParagraphIndentSpacing.ui
     dialogs/ParagraphDecorations.ui
     dialogs/ParagraphBulletsNumbers.ui
-    dialogs/ParagraphDropCaps.ui   
+    dialogs/ParagraphDropCaps.ui
     dialogs/StyleManager.ui
     dialogs/CharacterGeneral.ui
     dialogs/CharacterHighlighting.ui
@@ -124,7 +132,10 @@ kde4_add_ui_files(textshape_SRCS
     dialogs/TableDialog.ui
     dialogs/BibliographyConfigureDialog.ui
     dialogs/TableOfContentsConfigure.ui
-    dialogs/TableOfContentsStyleConfigure.ui 
+    dialogs/TableOfContentsStyleConfigure.ui
+
+    dialogs/StylesManager.ui
+    dialogs/StylesGeneralTab.ui
 
     dialogs/FontDecorations.ui
     dialogs/LanguageTab.ui
diff --git a/plugins/textshape/TextTool.cpp b/plugins/textshape/TextTool.cpp
index bae0847..fd86241 100644
--- a/plugins/textshape/TextTool.cpp
+++ b/plugins/textshape/TextTool.cpp
@@ -34,6 +34,9 @@
 #include "dialogs/FontDia.h"
 #include "dialogs/TableDialog.h"
 #include "dialogs/SimpleTableWidget.h"
+
+#include "dialogs/StylesManager.h"
+
 #include "commands/AutoResizeCommand.h"
 #include "commands/ChangeListLevelCommand.h"
 #include "FontSizeAction.h"
@@ -961,9 +964,11 @@ void TextTool::mousePressEvent(KoPointerEvent *event)
         repaintCaret();
 
     updateSelectionHandler();
+    kDebug() << "mousePress will update style manager";
     updateStyleManager();
-
+    kDebug() << "stylemanage updated";
     updateActions();
+    kDebug() << "action updated";
 
     //activate context-menu for spelling-suggestions
     if (event->button() == Qt::RightButton) {
@@ -984,6 +989,7 @@ void TextTool::mousePressEvent(KoPointerEvent *event)
             editingPluginEvents();
         }
     }
+    kDebug() << "press button finished";
 }
 
 void TextTool::setShapeData(KoTextShapeData *data)
@@ -2493,7 +2499,9 @@ void TextTool::showStyleManager(int styleId)
     Q_ASSERT(styleManager);
     if (!styleManager)
         return;  //don't crash
-    StyleManagerDialog *dia = new StyleManagerDialog(canvas()->canvasWidget());
+    StylesManager *dia = new StylesManager(styleManager);
+    dia->setStyleManager(styleManager);
+/*    StyleManagerDialog *dia = new StyleManagerDialog(canvas()->canvasWidget());
     dia->setStyleManager(styleManager);
     dia->setUnit(canvas()->unit());
 
@@ -2505,7 +2513,9 @@ void TextTool::showStyleManager(int styleId)
     if (characterStyle) {
         dia->setCharacterStyle(characterStyle);
     }
+   */
     dia->show();
+    kDebug() << "shown";
 }
 
 void TextTool::startTextEditingPlugin(const QString &pluginId)
diff --git a/plugins/textshape/dialogs/GeneralStylesTab.cpp \
b/plugins/textshape/dialogs/GeneralStylesTab.cpp new file mode 100644
index 0000000..aa07a8f
--- /dev/null
+++ b/plugins/textshape/dialogs/GeneralStylesTab.cpp
@@ -0,0 +1,63 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "GeneralStylesTab.h"
+#include "ui_GeneralStylesTab.h"
+
+GeneralStylesTab::GeneralStylesTab(QWidget *parent) :
+    QWidget(parent),
+    ui(new Ui::GeneralStylesTab),
+    m_style(0),
+//    m_styleManager(0),
+    m_StyleModel(0),
+    m_validParentStylesModel(new ValidParentStylesProxyModel())
+{
+    ui->setupUi(this);
+
+    ui->nextStyle->setStyleIsOriginal(true);
+    ui->nextStyle->showEditIcon(false);
+
+    ui->inheritStyle->setStyleIsOriginal(true);
+    ui->inheritStyle->showEditIcon(false);
+
+//widget.nextStyle->setVisible(false);
+//m_characterStyleModel->setStyleThumbnailer(m_thumbnail);
+//widget.nextStyle->setStylesModel(m_characterStyleModel);
+//widget.label_2->setVisible(false);
+//
+
+// inherited style model
+//widget.inheritStyle->showEditIcon(false);
+//widget.inheritStyle->setStyleIsOriginal(true);
+//for character General
+}
+
+GeneralStylesTab::~GeneralStylesTab()
+{
+    delete ui;
+}
+
+void GeneralStylesTab::setStylesModel(StylesModel *model)
+{
+    Q_ASSERT(model);
+    m_StyleModel = model;
+    m_validParentStylesModel->setStylesModel(m_StyleModel);
+    ui->nextStyle->setStylesModel(m_StyleModel);
+    ui->inheritStyle->setStylesModel(m_validParentStylesModel);
+}
diff --git a/plugins/textshape/dialogs/GeneralStylesTab.h \
b/plugins/textshape/dialogs/GeneralStylesTab.h new file mode 100644
index 0000000..b8d980c
--- /dev/null
+++ b/plugins/textshape/dialogs/GeneralStylesTab.h
@@ -0,0 +1,89 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GENERALSTYLESTAB_H
+#define GENERALSTYLESTAB_H
+
+#include <QWidget>
+
+class KoCharacterStyle;
+class KoStyleManager;
+class KoStyleThumbnailer;
+class FontDecorations;
+class CharacterHighlighting;
+class LanguageTab;
+class StylesModel;
+class ValidParentStylesProxyModel;
+
+namespace Ui {
+class GeneralStylesTab;
+}
+
+class GeneralStylesTab : public QWidget
+{
+    Q_OBJECT
+    
+public:
+    explicit GeneralStylesTab(QWidget *parent = 0);
+    ~GeneralStylesTab();
+
+    void setStylesModel(StylesModel *model);
+
+    void setStyle(KoCharacterStyle *style);
+//    void hideStyleName(bool hide);
+    bool isStyleChanged();
+//    QString styleName() const;
+//    void selectName();
+//    void setStyleManager(KoStyleManager *sm);
+
+
+//    void updateNextStyleCombo(KoParagraphStyle *style); // set current style in \
next style combo +//    int nextStyleId(); //return the current style id in next \
style combo +
+public slots:
+    void save(KoCharacterStyle *style = 0);
+
+//    void switchToGeneralTab();
+
+signals:
+    void nameChanged(const QString &name);
+    void styleAltered(const KoCharacterStyle *style); // when saving
+    void styleChanged(); /// when user modifying
+
+private slots:
+//    void setPreviewCharacterStyle();
+
+private:
+    Ui::GeneralStylesTab *ui;
+
+//    bool m_nameHidden;
+
+//    FontDecorations *m_characterDecorations;
+//    CharacterHighlighting *m_characterHighlighting;
+//    LanguageTab *m_languageTab;
+
+    KoCharacterStyle *m_style;
+//    KoStyleManager *m_styleManager;
+//    KoStyleThumbnailer *m_thumbnailer;
+    StylesModel *m_StyleModel;
+    ValidParentStylesProxyModel *m_validParentStylesModel;
+//    StylesModel *m_characterInheritedStyleModel;
+};
+
+#endif // GENERALSTYLESTAB_H
diff --git a/plugins/textshape/dialogs/GeneralStylesTab.ui \
b/plugins/textshape/dialogs/GeneralStylesTab.ui new file mode 100644
index 0000000..f5823c1
--- /dev/null
+++ b/plugins/textshape/dialogs/GeneralStylesTab.ui
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>GeneralStylesTab</class>
+ <widget class="QWidget" name="GeneralStylesTab">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string comment="Name of the style">Name:</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="QLineEdit" name="name"/>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="label_2">
+     <property name="text">
+      <string>Next style:</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+     <property name="buddy">
+      <cstring>nextStyle</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="StylesCombo" name="nextStyle"/>
+   </item>
+   <item row="2" column="0">
+    <widget class="QLabel" name="label_3">
+     <property name="text">
+      <string>Parent style:</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+     <property name="buddy">
+      <cstring>inheritStyle</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1">
+    <widget class="StylesCombo" name="inheritStyle"/>
+   </item>
+   <item row="3" column="0" colspan="2">
+    <widget class="QCheckBox" name="inToc">
+     <property name="text">
+      <string>Include in table of contents</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="0">
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>184</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>StylesCombo</class>
+   <extends>QComboBox</extends>
+   <header>dialogs/StylesCombo.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/plugins/textshape/dialogs/StyleManager.ui \
b/plugins/textshape/dialogs/StyleManager.ui index f9efe07..474a441 100644
--- a/plugins/textshape/dialogs/StyleManager.ui
+++ b/plugins/textshape/dialogs/StyleManager.ui
@@ -25,6 +25,9 @@
        <verstretch>0</verstretch>
       </sizepolicy>
      </property>
+     <property name="currentIndex">
+      <number>0</number>
+     </property>
      <widget class="QListView" name="paragraphStylesListView">
       <property name="sizePolicy">
        <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
@@ -64,7 +67,7 @@
       </sizepolicy>
      </property>
      <property name="currentIndex">
-      <number>2</number>
+      <number>1</number>
      </property>
      <widget class="StyleManagerWelcome" name="welcomePage"/>
      <widget class="ParagraphGeneral" name="paragraphStylePage"/>
diff --git a/plugins/textshape/dialogs/StylesDelegate.cpp \
b/plugins/textshape/dialogs/StylesDelegate.cpp index 39a6fc7..bb2a959 100644
--- a/plugins/textshape/dialogs/StylesDelegate.cpp
+++ b/plugins/textshape/dialogs/StylesDelegate.cpp
@@ -47,8 +47,7 @@ StylesDelegate::StylesDelegate()
     m_buttonDistance = 2;
 }
 
-void StylesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optionV1,
-                            const QModelIndex &index) const
+void StylesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optionV1, \
const QModelIndex &index) const  {
     QStyleOptionViewItemV4 option = optionV1;
     initStyleOption(&option, index);
diff --git a/plugins/textshape/dialogs/StylesGeneralTab.cpp \
b/plugins/textshape/dialogs/StylesGeneralTab.cpp new file mode 100644
index 0000000..0377845
--- /dev/null
+++ b/plugins/textshape/dialogs/StylesGeneralTab.cpp
@@ -0,0 +1,228 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "ui_StylesGeneralTab.h"
+
+#include "StylesGeneralTab.h"
+
+#include "StylesModel.h"
+#include "AbstractStylesModel.h"
+#include "ValidParentStylesProxyModel.h"
+
+#include <KoCharacterStyle.h>
+#include <KoIcon.h>
+#include <KoParagraphStyle.h>
+#include <KoStyleManager.h>
+
+#include <KDebug>
+#include <KLocale>
+
+StylesGeneralTab::StylesGeneralTab(QWidget *parent) :
+    QWidget(parent),
+    ui(new Ui::StylesGeneralTab),
+    m_style(0),
+    m_styleManager(0),
+    m_styleModel(0),
+    m_validParentStylesModel(new ValidParentStylesProxyModel())
+{
+    ui->setupUi(this);
+
+    ui->nextStyle->setStyleIsOriginal(true);
+    ui->nextStyle->showEditIcon(false);
+
+    ui->inheritStyle->setStyleIsOriginal(true);
+    ui->inheritStyle->showEditIcon(false);
+
+    const KIcon clearIcon(koIconName("edit-clear"));
+    ui->clearInheritStyle->setIcon(clearIcon);
+    ui->clearNextStyle->setIcon(clearIcon);
+
+
+    connect(ui->name, SIGNAL(textChanged(const QString&)), this, \
SIGNAL(nameChanged(const QString&))); +    connect(ui->nextStyle, \
SIGNAL(currentIndexChanged(int)), this, SIGNAL(styleChanged())); +    \
connect(ui->inheritStyle, SIGNAL(currentIndexChanged(int)), this, \
SIGNAL(styleChanged())); +    connect(ui->clearNextStyle, SIGNAL(clicked()), this, \
SLOT(slotClearNextStyle())); +    connect(ui->clearInheritStyle, SIGNAL(clicked()), \
this, SLOT(slotClearInheritStyle())); +}
+
+StylesGeneralTab::~StylesGeneralTab()
+{
+    delete ui;
+}
+
+void StylesGeneralTab::setStylesModel(AbstractStylesModel *model)
+{
+    Q_ASSERT(model);
+/*    m_styleModel = model;
+    m_validParentStylesModel->setStylesModel(m_styleModel);
+    if (model->stylesType() == StylesModel::CharacterStyle) {
+        m_styleType = CharacterStyle;
+        ui->nextStyle->setVisible(false);
+        ui->nextStyleLabel->setVisible(false);
+    }
+    else {
+        m_styleType = ParagraphStyle;
+        ui->nextStyle->setStylesModel(m_styleModel);
+    }
+    ui->inheritStyle->setStylesModel(m_validParentStylesModel);*/
+}
+
+void StylesGeneralTab::setStyleManager(KoStyleManager *sm)
+{
+    Q_ASSERT(sm);
+    m_styleManager = sm;
+    m_validParentStylesModel->setStyleManager(sm);
+}
+
+void StylesGeneralTab::setCurrentStyle(KoCharacterStyle *style)
+{
+    Q_ASSERT(m_styleModel);
+    Q_ASSERT(m_styleManager);
+    Q_ASSERT(style);
+    if (!style || !m_styleModel || !m_styleManager) {
+        return;
+    }
+
+    if (style->styleType() != KoCharacterStyle::ParagraphStyle && m_styleType == \
ParagraphStyle) { +        Q_ASSERT(false);
+        return;
+    }
+
+    KoParagraphStyle *paragStyle = dynamic_cast<KoParagraphStyle*>(style);
+    blockSignals(true);
+
+    if (!style->name().isEmpty()) {
+        ui->name->setText(style->name());
+    }
+    else {
+        ui->name->setText(QString());
+        ui->name->setPlaceholderText(i18n("New name"));
+    }
+
+    m_validParentStylesModel->setCurrentChildStyleId(style->styleId());
+
+    if (paragStyle) {
+//        m_styleModel->setCurrentParagraphStyle(paragStyle->styleId());
+        KoParagraphStyle *nextStyle = \
m_styleManager->paragraphStyle(paragStyle->nextStyle()); +        if (nextStyle) {
+            ui->nextStyle->setCurrentIndex(m_styleModel->indexForParagraphStyle(*nextStyle).row());
 +        }
+        else {
+            ui->nextStyle->setCurrentIndex(-1);
+        }
+        KoParagraphStyle *parentStyle = paragStyle->parentStyle();
+        if (parentStyle) {
+            ui->inheritStyle->setCurrentIndex(m_validParentStylesModel->indexForParagraphStyle(*parentStyle).row());
 +        }
+        else {
+            ui->inheritStyle->setCurrentIndex(-1);
+        }
+    }
+    else {
+        KoCharacterStyle *parentStyle = style->parentStyle();
+        if (parentStyle) {
+            ui->inheritStyle->setCurrentIndex(m_validParentStylesModel->indexForCharacterStyle(*parentStyle).row());
 +        }
+        else {
+            ui->inheritStyle->setCurrentIndex(-1);
+        }
+    }
+
+    m_style = style;
+
+    blockSignals(false);
+}
+
+void StylesGeneralTab::save(KoCharacterStyle *style)
+{
+    Q_ASSERT(m_styleModel);
+    Q_ASSERT(m_styleManager);
+    if (!m_styleModel || !m_styleManager) {
+        return;
+    }
+
+    KoCharacterStyle *savingStyle = style;
+    if (savingStyle == 0) {
+        if (m_style == 0) {
+            return;
+        }
+        else {
+            savingStyle = m_style;
+        }
+    }
+
+    if (!ui->name->text().isEmpty() && ui->name->text() != savingStyle->name()) {
+        savingStyle->setName(ui->name->text());
+    }
+
+    if (savingStyle->styleType() == KoCharacterStyle::ParagraphStyle) {
+        KoParagraphStyle *paragStyle = dynamic_cast<KoParagraphStyle*>(savingStyle);
+        Q_ASSERT(paragStyle); //this should not be the case
+
+        if (ui->nextStyle->currentIndex() != -1) {
+//            paragStyle->setNextStyle(m_styleModel->index(ui->nextStyle->currentIndex()).internalId());
 +        }
+        else {
+            paragStyle->remove(KoParagraphStyle::NextStyle);
+        }
+
+        if (ui->inheritStyle->currentIndex() != -1) {
+            KoParagraphStyle *parentStyle = \
m_styleManager->paragraphStyle(m_validParentStylesModel->index(ui->inheritStyle->currentIndex(), \
0, QModelIndex()).internalId()); +            if (parentStyle) {
+                paragStyle->setParentStyle(parentStyle);
+            }
+            else {
+                paragStyle->setParentStyle(0);
+            }
+        }
+        else {
+            paragStyle->setParentStyle(0);
+        }
+    }
+    else {
+        if (ui->inheritStyle->currentIndex() != -1) {
+            KoCharacterStyle *parentStyle = \
m_styleManager->characterStyle(m_validParentStylesModel->index(ui->inheritStyle->currentIndex(), \
0, QModelIndex()).internalId()); +            if (parentStyle) {
+                savingStyle->setParentStyle(parentStyle);
+            }
+            else {
+                savingStyle->setParentStyle(0);
+            }
+        }
+        else {
+            savingStyle->setParentStyle(0);
+        }
+    }
+}
+
+void StylesGeneralTab::slotClearNextStyle()
+{/*
+    if (m_styleModel->stylesType() != StylesModel::ParagraphStyle || \
m_style->styleType() != KoCharacterStyle::ParagraphStyle) { +        return;
+    }
+    else {
+        QModelIndex index = \
m_styleModel->indexForParagraphStyle(*(dynamic_cast<KoParagraphStyle*>(m_style))); +  \
ui->nextStyle->setCurrentIndex(index.row()); +    }*/
+}
+
+void StylesGeneralTab::slotClearInheritStyle()
+{
+    ui->inheritStyle->setCurrentIndex(-1);
+}
diff --git a/plugins/textshape/dialogs/StylesGeneralTab.h \
b/plugins/textshape/dialogs/StylesGeneralTab.h new file mode 100644
index 0000000..41804e8
--- /dev/null
+++ b/plugins/textshape/dialogs/StylesGeneralTab.h
@@ -0,0 +1,78 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef STYLESGENERALTAB_H
+#define STYLESGENERALTAB_H
+
+#include <QWidget>
+
+class KoCharacterStyle;
+class KoStyleManager;
+class KoStyleThumbnailer;
+class FontDecorations;
+class CharacterHighlighting;
+class LanguageTab;
+class AbstractStylesModel;
+class StylesModel;
+class ValidParentStylesProxyModel;
+
+namespace Ui {
+class StylesGeneralTab;
+}
+
+class StylesGeneralTab : public QWidget
+{
+    Q_OBJECT
+
+public:
+    explicit StylesGeneralTab(QWidget *parent = 0);
+    ~StylesGeneralTab();
+
+    void setStylesModel(AbstractStylesModel *model);
+    void setStyleManager(KoStyleManager *sm);
+
+    void setCurrentStyle(KoCharacterStyle *style);
+
+public slots:
+    void save(KoCharacterStyle *style = 0);
+
+signals:
+    void nameChanged(const QString &name);
+    void styleChanged(); /// when user modifying
+
+private slots:
+    void slotClearNextStyle();
+    void slotClearInheritStyle();
+
+private:
+    Ui::StylesGeneralTab *ui;
+
+    enum Type {
+        CharacterStyle,
+        ParagraphStyle
+    };
+
+    Type m_styleType;
+    KoCharacterStyle *m_style;
+    KoStyleManager *m_styleManager;
+    AbstractStylesModel *m_styleModel;
+    ValidParentStylesProxyModel *m_validParentStylesModel;
+};
+
+#endif // STYLESGENERALTAB_H
diff --git a/plugins/textshape/dialogs/StylesGeneralTab.ui \
b/plugins/textshape/dialogs/StylesGeneralTab.ui new file mode 100644
index 0000000..85e4c6b
--- /dev/null
+++ b/plugins/textshape/dialogs/StylesGeneralTab.ui
@@ -0,0 +1,102 @@
+<ui version="4.0">
+ <author/>
+ <comment/>
+ <exportmacro/>
+ <class>StylesGeneralTab</class>
+ <widget class="QWidget" name="StylesGeneralTab">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string comment="Name of the style">Name:</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="QLineEdit" name="name"/>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="nextStyleLabel">
+     <property name="text">
+      <string>Next style:</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+     <property name="buddy">
+      <cstring>nextStyle</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="StylesCombo" name="nextStyle"/>
+   </item>
+   <item row="1" column="2">
+    <widget class="QPushButton" name="clearNextStyle"/>
+   </item>
+   <item row="2" column="0">
+    <widget class="QLabel" name="label_3">
+     <property name="text">
+      <string>Parent style:</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+     <property name="buddy">
+      <cstring>inheritStyle</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1">
+    <widget class="StylesCombo" name="inheritStyle"/>
+   </item>
+   <item row="2" column="2">
+    <widget class="QPushButton" name="clearInheritStyle"/>
+   </item>
+   <item row="3" column="0" colspan="2">
+    <widget class="QCheckBox" name="inToc">
+     <property name="text">
+      <string>Include in table of contents</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="0">
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>184</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>StylesCombo</class>
+   <extends>QComboBox</extends>
+   <header>dialogs/StylesCombo.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
+ <pixmapfunction/>
+ <connections/>
+</ui>
diff --git a/plugins/textshape/dialogs/StylesManager.cpp \
b/plugins/textshape/dialogs/StylesManager.cpp new file mode 100644
index 0000000..64a74f1
--- /dev/null
+++ b/plugins/textshape/dialogs/StylesManager.cpp
@@ -0,0 +1,259 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "ui_StylesManager.h"
+
+#include "StylesManager.h"
+#include "StylesManagerStylesListItemDelegate.h"
+#include "StylesManagerStylesModel.h"
+#include "StylesManagerStylesListModel.h"
+#include "StylesModel.h"
+#include "StylesModelV1.h"
+
+#include <KoCharacterStyle.h>
+#include <KoParagraphStyle.h>
+#include <KoStyleManager.h>
+#include <KoStyleThumbnailer.h>
+
+#include <QModelIndex>
+#include <QSortFilterProxyModel>
+#include <QTreeView>
+
+#include <KDebug>
+
+StylesManager::StylesManager(KoStyleManager *sm, QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::StylesManager),
+    m_styleManager(sm),
+    m_styleThumbnailer(new KoStyleThumbnailer()),
+    m_characterStyleBaseModel(new StylesModel(0,StylesModel::CharacterStyle)),
+    m_paragraphStyleBaseModel(new StylesModel(0,StylesModel::ParagraphStyle)),
+    m_characterStylesModel(new StylesManagerStylesModel()),
+    m_paragraphStylesModel(new StylesManagerStylesModel()),
+    m_characterStylesListModel(new StylesManagerStylesListModel()),
+    m_paragraphStylesListModel(new StylesManagerStylesListModel()),
+    m_characterStylesListItemDelegate(new StylesManagerStylesListItemDelegate()),
+    m_paragraphStylesListItemDelegate(new StylesManagerStylesListItemDelegate())
+{
+    ui->setupUi(this);
+
+    // Force "Base" background of the style listviews to white, so the background
+    // is consistent with the one of the preview area. Also the usual document text \
colors +    // are dark, because made for a white paper background, so with a dark UI
+    // color scheme they are hardly seen.
+    // TODO: update to background color of currently selected/focused shape/page
+    QPalette palette = this->palette();
+    palette.setColor(QPalette::Base, QColor(Qt::white));
+
+    ui->characterStylesListView->setPalette(palette);
+    ui->paragraphStylesListView->setPalette(palette);
+
+//    ui->characterGeneralTab->setVisible(false);
+//    ui->paragraphGeneralTab->setVisible(false);
+//    ui->characterStylesListView->setVisible(false);
+
+}
+
+StylesManager::~StylesManager()
+{
+    delete ui;
+    delete m_characterStylesListModel;
+    delete m_paragraphStylesListModel;
+    delete m_characterStyleBaseModel;
+    delete m_paragraphStyleBaseModel;
+    delete m_characterStylesModel;
+    delete m_paragraphStylesModel;
+    delete m_characterStylesListItemDelegate;
+    delete m_paragraphStylesListItemDelegate;
+}
+
+void StylesManager::setStyleManager(KoStyleManager *sm)
+{
+
+    Q_ASSERT(sm);
+    m_styleManager = sm;
+
+//    m_characterStyleBaseModel->setProvideStyleNone(false);
+//    m_characterStyleBaseModel->setStyleManager(m_styleManager);
+//    m_characterStyleBaseModel->setStyleThumbnailer(m_styleThumbnailer);
+    m_paragraphStyleBaseModel->setStyleManager(m_styleManager);
+    m_paragraphStyleBaseModel->setStyleThumbnailer(m_styleThumbnailer);
+
+//    m_characterStylesModel->setStyleManager(m_styleManager);
+//    m_characterStylesModel->setStylesModel(m_characterStyleBaseModel);
+    m_paragraphStylesModel->setStyleManager(m_styleManager);
+    m_paragraphStylesModel->setStylesModel(m_paragraphStyleBaseModel);
+
+//    m_characterStylesListModel->setStylesModel(m_characterStylesModel);
+    m_paragraphStylesListModel->setStylesModel(m_paragraphStylesModel);
+
+//    ui->characterStylesListView->setModel(m_characterStylesListModel);
+//    ui->characterStylesListView->setItemDelegate(m_characterStylesListItemDelegate);
 +//    ui->characterStylesListView->expandAll();
+//    ui->characterStylesListView->setIndentation(5);
+//    ui->characterStylesListView->setHeaderHidden(true);
+//    ui->characterStylesListView->setRootIsDecorated(false);
+    ui->paragraphStylesListView->setModel(m_paragraphStylesListModel);
+    ui->paragraphStylesListView->setItemDelegate(m_paragraphStylesListItemDelegate);
+    ui->paragraphStylesListView->expandAll();
+    ui->paragraphStylesListView->setIndentation(5);
+    ui->paragraphStylesListView->setHeaderHidden(true);
+    ui->paragraphStylesListView->setRootIsDecorated(false);
+
+    ui->characterGeneralTab->setStyleManager(m_styleManager);
+//    ui->characterGeneralTab->setStylesModel(m_characterStylesModel);
+    ui->paragraphGeneralTab->setStyleManager(m_styleManager);
+//    ui->paragraphGeneralTab->setStylesModel(m_paragraphStylesModel);
+
+    connect(ui->characterStylesListView, SIGNAL(activated(const QModelIndex&)), \
this, SLOT(slotCharacterStyleSelected(const QModelIndex&))); +    \
connect(ui->paragraphStylesListView, SIGNAL(activated(const QModelIndex&)), this, \
SLOT(slotParagraphStyleSelected(const QModelIndex&))); +
+    connect(ui->saveCharacterStyleButton, SIGNAL(clicked()), this, \
SLOT(slotSaveCharacterStyle())); +    connect(ui->saveParagraphStyleButton, \
SIGNAL(clicked()), this, SLOT(slotSaveParagraphStyle())); +
+    connect(ui->characterGeneralTab, SIGNAL(styleChanged()), this, \
SLOT(slotCharacterStyleChanged())); +    connect(ui->paragraphGeneralTab, \
SIGNAL(styleChanged()), this, SLOT(slotParagraphStyleChanged())); +
+}
+
+void StylesManager::slotCharacterStyleSelected(const QModelIndex &index)
+{
+    Q_ASSERT(m_styleManager);
+    if (!m_styleManager) {
+        return;
+    }
+
+    KoCharacterStyle *style = m_styleManager->characterStyle(index.internalId());
+    if (!style) {
+        return;
+    }
+    setCurrentCharacterStyle(style);
+}
+
+void StylesManager::slotParagraphStyleSelected(const QModelIndex &index)
+{
+    kDebug() << "in slot parag activated. internal id: " << index.internalId();
+//    kDebug() << "mapped internalId: " << \
m_paragraphStylesListModel->mapToSource(index).internalId(); +    kDebug() << \
"selection name: " << index.data(); +
+    Q_ASSERT(m_styleManager);
+    if (!m_styleManager) {
+        return;
+    }
+
+    blockSignals(true);
+
+    m_paragraphStylesModel->slotSetCurrentIndex(index);
+
+    if (m_paragraphStylesModel->currentSelectedStyle()) {
+        ui->paragraphGeneralTab->setCurrentStyle(m_paragraphStylesModel->currentSelectedStyle());
 +    }
+//    m_currentCharacterStyle = style;
+
+    blockSignals(false);
+
+}
+
+void StylesManager::slotSaveCharacterStyle()
+{
+    if (m_currentCharacterStyle) {
+        kDebug() << "-----------------------CharacterStyle saving----------";
+        kDebug() << "current name: " << m_currentCharacterStyle->name();
+        if (m_currentCharacterStyle->parentStyle())
+            kDebug() << "current parent: " << \
m_currentCharacterStyle->parentStyle()->name(); +        else
+            kDebug() << "current parent: None";
+        ui->characterGeneralTab->save(m_currentCharacterStyle);
+        kDebug() << "-------------after saving";
+        kDebug() << "current name: " << m_currentCharacterStyle->name();
+        if (m_currentCharacterStyle->parentStyle())
+            kDebug() << "current parent: " << \
m_currentCharacterStyle->parentStyle()->name(); +        else
+            kDebug() << "current parent: None";
+    }
+}
+
+void StylesManager::slotSaveParagraphStyle()
+{
+    if (m_currentParagraphStyle) {
+        kDebug() << "-----------------------ParagraphStyle saving-----------";
+        kDebug() << "current name: " << m_currentParagraphStyle->name();
+        if (m_currentParagraphStyle->parentStyle())
+            kDebug() << "current parent: " << \
m_currentParagraphStyle->parentStyle()->name(); +        else
+            kDebug() << "current parent: None";
+        KoParagraphStyle *nextStyle = \
m_styleManager->paragraphStyle(m_currentParagraphStyle->nextStyle()); +        if \
(nextStyle) +            kDebug() << "current next style: " << nextStyle->name();
+        else
+            kDebug() << "current next style: None";
+
+        ui->paragraphGeneralTab->save(m_currentParagraphStyle);
+
+        kDebug() << "-----------------------after saving";
+        kDebug() << "current name: " << m_currentParagraphStyle->name();
+        if (m_currentParagraphStyle->parentStyle())
+            kDebug() << "current parent: " << \
m_currentParagraphStyle->parentStyle()->name(); +        else
+            kDebug() << "current parent: None";
+        nextStyle = \
m_styleManager->paragraphStyle(m_currentParagraphStyle->nextStyle()); +        if \
(nextStyle) +            kDebug() << "current next style: " << nextStyle->name();
+        else
+            kDebug() << "current next style: None";
+    }
+}
+
+void StylesManager::slotCharacterStyleChanged()
+{
+
+}
+
+void StylesManager::slotParagraphStyleChanged()
+{
+    kDebug() << "in slotParagStyle changed";
+    m_paragraphStylesModel->slotModifiedStyle(/*m_currentParagraphStyle*/);
+    ui->paragraphGeneralTab->save(dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->currentSelectedStyle()));
 +    kDebug() << "saved. parent style: " << \
((m_paragraphStylesModel->currentSelectedStyle()->parentStyle())?m_paragraphStylesModel->currentSelectedStyle()->parentStyle()->name():"None");
 +    ui->paragraphStylesListView->expandAll();
+}
+
+void StylesManager::setCurrentCharacterStyle(KoCharacterStyle *style)
+{
+    blockSignals(true);
+
+    ui->characterGeneralTab->setCurrentStyle(style);
+//    m_currentCharacterStyle = style;
+
+    blockSignals(false);
+}
+
+void StylesManager::setCurrentParagraphStyle(KoParagraphStyle *style)
+{
+    blockSignals(true);
+
+    if (style) {
+        kDebug() << "setCurrent parStyle: "  << style->styleId();
+        kDebug() << "style name: " << style->name();
+        ui->paragraphGeneralTab->setCurrentStyle((KoCharacterStyle*)(style));
+        m_currentParagraphStyle = style;
+    }
+
+    blockSignals(false);
+}
diff --git a/plugins/textshape/dialogs/StylesManager.h \
b/plugins/textshape/dialogs/StylesManager.h new file mode 100644
index 0000000..edcec4e
--- /dev/null
+++ b/plugins/textshape/dialogs/StylesManager.h
@@ -0,0 +1,89 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef STYLESMANAGER_H
+#define STYLESMANAGER_H
+
+#include <QDialog>
+#include <QMap>
+
+class StylesModel;
+class StylesManagerStylesModel;
+class StylesManagerStylesListModel;
+class StylesManagerStylesListItemDelegate;
+
+class KoCharacterStyle;
+class KoParagraphStyle;
+class KoStyleManager;
+class KoStyleThumbnailer;
+
+class QModelIndex;
+class QSortFilterProxyModel;
+
+namespace Ui {
+class StylesManager;
+}
+
+class StylesManager : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit StylesManager(KoStyleManager *sm, QWidget *parent = 0);
+    ~StylesManager();
+
+    void setStyleManager(KoStyleManager *sm);
+
+public slots:
+    void setCurrentCharacterStyle(KoCharacterStyle *style);
+    void setCurrentParagraphStyle(KoParagraphStyle *style);
+
+private slots:
+    void slotCharacterStyleSelected(const QModelIndex&);
+    void slotParagraphStyleSelected(const QModelIndex&);
+
+    void slotCharacterStyleChanged();
+    void slotParagraphStyleChanged();
+
+    void slotSaveCharacterStyle();
+    void slotSaveParagraphStyle();
+private:
+    Ui::StylesManager *ui;
+
+    KoStyleManager *m_styleManager;
+    KoStyleThumbnailer *m_styleThumbnailer;
+    StylesModel *m_characterStyleBaseModel;
+    StylesModel *m_paragraphStyleBaseModel;
+//    StylesModelV1 *m_paragraphStyleModel;
+
+    StylesManagerStylesModel *m_characterStylesModel;
+    StylesManagerStylesModel *m_paragraphStylesModel;
+    StylesManagerStylesListModel *m_characterStylesListModel;
+    StylesManagerStylesListModel *m_paragraphStylesListModel;
+
+    StylesManagerStylesListItemDelegate *m_characterStylesListItemDelegate;
+    StylesManagerStylesListItemDelegate *m_paragraphStylesListItemDelegate;
+
+    KoCharacterStyle *m_currentCharacterStyle;
+    KoParagraphStyle *m_currentParagraphStyle;
+
+//    QMap<int, KoCharacterStyle*> m_modifiedCharacterStyles;
+//    QMap<int, KoParagraphStyle*> m_modifiedParagraphStyles;
+};
+
+#endif // STYLESMANAGER_H
diff --git a/plugins/textshape/dialogs/StylesManager.ui \
b/plugins/textshape/dialogs/StylesManager.ui new file mode 100644
index 0000000..49001ab
--- /dev/null
+++ b/plugins/textshape/dialogs/StylesManager.ui
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>StylesManager</class>
+ <widget class="QDialog" name="StylesManager">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>945</width>
+    <height>597</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_3">
+   <item>
+    <widget class="QTabWidget" name="stylesTypes">
+     <property name="currentIndex">
+      <number>0</number>
+     </property>
+     <widget class="QWidget" name="paragraphStylesTab">
+      <attribute name="title">
+       <string>Paragraph Styles</string>
+      </attribute>
+      <layout class="QHBoxLayout" name="horizontalLayout_3">
+       <item>
+        <layout class="QVBoxLayout" name="verticalLayout">
+         <item>
+          <widget class="QTreeView" name="paragraphStylesListView"/>
+         </item>
+         <item>
+          <layout class="QHBoxLayout" name="horizontalLayout">
+           <item>
+            <widget class="QPushButton" name="newParagraphStyleButton">
+             <property name="text">
+              <string>New</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QPushButton" name="saveParagraphStyleButton">
+             <property name="text">
+              <string>Save</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QPushButton" name="deleteParagraphStyleButton">
+             <property name="text">
+              <string>Delete</string>
+             </property>
+            </widget>
+           </item>
+          </layout>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <widget class="QTabWidget" name="paragraphOptionsTabs">
+         <property name="currentIndex">
+          <number>0</number>
+         </property>
+         <widget class="StylesGeneralTab" name="paragraphGeneralTab">
+          <attribute name="title">
+           <string>General</string>
+          </attribute>
+         </widget>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="characterStylesTab">
+      <attribute name="title">
+       <string>Character Styles</string>
+      </attribute>
+      <layout class="QHBoxLayout" name="horizontalLayout_5">
+       <item>
+        <layout class="QVBoxLayout" name="verticalLayout_2">
+         <item>
+          <widget class="QTreeView" name="characterStylesListView"/>
+         </item>
+         <item>
+          <layout class="QHBoxLayout" name="horizontalLayout_2">
+           <item>
+            <widget class="QPushButton" name="newCharacterStyleButton">
+             <property name="text">
+              <string>New</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QPushButton" name="saveCharacterStyleButton">
+             <property name="text">
+              <string>Save</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QPushButton" name="deleteCharacterStyleButton">
+             <property name="text">
+              <string>Delete</string>
+             </property>
+            </widget>
+           </item>
+          </layout>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <widget class="QTabWidget" name="characterOptionsTabs">
+         <widget class="StylesGeneralTab" name="characterGeneralTab">
+          <attribute name="title">
+           <string>General</string>
+          </attribute>
+         </widget>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+   <item>
+    <widget class="QWidget" name="stylePreview" native="true"/>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_4">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="applyToCursorButton">
+       <property name="text">
+        <string>Apply Style</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="exitWithoutApplyButton">
+       <property name="text">
+        <string>Exit without applying</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>StylesGeneralTab</class>
+   <extends>QWidget</extends>
+   <header>dialogs/StylesGeneralTab.h</header>
+   <container>1</container>
+  </customwidget>
+  <customwidget>
+   <class>KCategorizedView</class>
+   <extends>QWidget</extends>
+   <header>kcategorizedview.h</header>
+   <container>1</container>
+  </customwidget>
+</customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/plugins/textshape/dialogs/StylesManagerStylesListItemDelegate.cpp \
b/plugins/textshape/dialogs/StylesManagerStylesListItemDelegate.cpp new file mode \
100644 index 0000000..7702b9a
--- /dev/null
+++ b/plugins/textshape/dialogs/StylesManagerStylesListItemDelegate.cpp
@@ -0,0 +1,128 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "StylesManagerStylesListItemDelegate.h"
+
+#include "StylesManagerStylesListModel.h"
+
+#include <QApplication>
+#include <QPainter>
+#include <QStyleOptionViewItemV4>
+
+StylesManagerStylesListItemDelegate::StylesManagerStylesListItemDelegate(QObject \
*parent) : +    QStyledItemDelegate(parent)
+{
+}
+
+void StylesManagerStylesListItemDelegate::paint(QPainter *painter, const \
QStyleOptionViewItem &optionV1, const QModelIndex &index) const +{
+    QStyleOptionViewItemV4 option = optionV1;
+    initStyleOption(&option, index);
+
+    if (!index.data(StylesManagerStylesListModel::isTitleRole).toBool()) {
+        QStyledItemDelegate::paint(painter, option, index);
+    }
+    else {
+        const QString category = index.data().toString();
+        const QRect optRect = option.rect;
+        QFont font(QApplication::font());
+        font.setBold(true);
+        const QFontMetrics fontMetrics = QFontMetrics(font);
+        QColor outlineColor = option.palette.text().color();
+        outlineColor.setAlphaF(0.35);
+        //BEGIN: top left corner
+        {
+            painter->save();
+            painter->setPen(outlineColor);
+            const QPointF topLeft(optRect.topLeft());
+            QRectF arc(topLeft, QSizeF(4, 4));
+            arc.translate(0.5, 0.5);
+            painter->drawArc(arc, 1440, 1440);
+            painter->restore();
+        }
+        //END: top left corner
+        //BEGIN: left vertical line
+        {
+            QPoint start(optRect.topLeft());
+            start.ry() += 3;
+            QPoint verticalGradBottom(optRect.topLeft());
+            verticalGradBottom.ry() += fontMetrics.height() + 5;
+            QLinearGradient gradient(start, verticalGradBottom);
+            gradient.setColorAt(0, outlineColor);
+            gradient.setColorAt(1, Qt::transparent);
+            painter->fillRect(QRect(start, QSize(1, fontMetrics.height() + 5)), \
gradient); +        }
+        //END: left vertical line
+        //BEGIN: horizontal line
+        {
+            QPoint start(optRect.topLeft());
+            start.rx() += 3;
+            QPoint horizontalGradTop(optRect.topLeft());
+            horizontalGradTop.rx() += optRect.width() - 6;
+            painter->fillRect(QRect(start, QSize(optRect.width() - 6, 1)), \
outlineColor); +        }
+        //END: horizontal line
+        //BEGIN: top right corner
+        {
+            painter->save();
+            painter->setPen(outlineColor);
+            QPointF topRight(optRect.topRight());
+            topRight.rx() -= 4;
+            QRectF arc(topRight, QSizeF(4, 4));
+            arc.translate(0.5, 0.5);
+            painter->drawArc(arc, 0, 1440);
+            painter->restore();
+        }
+        //END: top right corner
+        //BEGIN: right vertical line
+        {
+            QPoint start(optRect.topRight());
+            start.ry() += 3;
+            QPoint verticalGradBottom(optRect.topRight());
+            verticalGradBottom.ry() += fontMetrics.height() + 5;
+            QLinearGradient gradient(start, verticalGradBottom);
+            gradient.setColorAt(0, outlineColor);
+            gradient.setColorAt(1, Qt::transparent);
+            painter->fillRect(QRect(start, QSize(1, fontMetrics.height() + 5)), \
gradient); +        }
+        //END: right vertical line
+        //BEGIN: text
+        {
+            QRect textRect(option.rect);
+            textRect.setTop(textRect.top() + 7);
+            textRect.setLeft(textRect.left() + 7);
+            textRect.setHeight(fontMetrics.height());
+            textRect.setRight(textRect.right() - 7);
+            painter->save();
+            painter->setFont(font);
+            QColor penColor(option.palette.text().color());
+            penColor.setAlphaF(0.6);
+            painter->setPen(penColor);
+            painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, category);
+            painter->restore();
+        }
+        //END: text
+    }
+}
+
+QSize StylesManagerStylesListItemDelegate::sizeHint(const QStyleOptionViewItem \
&option, const QModelIndex &index) const +{
+    Q_UNUSED(option);
+    return index.data(Qt::SizeHintRole).toSize();
+}
diff --git a/plugins/textshape/dialogs/StylesManagerStylesListItemDelegate.h \
b/plugins/textshape/dialogs/StylesManagerStylesListItemDelegate.h new file mode \
100644 index 0000000..e94f81f
--- /dev/null
+++ b/plugins/textshape/dialogs/StylesManagerStylesListItemDelegate.h
@@ -0,0 +1,52 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef STYLESMANAGERSTYLESLISTITEMDELEGATE_H
+#define STYLESMANAGERSTYLESLISTITEMDELEGATE_H
+
+#include <QStyledItemDelegate>
+
+class StylesManagerStylesListItemDelegate : public QStyledItemDelegate
+{
+    Q_OBJECT
+public:
+    explicit StylesManagerStylesListItemDelegate(QObject *parent = 0);
+
+    virtual void paint(QPainter *painter, const QStyleOptionViewItem &option,        \
const QModelIndex &index) const; +    virtual QSize sizeHint(const \
QStyleOptionViewItem &option, const QModelIndex &index) const; +
+//    virtual bool editorEvent(QEvent *event, QAbstractItemModel *model,             \
const QStyleOptionViewItem &option, const QModelIndex &index); +//    void \
setEditButtonEnable(bool enable); +
+signals:
+//    void styleManagerButtonClicked(QModelIndex index);
+//    void deleteStyleButtonClicked(QModelIndex index);
+//    void needsUpdate(QModelIndex index);
+//    void clickedInItem(QModelIndex index);
+
+private:
+//    bool m_editButtonPressed;
+//    bool m_deleteButtonPressed;
+//    bool m_enableEditButton;
+
+//    int m_buttonSize;
+//    int m_buttonDistance;
+};
+
+#endif // STYLESMANAGERSTYLESLISTITEMDELEGATE_H
diff --git a/plugins/textshape/dialogs/StylesManagerStylesListModel.cpp \
b/plugins/textshape/dialogs/StylesManagerStylesListModel.cpp new file mode 100644
index 0000000..ec58ab4
--- /dev/null
+++ b/plugins/textshape/dialogs/StylesManagerStylesListModel.cpp
@@ -0,0 +1,278 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "StylesManagerStylesListModel.h"
+
+#include "StylesModel.h"
+
+#include <KoCharacterStyle.h>
+#include <KoParagraphStyle.h>
+#include <KoStyleManager.h>
+#include <KoStyleThumbnailer.h>
+
+#include <KLocale>
+
+#include <QSize>
+#include <QSortFilterProxyModel>
+#include <QVariant>
+
+#include <KDebug>
+
+StylesManagerStylesListModel::StylesManagerStylesListModel(QObject *parent) :
+    StylesFilteredModelBase(parent)
+//    m_styleManager(0),
+//    m_thumbnailer(0),
+//    m_currentSelectedStyle(0)//,
+//    QSortFilterProxyModel(parent),
+//    KCategorizedSortFilterProxyModel(parent),
+//    m_sourceModel(0)
+{
+}
+
+Qt::ItemFlags StylesManagerStylesListModel::flags(const QModelIndex &index) const
+{
+    if (index.internalId() == ModifiedStyleId || index.internalId() == \
OriginalStyleId) { +        return (Qt::NoItemFlags);
+    }
+    return (Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+}
+
+QModelIndex StylesManagerStylesListModel::parent(const QModelIndex &child) const
+{
+    if (child.data(isTitleRole).toBool()) {
+        return QModelIndex();
+    }
+    else {
+        if (child.data(AbstractStylesModel::isModifiedStyle).toBool()) {
+            return createIndex(0, 0, ModifiedStyleId);
+        }
+        else {
+            return createIndex(1, 0, OriginalStyleId);
+        }
+    }
+    return QModelIndex();
+}
+
+int StylesManagerStylesListModel::rowCount(const QModelIndex &parent) const
+{
+    if (!parent.isValid()) {
+        return 2;
+    }
+    if (parent.internalId() == ModifiedStyleId) {
+        kDebug() << "row count modified: " << m_modifiedStylesCount;
+        return m_modifiedStylesCount;
+    }
+    if (parent.internalId() == OriginalStyleId) {
+        kDebug() << "row count original: " << m_originalStylesCount;
+        return m_originalStylesCount;
+    }
+    return 0;
+}
+
+QModelIndex StylesManagerStylesListModel::index(int row, int column, const \
QModelIndex &parent) const +{
+    if (row < 0 || column != 0)
+        return QModelIndex();
+
+    if (!parent.isValid()) {
+        if (row >= 2) {
+            return QModelIndex();
+        }
+        return createIndex(row, 0, (row == 0)?ModifiedStyleId:OriginalStyleId);
+    }
+    else {
+        if (parent.internalId() == ModifiedStyleId) {
+            if (row >= m_modifiedStylesCount) {
+                return QModelIndex();
+            }
+            return createIndex(row, 0, int(m_sourceModel->index(row, 0, \
QModelIndex()).internalId())); +        }
+        else {
+            if (row >= m_originalStylesCount) {
+                return QModelIndex();
+            }
+            return createIndex(row, 0, \
int(m_sourceModel->index(m_modifiedStylesCount + row, 0, \
QModelIndex()).internalId())); +        }
+    }
+    return QModelIndex();
+}
+
+QVariant StylesManagerStylesListModel::data(const QModelIndex &index, int role) \
const +{
+    if (!index.isValid()) {
+        return QVariant();
+    }
+
+    switch (role) {
+    case AbstractStylesModel::isTitleRole: {
+        if (index.internalId() == ModifiedStyleId || index.internalId() == \
OriginalStyleId) { +            return true;
+        }
+    }
+    case Qt::DisplayRole: {
+        if (index.internalId() == ModifiedStyleId) {
+            return i18n("Modified Styles");
+        }
+        if (index.internalId() == OriginalStyleId) {
+            return i18n("Original Styles");
+        }
+        return QVariant();
+    }
+    case Qt::DecorationRole: {
+        if (index.internalId() == ModifiedStyleId || index.internalId() == \
OriginalStyleId) { +            return QVariant();
+        }
+        if (index.parent().isValid() && index.parent().internalId() == \
ModifiedStyleId) { +            return \
m_sourceModel->data(m_sourceModel->index(index.row(), 0, QModelIndex()), role); +     \
} +        if (index.parent().isValid() && index.parent().internalId() == \
OriginalStyleId) { +            return \
m_sourceModel->data(m_sourceModel->index(index.row() + m_modifiedStylesCount, 0, \
QModelIndex()), role); +        }
+        return QVariant();
+    }
+    case Qt::SizeHintRole: {
+        return QVariant(QSize(250, 48));
+    }
+    default: break;
+//        if (index.parent().isValid()) {
+//        }
+//        kDebug() << "other role. style id: " << index.row();
+//        kDebug() << "other role. data: " << m_sourceModel->data(index, role);
+
+//        return KCategorizedSortFilterProxyModel::data(index, role);
+//        return QSortFilterProxyModel::data(index, role);
+    }
+
+    return QVariant();
+}
+/*
+void StylesManagerStylesListModel::setSourceModel(QAbstractItemModel *sourceModel)
+{
+    Q_ASSERT(sourceModel);
+    if (!sourceModel) {
+        return;
+    }
+/*
+    if (m_sourceModel) {
+        disconnect(m_sourceModel, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, \
int, int)), this, SLOT(rowsAboutToBeInserted(QModelIndex,int,int))); +        \
disconnect(m_sourceModel, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, \
const QModelIndex &, int)), this, SLOT(rowsAboutToBeMoved(QModelIndex, int, int, \
QModelIndex, int))); +        disconnect(m_sourceModel, \
SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), this, \
SLOT(rowsAboutToBeRemoved(QModelIndex, int, int, QModelIndex, int))); +        \
disconnect(m_sourceModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, \
SLOT(rowsInserted(QModelIndex,int,int))); +        disconnect(m_sourceModel, \
SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), this, \
SLOT(rowsMoved(QModelIndex, int, int, QModelIndex, int))); +        \
disconnect(m_sourceModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, \
SLOT(rowsRemoved(QModelIndex, int, int, QModelIndex, int))); +        \
disconnect(m_sourceModel, SIGNAL(modelAboutToBeReset()), this, \
SLOT(modelAboutToBeReset())); +        disconnect(m_sourceModel, \
SIGNAL(modelReset()), this, SLOT(modelReset())); +    }
+
+    m_sourceModel = sourceModel;
+    connect(m_sourceModel, \
SIGNAL(/*QAbstractItemModel::*//*rowsAboutToBeInserted(const QModelIndex &, int, \
int)), this, SLOT(rowsAboutToBeInserted(QModelIndex,int,int))); +    \
connect(m_sourceModel, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const \
QModelIndex &, int)), this, SLOT(rowsAboutToBeMoved(QModelIndex, int, int, \
QModelIndex, int))); +    connect(m_sourceModel, SIGNAL(rowsAboutToBeRemoved(const \
QModelIndex &, int, int)), this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int, \
QModelIndex, int))); +    connect(m_sourceModel, SIGNAL(rowsInserted(const \
QModelIndex &, int, int)), this, SLOT(rowsInserted(QModelIndex,int,int))); +    \
connect(m_sourceModel, SIGNAL(rowsMoved(const QModelIndex &, int, int, const \
QModelIndex &, int)), this, SLOT(rowsMoved(QModelIndex, int, int, QModelIndex, \
int))); +    connect(m_sourceModel, SIGNAL(rowsRemoved(const QModelIndex &, int, \
int)), this, SLOT(rowsRemoved(QModelIndex &, int, int, QModelIndex, int))); +    \
connect(m_sourceModel, SIGNAL(modelAboutToBeReset()), this, \
SLOT(modelAboutToBeReset())); +    connect(m_sourceModel, SIGNAL(modelReset()), this, \
SLOT(modelReset())); +
+    QSortFilterProxyModel::setSourceModel(sourceModel);
+    m_sourceModel = dynamic_cast<StylesModel*>(sourceModel);
+    Q_ASSERT(m_sourceModel);
+    if (!m_sourceModel) {
+        return;
+    }
+    beginResetModel();
+    createMapping();
+    endResetModel();
+}
+*/
+/*
+KoCharacterStyle* StylesManagerStylesListModel::currentSelectedStyle()
+{
+    return m_currentSelectedStyle;
+}
+*/
+/*
+void StylesManagerStylesListModel::slotModifiedStyle()
+{
+    if (!m_modifiedStyles.contains(m_currentSelectedStyle->styleId())) {
+        beginResetModel();
+        if (m_currentSelectedStyle->styleType() == KoCharacterStyle::ParagraphStyle) \
{ +            KoParagraphStyle *paragStyle = \
dynamic_cast<KoParagraphStyle*>(m_currentSelectedStyle); +            if (paragStyle) \
{ +                m_currentSelectedStyle = paragStyle->clone();
+                m_modifiedStyles.insert(m_currentSelectedStyle->styleId(), \
m_currentSelectedStyle); +            }
+        }
+        else {
+            m_currentSelectedStyle = m_currentSelectedStyle->clone();
+            m_modifiedStyles.insert(m_currentSelectedStyle->styleId(), \
m_currentSelectedStyle); +        }
+        createMapping();
+        endResetModel();
+    }
+}
+*/
+/*
+void StylesManagerStylesListModel::slotSetCurrentIndex(QModelIndex index)
+{
+    if (m_modifiedStyles.contains(index.internalId())) {
+        m_currentSelectedStyle = m_modifiedStyles.value(index.internalId());
+    }
+    else {
+        if (!(m_currentSelectedStyle = \
m_styleManager->paragraphStyle(index.internalId()))) { +            \
m_currentSelectedStyle = m_styleManager->characterStyle(index.internalId()); +        \
} +    }
+}
+*/
+void StylesManagerStylesListModel::createMapping()
+{
+    Q_ASSERT(m_sourceModel);
+    if (!m_sourceModel) {
+        return;
+    }
+
+    m_originalStylesCount = 0;
+    m_modifiedStylesCount = 0;
+
+    for (int i = 0; i < m_sourceModel->rowCount(QModelIndex()); ++i) {
+        QModelIndex index = m_sourceModel->index(i, 0, QModelIndex());
+        if (m_sourceModel->data(index, \
AbstractStylesModel::isModifiedStyle).toBool()) { +            \
m_modifiedStylesCount++; +        }
+        else {
+            m_originalStylesCount++;
+        }
+    }
+/*    m_sourceToProxy.clear();
+    m_proxyToSource.clear();
+
+    for (int i = 0; i < m_sourceModel->rowCount(QModelIndex()); ++i) {
+        QModelIndex index = m_sourceModel->index(i, 0, QModelIndex());
+        int id = (int)index.internalId();
+        if (!m_modifiedStyles.contains(id)) {
+            m_proxyToSource.append(i);
+        }
+    }
+    m_sourceToProxy.fill(-1, m_sourceModel->rowCount((QModelIndex())));
+    for (int i = 0; i < m_proxyToSource.count(); ++i) {
+        m_sourceToProxy[m_proxyToSource.at(i)] = i;
+    }
+*/
+}
diff --git a/plugins/textshape/dialogs/StylesManagerStylesListModel.h \
b/plugins/textshape/dialogs/StylesManagerStylesListModel.h new file mode 100644
index 0000000..fe69cf2
--- /dev/null
+++ b/plugins/textshape/dialogs/StylesManagerStylesListModel.h
@@ -0,0 +1,72 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef STYLESMANAGERSTYLESLISTMODEL_H
+#define STYLESMANAGERSTYLESLISTMODEL_H
+
+#include "StylesModel.h"
+
+#include "StylesFilteredModelBase.h"
+
+#include <QMap>
+#include <QVector>
+
+class StylesModel;
+class KoCharacterStyle;
+class KoParagraphStyle;
+class KoStyleManager;
+class KoStyleThumbnailer;
+
+class StylesManagerStylesListModel : public StylesFilteredModelBase
+{
+    Q_OBJECT
+public:
+
+    enum CategoriesInternalIds {
+        ModifiedStyleId = -1,
+        OriginalStyleId = -2
+    };
+
+    explicit StylesManagerStylesListModel(QObject *parent = 0);
+
+    virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+
+    virtual QModelIndex parent(const QModelIndex &child) const;
+
+    virtual QModelIndex index(int row, int column, const QModelIndex &parent) const;
+
+    virtual int rowCount(const QModelIndex &parent) const;
+
+    virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) \
const; +
+//    KoCharacterStyle* currentSelectedStyle();
+
+signals:
+
+public slots:
+//    void slotSetCurrentIndex(QModelIndex index);
+
+protected:
+    void createMapping();
+
+private:
+    int m_modifiedStylesCount, m_originalStylesCount;
+};
+
+#endif // STYLESMANAGERSTYLESLISTMODEL_H
diff --git a/plugins/textshape/dialogs/StylesManagerStylesModel.cpp \
b/plugins/textshape/dialogs/StylesManagerStylesModel.cpp new file mode 100644
index 0000000..e23d9fe
--- /dev/null
+++ b/plugins/textshape/dialogs/StylesManagerStylesModel.cpp
@@ -0,0 +1,170 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "StylesManagerStylesModel.h"
+
+#include "AbstractStylesModel.h"
+
+#include <KoCharacterStyle.h>
+#include <KoParagraphStyle.h>
+#include <KoStyleManager.h>
+#include <KoStyleThumbnailer.h>
+
+#include <KLocale>
+
+#include <QMap>
+#include <QSize>
+#include <QVariant>
+
+#include <KDebug>
+
+
+StylesManagerStylesModel::StylesManagerStylesModel(QObject *parent) :
+    StylesFilteredModelBase(parent),
+    m_styleManager(0),
+    m_currentSelectedStyle(0)
+{
+}
+
+int StylesManagerStylesModel::rowCount(const QModelIndex &parent) const
+{
+    return m_modifiedStyles.count() + m_proxyToSource.count();
+}
+
+QModelIndex StylesManagerStylesModel::index(int row, int column, const QModelIndex \
&parent) const +{
+    if (row < 0 || row >= (m_modifiedStyles.count() + m_proxyToSource.count()) || \
column != 0) { +        return QModelIndex();
+    }
+
+    if (!parent.isValid()) {
+        if (row < m_modifiedStyles.count()) {
+            return createIndex(row, 0, m_modifiedStyles.keys().at(row));
+        }
+        else {
+            return createIndex(row, 0, \
(int)(m_sourceModel->index(m_proxyToSource.at(row - m_modifiedStyles.count()), 0, \
parent).internalId())); +        }
+    }
+    return QModelIndex();
+}
+
+QVariant StylesManagerStylesModel::data(const QModelIndex &index, int role) const
+{
+    if (!index.isValid()) {
+        return QVariant();
+    }
+
+    switch (role) {
+    case AbstractStylesModel::isModifiedStyle: {
+        if (m_modifiedStyles.contains(index.internalId())) {
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
+    case Qt::DisplayRole: {
+        return QVariant();
+    }
+    case Qt::DecorationRole: {
+        if (m_modifiedStyles.contains(index.internalId())) {
+            if (m_modifiedStyles.value(index.internalId())->styleType() == \
KoCharacterStyle::ParagraphStyle) { +                return \
m_styleThumbnailer->thumbnail(dynamic_cast<KoParagraphStyle*>(m_modifiedStyles.value(index.internalId())), \
QSize(250, 48)); +            }
+        }
+        return m_sourceModel->data(m_sourceModel->index(m_proxyToSource.at(index.row() \
- m_modifiedStyles.count()), 0, QModelIndex()), role); +    }
+    case Qt::SizeHintRole: {
+        return QSize(250, 48);
+    }
+    default: break;
+    }
+    return QVariant();
+}
+
+void StylesManagerStylesModel::setStyleManager(KoStyleManager *sm)
+{
+    Q_ASSERT(sm);
+    if (!sm) {
+        return;
+    }
+
+    m_styleManager = sm;
+}
+
+KoCharacterStyle* StylesManagerStylesModel::currentSelectedStyle()
+{
+    return m_currentSelectedStyle;
+}
+
+void StylesManagerStylesModel::slotModifiedStyle()
+{
+    if (!m_modifiedStyles.contains(m_currentSelectedStyle->styleId())) {
+        beginResetModel();
+        if (m_currentSelectedStyle->styleType() == KoCharacterStyle::ParagraphStyle) \
{ +            KoParagraphStyle *paragStyle = \
dynamic_cast<KoParagraphStyle*>(m_currentSelectedStyle); +            if (paragStyle) \
{ +                m_currentSelectedStyle = paragStyle->clone();
+                m_modifiedStyles.insert(m_currentSelectedStyle->styleId(), \
m_currentSelectedStyle); +            }
+        }
+        else {
+            m_currentSelectedStyle = m_currentSelectedStyle->clone();
+            m_modifiedStyles.insert(m_currentSelectedStyle->styleId(), \
m_currentSelectedStyle); +        }
+        createMapping();
+        endResetModel();
+    }
+}
+
+void StylesManagerStylesModel::slotSetCurrentIndex(QModelIndex index)
+{
+    if (m_modifiedStyles.contains(index.internalId())) {
+        m_currentSelectedStyle = m_modifiedStyles.value(index.internalId());
+    }
+    else {
+        if (!(m_currentSelectedStyle = \
m_styleManager->paragraphStyle(index.internalId()))) { +            \
m_currentSelectedStyle = m_styleManager->characterStyle(index.internalId()); +        \
} +    }
+}
+
+void StylesManagerStylesModel::createMapping()
+{
+    Q_ASSERT(m_sourceModel);
+    Q_ASSERT(m_styleManager);
+    if (!m_sourceModel || !m_styleManager) {
+        return;
+    }
+
+    m_sourceToProxy.clear();
+    m_proxyToSource.clear();
+
+    for (int i = 0; i < m_sourceModel->rowCount(QModelIndex()); ++i) {
+        QModelIndex index = m_sourceModel->index(i, 0, QModelIndex());
+        int id = (int)index.internalId();
+        if (!m_modifiedStyles.contains(id)) {
+            m_proxyToSource.append(i);
+        }
+    }
+    m_sourceToProxy.fill(-1, m_sourceModel->rowCount((QModelIndex())));
+    for (int i = 0; i < m_proxyToSource.count(); ++i) {
+        m_sourceToProxy[m_proxyToSource.at(i)] = i;
+    }
+}
diff --git a/plugins/textshape/dialogs/StylesManagerStylesModel.h \
b/plugins/textshape/dialogs/StylesManagerStylesModel.h new file mode 100644
index 0000000..4417e12
--- /dev/null
+++ b/plugins/textshape/dialogs/StylesManagerStylesModel.h
@@ -0,0 +1,65 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef STYLESMANAGERSTYLESMODEL_H
+#define STYLESMANAGERSTYLESMODEL_H
+
+#include "StylesFilteredModelBase.h"
+
+class AbstractStylesModel;
+class KoCharacterStyle;
+class KoParagraphStyle;
+class KoStyleManager;
+class KoStyleThumbnailer;
+
+class StylesManagerStylesModel : public StylesFilteredModelBase
+{
+    Q_OBJECT
+public:
+    explicit StylesManagerStylesModel(QObject *parent = 0);
+
+    virtual QModelIndex index(int row, int column, const QModelIndex &parent) const;
+
+    virtual int rowCount(const QModelIndex &parent) const;
+
+    virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) \
const; +
+    void setStyleManager(KoStyleManager *sm);
+
+    KoCharacterStyle* currentSelectedStyle();
+
+signals:
+
+public slots:
+    void slotModifiedStyle();
+
+    void slotSetCurrentIndex(QModelIndex index);
+
+protected:
+    void createMapping();
+
+private:
+    KoStyleManager *m_styleManager;
+//    KoStyleThumbnailer *m_thumbnailer;
+
+    QMap<int, KoCharacterStyle*> m_modifiedStyles;
+    KoCharacterStyle *m_currentSelectedStyle;
+};
+
+#endif // STYLESMANAGERSTYLESMODEL_H
diff --git a/plugins/textshape/dialogs/StylesModel.cpp \
b/plugins/textshape/dialogs/StylesModel.cpp index 9c3141e..67a6bd7 100644
--- a/plugins/textshape/dialogs/StylesModel.cpp
+++ b/plugins/textshape/dialogs/StylesModel.cpp
@@ -143,6 +143,14 @@ QVariant StylesModel::data(const QModelIndex &index, int role) \
const  case Qt::SizeHintRole: {
         return QVariant(QSize(250, 48));
     }
+    case AbstractStylesModel::CharacterStylePointer: {
+        //TODO: make it safe
+        return QVariant::fromValue< QSharedPointer<KoCharacterStyle> \
>(QSharedPointer<KoCharacterStyle>(m_styleManager->characterStyle(index.internalId())));
> 
+    }
+    case AbstractStylesModel::ParagraphStylePointer: {
+        //TODO: make it safe
+        return QVariant::fromValue< QSharedPointer<KoParagraphStyle> \
>(QSharedPointer<KoParagraphStyle>(m_styleManager->paragraphStyle(index.internalId())));
> 
+    }
     default: break;
     };
     return QVariant();
@@ -176,7 +184,9 @@ void StylesModel::setProvideStyleNone(bool provide)
 
 QModelIndex StylesModel::indexForParagraphStyle(const KoParagraphStyle &style) const
 {
+    kDebug() << "index for parStyle";
     if (&style) {
+        kDebug() << "row of style: " << m_styleList.indexOf(style.styleId());
         QModelIndex index = createIndex(m_styleList.indexOf(style.styleId()), 0, \
style.styleId());  return index;
     }
@@ -197,13 +207,16 @@ QModelIndex StylesModel::indexForCharacterStyle(const \
KoCharacterStyle &style) c  
 QImage StylesModel::stylePreview(int row, QSize size)
 {
+    kDebug() << "stylePreview. model type: " << stylesType() << ". row: " << row;
     if (!m_styleManager || !m_styleThumbnailer) {
         return QImage();
     }
     if (m_modelType == StylesModel::ParagraphStyle) {
         KoParagraphStyle *usedStyle = 0;
         usedStyle = m_styleManager->paragraphStyle(index(row).internalId());
+        kDebug() << "used style: " << usedStyle;
         if (usedStyle) {
+            kDebug() << "stylename: " << usedStyle->name();
             return m_styleThumbnailer->thumbnail(usedStyle, size);
         }
         if (!usedStyle && m_draftParStyleList.contains(index(row).internalId())) {
diff --git a/plugins/textshape/dialogs/StylesModel.cpp \
b/plugins/textshape/dialogs/StylesModelV1.cpp similarity index 85%
copy from plugins/textshape/dialogs/StylesModel.cpp
copy to plugins/textshape/dialogs/StylesModelV1.cpp
index 9c3141e..218011e 100644
--- a/plugins/textshape/dialogs/StylesModel.cpp
+++ b/plugins/textshape/dialogs/StylesModelV1.cpp
@@ -1,7 +1,5 @@
 /* This file is part of the KDE project
- * Copyright (C) 2008 Thomas Zander <zander@kde.org>
- * Copyright (C) 2011 C. Boemann <cbo@boemann.dk>
- * Copyright (C) 2011-2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -18,7 +16,9 @@
  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301, USA.
  */
-#include "StylesModel.h"
+
+#include "StylesModelV1.h"
+
 
 #include <KoStyleThumbnailer.h>
 #include <KoStyleManager.h>
@@ -27,24 +27,24 @@
 
 #include <QImage>
 #include <QList>
-#include <QSharedPointer>
 #include <QSignalMapper>
 
 #include <KLocale>
 #include <KDebug>
 
-StylesModel::StylesModel(KoStyleManager *manager, AbstractStylesModel::Type \
                modelType, QObject *parent)
-    : AbstractStylesModel(parent),
+StylesModelV1::StylesModelV1(KoStyleManager *manager, Type modelType, QObject \
*parent) +    : QAbstractItemModel(parent),
       m_styleManager(0),
+      m_styleThumbnailer(0),
       m_currentParagraphStyle(0),
       m_defaultCharacterStyle(0),
+      m_modelType(modelType),
       m_styleMapper(new QSignalMapper(this)),
       m_provideStyleNone(false)
 {
-    m_modelType = modelType;
     setStyleManager(manager);
     //Create a default characterStyle for the preview of "None" character style
-    if (m_modelType == StylesModel::CharacterStyle) {
+    if (m_modelType == StylesModelV1::CharacterStyle) {
         m_defaultCharacterStyle = new KoCharacterStyle();
         m_defaultCharacterStyle->setStyleId(-1);
         m_defaultCharacterStyle->setName(i18n("None"));
@@ -56,17 +56,24 @@ StylesModel::StylesModel(KoStyleManager *manager, \
                AbstractStylesModel::Type mode
     connect(m_styleMapper, SIGNAL(mapped(int)), this, SLOT(updateName(int)));
 }
 
-StylesModel::~StylesModel()
+StylesModelV1::~StylesModelV1()
 {
     delete m_currentParagraphStyle;
     delete m_defaultCharacterStyle;
 }
 
-QModelIndex StylesModel::index(int row, int column, const QModelIndex &parent) const
+QModelIndex StylesModelV1::parent(const QModelIndex &child) const
+{
+    return QModelIndex();
+}
+
+QModelIndex StylesModelV1::index(int row, int column, const QModelIndex &parent) \
const  {
     if (row < 0 || column != 0)
         return QModelIndex();
 
+    kDebug() << "index for row: " << row << " column: " << column << "internalId: " \
<< m_styleList[row]; +
     if (! parent.isValid()) {
         if (row >= m_styleList.count())
             return QModelIndex();
@@ -75,24 +82,20 @@ QModelIndex StylesModel::index(int row, int column, const \
QModelIndex &parent) c  return QModelIndex();
 }
 
-QModelIndex StylesModel::parent(const QModelIndex &child) const
-{
-    return QModelIndex();
-}
 
-int StylesModel::rowCount(const QModelIndex &parent) const
+int StylesModelV1::rowCount(const QModelIndex &parent) const
 {
     if (!parent.isValid())
         return m_styleList.count();
     return 0;
 }
 
-int StylesModel::columnCount(const QModelIndex &parent) const
+int StylesModelV1::columnCount(const QModelIndex &parent) const
 {
     return 1;
 }
 
-QVariant StylesModel::data(const QModelIndex &index, int role) const
+QVariant StylesModelV1::data(const QModelIndex &index, int role) const
 {
     if (!index.isValid())
         return QVariant();
@@ -100,13 +103,19 @@ QVariant StylesModel::data(const QModelIndex &index, int role) \
const  int id = (int)index.internalId();
     switch (role){
     case Qt::DisplayRole: {
+        if (m_modelType == StylesModelV1::ParagraphStyle) {
+            KoParagraphStyle *paragStyle = m_styleManager->paragraphStyle(id);
+            if (paragStyle) {
+                return paragStyle->name();
+            }
+        }
         return QVariant();
     }
     case Qt::DecorationRole: {
         if (!m_styleThumbnailer) {
             return QPixmap();
         }
-        if (m_modelType == StylesModel::ParagraphStyle) {
+        if (m_modelType == StylesModelV1::ParagraphStyle) {
             KoParagraphStyle *paragStyle = m_styleManager->paragraphStyle(id);
             if (paragStyle) {
                 return m_styleThumbnailer->thumbnail(paragStyle);
@@ -148,14 +157,14 @@ QVariant StylesModel::data(const QModelIndex &index, int role) \
const  return QVariant();
 }
 
-Qt::ItemFlags StylesModel::flags(const QModelIndex &index) const
+Qt::ItemFlags StylesModelV1::flags(const QModelIndex &index) const
 {
     if (!index.isValid())
         return 0;
     return (Qt::ItemIsSelectable | Qt::ItemIsEnabled);
 }
 
-void StylesModel::setCurrentParagraphStyle(int styleId)
+void StylesModelV1::setCurrentParagraphStyle(int styleId)
 {
     if (!m_styleManager || m_currentParagraphStyle == \
m_styleManager->paragraphStyle(styleId) || !m_styleManager->paragraphStyle(styleId)) \
                {
         return; //TODO do we create a default paragraphStyle? use the styleManager \
default? @@ -167,14 +176,14 @@ void StylesModel::setCurrentParagraphStyle(int \
                styleId)
     m_currentParagraphStyle = m_styleManager->paragraphStyle(styleId)->clone();
 }
 
-void StylesModel::setProvideStyleNone(bool provide)
+void StylesModelV1::setProvideStyleNone(bool provide)
 {
-    if (m_modelType == StylesModel::CharacterStyle) {
+    if (m_modelType == StylesModelV1::CharacterStyle) {
         m_provideStyleNone = provide;
     }
 }
 
-QModelIndex StylesModel::indexForParagraphStyle(const KoParagraphStyle &style) const
+QModelIndex StylesModelV1::indexForParagraphStyle(const KoParagraphStyle &style) \
const  {
     if (&style) {
         QModelIndex index = createIndex(m_styleList.indexOf(style.styleId()), 0, \
style.styleId()); @@ -185,7 +194,7 @@ QModelIndex \
StylesModel::indexForParagraphStyle(const KoParagraphStyle &style) c  }
 }
 
-QModelIndex StylesModel::indexForCharacterStyle(const KoCharacterStyle &style) const
+QModelIndex StylesModelV1::indexForCharacterStyle(const KoCharacterStyle &style) \
const  {
     if (&style) {
         return createIndex(m_styleList.indexOf(style.styleId()), 0, \
style.styleId()); @@ -195,12 +204,12 @@ QModelIndex \
StylesModel::indexForCharacterStyle(const KoCharacterStyle &style) c  }
 }
 
-QImage StylesModel::stylePreview(int row, QSize size)
+QImage StylesModelV1::stylePreview(int row, QSize size)
 {
     if (!m_styleManager || !m_styleThumbnailer) {
         return QImage();
     }
-    if (m_modelType == StylesModel::ParagraphStyle) {
+    if (m_modelType == StylesModelV1::ParagraphStyle) {
         KoParagraphStyle *usedStyle = 0;
         usedStyle = m_styleManager->paragraphStyle(index(row).internalId());
         if (usedStyle) {
@@ -236,7 +245,7 @@ QImage StylesModel::stylePreview(int row, QSize size)
     return QImage();
 }
 
-void StylesModel::setStyleManager(KoStyleManager *sm)
+void StylesModelV1::setStyleManager(KoStyleManager *sm)
 {
     if (sm == m_styleManager)
         return;
@@ -251,7 +260,7 @@ void StylesModel::setStyleManager(KoStyleManager *sm)
         return;
     }
 
-    if (m_modelType == StylesModel::ParagraphStyle) {
+    if (m_modelType == StylesModelV1::ParagraphStyle) {
         updateParagraphStyles();
         connect(sm, SIGNAL(styleAdded(KoParagraphStyle*)), this, \
                SLOT(addParagraphStyle(KoParagraphStyle*)));
         connect(sm, SIGNAL(styleRemoved(KoParagraphStyle*)), this, \
SLOT(removeParagraphStyle(KoParagraphStyle*))); @@ -262,13 +271,13 @@ void \
StylesModel::setStyleManager(KoStyleManager *sm)  }
 }
 
-void StylesModel::setStyleThumbnailer(KoStyleThumbnailer *thumbnailer)
+void StylesModelV1::setStyleThumbnailer(KoStyleThumbnailer *thumbnailer)
 {
     m_styleThumbnailer = thumbnailer;
 }
 
 // called when the stylemanager adds a style
-void StylesModel::addParagraphStyle(KoParagraphStyle *style)
+void StylesModelV1::addParagraphStyle(KoParagraphStyle *style)
 {
     Q_ASSERT(style);
     QList<int>::iterator begin = m_styleList.begin();
@@ -291,14 +300,14 @@ void StylesModel::addParagraphStyle(KoParagraphStyle *style)
     endInsertRows();
 }
 
-bool sortParagraphStyleByName(KoParagraphStyle *style1, KoParagraphStyle *style2)
+bool sortParagraphStyleByNameV1(KoParagraphStyle *style1, KoParagraphStyle *style2)
 {
     Q_ASSERT(style1);
     Q_ASSERT(style2);
     return QString::localeAwareCompare(style1->name(), style2->name()) < 0;
 }
 
-void StylesModel::updateParagraphStyles()
+void StylesModelV1::updateParagraphStyles()
 {
     Q_ASSERT(m_styleManager);
 
@@ -306,7 +315,7 @@ void StylesModel::updateParagraphStyles()
     m_styleList.clear();
 
     QList<KoParagraphStyle *> styles = m_styleManager->paragraphStyles();
-    qSort(styles.begin(), styles.end(), sortParagraphStyleByName);
+    qSort(styles.begin(), styles.end(), sortParagraphStyleByNameV1);
 
     foreach(KoParagraphStyle *style, styles) {
         m_styleList.append(style->styleId());
@@ -318,7 +327,7 @@ void StylesModel::updateParagraphStyles()
 }
 
 // called when the stylemanager adds a style
-void StylesModel::addCharacterStyle(KoCharacterStyle *style)
+void StylesModelV1::addCharacterStyle(KoCharacterStyle *style)
 {
     Q_ASSERT(style);
     // find the place where we need to insert the style
@@ -348,14 +357,14 @@ void StylesModel::addCharacterStyle(KoCharacterStyle *style)
     connect(style, SIGNAL(nameChanged(const QString&)), m_styleMapper, SLOT(map()));
 }
 
-bool sortCharacterStyleByName(KoCharacterStyle *style1, KoCharacterStyle *style2)
+bool sortCharacterStyleByNameV1(KoCharacterStyle *style1, KoCharacterStyle *style2)
 {
     Q_ASSERT(style1);
     Q_ASSERT(style2);
     return QString::localeAwareCompare(style1->name(), style2->name()) < 0;
 }
 
-void StylesModel::updateCharacterStyles()
+void StylesModelV1::updateCharacterStyles()
 {
     Q_ASSERT(m_styleManager);
 
@@ -367,7 +376,7 @@ void StylesModel::updateCharacterStyles()
     }
 
     QList<KoCharacterStyle *> styles = m_styleManager->characterStyles();
-    qSort(styles.begin(), styles.end(), sortCharacterStyleByName);
+    qSort(styles.begin(), styles.end(), sortCharacterStyleByNameV1);
 
     foreach(KoCharacterStyle *style, styles) {
         if (style != m_styleManager->defaultCharacterStyle()) { //The default \
character style is not user selectable. It only provides individual property defaults \
and is not a style per say. @@ -381,7 +390,7 @@ void \
StylesModel::updateCharacterStyles()  }
 
 // called when the stylemanager removes a style
-void StylesModel::removeParagraphStyle(KoParagraphStyle *style)
+void StylesModelV1::removeParagraphStyle(KoParagraphStyle *style)
 {
     int row = m_styleList.indexOf(style->styleId());
     beginRemoveRows(QModelIndex(), row, row);
@@ -392,7 +401,7 @@ void StylesModel::removeParagraphStyle(KoParagraphStyle *style)
 }
 
 // called when the stylemanager removes a style
-void StylesModel::removeCharacterStyle(KoCharacterStyle *style)
+void StylesModelV1::removeCharacterStyle(KoCharacterStyle *style)
 {
     int row = m_styleList.indexOf(style->styleId());
     beginRemoveRows(QModelIndex(), row, row);
@@ -402,13 +411,13 @@ void StylesModel::removeCharacterStyle(KoCharacterStyle *style)
     endRemoveRows();
 }
 
-void StylesModel::updateName(int styleId)
+void StylesModelV1::updateName(int styleId)
 {
     // updating the name of a style can mean that the style needs to be moved inside \
the list to keep the sort order.  int oldIndex = m_styleList.indexOf(styleId);
     if (oldIndex >= 0) {
         int newIndex = 0;
-        if (m_modelType == StylesModel::ParagraphStyle) {
+        if (m_modelType == StylesModelV1::ParagraphStyle) {
             KoParagraphStyle *paragStyle = m_styleManager->paragraphStyle(styleId);
             if (!paragStyle && m_draftParStyleList.contains(styleId))
                 paragStyle = m_draftParStyleList.value(styleId);
@@ -481,7 +490,7 @@ void StylesModel::updateName(int styleId)
     }
 }
 
-QModelIndex StylesModel::firstStyleIndex()
+QModelIndex StylesModelV1::firstStyleIndex()
 {
     if (!m_styleList.count()) {
         return QModelIndex();
@@ -489,36 +498,36 @@ QModelIndex StylesModel::firstStyleIndex()
     return createIndex(m_styleList.indexOf(m_styleList.at(0)), 0, \
m_styleList.at(0));  }
 
-QList<int> StylesModel::StyleList()
+QList<int> StylesModelV1::StyleList()
 {
     return m_styleList;
 }
 
-QHash<int, KoParagraphStyle *> StylesModel::draftParStyleList()
+QHash<int, KoParagraphStyle *> StylesModelV1::draftParStyleList()
 {
     return m_draftParStyleList;
 }
 
-QHash<int, KoCharacterStyle *> StylesModel::draftCharStyleList()
+QHash<int, KoCharacterStyle *> StylesModelV1::draftCharStyleList()
 {
     return m_draftCharStyleList;
 }
 
-void StylesModel::addDraftParagraphStyle(KoParagraphStyle *style)
+void StylesModelV1::addDraftParagraphStyle(KoParagraphStyle *style)
 {
     style->setStyleId(-(m_draftParStyleList.count()+1));
     m_draftParStyleList.insert(style->styleId(), style);
     addParagraphStyle(style);
 }
 
-void StylesModel::addDraftCharacterStyle(KoCharacterStyle *style)
+void StylesModelV1::addDraftCharacterStyle(KoCharacterStyle *style)
 {
     style->setStyleId(-(m_draftCharStyleList.count()+2)); //we have a virtual \
characterStyle with style id -1, so we need to skip it  \
m_draftCharStyleList.insert(style->styleId(), style);  addCharacterStyle(style);
 }
 
-void StylesModel::clearDraftStyles()
+void StylesModelV1::clearDraftStyles()
 {
     foreach(KoParagraphStyle *style, m_draftParStyleList.values()) {
         removeParagraphStyle(style);
@@ -530,9 +539,9 @@ void StylesModel::clearDraftStyles()
     m_draftCharStyleList.clear();
 }
 
-void StylesModel::clearStyleModel()
+void StylesModelV1::clearStyleModel()
 {
-    if (m_modelType == StylesModel::ParagraphStyle) {
+    if (m_modelType == StylesModelV1::ParagraphStyle) {
         QList<int>::iterator begin = m_styleList.begin();
         for ( ; begin != m_styleList.end(); ++begin) {
             removeParagraphStyle(m_styleManager->paragraphStyle(*begin));
@@ -549,7 +558,7 @@ void StylesModel::clearStyleModel()
     }
 }
 
-StylesModel::Type StylesModel::stylesType()
+StylesModelV1::Type StylesModelV1::stylesType()
 {
     return m_modelType;
 }
diff --git a/plugins/textshape/dialogs/StylesModelV1.h \
b/plugins/textshape/dialogs/StylesModelV1.h new file mode 100644
index 0000000..150aecd
--- /dev/null
+++ b/plugins/textshape/dialogs/StylesModelV1.h
@@ -0,0 +1,175 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2012 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef STYLESMODELV1_H
+#define STYLESMODELV1_H
+
+#include <QAbstractItemModel>
+
+#include <QAbstractItemModel>
+
+#include <QSize>
+
+class KoStyleThumbnailer;
+
+class KoStyleManager;
+class KoParagraphStyle;
+class KoCharacterStyle;
+
+class QImage;
+class QSignalMapper;
+
+/** This class is used to provide widgets (like the @class StylesCombo) the styles \
available to the document being worked on. The @class StylesModel can be of two \
types: character styles or paragraph styles type. This allows the widget to ignore \
the type of style it is handling. +  * Character styles in ODF can be specified in \
two ways. First, a named character style, specifying character formatting properties. \
It is meant to be used on a couple of individual characters. Secondely, a paragraph \
style also specifies character formatting properties, which are to be considered the \
default for that particular paragraph. +  * For this reason, the @class Stylesmodel, \
when of the type @value characterStyle, do not list the paragraph style names. Only \
the specific named chracter styles are listed. Additionally, as the first item, a \
virtual style "As paragraph" is provided. Selecting this "style" will set the \
character properties as specified by the paragraph style currently applied to the \
selection. +  * This class requires that a @class KoStyleManager and a @class \
KoStyleThumbnailer be set. See below methods. +  *
+  * The StylesModel re-implement the AbstractStylesModel interface. Several \
components assume the following properties: +  * - the StylesModel is a flat list of \
items (this also means that "parent" QModelIndexes are always invalid) +  * - the \
StylesModel has only one column +  * - there is no header in the model
+  * - only the following methods are used when updating the underlying model's data: \
resetModel, insertRows, moveRows, removeRows +*/
+
+class StylesModelV1 : public QAbstractItemModel
+{
+    Q_OBJECT
+
+public:
+    enum Type {
+        CharacterStyle,
+        ParagraphStyle
+    };
+
+    explicit StylesModelV1(KoStyleManager *styleManager, Type modelType, QObject \
*parent = 0); +    ~StylesModelV1();
+
+    /** Re-implemented from QAbstractItemModel. */
+
+    virtual QModelIndex parent(const QModelIndex &child) const;
+
+    virtual QModelIndex index(int row, int column=0, const QModelIndex &parent = \
QModelIndex()) const; +
+    virtual int rowCount(const QModelIndex &parent) const;
+
+    virtual int columnCount(const QModelIndex &parent) const;
+
+    virtual QVariant data(const QModelIndex &index, int role) const;
+
+    virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+
+    /** *********************************** */
+    /** Specific methods of the StylesModel */
+
+    /** ************************* */
+    /** Initialising of the model */
+
+    /** Specify if the combo should provide the virtual style None. This style is a \
virtual style which equates to no style. It is only relevant for character styles. +  \
In case the "None" character style is selected, the character formatting properties \
of the paragraph style are used. +        A @class StylesModel of the @enum Type \
ParagraphStyle always has this property set to false. +        On the other hand, the \
default for a @class StylesModel of the @enum Type CharacterStyle is true. +
+        It is important to set this before setting the stylemanager on the model. \
The flag is used when populating the styles from the KoStyleManager. +    */
+    void setProvideStyleNone(bool provide);
+
+    /** Sets the @class KoStyleManager of the model. Setting this will populate the \
styles. It is required that a @param manager is set before using the model. +      * \
CAUTION: Populating the style will select the first inserted item. If this model is \
already set on a view, this might cause the view to emit an item selection changed \
signal. +    */
+    void setStyleManager(KoStyleManager *manager);
+
+    /** Sets the @class KoStyleThumbnailer of the model. It is required that a \
@param thumbnailer is set before using the model. */ +    void \
setStyleThumbnailer(KoStyleThumbnailer *thumbnailer); +
+
+    /** *************** */
+    /** Using the model */
+
+    /** Return a @class QModelIndex for the specified @param style. */
+    QModelIndex indexForParagraphStyle(const KoParagraphStyle &style) const;
+
+    /** Return a @class QModelIndex for the specified @param style. */
+    QModelIndex indexForCharacterStyle(const KoCharacterStyle &style) const;
+
+    /** Returns a QImage which is a preview of the style specified by @param row of \
the given @param size. +      * If size isn't specified, the default size of the \
given @class KoStyleThumbnailer is used. +    */
+    QImage stylePreview(int row, QSize size = QSize());
+
+    /** Specifies which paragraph style is currently the active one (on the current \
paragraph). This is used in order to properly preview the "As paragraph" virtual \
character style. */ +    void setCurrentParagraphStyle(int styleId);
+
+    /** Return the first index at list. */
+    QModelIndex firstStyleIndex();
+
+    /** Return style id list. */
+    QList<int> StyleList();
+
+    /** Return new styles and their ids. */
+    QHash<int, KoParagraphStyle *> draftParStyleList();
+    QHash<int, KoCharacterStyle *> draftCharStyleList();
+
+    /** Add a paragraph style to pargraph style list but this style is not applied. \
*/ +    void addDraftParagraphStyle(KoParagraphStyle *style);
+
+    /** Add a character style to character style list but this style is not applied. \
*/ +    void addDraftCharacterStyle(KoCharacterStyle *style);
+
+    /** we call this when we apply our unapplied styles and we clear our list. */
+    void clearDraftStyles();
+
+    /** We call this when we want a clear style model. */
+    void clearStyleModel();
+
+    /** Returns the type of styles in the model */
+    StylesModelV1::Type stylesType();
+
+private slots:
+    void removeParagraphStyle(KoParagraphStyle*);
+    void removeCharacterStyle(KoCharacterStyle*);
+    void updateName(int styleId);
+
+public slots:
+    void addParagraphStyle(KoParagraphStyle*);
+    void addCharacterStyle(KoCharacterStyle*);
+
+
+private:
+    void updateParagraphStyles();
+    void updateCharacterStyles();
+
+protected:
+    QList<int> m_styleList; // list of style IDs
+    QHash<int, KoParagraphStyle *> m_draftParStyleList; // list of new styles that \
are not applied +    QHash<int, KoCharacterStyle *> m_draftCharStyleList;
+
+private:
+    KoStyleManager *m_styleManager;
+    KoStyleThumbnailer *m_styleThumbnailer;
+
+    KoParagraphStyle *m_currentParagraphStyle;
+    KoCharacterStyle *m_defaultCharacterStyle;
+    Type m_modelType;
+
+    QSignalMapper *m_styleMapper;
+
+    bool m_provideStyleNone;
+};
+
+#endif // STYLESMODELV1_H


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic