|
From: <ag...@us...> - 2011-01-02 19:22:11
|
Revision: 1845
http://zoolib.svn.sourceforge.net/zoolib/?rev=1845&view=rev
Author: agreen
Date: 2011-01-02 19:22:05 +0000 (Sun, 02 Jan 2011)
Log Message:
-----------
Have separate editing and normal accessory buttons.
Pass the indexpath down through selected/buttontapped APIs, so
we can find the physical cell in their handlers.
Modified Paths:
--------------
trunk/zoolib/source/cxx/more/zoolib/uikit/UITVController_WithSections.h
trunk/zoolib/source/cxx/more/zoolib/uikit/UITVController_WithSections.mm
Modified: trunk/zoolib/source/cxx/more/zoolib/uikit/UITVController_WithSections.h
===================================================================
--- trunk/zoolib/source/cxx/more/zoolib/uikit/UITVController_WithSections.h 2011-01-02 19:20:52 UTC (rev 1844)
+++ trunk/zoolib/source/cxx/more/zoolib/uikit/UITVController_WithSections.h 2011-01-02 19:22:05 UTC (rev 1845)
@@ -128,17 +128,19 @@
virtual ZQ<CGFloat> QRowHeight(size_t iRowIndex) = 0;
virtual ZQ<NSInteger> QIndentationLevel(size_t iRowIndex) = 0;
- virtual bool ButtonTapped(UITVController_WithSections* iTVC, UITableView* iTableView, size_t iRowIndex) = 0;
- virtual ZQ<bool> HasButton(size_t iRowIndex) = 0;
+ virtual bool ButtonTapped(UITVController_WithSections* iTVC,
+ UITableView* iTableView, NSIndexPath* iIndexPath, size_t iRowIndex) = 0;
+ virtual ZQ<bool> HasButton(bool iEditing, size_t iRowIndex) = 0;
- virtual bool RowSelected(UITVController_WithSections* iTVC, UITableView* iTableView, size_t iRowIndex) = 0;
- virtual ZQ<bool> CanSelect(bool iIEditing, size_t iRowIndex) = 0;
+ virtual bool RowSelected(UITVController_WithSections* iTVC,
+ UITableView* iTableView, NSIndexPath* iIndexPath, size_t iRowIndex) = 0;
+ virtual ZQ<bool> CanSelect(bool iEditing, size_t iRowIndex) = 0;
typedef ZCallable<ZRef<UITableViewCell>(UITableView*,size_t)> Callable_GetCell;
- typedef ZCallable<bool(UITVController_WithSections*,UITableView*,ZRef<SectionBody>,size_t)> Callable_ButtonTapped;
+ typedef ZCallable<bool(UITVController_WithSections*,UITableView*,NSIndexPath*,ZRef<SectionBody>,size_t)> Callable_ButtonTapped;
- typedef ZCallable<bool(UITVController_WithSections*,UITableView*,ZRef<SectionBody>,size_t)> Callable_RowSelected;
+ typedef ZCallable<bool(UITVController_WithSections*,UITableView*,NSIndexPath*,ZRef<SectionBody>,size_t)> Callable_RowSelected;
};
// =================================================================================================
@@ -190,11 +192,13 @@
virtual ZQ<CGFloat> QRowHeight(size_t iRowIndex);
virtual ZQ<NSInteger> QIndentationLevel(size_t iRowIndex);
- virtual bool ButtonTapped(UITVController_WithSections* iTVC, UITableView* iTableView, size_t iRowIndex);
- virtual ZQ<bool> HasButton(size_t iRowIndex);
+ virtual bool ButtonTapped(UITVController_WithSections* iTVC,
+ UITableView* iTableView, NSIndexPath* iIndexPath, size_t iRowIndex);
+ virtual ZQ<bool> HasButton(bool iEditing, size_t iRowIndex);
- virtual bool RowSelected(UITVController_WithSections* iTVC, UITableView* iTableView, size_t iRowIndex);
- virtual ZQ<bool> CanSelect(bool iIEditing, size_t iRowIndex);
+ virtual bool RowSelected(UITVController_WithSections* iTVC,
+ UITableView* iTableView, NSIndexPath* iIndexPath, size_t iRowIndex);
+ virtual ZQ<bool> CanSelect(bool iEditing, size_t iRowIndex);
//
ZQ<UITableViewCellEditingStyle> fEditingStyle;
@@ -205,6 +209,7 @@
ZRef<Callable_GetCell> fCallable_GetCell;
ZRef<Callable_ButtonTapped> fCallable_ButtonTapped;
+ ZRef<Callable_ButtonTapped> fCallable_ButtonTapped_Editing;
ZRef<Callable_RowSelected> fCallable_RowSelected;
ZRef<Callable_RowSelected> fCallable_RowSelected_Editing;
@@ -274,11 +279,13 @@
virtual ZQ<CGFloat> QRowHeight(size_t iRowIndex);
virtual ZQ<NSInteger> QIndentationLevel(size_t iRowIndex);
- virtual bool ButtonTapped(UITVController_WithSections* iTVC, UITableView* iTableView, size_t iRowIndex);
- virtual ZQ<bool> HasButton(size_t iRowIndex);
+ virtual bool ButtonTapped(UITVController_WithSections* iTVC,
+ UITableView* iTableView, NSIndexPath* iIndexPath, size_t iRowIndex);
+ virtual ZQ<bool> HasButton(bool iEditing, size_t iRowIndex);
- virtual bool RowSelected(UITVController_WithSections* iTVC, UITableView* iTableView, size_t iRowIndex);
- virtual ZQ<bool> CanSelect(bool iIEditing, size_t iRowIndex);
+ virtual bool RowSelected(UITVController_WithSections* iTVC,
+ UITableView* iTableView, NSIndexPath* iIndexPath, size_t iRowIndex);
+ virtual ZQ<bool> CanSelect(bool iEditing, size_t iRowIndex);
std::vector<ZRef<SectionBody> > fBodies_Pending;
Modified: trunk/zoolib/source/cxx/more/zoolib/uikit/UITVController_WithSections.mm
===================================================================
--- trunk/zoolib/source/cxx/more/zoolib/uikit/UITVController_WithSections.mm 2011-01-02 19:20:52 UTC (rev 1844)
+++ trunk/zoolib/source/cxx/more/zoolib/uikit/UITVController_WithSections.mm 2011-01-02 19:22:05 UTC (rev 1845)
@@ -187,33 +187,41 @@
ZQ<NSInteger> SectionBody_Concrete::QIndentationLevel(size_t iRowIndex)
{ return fIndentationLevel; }
-bool SectionBody_Concrete::ButtonTapped(
- UITVController_WithSections* iTVC, UITableView* iTableView, size_t iRowIndex)
+bool SectionBody_Concrete::ButtonTapped(UITVController_WithSections* iTVC,
+ UITableView* iTableView, NSIndexPath* iIndexPath, size_t iRowIndex)
{
if (fCallable_ButtonTapped)
- return fCallable_ButtonTapped->Call(iTVC, iTableView, this, iRowIndex);
+ return fCallable_ButtonTapped->Call(iTVC, iTableView, iIndexPath, this, iRowIndex);
return false;
}
-ZQ<bool> SectionBody_Concrete::HasButton(size_t iRowIndex)
+ZQ<bool> SectionBody_Concrete::HasButton(bool iEditing, size_t iRowIndex)
{
- if (fCallable_ButtonTapped)
- return true;
+ if (iEditing)
+ {
+ if (fCallable_ButtonTapped_Editing)
+ return true;
+ }
+ else
+ {
+ if (fCallable_ButtonTapped)
+ return true;
+ }
return null;
}
-bool SectionBody_Concrete::RowSelected(
- UITVController_WithSections* iTVC, UITableView* iTableView, size_t iRowIndex)
+bool SectionBody_Concrete::RowSelected(UITVController_WithSections* iTVC,
+ UITableView* iTableView, NSIndexPath* iIndexPath, size_t iRowIndex)
{
if ([iTableView isEditing])
{
if (fCallable_RowSelected_Editing)
- return fCallable_RowSelected_Editing->Call(iTVC, iTableView, this, iRowIndex);
+ return fCallable_RowSelected_Editing->Call(iTVC, iTableView, iIndexPath, this, iRowIndex);
}
else
{
if (fCallable_RowSelected)
- return fCallable_RowSelected->Call(iTVC, iTableView, this, iRowIndex);
+ return fCallable_RowSelected->Call(iTVC, iTableView, iIndexPath, this, iRowIndex);
}
return false;
}
@@ -484,35 +492,36 @@
return null;
}
-bool SectionBody_Multi::ButtonTapped(UITVController_WithSections* iTVC, UITableView* iTableView, size_t iRowIndex)
+bool SectionBody_Multi::ButtonTapped(UITVController_WithSections* iTVC,
+ UITableView* iTableView, NSIndexPath* iIndexPath, size_t iRowIndex)
{
size_t localRowIndex;
if (ZRef<SectionBody> theBody = this->pGetBodyAndRowIndex(localRowIndex, iRowIndex))
{
- if (theBody->ButtonTapped(iTVC, iTableView, localRowIndex))
+ if (theBody->ButtonTapped(iTVC, iTableView, iIndexPath, localRowIndex))
return true;
}
return false;
}
-ZQ<bool> SectionBody_Multi::HasButton(size_t iRowIndex)
+ZQ<bool> SectionBody_Multi::HasButton(bool iEditing, size_t iRowIndex)
{
size_t localRowIndex;
if (ZRef<SectionBody> theBody = this->pGetBodyAndRowIndex(localRowIndex, iRowIndex))
{
- if (ZQ<bool> theQ = theBody->HasButton(localRowIndex))
+ if (ZQ<bool> theQ = theBody->HasButton(iEditing, localRowIndex))
return theQ;
}
return null;
}
bool SectionBody_Multi::RowSelected(UITVController_WithSections* iTVC,
- UITableView* iTableView, size_t iRowIndex)
+ UITableView* iTableView, NSIndexPath* iIndexPath, size_t iRowIndex)
{
size_t localRowIndex;
if (ZRef<SectionBody> theBody = this->pGetBodyAndRowIndex(localRowIndex, iRowIndex))
{
- if (theBody->RowSelected(iTVC, iTableView, localRowIndex))
+ if (theBody->RowSelected(iTVC, iTableView, iIndexPath, localRowIndex))
return true;
}
return false;
@@ -633,31 +642,45 @@
if (ZRef<UITableViewCell> theCell =
theSection->GetBody()->UITableViewCellForRow(tableView, theRowIndex))
{
- if (ZQ<bool> theQ = theSection->GetBody()->HasButton(theRowIndex))
+ UITableViewCellAccessoryType theAccessoryType = UITableViewCellAccessoryNone;
+ if (![theCell accessoryView])
{
- if (theQ.Get())
- [theCell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
- else
- [theCell setEditingAccessoryType:UITableViewCellAccessoryNone];
+ if (ZQ<bool> theQ = theSection->GetBody()->HasButton(false, theRowIndex))
+ {
+ if (theQ.Get())
+ theAccessoryType = UITableViewCellAccessoryDetailDisclosureButton;
+ }
}
- else
+
+ if (theAccessoryType == UITableViewCellAccessoryNone)
{
if (ZQ<bool> theQ = theSection->GetBody()->CanSelect(false, theRowIndex))
{
if (theQ.Get())
- [theCell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
- else
- [theCell setAccessoryType:UITableViewCellAccessoryNone];
+ theAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
+ }
+ [theCell setAccessoryType:theAccessoryType];
+ UITableViewCellAccessoryType theEditingAccessoryType = UITableViewCellAccessoryNone;
+ if (![theCell editingAccessoryView])
+ {
+ if (ZQ<bool> theQ = theSection->GetBody()->HasButton(true, theRowIndex))
+ {
+ if (theQ.Get())
+ theEditingAccessoryType = UITableViewCellAccessoryDetailDisclosureButton;
+ }
+ }
+
+ if (theEditingAccessoryType == UITableViewCellAccessoryNone)
+ {
if (ZQ<bool> theQ = theSection->GetBody()->CanSelect(true, theRowIndex))
{
if (theQ.Get())
- [theCell setEditingAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
- else
- [theCell setEditingAccessoryType:UITableViewCellAccessoryNone];
+ theEditingAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
}
+ [theCell setEditingAccessoryType:theEditingAccessoryType];
return [theCell.Orphan() autorelease];
}
@@ -740,13 +763,13 @@
accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
if (ZRef<Section> theSection = [self pGetSection:indexPath.section])
- theSection->GetBody()->ButtonTapped(self, tableView, indexPath.row);
+ theSection->GetBody()->ButtonTapped(self, tableView, indexPath, indexPath.row);
}
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
if (ZRef<Section> theSection = [self pGetSection:indexPath.section])
- theSection->GetBody()->RowSelected(self, tableView, indexPath.row);
+ theSection->GetBody()->RowSelected(self, tableView, indexPath, indexPath.row);
}
- (BOOL)tableView:(UITableView *)tableView
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|