File: KoTableColumnAndRowStyleManager.h

package info (click to toggle)
calligra 1%3A25.04.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 309,164 kB
  • sloc: cpp: 667,890; xml: 126,105; perl: 2,724; python: 2,497; yacc: 1,817; ansic: 1,326; sh: 1,223; lex: 1,107; javascript: 495; makefile: 24
file content (162 lines) | stat: -rw-r--r-- 5,362 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/* This file is part of the KDE project
 * SPDX-FileCopyrightText: 2009 KO GmbH <cbo@kogmbh.com>
 * SPDX-FileCopyrightText: 2009 Elvis Stansvik <elvstone@gmail.com>
 *
 * SPDX-License-Identifier: LGPL-2.0-or-later
 */
#ifndef KOTABLECOLUMNANDROWSTYLEMANAGER_H
#define KOTABLECOLUMNANDROWSTYLEMANAGER_H

#include "kotext_export.h"

#include <QExplicitlySharedDataPointer>
#include <QMetaType>

class KoTableColumnStyle;
class KoTableRowStyle;
class KoTableCellStyle;
class QTextTable;

/**
 * Manages all column and row styles for a single table.
 *
 * It's not managing the lifetime of named styles, which is the job of the KoStyleManager,
 * so you should still register such styles in the styleManager too.
 *
 * The main purpose of this manager is simply to keep track of which styles are in
 * which column (and in which row).
 *
 * It's explicitly shared (for the same table)
 * TODO:
 *  - Eliminate duplicates.
 */
class KOTEXT_EXPORT KoTableColumnAndRowStyleManager
{
public:
    /// constructor @see getManager for how to create a class the correct way
    explicit KoTableColumnAndRowStyleManager();

    virtual ~KoTableColumnAndRowStyleManager();

    /// Convenience function to get the KoTableColumnAndRowStyleManager for a table (or create one)
    static KoTableColumnAndRowStyleManager getManager(QTextTable *table);

    /// Constructor
    KoTableColumnAndRowStyleManager(const KoTableColumnAndRowStyleManager &rhs);
    /// assign operator
    KoTableColumnAndRowStyleManager &operator=(const KoTableColumnAndRowStyleManager &rhs);

    /**
     * Set the column style for the column \a column to \a columnStyle.
     *
     * @param column the column to set the style for.
     * @param columnStyle a column style.
     */
    void setColumnStyle(int column, const KoTableColumnStyle &columnStyle);

    /**
     * Insert a number of columns before the column \a column to \a columnStyle.
     *
     * @param column the columns are inserted before this column.
     * @param numberColumns how many columns to insert.
     * @param columnStyle the column style of the new columns.
     * @see QTextTable::insertColumns for the analog method for the table data.
     */
    void insertColumns(int column, int numberColumns, const KoTableColumnStyle &columnStyle);

    /**
     * Remove a number of columns  \a column to \a columnStyle.
     *
     * @param column this and possibly following columns are removed.
     * @param numberColumns how many columns to remove.
     * @see QTextTable::removeColumns for the analog method for the table data.
     */
    void removeColumns(int column, int numberColumns);

    /**
     * Get the column style for the column \a column.
     *
     * If you modify it don't forget to set it back here to actually have an effect
     *
     * @param column the column to get the style for.
     * @return the column style.
     */
    KoTableColumnStyle columnStyle(int column) const;

    /**
     * Set the row style for the row \a row to \a rowStyle.
     *
     * @param row the row to set the style for.
     * @param rowStyle a row style.
     */
    void setRowStyle(int row, const KoTableRowStyle &rowStyle);

    /**
     * Insert a number of rows above the row \a row to \a rowStyle.
     *
     * @param row the rows are inserted above this row.
     * @param numberRows how many rows to insert.
     * @param rowStyle the row style of the new rows.
     * @see QTextTable::insertRows for the analog method for the table data.
     */
    void insertRows(int row, int numberRows, const KoTableRowStyle &rowStyle);

    /**
     * Remove a number of rows  \a row to \a rowStyle.
     *
     * @param row this and possibly following rows are removed.
     * @param numberRows how many rows to remove.
     * @see QTextTable::removeRows for the analog method for the table data.
     */
    void removeRows(int row, int numberRows);

    /**
     * Get the row style for the row \a column.
     *
     * If you modify it don't forget to set it back here to actually have an effect
     *
     * @param row the row to get the style for.
     * @return the row style.
     */
    KoTableRowStyle rowStyle(int row) const;

    /**
     * Get the default cell style for the row \a row.
     *
     * @param row the row to get the style for.
     * @return the default cell style for \a row.
     */
    KoTableCellStyle *defaultRowCellStyle(int row) const;

    /**
     * Set the default cell style for the row \a row.
     *
     * @param row the row to set the style to.
     * @return the default cell style for \a row.
     */
    void setDefaultRowCellStyle(int row, KoTableCellStyle *cellStyle);

    /**
     * Get the default cell style for the column \a column.
     *
     * @param column the column to get the style for.
     * @return the default cell style for \a column.
     */
    KoTableCellStyle *defaultColumnCellStyle(int column) const;

    /**
     * Set the default cell style for the column \a column.
     *
     * @param column the column to set the style to.
     * @return the default cell style for \a column.
     */
    void setDefaultColumnCellStyle(int column, KoTableCellStyle *cellStyle);

private:
    class Private;
    QExplicitlySharedDataPointer<Private> d;
};

Q_DECLARE_METATYPE(KoTableColumnAndRowStyleManager)

#endif // KOTABLECOLUMNANDROWSTYLEMANAGER_H