← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2426: UsersFrame updates

 

------------------------------------------------------------
revno: 2426
committer: Jacek Sieka <arnetheduck@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Sat 2011-02-19 16:32:03 +0100
message:
  UsersFrame updates
modified:
  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 'win32/UsersFrame.cpp'
--- win32/UsersFrame.cpp	2011-02-08 19:27:11 +0000
+++ win32/UsersFrame.cpp	2011-02-19 15:32:03 +0000
@@ -24,6 +24,7 @@
 
 #include <dcpp/FavoriteManager.h>
 #include <dcpp/ClientManager.h>
+#include <dcpp/QueueManager.h>
 #include <dcpp/version.h>
 
 const string UsersFrame::id = "Users";
@@ -50,6 +51,14 @@
 {
 	{ "NI", T_("Nick") },
 	{ "DE", T_("Description") },
+	{ "EM", T_("E-Mail"),
+	{ "SL", T_("Slots") },
+	{ "SF", T_("Shared files") },
+	{ "SS", T_("Shared bytes") },
+	{ "I4", T_("IP (v4)") },
+	{ "I6", T_("IP (v6)") },
+	{ "VE", T_("Client") },
+	{ "", _T("") }
 };
 
 UsersFrame::UsersFrame(TabViewPtr parent) :
@@ -57,16 +66,26 @@
 	users(0),
 	startup(true)
 {
-	filterGrid = addChild(Grid::Seed(1, 2));
+	filterGrid = addChild(Grid::Seed(1, 4));
 
 	filter = filterGrid->addChild(WinUtil::Seeds::textBox);
 	filter->onUpdated(std::bind(&UsersFrame::handleFilterUpdated, this));
 	filterGrid->column(0).mode = GridInfo::FILL;
 
+	showOnline = filterGrid->addChild(WinUtil::Seeds::checkBox);
+	showOnline->setText(_T("Online"));
+	showOnline->setChecked(); // TODO save / restore last state
+	showOnline->onClicked(std::bind(&UsersFrame::handleFilterUpdated, this));
+
 	showFavs = filterGrid->addChild(WinUtil::Seeds::checkBox);
-	showFavs->setText(_T("Favorite users only"));
+	showFavs->setText(_T("Favorite"));
+	showFavs->setChecked();	// TODO save / restore last state
 	showFavs->onClicked(std::bind(&UsersFrame::handleFilterUpdated, this));
 
+	showQueue = filterGrid->addChild(WinUtil::Seeds::checkBox);
+	showQueue->setText(_T("Download queue"));
+	showQueue->onClicked(std::bind(&UsersFrame::handleFilterUpdated, this));
+
 	splitter = addChild(VSplitter::Seed(0.7));
 
 	if(!userIcons) {
@@ -145,11 +164,12 @@
 	status->layout(r);
 
 	auto r2 = r;
-	r2.size.y = filter->getPreferredSize().y;
+	auto r2y = filter->getPreferredSize().y;
+	r2.pos.y = r2.pos.y + r2.size.y - r2y;
+	r2.size.y = r2y;
 
 	filterGrid->layout(r2);
 
-	r.pos.y += filter->getWindowSize().y + 3;
 	r.size.y -= filter->getWindowSize().y + 3;
 
 	splitter->layout(r);
@@ -250,6 +270,10 @@
 
 	userInfo->clearRows();
 
+	if(users->countSelected() != 1) {
+		return;
+	}
+
 	auto sel = users->getSelectedData();
 	if(!sel) {
 		return;
@@ -262,7 +286,17 @@
 	}
 
 	auto info = ui->getIdentity().getInfo();
-	tstring text;
+
+	for(auto f = fields; !f->field.empty(); ++f) {
+		auto i = info.find(f->field);
+		if(i != info.end()) {
+			userInfo->addRow(GridInfo());
+			userInfo->addChild(Label::Seed(f->name));
+			userInfo->addChild(Label::Seed(Text::toT(i->second)));
+			info.erase(i);
+		}
+	}
+
 	for(auto i = info.begin(); i != info.end(); ++i) {
 		userInfo->addRow(GridInfo());
 		userInfo->addChild(Label::Seed(Text::toT(i->first)));
@@ -368,13 +402,21 @@
 }
 
 bool UsersFrame::matches(const UserInfo &ui) {
-	if(showFavs->getChecked() && !FavoriteManager::getInstance()->isFavoriteUser(ui.getUser())) {
-		return false;
-	}
 
 	auto txt = filter->getText();
-
-	if(Util::findSubString(ui.columns[COLUMN_NICK], txt) != string::npos) {
+	if(!txt.empty() && Util::findSubString(ui.columns[COLUMN_NICK], txt) == string::npos) {
+		return false;
+	}
+
+	if(showOnline->getChecked() && ui.getUser().user->isOnline()) {
+		return true;
+	}
+
+	if(showFavs->getChecked() && FavoriteManager::getInstance()->isFavoriteUser(ui.getUser())) {
+		return true;
+	}
+
+	if(showQueue->getChecked() && QueueManager::getInstance()->getQueued(ui.getUser()) > 0) {
 		return true;
 	}
 

=== modified file 'win32/UsersFrame.h'
--- win32/UsersFrame.h	2011-02-08 19:27:11 +0000
+++ win32/UsersFrame.h	2011-02-19 15:32:03 +0000
@@ -126,6 +126,8 @@
 
 	TextBoxPtr filter;
 	CheckBoxPtr showFavs;
+	CheckBoxPtr showOnline;
+	CheckBoxPtr showQueue;
 
 	static dwt::ImageListPtr userIcons;