X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Ffontlist.cpp;fp=src%2Fbase%2Ffontlist.cpp;h=0000000000000000000000000000000000000000;hb=9f6ad3fe0b9cb30115a5d38e8af3aebed0d70c08;hp=2c1b7423c4d46f24c3eeb748e021af5e4750602e;hpb=43c13b052d069ba435277d93867380d00c04931f;p=architektonas diff --git a/src/base/fontlist.cpp b/src/base/fontlist.cpp deleted file mode 100644 index 2c1b742..0000000 --- a/src/base/fontlist.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// fontlist.cpp -// -// Part of the Architektonas Project -// Originally part of QCad Community Edition by Andrew Mustun -// Extensively rewritten and refactored by James L. Hammons -// Portions copyright (C) 2001-2003 RibbonSoft -// Copyright (C) 2010 Underground Software -// See the README and GPLv2 files for licensing and warranty information -// -// JLH = James L. Hammons -// -// Who When What -// --- ---------- ----------------------------------------------------------- -// JLH 05/27/2010 Added this text. :-) -// - -#include "fontlist.h" - -#include "font.h" -#include "entity.h" -#include "system.h" - -//[DONE] #warning "!!! NEED TO FIX ITERATORS IN THIS CLASS !!!" - -FontList * FontList::uniqueInstance = NULL; - -/** - * Default constructor. - */ -FontList::FontList(): fontIterator(fonts) -{ -//Dealt with here... -//#warning "!!! Need to deal with setAutoDelete() Qt3->Qt4 !!!" -// fonts.setAutoDelete(true); - //fontListListeners.setAutoDelete(false); -} - -/*static*/ FontList * FontList::instance() -{ - if (uniqueInstance == NULL) - uniqueInstance = new FontList(); - - return uniqueInstance; -} - -FontList::~FontList() -{ - clearFonts(); -} - -/** - * Initializes the font list by creating empty Font - * objects, one for each font that could be found. - */ -void FontList::init() -{ - DEBUG->print("FontList::initFonts"); - - QStringList list = SYSTEM->getFontList(); -// Q3Dict added; //used to remeber added fonts (avoid duplication) - QMultiHash added; //used to remeber added fonts (avoid duplication) - - for(QStringList::Iterator it=list.begin(); it!=list.end(); ++it) - { - DEBUG->print("font: %s:", (*it).toLatin1().data()); -//printf("FontList::init(): font: %s:\n", (*it).toLatin1().data()); - - QFileInfo fi(*it); - -// if (!added[fi.baseName()]) - if (added.value(fi.baseName()) == 0) - { - Font * font = new Font(fi.baseName()); - fonts.append(font); - added.insert(fi.baseName(), (char *)1); - } - - DEBUG->print("base: %s", fi.baseName().toLatin1().data()); - } -} - -/** - * Removes all fonts in the fontlist. - */ -void FontList::clearFonts() -{ -// fonts.clear(); - while (!fonts.isEmpty()) - delete fonts.takeFirst(); -} - -int FontList::countFonts() -{ - return fonts.count(); -} - -/** - * Removes a font from the list. - * Listeners are notified after the font was removed from - * the list but before it gets deleted. - */ -void FontList::removeFont(Font * font) -{ - DEBUG->print("FontList::removeFont()"); - - // here the font is removed from the list but not deleted -// fonts.remove(font); - // Here we have to delete this ourselves, because there is no AutoDelete - // for QLists - int i = fonts.indexOf(font); - - if (i != -1) - delete fonts.takeAt(i); - - //for (uint i=0; ifontRemoved(font); - //} -} - -/** - * @return Pointer to the font with the given name or - * \p NULL if no such font was found. The font will be loaded into - * memory if it's not already. - */ -Font * FontList::requestFont(const QString & name) -{ - DEBUG->print("FontList::requestFont %s", name.toLatin1().data()); - - QString name2 = name.toLower(); - Font * foundFont = NULL; - - // QCad 1 compatibility: - if (name2.contains('#') && name2.contains('_')) -// name2 = name2.left(name2.find('_')); - name2 = name2.left(name2.indexOf('_')); - else if (name2.contains('#')) -// name2 = name2.left(name2.find('#')); - name2 = name2.left(name2.indexOf('#')); - - DEBUG->print("name2: %s", name2.toLatin1().data()); - - // Search our list of available fonts: -// for(Font * f=fonts.first(); f!=NULL; f=fonts.next()) - for(int i=0; igetFileName() == name2) - { - // Make sure this font is loaded into memory: - f->loadFont(); - foundFont = f; - break; - } - } - - if (foundFont == NULL && name != "standard") - foundFont = requestFont("standard"); - - return foundFont; -} - -//! @return First font of the list. -Font * FontList::firstFont() -{ -// return fonts.first(); -// fontIterator.toFront(); -// return fontIterator.next(); - - fontIterator = fonts; - return (fontIterator.hasNext() ? fontIterator.next() : NULL); -} - -/** - * @return Next font from the list after - * calling firstFont() or nextFont(). - */ -Font * FontList::nextFont() -{ -// return fonts.next(); -// return fontIterator.next(); - return (fontIterator.hasNext() ? fontIterator.next() : NULL); -} - -/** - * Dumps the fonts to stdout. - */ -std::ostream & operator<<(std::ostream & os, FontList & l) -{ - os << "Fontlist: \n"; - - for(Font * f=l.firstFont(); f!=NULL; f=l.nextFont()) - os << *f << "\n"; - - return os; -}