[UPDATE] @Karl-Heinz - http://kh-rademacher.de/4d/OnArticleListPaint_2.html

11/01/2009 - 18:01 von Hermann Hippen | Report spam
Moin Moin :-),

Betrifft: http://kh-rademacher.de/4d/OnArticl...int_2.html

| - Code optimiert

8<[ OnArticleListPaint ]>8
Program OnArticleListPaint;
{$I ChangeNameInArticleList_include.ds}
// Version : 1.5
// Date : 11.07.2006
// Dialog : 2.0.15.1 beta 38
//
// 1.2 Amended for 2.0.13.1 beta 36
// 1.3 += doesn't fail if '(' in subject (by Dirk Straka)
// 1.4 += format date string (by Dirk Straka)
// 1.4.1 += Subject_was_only() (by Dirk Straka)
// 1.4.2 += TODAYSTR <none> (by Dirk Straka)
// 1.4.3 -= bug (failed with '(<anything>)' in author's name)
// += correct subject changes without 'was: ' will be shown, too
// (by Dirk Straka)
// 1.4.4 += format date string with 'Yesterday'
// (by Maik Prinz)
// 1.5 += format date string with 'n days ago' or weekday's name
// (by Dirk Straka)
//
// Remarks: - Set subject column to "%subjectnamechange%"
// and name column to "%threadindent%%fromname%"
// It's recommended to set date column's alignment to 'right'
//
// - Subject_was_only() does not need any From column.
//
// --> adjust column indexes and date format below ... <--
//
Const
//
// - configure column number of columns here.
// - if you don't have a <from> column,
// just set it's index to zero (0).
//
n_subject_column = 3; // <-- set subject column here!
n_from_column = 0; // <-- set from column here!
n_date_column = 4; // <-- set date column here!
//
// If you like to use dialog's default thread view (i. e. show
// '<subject> (<from>)' on subject changes), but want to see subjects
// of "correct" subject changes only (i. e. containing "was: "),
// then set this value to TRUE; normal FUp's display <from> only.
// BTW: Subjects containing "Re: " _and_ "was: " will be suppressed,
// too (as they seem to be incorrect replies):
//
// If set to FALSE, only <from> will be shown.
//
SHOW_SUBJECT_ON_CHANGE = TRUE; // set to TRUE or FALSE
//
// In DATEFMT you can define how to display the date.
// Hint: If you want to add normal text, use double quotes like this:
// DATEFMT = '"Date:" dd.mm.yy ("Time:" hh:nn)';
// If you want to see a single quote ('), use two, like this:
// DATEFMT = '"Date:" dd.mm.yy ("Time:" hh:nn "o''clock")';
//
DATEFMT = 'dd.mm.yy (hh:nn)'; // <-- set preferred date format
//
// TODAYSTR and TIMEFMT:
// If TODAYSTR is filled with a string,
// today's date will be replaced by this string;
// today's time will be formatted as spec. in TIMEFMT
// If TODAYSTR is set to '<none>',
// we will display no string for TODAY at all;
// today's time will be formatted as spec. in TIMEFMT
// If TODAYSTR is empty (''),
// today's date & time displays as defined in DATEFMT
// If YESTERDAYSTR is set to any non-empty string,
// handling will be the same acc. to TODAYSTR
//
TIMEFMT = '(hh:nn)'; // <-- set time format for today's msgs
TODAYSTR = 'Heute '; // <-- will result in ' Today (14:23)'
//TODAYSTR = '<none>'; // <-- will result in ' (14:23)'
YESTERDAYSTR = 'Gestern '; // <-- will result in 'Yesterday (14:23)'
//
// ORDINALDAYS
// If ORDINALDAYS is set to a value greater than 0,
// this many days back will be shown as e. g. 'n days ago'
// or with it's weekday name instead of the article's
// absolute date.
// Hint: ORDINALDAYS=1 will be overruled by YESTERDAYSTR!
//
ORDINALDAYS = 7; // <-- how many days back
// USE_ORDINALS (doesn't matter if ORDINALDAYS is set to 0)
// If USE_ORDINALS is set to ...
// TRUE: ORDINALPREFIX and -SUFFIX will be used (e. g. 'n days ago'):
// FALSE: WEEKDAY_n will be used (e. g. 'Wed' or 'Wednesday')
//
// ORDDAYPREFIX can be set to any text
// and will be shown before the count of days
// ORDDAYSUFFIX can be set to any text
// and will be shown beyond the count of days.
// Thus you can even display
// 'sent 4 days ago',
// by setting ORDDAYPREFIX to 'sent '
// and ORDDAYSUFFIX to ' days ago'
//
USE_ORDINALS = FALSE; // <-- results in ordinals e. g. 'n days ago'
//USE_ORDINALS = FALSE; // <-- results in weekday's name e. g. 'Wednesday'
//
// Settings for USE_ORDINALS = TRUE: Prefix and suffix
//
ORDDAYPREFIX = ''; // <-- text before daycount 'n' in 'n days ago'
ORDDAYSUFFIX = ' days ago '; // <-- text beyond daycount 'n' in 'n days ago'

// - //
// -- No user maintainable parts below this line //
// - //
Var Weekday : Array[1..7] Of String;
// Is the line indented?
// Indented lines start with a space
//
Function IsIndented( PaintString : WideString ) : Boolean;
Begin
result := (Copy( PaintString, 1, 1 ) = ' ');
End;
//
// Is this a correctly changed subject (i. e. contains "(was: "
//
Function IsSubjectChange( PaintString : WideString ) : Boolean;
Begin
Result := True;
If Not SHOW_SUBJECT_ON_CHANGE Then Result := False Else
If IsIndented( PaintString ) Then
Begin
If ( (Pos(' (was: ', PaintString) = 0) // ... there's no regular subject change ...
and (Pos(' (war: ', PaintString) = 0) // ... possibly in german ...
and (Pos(', was: ', PaintString) = 0) // ... or with comma ...
and (Pos(', war: ', PaintString) = 0)) // ... or with german comma. ;o)
Then Result := False; // no (correct) subject change found
// thus suppress subject
// suppress incorrect Re's.
If Result and (Pos('Re: ', Trim(PaintString)) = 1) Then Result := False;
// No "^Re: " - seems to be new (or a name), thus show it.
If Not (Pos('Re: ', Trim(PaintString)) = 1) Then Result := True;
End;
End;
//
// - Prerequisite: set Subject column to '%subjectnamechange%'
// - Check if there is a subject change, i. e. if there's a "(was: "
// in the subject (and no "^Re: "),
// - If so, display "<subject> (<from>)", otherwise just "<from>".
// - Strip (<from>) from "<subject> (<from>) if there's an extra
// from column (n_from_column > 0)
//
// - Will _NOT_ fail if subject has ' (', now. ;o)
//
Function Subject( PaintString : WideString ) : WideString;
Var
bpos, // pos of opening bracket
pbpos, // pos of previous opening bracket
flen, // length of <from> field
ilvl, // identation level (i. e. number of leading blanks)
i : Integer; // counter
s : WideString; // copy of 2 PaintString chars

Begin
bpos := 0; pbpos := 0;
Result := Copy( PaintString, 1, Length(PaintString) );
For i := 1 to Length( PaintString ) - 1 do // get start of <from> field
Begin
s := Copy( PaintString, i, 2 );
If s = ' (' Then
Begin
pbpos := bpos; // remember last bracket
bpos := i; // no break, to get the last '('
End;
If s = ' ' Then ilvl := ilvl + 1; // indentation levels
End;
If s = '))' Then bpos := pbpos; // Author with bracket in name
flen := Length( PaintString ) - bpos-2; // length of <from>

If IsIndented( PaintString ) Then // FollowUp -> strip subject if ...
If IsSubjectChange(PaintString) Then // ... there's no subject change
Result := Copy( PaintString, 1, Length(PaintString) ) // show complete subject
Else Begin // print <from> only
Result := '';
For i:=0 to ilvl do Result := Result + ' ';
If bpos > 0 Then Result := Result + Copy( PaintString, bpos+2, flen )
Else Result := Copy( PaintString, 1, Length(PaintString) );
End;
// have to strip from
If (n_from_column>0) and (bpos>0) and IsSubjectChange(PaintString) and Not IsIndented(PaintString)
then Result := Copy( PaintString, 1, bpos-1 );
End;
//
// From column = %threadindent%%fromname%
// Blank the column if it has a threadindent char at start
//
Function From( PaintString : WideString ) : WideString;
Begin
If IsIndented( PaintString ) Then Result := '' Else Result := PaintString;
End;
//
// Format date column following const DATEFMT (resp. TODAYSTR + TIMEFMT)
//
Function Date( Const PaintString : WideString ) : WideString;
Var daysago : Integer;
daystr : String;
y, m, d, dow : Word;
Begin
WEEKDAY[2]:='Montag '; WEEKDAY[3]:='Dienstag '; WEEKDAY[4]:='Mittwoch ';
WEEKDAY[5]:='Donnerstag '; WEEKDAY[6]:='Freitag '; WEEKDAY[7]:='Samstag ';
WEEKDAY[1]:='Sonntag ';
Result := FormatDateTime( DATEFMT, StrToDateTime(PaintString) ); // default
daysago := Trunc(Now()) - Trunc(StrToDateTime(PaintString));
case daysago of
0: daystr := TODAYSTR; // Today
1: daystr := YESTERDAYSTR; // Yesterday
Else // 2 or more days ago
If daysago <= ORDINALDAYS Then
If USE_ORDINALS = TRUE Then daystr := ORDDAYPREFIX + IntToStr(daysago) + ORDDAYSUFFIX Else
Begin
DecodeDateFully( StrToDateTime(PaintString), y, m, d, dow );
daystr := WEEKDAY[dow];
End;
End;
If Not (daystr = '') Then
If (daystr = '<none>') Then Result:=FormatDateTime(TIMEFMT,StrToDateTime(PaintString) )
Else Result:=daystr+' '+FormatDateTime(TIMEFMT,StrToDateTime(PaintString) );
End;
Function OnArticleListPaint(PaintString : WideString; ColumnIndex : Integer) : Widestring;
Begin

PaintString := Change_Name_In_ArticleList (PaintString);
Result := PaintString;
Case ColumnIndex of
n_subject_column: Result := Subject( PaintString );
n_from_column: Result := From ( PaintString );
n_date_column: Result := Date ( PaintString );
Else Result := PaintString;
End;
End;
Begin
End.
8<->8

Cu,
Hermann Hippen.
ž' š°º€ø?žžžžž?ø€º°š 'ž
ø€º° '<http://4ds.siteboard.eu>' °º€ø
'ž '40tude-Dialog Scriptwerkstatt' ž'
ø€º°' ž ž ø€º°ššššššš°º€øšž ž '°º€ø
 

Lesen sie die antworten

#1 Karl-Heinz Rademacher
11/01/2009 - 18:35 | Warnen spam
Hallo Hermann,

Hermann Hippen schrieb:
Betrifft: http://kh-rademacher.de/4d/OnArticl...int_2.html

| - Code optimiert



Du hast dein /"Soll"/ für Sonntag nun übererfüllt, mach mal eine Pause.

Danke. :-)

Mit freundlichen Gruß
Karl-Heinz Rademacher
,--[ Die 40tude Dialog - Seiten! ]
Š http://kh-rademacher.de/4d
Š http://kh-rademacher.de/face
`-

Ähnliche fragen