File indexing completed on 2024-05-12 16:41:07

0001 /********************************************************************************************
0002     Copyright (C) 2008 by Mathias Soeken (msoeken@informatik.uni-bremen.de)
0003               (C) 2005-2006 by Holger Danielsson (holger.danielsson@t-online.de)
0004  ********************************************************************************************/
0005 
0006 /***************************************************************************
0007  *                                                                         *
0008  *   This program is free software; you can redistribute it and/or modify  *
0009  *   it under the terms of the GNU General Public License as published by  *
0010  *   the Free Software Foundation; either version 2 of the License, or     *
0011  *   (at your option) any later version.                                   *
0012  *                                                                         *
0013  ***************************************************************************/
0014 
0015 #include "tabularproperties.h"
0016 
0017 namespace KileDialog {
0018 
0019 TabularProperties::TabularProperties()
0020     : m_UseMultiColumn(false), m_ColorIndex(0),
0021       m_TopBorder(false), m_LeftBorder(false) {}
0022 
0023 void TabularProperties::setUseMultiColumn(bool useMultiColumn)
0024 {
0025     m_UseMultiColumn = useMultiColumn;
0026 }
0027 
0028 bool TabularProperties::useMultiColumn() const
0029 {
0030     return m_UseMultiColumn;
0031 }
0032 
0033 void TabularProperties::addRowColor(int row, const QColor &color)
0034 {
0035     if(!color.isValid()) {
0036         return;
0037     }
0038 
0039     m_RowColors.insert(row, color);
0040 }
0041 
0042 void TabularProperties::addColor(const QColor &color)
0043 {
0044     if(!color.isValid()) {
0045         return;
0046     }
0047 
0048     if(!m_ColorNames.contains(color.name())) {
0049         int index = m_ColorIndex;
0050         QString newColorName = "tc";
0051 
0052         do {
0053             int value = index % 26;
0054             newColorName += ('A' + value);
0055             index -= value;
0056         } while(index > 0);
0057 
0058         if(m_ColorNames.count() == 0) {
0059             m_RequiredPackages << "color" << "colortbl";
0060         }
0061 
0062         m_ColorNames.insert(color.name(), newColorName);
0063         ++m_ColorIndex;
0064     }
0065 }
0066 
0067 QColor TabularProperties::rowColor(int row) const
0068 {
0069     if(m_RowColors.contains(row)) {
0070         return m_RowColors[row];
0071     }
0072     else {
0073         return QColor();
0074     }
0075 }
0076 
0077 QString TabularProperties::colorName(const QColor &color) const
0078 {
0079     if(color.isValid() && m_ColorNames.contains(color.name())) {
0080         return m_ColorNames[color.name()];
0081     }
0082     else {
0083         return QString();
0084     }
0085 }
0086 
0087 const QHash<QString, QString>& TabularProperties::colorNames() const
0088 {
0089     return m_ColorNames;
0090 }
0091 
0092 const QStringList& TabularProperties::requiredPackages() const
0093 {
0094     return m_RequiredPackages;
0095 }
0096 
0097 void TabularProperties::setBullet(const QString &bullet)
0098 {
0099     m_Bullet = bullet;
0100 }
0101 
0102 QString TabularProperties::bullet() const
0103 {
0104     return m_Bullet;
0105 }
0106 
0107 void TabularProperties::addBorderUnderRow(int row)
0108 {
0109     m_BorderUnderRow.append(row);
0110 }
0111 
0112 bool TabularProperties::hasBorderUnderRow(int row) const
0113 {
0114     return m_BorderUnderRow.contains(row);
0115 }
0116 
0117 void TabularProperties::setHasTopBorder()
0118 {
0119     m_TopBorder = true;
0120 }
0121 
0122 bool TabularProperties::hasTopBorder() const
0123 {
0124     return m_TopBorder;
0125 }
0126 
0127 void TabularProperties::addBorderBesideColumn(int column)
0128 {
0129     m_BorderBesideColumn.append(column);
0130 }
0131 
0132 bool TabularProperties::hasBorderBesideColumn(int column) const
0133 {
0134     return m_BorderBesideColumn.contains(column);
0135 }
0136 
0137 void TabularProperties::setHasLeftBorder()
0138 {
0139     m_LeftBorder = true;
0140 }
0141 
0142 bool TabularProperties::hasLeftBorder() const
0143 {
0144     return m_LeftBorder;
0145 }
0146 
0147 }
0148