@@ -591,12 +591,14 void QPieSeriesPrivate::modelDataAdded(QModelIndex parent, int start, int end) | |||
|
591 | 591 | Q_UNUSED(parent); |
|
592 | 592 | Q_Q(QPieSeries); |
|
593 | 593 | // series uses model as a data sourceupda |
|
594 | int addedCount = end - start + 1; | |
|
595 | 594 | if (m_mapCount != -1 && start >= m_mapFirst + m_mapCount) { |
|
596 | 595 | return; |
|
597 | 596 | } else { |
|
597 | int addedCount = end - start + 1; | |
|
598 | if (m_mapCount != -1 && addedCount > m_mapCount) | |
|
599 | addedCount = m_mapCount; | |
|
598 | 600 | int first = qMax(start, m_mapFirst); |
|
599 | int last = qMin(first + addedCount - 1, end); | |
|
601 | int last = qMin(first + addedCount - 1, m_mapOrientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); | |
|
600 | 602 | for (int i = first; i <= last; i++) { |
|
601 | 603 | QPieSlice *slice = new QPieSlice; |
|
602 | 604 | if (m_mapOrientation == Qt::Vertical) { |
@@ -679,17 +681,21 void QPieSeriesPrivate::modelDataRemoved(QModelIndex parent, int start, int end) | |||
|
679 | 681 | } |
|
680 | 682 | |
|
681 | 683 | // else if (m_mapCount == -1) { |
|
684 | // // first find how many items can actually be removed | |
|
685 | // int toRemove = qMin(m_slices.size(), removedCount); | |
|
686 | // // get the index of the first item that will be removed. | |
|
682 | 687 | // int first = qMax(start, m_mapFirst); |
|
683 | // int last = qMax(end, m_mapFirst + removedCount - 1); | |
|
684 |
// |
|
|
688 | // // get the index of the last item that will be removed. | |
|
689 | // int last = first + toRemove; | |
|
690 | // for (int i = last - 1; i >= first; i--) | |
|
685 | 691 | // q->remove(q->slices().at(i - m_mapFirst)); |
|
686 | 692 | // } |
|
687 | // else { | |
|
688 | // int toRemove = qMin(m_slices.size() - 1, removedCount); | |
|
689 | // int first = qMax(start, m_mapFirst); | |
|
690 | // int last = qMax(end, m_mapFirst + toRemove - 1); | |
|
693 | // else { | |
|
694 | // int toRemove = qMin(m_slices.size() - 1, removedCount); | |
|
695 | // int first = qMax(start, m_mapFirst); | |
|
696 | // int last = qMax(end, m_mapFirst + toRemove - 1); | |
|
691 | 697 | |
|
692 | // } | |
|
698 | // } | |
|
693 | 699 | |
|
694 | 700 | // removing items from unlimited map |
|
695 | 701 | else if (m_mapCount == -1 && start >= m_mapFirst) { |
@@ -698,7 +704,8 void QPieSeriesPrivate::modelDataRemoved(QModelIndex parent, int start, int end) | |||
|
698 | 704 | // handlePointRemoved(i - m_mapFirst); |
|
699 | 705 | } else if (m_mapCount == - 1 && start < m_mapFirst) { |
|
700 | 706 | // not all removed items |
|
701 | for (int i = m_mapFirst + removedCount - 1; i >= m_mapFirst; i--) | |
|
707 | int lastExisting = qMin(m_mapFirst + m_slices.size() - 1, m_mapFirst + removedCount - 1); | |
|
708 | for (int i = lastExisting; i >= m_mapFirst; i--) | |
|
702 | 709 | q->remove(q->slices().at(i - m_mapFirst)); |
|
703 | 710 | // handlePointRemoved(i - m_mapFirst); |
|
704 | 711 | } |
@@ -706,11 +713,11 void QPieSeriesPrivate::modelDataRemoved(QModelIndex parent, int start, int end) | |||
|
706 | 713 | // removing items from limited map |
|
707 | 714 | else if (start >= m_mapFirst) { |
|
708 | 715 | // |
|
709 | // int sizeAfter = m_slices.size(); | |
|
716 | // int sizeAfter = m_slices.size(); | |
|
710 | 717 | int lastExisting = qMin(m_mapFirst + m_slices.size() - 1, end); |
|
711 | 718 | for (int i = lastExisting; i >= start; i--) { |
|
712 | 719 | q->remove(q->slices().at(i - m_mapFirst)); |
|
713 | // sizeAfter--; | |
|
720 | // sizeAfter--; | |
|
714 | 721 | // handlePointRemoved(i - m_mapFirst); |
|
715 | 722 | } |
|
716 | 723 |
@@ -174,6 +174,7 void QXYSeries::removeAll() | |||
|
174 | 174 | */ |
|
175 | 175 | QList<QPointF> QXYSeries::points() const |
|
176 | 176 | { |
|
177 | // Q_ASSERT(false); | |
|
177 | 178 | Q_D(const QXYSeries); |
|
178 | 179 | if (d->m_model) { |
|
179 | 180 | QList<QPointF> result; |
@@ -129,52 +129,68 void XYChartItem::handlePointsAdded(int start, int end) | |||
|
129 | 129 | if (m_series->model() == 0) { |
|
130 | 130 | for (int i = start; i <= end; i++) |
|
131 | 131 | handlePointAdded(i); |
|
132 | } else if (m_series->mapCount() != -1 && start >= m_series->mapFirst() + m_series->mapCount()) { | |
|
133 | return; | |
|
132 | 134 | } else { |
|
133 | // series uses model as a data source | |
|
134 | int first = m_series->mapFirst(); | |
|
135 | int count = m_series->mapCount(); | |
|
136 | 135 | int addedCount = end - start + 1; |
|
137 | if (count != -1 && start >= first + count) { | |
|
138 | return; | |
|
139 | } | |
|
140 | ||
|
141 | // adding items to unlimited map | |
|
142 | else if (count == -1 && start >= first) { | |
|
143 | for (int i = start; i <= end; i++) | |
|
144 | handlePointAdded(i - first); | |
|
145 | } else if (count == - 1 && start < first) { | |
|
146 | // not all newly added items | |
|
147 | for (int i = first; i < first + addedCount; i++) | |
|
148 | handlePointAdded(i - first); | |
|
149 | } | |
|
150 | // commented out code below does the same thing, but its more confusing. | |
|
151 | // } else if (count == -1) { | |
|
152 | // int begin = qMax(start, first); | |
|
153 | // for (int i = begin; i < begin + (end - start + 1); i++) | |
|
154 | // handlePointAdded(i - first); | |
|
155 | // } | |
|
156 | ||
|
157 | // adding items to limited map | |
|
158 | else if (start >= first) { | |
|
159 | // remove the items that will no longer fit into the map | |
|
160 | // int toRemove = addedCount - (count - points().size()); | |
|
161 | for (int i = start; i <= end; i++) { | |
|
162 | handlePointAdded(i - first); | |
|
163 | } | |
|
164 | if (m_points.size() > count) | |
|
165 | for (int i = m_points.size() - 1; i >= count; i--) | |
|
166 | handlePointRemoved(i); | |
|
167 | // update(); | |
|
168 | } else { | |
|
169 | // | |
|
170 | for (int i = first; i < first + addedCount; i++) { | |
|
171 | handlePointAdded(i - first); | |
|
172 | } | |
|
173 | if (m_points.size() > count) | |
|
174 | for (int i = m_points.size() - 1; i >= count; i--) | |
|
175 | handlePointRemoved(i); | |
|
136 | if (m_series->mapCount() != -1 && addedCount > m_series->mapCount()) | |
|
137 | addedCount = m_series->mapCount(); | |
|
138 | int first = qMax(start, m_series->mapFirst()); | |
|
139 | int last = qMin(first + addedCount - 1, m_series->mapOrientation() == Qt::Vertical ? m_series->model()->rowCount() - 1 : m_series->model()->columnCount() - 1); | |
|
140 | for (int i = first; i <= last; i++) { | |
|
141 | handlePointAdded(i - m_series->mapFirst()); | |
|
176 | 142 | } |
|
143 | if (m_series->mapCount() != -1 && m_points.size() > m_series->mapCount()) | |
|
144 | for (int i = m_points.size() - 1; i >= m_series->mapCount(); i--) | |
|
145 | handlePointRemoved(i); | |
|
177 | 146 | } |
|
147 | ||
|
148 | // else { | |
|
149 | // // series uses model as a data source | |
|
150 | // int first = m_series->mapFirst(); | |
|
151 | // int count = m_series->mapCount(); | |
|
152 | // int addedCount = end - start + 1; | |
|
153 | // if (count != -1 && start >= first + count) { | |
|
154 | // return; | |
|
155 | // } | |
|
156 | ||
|
157 | // // adding items to unlimited map | |
|
158 | // else if (count == -1 && start >= first) { | |
|
159 | // for (int i = start; i <= end; i++) | |
|
160 | // handlePointAdded(i - first); | |
|
161 | // } else if (count == - 1 && start < first) { | |
|
162 | // // not all newly added items | |
|
163 | // for (int i = first; i < first + addedCount; i++) | |
|
164 | // handlePointAdded(i - first); | |
|
165 | // } | |
|
166 | // // commented out code below does the same thing, but its more confusing. | |
|
167 | // // } else if (count == -1) { | |
|
168 | // // int begin = qMax(start, first); | |
|
169 | // // for (int i = begin; i < begin + (end - start + 1); i++) | |
|
170 | // // handlePointAdded(i - first); | |
|
171 | // // } | |
|
172 | ||
|
173 | // // adding items to limited map | |
|
174 | // else if (start >= first) { | |
|
175 | // // remove the items that will no longer fit into the map | |
|
176 | // // int toRemove = addedCount - (count - points().size()); | |
|
177 | // for (int i = start; i <= end; i++) { | |
|
178 | // handlePointAdded(i - first); | |
|
179 | // } | |
|
180 | // if (m_points.size() > count) | |
|
181 | // for (int i = m_points.size() - 1; i >= count; i--) | |
|
182 | // handlePointRemoved(i); | |
|
183 | // // update(); | |
|
184 | // } else { | |
|
185 | // // | |
|
186 | // for (int i = first; i < first + addedCount; i++) { | |
|
187 | // handlePointAdded(i - first); | |
|
188 | // } | |
|
189 | // if (m_points.size() > count) | |
|
190 | // for (int i = m_points.size() - 1; i >= count; i--) | |
|
191 | // handlePointRemoved(i); | |
|
192 | // } | |
|
193 | // } | |
|
178 | 194 | } |
|
179 | 195 | |
|
180 | 196 | void XYChartItem::handlePointRemoved(int index) |
@@ -211,7 +227,8 void XYChartItem::handlePointsRemoved(int start, int end) | |||
|
211 | 227 | handlePointRemoved(i - first); |
|
212 | 228 | } else if (count == - 1 && start < first) { |
|
213 | 229 | // not all removed items |
|
214 | for (int i = first + removedCount - 1; i >= first; i--) | |
|
230 | int lastExisting = qMin(first + m_points.size() - 1, first + removedCount - 1); | |
|
231 | for (int i = lastExisting; i >= first; i--) | |
|
215 | 232 | handlePointRemoved(i - first); |
|
216 | 233 | } |
|
217 | 234 |
@@ -53,7 +53,7 TableWidget::TableWidget(QWidget *parent) | |||
|
53 | 53 | // tableView->setItemDelegate(new QStyledItemDelegate); |
|
54 | 54 | m_chart = new QChart; |
|
55 | 55 | m_chart->legend()->setVisible(true); |
|
56 | m_chart->setAnimationOptions(QChart::SeriesAnimations); | |
|
56 | // m_chart->setAnimationOptions(QChart::SeriesAnimations); | |
|
57 | 57 | m_chartView = new QChartView(m_chart); |
|
58 | 58 | m_chartView->setRenderHint(QPainter::Antialiasing); |
|
59 | 59 | m_chartView->setMinimumSize(640, 480); |
General Comments 0
You need to be logged in to leave comments.
Login now