← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3250: Add user commands to transfer menus

 

------------------------------------------------------------
revno: 3250
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2013-03-31 19:09:29 +0200
message:
  Add user commands to transfer menus
modified:
  changelog.txt
  win32/TransferView.cpp
  win32/TransferView.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	2013-03-31 16:34:44 +0000
+++ changelog.txt	2013-03-31 17:09:29 +0000
@@ -1,7 +1,8 @@
 * Rotate the icon while DC++ is loading (poy)
 * [L#243727] Allow expanding merged search results (poy)
 * Merge connections, downloads and uploads in the same list (poy)
-* Add a command to disconnect a hub (poy)
+* [L#249622] Add user commands to transfer menus
+* Add a tab menu command to disconnect a hub (poy)
 
 -- 0.811 2013-03-04 --
 * Fix status bar parts when the window is too small (poy)

=== modified file 'win32/TransferView.cpp'
--- win32/TransferView.cpp	2013-03-31 16:22:41 +0000
+++ win32/TransferView.cpp	2013-03-31 17:09:29 +0000
@@ -456,6 +456,12 @@
 
 		WinUtil::addCopyMenu(menu.get(), transfers);
 
+		set<string> hubs;
+		for(auto& i: selectedUsersImpl()) {
+			hubs.insert(i->getUser().hint);
+		}
+		prepareMenu(menu.get(), UserCommand::CONTEXT_HUB, StringList(hubs.begin(), hubs.end()));
+
 		menu->open(pt);
 		return true;
 	}
@@ -470,28 +476,6 @@
 	transfers->forEachSelected(&ItemInfo::disconnect);
 }
 
-void TransferView::runUserCommand(const UserCommand& uc) {
-	if(!WinUtil::getUCParams(this, uc, ucLineParams))
-		return;
-
-	auto ucParams = ucLineParams;
-
-	int i = -1;
-	while((i = transfers->getNext(i, LVNI_SELECTED)) != -1) {
-		auto conn = dynamic_cast<ConnectionInfo*>(transfers->getData(i));
-		if(!conn) { continue; }
-		if(!conn->getUser().user->isOnline()) { continue; }
-
-		auto tmp = ucParams;
-		tmp["fileFN"] = conn->transfer().path;
-
-		// compatibility with 0.674 and earlier
-		ucParams["file"] = ucParams["fileFN"];
-
-		ClientManager::getInstance()->userCommand(conn->getUser(), uc, tmp, true);
-	}
-}
-
 bool TransferView::handleKeyDown(int c) {
 	if(c == VK_DELETE) {
 		handleDisconnect();
@@ -654,6 +638,26 @@
 	return true;
 }
 
+void TransferView::runUserCommand(const UserCommand& uc) {
+	if(!WinUtil::getUCParams(this, uc, ucLineParams))
+		return;
+
+	set<CID> users;
+
+	for(auto& i: selectedUsersImpl()) {
+		if(!i->getUser().user->isOnline()) { continue; }
+
+		if(uc.once()) {
+			if(users.find(i->getUser().user->getCID()) != users.end())
+				continue;
+			users.insert(i->getUser().user->getCID());
+		}
+
+		auto tmp = ucLineParams;
+		ClientManager::getInstance()->userCommand(i->getUser(), uc, tmp, true);
+	}
+}
+
 void TransferView::layout() {
 	transfers->resize(dwt::Rectangle(getClientSize()));
 }

=== modified file 'win32/TransferView.h'
--- win32/TransferView.h	2013-03-31 16:22:41 +0000
+++ win32/TransferView.h	2013-03-31 17:09:29 +0000
@@ -49,6 +49,7 @@
 	public AspectUserCommand<TransferView>
 {
 	friend class AspectUserInfo<TransferView>;
+	friend class AspectUserCommand<TransferView>;
 
 public:
 	TransferView(dwt::Widget* parent, TabViewPtr mdi_);
@@ -223,12 +224,13 @@
 	bool handleContextMenu(dwt::ScreenCoordinate pt);
 	void handleForce();
 	void handleDisconnect();
-	void runUserCommand(const UserCommand& uc);
 	bool handleKeyDown(int c);
 	void handleDblClicked();
 	LRESULT handleCustomDraw(NMLVCUSTOMDRAW& data);
 	bool handleTimer();
 
+	void runUserCommand(const UserCommand& uc);
+
 	void layout();
 
 	void addConn(const UpdateInfo& ui);