Преглед изворни кода

Fix status bar display of records for select queries in query window

Reinier Olislagers пре 11 година
родитељ
комит
e41ebdf7f4
3 измењених фајлова са 28 додато и 37 уклоњено
  1. 1 1
      querywindow.lfm
  2. 3 1
      querywindow.lrs
  3. 24 35
      querywindow.pas

+ 1 - 1
querywindow.lfm

@@ -2676,7 +2676,7 @@ object fmQueryWindow: TfmQueryWindow
       OnClick = lmCopyAllClick
     end
     object lmExportAsComma: TMenuItem
-      Caption = 'Export Grid as Comma Delimited'
+      Caption = 'Export Grid as Comma Delemited'
       OnClick = lmExportAsCommaClick
     end
     object lmExportAsHTML: TMenuItem

+ 3 - 1
querywindow.lrs

@@ -1,3 +1,5 @@
+{ This is an automatically generated lazarus resource file }
+
 LazarusResources.Add('TfmQueryWindow','FORMDATA',[
   'TPF0'#14'TfmQueryWindow'#13'fmQueryWindow'#4'Left'#3#21#2#6'Height'#3'Y'#2#3
   +'Top'#3#204#0#5'Width'#3#208#2#13'ActiveControl'#7#6'Panel1'#7'Caption'#6#13
@@ -2502,7 +2504,7 @@ LazarusResources.Add('TfmQueryWindow','FORMDATA',[
   +'ion'#6#10'Copy field'#7'OnClick'#7#15'lmCopyCellClick'#0#0#9'TMenuItem'#9'l'
   +'mCopyAll'#7'Caption'#6#15'Copy all result'#7'OnClick'#7#14'lmCopyAllClick'#0
   +#0#9'TMenuItem'#15'lmExportAsComma'#7'Caption'#6#30'Export Grid as Comma Del'
-  +'imited'#7'OnClick'#7#20'lmExportAsCommaClick'#0#0#9'TMenuItem'#14'lmExportA'
+  +'emited'#7'OnClick'#7#20'lmExportAsCommaClick'#0#0#9'TMenuItem'#14'lmExportA'
   +'sHTML'#7'Caption'#6#19'Export Grid as HTML'#7'OnClick'#7#19'lmExportAsHTMLC'
   +'lick'#0#0#0#14'TSynCompletion'#14'SynCompletion1'#8'Position'#2#0#13'LinesI'
   +'nWindow'#2#6#13'SelectedColor'#7#11'clHighlight'#13'CaseSensitive'#8#5'Widt'

+ 24 - 35
querywindow.pas

@@ -592,7 +592,6 @@ var
   Ctl: TControl;
   ParentPanel: TPanel;
 begin
-  //todo: priority high test whether this works
   // The page has a panel that contains the button
   ParentPanel:=nil;
   for i:= 0 to pgOutputPageCtl.ActivePage.ControlCount-1 do
@@ -1968,12 +1967,20 @@ begin
   SaveDialog1.DefaultExt:= '.htm';
   SqlQuery:= nil;
   SqlQuery:= GetCurrentSelectQuery;
+
+  // Check for results being present:
   if not(assigned(SqlQuery)) then
-    ShowMessage('There is no record set in result')
-  else
+  begin
+    MessageDlg('There is no record set in result', mtError, [mbOk], 0);
+    exit;
+  end;
   if (not SQLQuery.Active) or (SQLQuery.RecordCount = 0) then
-    MessageDlg('No data', mtError, [mbOk], 0)
-  else // Valid data, let's try to save:
+  begin
+    MessageDlg('No data', mtError, [mbOk], 0);
+    exit;
+  end;
+
+  // We know there's valid data, let's try to save:
   if SaveDialog1.Execute then
   begin
     SQLQuery.DisableControls;
@@ -2111,46 +2118,28 @@ end;
 
 procedure TfmQueryWindow.QueryAfterScroll(DataSet: TDataSet);
 var
+  Ctl: TControl;
   TabSheet: TTabSheet;
   i: Integer;
 begin
   TabSheet:= nil;
 
   // Get DataSet's TTabsheet
-  //todo: high
-  //showmessage('todo: priority high same approach as apply button');
-  {
-  for i:= 0 to High(FResultControls) do
-  begin
-    if (FResultControls[i] <> nil) and
-      (DataSet = FResultControls[i]) then
-    begin
-      TabSheet:= FParentResultControls[i] as TTabSheet;
-      Break;
-    end;
-  end;
-  }
-  // Search for status bar inside current query result TTabSheet
-  if TabSheet <> nil then
+  // The query object's tag should be the tab index number
+  if (Dataset is TSQLQuery) then
+    TabSheet:= pgOutputPageCtl.Pages[TSQLQuery(DataSet).Tag];
+
+  if assigned(TabSheet) then
   begin
-    //todo: high
-    //showmessage('todo: priority high same approach as apply button');
-    {
-    for i:= 0 to High(FResultControls) do
+    for i:= 0 to TabSheet.ControlCount-1 do
     begin
-      if FResultControls[i] <> nil then
-      begin
-        if (FParentResultControls[i] <> nil) and ((FParentResultControls[i] as TTabSheet) = TabSheet)
-          and (FResultControls[i] is TStatusBar) then
-        begin
-          // Display current record and number of total records in status bar
-          (FResultControls[i] as TStatusBar).SimpleText:= IntToStr(DataSet.RecordCount) +
+      Ctl:= TabSheet.Controls[i];
+      if (Ctl is TStatusBar) then
+        // Display current record and number of total records in status bar
+        TStatusBar(Ctl).SimpleText:= IntToStr(DataSet.RecordCount) +
           ' records fetched. At record # ' + IntToStr(DataSet.RecNo);
-          break;
-        end;
-      end;
+        break;
     end;
-    }
   end;
 end;