← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2462: file list fixes

 

------------------------------------------------------------
revno: 2462
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2011-03-18 21:38:32 +0100
message:
  file list fixes
modified:
  win32/DirectoryListingFrame.cpp
  win32/DirectoryListingFrame.h
  win32/UserInfoBase.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/DirectoryListingFrame.cpp'
--- win32/DirectoryListingFrame.cpp	2011-03-18 15:40:31 +0000
+++ win32/DirectoryListingFrame.cpp	2011-03-18 20:38:32 +0000
@@ -298,16 +298,17 @@
 	searchGrid->setEnabled(false);
 	searchGrid->setVisible(false);
 
-	// create the rebar after the rest to make sure it doesn't grab the default focus.
-	rebar = addChild(Rebar::Seed());
-
 	{
+		// create the rebar after the rest to make sure it doesn't grab the default focus.
+		rebar = addChild(Rebar::Seed());
+
+		// create the first toolbar (on the left of the address bar).
 		auto seed = ToolBar::Seed();
 		seed.style &= ~CCS_ADJUSTABLE;
 		ToolBarPtr toolbar = addChild(seed);
 
 		StringList ids;
-		auto addButton = [toolbar, &ids](unsigned icon, const tstring& text, unsigned helpId, const dwt::Dispatchers::VoidVoid<>::F& f) {
+		auto addButton = [&toolbar, &ids](unsigned icon, const tstring& text, unsigned helpId, const dwt::Dispatchers::VoidVoid<>::F& f) {
 			ids.push_back(std::string(1, '0' + ids.size()));
 			toolbar->addButton(ids.back(), WinUtil::toolbarIcon(icon), 0, text, helpId, f);
 		};
@@ -318,17 +319,17 @@
 		toolbar->setLayout(ids);
 
 		rebar->add(toolbar, RBBS_NOGRIPPER);
+
+		// create the address bar.
+		pathBox = addChild(WinUtil::Seeds::comboBoxEdit);
+		pathBox->getTextBox()->setReadOnly();
+		addWidget(pathBox);
+		pathBox->onSelectionChanged([this] { selectItem(Text::toT(history[pathBox->getSelected()])); });
+
+		rebar->add(pathBox, RBBS_NOGRIPPER);
+		rebar->sendMessage(RB_MAXIMIZEBAND, 1); // the address bar will occupy all the space it can.
 	}
 
-	pathBox = addChild(WinUtil::Seeds::comboBoxEdit);
-	pathBox->getTextBox()->setReadOnly();
-	addWidget(pathBox);
-	pathBox->onSelectionChanged([this] { selectItem(Text::toT(history[pathBox->getSelected()])); });
-
-	rebar->add(pathBox, RBBS_NOGRIPPER);
-
-	rebar->sendMessage(RB_MINIMIZEBAND); // minimize the toolbar band and maximize the path box
-
 	initStatus();
 
 	status->setSize(STATUS_FILE_LIST_DIFF, listDiff->getPreferredSize().x);
@@ -422,6 +423,10 @@
 	status->setText(STATUS_STATUS, str(TFN_("Matched %1% file", "Matched %1% files", matched) % matched));
 }
 
+void DirectoryListingFrame::UserHolder::matchQueue() {
+	lists[user]->handleMatchQueue();
+}
+
 void DirectoryListingFrame::handleListDiff() {
 	tstring file;
 	if(WinUtil::browseFileList(this, file)) {
@@ -482,7 +487,9 @@
 		text += _T(" - ") + WinUtil::getHubNames(dl->getUser()).first;
 	else
 		text += _T(": ") + error;
-	setText(text);
+
+	// bypass the recent item updater if the file list hasn't been loaded yet.
+	if(loaded) setText(text); else BaseType::setText(text);
 
 	dirs->getData(treeRoot)->setText(text);
 	dirs->redraw();
@@ -558,7 +565,7 @@
 }
 
 void DirectoryListingFrame::addUserMenu(const MenuPtr& menu) {
-	appendUserItems(getParent(), menu->appendPopup(T_("User")), true, true, false);
+	appendUserItems(getParent(), menu->appendPopup(T_("User")));
 }
 
 void DirectoryListingFrame::addTargets(const MenuPtr& parent, ItemInfo* ii) {

=== modified file 'win32/DirectoryListingFrame.h'
--- win32/DirectoryListingFrame.h	2011-03-16 18:23:54 +0000
+++ win32/DirectoryListingFrame.h	2011-03-18 20:38:32 +0000
@@ -174,9 +174,14 @@
 	int64_t speed;		/**< Speed at which this file list was downloaded */
 
 	std::unique_ptr<DirectoryListing> dl;
-	UserInfoBase user;
 	string path;
 
+	// override the default match-queue method not to download the file list again.
+	struct UserHolder : UserInfoBase {
+		UserHolder(const HintedUser& u) : UserInfoBase(u) { }
+		void matchQueue();
+	} user;
+
 	tstring error;
 	bool usingDirMenu;
 	StringList targets;
@@ -262,6 +267,8 @@
 	void back();
 	void forward();
 
+	void refresh();
+
 	void initStatusText();
 	void updateStatus();
 

=== modified file 'win32/UserInfoBase.h'
--- win32/UserInfoBase.h	2011-01-09 14:54:10 +0000
+++ win32/UserInfoBase.h	2011-03-18 20:38:32 +0000
@@ -32,14 +32,14 @@
 public:
 	UserInfoBase(const HintedUser& u) : user(u) { }
 
-	void getList();
-	void browseList();
-	void matchQueue();
-	void pm(TabViewPtr);
-	void grant();
-	void addFav();
-	void removeFromQueue();
-	void connectFav(TabViewPtr);
+	virtual void getList();
+	virtual void browseList();
+	virtual void matchQueue();
+	virtual void pm(TabViewPtr);
+	virtual void grant();
+	virtual void addFav();
+	virtual void removeFromQueue();
+	virtual void connectFav(TabViewPtr);
 
 	tstring getTooltip(bool priv) const;
 
@@ -116,9 +116,7 @@
 		handleUserFunction(std::bind(&UserInfoBase::connectFav, _1, parent));
 	}
 
-	void appendUserItems(TabViewPtr parent, dwt::MenuPtr menu,
-		bool defaultIsGetList = true, bool includeSendPM = true, bool includeGetList = true)
-	{
+	void appendUserItems(TabViewPtr parent, dwt::MenuPtr menu, bool defaultIsGetList = true, bool includeSendPM = true) {
 		UserInfoList users = t().selectedUsersImpl();
 		if(users.empty())
 			return;
@@ -126,12 +124,10 @@
 		UserInfoBase::UserTraits traits;
 		for_each(users.begin(), users.end(), std::bind(&UserInfoBase::UserTraits::parse, &traits, _1));
 
-		if(includeGetList) {
-			menu->appendItem(T_("&Get file list"), std::bind(&ThisType::handleGetList, this), dwt::IconPtr(), true, defaultIsGetList);
-			if(traits.adcOnly)
-				menu->appendItem(T_("&Browse file list"), std::bind(&ThisType::handleBrowseList, this));
-			menu->appendItem(T_("&Match queue"), std::bind(&ThisType::handleMatchQueue, this));
-		}
+		menu->appendItem(T_("&Get file list"), std::bind(&ThisType::handleGetList, this), dwt::IconPtr(), true, defaultIsGetList);
+		if(traits.adcOnly)
+			menu->appendItem(T_("&Browse file list"), std::bind(&ThisType::handleBrowseList, this));
+		menu->appendItem(T_("&Match queue"), std::bind(&ThisType::handleMatchQueue, this));
 		if(includeSendPM)
 			menu->appendItem(T_("&Send private message"), std::bind(&ThisType::handlePrivateMessage, this, parent), dwt::IconPtr(), true, !defaultIsGetList);
 		if(!traits.favOnly)