F:/KPlato/koffice/libs/kotext/styles/Styles_p.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002  * Copyright (C) 2006 Thomas Zander <zander@kde.org>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; version 2.
00007  *
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Library General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Library General Public License
00014  * along with this library; see the file COPYING.LIB.  If not, write to
00015  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016  * Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #include "Styles_p.h"
00020 
00021 #include <QTextFormat>
00022 
00023 StylePrivate::StylePrivate() {
00024 }
00025 
00026 StylePrivate::~StylePrivate() {
00027 }
00028 
00029 
00030 void StylePrivate::add(int key, const QVariant &value) {
00031     for(int i=m_properties.count()-1; i >= 0; i--) {
00032         if(m_properties[i].key == key) {
00033             m_properties[i].value = value;
00034             return;
00035         }
00036     }
00037     Property prop(key, value);
00038     m_properties.append(prop);
00039 }
00040 
00041 void StylePrivate::remove(int key) {
00042     for(int i=m_properties.count()-1; i >= 0; i--) {
00043         if(m_properties[i].key == key) {
00044             m_properties.remove(i);
00045             return;
00046         }
00047     }
00048 }
00049 
00050 const QVariant *StylePrivate::get(int key) const {
00051     for(int i=m_properties.count()-1; i >= 0; i--) {
00052         if(m_properties[i].key == key) {
00053             return &m_properties[i].value;
00054         }
00055     }
00056     return 0;
00057 }
00058 
00059 bool StylePrivate::contains(int key) const {
00060     for(int i=m_properties.count()-1; i >= 0; i--) {
00061         if(m_properties[i].key == key) {
00062             return true;
00063         }
00064     }
00065     return false;
00066 }
00067 
00068 void StylePrivate::copyMissing(const StylePrivate *other) {
00069     for(int i=other->m_properties.count()-1; i >= 0; i--) {
00070         bool found = false;
00071         for(int x=m_properties.count()-1; x >= 0; x--) {
00072             if(other->m_properties[i].key == m_properties[x].key) {
00073                 found = true;
00074                 break;
00075             }
00076         }
00077         if(!found) // we don't have that key. Copy it.
00078             m_properties.append( other->m_properties[i] );
00079     }
00080 }
00081 
00082 void StylePrivate::removeDuplicates(const StylePrivate *other) {
00083     for(int i=other->m_properties.count()-1; i >= 0; i--) {
00084         for(int x=m_properties.count()-1; x >= 0; x--) {
00085             if(other->m_properties[i] == m_properties[x]) {
00086                 m_properties.remove(x);
00087                 break;
00088             }
00089         }
00090     }
00091 }

Généré le Wed Nov 22 23:41:11 2006 pour KPlato par  doxygen 1.5.1-p1