Browse Source

Initial batch count support in AnnotationButton

Neal Wilson 6 years ago
parent
commit
7598df7050
1 changed files with 57 additions and 4 deletions
  1. 57
    4
      src/typica.w

+ 57
- 4
src/typica.w View File

@@ -10711,10 +10711,12 @@ be applied to the roasting log quickly. This is the purpose of the
10711 10711
 class AnnotationButton : public QPushButton@/
10712 10712
 {@t\1@>@/
10713 10713
     Q_OBJECT@;
10714
+	QString noteTemplate;
10714 10715
     QString note;
10715 10716
     int tc;
10716 10717
     int ac;
10717 10718
     int count;
10719
+	QString batch;
10718 10720
     public:@/
10719 10721
         AnnotationButton(const QString &text, QWidget *parent = NULL);@/
10720 10722
     @t\4@>public slots@t\kern-3pt@>:@/
@@ -10723,6 +10725,8 @@ class AnnotationButton : public QPushButton@/
10723 10725
         void setAnnotationColumn(int annotationcolumn);
10724 10726
         void annotate();
10725 10727
         void resetCount();
10728
+		void resetBatch();
10729
+		void incrementBatch();
10726 10730
     signals:@/
10727 10731
         void annotation(QString annotation, int tempcolumn,
10728 10732
                         int notecolumn);@t\2@>@/
@@ -10735,7 +10739,8 @@ button should exhibit when clicked.
10735 10739
 
10736 10740
 @<AnnotationButton Implementation@>=
10737 10741
 AnnotationButton::AnnotationButton(const QString &text, QWidget *parent) :
10738
-    QPushButton(text, parent), note(""), tc(0), ac(0), count(0)@/
10742
+    QPushButton(text, parent), noteTemplate(""), note(""), tc(0), ac(0),
10743
+	count(0), batch("A")@/
10739 10744
 {
10740 10745
     connect(this, SIGNAL(clicked()), this, SLOT(annotate()));
10741 10746
 }
@@ -10779,11 +10784,26 @@ void AnnotationButton::setAnnotationColumn(int annotationcolumn)
10779 10784
 
10780 10785
 void AnnotationButton::setAnnotation(const QString &annotation)
10781 10786
 {
10782
-    note = annotation;
10787
+    noteTemplate = annotation;
10788
+	@<Replace batch holder in template@>@;
10783 10789
 }
10784 10790
 
10785
-@ Finally, in the case of counting annotations, there should be a way to reset
10786
-the number used in the annotation.
10791
+@ Note templates that contain "%A" should have that replaced with a
10792
+string that can be incremented between batches.
10793
+
10794
+@<Replace batch holder in template@>=
10795
+int batchReplace = noteTemplate.indexOf("%A");
10796
+if(batchReplace >= 0)
10797
+{
10798
+	note = noteTemplate.replace(batchReplace, 2, batch);
10799
+}
10800
+else
10801
+{
10802
+	note = noteTemplate;
10803
+}
10804
+
10805
+@ In the case of counting annotations, there should be a way to reset
10806
+the number and batch used in the annotation.
10787 10807
 
10788 10808
 @<AnnotationButton Implementation@>=
10789 10809
 void AnnotationButton::resetCount()
@@ -10791,6 +10811,39 @@ void AnnotationButton::resetCount()
10791 10811
     count = 0;
10792 10812
 }
10793 10813
 
10814
+void AnnotationButton::resetBatch()
10815
+{
10816
+	batch = "A";
10817
+}
10818
+
10819
+@ The batch sequence starts at A through Z, then proceeds to AA through AZ
10820
+and so on.
10821
+
10822
+@<AnnotationButton Implementation@>=
10823
+void AnnotationButton::incrementBatch()
10824
+{
10825
+	int position = batch.size() - 1;
10826
+increment:
10827
+	if(batch[position] != 'Z')
10828
+	{
10829
+		batch[position] = batch[position].unicode() + 1;
10830
+	}
10831
+	else
10832
+	{
10833
+		batch[position] = 'A';
10834
+		if(position > 0)
10835
+		{
10836
+			position--;
10837
+			goto increment;
10838
+		}
10839
+		else
10840
+		{
10841
+			batch.append("A");
10842
+		}
10843
+	}
10844
+	@<Replace batch holder in template@>@;
10845
+}
10846
+
10794 10847
 @ A script constructor is needed to allow an |AnnotationButton| to be created
10795 10848
 from a script.
10796 10849
 

Loading…
Cancel
Save