Index: cprs/trunk/CPRS-Chart/fGraphProfiles.pas
===================================================================
--- cprs/trunk/CPRS-Chart/fGraphProfiles.pas	(revision 830)
+++ cprs/trunk/CPRS-Chart/fGraphProfiles.pas	(revision 1679)
@@ -86,4 +86,6 @@
     procedure lstSourcesEnter(Sender: TObject);
     procedure lstSourcesExit(Sender: TObject);
+    procedure lstOtherSourcesEnter(Sender: TObject);
+    procedure lstOtherSourcesExit(Sender: TObject);
     procedure radSourceAllClick(Sender: TObject);
 
@@ -96,11 +98,11 @@
       aListBox: TORListBox; var addtolist: boolean);
     procedure AssignHints;
-    procedure AssignProfile(aList: TStrings; aProfile: string; UserNum: integer; allitems: boolean);
-    procedure AssignProfilePre(aList: TStrings; var aProfile: string; UserNum: integer);
+    procedure AssignProfile(aList: TStrings; aProfile: string; UserNum: int64; allitems: boolean);
+    procedure AssignProfilePre(aList: TStrings; var aProfile: string; UserNum: int64);
     procedure AssignProfilePost(aList: TStrings; var aProfile, typedata: string);
     procedure CheckPublic;
     procedure FillSource(aList: TORListBox);
     function ProfileExists(aName, aType: string): boolean;
-    procedure btnAddAllClick(Sender: TObject);
+    procedure lstOtherSourcesChange(Sender: TObject);
   private
     FHintPauseTime: integer;
@@ -193,7 +195,5 @@
           GtslViews.Insert(0, VIEW_CURRENT + '^<current selections>^' + aSelections)
         else if Piece(GtslViews[0], '^', 1) <> VIEW_CURRENT then
-          GtslViews.Insert(0, VIEW_CURRENT + '^<current selections>^' + aSelections)
-        else if GtslViews.Count > 0 then
-          GtslViews[0] := VIEW_CURRENT + '^<current selections>^' + aSelections;
+          GtslViews.Insert(0, VIEW_CURRENT + '^<current selections>^' + aSelections);
       end;
       ResizeAnchoredFormToFont(frmGraphProfiles);
@@ -256,10 +256,10 @@
   begin
     radSourceAll.Checked := true;
-    //radSourcePat.Enabled := false;
+    radSourcePat.Enabled := false;
   end
   else if GtslData.Count < 1 then
   begin
     radSourceAll.Checked := true;
-    //radSourcePat.Enabled := false;
+    radSourcePat.Enabled := false;
   end;
   cboAllItems.Visible := radSourceAll.Checked;
@@ -304,5 +304,5 @@
   begin
     lstOtherSources.Tag := BIG_NUMBER;
-    lstSourcesChange(lstOtherSources);
+    lstOtherSourcesChange(lstOtherSources);
   end;
 end;
@@ -310,24 +310,17 @@
 procedure TfrmGraphProfiles.lstSourcesChange(Sender: TObject);
 var
+// CQ #15852 - Changed UserNum to Int64 for a long DUZ - JCS
   UserNum: int64;
   filetype, typedata: string;
-  aListBox, oppositeListBox: TORListBox;
-  viewselected: boolean;
+  aListBox: TORListBox;
 begin
   CheckPublic;
   aListBox := (Sender as TORListBox);
-  if aListBox = lstSources then
-  begin
-    oppositeListBox := lstOtherSources;
-    UserNum := User.DUZ;
-  end
-  else
-  begin
-    oppositeListBox := lstSources;
-    UserNum := cboUser.ItemID;
-  end;
-  if aListBox.Tag <> BIG_NUMBER then
+  if aListBox = lstOtherSources then
     exit;
-  oppositeListBox.ItemIndex := -1;
+  if lstSources.Tag <> BIG_NUMBER then
+    exit;
+  UserNum := User.DUZ;
+  lstOtherSources.ItemIndex := -1;
   cboAllItems.Items.Clear;
   cboAllItems.Text := '';
@@ -348,30 +341,13 @@
   or (filetype = VIEW_CURRENT) then
   begin
-    RadSourceAll.Checked := true;
-    RadSourcePat.Enabled := false;
     AssignProfile(cboAllItems.Items, typedata, UserNum, false);
     FastAssign(cboAllItems.Items, lstItemsSelection.Items);
-    viewselected := true;
   end
   else
   begin
-    RadSourcePat.Enabled := true;
     AllItemsBefore(typedata);
     AllItemsAfter(filetype, typedata);
-    viewselected := false;
-  end;
-  lstItemsSelection.Visible := viewselected or radSourcePat.Checked;
-  cboAllItems.Visible := not lstItemsSelection.Visible;
+  end;
   cboAllItemsChange(cboAllItems);
-end;
-
-procedure TfrmGraphProfiles.lstSourcesEnter(Sender: TObject);
-begin
-  (Sender as TORListBox).Tag := BIG_NUMBER;
-end;
-
-procedure TfrmGraphProfiles.lstSourcesExit(Sender: TObject);
-begin
-  (Sender as TORListBox).Tag := 0;
 end;
 
@@ -387,8 +363,69 @@
   begin
     if lstItemsSelection.Items.Count < 1 then exit;
-    //lstItemsSelection.Selected[0] := true;
+    lstItemsSelection.Selected[0] := true;
     cboAllItemsClick(lstItemsSelection);
-    btnAddAllClick(self);
-  end;
+  end;
+end;
+
+procedure TfrmGraphProfiles.lstSourcesEnter(Sender: TObject);
+begin
+  lstSources.Tag := BIG_NUMBER;
+end;
+
+procedure TfrmGraphProfiles.lstSourcesExit(Sender: TObject);
+begin
+  lstSources.Tag := 0;
+end;
+
+procedure TfrmGraphProfiles.lstOtherSourcesChange(Sender: TObject);
+var
+// CQ #15852 - Changed UserNum to Int64 for a long DUZ - JCS
+  UserNum: int64;
+  filetype, typedata: string;
+  aListBox: TORListBox;
+begin
+  CheckPublic;
+  aListBox := (Sender as TORListBox);
+  if aListBox = lstSources then
+    exit;
+  if lstOtherSources.Tag <> BIG_NUMBER then
+    exit;
+  UserNum := cboUser.ItemID;
+  lstSources.ItemIndex := -1;
+  cboAllItems.Items.Clear;
+  cboAllItems.Text := '';
+  if aListBox.ItemIndex = -1 then exit;
+  typedata :=  aListBox.Items[aListBox.ItemIndex];
+  if pos(LLS_FRONT, typedata) > 0 then  // <clear all selections>
+  begin
+    lstItemsSelection.Clear;
+    cboAllItems.Items.Clear;
+    cboAllItems.Text := '';
+    exit;
+  end;
+  filetype := Piece(typedata, '^', 1);
+  if (filetype = VIEW_PERSONAL)
+  or (filetype = VIEW_PUBLIC)
+  or (filetype = VIEW_LABS) then
+  begin
+    AssignProfile(cboAllItems.Items, typedata, UserNum, false);
+    FastAssign(cboAllItems.Items, lstItemsSelection.Items);
+  end
+  else
+  begin
+    AllItemsBefore(typedata);
+    AllItemsAfter(filetype, typedata);
+  end;
+  cboAllItemsChange(cboAllItems);
+end;
+
+procedure TfrmGraphProfiles.lstOtherSourcesEnter(Sender: TObject);
+begin
+  lstOtherSources.Tag := BIG_NUMBER;
+end;
+
+procedure TfrmGraphProfiles.lstOtherSourcesExit(Sender: TObject);
+begin
+  lstOtherSources.Tag := 0;
 end;
 
@@ -409,6 +446,6 @@
 
 procedure TfrmGraphProfiles.cboAllItemsChange(Sender: TObject);
-//var
- //astring: string;
+var
+ astring: string;
 begin
  if (Sender is TORListBox) then
@@ -420,6 +457,6 @@
    btnAddAll.Enabled := lstItemsSelection.Items.Count > 0;
    btnAdd.Enabled := lstItemsSelection.ItemIndex > -1;
-   //if btnAdd.Enabled then
-     //astring := lstItemsSelection.Items[lstItemsSelection.ItemIndex];
+   if btnAdd.Enabled then
+     astring := lstItemsSelection.Items[lstItemsSelection.ItemIndex];
  end
  else
@@ -431,6 +468,4 @@
 
 procedure TfrmGraphProfiles.cboAllItemsClick(Sender: TObject);
-var
-  i: integer;
 begin
   if Sender is TButton then
@@ -439,31 +474,12 @@
     begin
       if Sender = btnAddAll then
-      begin
-        for i := 0 to lstItemsSelection.Items.Count - 1 do
-        begin
-          lstItemsSelection.Selected[i] := true;
-          lstItemsSelection.ItemIndex := i;
-          ListBoxSetup(lstItemsSelection);
-        end;
-        lstItemsSelection.Clear;
-      end
-      else
-      begin
-        lstItemsDisplayed.ItemIndex := 0;
-        ListBoxSetup(lstItemsSelection);
-      end;
-      lstItemsDisplayedChange(self);
-      CheckToClear;
-      exit;
+        lstItemsSelection.ItemIndex := 0;
+      Sender := lstItemsSelection;
     end
     else
     begin
-      if Sender = btnAdd then
-      begin
-        ComboBoxSetup(cboAllItems);
-        lstItemsDisplayedChange(self);
-        CheckToClear;
-        exit;
-      end;
+      if Sender = btnAddAll then
+        cboAllItems.ItemIndex := 0;
+      Sender := cboAllItems;
     end;
   end;
@@ -509,19 +525,4 @@
   QualifierDelete(line);
   lstItemsDisplayedChange(self);
-end;
-
-procedure TfrmGraphProfiles.btnAddAllClick(Sender: TObject);
-begin
-  if cboAllItems.Visible then
-  begin
-    if cboAllItems.Items.Count < 1 then exit;
-    cboAllItems.ItemIndex := 0;
-    cboAllItemsClick(cboAllItems);
-  end
-  else
-  begin
-    if lstItemsSelection.Items.Count < 1 then exit;
-    cboAllItemsClick(btnAddAll);
-  end;
 end;
 
@@ -978,5 +979,5 @@
     else
       AddToList(selection, lstItemsDisplayed);
-    //if ItemIndex = 0 then Clear;        //profile or type <any>
+    if ItemIndex = 0 then Clear;        //profile or type <any>
     ItemIndex := -1;
   end;
@@ -1135,5 +1136,5 @@
 var
   i: integer;
-  itemdata, itemname: string;
+  itemdata: string;
 begin
   with lstItemsSelection.Items do
@@ -1141,12 +1142,6 @@
     Clear;
     lstItemsSelection.Sorted := true;
-    itemname := Piece(typedata, '^', 3);
-    if copy(itemname, 1, 1) = ' ' then
-    begin
-      itemname := copy(itemname, 2, length(itemname));   // strip preceding space
-      typedata := '0^' + Piece(typedata, '^', 2) + '^ ' + itemname;
-    end
-    else
-      typedata := '0^' + Piece(typedata, '^', 1) + '^ ' + itemname;
+    //typedata := '0^' + Piece(typedata, '^', 1) + '^ ' + Piece(typedata, '^', 2) + ' <any>';
+    typedata := '0^' + Piece(typedata, '^', 1) + '^ ' + Piece(typedata, '^', 3);
     Insert(0, typedata);
     Insert(1, '^' + LLS_LINE);
@@ -1295,5 +1290,6 @@
 end;
 
-procedure TfrmGraphProfiles.AssignProfile(aList: TStrings; aProfile: string; UserNum: integer; allitems: boolean);
+// CQ #15852 - Changed UserNum to Int64 for a long DUZ - JCS
+procedure TfrmGraphProfiles.AssignProfile(aList: TStrings; aProfile: string; UserNum: int64; allitems: boolean);
 var
   i, k: integer;
@@ -1391,5 +1387,6 @@
 end;
 
-procedure TfrmGraphProfiles.AssignProfilePre(aList: TStrings; var aProfile: string; UserNum: integer);
+// CQ #15852 - Changed UserNum to Int64 for a long DUZ - JCS
+procedure TfrmGraphProfiles.AssignProfilePre(aList: TStrings; var aProfile: string; UserNum: int64);
 var
   i: integer;
@@ -1473,5 +1470,7 @@
 procedure TfrmGraphProfiles.FillSource(aList: TORListBox);
 var
-  i, UserNum: integer;
+  i: integer;
+// CQ #15852 - Changed UserNum to Int64 for a long DUZ - JCS
+  UserNum: Int64;
   dfntype, firstline, listline: string;
 begin
@@ -1648,5 +1647,5 @@
   if length(profilename) > 0 then
     lblSave.Hint := profilename;
-  //btnClearClick(self);
+  btnClearClick(self);
   lstScratch.Items.Clear;
   lstSources.Items.Clear;
