← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3245: the space bar checks/unchecks selected rows

 

------------------------------------------------------------
revno: 3245
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2013-03-30 16:55:28 +0100
message:
  the space bar checks/unchecks selected rows
removed:
  win32/Table.cpp
  win32/Table.h
modified:
  dwt/include/dwt/widgets/Table.h
  dwt/src/widgets/Table.cpp
  dwt/test/TableTest.cpp
  win32/TransferView.cpp
  win32/TypedTable.h
  win32/WinUtil.h
  win32/forward.h
  win32/stdafx.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 'dwt/include/dwt/widgets/Table.h'
--- dwt/include/dwt/widgets/Table.h	2013-03-16 13:25:11 +0000
+++ dwt/include/dwt/widgets/Table.h	2013-03-30 15:55:28 +0000
@@ -374,7 +374,9 @@
 
 	/// obsolete
 	inline void select(int i) { setSelected(i); }
+
 	void selectAll();
+	void checkSel();
 
 	ScreenCoordinate getContextMenuPos();
 

=== modified file 'dwt/src/widgets/Table.cpp'
--- dwt/src/widgets/Table.cpp	2013-03-21 23:03:56 +0000
+++ dwt/src/widgets/Table.cpp	2013-03-30 15:55:28 +0000
@@ -91,6 +91,17 @@
 
 void Table::create( const Seed & cs )
 {
+	/* handle Ctrl+A to select every item. */
+	if((cs.style & LVS_SINGLESEL) != LVS_SINGLESEL) {
+		addAccel(FCONTROL, 'A', [this] { selectAll(); });
+	}
+
+	/* handle the space bar on multi-selection tables with check-boxes (single-sel ones already handle
+	it). */
+	if((cs.lvStyle & LVS_EX_CHECKBOXES) == LVS_EX_CHECKBOXES && (cs.style & LVS_SINGLESEL) != LVS_SINGLESEL) {
+		addAccel(0, VK_SPACE, [this] { checkSel(); });
+	}
+
 	BaseType::create(cs);
 	setFont(cs.font);
 	if(cs.lvStyle != 0)
@@ -153,6 +164,21 @@
 		setSelected(i);
 }
 
+void Table::checkSel() {
+	/* check every row, unless they are all already checked; in that case, uncheck them. */
+	auto allChecked = true;
+	auto sel = getSelection();
+	for(auto i: sel) {
+		if(!isChecked(i)) {
+			allChecked = false;
+			break;
+		}
+	}
+	for(auto i: sel) {
+		setChecked(i, !allChecked);
+	}
+}
+
 void Table::clearSelection() {
 	int i = -1;
 	while((i = getNext(i, LVNI_SELECTED)) != -1) {

=== modified file 'dwt/test/TableTest.cpp'
--- dwt/test/TableTest.cpp	2013-03-16 13:25:11 +0000
+++ dwt/test/TableTest.cpp	2013-03-30 15:55:28 +0000
@@ -9,7 +9,9 @@
 	window->create();
 	window->onClosing([] { return ::PostQuitMessage(0), true; });
 
-	auto table = window->addChild(dwt::Table::Seed());
+	auto seed = dwt::Table::Seed();
+	seed.lvStyle |= LVS_EX_CHECKBOXES;
+	auto table = window->addChild(seed);
 
 	table->addColumn(dwt::Column(_T("Column A")));
 	table->addColumn(dwt::Column(_T("Column B")));
@@ -18,17 +20,22 @@
 	table->addColumn(_T("Column C"), dwt::Column::SIZE_TO_HEADER);
 
 	table->setColumnWidth(0, 100);
+	table->setColumnWidth(1, 200);
 
 	auto order = table->getColumnOrder();
 	order[0] = 1;
 	order[1] = 0;
 	table->setColumnOrder(order);
 
-	std::vector<tstring> rows;
-	rows.push_back(_T("A"));
-	rows.push_back(_T("B"));
-
-	table->insert(rows);
+	std::vector<tstring> row(2);
+
+	row[0] = _T("A1");
+	row[1] = _T("B1");
+	table->insert(row);
+
+	row[0] = _T("A2");
+	row[1] = _T("B2");
+	table->insert(row);
 
 	table->resize(window->getClientSize());
 	window->onSized([=](const dwt::SizedEvent&) { table->resize(window->getClientSize()); });

=== removed file 'win32/Table.cpp'
--- win32/Table.cpp	2013-01-18 21:28:38 +0000
+++ win32/Table.cpp	1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2001-2013 Jacek Sieka, arnetheduck on gmail point com
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "stdafx.h"
-
-#include "Table.h"
-
-Table::Seed::Seed() :
-BaseType::Seed()
-{
-}
-
-Table::Table(dwt::Widget* parent) :
-BaseType(parent)
-{
-	addAccel(FCONTROL, 'A', [this] { selectAll(); });
-}

=== removed file 'win32/Table.h'
--- win32/Table.h	2013-01-18 21:28:38 +0000
+++ win32/Table.h	1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2001-2013 Jacek Sieka, arnetheduck on gmail point com
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef DCPLUSPLUS_WIN32_Table_H_
-#define DCPLUSPLUS_WIN32_Table_H_
-
-#include <dwt/widgets/Table.h>
-
-/** Our own flavour of list views that handle the Ctrl+A shortcut */
-class Table : public dwt::Table {
-private:
-	typedef dwt::Table BaseType;
-	friend class dwt::WidgetCreator<Table>;
-
-public:
-	typedef Table ThisType;
-
-	typedef ThisType* ObjectType;
-
-	struct Seed : public BaseType::Seed {
-		typedef ThisType WidgetType;
-
-		Seed();
-	};
-
-	explicit Table(dwt::Widget* parent);
-};
-
-#endif /*Table_H_*/

=== modified file 'win32/TransferView.cpp'
--- win32/TransferView.cpp	2013-03-30 14:28:28 +0000
+++ win32/TransferView.cpp	2013-03-30 15:55:28 +0000
@@ -402,8 +402,9 @@
 
 		set<TransferInfo*> files;
 		for(auto i: sel) {
-			if(!transfer->getText(COLUMN_FILE).empty()) {
-				files.insert(&transfers->getData(i)->transfer());
+			auto& transfer = transfers->getData(i)->transfer();
+			if(!transfer.getText(COLUMN_FILE).empty()) {
+				files.insert(&transfer);
 			}
 		}
 		if(files.size() == 1) {
@@ -959,6 +960,7 @@
 	ui->setStatus(ConnectionInfo::STATUS_WAITING);
 	ui->setStatusString(T_("Idle"));
 	ui->setTransferred(t->getPos(), t->getActual(), t->getSize());
+	ui->setSpeed(0);
 
 	updatedConn(ui);
 }
@@ -968,6 +970,7 @@
 	ui->setFile(d->getPath());
 	ui->setStatus(ConnectionInfo::STATUS_WAITING);
 	ui->setStatusString(Text::toT(aReason));
+	ui->setSpeed(0);
 
 	updatedConn(ui);
 }

=== modified file 'win32/TypedTable.h'
--- win32/TypedTable.h	2013-01-18 21:28:38 +0000
+++ win32/TypedTable.h	2013-03-30 15:55:28 +0000
@@ -20,7 +20,6 @@
 #define DCPLUSPLUS_WIN32_TYPED_TABLE_H
 
 #include "forward.h"
-#include "Table.h"
 #include "WinUtil.h"
 
 /** Table with an object associated to each item.

=== modified file 'win32/WinUtil.h'
--- win32/WinUtil.h	2013-03-22 16:30:58 +0000
+++ win32/WinUtil.h	2013-03-30 15:55:28 +0000
@@ -34,12 +34,12 @@
 #include <dwt/widgets/ComboBox.h>
 #include <dwt/widgets/GroupBox.h>
 #include <dwt/widgets/Label.h>
+#include <dwt/widgets/Table.h>
 #include <dwt/widgets/TabView.h>
 #include <dwt/widgets/Tree.h>
 
 #include "forward.h"
 #include "RichTextBox.h"
-#include "Table.h"
 
 using std::unordered_map;
 
@@ -50,6 +50,7 @@
 using dwt::Label;
 using dwt::Menu;
 using dwt::TextBox;
+using dwt::Table;
 using dwt::TabView;
 using dwt::Tree;
 

=== modified file 'win32/forward.h'
--- win32/forward.h	2013-01-18 21:28:38 +0000
+++ win32/forward.h	2013-03-30 15:55:28 +0000
@@ -36,6 +36,7 @@
 using dwt::SliderPtr;
 using dwt::SpinnerPtr;
 using dwt::SplitterContainerPtr;
+using dwt::TablePtr;
 using dwt::TabViewPtr;
 using dwt::TextBoxPtr;
 using dwt::ToolBarPtr;
@@ -49,12 +50,9 @@
 class RichTextBox;
 typedef RichTextBox* RichTextBoxPtr;
 
-class Table;
-typedef Table* TablePtr;
-
 class TransferView;
 
-template<typename ContentType, bool managed = true, typename TableType = Table>
+template<typename ContentType, bool managed = true, typename TableType = dwt::Table>
 class TypedTable;
 
 template<typename ContentType, bool managed = true, typename TreeType = dwt::Tree>

=== modified file 'win32/stdafx.h'
--- win32/stdafx.h	2013-01-18 21:28:38 +0000
+++ win32/stdafx.h	2013-03-30 15:55:28 +0000
@@ -53,7 +53,6 @@
 
 #include "RichTextBox.h"
 #include "ShellMenu.h"
-#include "Table.h"
 
 #endif