← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2720: tooltips in the user matching list

 

------------------------------------------------------------
revno: 2720
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Wed 2011-12-14 20:07:55 +0100
message:
  tooltips in the user matching list
modified:
  win32/UserInfoBase.cpp
  win32/UserMatchPage.cpp
  win32/UserMatchPage.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/UserInfoBase.cpp'
--- win32/UserInfoBase.cpp	2011-12-13 17:16:36 +0000
+++ win32/UserInfoBase.cpp	2011-12-14 19:07:55 +0000
@@ -86,11 +86,11 @@
 	UserMatchManager::getInstance()->ignoreChat(user, ignore);
 }
 
-const size_t maxChars = 100; // max chars per tooltip line
-
 tstring UserInfoBase::getTooltip() const {
 	auto priv = keepHub();
 
+	static const size_t maxChars = 100; // max chars per tooltip line
+
 	tstring ret(WinUtil::getNicks(user, priv));
 	dwt::util::cutStr(ret, maxChars);
 

=== modified file 'win32/UserMatchPage.cpp'
--- win32/UserMatchPage.cpp	2011-12-13 17:16:36 +0000
+++ win32/UserMatchPage.cpp	2011-12-14 19:07:55 +0000
@@ -19,9 +19,11 @@
 #include "stdafx.h"
 #include "UserMatchPage.h"
 
+#include <dcpp/format.h>
 #include <dcpp/UserMatchManager.h>
 #include <dcpp/version.h>
 
+#include <dwt/util/StringUtils.h>
 #include <dwt/widgets/Grid.h>
 #include <dwt/widgets/MessageBox.h>
 
@@ -121,6 +123,7 @@
 	table->onDblClicked([this] { handleDoubleClick(); });
 	table->onKeyDown([this](int c) { return handleKeyDown(c); });
 	table->onSelectionChanged([this] { handleSelectionChanged(); });
+	table->setTooltips([this](int i) { return handleTooltip(i); });
 
 	// async to avoid problems if one page gets init'd before the other.
 	callAsync([this] { updateStyles(); });
@@ -178,6 +181,47 @@
 	remove->setEnabled(sel > 0);
 }
 
+tstring UserMatchPage::handleTooltip(int i) {
+	auto& matcher = list[i];
+
+	static const size_t maxChars = 100; // max chars per tooltip line
+
+	tstring ret = str(TF_("Name: %1%") % Text::toT(matcher.name));
+	dwt::util::cutStr(ret, maxChars);
+
+	auto addLine = [&ret](tstring line) {
+		dwt::util::cutStr(line, maxChars);
+		ret += _T("\r\n") + line;
+	};
+
+	if(matcher.isSet(UserMatch::FAVS))
+		addLine(T_("Match favorites"));
+	if(matcher.isSet(UserMatch::OPS))
+		addLine(T_("Match operators"));
+	if(matcher.isSet(UserMatch::BOTS))
+		addLine(T_("Match bots"));
+
+	tstring fields[UserMatch::Rule::FIELD_LAST] = { T_("Nick"), T_("CID"), T_("IP"), T_("Hub address") };
+	tstring methods[UserMatch::Rule::METHOD_LAST] = { T_("Partial match"), T_("Exact match"), T_("Regular Expression") };
+	for(auto rule = matcher.rules.cbegin(), rule_end = matcher.rules.cend(); rule != rule_end; ++rule) {
+		addLine(str(TF_("%1% %2%: %3%") % fields[rule->field] % methods[rule->getMethod()] % Text::toT(rule->pattern)));
+	}
+
+	if(matcher.isSet(UserMatch::FORCE_CHAT))
+		addLine(T_("Always show chat messages"));
+	else if(matcher.isSet(UserMatch::IGNORE_CHAT))
+		addLine(T_("Ignore chat messages"));
+
+	if(!matcher.style.font.empty())
+		addLine(T_("Custom font"));
+	if(matcher.style.textColor >= 0)
+		addLine(T_("Custom text color"));
+	if(matcher.style.bgColor >= 0)
+		addLine(T_("Custom background color"));
+
+	return ret;
+}
+
 void UserMatchPage::handleAddClicked() {
 	UserMatchDlg dlg(this);
 	if(dlg.run() == IDOK) {

=== modified file 'win32/UserMatchPage.h'
--- win32/UserMatchPage.h	2011-12-10 18:51:47 +0000
+++ win32/UserMatchPage.h	2011-12-14 19:07:55 +0000
@@ -45,6 +45,7 @@
 	void handleDoubleClick();
 	bool handleKeyDown(int c);
 	void handleSelectionChanged();
+	tstring handleTooltip(int i);
 
 	void handleAddClicked();
 	void handleEditClicked();