Commit deda1943 authored by Inge Wallin's avatar Inge Wallin

Merge the branch words-sections-deniskup

This commit merges the branch words-sections-deniskup. It was
originally merged to master, but without --squash, which this commit
contains.  This branch only contains fixes to handling of text
sections and no other things, in particular nothing to do with the
text outliner which will be merged to master during the merge window.

I have looked through all the changes line by line and I *think* that
I have checked everything.  I could find no new strings but I may have
missed something.  There are a number of new translations of old ones
because the branch has gotten master merged into it at some points.
Because of the freeze there should be no other new features but also
that could have slipped through my checks. If so, I hope that I can be
forgiven for missing it.

Conflicts:
	krita/integration/thumbnail/kritaanimation_kranim_thumbnail.desktop
	krita/plugins/extensions/dockers/animator/krita_animator.desktop
	krita/plugins/formats/kranimseq/kranimseq_export.desktop
parent 414f36ab
......@@ -4,11 +4,16 @@ X-KDE-ServiceType=Krita/FileFilter
Comment=Krita FileFilter
Comment[ca]=Filtre de fitxers per al Krita
Comment[cs]=Krita FileFilter
Comment[da]=Krita filfilter
Comment[de]=Krita-Dateifilter
Comment[en_GB]=Krita FileFilter
Comment[it]=Filtro file per Krita
Comment[nl]=Bestandsfilter voor Krita
Comment[pl]=Filtr plików Krita
Comment[pt]=Filtro de Ficheiros do Krita
Comment[pt_BR]=Filtro de arquivos do Krita
Comment[sk]=Filter súborov Krita
Comment[sv]=Krita filfilter
Comment[uk]=Фільтр файлів для Krita
Comment[x-test]=xxKrita FileFilterxx
......
......@@ -3,6 +3,7 @@ Icon=template_web_design
Name=Web Design [ 2160x1440 , 72ppi RGB , 8bit ]
Name[ca]=Disseny Web [ 2160x1440 / 72ppi RGB / 8bit ]
Name[cs]=Návrh webu [ 2160x1440 , 72ppi RGB , 8bit ]
Name[da]=Webdesign [ 2160x1440 , 72ppi RGB , 8bit ]
Name[de]=Web-Design [ 2160x1440 , 72ppi RGB , 8bit ]
Name[en_GB]=Web Design [ 2160x1440 , 72ppi RGB , 8bit ]
Name[es]=Diseño de web 4:3 [ 2160x1440 , 72ppi RGB , 8bit ]
......
......@@ -3,6 +3,7 @@ Icon=template_texture
Name=Texture 1024x1024 8bit srgb
Name[ca]=Textura 1024x1024 8bit SRGB
Name[cs]=Textura 1024x1024 8bit srgb
Name[da]=Tekstur 1024x1024 8bit srgb
Name[de]=Textur 1024x1024 8bit srgb
Name[en_GB]=Texture 1024x1024 8bit srgb
Name[es]=Textura 1024x1024 8bits srgb
......
......@@ -3,6 +3,7 @@ Icon=template_texture
Name=Texture 2048x2048 8bit srgb
Name[ca]=Textura 2048x2048 8bit SRGB
Name[cs]=Textura 2048x2048 8bit srgb
Name[da]=Tekstur 2048x2048 8bit srgb
Name[de]=Textur 2048x2048 8bit srgb
Name[en_GB]=Texture 2048x2048 8bit srgb
Name[es]=Textura 2048x2048 8bits srgb
......
......@@ -3,6 +3,7 @@ Icon=template_texture
Name=Texture 256x256 8bit srgb
Name[ca]=Textura 256x256 8bit SRGB
Name[cs]=Textura 256x256 8bit srgb
Name[da]=Tekstur 256x256 8bit srgb
Name[de]=Textur 256x256 8bit srgb
Name[en_GB]=Texture 256x256 8bit srgb
Name[es]=Textura 256x256 8bits srgb
......
......@@ -3,6 +3,7 @@ Icon=template_texture
Name=Texture 4096x4096 8bit srgb
Name[ca]=Textura 4096x4096 8bit SRGB
Name[cs]=Textura 4096x4096 8bit srgb
Name[da]=Tekstur 4096x4096 8bit srgb
Name[de]=Textur 4096x4096 8bit srgb
Name[en_GB]=Texture 4096x4096 8bit srgb
Name[es]=Textura 4096x4096 8bits srgb
......
......@@ -3,6 +3,7 @@ Icon=template_texture
Name=Texture 512x512 8bit srgb
Name[ca]=Textura 512x512 8bit SRGB
Name[cs]=Textura 512x512 8bit srgb
Name[da]=Tekstur 512x512 8bit srgb
Name[de]=Textur 512x512 8bit srgb
Name[en_GB]=Texture 512x512 8bit srgb
Name[es]=Textura 512x512 8bits srgb
......
......@@ -23,7 +23,7 @@ GenericName[lt]=Skaitmeninis piešimas
GenericName[mr]=डिजिटल पेंटिंग
GenericName[nb]=Digital maling
GenericName[nl]=Digitaal schilderen
GenericName[pl]=Cyfrowe malowanie
GenericName[pl]=Cyfrowe malowanie
GenericName[pt]=Pintura Digital
GenericName[pt_BR]=Pintura digital
GenericName[ru]=Цифровая живопись
......
[Desktop Entry]
Type=Service
Name=Krita Animation Documents
Name[ca]=Documents d'animació del Krita
Name[cs]=Dokumenty animace Krita
Name[da]=Krita Animation-dokumenter
Name[de]=Krita-Animationsdokumente
Name[en_GB]=Krita Animation Documents
Name[es]=Documentos de Krita animación
Name[fi]=Krita-animaatiotiedostot
Name[ia]=Documentos de animation de Krita
Name[it]=Documenti di animazione di Krita
Name[ja]=Krita Animation 文書
Name[nb]=Krita animasjonsdokumenter
Name[nl]=Animatiedocumenten van Krita
Name[pl]=Dokumenty animacji Krita
Name[pt]=Documentos do Krita Animação
Name[pt_BR]=Documentos de animação do Krita
Name[sk]=Dokumenty animácií Krita
Name[sv]=Krita-animeringsdokument
Name[uk]=Документи анімації Krita
Name[x-test]=xxKrita Animation Documentsxx
X-KDE-ServiceTypes=ThumbCreator
MimeType=application/x-krita-animation;
X-KDE-Library=kritathumbnail
CacheThumbnail=true
......@@ -44,6 +44,7 @@
<p xml:lang="en-GB">It is perfect for sketching and painting, and presents an end–to–end solution for creating digital painting files from scratch by masters.</p>
<p xml:lang="es">Es perfecto para diseñar y pintar, y ofrece una solución completa para crear desde cero archivos de pintura digital apta para profesionales.</p>
<p xml:lang="fi">Se on täydellinen luonnosteluun ja maalaukseen ja tarjoaa kokonaisratkaisun digitaalisten kuvatiedostojen luomiseen alusta alkaen.</p>
<p xml:lang="ia">Illo es perfecte pro schizzar e pinger, e presenta un solution ab fin al fin pro crear files de pictura digital ab grattamentos per maestros.</p>
<p xml:lang="it">Perfetto per fare schizzi e dipingere, prevede una soluzione completa che consente agli artisti di creare file di dipinti digitali partendo da zero.</p>
<p xml:lang="nl">Het is perfect voor schetsen en schilderen en zet een end–to–end oplossing voor het maken van digitale bestanden voor schilderingen vanuit het niets door meesters.</p>
<p xml:lang="pl">Nadaje się perfekcyjnie do szkicowania i malowania i dostarcza zupełnego rozwiązania dla tworzenia plików malowideł cyfrowych od zalążka.</p>
......
......@@ -84,7 +84,7 @@ GenericName[lt]=Skaitmeninis piešimas
GenericName[mr]=डिजिटल पेंटिंग
GenericName[nb]=Digital maling
GenericName[nl]=Digitaal schilderen
GenericName[pl]=Cyfrowe malowanie
GenericName[pl]=Cyfrowe malowanie
GenericName[pt]=Pintura Digital
GenericName[pt_BR]=Pintura digital
GenericName[ru]=Цифровая живопись
......@@ -117,7 +117,7 @@ Comment[lt]=Skaitmeninis piešimas
Comment[mr]=डिजिटल पेंटिंग
Comment[nb]=Digital maling
Comment[nl]=Digitaal schilderen
Comment[pl]=Cyfrowe malowanie
Comment[pl]=Cyfrowe malowanie
Comment[pt]=Pintura Digital
Comment[pt_BR]=Pintura digital
Comment[ru]=Цифровая живопись
......
[Desktop Entry]
Name=Animator
Name[ca]=Animador
Name[cs]=Nástroj pro animace
Name[da]=Animator
Name[de]=Animator
Name[en_GB]=Animator
Name[es]=Animador
Name[it]=Animatore
Name[ja]=アニメータ
Name[nb]=Animator
Name[nl]=Animator
Name[pl]=Animator
Name[pt]=Animador
Name[pt_BR]=Animador
Name[sk]=Animátor
Name[sv]=Animeringsverktyg
Name[uk]=Animator
Name[x-test]=xxAnimatorxx
Comment=Animator
Comment[ca]=Animador
Comment[cs]=Nástroj pro animace
Comment[da]=Animator
Comment[de]=Animator
Comment[en_GB]=Animator
Comment[es]=Animador
Comment[it]=Animatore
Comment[ja]=アニメータ
Comment[nb]=Animator
Comment[nl]=Animator
Comment[pl]=Animator
Comment[pt]=Animador
Comment[pt_BR]=Animador
Comment[sk]=Animátor
Comment[sv]=Animeringsverktyg
Comment[uk]=Аніматор
Comment[x-test]=xxAnimatorxx
X-KDE-ServiceTypes=Krita/Dock
Type=Service
X-KDE-Library=kritaanimator
X-Krita-Version=28
[Desktop Entry]
Name=ColorSlider
Name[ca]=ControlLliscantColor
Name[da]=ColorSlider
Name[de]=Farbschieber
Name[en_GB]=ColourSlider
Name[es]=Selector de color
......@@ -8,7 +9,7 @@ Name[it]=Cursore del colore
Name[ja]=カラースライダー
Name[nb]=ColorSlider
Name[nl]=KleurSchuifknop
Name[pl]=Suwa koloru
Name[pl]=Suwak koloru
Name[pt]=Barras de Cores
Name[pt_BR]=Seletor de Cores
Name[sk]=Posuvník farieb
......
[Desktop Entry]
Name=Layer Splitter
Name[ca]=Separador de capes
Name[da]=Lagopdeler
Name[en_GB]=Layer Splitter
Name[it]=Divisore di livelli
Name[nl]=Splitser van lagen
Name[pl]=Podzielnik warstwy
Name[pt]=Divisor de Camadas
Name[pt_BR]=Divisor de camadas
Name[sk]=Rozdeľovač vrstiev
Name[sv]=Lagerdelning
Name[uk]=Роздільник шарів
Name[x-test]=xxLayer Splitterxx
X-KDE-ServiceTypes=Krita/ViewPlugin
......
......@@ -2,6 +2,7 @@
Name=Resource Manager
Name[ca]=Gestor de recursos
Name[cs]=Správce zdrojů
Name[da]=Håndtering af ressourcer
Name[de]=Ressourcenverwaltung
Name[en_GB]=Resource Manager
Name[es]=Gestor de recursos
......
[Desktop Entry]
Name=Index Colors Filter
Name[ca]=Filtre de colors indexats
Name[da]=Indeksfarvefilter
Name[de]=Farbfilter-Index
Name[en_GB]=Index Colours Filter
Name[es]=Filtros de colores indexados
......@@ -18,6 +19,7 @@ Name[uk]=Фільтр індексованих кольорів
Name[x-test]=xxIndex Colors Filterxx
Comment=Reduce the amount of colors in the picture to a pre-defined palette.
Comment[ca]=Redueix la quantitat de colors en la imatge a una paleta predefinida.
Comment[da]=Reducér mængden af farver i billedet til en prædefineret palette.
Comment[de]=Reduziert die Anzahl der Farben im Bild auf eine vordefinierte Palette.
Comment[en_GB]=Reduce the amount of colours in the picture to a pre-defined palette.
Comment[es]=Reduce la cantidad de colores que hay en una imagen a una paleta predefinida.
......
[Desktop Entry]
Name=Posterize Filter
Name[ca]=Filtre de posterització
Name[da]=Posteriseringsfilter
Name[de]=Posterisation-Filter
Name[en_GB]=Posterise Filter
Name[es]=Filtro posterizar
......@@ -19,6 +20,7 @@ Name[uk]=Фільтр постеризації
Name[x-test]=xxPosterize Filterxx
Comment=Reduce the amount of colors in the picture to a fixed interval
Comment[ca]=Redueix la quantitat de colors en la imatge a un interval fix
Comment[da]=Reducér mængden af farver i billedet til et fast interval
Comment[de]=Reduziert die Anzahl der Farben im Bild auf ein festgelegtes Intervall (Tontrennung)
Comment[en_GB]=Reduce the amount of colours in the picture to a fixed interval
Comment[es]=Reduce la cantidad de colores que hay en una imagen a un intervalo fijo
......
......@@ -3,6 +3,7 @@ Icon=
Name=Krita HeightMap Export Filter
Name[ca]=Filtre d'exportació HeightMap per al Krita
Name[cs]=Exportní filtr výškové mapy pro Krita
Name[da]=HeightMap-eksportfilter til Krita
Name[de]=Krita Höhenkarten-Exportfilter
Name[en_GB]=Krita HeightMap Export Filter
Name[es]=Filtro de Krita de exportación a HeightMap
......
......@@ -3,6 +3,7 @@ Icon=
Name=Krita HeightMap Import Filter
Name[ca]=Filtre d'importació HeightMap per al Krita
Name[cs]=Importní filtr výškové mapy pro Kritu
Name[da]=HeightMap-importfilter til Krita
Name[de]=Krita-Höhenkarten-Importfilter
Name[en_GB]=Krita HeightMap Import Filter
Name[es]=Filtro de Krita de importación de HeightMap
......
[Desktop Entry]
Name=Krita PNG Sequence Export Filter
Name[ca]=Filtre d'exportació de seqüències PNG per al Krita
Name[cs]=Exportní filtr sekvence PNG pro Kritu
Name[da]=PNG-sekvens-eksportfilter til Krita
Name[en_GB]=Krita PNG Sequence Export Filter
Name[es]=Filtro de Krita de exportación a secuencia PNG
Name[fi]=Kritan PNG Sequence -vientisuodatin
Name[it]=Filtro di esportazione sequenza PNG per Krita
Name[ja]=Krita PNG シーケンスエクスポートフィルタ
Name[nb]=PNG sekvens-eksportfilter for Krita
Name[nl]=PNG volgorde exportfilter voor Krita
Name[pl]=Filtr eksportu szeregu PNG z Krita
Name[pt]=Filtro de Exportação de Sequências em PNG para o Krita
Name[pt_BR]=Filtro de exportação sequências em PNG para Krita
Name[sk]=Exportný filter Krita PNG sekvencia
Name[sv]=Krita PNG-sekvensexportfilter
Name[uk]=Фільтр експорту послідовності зображень PNG для Krita
Name[x-test]=xxKrita PNG Sequence Export Filterxx
X-KDE-Export=application/x-kranim-sequence
X-KDE-ServiceTypes=Krita/FileFilter
Type=Service
X-KDE-Import=application/x-krita
X-KDE-Weight=1
X-KDE-Library=kranimseq
NoDisplay=true
......@@ -2,6 +2,7 @@
Name=Krita TGA Export Filter
Name[ca]=Filtre d'exportació TGA per al Krita
Name[cs]=Exportní filtr do formátu TGS pro Kritu
Name[da]=TGA-eksportfilter til Krita
Name[de]=Krita-TGA-Exportfilter
Name[en_GB]=Krita TGA Export Filter
Name[es]=Filtro de Krita de exportación a TGA
......
......@@ -2,6 +2,7 @@
Name=Krita TGA Import Filter
Name[ca]=Filtre d'importació TGA per al Krita
Name[cs]=Importní filtr formátu TGA pro Kritu
Name[da]=TGA-importfilter til Krita
Name[de]=Krita-TGA-Importfilter
Name[en_GB]=Krita TGA Import Filter
Name[es]=Filtro de Krita de importación de TGA
......
[Desktop Entry]
Name=Grid Brush
Name[ca]=Pinzell de graella
Name[da]=Gitterpensel
Name[de]=Gitter-Pinsel
Name[en_GB]=Grid Brush
Name[es]=Pincel de rejilla
......
......@@ -336,7 +336,7 @@ namespace GSL
{
QMessageBox::warning(0,
i18nc("@title:window", "Krita"),
i18n("Sorry, Krita was build without the support "
i18n("Sorry, Krita was built without the support "
"of GNU Scientific Library, so you cannot scale "
"the selection with handles. Please compile "
"Krita with GNU Scientific Library support, or use "
......
......@@ -50,7 +50,7 @@ GenericName[lt]=Skaitmeninis piešimas
GenericName[mr]=डिजिटल पेंटिंग
GenericName[nb]=Digital maling
GenericName[nl]=Digitaal schilderen
GenericName[pl]=Cyfrowe malowanie
GenericName[pl]=Cyfrowe malowanie
GenericName[pt]=Pintura Digital
GenericName[pt_BR]=Pintura digital
GenericName[ru]=Цифровая живопись
......
......@@ -16,9 +16,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
......
......@@ -3,6 +3,7 @@ Type=ServiceType
X-KDE-ServiceType=CalligraPageApp/Tool
Comment=Tool for Calligra Page Applications
Comment[ca]=Eina per les aplicacions de pàgina del Calligra
Comment[da]=Værktøj til Calligra Page-programmer
Comment[de]=Werkzeug für Calligra-Seitenanwendungen
Comment[en_GB]=Tool for Calligra Page Applications
Comment[es]=Herramienta para las aplicaciones de páginas de Calligra
......
......@@ -22,7 +22,7 @@ Comment[kk]=KoReport нысан плагині
Comment[nb]=Programtillegg for KoReport-element
Comment[nds]=Moduul för KoReport-Element
Comment[nl]=Plug-in voor KoReport-item
Comment[pl]=Wtyczka elementu KoReport
Comment[pl]=Wtyczka dostarczająca elementy raportu
Comment[pt]='Plugin' de Itens do KoReport
Comment[pt_BR]=Plugin de itens do KoReport
Comment[ru]=Модуль KoReport
......
......@@ -40,7 +40,6 @@ public:
explicit KoSectionPrivate(const QTextDocument *_document)
: manager(KoTextDocument(_document).sectionManager())
, sectionStyle(0)
, modelItem(0)
{
Q_ASSERT(manager);
name = manager->possibleNewName();
......@@ -62,7 +61,6 @@ public:
QScopedPointer<KoSectionEnd> sectionEnd; //< pointer to the corresponding section end
int level; //< level of the section in document, root sections have 0 level
QPair<int, int> bounds; //< start and end position of section in QDocument
QStandardItem *modelItem;
};
KoSection::KoSection(const QTextCursor &cursor)
......@@ -107,8 +105,8 @@ bool KoSection::setName(const QString &name)
}
if (d->manager->isValidNewName(name)) {
d->manager->sectionRenamed(d->name, name);
d->name = name;
d->manager->invalidate();
return true;
}
return false;
......@@ -190,15 +188,3 @@ void KoSection::setLevel(int level)
Q_D(KoSection);
d->level = level;
}
QStandardItem *KoSection::modelItem()
{
Q_D(KoSection);
return d->modelItem;
}
void KoSection::setModelItem(QStandardItem *item)
{
Q_D(KoSection);
d->modelItem = item;
}
......@@ -22,10 +22,11 @@
#include "kotext_export.h"
#include <QMetaType>
#include <QList>
#include <QString>
#include <QPair>
#include <QScopedPointer>
#include <QStandardItem>
#include <QTextCursor>
class KoXmlElement;
......@@ -83,11 +84,12 @@ private:
void setBeginPos(int pos);
void setEndPos(int pos);
void setLevel(int level);
void setModelItem(QStandardItem *item);
QStandardItem *modelItem();
friend class KoSectionManager;
friend class KoSectionEnd;
};
Q_DECLARE_METATYPE(KoSection *)
Q_DECLARE_METATYPE(QList<KoSection *>)
#endif // KOSECTION_H
......@@ -53,7 +53,7 @@ QString KoSectionEnd::name() const
return d->section->name();
}
KoSection* KoSectionEnd::correspondingSection() const
KoSection *KoSectionEnd::correspondingSection() const
{
Q_D(const KoSectionEnd);
return d->section;
......
......@@ -22,6 +22,8 @@
#include "kotext_export.h"
#include <QMetaType>
#include <QList>
#include <QString>
#include <QScopedPointer>
......@@ -51,4 +53,7 @@ private:
Q_DECLARE_PRIVATE(KoSectionEnd)
};
Q_DECLARE_METATYPE(KoSectionEnd *)
Q_DECLARE_METATYPE(QList<KoSectionEnd *>)
#endif // KOSECTIONEND_H
......@@ -23,6 +23,7 @@
#include "KoSectionEnd.h"
#include <KLocalizedString>
#include <KoTextDocument.h>
#include "KoSectionUtils.h"
#include <QHash>
#include <QString>
......@@ -31,27 +32,56 @@
#include <kdebug.h>
KoSectionManagerPrivate::KoSectionManagerPrivate(QTextDocument *_doc)
: doc(_doc)
, valid(false)
, sectionCount(0)
, model(new QStandardItemModel())
class KoSectionManagerPrivate
{
Q_ASSERT(_doc);
}
public:
KoSectionManagerPrivate(KoSectionManager *parent, QTextDocument *_doc)
: doc(_doc)
, valid(false)
, q_ptr(parent)
{
Q_ASSERT(_doc);
}
KoSectionManagerPrivate::~KoSectionManagerPrivate()
{
QHash<QString, KoSection *>::iterator it = sectionNames.begin();
for (; it != sectionNames.end(); it++) {
delete it.value(); // KoSectionEnd will be deleted in KoSection
~KoSectionManagerPrivate()
{
QSet<KoSection *>::iterator it = registeredSections.begin();
for (; it != registeredSections.end(); it++) {
delete *it; // KoSectionEnd will be deleted in KoSection
}
}
}
QTextDocument *doc;
bool valid; //< is current section info is valid
QSet<KoSection *> registeredSections; //< stores pointer to sections that sometime was registered
// used to prevent using sectionNames without update
QHash<QString, KoSection *> &sectionNames()
{
Q_Q(KoSectionManager);
q->update();
return m_sectionNames;
}
protected:
KoSectionManager *q_ptr;
private:
Q_DISABLE_COPY(KoSectionManagerPrivate)
Q_DECLARE_PUBLIC(KoSectionManager);
QHash<QString, KoSection *> m_sectionNames; //< stores name -> pointer reference, for sections that are visible in document now
};
KoSectionManager::KoSectionManager(QTextDocument* doc)
: d_ptr(new KoSectionManagerPrivate(doc))
: d_ptr(new KoSectionManagerPrivate(this, doc))
{
KoTextDocument(doc).setSectionManager(this); //FIXME: setting it back from here looks bad
}
KoSectionManager::~KoSectionManager()
{
KoTextDocument(doc).setSectionManager(this);
delete d_ptr;
}
KoSection *KoSectionManager::sectionAtPosition(int pos)
......@@ -61,8 +91,8 @@ KoSection *KoSectionManager::sectionAtPosition(int pos)
KoSection *result = 0;
int smallest = INT_MAX; //smallest in size section will be the deepest
QHash<QString, KoSection *>::iterator it = d->sectionNames.begin();
for (; it != d->sectionNames.end(); it++) {
QHash<QString, KoSection *>::iterator it = d->sectionNames().begin();
for (; it != d->sectionNames().end(); it++) {
if (it.value()->bounds().first > pos || it.value()->bounds().second < pos) {
continue;
}
......@@ -82,21 +112,20 @@ void KoSectionManager::invalidate()
d->valid = false;
}
bool KoSectionManager::isValidNewName(const QString &name) const
bool KoSectionManager::isValidNewName(const QString &name)
{
Q_D(const KoSectionManager);
return (d->sectionNames.find(name) == d->sectionNames.end());
Q_D(KoSectionManager);
return (d->sectionNames().constFind(name) == d->sectionNames().constEnd());
}
QString KoSectionManager::possibleNewName() const
QString KoSectionManager::possibleNewName()
{
Q_D(const KoSectionManager);
Q_D(KoSectionManager);
QString newName;
int i = d->sectionCount;
int i = d->registeredSections.count();
do {
++i;
i++;
newName = i18nc("new numbered section name", "New section %1", i);
} while (!isValidNewName(newName));
......@@ -106,73 +135,57 @@ QString KoSectionManager::possibleNewName() const
void KoSectionManager::registerSection(KoSection* section)
{
Q_D(KoSectionManager);
d->sectionCount++;
d->sectionNames[section->name()] = section;
d->registeredSections.insert(section);
invalidate();
}
void KoSectionManager::sectionRenamed(const QString &oldName, const QString &name)
{
Q_D(KoSectionManager);
QHash<QString, KoSection *>::iterator it = d->sectionNames.find(oldName);
KoSection *sec = *it;
d->sectionNames.erase(it);
d->sectionNames[name] = sec;
if (sec->modelItem()) {
sec->modelItem()->setData(name, Qt::DisplayRole);
}
}
void KoSectionManager::unregisterSection(KoSection* section)
{
Q_D(KoSectionManager);
d->sectionCount--;
d->sectionNames.remove(section->name());
d->registeredSections.remove(section);
invalidate();
}
void KoSectionManager::update()
QStandardItemModel *KoSectionManager::update(bool needModel)
{
Q_D(KoSectionManager);
if (d->valid) {
return;
if (d->valid && !needModel) {
return 0;
}
d->valid = true;
d->sectionNames().clear();
QHash<QString, KoSection *>::iterator it = d->sectionNames.begin();
for (; it != d->sectionNames.end(); it++) {
it.value()->setBeginPos(-1);
it.value()->setEndPos(-1);
it.value()->setLevel(-1);
QSet<KoSection *>::iterator it = d->registeredSections.begin();
for (; it != d->registeredSections.end(); it++) {
(*it)->setBeginPos(-1);
(*it)->setEndPos(-1);
(*it)->setLevel(-1);
}
QTextBlock block = d->doc->begin();
QStringList head;
head << i18n("Section");
d->model->clear();
d->model->setHorizontalHeaderLabels(head);
d->model->setColumnCount(1);
QStandardItemModel *model = 0;
QStack<QStandardItem *> curChain;
curChain.push(d->model->invisibleRootItem());
if (needModel) {
model = new QStandardItemModel();
curChain.push(model->invisibleRootItem());
}
int curLevel = -1;
do {
QTextBlockFormat fmt = block.blockFormat();
if (fmt.hasProperty(KoParagraphStyle::SectionStartings)) {
QList<QVariant> starts = fmt.property(KoParagraphStyle::SectionStartings).value< QList<QVariant> >();
foreach (const QVariant &sv, starts) {
curLevel++;
KoSection *sec = static_cast<KoSection *>(sv.value<void *>());
sec->setBeginPos(block.position());
sec->setLevel(curLevel);
foreach (KoSection *sec, KoSectionUtils::sectionStartings(fmt)) {
curLevel++;
sec->setBeginPos(block.position());
sec->setLevel(curLevel);
d->sectionNames()[sec->name()] = sec;
if (needModel) {
QStandardItem *item = new QStandardItem(sec->name());
item->setData(qVariantFromValue(static_cast<void *>(sec)), Qt::UserRole + 1);
sec->setModelItem(item);
item->setData(QVariant::fromValue<KoSection *>(sec), Qt::UserRole + 1);
curChain.top()->appendRow(item);
......@@ -180,24 +193,15 @@ void KoSectionManager::update()
}
}
if (fmt.hasProperty(KoParagraphStyle::SectionEndings)) {
QList<QVariant> ends = fmt.property(KoParagraphStyle::SectionEndings).value< QList<QVariant> >();
foreach (const QVariant &sv, ends) {
curLevel--;
KoSectionEnd *sec = static_cast<KoSectionEnd *>(sv.value<void *>());
sec->correspondingSection()->setEndPos(block.position() + block.length());
foreach (const KoSectionEnd *sec, KoSectionUtils::sectionEndings(fmt)) {
curLevel--;
sec->correspondingSection()->setEndPos(block.position() + block.length());
if (needModel) {
curChain.pop();
}
}
} while ((block = block.next()).isValid());
d->valid = true;
}
QStandardItemModel* KoSectionManager::sectionsModel()
{
Q_D(KoSectionManager);
update();
return d->model.data();