edbee - Qt Editor Library
textlinedata.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <QObject>
9 
10 #include "edbee/util/gapvector.h"
11 
12 namespace edbee {
13 
14 
17 // LineDataMarkers, /// Bookmarks etc
19 };
20 
21 
22 class Change;
24 
25 
26 
29 {
30 public:
32  virtual ~TextLineData() {}
33 // bool undoable() = 0;
34 };
35 
37 template<typename T>
39 {
40 public:
41  BasicTextLineData( const T& val ) : value_(val) {}
42  T value() { return value_; }
43  void setValue( const T& value ) { value_ = value; }
44 
45 private:
46  T value_;
47 };
48 
50 
51 
52 //-------
53 
56 {
57 public:
59  virtual ~TextLineDataList();
60  virtual void destroy( TextLineDataManager* manager );
61 
62  void give( TextLineDataManager* manager, int field, TextLineData *dataItem );
63  TextLineData* take( TextLineDataManager* manager, int field );
64  TextLineData* at( TextLineDataManager* manager, int field );
65 
66  void realloc( TextLineDataManager* manager, int oldFieldPerLine, int newFieldsPerLine );
67 
68 private:
69  TextLineData** lineDataList_;
70 };
71 
72 //-------
73 
75 class TextLineDataManager : public QObject
76 {
77 Q_OBJECT
78 
79 public:
80  TextLineDataManager( int fieldsPerLine = PredefinedFieldCount);
81  virtual ~TextLineDataManager();
82 
83  void clear();
84 
85 
86  void give(int line, int field, TextLineData *dataItem );
87  TextLineData* take(int line, int field );
88  TextLineData* get( int line, int field );
89 
91  int fieldsPerLine() { return fieldsPerLine_; }
92  void setFieldsPerLine( int count );
93 
95  int length() const { return textLineDataList_.length(); }
97  TextLineDataList* at(int idx) const { return textLineDataList_.at(idx); }
98 
99  // internal functions
100  Change* createLinesReplacedChange( int lineStart, int lineCount, int newLineCount );
101  TextLineDataList* takeList( int line );
102  void giveList( int line, TextLineDataList* list );
103 
104  void fillWithEmpty( int line, int length, int newLength );
105  void replace( int line, int length, TextLineDataList** items, int newLength );
106 
108  GapVector<TextLineDataList*>* textLineDataList() { return &textLineDataList_; }
109 
110 protected:
111 
112  void destroyRange( int line, int length );
113 
114 
115 public slots:
116 
117 // void linesReplaced( int lineStart, int lineCount, int newLineCount );
118 // void dumpGapvector();
119 signals:
120 
121  void lineDataChanged( int line, int length, int newLength );
122 
123 private:
124 
125  int fieldsPerLine_;
126  GapVector<TextLineDataList*> textLineDataList_;
127 // NoGapVector<TextLineDataList*> textLineDataList_;
128 };
129 
130 
131 } // edbee
TextLineDataPredefinedFields
Definition: textlinedata.h:15
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
int fieldsPerLine()
returns the number of items per line
Definition: textlinedata.h:91
TextLineData * at(TextLineDataManager *manager, int field)
This method returns the given data item /.
Definition: textlinedata.cpp:75
GapVector< TextLineDataList * > * textLineDataList()
internal method for direct accesss
Definition: textlinedata.h:108
BasicTextLineData< QString > QStringTextLineData
Definition: textlinedata.h:49
This manager manages all line definitions.
Definition: textlinedata.h:75
a simple class to store a QString in a line
Definition: textlinedata.h:38
BasicTextLineData(const T &val)
Definition: textlinedata.h:41
TextLineData()
Definition: textlinedata.h:31
Copyright 2011-2013 - Reliable Bits Software by Blommers IT.
Definition: commentcommand.cpp:22
TextLineDataList * at(int idx) const
returns the textline data list item
Definition: textlinedata.h:97
A basic change.
Definition: change.h:18
the line data items
Definition: textlinedata.h:55
int length() const
returns the number of items
Definition: textlinedata.h:95
T value()
Definition: textlinedata.h:42
Definition: textlinedata.h:18
Definition: textlinedata.h:16
void setValue(const T &value)
Definition: textlinedata.h:43
A text line item reference.
Definition: textlinedata.h:28
#define give(key, command)
Definition: factorycommandmap.cpp:30
virtual ~TextLineData()
Definition: textlinedata.h:32