• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

sublime

document.cpp

00001 /***************************************************************************
00002  *   Copyright 2006-2007 Alexander Dymo  <adymo@kdevelop.org>       *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU Library General Public License as       *
00006  *   published by the Free Software Foundation; either version 2 of the    *
00007  *   License, or (at your option) any later version.                       *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Library General Public     *
00015  *   License along with this program; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
00018  ***************************************************************************/
00019 #include "document.h"
00020 
00021 #include <kdebug.h>
00022 
00023 #include "view.h"
00024 #include "controller.h"
00025 
00026 namespace Sublime {
00027 
00028 // struct DocumentPrivate
00029 
00030 struct DocumentPrivate {
00031     DocumentPrivate(Document *doc): m_document(doc) {}
00032 
00033     void removeView(QObject *obj)
00034     {
00035         views.removeAll(reinterpret_cast<Sublime::View*>(obj));
00036         emit m_document->viewNumberChanged(m_document);
00037         //no need to keep empty document - we need to remove it
00038         if (views.count() == 0)
00039         {
00040             emit m_document->aboutToDelete(m_document);
00041             m_document->deleteLater();
00042         }
00043     }
00044 
00045     Controller *controller;
00046     QList<View*> views;
00047 
00048     Document *m_document;
00049 };
00050 
00051 
00052 
00053 //class Document
00054 
00055 Document::Document(const QString &title, Controller *controller)
00056     :QObject(controller), d( new DocumentPrivate(this) )
00057 {
00058     setObjectName(title);
00059     d->controller = controller;
00060     d->controller->addDocument(this);
00061     connect(this, SIGNAL(destroyed(QObject*)), d->controller, SLOT(removeDocument(QObject*)));
00062 }
00063 
00064 Document::~Document()
00065 {
00066     delete d;
00067 }
00068 
00069 Controller *Document::controller() const
00070 {
00071     return d->controller;
00072 }
00073 
00074 View *Document::createView()
00075 {
00076     View *view = newView(this);
00077     connect(view, SIGNAL(destroyed(QObject*)), this, SLOT(removeView(QObject*)));
00078     d->views.append(view);
00079     return view;
00080 }
00081 
00082 const QList<View*> &Document::views() const
00083 {
00084     return d->views;
00085 }
00086 
00087 QString Document::title() const
00088 {
00089     return objectName();
00090 }
00091 
00092 void Document::setTitle(const QString& newTitle)
00093 {
00094     setObjectName(newTitle);
00095     emit titleChanged(this);
00096 }
00097 
00098 View *Document::newView(Document *doc)
00099 {
00100     emit viewNumberChanged(this);
00101     return new View(doc);
00102 }
00103 
00104 }
00105 
00106 #include "document.moc"

sublime

Skip menu "sublime"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   codegen
  •   duchain
  •   editor
  • outputview
  •     interfaces
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal