aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-07-26 04:55:07 +0800
committerChris Lahey <clahey@src.gnome.org>2000-07-26 04:55:07 +0800
commit120687c8a8b3b7df579f2dcad8badefb67e4d30b (patch)
tree5dfbe79433eff40d91083d1b74ac7ad8f227b40c /widgets
parentcbaec9459607a60bf56a727f74ffd45de0543207 (diff)
downloadgsoc2013-evolution-120687c8a8b3b7df579f2dcad8badefb67e4d30b.tar
gsoc2013-evolution-120687c8a8b3b7df579f2dcad8badefb67e4d30b.tar.gz
gsoc2013-evolution-120687c8a8b3b7df579f2dcad8badefb67e4d30b.tar.bz2
gsoc2013-evolution-120687c8a8b3b7df579f2dcad8badefb67e4d30b.tar.lz
gsoc2013-evolution-120687c8a8b3b7df579f2dcad8badefb67e4d30b.tar.xz
gsoc2013-evolution-120687c8a8b3b7df579f2dcad8badefb67e4d30b.tar.zst
gsoc2013-evolution-120687c8a8b3b7df579f2dcad8badefb67e4d30b.zip
Added comments to the bit field code.
2000-07-25 Christopher James Lahey <clahey@helixcode.com> * e-table-selection-model.c: Added comments to the bit field code. * e-table-selection-model.h: Made the selection data guint32s. svn path=/trunk/; revision=4329
Diffstat (limited to 'widgets')
-rw-r--r--widgets/e-table/ChangeLog10
-rw-r--r--widgets/e-table/e-table-selection-model.c15
-rw-r--r--widgets/e-table/e-table-selection-model.h2
-rw-r--r--widgets/table/e-table-selection-model.c15
-rw-r--r--widgets/table/e-table-selection-model.h2
5 files changed, 38 insertions, 6 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index 3a6e2d9fb6..6b8b1f6918 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,5 +1,15 @@
2000-07-25 Christopher James Lahey <clahey@helixcode.com>
+ * e-table-selection-model.c: Added comments to the bit data.
+
+ * e-table-selection-model.h: Made the selection data guint32s.
+
+2000-07-25 Christopher James Lahey <clahey@helixcode.com>
+
+ * e-table-selection-model.c: More fixes.
+
+2000-07-25 Christopher James Lahey <clahey@helixcode.com>
+
* e-table-selection-model.c: Fixed up the bit manipulation a bit
here.
diff --git a/widgets/e-table/e-table-selection-model.c b/widgets/e-table/e-table-selection-model.c
index b8c4d65d2e..6bdfa90990 100644
--- a/widgets/e-table/e-table-selection-model.c
+++ b/widgets/e-table/e-table-selection-model.c
@@ -44,19 +44,26 @@ model_row_inserted(ETableModel *etm, int row, ETableSelectionModel *etsm)
if(etsm->row_count >= 0) {
guint32 bitmask1 = 0xffff;
guint32 bitmask2;
+
+ /* Add another word if needed. */
if ((etsm->row_count & 0x1f) == 0) {
etsm->selection = e_realloc(etsm->selection, (etsm->row_count >> 5) + 1);
etsm->selection[etsm->row_count >> 5] = 0;
}
+
+ /* The box is the word that our row is in. */
box = row >> 5;
+ /* Shift all words to the right of our box right one bit. */
for (i = etsm->row_count >> 5; i > box; i--) {
etsm->selection[i] = (etsm->selection[i] >> 1) | (etsm->selection[i - 1] << 31)
}
+ /* Build bitmasks for the left and right half of the box */
offset = row & 0x1f;
bitmask1 = bitmask1 << (32 - offset);
bitmask2 = ~bitmask1;
- etsm->selection[i] = (etsm->selection[i] & bitmask1) | ((etsm->selection[i] & bitmask2) >> 1);
+ /* Shift right half of box one bit to the right. */
+ etsm->selection[box] = (etsm->selection[box] & bitmask1) | ((etsm->selection[box] & bitmask2) >> 1);
etsm->row_count ++;
}
}
@@ -71,13 +78,16 @@ model_row_deleted(ETableModel *etm, int row, ETableSelectionModel *etsm)
guint32 bitmask1 = 0xffff;
guint32 bitmask2;
box = row >> 5;
- last = etsm->row_count >> 5
+ last = etsm->row_count >> 5;
+ /* Build bitmasks for the left and right half of the box */
offset = row & 0x1f;
bitmask1 = bitmask1 << (32 - offset);
bitmask2 = (~bitmask1) >> 1;
+ /* Shift right half of box one bit to the left. */
etsm->selection[box] = (etsm->selection[box] & bitmask1) | ((etsm->selection[box] & bitmask2) << 1);
+ /* Shift all words to the right of our box left one bit. */
if (box < last) {
etsm->selection[box] &= etsm->selection[box + 1] >> 31;
@@ -87,6 +97,7 @@ model_row_deleted(ETableModel *etm, int row, ETableSelectionModel *etsm)
etsm->selection[i] = etsm->selection[i] << 1;
}
etsm->row_count --;
+ /* Remove the last word if not needed. */
if ((etsm->row_count & 0x1f) == 0) {
etsm->selection = e_realloc(etsm->selection, etsm->row_count >> 5);
}
diff --git a/widgets/e-table/e-table-selection-model.h b/widgets/e-table/e-table-selection-model.h
index 8b7d0a0507..7fb6158ad2 100644
--- a/widgets/e-table/e-table-selection-model.h
+++ b/widgets/e-table/e-table-selection-model.h
@@ -23,7 +23,7 @@ typedef struct {
ETableModel *model;
gint row_count;
- guint *selection;
+ guint32 *selection;
gint cursor_row;
gint cursor_col;
diff --git a/widgets/table/e-table-selection-model.c b/widgets/table/e-table-selection-model.c
index b8c4d65d2e..6bdfa90990 100644
--- a/widgets/table/e-table-selection-model.c
+++ b/widgets/table/e-table-selection-model.c
@@ -44,19 +44,26 @@ model_row_inserted(ETableModel *etm, int row, ETableSelectionModel *etsm)
if(etsm->row_count >= 0) {
guint32 bitmask1 = 0xffff;
guint32 bitmask2;
+
+ /* Add another word if needed. */
if ((etsm->row_count & 0x1f) == 0) {
etsm->selection = e_realloc(etsm->selection, (etsm->row_count >> 5) + 1);
etsm->selection[etsm->row_count >> 5] = 0;
}
+
+ /* The box is the word that our row is in. */
box = row >> 5;
+ /* Shift all words to the right of our box right one bit. */
for (i = etsm->row_count >> 5; i > box; i--) {
etsm->selection[i] = (etsm->selection[i] >> 1) | (etsm->selection[i - 1] << 31)
}
+ /* Build bitmasks for the left and right half of the box */
offset = row & 0x1f;
bitmask1 = bitmask1 << (32 - offset);
bitmask2 = ~bitmask1;
- etsm->selection[i] = (etsm->selection[i] & bitmask1) | ((etsm->selection[i] & bitmask2) >> 1);
+ /* Shift right half of box one bit to the right. */
+ etsm->selection[box] = (etsm->selection[box] & bitmask1) | ((etsm->selection[box] & bitmask2) >> 1);
etsm->row_count ++;
}
}
@@ -71,13 +78,16 @@ model_row_deleted(ETableModel *etm, int row, ETableSelectionModel *etsm)
guint32 bitmask1 = 0xffff;
guint32 bitmask2;
box = row >> 5;
- last = etsm->row_count >> 5
+ last = etsm->row_count >> 5;
+ /* Build bitmasks for the left and right half of the box */
offset = row & 0x1f;
bitmask1 = bitmask1 << (32 - offset);
bitmask2 = (~bitmask1) >> 1;
+ /* Shift right half of box one bit to the left. */
etsm->selection[box] = (etsm->selection[box] & bitmask1) | ((etsm->selection[box] & bitmask2) << 1);
+ /* Shift all words to the right of our box left one bit. */
if (box < last) {
etsm->selection[box] &= etsm->selection[box + 1] >> 31;
@@ -87,6 +97,7 @@ model_row_deleted(ETableModel *etm, int row, ETableSelectionModel *etsm)
etsm->selection[i] = etsm->selection[i] << 1;
}
etsm->row_count --;
+ /* Remove the last word if not needed. */
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.h b/widgets/table/e-table-selection-model.h
index 8b7d0a0507..7fb6158ad2 100644
--- a/widgets/table/e-table-selection-model.h
+++ b/widgets/table/e-table-selection-model.h
@@ -23,7 +23,7 @@ typedef struct {
ETableModel *model;
gint row_count;
- guint *selection;
+ guint32 *selection;
gint cursor_row;
gint cursor_col;