← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2641: save the state of some check-boxes earlier

 

------------------------------------------------------------
revno: 2641
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Mon 2011-10-17 21:39:46 +0200
message:
  save the state of some check-boxes earlier
modified:
  dwt/src/widgets/Control.cpp
  win32/DirectoryListingFrame.cpp
  win32/DirectoryListingFrame.h
  win32/QueueFrame.cpp
  win32/QueueFrame.h
  win32/SearchFrame.cpp
  win32/SearchFrame.h
  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 'dwt/src/widgets/Control.cpp'
--- dwt/src/widgets/Control.cpp	2011-07-05 12:16:32 +0000
+++ dwt/src/widgets/Control.cpp	2011-10-17 19:39:46 +0000
@@ -58,9 +58,10 @@
 }
 
 void Control::initAccels() {
+	dwtassert(!accel, "Control::initAccels called twice on the same control");
 	accel = ::CreateAcceleratorTable(&accels[0], accels.size());
 	if(!accel) {
-		throw Win32Exception("Control::create: CreateAcceleratorTable failed");
+		throw Win32Exception("Control::initAccels: CreateAcceleratorTable failed");
 	}
 }
 

=== modified file 'win32/DirectoryListingFrame.cpp'
--- win32/DirectoryListingFrame.cpp	2011-10-10 20:18:18 +0000
+++ win32/DirectoryListingFrame.cpp	2011-10-17 19:39:46 +0000
@@ -216,7 +216,6 @@
 	searchBox(0),
 	dirs(0),
 	files(0),
-	showTree(0),
 	speed(aSpeed),
 	dl(new DirectoryListing(aUser)),
 	user(aUser),
@@ -350,14 +349,16 @@
 
 	initStatus();
 
-	showTree = addChild(WinUtil::Seeds::splitCheckBox);
-	showTree->setChecked(true);
-	showTree->onClicked([this, paned] {
-		auto checked = showTree->getChecked();
-		dirs->setEnabled(checked);
-		paned->maximize(checked ? nullptr : files);
-	});
-	status->setWidget(STATUS_SHOW_TREE, showTree);
+	{
+		auto showTree = addChild(WinUtil::Seeds::splitCheckBox);
+		showTree->setChecked(true);
+		showTree->onClicked([this, showTree, paned] {
+			auto checked = showTree->getChecked();
+			dirs->setEnabled(checked);
+			paned->maximize(checked ? nullptr : files);
+		});
+		status->setWidget(STATUS_SHOW_TREE, showTree);
+	}
 
 	treeRoot = dirs->insert(NULL, new ItemInfo(true, dl->getRoot()));
 

=== modified file 'win32/DirectoryListingFrame.h'
--- win32/DirectoryListingFrame.h	2011-10-02 12:14:41 +0000
+++ win32/DirectoryListingFrame.h	2011-10-17 19:39:46 +0000
@@ -166,8 +166,6 @@
 	typedef WidgetFiles* WidgetFilesPtr;
 	WidgetFilesPtr files;
 
-	CheckBoxPtr showTree;
-
 	int64_t speed;		/**< Speed at which this file list was downloaded */
 
 	std::unique_ptr<DirectoryListing> dl;

=== modified file 'win32/QueueFrame.cpp'
--- win32/QueueFrame.cpp	2011-10-10 20:18:18 +0000
+++ win32/QueueFrame.cpp	2011-10-17 19:39:46 +0000
@@ -65,7 +65,6 @@
 paned(0),
 dirs(0),
 files(0),
-showTree(0),
 dirty(true),
 usingDirMenu(false),
 queueSize(0),
@@ -104,11 +103,17 @@
 
 	initStatus();
 
-	showTree = addChild(WinUtil::Seeds::splitCheckBox);
-	showTree->setHelpId(IDH_QUEUE_SHOW_TREE);
-	showTree->setChecked(BOOLSETTING(QUEUEFRAME_SHOW_TREE));
-	showTree->onClicked([this] { handleShowTreeClicked(); });
-	status->setWidget(STATUS_SHOW_TREE, showTree);
+	{
+		auto showTree = addChild(WinUtil::Seeds::splitCheckBox);
+		showTree->setHelpId(IDH_QUEUE_SHOW_TREE);
+		showTree->setChecked(BOOLSETTING(QUEUEFRAME_SHOW_TREE));
+		showTree->onClicked([this, showTree] {
+			auto checked = showTree->getChecked();
+			SettingsManager::getInstance()->set(SettingsManager::QUEUEFRAME_SHOW_TREE, checked);
+			paned->maximize(checked ? nullptr : files);
+		});
+		status->setWidget(STATUS_SHOW_TREE, showTree);
+	}
 
 	status->setHelpId(STATUS_PARTIAL_COUNT, IDH_QUEUE_PARTIAL_COUNT);
 	status->setHelpId(STATUS_PARTIAL_BYTES, IDH_QUEUE_PARTIAL_BYTES);
@@ -187,7 +192,7 @@
 	int cnt = files->countSelected();
 	if(cnt < 2) {
 		cnt = files->size();
-		if(showTree->getChecked()) {
+		if(BOOLSETTING(QUEUEFRAME_SHOW_TREE)) {
 			for(int i = 0; i < cnt; ++i) {
 				QueueItemInfo* ii = files->getData(i);
 				total += (ii->getSize() > 0) ? ii->getSize() : 0;
@@ -225,7 +230,6 @@
 		ht = dirs->getNextSibling(ht);
 	}
 
-	SettingsManager::getInstance()->set(SettingsManager::QUEUEFRAME_SHOW_TREE, showTree->getChecked());
 	SettingsManager::getInstance()->set(SettingsManager::QUEUE_PANED_POS, paned->getSplitterPos(0));
 
 	for(DirectoryIter i = directories.begin(); i != directories.end(); ++i) {
@@ -253,7 +257,7 @@
 	if(updateDir) {
 		addDirectory(dir, ii->isSet(QueueItem::FLAG_USER_LIST));
 	}
-	if(!showTree->getChecked() || isCurDir(dir)) {
+	if(!BOOLSETTING(QUEUEFRAME_SHOW_TREE) || isCurDir(dir)) {
 		ii->update();
 		if(noSort) {
 			files->insert(files->size(), ii);
@@ -263,16 +267,12 @@
 	}
 }
 
-void QueueFrame::handleShowTreeClicked() {
-	paned->maximize(showTree->getChecked() ? NULL : files);
-}
-
 void QueueFrame::updateFiles() {
 	HoldRedraw hold(files);
 
 	files->clear();
 	pair<DirectoryIter, DirectoryIter> i;
-	if(showTree->getChecked()) {
+	if(BOOLSETTING(QUEUEFRAME_SHOW_TREE)) {
 		i = directories.equal_range(getSelectedDir());
 	} else {
 		i.first = directories.begin();
@@ -627,7 +627,7 @@
 		}
 	} else if(n > 1) {
 		tstring name;
-		if(showTree->getChecked()) {
+		if(BOOLSETTING(QUEUEFRAME_SHOW_TREE)) {
 			name = Text::toT(curDir);
 		}
 		if(FolderDialog(this).open(name)) {
@@ -1010,7 +1010,7 @@
 		return;
 	}
 
-	if(!showTree->getChecked() || isCurDir(ii->getPath()) ) {
+	if(!BOOLSETTING(QUEUEFRAME_SHOW_TREE) || isCurDir(ii->getPath()) ) {
 		dcassert(files->find(ii) != -1);
 		files->erase(ii);
 	}
@@ -1056,7 +1056,7 @@
 
 	ii->updateMask |= QueueItemInfo::MASK_PRIORITY | QueueItemInfo::MASK_USERS | QueueItemInfo::MASK_ERRORS | QueueItemInfo::MASK_STATUS | QueueItemInfo::MASK_DOWNLOADED;
 
-	if(!showTree->getChecked() || isCurDir(ii->getPath())) {
+	if(!BOOLSETTING(QUEUEFRAME_SHOW_TREE) || isCurDir(ii->getPath())) {
 		dcassert(files->find(ii) != -1);
 		ii->update();
 		files->update(ii);

=== modified file 'win32/QueueFrame.h'
--- win32/QueueFrame.h	2011-07-30 08:58:17 +0000
+++ win32/QueueFrame.h	2011-10-17 19:39:46 +0000
@@ -197,8 +197,6 @@
 	typedef WidgetFiles* WidgetFilesPtr;
 	WidgetFilesPtr files;
 
-	CheckBoxPtr showTree;
-
 	typedef unordered_multimap<string, QueueItemInfo*, noCaseStringHash, noCaseStringEq> DirectoryMap;
 	typedef DirectoryMap::iterator DirectoryIter;
 	typedef pair<DirectoryIter, DirectoryIter> DirectoryPair;
@@ -266,7 +264,6 @@
 	bool preClosing();
 	void postClosing();
 
-	void handleShowTreeClicked();
 	void handleMove();
 	void handleRemove();
 	void handleRecheck();

=== modified file 'win32/SearchFrame.cpp'
--- win32/SearchFrame.cpp	2011-10-11 18:38:23 +0000
+++ win32/SearchFrame.cpp	2011-10-17 19:39:46 +0000
@@ -126,7 +126,6 @@
 bMerge(BOOLSETTING(SEARCH_MERGE)),
 hubs(0),
 results(0),
-showUI(0),
 initialType(initialType_),
 droppedResults(0)
 {
@@ -262,10 +261,12 @@
 
 	initStatus();
 
-	showUI = addChild(WinUtil::Seeds::splitCheckBox);
-	showUI->setChecked(true);
-	showUI->onClicked([this] { handleShowUIClicked(); });
-	status->setWidget(STATUS_SHOW_UI, showUI);
+	{
+		auto showUI = addChild(WinUtil::Seeds::splitCheckBox);
+		showUI->setChecked(true);
+		showUI->onClicked([this, showUI] { paned->maximize(showUI->getChecked() ? nullptr : results); });
+		status->setWidget(STATUS_SHOW_UI, showUI);
+	}
 
 	layout();
 	activate();
@@ -556,10 +557,6 @@
 	bMerge = merge->getChecked();
 }
 
-void SearchFrame::handleShowUIClicked() {
-	paned->maximize(showUI->getChecked() ? NULL : results);
-}
-
 LRESULT SearchFrame::handleHubItemChanged(WPARAM wParam, LPARAM lParam) {
 	LPNMLISTVIEW lv = (LPNMLISTVIEW)lParam;
 	if(lv->iItem == 0 && (lv->uNewState ^ lv->uOldState) & LVIS_STATEIMAGEMASK) {

=== modified file 'win32/SearchFrame.h'
--- win32/SearchFrame.h	2011-09-30 11:33:12 +0000
+++ win32/SearchFrame.h	2011-10-17 19:39:46 +0000
@@ -189,8 +189,6 @@
 	typedef WidgetResults* WidgetResultsPtr;
 	WidgetResultsPtr results;
 
-	CheckBoxPtr showUI;
-
 	SearchManager::TypeModes initialType;
 
 	static TStringList lastSearches;
@@ -213,7 +211,6 @@
 	void handleSlotsClicked();
 	void handleFilterClicked();
 	void handleMergeClicked();
-	void handleShowUIClicked();
 	LRESULT handleHubItemChanged(WPARAM wParam, LPARAM lParam);
 	bool handleKeyDown(int c);
 	bool handleContextMenu(dwt::ScreenCoordinate pt);

=== modified file 'win32/UsersFrame.cpp'
--- win32/UsersFrame.cpp	2011-10-15 23:57:49 +0000
+++ win32/UsersFrame.cpp	2011-10-17 19:39:46 +0000
@@ -105,43 +105,39 @@
 };
 
 UsersFrame::UsersFrame(TabViewPtr parent) :
-	BaseType(parent, T_("Users"), IDH_USERS, IDI_USERS),
-	users(0),
-	scroll(0),
-	startup(true)
+BaseType(parent, T_("Users"), IDH_USERS, IDI_USERS, false),
+filterGrid(0),
+users(0),
+userInfo(0),
+splitter(0),
+filter(0),
+scroll(0)
 {
 	filterGrid = addChild(Grid::Seed(1, 6));
 
-	auto updated = [this] { handleFilterUpdated(); };
 	filterGrid->addChild(Label::Seed(T_("Nick filter:")));
 	filter = filterGrid->addChild(WinUtil::Seeds::textBox);
 	filter->setHelpId(IDH_USERS_FILTER_NICK);
-	filter->onUpdated(updated);
+	filter->onUpdated([this] { handleFilterUpdated(); });
 	filterGrid->column(1).mode = GridInfo::FILL;
 
-	showOnline = filterGrid->addChild(WinUtil::Seeds::checkBox);
-	showOnline->setHelpId(IDH_USERS_FILTER_ONLINE);
-	showOnline->setText(_T("Online"));
-	showOnline->setChecked(BOOLSETTING(USERS_FILTER_ONLINE));
-	showOnline->onClicked(updated);
-
-	showFavs = filterGrid->addChild(WinUtil::Seeds::checkBox);
-	showFavs->setHelpId(IDH_USERS_FILTER_FAVORITE);
-	showFavs->setText(_T("Favorite"));
-	showFavs->setChecked(BOOLSETTING(USERS_FILTER_FAVORITE));
-	showFavs->onClicked(updated);
-
-	showQueue = filterGrid->addChild(WinUtil::Seeds::checkBox);
-	showQueue->setHelpId(IDH_USERS_FILTER_QUEUE);
-	showQueue->setText(_T("Pending download"));
-	showQueue->setChecked(BOOLSETTING(USERS_FILTER_QUEUE));
-	showQueue->onClicked(updated);
-
-	showWaiting = filterGrid->addChild(WinUtil::Seeds::checkBox);
-	showWaiting->setHelpId(IDH_USERS_FILTER_WAITING);
-	showWaiting->setText(_T("Pending upload"));
-	showWaiting->setChecked(BOOLSETTING(USERS_FILTER_WAITING));
-	showWaiting->onClicked(updated);
+	{
+		auto addFilterBox = [this](const tstring& text, SettingsManager::IntSetting setting, unsigned helpId) {
+			auto box = filterGrid->addChild(WinUtil::Seeds::checkBox);
+			box->setHelpId(helpId);
+			box->setText(text);
+			box->setChecked(SettingsManager::getInstance()->getBool(setting, true));
+			box->onClicked([=] {
+				SettingsManager::getInstance()->set(setting, box->getChecked());
+				handleFilterUpdated();
+			});
+		};
+
+		addFilterBox(T_("Online"), SettingsManager::USERS_FILTER_ONLINE, IDH_USERS_FILTER_ONLINE);
+		addFilterBox(T_("Favorite"), SettingsManager::USERS_FILTER_FAVORITE, IDH_USERS_FILTER_FAVORITE);
+		addFilterBox(T_("Pending download"), SettingsManager::USERS_FILTER_QUEUE, IDH_USERS_FILTER_QUEUE);
+		addFilterBox(T_("Pending upload"), SettingsManager::USERS_FILTER_WAITING, IDH_USERS_FILTER_WAITING);
+	}
 
 	splitter = addChild(SplitterContainer::Seed(0.7));
 
@@ -199,8 +195,6 @@
 
 	layout();
 
-	startup = false;
-
 	handleFilterUpdated();
 }
 
@@ -236,11 +230,6 @@
 void UsersFrame::postClosing() {
 	SettingsManager::getInstance()->set(SettingsManager::USERSFRAME_ORDER, WinUtil::toString(users->getColumnOrder()));
 	SettingsManager::getInstance()->set(SettingsManager::USERSFRAME_WIDTHS, WinUtil::toString(users->getColumnWidths()));
-
-	SettingsManager::getInstance()->set(SettingsManager::USERS_FILTER_ONLINE, showOnline->getChecked());
-	SettingsManager::getInstance()->set(SettingsManager::USERS_FILTER_FAVORITE, showFavs->getChecked());
-	SettingsManager::getInstance()->set(SettingsManager::USERS_FILTER_QUEUE, showQueue->getChecked());
-	SettingsManager::getInstance()->set(SettingsManager::USERS_FILTER_WAITING, showWaiting->getChecked());
 }
 
 UsersFrame::UserInfo::UserInfo(const UserPtr& u, bool visible) :
@@ -535,19 +524,19 @@
 		return true;
 	}
 
-	if(showOnline->getChecked() && !u->isOnline()) {
-		return false;
-	}
-
-	if(showFavs->getChecked() && !isFav(u)) {
-		return false;
-	}
-
-	if(showWaiting->getChecked() && !isWaiting(u)) {
-		return false;
-	}
-
-	if(showQueue->getChecked() && !hasDownload(u)) {
+	if(BOOLSETTING(USERS_FILTER_ONLINE) && !u->isOnline()) {
+		return false;
+	}
+
+	if(BOOLSETTING(USERS_FILTER_FAVORITE) && !isFav(u)) {
+		return false;
+	}
+
+	if(BOOLSETTING(USERS_FILTER_WAITING) && !isWaiting(u)) {
+		return false;
+	}
+
+	if(BOOLSETTING(USERS_FILTER_QUEUE) && !hasDownload(u)) {
 		return false;
 	}
 

=== modified file 'win32/UsersFrame.h'
--- win32/UsersFrame.h	2011-10-13 13:43:14 +0000
+++ win32/UsersFrame.h	2011-10-17 19:39:46 +0000
@@ -124,18 +124,12 @@
 	SplitterContainerPtr splitter;
 
 	TextBoxPtr filter;
-	CheckBoxPtr showFavs;
-	CheckBoxPtr showOnline;
-	CheckBoxPtr showQueue;
-	CheckBoxPtr showWaiting;
 	dwt::ScrolledContainerPtr scroll;
 
 	static dwt::ImageListPtr userIcons;
 
 	std::unordered_map<UserPtr, UserInfo, User::Hash> userInfos;
 
-	bool startup;
-
 	void addUser(const UserPtr& aUser);
 	void updateUser(const UserPtr& aUser);