Re: [Lazarus] DragManager issues

2014-09-12 Thread Mattias Gaertner
On Fri, 12 Sep 2014 03:21:55 +0200
Hans-Peter Diettrich  wrote:

> I received messages from Mantis, that something changed in the bug 
> reports related to drag/drop. Please let me know when somebody wants to 
> put his hands on related code.

What messages?

Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DragManager issues

2014-09-12 Thread zeljko

On 09/12/2014 11:57 AM, Mattias Gaertner wrote:

On Fri, 12 Sep 2014 03:21:55 +0200
Hans-Peter Diettrich  wrote:


I received messages from Mantis, that something changed in the bug
reports related to drag/drop. Please let me know when somebody wants to
put his hands on related code.


What messages?


I guess about changing laztarget recently.

zeljko


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] StrToDate and DefaultFormatSettings

2014-09-12 Thread Leonardo M. Ramé

Hi, I need to convert strings with format "d-mmm-y" to TDateTime.

For example: '12-Sep-14'

Here's my code:

DefaultFormatSettings.DateSeparator:='-';
DefaultFormatSettings.ShortDateFormat:='D-MMM-Y';
DefaultFormatSettings.ShortMonthNames[1] := 'Jan';
DefaultFormatSettings.ShortMonthNames[2] := 'Feb';
DefaultFormatSettings.ShortMonthNames[3] := 'Mar';
DefaultFormatSettings.ShortMonthNames[4] := 'Apr';
DefaultFormatSettings.ShortMonthNames[5] := 'May';
DefaultFormatSettings.ShortMonthNames[6] := 'Jun';
DefaultFormatSettings.ShortMonthNames[7] := 'Jul';
DefaultFormatSettings.ShortMonthNames[8] := 'Aug';
DefaultFormatSettings.ShortMonthNames[9] := 'Sep';
DefaultFormatSettings.ShortMonthNames[10] := 'Oct';
DefaultFormatSettings.ShortMonthNames[11] := 'Nov';
DefaultFormatSettings.ShortMonthNames[12] := 'Dec';
lStr := DateToStr(now); // This works Ok.
lDate := StrToDate(lStr); // Here I get EConvert exception.

Am I missing something?.


--
Leonardo M. Ramé
http://leonardorame.blogspot.com

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Qt - Checkbox state images

2014-09-12 Thread Gabor Boros

2014.08.13. 15:45 keltezéssel, Gabor Boros írta:

My problem is, image for tbCheckBoxCheckedDisabled and
tbCheckBoxMixedDisabled is not grayed out under KDE. Why?


Hi All,

Reported as 26586 and fixed in trunk 46198.

Gabor

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] StrToDate and DefaultFormatSettings

2014-09-12 Thread Henry Vermaak
On Fri, Sep 12, 2014 at 08:18:36AM -0300, "Leonardo M. Ramé" wrote:
> Hi, I need to convert strings with format "d-mmm-y" to TDateTime.
> 
> For example: '12-Sep-14'
> 
> Here's my code:
> 
> DefaultFormatSettings.DateSeparator:='-';
> DefaultFormatSettings.ShortDateFormat:='D-MMM-Y';
> DefaultFormatSettings.ShortMonthNames[1] := 'Jan';
> DefaultFormatSettings.ShortMonthNames[2] := 'Feb';
> DefaultFormatSettings.ShortMonthNames[3] := 'Mar';
> DefaultFormatSettings.ShortMonthNames[4] := 'Apr';
> DefaultFormatSettings.ShortMonthNames[5] := 'May';
> DefaultFormatSettings.ShortMonthNames[6] := 'Jun';
> DefaultFormatSettings.ShortMonthNames[7] := 'Jul';
> DefaultFormatSettings.ShortMonthNames[8] := 'Aug';
> DefaultFormatSettings.ShortMonthNames[9] := 'Sep';
> DefaultFormatSettings.ShortMonthNames[10] := 'Oct';
> DefaultFormatSettings.ShortMonthNames[11] := 'Nov';
> DefaultFormatSettings.ShortMonthNames[12] := 'Dec';
> lStr := DateToStr(now); // This works Ok.
> lDate := StrToDate(lStr); // Here I get EConvert exception.
> 
> Am I missing something?.

Have you tried ScanDateTime()?  Then you don't need to fiddle with the
format settings.

Henry

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DragManager issues

2014-09-12 Thread Graeme Geldenhuys
On 12/09/14 11:18, zeljko wrote:
> I guess about changing laztarget recently.

Yeah, I got loads of those.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] StrToDate and DefaultFormatSettings

2014-09-12 Thread Howard Page-Clark

On 12/09/2014 13:04, Henry Vermaak wrote:

On Fri, Sep 12, 2014 at 08:18:36AM -0300, "Leonardo M. Ramé" wrote:

Hi, I need to convert strings with format "d-mmm-y" to TDateTime.

For example: '12-Sep-14'


This will accomplish the task.

function DatestrToDateTime(const aDate: string): TDateTime;
const
  sep = '-';
var
  el, p, im, id, iy: integer;
  d, m, y: word;
  dt: string;

  function FindMatch(const aMon: string): integer;
  var
i: integer;
  begin
DebugLn(['aMon=',aMon]);
Result:=-1;
for i:=Low(TMonthNameArray) to High(TMonthNameArray) do
 if SameText(aMon, DefaultFormatSettings.ShortMonthNames[i]) then begin
   Result:=i;
   Break;
 end;
  end;

begin
  dt:=Trim(aDate);
  el:=Length(dt);
  if (el < 7) or (el > 11) then
Exit(0.0);

  p:=Pos(sep, aDate);
  if (p=0) or (not TryStrToInt(Copy(dt, 1, p-1), id)) then
Exit(0.0);
  Delete(dt, 1, p);
  p:=Pos(sep, dt);
  if (p=0) then
Exit(0.0);

  im:=FindMatch(Copy(dt, 1, p-1));
  if (im < 1) then
Exit(0.0)
  else m:=im;

  Delete(dt, 1, p);
  if not TryStrToInt(dt, iy) then
Exit(0.0);
  d:=id;

  if (iy < 2000) then
Inc(iy, 2000);
  y:=iy;
  if not TryEncodeDate(y, m, d, Result) then
Result:=0.0;
end;


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Questions about SetLength

2014-09-12 Thread Agranov, Gennady
Hi,

Maybe it is not a correct list, but I am going to ask my question anyway :)

Is there a penalty for calling SetLength if array already has the length we 
need?

And if there is a penalty - is there a way to write "generic" function 
SmartSetLength(array,length) that will only call SetLength if necessary?

I hope other people find these questions interesting enough :)

Thanks,
Gena





--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Questions about SetLength

2014-09-12 Thread payl

Hi,

Maybe it is not a correct list, but I am going to ask my question anyway  
:)


Is there a penalty for calling SetLength if array already has the length  
we need?
Yes, there's always penalty for operations that you don't need. FPC will  
generate normal call, pass arguments, etc. I checked if SetLength with  
ansistring detects that requested size is same: It doesn't, it performs  
whole allocation and moving.


And if there is a penalty - is there a way to write "generic" function  
SmartSetLength(array,length) that will only call SetLength if necessary?
No. Compiler internally emits information about element size, how are they  
refcounted etc. as a pointer. Your best bet would be "hacking" FPC to emit  
such information to your procedure and then pass it to internal fpc  
setlength.
I would personally like it a lot if there was way to access "secret"  
information stored along with dynamic arrays/ansistrings, however it's not  
easy task. I think best bet would be storing secret information pointers  
along with refcount/length and then making functions that allow editing  
those data. Then we could have generic "dynamic array" type (I assume?).


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Questions about SetLength

2014-09-12 Thread Mattias Gaertner
On Fri, 12 Sep 2014 19:21:45 +0200
payl  wrote:

>[...]
> > Is there a penalty for calling SetLength if array already has the length  
> > we need?
> Yes, there's always penalty for operations that you don't need. FPC will  
> generate normal call, pass arguments, etc. I checked if SetLength with  
> ansistring detects that requested size is same: It doesn't, it performs  
> whole allocation and moving.

Not always.
Keep in mind that dynamic arrays have references and the array
memory itself is a reference counted structure.

SetLength creates a unique copy of the array, that means an array with
reference count 1. If it is already unique nothing is changed.
For example:

var
  A,B: array of string;
begin
  SetLength(A,10); // this allocates, A points to unique array
  A[0]:='bla'; // the A array is still unique
  SetLength(A,10); // no reallocation
  B:=A; // reference count increased to 2, not unique anymore
  SetLength(A,10); // reallocation to create a second array, now A
   // and B point to two unique arrays
  SetLength(A,10); // no reallocation
  SetLength(B,10); // no reallocation
end;


Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Help system questions

2014-09-12 Thread Reinier Olislagers
Hi list (and Laz devs),

I'm working on fixing some things in the help system.

1. function TChmHelpViewer.ShowNode(Node: THelpNode; var ErrMsg: string
  ): TShowHelpResult;
in
components\chmhelp\packages\idehelp\lazchmhelp.pas
has
  if Pos('file://', Node.URL) = 1 then
  begin
Result := PassTheBuck(Node, ErrMsg);
Exit;
  end;

Is ignoring the results of the PassTheBuck (nice name ;) ) call on
purpose or should it be changed to Exit(Result)?

2. My patch in
http://bugs.freepascal.org/view.php?id=26079
seems to work ok: for context-sensitive lhelp is started, hidden, loads
.chm files and then is shown once the files are loaded.
Then it shows the help for the requested item.

However, after a couple of seconds (which suggests a timeout error in
the IPC communication) the IDE starts the Code Browser, looking for the
identifier.

Getting a bit tired, so perhaps somebody can tell me where the fallback
to showing the code browser is coded...

Thanks,
Reinier

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus