edbee - Qt Editor Library v0.11.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
textlinedata.h
Go to the documentation of this file.
1// edbee - Copyright (c) 2012-2025 by Rick Blommers and contributors
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include "edbee/exports.h"
7
8#include <QObject>
9#include <QTextLayout>
10
12
13namespace edbee {
14
15
22
23
24class Change;
25class TextLineDataManager;
26
27
28
31public:
33 virtual ~TextLineData() {}
34// bool undoable() = 0;
35};
36
38template<typename T>
40{
41public:
42 BasicTextLineData( const T& val ) : value_(val) {}
43 T value() { return value_; }
44 void setValue( const T& value ) { value_ = value; }
45
46private:
47 T value_;
48};
49
50
53
54//-------
55
58public:
60 virtual ~TextLineDataList();
61 virtual void destroy( TextLineDataManager* manager );
62
63 void give( TextLineDataManager* manager, int field, TextLineData *dataItem );
64 TextLineData* take( TextLineDataManager* manager, int field );
65 TextLineData* at( TextLineDataManager* manager, int field );
66
67 void realloc( TextLineDataManager* manager, int oldFieldPerLine, int newFieldsPerLine );
68
69private:
70 TextLineData** lineDataList_;
71};
72
73//-------
74
76class EDBEE_EXPORT TextLineDataManager : public QObject
77{
78Q_OBJECT
79
80public:
82 virtual ~TextLineDataManager();
83
84 void clear();
85
86
87 void give(int line, int field, TextLineData *dataItem );
88 TextLineData* take(int line, int field );
89 TextLineData* get( int line, int field );
90
92 int fieldsPerLine() { return fieldsPerLine_; }
93 void setFieldsPerLine( int count );
94
96 int length() const { return textLineDataList_.length(); }
98 TextLineDataList* at(int idx) const { return textLineDataList_.at(idx); }
99
100 // internal functions
101 Change* createLinesReplacedChange( int lineStart, int lineCount, int newLineCount );
102 TextLineDataList* takeList( int line );
103 void giveList( int line, TextLineDataList* list );
104
105 void fillWithEmpty( int line, int length, int newLength );
106 void replace( int line, int length, TextLineDataList** items, int newLength );
107
109 GapVector<TextLineDataList*>* textLineDataList() { return &textLineDataList_; }
110
111protected:
112
113 void destroyRange( int line, int length );
114
115
116public slots:
117
118// void linesReplaced( int lineStart, int lineCount, int newLineCount );
119// void dumpGapvector();
120signals:
121
122 void lineDataChanged( int line, int length, int newLength );
123
124private:
125
126 int fieldsPerLine_;
127 GapVector<TextLineDataList*> textLineDataList_;
128// NoGapVector<TextLineDataList*> textLineDataList_;
129};
130
131
132} // edbee
a simple class to store a QString in a line
Definition textlinedata.h:40
void setValue(const T &value)
Definition textlinedata.h:44
BasicTextLineData(const T &val)
Definition textlinedata.h:42
T value()
Definition textlinedata.h:43
A basic change.
Definition change.h:18
This class is used to define a gap vector. A Gapvector is split in 2 parts. where the gap is moved to...
Definition gapvector.h:19
A text line item reference.
Definition textlinedata.h:30
TextLineData()
Definition textlinedata.h:32
virtual ~TextLineData()
Definition textlinedata.h:33
the line data items
Definition textlinedata.h:57
void realloc(TextLineDataManager *manager, int oldFieldPerLine, int newFieldsPerLine)
This method reallocates the number of fields.
Definition textlinedata.cpp:83
TextLineDataList()
construct the text line data item
Definition textlinedata.cpp:16
TextLineData * at(TextLineDataManager *manager, int field)
This method returns the given data item /.
Definition textlinedata.cpp:73
TextLineData * take(TextLineDataManager *manager, int field)
This method returns the given data item and transfers the ownership. The item in the list is set to 0...
Definition textlinedata.cpp:59
virtual void destroy(TextLineDataManager *manager)
destroys the data items
Definition textlinedata.cpp:30
This manager manages all line definitions.
Definition textlinedata.h:77
TextLineDataList * at(int idx) const
returns the textline data list item
Definition textlinedata.h:98
TextLineData * take(int line, int field)
Definition textlinedata.cpp:149
GapVector< TextLineDataList * > * textLineDataList()
internal method for direct accesss
Definition textlinedata.h:109
int length() const
returns the number of items
Definition textlinedata.h:96
int fieldsPerLine()
returns the number of items per line
Definition textlinedata.h:92
TextLineDataManager(int fieldsPerLine=PredefinedFieldCount)
Definition textlinedata.cpp:109
TextLineData * get(int line, int field)
Definition textlinedata.cpp:157
void clear()
this method clears all field items
Definition textlinedata.cpp:124
#define EDBEE_EXPORT
Definition exports.h:15
#define give(key, command)
Definition factorycommandmap.cpp:30
QT Acessibility has an issue with reporting blank lines between elements lines. defining 'WINDOWS_EMP...
Definition commentcommand.cpp:20
BasicTextLineData< QList< QTextLayout::FormatRange > > LineAppendTextLayoutFormatListData
Definition textlinedata.h:52
TextLineDataPredefinedFields
Definition textlinedata.h:16
@ LineTextScopesField
Definition textlinedata.h:17
@ LineAppendTextLayoutFormatListField
Definition textlinedata.h:19
@ PredefinedFieldCount
Definition textlinedata.h:20
BasicTextLineData< QString > QStringTextLineData
Definition textlinedata.h:51