Changeset View
Changeset View
Standalone View
Standalone View
libs/pageapp/KoPADocumentModel.cpp
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
53 | 53 | | |||
54 | KoPADocumentModel::KoPADocumentModel( QObject* parent, KoPADocument *document ) | 54 | KoPADocumentModel::KoPADocumentModel( QObject* parent, KoPADocument *document ) | ||
55 | : KoDocumentSectionModel( parent ) | 55 | : KoDocumentSectionModel( parent ) | ||
56 | , m_document(0) | 56 | , m_document(0) | ||
57 | , m_master(false) | 57 | , m_master(false) | ||
58 | , m_lastContainer( 0 ) | 58 | , m_lastContainer( 0 ) | ||
59 | { | 59 | { | ||
60 | setDocument( document ); | 60 | setDocument( document ); | ||
61 | setSupportedDragActions( Qt::MoveAction ); | 61 | } | ||
62 | | ||||
63 | Qt::DropActions KoPADocumentModel::supportedDragActions() const | ||||
64 | { | ||||
65 | return Qt::MoveAction; | ||||
62 | } | 66 | } | ||
63 | 67 | | |||
64 | void KoPADocumentModel::update() | 68 | void KoPADocumentModel::update() | ||
65 | { | 69 | { | ||
66 | emit layoutAboutToBeChanged(); | 70 | emit layoutAboutToBeChanged(); | ||
67 | emit layoutChanged(); | 71 | emit layoutChanged(); | ||
68 | if (m_document) { | 72 | if (m_document) { | ||
69 | dataChanged(index(0, 0), index(m_document->pageCount() - 1, columnCount() - 1)); | 73 | dataChanged(index(0, 0), index(m_document->pageCount() - 1, columnCount() - 1)); | ||
▲ Show 20 Lines • Show All 569 Lines • ▼ Show 20 Line(s) | 610 | { | |||
639 | return createIndex( indexFromChild( grandParentShape, parentShape ), 0, parentShape ); | 643 | return createIndex( indexFromChild( grandParentShape, parentShape ), 0, parentShape ); | ||
640 | } | 644 | } | ||
641 | 645 | | |||
642 | void KoPADocumentModel::setDocument( KoPADocument* document ) | 646 | void KoPADocumentModel::setDocument( KoPADocument* document ) | ||
643 | { | 647 | { | ||
644 | if (m_document == document) { | 648 | if (m_document == document) { | ||
645 | return; | 649 | return; | ||
646 | } | 650 | } | ||
651 | | ||||
647 | if (m_document) { | 652 | if (m_document) { | ||
648 | disconnect( m_document, SIGNAL(pageAdded(KoPAPageBase*)), this, SLOT(update()) ); | 653 | disconnect( m_document, SIGNAL(pageAdded(KoPAPageBase*)), this, SLOT(update()) ); | ||
649 | disconnect( m_document, SIGNAL(pageRemoved(KoPAPageBase*)), this, SLOT(update()) ); | 654 | disconnect( m_document, SIGNAL(pageRemoved(KoPAPageBase*)), this, SLOT(update()) ); | ||
650 | disconnect( m_document, SIGNAL(update(KoPAPageBase*)), this, SLOT(update()) ); | 655 | disconnect( m_document, SIGNAL(update(KoPAPageBase*)), this, SLOT(update()) ); | ||
651 | disconnect( m_document, SIGNAL(shapeAdded(KoShape*)), this, SLOT(update()) ); | 656 | disconnect( m_document, SIGNAL(shapeAdded(KoShape*)), this, SLOT(update()) ); | ||
652 | disconnect( m_document, SIGNAL(shapeRemoved(KoShape*)), this, SLOT(update()) ); | 657 | disconnect( m_document, SIGNAL(shapeRemoved(KoShape*)), this, SLOT(update()) ); | ||
653 | } | 658 | } | ||
659 | | ||||
660 | beginResetModel(); | ||||
654 | m_document = document; | 661 | m_document = document; | ||
662 | endResetModel(); | ||||
655 | 663 | | |||
656 | if ( m_document ) { | 664 | if ( m_document ) { | ||
657 | connect( m_document, SIGNAL(pageAdded(KoPAPageBase*)), this, SLOT(update()) ); | 665 | connect( m_document, SIGNAL(pageAdded(KoPAPageBase*)), this, SLOT(update()) ); | ||
658 | connect( m_document, SIGNAL(pageRemoved(KoPAPageBase*)), this, SLOT(update()) ); | 666 | connect( m_document, SIGNAL(pageRemoved(KoPAPageBase*)), this, SLOT(update()) ); | ||
659 | connect( m_document, SIGNAL(update(KoPAPageBase*)), this, SLOT(update()) ); | 667 | connect( m_document, SIGNAL(update(KoPAPageBase*)), this, SLOT(update()) ); | ||
660 | connect( m_document, SIGNAL(shapeAdded(KoShape*)), this, SLOT(update()) ); | 668 | connect( m_document, SIGNAL(shapeAdded(KoShape*)), this, SLOT(update()) ); | ||
661 | connect( m_document, SIGNAL(shapeRemoved(KoShape*)), this, SLOT(update()) ); | 669 | connect( m_document, SIGNAL(shapeRemoved(KoShape*)), this, SLOT(update()) ); | ||
662 | } | 670 | } | ||
663 | | ||||
664 | reset(); | | |||
665 | } | 671 | } | ||
666 | 672 | | |||
667 | void KoPADocumentModel::setMasterMode(bool master) | 673 | void KoPADocumentModel::setMasterMode(bool master) | ||
668 | { | 674 | { | ||
669 | m_master = master; | 675 | m_master = master; | ||
670 | update(); // Rebuild the model | 676 | update(); // Rebuild the model | ||
671 | } | 677 | } | ||
672 | 678 | | |||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |