1 /* 2 SPDX-FileCopyrightText: 2007-2009 Sergio Pistone <sergio_pistone@yahoo.com.ar> 3 SPDX-FileCopyrightText: 2010-2018 Mladen Milinkovic <max@smoothware.net> 4 5 SPDX-License-Identifier: GPL-2.0-or-later 6 */ 7 8 #ifndef SCRIPTING_SSTRING_H 9 #define SCRIPTING_SSTRING_H 10 11 #include "core/sstring.h" 12 13 #include <QObject> 14 #include <QString> 15 16 namespace SubtitleComposer { 17 namespace Scripting { 18 class List; 19 class SString : public QObject 20 { 21 Q_OBJECT 22 23 public slots: 24 bool isEmpty() const; 25 26 int count() const; 27 int size() const; 28 int length() const; 29 30 QString plainText() const; 31 void setPlainText(const QString &string, int styleFlags = 0); 32 33 QString richText() const; 34 void setRichText(const QString &string); 35 36 const QChar charAt(int index); 37 void setCharAt(int index, const QChar &chr); 38 39 int styleFlagsAt(int index) const; 40 void setStyleFlagsAt(int index, int styleFlags) const; 41 42 int cummulativeStyleFlags() const; 43 bool hasStyleFlags(int styleFlags) const; 44 45 void setStyleFlags(int index, int len, int styleFlags); 46 void setStyleFlags(int index, int len, int styleFlags, bool on); 47 48 void clear(); 49 void truncate(int size); 50 51 QObject * insert(int index, QObject *str); 52 QObject * insertPlain(int index, const QString &str); 53 QObject * append(QObject *str); 54 QObject * appendPlain(const QString &str); 55 QObject * prepend(QObject *str); 56 QObject * prependPlain(const QString &str); 57 58 QObject * remove(int index, int len); 59 QObject * removeAll(const QString &str, bool regExp = false, bool caseSensitive = true); 60 61 QObject * replace(int index, int len, QObject *replacement); 62 QObject * replacePlain(int index, int len, const QString &replacement); 63 QObject * replaceAll(const QString &before, QObject *after, bool regExp = false, bool caseSensitive = true); 64 QObject * replaceAllPlain(const QString &before, const QString &after, bool regExp = false, bool caseSensitive = true); 65 66 List * split(const QString &sep, bool regExp, bool caseSensitive = true) const; 67 68 QObject * left(int len) const; 69 QObject * right(int len) const; 70 QObject * mid(int index, int len = -1) const; 71 72 QObject * toLower() const; 73 QObject * toUpper() const; 74 75 QObject * simplified() const; 76 QObject * trimmed() const; 77 78 int compareTo(QObject *string) const; 79 int compareToPlain(const QString &string) const; 80 81 private: 82 friend class StringsModule; 83 friend class SubtitleLine; 84 85 SString(const SubtitleComposer::SString &backend, QObject *parent); 86 87 SubtitleComposer::SString m_backend; 88 }; 89 } 90 } 91 #endif 92