aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-07-26 04:17:59 +0800
committerChris Lahey <clahey@src.gnome.org>2000-07-26 04:17:59 +0800
commit4ab46c1b63a253f77aff9de8a128160ab1b2468f (patch)
treef85b3d6f7baf46e01be7a8fc1fb776bc34a13aa2 /widgets
parent384b3e38f2b049f808d1b4a72ca1d396ae6e2fb2 (diff)
downloadgsoc2013-evolution-4ab46c1b63a253f77aff9de8a128160ab1b2468f.tar.gz
gsoc2013-evolution-4ab46c1b63a253f77aff9de8a128160ab1b2468f.tar.zst
gsoc2013-evolution-4ab46c1b63a253f77aff9de8a128160ab1b2468f.zip
Fixed up the bit manipulation a bit here.
2000-07-25 Christopher James Lahey <clahey@helixcode.com> * e-table-selection-model.c: Fixed up the bit manipulation a bit here. svn path=/trunk/; revision=4327
Diffstat (limited to 'widgets')
-rw-r--r--widgets/e-table/ChangeLog5
-rw-r--r--widgets/e-table/e-table-selection-model.c37
-rw-r--r--widgets/table/e-table-selection-model.c37
3 files changed, 73 insertions, 6 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index c6348038fd..3a6e2d9fb6 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,5 +1,10 @@
2000-07-25 Christopher James Lahey <clahey@helixcode.com>
+ * e-table-selection-model.c: Fixed up the bit manipulation a bit
+ here.
+
+2000-07-25 Christopher James Lahey <clahey@helixcode.com>
+
* e-table-selection-model.c, e-table-selection-model.h: New files
for doing a selection model. Not finished yet and thus not in
Makefile.am.
diff --git a/widgets/e-table/e-table-selection-model.c b/widgets/e-table/e-table-selection-model.c
index 9a199f74e8..44ecc07979 100644
--- a/widgets/e-table/e-table-selection-model.c
+++ b/widgets/e-table/e-table-selection-model.c
@@ -42,8 +42,8 @@ model_row_inserted(ETableModel *etm, int row, ETableSelectionModel *etsm)
int i;
int offset;
if(etsm->row_count >= 0) {
- if ((etsm->row_count & 0x1f /*%32*/) == 0) {
- etsm->selection = e_realloc(etsm->selection, (etsm->row_count >> 5/* /32 */) + 1);
+ if ((etsm->row_count & 0x1f) == 0) {
+ etsm->selection = e_realloc(etsm->selection, (etsm->row_count >> 5) + 1);
etsm->selection[etsm->row_count >> 5] = 0;
}
box = row >> 5;
@@ -51,7 +51,38 @@ model_row_inserted(ETableModel *etm, int row, ETableSelectionModel *etsm)
etsm->selection[i] = (etsm->selection[i] >> 1) & (etsm->selection[i - 1] << 31)
}
offset = row & 0x1f;
- etsm->selection[i] = ((etsm->selection[i] >> (32 - offset)) << (31 - offset)) & ((etsm->selection[i] << offset) >> offset);
+ etsm->selection[i] = ((etsm->selection[i] >> (32 - offset)) << (32 - offset)) & ((etsm->selection[i] << offset) >> (offset + 1));
+ etsm->row_count ++;
+ }
+}
+
+static void
+model_row_deleted(ETableModel *etm, int row, ETableSelectionModel *etsm)
+{
+ int box;
+ int i;
+ int offset;
+ if(etsm->row_count >= 0) {
+ box = row >> 5;
+ last = etsm->row_count >> 5
+
+ offset = row & 0x1f;
+ if (offset)
+ etsm->selection[box] = ((etsm->selection[box] >> (32 - offset)) << (32 - offset)) & ((etsm->selection[box] << offset) >> (offset - 1));
+ else
+ etsm->selection[box] = etsm->selection[box] << 1;
+ if (box < last) {
+ etsm->selection[box] &= etsm->selection[box + 1] >> 31;
+
+ for (i = box + 1; i < last; i++) {
+ etsm->selection[i] = (etsm->selection[i] << 1) & (etsm->selection[i + 1] >> 31);
+ }
+ etsm->selection[i] = etsm->selection[i] << 1;
+ }
+ etsm->row_count --;
+ if ((etsm->row_count & 0x1f) == 0) {
+ etsm->selection = e_realloc(etsm->selection, etsm->row_count >> 5);
+ }
}
}
diff --git a/widgets/table/e-table-selection-model.c b/widgets/table/e-table-selection-model.c
index 9a199f74e8..44ecc07979 100644
--- a/widgets/table/e-table-selection-model.c
+++ b/widgets/table/e-table-selection-model.c
@@ -42,8 +42,8 @@ model_row_inserted(ETableModel *etm, int row, ETableSelectionModel *etsm)
int i;
int offset;
if(etsm->row_count >= 0) {
- if ((etsm->row_count & 0x1f /*%32*/) == 0) {
- etsm->selection = e_realloc(etsm->selection, (etsm->row_count >> 5/* /32 */) + 1);
+ if ((etsm->row_count & 0x1f) == 0) {
+ etsm->selection = e_realloc(etsm->selection, (etsm->row_count >> 5) + 1);
etsm->selection[etsm->row_count >> 5] = 0;
}
box = row >> 5;
@@ -51,7 +51,38 @@ model_row_inserted(ETableModel *etm, int row, ETableSelectionModel *etsm)
etsm->selection[i] = (etsm->selection[i] >> 1) & (etsm->selection[i - 1] << 31)
}
offset = row & 0x1f;
- etsm->selection[i] = ((etsm->selection[i] >> (32 - offset)) << (31 - offset)) & ((etsm->selection[i] << offset) >> offset);
+ etsm->selection[i] = ((etsm->selection[i] >> (32 - offset)) << (32 - offset)) & ((etsm->selection[i] << offset) >> (offset + 1));
+ etsm->row_count ++;
+ }
+}
+
+static void
+model_row_deleted(ETableModel *etm, int row, ETableSelectionModel *etsm)
+{
+ int box;
+ int i;
+ int offset;
+ if(etsm->row_count >= 0) {
+ box = row >> 5;
+ last = etsm->row_count >> 5
+
+ offset = row & 0x1f;
+ if (offset)
+ etsm->selection[box] = ((etsm->selection[box] >> (32 - offset)) << (32 - offset)) & ((etsm->selection[box] << offset) >> (offset - 1));
+ else
+ etsm->selection[box] = etsm->selection[box] << 1;
+ if (box < last) {
+ etsm->selection[box] &= etsm->selection[box + 1] >> 31;
+
+ for (i = box + 1; i < last; i++) {
+ etsm->selection[i] = (etsm->selection[i] << 1) & (etsm->selection[i + 1] >> 31);
+ }
+ etsm->selection[i] = etsm->selection[i] << 1;
+ }
+ etsm->row_count --;
+ if ((etsm->row_count & 0x1f) == 0) {
+ etsm->selection = e_realloc(etsm->selection, etsm->row_count >> 5);
+ }
}
}