File indexing completed on 2024-05-19 04:44:34

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0012  * Lesser General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Lesser General Public
0015  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 #ifndef SCRIPTINGKRSCRIPTTEXT_H
0018 #define SCRIPTINGKRSCRIPTTEXT_H
0019 
0020 #include <QObject>
0021 
0022 #include "KReportItemText.h"
0023 
0024 namespace Scripting
0025 {
0026 
0027 /**
0028 @brief Text item script interface
0029 
0030 The user facing interface for scripting report text items
0031 */
0032 class Text : public QObject
0033 {
0034     Q_OBJECT
0035 public:
0036     explicit Text(KReportItemText*);
0037 
0038     ~Text() override;
0039 public Q_SLOTS:
0040 
0041     //! @return the data source for the text element
0042     //! The source can be a column name or a valid script expression if prefixed with a '='.
0043     QString source() const;
0044 
0045     //! Sets the data source for the text element.
0046     //! @see source()
0047     void setSource(const QString &s);
0048 
0049     //! @return the horizontal alignment as an integer
0050     //! Valid values are left: -1, center: 0, right; 1
0051     int horizontalAlignment() const;
0052 
0053     //! Sets the horizontal alignment
0054     //! Valid values for alignment are left: -1, center: 0, right; 1
0055     void setHorizonalAlignment(int);
0056 
0057     //! @return the vertical alignment
0058     //! Valid values are top: -1, middle: 0, bottom: 1
0059     int verticalAlignment() const;
0060 
0061     //! Sets the vertical alignment
0062     //! Valid values for aligmnt are top: -1, middle: 0, bottom: 1
0063     void setVerticalAlignment(int);
0064 
0065     //! @return the background color of the lable
0066     QColor backgroundColor() const;
0067 
0068     //! Set the background color of the text-item to the given color
0069     void setBackgroundColor(const QColor&);
0070 
0071     //! @return the foreground (text) color of the text-item
0072     QColor foregroundColor() const;
0073 
0074     //! Sets the foreground (text) color of the text-item to the given color
0075     void setForegroundColor(const QColor&);
0076 
0077     //! @return the opacity of the text-item
0078     int backgroundOpacity() const;
0079 
0080     //! Sets the background opacity of the text-item
0081     //! Valid values are in the range 0-100
0082     void setBackgroundOpacity(int);
0083 
0084     //! @return the border line color of the text-item
0085     QColor lineColor() const;
0086 
0087     //! Sets the border line color of the text-item to the given color
0088     void setLineColor(const QColor&);
0089 
0090     //! @return the border line weight (thickness) of the text-item
0091     int lineWeight() const;
0092 
0093     //! Sets the border line weight (thickness) of the text-item
0094     void setLineWeight(int);
0095 
0096     //! @return the border line style of the text-item.  Values are from Qt::Penstyle range 0-5
0097     int lineStyle() const;
0098 
0099     //! Sets the border line style of the text-item to the given style in the range 0-5
0100     void setLineStyle(int);
0101 
0102     //! @returns the position of the text-item in points
0103     QPointF position() const;
0104 
0105     //! Sets the position of the text-item to the given point coordinates
0106     void setPosition(const QPointF&);
0107 
0108     //! @returns the size of the text-item in points
0109     QSizeF size() const;
0110 
0111     //! Sets the size of the text-item to the given size in points
0112     void setSize(const QSizeF&);
0113 
0114     //!Load the contents for the text item from the given file
0115     bool loadFromFile(const QString& fileName);
0116 private:
0117     KReportItemText *m_text;
0118 };
0119 
0120 }
0121 
0122 #endif