← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2166: allow StringListDlg's edit functionality to be overriden

 

------------------------------------------------------------
revno: 2166
committer: poy <poy@xxxxxxxxxx>
branch nick: repo
timestamp: Sat 2010-06-19 17:28:04 +0200
message:
  allow StringListDlg's edit functionality to be overriden
modified:
  win32/HubListsDlg.cpp
  win32/HubListsDlg.h
  win32/StringListDlg.cpp
  win32/StringListDlg.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/HubListsDlg.cpp'
--- win32/HubListsDlg.cpp	2010-06-08 20:04:18 +0000
+++ win32/HubListsDlg.cpp	2010-06-19 15:28:04 +0000
@@ -24,6 +24,7 @@
 
 #include <dcpp/FavoriteManager.h>
 #include <dcpp/StringTokenizer.h>
+#include "ParamDlg.h"
 
 HubListsDlg::HubListsDlg(dwt::Widget* parent) :
 StringListDlg(parent, getHubLists())
@@ -71,6 +72,23 @@
 			insert(*i);
 }
 
+void HubListsDlg::edit(unsigned row, const tstring& s) {
+	ParamDlg dlg(this, getEditTitle(), getEditDescription(), s);
+	if(dlg.run() == IDOK) {
+		bool modified = false;
+		StringTokenizer<tstring> t(dlg.getValue(), ';');
+		for(TStringIterC i = t.getTokens().begin(), iend = t.getTokens().end(); i != iend; ++i)
+			if(!i->empty()) {
+				if(!modified) {
+					modify(row, *i);
+					modified = true;
+				} else {
+					insert(*i, ++row);
+				}
+			}
+	}
+}
+
 TStringList HubListsDlg::getHubLists() {
 	TStringList ret;
 	StringList lists(FavoriteManager::getInstance()->getHubLists());

=== modified file 'win32/HubListsDlg.h'
--- win32/HubListsDlg.h	2010-06-08 20:04:18 +0000
+++ win32/HubListsDlg.h	2010-06-19 15:28:04 +0000
@@ -34,6 +34,7 @@
 	tstring getEditDescription() const;
 	unsigned getHelpId(HelpFields field) const;
 	void add(const tstring& s);
+	void edit(unsigned row, const tstring& s);
 
 	static TStringList getHubLists();
 };

=== modified file 'win32/StringListDlg.cpp'
--- win32/StringListDlg.cpp	2010-06-08 20:04:18 +0000
+++ win32/StringListDlg.cpp	2010-06-19 15:28:04 +0000
@@ -51,6 +51,10 @@
 	list->ensureVisible(index);
 }
 
+void StringListDlg::modify(unsigned row, const tstring& text) {
+	list->setText(row, 0, text);
+}
+
 tstring StringListDlg::getTitle() const {
 	return T_("List configuration");
 }
@@ -80,6 +84,12 @@
 	insert(s);
 }
 
+void StringListDlg::edit(unsigned row, const tstring& s) {
+	ParamDlg dlg(this, getEditTitle(), getEditDescription(), s);
+	if(dlg.run() == IDOK)
+		modify(row, dlg.getValue());
+}
+
 bool StringListDlg::handleInitDialog(const TStringList& initialValues) {
 	setHelpId(getHelpId(HELP_DIALOG));
 
@@ -204,9 +214,7 @@
 void StringListDlg::handleEditClicked() {
 	int i = -1;
 	while((i = list->getNext(i, LVNI_SELECTED)) != -1) {
-		ParamDlg dlg(this, getEditTitle(), getEditDescription(), list->getText(i, 0));
-		if(dlg.run() == IDOK)
-			list->setText(i, 0, dlg.getValue());
+		edit(i, list->getText(i, 0));
 	}
 }
 

=== modified file 'win32/StringListDlg.h'
--- win32/StringListDlg.h	2010-06-08 20:04:18 +0000
+++ win32/StringListDlg.h	2010-06-19 15:28:04 +0000
@@ -43,6 +43,7 @@
 	};
 
 	void insert(const tstring& line, int index = -1);
+	void modify(unsigned row, const tstring& value);
 
 private:
 	virtual tstring getTitle() const;
@@ -50,6 +51,7 @@
 	virtual tstring getEditDescription() const;
 	virtual unsigned getHelpId(HelpFields field) const;
 	virtual void add(const tstring& s);
+	virtual void edit(unsigned row, const tstring& s);
 
 	GridPtr grid;
 	TextBoxPtr editBox;