Sign in to follow this  
Followers 0
jkollss

Save user list sort order and column

1 post in this topic

Sorry, maybe I put this to wrong topic, please move this to the proper one. Thanks.

Here is a git patch which adds a feature to save user list column sort order between the sessions:

I wrote it and found quite useful.

diff --git a/client/SettingsManager.cpp b/client/SettingsManager.cpp

index f77f72f..f5af4f7 100644

--- a/client/SettingsManager.cpp

+++ b/client/SettingsManager.cpp

@@ -143,7 +143,7 @@ const string SettingsManager::settingTags[] =

 	"ShowQSearch", "SearchDetectHash", "ZionTabs", "NonHubsFront", "GlobalMiniTabs", "BlendOffline", "MaxResizeLines",

 	"CheckClientBeforeFileList", "MaxTestSURs", "MaxFileLists", "CheckDelay", "SleepTime", "DelayedRawSending",

 	"NatSort", "DontShareEmptyDirs", "OnlyShareFullDirs", "UseCustomListBackground", "ProtectedColour", "UseFavNames",

-	"EnableIpGuard", "DefaultPolicy",

+	"EnableIpGuard", "DefaultPolicy", "UserlistSortColumn", "UserlistSortAscending",

 	"SENTRY",

 	// Int64

 	"TotalUpload", "TotalDownload",

@@ -536,6 +536,8 @@ SettingsManager::SettingsManager()

 	setDefault(USE_FAV_NAMES, false);

 	setDefault(ENABLE_IPGUARD, false);

 	setDefault(DEFAULT_POLICY, false);

+	setDefault(USERLIST_SORTCOLUMN, -1);

+	setDefault(USERLIST_SORTASCENDING, true);


 	setDefault(MAIN_WINDOW_STATE, SW_SHOWNORMAL);

 	setDefault(MAIN_WINDOW_SIZE_X, CW_USEDEFAULT);

diff --git a/client/SettingsManager.h b/client/SettingsManager.h

index 13e5879..f1fd25d 100644

--- a/client/SettingsManager.h

+++ b/client/SettingsManager.h

@@ -154,7 +154,7 @@ public:

 		SHOW_QUICK_SEARCH, SEARCH_DETECT_TTH, ZION_TABS, NON_HUBS_FRONT, GLOBAL_MINI_TABS, BLEND_OFFLINE_SEARCH, MAX_RESIZE_LINES,

 		CHECK_CLIENT_BEFORE_FILELIST, MAX_TESTSURS, MAX_FILELISTS, CHECK_DELAY, SLEEP_TIME, DELAYED_RAW_SENDING,

 		NAT_SORT, DONT_SHARE_EMPTY_DIRS, ONLY_SHARE_FULL_DIRS, USE_CUSTOM_LIST_BACKGROUND, PROTECTED_COLOUR, USE_FAV_NAMES,

-		ENABLE_IPGUARD, DEFAULT_POLICY,

+		ENABLE_IPGUARD, DEFAULT_POLICY, USERLIST_SORTCOLUMN, USERLIST_SORTASCENDING,

 		INT_LAST };


 	enum Int64Setting { INT64_FIRST = INT_LAST + 1,

diff --git a/windows/HubFrame.cpp b/windows/HubFrame.cpp

index b8d8960..f68101d 100644

--- a/windows/HubFrame.cpp

+++ b/windows/HubFrame.cpp

@@ -151,7 +151,14 @@ LRESULT HubFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,

 	ctrlUsers.setFlickerFree(WinUtil::bgBrush);

 	ctrlClient.SetBackgroundColor(WinUtil::bgColor); 


-	ctrlUsers.setSortColumn(OnlineUser::COLUMN_NICK);

+	bool bSortAsc = SETTING(USERLIST_SORTASCENDING);

+	ctrlUsers.setAscending(bSortAsc);

+	int nSortColumn = SETTING(USERLIST_SORTCOLUMN);

+	if (nSortColumn >= OnlineUser::COLUMN_FIRST && nSortColumn < OnlineUser::COLUMN_LAST)

+		ctrlUsers.setSortColumn(nSortColumn);

+	else

+		ctrlUsers.setSortColumn(OnlineUser::COLUMN_NICK);

+


 	ctrlUsers.SetImageList(WinUtil::userImages, LVSIL_SMALL);


@@ -936,6 +943,11 @@ LRESULT HubFrame::onClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, B

 		clearUserList();

 		clearTaskList();


+		int nSortColumn = ctrlUsers.getSortColumn();

+		SettingsManager::getInstance()->set(SettingsManager::USERLIST_SORTCOLUMN, nSortColumn);

+		bool bAscend = ctrlUsers.isAscending();

+		SettingsManager::getInstance()->set(SettingsManager::USERLIST_SORTASCENDING, bAscend);

+

 		string tmp, tmp2, tmp3;

 		ctrlUsers.saveHeaderOrder(tmp, tmp2, tmp3);

With best regards,

Sergey.

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0