← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2963: change list selection change handlers to timers

 

------------------------------------------------------------
revno: 2963
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2012-06-23 14:31:10 +0200
message:
  change list selection change handlers to timers
modified:
  changelog.txt
  win32/DirectoryListingFrame.cpp
  win32/HubFrame.cpp
  win32/HubFrame.h
  win32/QueueFrame.cpp
  win32/UsersFrame.cpp
  win32/UsersFrame.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt	2012-06-22 14:46:44 +0000
+++ changelog.txt	2012-06-23 12:31:10 +0000
@@ -19,6 +19,7 @@
 * Fix GUI problems in a download attempt of a public hublist with invalid address (emtee)
 * Fix unsuccessful HTTP redirections (emtee)
 * [L#1016205] Avoid deadlocks when changing user matchings (poy)
+* [L#249159] Improve performance when selecting lots of lines in lists (poy)
 
 -- 0.799 2012-05-05 --
 * Add icons (iceman50)

=== modified file 'win32/DirectoryListingFrame.cpp'
--- win32/DirectoryListingFrame.cpp	2012-06-21 18:52:47 +0000
+++ win32/DirectoryListingFrame.cpp	2012-06-23 12:31:10 +0000
@@ -314,7 +314,6 @@
 		WinUtil::makeColumns(files, filesColumns, COLUMN_LAST, SETTING(DIRECTORYLISTINGFRAME_ORDER), SETTING(DIRECTORYLISTINGFRAME_WIDTHS));
 		files->setSort(COLUMN_FILENAME);
 
-		files->onSelectionChanged([this] { callAsync([&] { updateStatus(); }); });
 		files->onDblClicked([this] { handleDoubleClickFiles(); });
 		files->onKeyDown([this](int c) { return handleKeyDownFiles(c); });
 		files->onSysKeyDown([this](int c) { return handleKeyDownFiles(c); });
@@ -387,6 +386,8 @@
 		status->setWidget(STATUS_SHOW_TREE, showTree);
 	}
 
+	setTimer([this]() -> bool { updateStatus(); return true; }, 500);
+
 	dirs->setFocus();
 
 	treeRoot = dirs->insert(NULL, new ItemInfo(true, dl->getRoot()));

=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp	2012-06-21 18:52:47 +0000
+++ win32/HubFrame.cpp	2012-06-23 12:31:10 +0000
@@ -204,7 +204,6 @@
 		WinUtil::makeColumns(users, usersColumns, COLUMN_LAST, SETTING(HUBFRAME_ORDER), SETTING(HUBFRAME_WIDTHS));
 		users->setSort(COLUMN_NICK);
 
-		users->onSelectionChanged([this] { callAsync([&] { updateStatus(); }); });
 		users->onDblClicked([this] { handleDoubleClickUsers(); });
 		users->onKeyDown([this](int c) { return handleUsersKeyDown(c); });
 		users->onContextMenu([this](const dwt::ScreenCoordinate &sc) { return handleUsersContextMenu(sc); });
@@ -260,7 +259,7 @@
 
 	layout();
 
-	initSecond();
+	initTimer();
 
 	client = ClientManager::getInstance()->getClient(url);
 	client->addListener(this);
@@ -372,11 +371,11 @@
 	status->setToolTip(STATUS_SECURE, text);
 }
 
-void HubFrame::initSecond() {
-	setTimer([this] { return eachSecond(); }, 1000);
+void HubFrame::initTimer() {
+	setTimer([this] { return runTimer(); }, 500);
 }
 
-bool HubFrame::eachSecond() {
+bool HubFrame::runTimer() {
 	if(updateUsers) {
 		updateUsers = false;
 		callAsync([this] { execTasks(); });

=== modified file 'win32/HubFrame.h'
--- win32/HubFrame.h	2012-06-03 17:49:39 +0000
+++ win32/HubFrame.h	2012-06-23 12:31:10 +0000
@@ -203,8 +203,8 @@
 	void updateStatus();
 	void updateSecureStatus();
 
-	void initSecond();
-	bool eachSecond();
+	void initTimer();
+	bool runTimer();
 
 	UserInfo* findUser(const tstring& nick);
 	bool updateUser(const UserTask& u);

=== modified file 'win32/QueueFrame.cpp'
--- win32/QueueFrame.cpp	2012-06-21 18:52:47 +0000
+++ win32/QueueFrame.cpp	2012-06-23 12:31:10 +0000
@@ -91,7 +91,6 @@
 		files->setSort(COLUMN_TARGET);
 
 		files->onKeyDown([this](int c) { return handleKeyDownFiles(c); });
-		files->onSelectionChanged([this] { callAsync([&] { updateStatus(); }); });
 		files->onContextMenu([this](const dwt::ScreenCoordinate &sc) { return handleFilesContextMenu(sc); });
 
 		if(!SETTING(QUEUEFRAME_SHOW_TREE)) {
@@ -118,10 +117,10 @@
 	status->setHelpId(STATUS_TOTAL_COUNT, IDH_QUEUE_TOTAL_COUNT);
 	status->setHelpId(STATUS_TOTAL_BYTES, IDH_QUEUE_TOTAL_BYTES);
 
+	setTimer([this]() -> bool { updateStatus(); return true; }, 500);
+
 	QueueManager::getInstance()->addListener(this, [this](const QueueItem::StringMap& qsm) { addQueueList(qsm); });
 
-	updateStatus();
-
 	layout();
 }
 

=== modified file 'win32/UsersFrame.cpp'
--- win32/UsersFrame.cpp	2012-06-21 18:52:47 +0000
+++ win32/UsersFrame.cpp	2012-06-23 12:31:10 +0000
@@ -141,7 +141,6 @@
 		users->onDblClicked([this] { handleGetList(); });
 		users->onKeyDown([this](int c) { return handleKeyDown(c); });
 		users->onContextMenu([this](dwt::ScreenCoordinate pt) { return handleContextMenu(pt); });
-		users->onSelectionChanged([this] { handleSelectionChanged(); });
 		users->setSmallImageList(userIcons);
 		users->onLeftMouseDown([this](const dwt::MouseEvent &me) { return handleClick(me); });
 
@@ -202,6 +201,8 @@
 
 	initStatus();
 
+	setTimer([this]() -> bool { updateUserInfo(); return true; }, 500);
+
 	addAccel(FALT, 'I', [this] { filter.text->setFocus(); });
 	initAccels();
 
@@ -317,11 +318,7 @@
 			ui->second.update(aUser, true);
 			auto i = users->find(&ui->second);
 			if(i != -1) {
-				if(users->getSelected() == i) {
-					handleSelectionChanged();
-				} else {
-					users->update(i);
-				}
+				users->update(i);
 			} else {
 				users->insert(&ui->second);
 			}
@@ -329,7 +326,7 @@
 	}
 }
 
-void UsersFrame::handleSelectionChanged() {
+void UsersFrame::updateUserInfo() {
 	ScopedFunctor([&] { scroll->layout(); userInfo->layout(); userInfo->redraw(); });
 
 	HoldRedraw hold(userInfo);

=== modified file 'win32/UsersFrame.h'
--- win32/UsersFrame.h	2012-02-17 23:34:33 +0000
+++ win32/UsersFrame.h	2012-06-23 12:31:10 +0000
@@ -131,13 +131,13 @@
 
 	void addUser(const UserPtr& aUser);
 	void updateUser(const UserPtr& aUser);
+	void updateUserInfo();
 
 	void handleDescription();
 	void handleRemove();
 	bool handleKeyDown(int c);
 	LRESULT handleItemChanged(LPARAM lParam);
 	bool handleContextMenu(dwt::ScreenCoordinate pt);
-	void handleSelectionChanged();
 	bool handleClick(const dwt::MouseEvent &me);
 
 	void updateList();