equal
deleted
inserted
replaced
20 #define HGSCROLLBUFFERMANAGER_H_ |
20 #define HGSCROLLBUFFERMANAGER_H_ |
21 |
21 |
22 #include <qobject> |
22 #include <qobject> |
23 #include <QTimer> |
23 #include <QTimer> |
24 |
24 |
|
25 class UpdatePair |
|
26 { |
|
27 public: |
|
28 UpdatePair(int start, int count); |
|
29 |
|
30 int start() const; |
|
31 int end() const; |
|
32 |
|
33 bool adjacent(int start, int count) const; |
|
34 bool contains(const UpdatePair &other) const; |
|
35 void extend(int start, int count); |
|
36 void subtract(int start, int count); |
|
37 |
|
38 void shiftRight(int count); |
|
39 void shiftLeft(int count); |
|
40 |
|
41 bool operator== (const UpdatePair &other) const; |
|
42 bool operator< (const UpdatePair &other) const; |
|
43 |
|
44 private: |
|
45 int mStart; |
|
46 int mCount; |
|
47 }; |
|
48 |
|
49 class UpdateBuffer : public QList<UpdatePair> |
|
50 { |
|
51 public: |
|
52 UpdateBuffer(); |
|
53 |
|
54 void add(int start, int count); |
|
55 void remove(int start, int count); |
|
56 void shiftRight(int startingFrom, int amount); |
|
57 void shiftLeft(int startingFrom, int amount); |
|
58 }; |
|
59 |
25 class HgScrollBufferManager: public QObject |
60 class HgScrollBufferManager: public QObject |
26 { |
61 { |
27 Q_OBJECT |
62 Q_OBJECT |
28 public: |
63 public: |
29 |
64 |
39 |
74 |
40 void scrollPositionChanged(int newPosition); |
75 void scrollPositionChanged(int newPosition); |
41 |
76 |
42 bool positionInsideBuffer(int position); |
77 bool positionInsideBuffer(int position); |
43 |
78 |
44 void removeItems(int start, int end, int totalCount); |
79 void addItems(int start, int count); |
45 void addItems(int start, int end, int totalCount); |
80 void removeItems(int start, int end); |
46 void moveItems(int start, int end, int target, int totalCount); |
81 void moveItems(int start, int end, int target); |
|
82 |
|
83 void flushRequestBuffers(); |
47 |
84 |
48 void currentBuffer(int& bufferStart, int& bufferEnd); |
85 void currentBuffer(int& bufferStart, int& bufferEnd); |
49 |
86 |
50 signals: |
87 signals: |
51 |
88 |
58 |
95 |
59 protected: |
96 protected: |
60 |
97 |
61 void init(); |
98 void init(); |
62 void asyncUpdate(); |
99 void asyncUpdate(); |
63 bool isInsideBuffer(int pos); |
100 |
64 bool isInsideBuffer(int start, int end); |
101 int changeBufferPosition(int newPos); |
|
102 |
|
103 void simpleAddItems(int start, int end); |
|
104 void simpleRemoveItems(int start, int end); |
|
105 |
|
106 void appendRequestBuffer(int start, int end); |
|
107 void appendReleaseBuffer(int start, int end); |
65 |
108 |
66 private: |
109 private: |
67 |
110 |
68 int mBufferSize; |
111 int mBufferSize; |
69 int mBufferTreshold; |
112 int mBufferTreshold; |
77 int mRequestCount; |
120 int mRequestCount; |
78 int mReleaseStart; |
121 int mReleaseStart; |
79 int mReleaseCount; |
122 int mReleaseCount; |
80 QTimer mTimer; |
123 QTimer mTimer; |
81 |
124 |
|
125 UpdateBuffer mRequestBuffer; |
|
126 UpdateBuffer mReleaseBuffer; |
|
127 |
82 private: |
128 private: |
83 Q_DISABLE_COPY(HgScrollBufferManager) |
129 Q_DISABLE_COPY(HgScrollBufferManager) |
84 }; |
130 }; |
85 |
131 |
86 #endif /*HGSCROLLBUFFERMANAGER_H_*/ |
132 #endif /*HGSCROLLBUFFERMANAGER_H_*/ |