Skip to content

Commit

Permalink
Merge pull request #3975 from zeeMonkeez/remove_SelectableView_dupe
Browse files Browse the repository at this point in the history
Remove duplicate definition of SelectableView from kivy.uix.listview
  • Loading branch information
dessant committed Feb 18, 2016
2 parents e357f1c + 101e38a commit 55bf644
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 49 deletions.
2 changes: 1 addition & 1 deletion kivy/adapters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
An adapter is a mediating controller-type class that processes and presents
data for use in views. It does this by generating models, generally lists of
:class:`~kivy.uix.listview.SelectableView` items, that are consumed and
:class:`~kivy.uix.selectableview.SelectableView` items, that are consumed and
presented by views. Views are top-level widgets, such as a
:class:`~kivy.uix.listview.ListView`, that allow users to scroll through
and (optionally) interact with your data.
Expand Down
2 changes: 1 addition & 1 deletion kivy/factory_registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
r('ListItemButton', module='kivy.uix.listview')
r('ListItemLabel', module='kivy.uix.listview')
r('ListView', module='kivy.uix.listview')
r('SelectableView', module='kivy.uix.listview')
r('SelectableView', module='kivy.uix.selectableview')
r('ModalView', module='kivy.uix.modalview')
r('ProgressBar', module='kivy.uix.progressbar')
r('Popup', module='kivy.uix.popup')
Expand Down
2 changes: 1 addition & 1 deletion kivy/tests/test_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import unittest

from kivy.uix.listview import SelectableView
from kivy.uix.selectableview import SelectableView
from kivy.uix.listview import ListItemButton
from kivy.uix.listview import ListItemLabel
from kivy.uix.listview import CompositeListItem
Expand Down
52 changes: 6 additions & 46 deletions kivy/uix/listview.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class MyListView(BoxLayout):
a Kivy view that is to be instantiated for each list item. There
are several built-in types available, including ListItemLabel and
ListItemButton, or you can make your own class that mixes in the
required :class:`~kivy.uix.listview.SelectableView`.
required :class:`~kivy.uix.selectableview.SelectableView`.
* :attr:`~kivy.adapters.adapter.Adapter.template`:
the name of a Kivy language (kv) template that defines the
Expand Down Expand Up @@ -390,7 +390,7 @@ class DataItem(SelectableDataItem):
Using an Item View Template
---------------------------
:class:`~kivy.uix.listview.SelectableView` is another simple mixin class that
:class:`~kivy.uix.selectableview.SelectableView` is another simple mixin class that
has required properties for a list item: text, and is_selected. To make your
own template, mix it in as follows::
Expand Down Expand Up @@ -546,53 +546,13 @@ class DataItem(SelectableDataItem):
from kivy.uix.boxlayout import BoxLayout
from kivy.adapters.simplelistadapter import SimpleListAdapter
from kivy.uix.abstractview import AbstractView
from kivy.uix.selectableview import SelectableView
from kivy.properties import ObjectProperty, DictProperty, \
NumericProperty, ListProperty, BooleanProperty
from kivy.lang import Builder
from math import ceil, floor


class SelectableView(object):
'''The :class:`~kivy.uix.listview.SelectableView` mixin is used to design
list items and other classes that are to be instantiated by an adapter for
use in a listview. The :class:`~kivy.adapters.listadapter.ListAdapter`
and :class:`~kivy.adapters.dictadapter.DictAdapter` adapters are
selection-enabled. select() and deselect() are to be overridden with
display code to mark items as selected or not, if desired.
'''

index = NumericProperty(-1)
'''The index into the underlying data list or the data item this view
represents.
:attr:`index` is a :class:`~kivy.properties.NumericProperty`, default
to -1.
'''

is_selected = BooleanProperty(False)
'''A SelectableView instance carries this property, which should be kept
in sync with the equivalent property in the data item it represents.
:attr:`is_selected` is a :class:`~kivy.properties.BooleanProperty`, default
to False.
'''

def __init__(self, **kwargs):
super(SelectableView, self).__init__(**kwargs)

def select(self, *args):
'''The list item is responsible for updating the display for
being selected, if desired.
'''
self.is_selected = True

def deselect(self, *args):
'''The list item is responsible for updating the display for
being unselected, if desired.
'''
self.is_selected = False


class ListItemReprMixin(Label):
'''
The :class:`~kivy.uix.listview.ListItemReprMixin` provides a
Expand All @@ -611,7 +571,7 @@ def __repr__(self):

class ListItemButton(ListItemReprMixin, SelectableView, Button):
''':class:`~kivy.uix.listview.ListItemButton` mixes
:class:`~kivy.uix.listview.SelectableView` with
:class:`~kivy.uix.selectableview.SelectableView` with
:class:`~kivy.uix.button.Button` to produce a button suitable for use in
:class:`~kivy.uix.listview.ListView`.
'''
Expand Down Expand Up @@ -656,7 +616,7 @@ def deselect_from_composite(self, *args):

class ListItemLabel(ListItemReprMixin, SelectableView, Label):
''':class:`~kivy.uix.listview.ListItemLabel` mixes
:class:`~kivy.uix.listview.SelectableView` with
:class:`~kivy.uix.selectableview.SelectableView` with
:class:`~kivy.uix.label.Label` to produce a label suitable for use in
:class:`~kivy.uix.listview.ListView`.
'''
Expand All @@ -683,7 +643,7 @@ def deselect_from_composite(self, *args):

class CompositeListItem(SelectableView, BoxLayout):
''':class:`~kivy.uix.listview.CompositeListItem` mixes
:class:`~kivy.uix.listview.SelectableView` with :class:`BoxLayout` for a
:class:`~kivy.uix.selectableview.SelectableView` with :class:`BoxLayout` for a
generic container-style list item, to be used in
:class:`~kivy.uix.listview.ListView`.
'''
Expand Down

0 comments on commit 55bf644

Please sign in to comment.