/* Klat - A LaTeX editor for KDE Copyright (C) 2002-2004 Jori Liesenborgs (jori@lumumba.luc.ac.be) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "klateditwidgetmanager.h" #include #include KlatEditWidgetManager *KlatEditWidgetManager::inst = 0; KlatEditWidgetManager *KlatEditWidgetManager::instance() { if (inst != 0) return inst; inst = new KlatEditWidgetManager(); return inst; } KlatEditWidgetManager::KlatEditWidgetManager() { lib = 0; } KlatEditWidgetManager::~KlatEditWidgetManager() { // this should never be called... } Kate::Document *KlatEditWidgetManager::createDocument() { Kate::Document *d; if (lib == 0) lib = KLibLoader::self()->library("libkatepart"); d = (Kate::Document *)lib->factory()->create(0L,"kate","KTextEditor::Document"); docs.push_front(d); return d; } void KlatEditWidgetManager::destroyDocument(Kate::Document *d) { std::list::iterator it; bool found; found = false; it = docs.begin(); while (!found && it != docs.end()) { if ((*it) == d) found = true; else ++it; } if (!found) return; docs.erase(it); delete d; if (docs.empty()) { lib->unload(); lib = 0; } }