Warning, file /office/calligra/libs/text/KoTableColumnAndRowStyleManager.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2009 KO GmbH <cbo@kogmbh.com>
0003  * Copyright (C) 2009 Elvis Stansvik <elvstone@gmail.com>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 #ifndef KOTABLECOLUMNANDROWSTYLEMANAGER_H
0021 #define KOTABLECOLUMNANDROWSTYLEMANAGER_H
0022 
0023 #include "kotext_export.h"
0024 
0025 #include <QMetaType>
0026 #include <QExplicitlySharedDataPointer>
0027 
0028 class KoTableColumnStyle;
0029 class KoTableRowStyle;
0030 class KoTableCellStyle;
0031 class QTextTable;
0032 
0033 /**
0034  * Manages all column and row styles for a single table.
0035  *
0036  * It's not managing the lifetime of named styles, which is the job of the KoStyleManager,
0037  * so you should still register such styles in the styleManager too.
0038  *
0039  * The main purpose of this manager is simply to keep track of which styles are in
0040  * which column (and in which row).
0041  *
0042  * It's explicitly shared (for the same table)
0043  * TODO:
0044  *  - Eliminate duplicates.
0045  */
0046 class KOTEXT_EXPORT KoTableColumnAndRowStyleManager
0047 {
0048 public:
0049     /// constructor @see getManager for how to create a class the correct way
0050     explicit KoTableColumnAndRowStyleManager();
0051 
0052     virtual ~KoTableColumnAndRowStyleManager();
0053 
0054     /// Convenience function to get the KoTableColumnAndRowStyleManager for a table (or create one)
0055     static KoTableColumnAndRowStyleManager getManager(QTextTable *table);
0056 
0057     /// Constructor
0058     KoTableColumnAndRowStyleManager(const KoTableColumnAndRowStyleManager &rhs);
0059     /// assign operator
0060     KoTableColumnAndRowStyleManager &operator=(const KoTableColumnAndRowStyleManager &rhs);
0061 
0062     /**
0063      * Set the column style for the column \a column to \a columnStyle.
0064      *
0065      * @param column the column to set the style for.
0066      * @param columnStyle a column style.
0067      */
0068     void setColumnStyle(int column, const KoTableColumnStyle &columnStyle);
0069 
0070     /**
0071      * Insert a number of columns before the column \a column to \a columnStyle.
0072      *
0073      * @param column the columns are inserted before this column.
0074      * @param numberColumns how many columns to insert.
0075      * @param columnStyle the column style of the new columns.
0076      * @see QTextTable::insertColumns for the analog method for the table data.
0077      */
0078     void insertColumns(int column, int numberColumns, const KoTableColumnStyle &columnStyle);
0079 
0080     /**
0081      * Remove a number of columns  \a column to \a columnStyle.
0082      *
0083      * @param column this and possibly following columns are removed.
0084      * @param numberColumns how many columns to remove.
0085      * @see QTextTable::removeColumns for the analog method for the table data.
0086      */
0087     void removeColumns(int column, int numberColumns);
0088 
0089     /**
0090      * Get the column style for the column \a column.
0091      *
0092      * If you modify it don't forget to set it back here to actually have an effect
0093      *
0094      * @param column the column to get the style for.
0095      * @return the column style.
0096      */
0097     KoTableColumnStyle columnStyle(int column) const;
0098 
0099     /**
0100      * Set the row style for the row \a row to \a rowStyle.
0101      *
0102      * @param row the row to set the style for.
0103      * @param rowStyle a row style.
0104      */
0105     void setRowStyle(int row, const KoTableRowStyle &rowStyle);
0106 
0107     /**
0108      * Insert a number of rows above the row \a row to \a rowStyle.
0109      *
0110      * @param row the rows are inserted above this row.
0111      * @param numberRows how many rows to insert.
0112      * @param rowStyle the row style of the new rows.
0113      * @see QTextTable::insertRows for the analog method for the table data.
0114      */
0115     void insertRows(int row, int numberRows, const KoTableRowStyle &rowStyle);
0116 
0117     /**
0118      * Remove a number of rows  \a row to \a rowStyle.
0119      *
0120      * @param row this and possibly following rows are removed.
0121      * @param numberRows how many rows to remove.
0122      * @see QTextTable::removeRows for the analog method for the table data.
0123      */
0124     void removeRows(int row, int numberRows);
0125 
0126     /**
0127      * Get the row style for the row \a column.
0128      *
0129      * If you modify it don't forget to set it back here to actually have an effect
0130      *
0131      * @param row the row to get the style for.
0132      * @return the row style.
0133      */
0134     KoTableRowStyle rowStyle(int row) const;
0135 
0136     /**
0137      * Get the default cell style for the row \a row.
0138      *
0139      * @param row the row to get the style for.
0140      * @return the default cell style for \a row.
0141      */
0142     KoTableCellStyle* defaultRowCellStyle(int row) const;
0143 
0144     /**
0145      * Set the default cell style for the row \a row.
0146      *
0147      * @param row the row to set the style to.
0148      * @return the default cell style for \a row.
0149      */
0150     void setDefaultRowCellStyle(int row, KoTableCellStyle* cellStyle);
0151 
0152     /**
0153      * Get the default cell style for the column \a column.
0154      *
0155      * @param column the column to get the style for.
0156      * @return the default cell style for \a column.
0157      */
0158     KoTableCellStyle* defaultColumnCellStyle(int column) const;
0159 
0160     /**
0161      * Set the default cell style for the column \a column.
0162      *
0163      * @param column the column to set the style to.
0164      * @return the default cell style for \a column.
0165      */
0166     void setDefaultColumnCellStyle(int column, KoTableCellStyle* cellStyle);
0167 
0168 private:
0169     class Private;
0170     QExplicitlySharedDataPointer<Private> d;
0171 };
0172 
0173 Q_DECLARE_METATYPE(KoTableColumnAndRowStyleManager)
0174 
0175 #endif // KOTABLECOLUMNANDROWSTYLEMANAGER_H
0176