summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2008-06-11 21:01:51 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2008-06-11 21:01:51 +0200
commit30a547b8f4f9f01b8270d653c7ac3784a8ce981c (patch)
treeb8b9523386f5563bac771101b1ee3b112fb60f9c
parent540cad830d639a57d9effe9b18283b3bb8cd7a07 (diff)
downloadtuxcmd-30a547b8f4f9f01b8270d653c7ac3784a8ce981c.tar.xz
Allow optional sorting directories like files
-rw-r--r--UConfig.pas10
-rw-r--r--UCoreUtils.pas46
-rw-r--r--UMain.pas11
-rw-r--r--UPreferences.pas40
4 files changed, 64 insertions, 43 deletions
diff --git a/UConfig.pas b/UConfig.pas
index d4eae70..0b2565b 100644
--- a/UConfig.pas
+++ b/UConfig.pas
@@ -25,8 +25,8 @@ uses Classes, ULocale;
resourcestring
ConstAppTitle = 'Tux Commander';
- ConstAboutVersion = '0.6.41-dev';
- ConstAboutBuildDate = '2008-06-10';
+ ConstAboutVersion = '0.6.42-dev';
+ ConstAboutBuildDate = '2008-06-11';
{$IFDEF __FPC__}
{$INCLUDE fpcver.inc}
@@ -95,7 +95,7 @@ var ConfPanelSep, ConfRowHeight, ConfRowHeightReal, ConfNumHistoryItems,
ConfLinkItemDefaultColors, ConfDotFileItemDefaultColors, ConfLynxLikeMotion, ConfSizeGroupRequestZeroDigits,
ConfDisableFileTips, ConfInsMoveDown, ConfSpaceMovesDown, ConfShowFuncButtons, ConfSelectAllDirs, ConfOctalPerm: boolean;
ConfMounterUseFSTab, ConfShowTextUIDs, ConfMounterPushDown, ConfSavePanelTabs, ConfDuplicateTabWarning,
- ConfOpenConnectionsWarning: boolean;
+ ConfOpenConnectionsWarning, ConfSortDirectoriesLikeFiles: boolean;
ConfShowMounterBar: integer;
ConfColumnSizes, ConfColumnIDs: array[1..ConstNumPanelColumns] of integer;
@@ -243,6 +243,7 @@ begin
ConfCustomDateFormat := '%x';
ConfCustomTimeFormat := '%X';
ConfQuickSearchActivationKey := 0;
+ ConfSortDirectoriesLikeFiles := False;
// Setup default values for colors
@@ -466,7 +467,7 @@ begin
ConfCustomDateFormat := IniFile.ReadString(ConfProfileName, 'CustomDateFormat', ConfCustomDateFormat);
ConfCustomTimeFormat := IniFile.ReadString(ConfProfileName, 'CustomTimeFormat', ConfCustomTimeFormat);
ConfQuickSearchActivationKey := IniFile.ReadInteger(ConfProfileName, 'QuickSearchActivationKey', ConfQuickSearchActivationKey);
-
+ ConfSortDirectoriesLikeFiles := IniFile.ReadBool(ConfProfileName, 'SortDirectoriesLikeFiles', ConfSortDirectoriesLikeFiles);
SearchForDefaultApps;
@@ -555,6 +556,7 @@ begin
IniFile.WriteString(ConfProfileName, 'CustomDateFormat', ConfCustomDateFormat);
IniFile.WriteString(ConfProfileName, 'CustomTimeFormat', ConfCustomTimeFormat);
IniFile.WriteInteger(ConfProfileName, 'QuickSearchActivationKey', ConfQuickSearchActivationKey);
+ IniFile.WriteBool(ConfProfileName, 'SortDirectoriesLikeFiles', ConfSortDirectoriesLikeFiles);
except
diff --git a/UCoreUtils.pas b/UCoreUtils.pas
index 6ee28d4..3dc91f0 100644
--- a/UCoreUtils.pas
+++ b/UCoreUtils.pas
@@ -58,6 +58,7 @@ function GetSignalString(SignalNo: integer): string;
function FormatSize(Value: Int64; Base: integer; OverrideSizeFormat: integer = -1): string;
function FormatDate(Value: TTimeT; const FormatTime, FormatDate: boolean; OverrideTimeFormat: integer = -1; OverrideDateFormat: integer = -1; OverrideDateTimeFormat: integer = -1; OverrideCustomDateFormat: string = ''; OverrideCustomTimeFormat: string = ''): string;
+function StripDate(Value: TTimeT): TTimeT;
function AttrToStr(const Mode: Cardinal; IncludeFileType: boolean = True): string;
function AttrToOctal(const Mode: Cardinal): integer;
@@ -347,6 +348,13 @@ begin
if FormatDate then Result := DateString;
end;
+function StripDate(Value: TTimeT): TTimeT;
+var time_tm: Ptm;
+begin
+ time_tm := localtime(@Value);
+ Result := time_tm^.tm_hour*60*60 + time_tm^.tm_min*60 + time_tm^.tm_sec;
+end;
+
(********************************************************************************************************************************)
function AttrToStr(const Mode: Cardinal; IncludeFileType: boolean = True): string;
@@ -1378,42 +1386,36 @@ begin
if Data2^.UpDir then Result := 1*mp else
if Data1^.IsDir and (not Data2^.IsDir) then Result := -1*mp else
if Data2^.IsDir and (not Data1^.IsDir) then Result := 1*mp else
+ if Data1^.IsDir and Data2^.IsDir and (not ConfSortDirectoriesLikeFiles)
+ then Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName)*mp else
+
case SortColumnID of
- 1, 2 : begin
- Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName);
- if Data1^.IsDir and Data2^.IsDir then Result := Result * mp;
- end;
- 3 : if Data1^.IsDir and Data2^.IsDir then Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName)*mp else begin
+ 1, 2 : Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName);
+ 3 : begin
SeparateExt(String(Data1^.FDisplayName), s1, s2);
SeparateExt(String(Data2^.FDisplayName), s3, s4);
if WideUpperCase(s2) <> WideUpperCase(s4)
then Result := CompareTextsEx(PChar(s2), PChar(s4))
else Result := CompareTextsEx(PChar(s1), PChar(s3));
end;
- 4 : if Data1^.IsDir and Data2^.IsDir then Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName)*mp else
- if Data1^.Size > Data2^.Size then Result := -1 else
+ 4 : if Data1^.Size > Data2^.Size then Result := -1 else
if Data1^.Size < Data2^.Size then Result := 1 else
Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName);
- 5, 6 : if Data1^.IsDir and Data2^.IsDir then Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName)*mp else
- if Data1^.ModifyTime > Data2^.ModifyTime then Result := -1 else
- if Data1^.ModifyTime < Data2^.ModifyTime then Result := 1 else
+ 5, 6 : if Data1^.ModifyTime > Data2^.ModifyTime then Result := -1 else
+ if Data1^.ModifyTime < Data2^.ModifyTime then Result := 1 else
+ Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName);
+ 7 : if StripDate(Data1^.ModifyTime) > StripDate(Data2^.ModifyTime) then Result := -1 else
+ if StripDate(Data1^.ModifyTime) < StripDate(Data2^.ModifyTime) then Result := 1 else
Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName);
- 7 : if Data1^.IsDir and Data2^.IsDir then Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName)*mp else
- if Frac(Data1^.ModifyTime) > Frac(Data2^.ModifyTime) then Result := -1 else
- if Frac(Data1^.ModifyTime) < Frac(Data2^.ModifyTime) then Result := 1 else
- Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName);
- 8 : if Data1^.IsDir and Data2^.IsDir then Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName)*mp else
- if Data1^.UID > Data2^.UID then Result := -1 else
+ 8 : if Data1^.UID > Data2^.UID then Result := -1 else
if Data1^.UID < Data2^.UID then Result := 1 else
Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName);
- 9 : if Data1^.IsDir and Data2^.IsDir then Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName)*mp else
- if Data1^.GID > Data2^.GID then Result := -1 else
+ 9 : if Data1^.GID > Data2^.GID then Result := -1 else
if Data1^.GID < Data2^.GID then Result := 1 else
Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName);
- 10 : if Data1^.IsDir and Data2^.IsDir then Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName)*mp else
- if Data1^.Mode > Data2^.Mode then Result := -1 else
- if Data1^.Mode < Data2^.Mode then Result := 1 else
- Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName);
+ 10 : if Data1^.Mode > Data2^.Mode then Result := -1 else
+ if Data1^.Mode < Data2^.Mode then Result := 1 else
+ Result := CompareTextsEx(Data1^.FDisplayName, Data2^.FDisplayName);
else Result := 0;
end;
end;
diff --git a/UMain.pas b/UMain.pas
index 2e06dbc..1e9f86f 100644
--- a/UMain.pas
+++ b/UMain.pas
@@ -2285,6 +2285,17 @@ begin
RunningEscSensitive := 1;
GetDirSize(ListView, Engine, DataList, AllItems);
+
+ if ConfSortDirectoriesLikeFiles and (ColumnSortIDs[ListView.SortColumnID + 1] = 4) then begin
+ if ListView.SortOrder = soAscending then begin
+ ListView.SetSortInfo(ListView.SortColumnID, soDescending);
+ ListView.SetSortInfo(ListView.SortColumnID, soAscending);
+ end else begin
+ ListView.SetSortInfo(ListView.SortColumnID, soAscending);
+ ListView.SetSortInfo(ListView.SortColumnID, soDescending);
+ end;
+ ListView.Selected.SetCursor(0, False, False, 0, 0);
+ end;
FMainEscPressed := False;
RunningEscSensitive := 0;
end;
diff --git a/UPreferences.pas b/UPreferences.pas
index 73b709f..a9e02e7 100644
--- a/UPreferences.pas
+++ b/UPreferences.pas
@@ -76,6 +76,7 @@ type
DateTimeFormatOptionMenu: TGTKOptionMenu;
QuickSearchLabel: TGTKLabel;
QuickSearchOptionMenu: TGTKOptionMenu;
+ SortDirectoriesLikeFilesCheckBox: TGTKCheckButton;
procedure FormCreate(Sender: TObject); override;
procedure FormDestroy(Sender: TObject);
@@ -252,7 +253,7 @@ begin
FormatTime := Libc.__time(nil);
DateFormatLabel := TGTKLabel.Create(Self);
- DateFormatLabel.Caption := '_Date format:';
+ DateFormatLabel.Caption := 'Date _format:';
DateFormatLabel.XAlign := 0;
DateFormatLabel.UseUnderline := True;
DateFormatOptionMenu := TGTKOptionMenu.Create(Self);
@@ -332,7 +333,7 @@ begin
PanelsPage.AddControlEx(PanelsLabel2, False, False, 5);
Table5 := TGTKTable.Create(Self);
- Table5.SetRowColCount(16, 2);
+ Table5.SetRowColCount(17, 2);
PanelsPage.AddControlEx(Table5, False, False, 0);
DisableMouseRename := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_DisableMouseRenaming);
@@ -341,42 +342,45 @@ begin
DisableFileTipsCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesDisableFileTipsCheckBox_Caption);
DisableFileTipsCheckBox.Tooltip := LANGPreferencesDisableFileTipsCheckBox_Tooltip;
Table5.AddControl(0, 1, 2, 1, DisableFileTipsCheckBox, 30, 2);
- Table5.AddControl(0, 2, 2, 1, TGTKVBox.Create(Self), 0, 7);
+ SortDirectoriesLikeFilesCheckBox := TGTKCheckButton.CreateWithLabel(Self, 'Sort directories lik_e files');
+ SortDirectoriesLikeFilesCheckBox.Tooltip := 'Check this to allow sorting directories along with files. Directories are always first in the list.'#10'Unchecked: directories are always sorted by name.';
+ Table5.AddControl(0, 2, 2, 1, SortDirectoriesLikeFilesCheckBox, 30, 2);
+ Table5.AddControl(0, 3, 2, 1, TGTKVBox.Create(Self), 0, 7);
PanelsLabel3 := TGTKLabel.Create(Self);
PanelsLabel3.XAlign := 0;
PanelsLabel3.XPadding := 0;
PanelsLabel3.Caption := Format('<span weight="ultrabold">%s</span>', [LANGPreferencesShow]);
PanelsLabel3.UseMarkup := True;
- Table5.AddControl(0, 3, 2, 1, PanelsLabel3, 10, 2);
+ Table5.AddControl(0, 4, 2, 1, PanelsLabel3, 10, 2);
ShowFiletypeIcons := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_ShowFiletypeIconsInList);
- Table5.AddControl(0, 4, 2, 1, ShowFiletypeIcons, 30, 2);
+ Table5.AddControl(0, 5, 2, 1, ShowFiletypeIcons, 30, 2);
DirsInBoldCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesDirsInBoldCheckBox_Caption);
- Table5.AddControl(0, 5, 2, 1, DirsInBoldCheckBox, 30, 2);
+ Table5.AddControl(0, 6, 2, 1, DirsInBoldCheckBox, 30, 2);
DisableDirectoryBracketsCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesDisableDirectoryBracketsCheckBox_Caption);
- Table5.AddControl(0, 6, 2, 1, DisableDirectoryBracketsCheckBox, 30, 2);
+ Table5.AddControl(0, 7, 2, 1, DisableDirectoryBracketsCheckBox, 30, 2);
OctalPermissionsCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesOctalPermissionsCheckBox_Caption);
OctalPermissionsCheckBox.Tooltip := LANGPreferencesOctalPermissionsCheckBox_Tooltip;
- Table5.AddControl(0, 7, 2, 1, OctalPermissionsCheckBox, 30, 2);
+ Table5.AddControl(0, 8, 2, 1, OctalPermissionsCheckBox, 30, 2);
ShowTextUIDsCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGShowTextUIDsCheckBox_Caption);
ShowTextUIDsCheckBox.Tooltip := LANGShowTextUIDsCheckBox_Tooltip;
- Table5.AddControl(0, 8, 2, 1, ShowTextUIDsCheckBox, 30, 2);
- Table5.AddControl(0, 9, 2, 1, TGTKVBox.Create(Self), 0, 7);
+ Table5.AddControl(0, 9, 2, 1, ShowTextUIDsCheckBox, 30, 2);
+ Table5.AddControl(0, 10, 2, 1, TGTKVBox.Create(Self), 0, 7);
PanelsLabel4 := TGTKLabel.Create(Self);
PanelsLabel4.XAlign := 0;
PanelsLabel4.XPadding := 0;
PanelsLabel4.Caption := Format('<span weight="ultrabold">%s</span>', [LANGPreferencesMovement]);
PanelsLabel4.UseMarkup := True;
- Table5.AddControl(0, 10, 2, 1, PanelsLabel4, 10, 2);
+ Table5.AddControl(0, 11, 2, 1, PanelsLabel4, 10, 2);
LynxLikeMotionCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesLynxLikeMotionCheckBox_Caption);
- Table5.AddControl(0, 11, 2, 1, LynxLikeMotionCheckBox, 30, 2);
+ Table5.AddControl(0, 12, 2, 1, LynxLikeMotionCheckBox, 30, 2);
InsertMovesDownCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesInsertMovesDownCheckBox_Caption);
- Table5.AddControl(0, 12, 2, 1, InsertMovesDownCheckBox, 30, 2);
+ Table5.AddControl(0, 13, 2, 1, InsertMovesDownCheckBox, 30, 2);
SpaceMovesDownCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesSpaceMovesDownCheckBox_Caption);
- Table5.AddControl(0, 13, 2, 1, SpaceMovesDownCheckBox, 30, 2);
+ Table5.AddControl(0, 14, 2, 1, SpaceMovesDownCheckBox, 30, 2);
QuickSearchLabel := TGTKLabel.Create(Self);
QuickSearchLabel.Caption := 'Quick search _keystroke:';
@@ -397,9 +401,9 @@ begin
Item := TGTKMenuItem.CreateTyped(Self, itLabel);
Item.Caption := 'letters directly';
QuickSearchOptionMenu.Items.Add(Item);
- Table5.AddControl(0, 14, 2, 1, TGTKVBox.Create(Self), 0, 2);
- Table5.AddControlEx(0, 15, 1, 1, QuickSearchLabel, [taoShrink], [taoShrink], 35, 2);
- Table5.AddControlEx(1, 15, 1, 1, QuickSearchOptionMenu, [taoExpand, taoFill], [taoShrink, taoExpand, taoFill], 20, 2);
+ Table5.AddControl(0, 15, 2, 1, TGTKVBox.Create(Self), 0, 2);
+ Table5.AddControlEx(0, 16, 1, 1, QuickSearchLabel, [taoShrink], [taoShrink], 35, 2);
+ Table5.AddControlEx(1, 16, 1, 1, QuickSearchOptionMenu, [taoExpand, taoFill], [taoShrink, taoExpand, taoFill], 20, 2);
// ********* PAGE Applications
@@ -886,6 +890,7 @@ begin
TimeFormatOptionMenu.ItemIndex := ConfTimeFormat;
DateTimeFormatOptionMenu.ItemIndex := ConfDateTimeFormat;
QuickSearchOptionMenu.ItemIndex := ConfQuickSearchActivationKey;
+ SortDirectoriesLikeFilesCheckBox.Checked := ConfSortDirectoriesLikeFiles;
DefaultFontCheckBoxToggled(Self);
ColorButtonDefaultsToggled(Self);
@@ -956,6 +961,7 @@ begin
ConfTimeFormat := TimeFormatOptionMenu.ItemIndex;
ConfDateTimeFormat := DateTimeFormatOptionMenu.ItemIndex;
ConfQuickSearchActivationKey := QuickSearchOptionMenu.ItemIndex;
+ ConfSortDirectoriesLikeFiles := SortDirectoriesLikeFilesCheckBox.Checked;
end;
(********************************************************************************************************************************)