1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2024-11-10 01:39:02 +00:00
dupeguru/help/en/developer/hscommon/gui/table.html

441 lines
38 KiB
HTML
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>hscommon.gui.table &#8212; dupeGuru 4.0.3 documentation</title>
<link rel="stylesheet" href="../../../_static/haiku.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<script type="text/javascript" src="../../../_static/documentation_options.js"></script>
<script type="text/javascript" src="../../../_static/jquery.js"></script>
<script type="text/javascript" src="../../../_static/underscore.js"></script>
<script type="text/javascript" src="../../../_static/doctools.js"></script>
<script type="text/javascript" src="../../../_static/translations.js"></script>
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
<link rel="next" title="hscommon.gui.text_field" href="text_field.html" />
<link rel="prev" title="hscommon.gui.selectable_list" href="selectable_list.html" />
</head><body>
<div class="header" role="banner"><h1 class="heading"><a href="../../../index.html">
<span>dupeGuru 4.0.3 documentation</span></a></h1>
<h2 class="heading"><span>hscommon.gui.table</span></h2>
</div>
<div class="topnav" role="navigation" aria-label="top navigation">
<p>
«&#160;&#160;<a href="selectable_list.html">hscommon.gui.selectable_list</a>
&#160;&#160;::&#160;&#160;
<a class="uplink" href="../../../index.html">Contents</a>
&#160;&#160;::&#160;&#160;
<a href="text_field.html">hscommon.gui.text_field</a>&#160;&#160;»
</p>
</div>
<div class="content">
<div class="section" id="module-hscommon.gui.table">
<span id="hscommon-gui-table"></span><h1>hscommon.gui.table<a class="headerlink" href="#module-hscommon.gui.table" title="Permalink to this headline"></a></h1>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#hscommon.gui.table.Table" title="hscommon.gui.table.Table"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Table</span></code></a>()</td>
<td>Sortable and selectable sequence of <a class="reference internal" href="#hscommon.gui.table.Row" title="hscommon.gui.table.Row"><code class="xref py py-class docutils literal notranslate"><span class="pre">Row</span></code></a>.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#hscommon.gui.table.Row" title="hscommon.gui.table.Row"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Row</span></code></a>(table)</td>
<td>Represents a row in a <a class="reference internal" href="#hscommon.gui.table.Table" title="hscommon.gui.table.Table"><code class="xref py py-class docutils literal notranslate"><span class="pre">Table</span></code></a>.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#hscommon.gui.table.GUITable" title="hscommon.gui.table.GUITable"><code class="xref py py-obj docutils literal notranslate"><span class="pre">GUITable</span></code></a>()</td>
<td>Cross-toolkit GUI-enabled table view.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#hscommon.gui.table.GUITableView" title="hscommon.gui.table.GUITableView"><code class="xref py py-obj docutils literal notranslate"><span class="pre">GUITableView</span></code></a></td>
<td>Expected interface for <a class="reference internal" href="#hscommon.gui.table.GUITable" title="hscommon.gui.table.GUITable"><code class="xref py py-class docutils literal notranslate"><span class="pre">GUITable</span></code></a>s view.</td>
</tr>
</tbody>
</table>
<dl class="class">
<dt id="hscommon.gui.table.Table">
<em class="property">class </em><code class="descclassname">hscommon.gui.table.</code><code class="descname">Table</code><a class="headerlink" href="#hscommon.gui.table.Table" title="Permalink to this definition"></a></dt>
<dd><p>Sortable and selectable sequence of <a class="reference internal" href="#hscommon.gui.table.Row" title="hscommon.gui.table.Row"><code class="xref py py-class docutils literal notranslate"><span class="pre">Row</span></code></a>.</p>
<p>In fact, the Table is very similar to <a class="reference internal" href="selectable_list.html#hscommon.gui.selectable_list.SelectableList" title="hscommon.gui.selectable_list.SelectableList"><code class="xref py py-class docutils literal notranslate"><span class="pre">SelectableList</span></code></a> in
practice and differs mostly in principle. Their difference lies in the nature of their items
they manage. With the Table, rows usually have many properties, presented in columns, and they
have to subclass <a class="reference internal" href="#hscommon.gui.table.Row" title="hscommon.gui.table.Row"><code class="xref py py-class docutils literal notranslate"><span class="pre">Row</span></code></a>.</p>
<p>Usually used with <a class="reference internal" href="column.html#hscommon.gui.column.Column" title="hscommon.gui.column.Column"><code class="xref py py-class docutils literal notranslate"><span class="pre">Column</span></code></a>.</p>
<p>Subclasses <a class="reference internal" href="selectable_list.html#hscommon.gui.selectable_list.Selectable" title="hscommon.gui.selectable_list.Selectable"><code class="xref py py-class docutils literal notranslate"><span class="pre">Selectable</span></code></a>.</p>
<dl class="method">
<dt id="hscommon.gui.table.Table.append">
<code class="descname">append</code><span class="sig-paren">(</span><em>item</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.Table.append" title="Permalink to this definition"></a></dt>
<dd><p>Appends <code class="docutils literal notranslate"><span class="pre">item</span></code> at the end of the table.</p>
<p>If theres a footer, the item is inserted before it.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.Table.insert">
<code class="descname">insert</code><span class="sig-paren">(</span><em>index</em>, <em>item</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.Table.insert" title="Permalink to this definition"></a></dt>
<dd><p>Inserts <code class="docutils literal notranslate"><span class="pre">item</span></code> at <code class="docutils literal notranslate"><span class="pre">index</span></code> in the table.</p>
<p>If theres a header, will make sure we dont insert before it, and if theres a footer, will
make sure that we dont insert after it.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.Table.remove">
<code class="descname">remove</code><span class="sig-paren">(</span><em>row</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.Table.remove" title="Permalink to this definition"></a></dt>
<dd><p>Removes <code class="docutils literal notranslate"><span class="pre">row</span></code> from table.</p>
<p>If <code class="docutils literal notranslate"><span class="pre">row</span></code> is a header or footer, that header or footer will be set to <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.Table.sort_by">
<code class="descname">sort_by</code><span class="sig-paren">(</span><em>column_name</em>, <em>desc=False</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.Table.sort_by" title="Permalink to this definition"></a></dt>
<dd><p>Sort table by <code class="docutils literal notranslate"><span class="pre">column_name</span></code>.</p>
<p>Sort key for each row is computed from <a class="reference internal" href="#hscommon.gui.table.Row.sort_key_for_column" title="hscommon.gui.table.Row.sort_key_for_column"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Row.sort_key_for_column()</span></code></a>.</p>
<p>If <code class="docutils literal notranslate"><span class="pre">desc</span></code> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, sort order is reversed.</p>
<p>If present, header and footer will always be first and last, respectively.</p>
</dd></dl>
<dl class="attribute">
<dt id="hscommon.gui.table.Table.footer">
<code class="descname">footer</code><a class="headerlink" href="#hscommon.gui.table.Table.footer" title="Permalink to this definition"></a></dt>
<dd><p>If set, a row that always stay at the bottom of the table.</p>
<p><a class="reference internal" href="#hscommon.gui.table.Row" title="hscommon.gui.table.Row"><code class="xref py py-class docutils literal notranslate"><span class="pre">Row</span></code></a>. <em>get/set</em>.</p>
<p>When set to something else than <code class="docutils literal notranslate"><span class="pre">None</span></code>, <code class="docutils literal notranslate"><span class="pre">header</span></code> and <code class="docutils literal notranslate"><span class="pre">footer</span></code> represent rows that will
always be kept in first and/or last position, regardless of sorting. <code class="docutils literal notranslate"><span class="pre">len()</span></code> and indexing
will include them, which means that if theres a header, <code class="docutils literal notranslate"><span class="pre">table[0]</span></code> returns it and if
theres a footer, <code class="docutils literal notranslate"><span class="pre">table[-1]</span></code> returns it. To make things short, all list-like functions
work with header and footer “on”. But things get fuzzy for <code class="docutils literal notranslate"><span class="pre">append()</span></code> and <code class="docutils literal notranslate"><span class="pre">insert()</span></code>
because these will ensure that no “normal” row gets inserted before the header or after the
footer.</p>
<p>Adding and removing footer here and there might seem (and is) hackish, but its much simpler
than the alternative (when, of course, you need such a feature), which is to override magic
methods and adjust the results. When we do that, there the slice stuff that we have to
implement and it gets quite complex. Moreover, the most frequent operation on a table is
<code class="docutils literal notranslate"><span class="pre">__getitem__</span></code>, and making checks to know whether the key is a header or footer at each
call would make that operation, which is the most used, slower.</p>
</dd></dl>
<dl class="attribute">
<dt id="hscommon.gui.table.Table.header">
<code class="descname">header</code><a class="headerlink" href="#hscommon.gui.table.Table.header" title="Permalink to this definition"></a></dt>
<dd><p>If set, a row that always stay at the bottom of the table.</p>
<p>See <a class="reference internal" href="#hscommon.gui.table.Table.footer" title="hscommon.gui.table.Table.footer"><code class="xref py py-attr docutils literal notranslate"><span class="pre">footer</span></code></a> for details.</p>
</dd></dl>
<dl class="attribute">
<dt id="hscommon.gui.table.Table.row_count">
<code class="descname">row_count</code><a class="headerlink" href="#hscommon.gui.table.Table.row_count" title="Permalink to this definition"></a></dt>
<dd><p>Number or rows in the table (without counting header and footer).</p>
<p><em>int</em>. <em>read-only</em>.</p>
</dd></dl>
<dl class="attribute">
<dt id="hscommon.gui.table.Table.rows">
<code class="descname">rows</code><a class="headerlink" href="#hscommon.gui.table.Table.rows" title="Permalink to this definition"></a></dt>
<dd><p>List of rows in the table, excluding header and footer.</p>
<p>List of <a class="reference internal" href="#hscommon.gui.table.Row" title="hscommon.gui.table.Row"><code class="xref py py-class docutils literal notranslate"><span class="pre">Row</span></code></a>. <em>read-only</em>.</p>
</dd></dl>
<dl class="attribute">
<dt id="hscommon.gui.table.Table.selected_row">
<code class="descname">selected_row</code><a class="headerlink" href="#hscommon.gui.table.Table.selected_row" title="Permalink to this definition"></a></dt>
<dd><p>Selected row according to <code class="xref py py-attr docutils literal notranslate"><span class="pre">Selectable.selected_index</span></code>.</p>
<p><a class="reference internal" href="#hscommon.gui.table.Row" title="hscommon.gui.table.Row"><code class="xref py py-class docutils literal notranslate"><span class="pre">Row</span></code></a>. <em>get/set</em>.</p>
<p>When setting this attribute, we look up the index of the row and set the selected index from
there. If the row isnt in the list, selection isnt changed.</p>
</dd></dl>
<dl class="attribute">
<dt id="hscommon.gui.table.Table.selected_rows">
<code class="descname">selected_rows</code><a class="headerlink" href="#hscommon.gui.table.Table.selected_rows" title="Permalink to this definition"></a></dt>
<dd><p>List of selected rows based on <a class="reference internal" href="selectable_list.html#hscommon.gui.selectable_list.Selectable.selected_indexes" title="hscommon.gui.selectable_list.Selectable.selected_indexes"><code class="xref py py-attr docutils literal notranslate"><span class="pre">selected_indexes</span></code></a>.</p>
<p>List of <a class="reference internal" href="#hscommon.gui.table.Row" title="hscommon.gui.table.Row"><code class="xref py py-class docutils literal notranslate"><span class="pre">Row</span></code></a>. <em>read-only</em>.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="hscommon.gui.table.Row">
<em class="property">class </em><code class="descclassname">hscommon.gui.table.</code><code class="descname">Row</code><span class="sig-paren">(</span><em>table</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.Row" title="Permalink to this definition"></a></dt>
<dd><p>Represents a row in a <a class="reference internal" href="#hscommon.gui.table.Table" title="hscommon.gui.table.Table"><code class="xref py py-class docutils literal notranslate"><span class="pre">Table</span></code></a>.</p>
<p>It holds multiple values to be represented through columns. Its its role to prepare data
fetched from model instances into ready-to-present-in-a-table fashion. You will do this in
<a class="reference internal" href="#hscommon.gui.table.Row.load" title="hscommon.gui.table.Row.load"><code class="xref py py-meth docutils literal notranslate"><span class="pre">load()</span></code></a>.</p>
<p>When you do this, youll put the result into arbitrary attributes, which will later be fetched
by your table for presentation to the user.</p>
<p>You can organize your attributes in whatever way you want, but theres a convention you can
follow if you want to minimize subclassing and use default behavior:</p>
<ol class="arabic simple">
<li>Attribute name = column name. If your attribute is <code class="docutils literal notranslate"><span class="pre">foobar</span></code>, whenever we refer to
<code class="docutils literal notranslate"><span class="pre">column_name</span></code>, you refer to that attribute with the column name <code class="docutils literal notranslate"><span class="pre">foobar</span></code>.</li>
<li>Public attributes are for <em>formatted</em> value, that is, user readable strings.</li>
<li>Underscore prefix is the unformatted (computable) value. For example, you could have
<code class="docutils literal notranslate"><span class="pre">_foobar</span></code> at <code class="docutils literal notranslate"><span class="pre">42</span></code> and <code class="docutils literal notranslate"><span class="pre">foobar</span></code> at <code class="docutils literal notranslate"><span class="pre">&quot;42</span> <span class="pre">seconds&quot;</span></code> (what you present to the user).</li>
<li>Unformatted values are used for sorting.</li>
<li>If your column name is a python keyword, add an underscore suffix (<code class="docutils literal notranslate"><span class="pre">from_</span></code>).</li>
</ol>
<p>Of course, this is only default behavior. This can be overriden.</p>
<dl class="method">
<dt id="hscommon.gui.table.Row.can_edit">
<code class="descname">can_edit</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.Row.can_edit" title="Permalink to this definition"></a></dt>
<dd><p>(Virtual) Whether the whole row can be edited.</p>
<p>By default, always returns <code class="docutils literal notranslate"><span class="pre">True</span></code>. This is for the <em>whole</em> row. For individual cells, its
<a class="reference internal" href="#hscommon.gui.table.Row.can_edit_cell" title="hscommon.gui.table.Row.can_edit_cell"><code class="xref py py-meth docutils literal notranslate"><span class="pre">can_edit_cell()</span></code></a>.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.Row.can_edit_cell">
<code class="descname">can_edit_cell</code><span class="sig-paren">(</span><em>column_name</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.Row.can_edit_cell" title="Permalink to this definition"></a></dt>
<dd><p>Returns whether cell for column <code class="docutils literal notranslate"><span class="pre">column_name</span></code> can be edited.</p>
<p>By the default, the check is done in many steps:</p>
<ol class="arabic simple">
<li>We check whether the whole row can be edited with <a class="reference internal" href="#hscommon.gui.table.Row.can_edit" title="hscommon.gui.table.Row.can_edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">can_edit()</span></code></a>. If it cant, the cell
cant either.</li>
<li>If the column doesnt exist as an attribute, we cant edit.</li>
<li>If we have an attribute <code class="docutils literal notranslate"><span class="pre">can_edit_&lt;column_name&gt;</span></code>, return that.</li>
<li>Check if our attribute is a property. If its not, its not editable.</li>
<li>If our attribute is in fact a property, check whether the property is “settable” (has a
<code class="docutils literal notranslate"><span class="pre">fset</span></code> method). The cell is editable only if the property is “settable”.</li>
</ol>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.Row.get_cell_value">
<code class="descname">get_cell_value</code><span class="sig-paren">(</span><em>attrname</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.Row.get_cell_value" title="Permalink to this definition"></a></dt>
<dd><p>Get cell value for <code class="docutils literal notranslate"><span class="pre">attrname</span></code>.</p>
<p>By default, does a simple <code class="docutils literal notranslate"><span class="pre">getattr()</span></code>, but it is used to allow subclasses to have
alternative value storage mechanisms.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.Row.load">
<code class="descname">load</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.Row.load" title="Permalink to this definition"></a></dt>
<dd><p>(Virtual/Required) Loads up values from the model to be presented in the table.</p>
<p>Usually, our model instances contain values that are not quite ready for display. If you
have number formatting, display calculations and other whatnots to perform, you do it here
and then you put the result in an arbitrary attribute of the row.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.Row.save">
<code class="descname">save</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.Row.save" title="Permalink to this definition"></a></dt>
<dd><p>(Virtual/Required) Saves user edits into your model.</p>
<p>If your table is editable, this is called when the user commits his changes. Usually, these
are typed up stuff, or selected indexes. You have to do proper parsing and reference
linking, and save that stuff into your model.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.Row.set_cell_value">
<code class="descname">set_cell_value</code><span class="sig-paren">(</span><em>attrname</em>, <em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.Row.set_cell_value" title="Permalink to this definition"></a></dt>
<dd><p>Set cell value to <code class="docutils literal notranslate"><span class="pre">value</span></code> for <code class="docutils literal notranslate"><span class="pre">attrname</span></code>.</p>
<p>By default, does a simple <code class="docutils literal notranslate"><span class="pre">setattr()</span></code>, but it is used to allow subclasses to have
alternative value storage mechanisms.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.Row.sort_key_for_column">
<code class="descname">sort_key_for_column</code><span class="sig-paren">(</span><em>column_name</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.Row.sort_key_for_column" title="Permalink to this definition"></a></dt>
<dd><p>(Virtual) Return the value that is to be used to sort by column <code class="docutils literal notranslate"><span class="pre">column_name</span></code>.</p>
<p>By default, looks for an attribute with the same name as <code class="docutils literal notranslate"><span class="pre">column_name</span></code>, but with an
underscore prefix (“unformatted value”). If theres none, tries without the underscore. If
theres none, raises <code class="docutils literal notranslate"><span class="pre">AttributeError</span></code>.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="hscommon.gui.table.GUITable">
<em class="property">class </em><code class="descclassname">hscommon.gui.table.</code><code class="descname">GUITable</code><a class="headerlink" href="#hscommon.gui.table.GUITable" title="Permalink to this definition"></a></dt>
<dd><p>Cross-toolkit GUI-enabled table view.</p>
<p>Represents a UI element presenting the user with a sortable, selectable, possibly editable,
table view.</p>
<p>Behaves like the <a class="reference internal" href="#hscommon.gui.table.Table" title="hscommon.gui.table.Table"><code class="xref py py-class docutils literal notranslate"><span class="pre">Table</span></code></a> which it subclasses, but is more focused on being the presenter
of some model data to its <a class="reference internal" href="base.html#hscommon.gui.base.GUIObject.view" title="hscommon.gui.base.GUIObject.view"><code class="xref py py-attr docutils literal notranslate"><span class="pre">GUIObject.view</span></code></a>. Theres a <a class="reference internal" href="#hscommon.gui.table.GUITable.refresh" title="hscommon.gui.table.GUITable.refresh"><code class="xref py py-meth docutils literal notranslate"><span class="pre">refresh()</span></code></a>
mechanism which ensures fresh data while preserving sorting order and selection. Theres also an
editing mechanism which tracks whether (and which) row is being edited (or added) and
save/cancel edits when appropriate.</p>
<p>Subclasses <a class="reference internal" href="#hscommon.gui.table.Table" title="hscommon.gui.table.Table"><code class="xref py py-class docutils literal notranslate"><span class="pre">Table</span></code></a> and <a class="reference internal" href="base.html#hscommon.gui.base.GUIObject" title="hscommon.gui.base.GUIObject"><code class="xref py py-class docutils literal notranslate"><span class="pre">GUIObject</span></code></a>. Expected view:
<a class="reference internal" href="#hscommon.gui.table.GUITableView" title="hscommon.gui.table.GUITableView"><code class="xref py py-class docutils literal notranslate"><span class="pre">GUITableView</span></code></a>.</p>
<dl class="method">
<dt id="hscommon.gui.table.GUITable._do_add">
<code class="descname">_do_add</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITable._do_add" title="Permalink to this definition"></a></dt>
<dd><p>(Virtual) Creates a new row, adds it in the table.</p>
<p>Returns <code class="docutils literal notranslate"><span class="pre">(row,</span> <span class="pre">insert_index)</span></code>.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.GUITable._do_delete">
<code class="descname">_do_delete</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITable._do_delete" title="Permalink to this definition"></a></dt>
<dd><p>(Virtual) Delete the selected rows.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.GUITable._fill">
<code class="descname">_fill</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITable._fill" title="Permalink to this definition"></a></dt>
<dd><p>(Virtual/Required) Fills the table with all the rows that this table is supposed to have.</p>
<p>Called by <a class="reference internal" href="#hscommon.gui.table.GUITable.refresh" title="hscommon.gui.table.GUITable.refresh"><code class="xref py py-meth docutils literal notranslate"><span class="pre">refresh()</span></code></a>. Does nothing by default.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.GUITable._is_edited_new">
<code class="descname">_is_edited_new</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITable._is_edited_new" title="Permalink to this definition"></a></dt>
<dd><p>(Virtual) Returns whether the currently edited row should be considered “new”.</p>
<p>This is used in <a class="reference internal" href="#hscommon.gui.table.GUITable.cancel_edits" title="hscommon.gui.table.GUITable.cancel_edits"><code class="xref py py-meth docutils literal notranslate"><span class="pre">cancel_edits()</span></code></a> to know whether the cancellation of the edit means a
revert of the rows value or the removal of the row.</p>
<p>By default, always false.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.GUITable._restore_selection">
<code class="descname">_restore_selection</code><span class="sig-paren">(</span><em>previous_selection</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITable._restore_selection" title="Permalink to this definition"></a></dt>
<dd><p>(Virtual) Restores row selection after a contents-changing operation.</p>
<p>Before each contents changing operation, we store our previously selected indexes because in
many cases, such as in <a class="reference internal" href="#hscommon.gui.table.GUITable.refresh" title="hscommon.gui.table.GUITable.refresh"><code class="xref py py-meth docutils literal notranslate"><span class="pre">refresh()</span></code></a>, our selection will be lost. After the operation is
over, we call this method with our previously selected indexes (in <code class="docutils literal notranslate"><span class="pre">previous_selection</span></code>).</p>
<p>The default behavior is (if we indeed have an empty <a class="reference internal" href="selectable_list.html#hscommon.gui.selectable_list.Selectable.selected_indexes" title="hscommon.gui.selectable_list.Selectable.selected_indexes"><code class="xref py py-attr docutils literal notranslate"><span class="pre">selected_indexes</span></code></a>) to re-select
<code class="docutils literal notranslate"><span class="pre">previous_selection</span></code>. If it was empty, we select the last row of the table.</p>
<p>This behavior can, of course, be overriden.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.GUITable.add">
<code class="descname">add</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITable.add" title="Permalink to this definition"></a></dt>
<dd><p>Add a new row in edit mode.</p>
<p>Requires <code class="xref py py-meth docutils literal notranslate"><span class="pre">do_add()</span></code> to be implemented. The newly added row will be selected and in edit
mode.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.GUITable.can_edit_cell">
<code class="descname">can_edit_cell</code><span class="sig-paren">(</span><em>column_name</em>, <em>row_index</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITable.can_edit_cell" title="Permalink to this definition"></a></dt>
<dd><p>Returns whether the cell at <code class="docutils literal notranslate"><span class="pre">row_index</span></code> and <code class="docutils literal notranslate"><span class="pre">column_name</span></code> can be edited.</p>
<p>A row is, by default, editable as soon as it has an attr with the same name as <cite>column</cite>.
If <a class="reference internal" href="#hscommon.gui.table.Row.can_edit" title="hscommon.gui.table.Row.can_edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Row.can_edit()</span></code></a> returns False, the row is not editable at all. You can set
editability of rows at the attribute level with can_edit_* properties.</p>
<p>Mostly just a shortcut to <a class="reference internal" href="#hscommon.gui.table.Row.can_edit_cell" title="hscommon.gui.table.Row.can_edit_cell"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Row.can_edit_cell()</span></code></a>.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.GUITable.cancel_edits">
<code class="descname">cancel_edits</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITable.cancel_edits" title="Permalink to this definition"></a></dt>
<dd><p>Cancels the current edit operation.</p>
<p>If theres an <a class="reference internal" href="#hscommon.gui.table.GUITable.edited" title="hscommon.gui.table.GUITable.edited"><code class="xref py py-attr docutils literal notranslate"><span class="pre">edited</span></code></a> row, it will be re-initialized (with <a class="reference internal" href="#hscommon.gui.table.Row.load" title="hscommon.gui.table.Row.load"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Row.load()</span></code></a>).</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.GUITable.delete">
<code class="descname">delete</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITable.delete" title="Permalink to this definition"></a></dt>
<dd><p>Delete the currently selected rows.</p>
<p>Requires <a class="reference internal" href="#hscommon.gui.table.GUITable._do_delete" title="hscommon.gui.table.GUITable._do_delete"><code class="xref py py-meth docutils literal notranslate"><span class="pre">_do_delete()</span></code></a> for this to have any effect on the model. Cancels editing if
relevant.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.GUITable.refresh">
<code class="descname">refresh</code><span class="sig-paren">(</span><em>refresh_view=True</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITable.refresh" title="Permalink to this definition"></a></dt>
<dd><p>Empty the table and re-create its rows.</p>
<p><a class="reference internal" href="#hscommon.gui.table.GUITable._fill" title="hscommon.gui.table.GUITable._fill"><code class="xref py py-meth docutils literal notranslate"><span class="pre">_fill()</span></code></a> is called after we emptied the table to create our rows. Previous sort order
will be preserved, regardless of the order in which the rows were filled. If there was any
edit operation taking place, its cancelled.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>refresh_view</strong> (<em>bool</em>) Whether we tell our view to refresh after our refill operation.
Most of the time, its what we want, but theres some cases where
we dont.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.GUITable.save_edits">
<code class="descname">save_edits</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITable.save_edits" title="Permalink to this definition"></a></dt>
<dd><p>Commit user edits to the model.</p>
<p>This is done by calling <a class="reference internal" href="#hscommon.gui.table.Row.save" title="hscommon.gui.table.Row.save"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Row.save()</span></code></a>.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.GUITable.sort_by">
<code class="descname">sort_by</code><span class="sig-paren">(</span><em>column_name</em>, <em>desc=False</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITable.sort_by" title="Permalink to this definition"></a></dt>
<dd><p>Sort table by <code class="docutils literal notranslate"><span class="pre">column_name</span></code>.</p>
<p>Overrides <a class="reference internal" href="#hscommon.gui.table.Table.sort_by" title="hscommon.gui.table.Table.sort_by"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Table.sort_by()</span></code></a>. After having performed sorting, calls
<a class="reference internal" href="selectable_list.html#hscommon.gui.selectable_list.Selectable._update_selection" title="hscommon.gui.selectable_list.Selectable._update_selection"><code class="xref py py-meth docutils literal notranslate"><span class="pre">_update_selection()</span></code></a> to give you the chance,
if appropriate, to update your selected indexes according to, maybe, the selection that you
have in your model.</p>
<p>Then, we refresh our view.</p>
</dd></dl>
<dl class="attribute">
<dt id="hscommon.gui.table.GUITable.edited">
<code class="descname">edited</code><em class="property"> = None</em><a class="headerlink" href="#hscommon.gui.table.GUITable.edited" title="Permalink to this definition"></a></dt>
<dd><p>The row being currently edited by the user. <code class="docutils literal notranslate"><span class="pre">None</span></code> if no edit is taking place.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="hscommon.gui.table.GUITableView">
<em class="property">class </em><code class="descclassname">hscommon.gui.table.</code><code class="descname">GUITableView</code><a class="headerlink" href="#hscommon.gui.table.GUITableView" title="Permalink to this definition"></a></dt>
<dd><p>Expected interface for <a class="reference internal" href="#hscommon.gui.table.GUITable" title="hscommon.gui.table.GUITable"><code class="xref py py-class docutils literal notranslate"><span class="pre">GUITable</span></code></a>s view.</p>
<p><em>Not actually used in the code. For documentation purposes only.</em></p>
<p>Our view, some kind of table view, is expected to sync with the tables contents by
appropriately behave to all callbacks in this interface.</p>
<p>When in edit mode, the content types by the user is expected to be sent as soon as possible
to the <a class="reference internal" href="#hscommon.gui.table.Row" title="hscommon.gui.table.Row"><code class="xref py py-class docutils literal notranslate"><span class="pre">Row</span></code></a>.</p>
<p>Whenever the user changes the selection, we expect the view to call <code class="xref py py-meth docutils literal notranslate"><span class="pre">Table.select()</span></code>.</p>
<dl class="method">
<dt id="hscommon.gui.table.GUITableView.refresh">
<code class="descname">refresh</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITableView.refresh" title="Permalink to this definition"></a></dt>
<dd><p>Refreshes the contents of the table widget.</p>
<p>Ensures that the contents of the table widget is synced with the model. This includes
selection.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.GUITableView.start_editing">
<code class="descname">start_editing</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITableView.start_editing" title="Permalink to this definition"></a></dt>
<dd><p>Start editing the currently selected row.</p>
<p>Begin whatever inline editing support that the view supports.</p>
</dd></dl>
<dl class="method">
<dt id="hscommon.gui.table.GUITableView.stop_editing">
<code class="descname">stop_editing</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.gui.table.GUITableView.stop_editing" title="Permalink to this definition"></a></dt>
<dd><p>Stop editing if theres an inline editing in effect.</p>
<p>Theres no “aborting” implied in this call, so its appropriate to send whatever the user
has typed and might not have been sent down to the <a class="reference internal" href="#hscommon.gui.table.Row" title="hscommon.gui.table.Row"><code class="xref py py-class docutils literal notranslate"><span class="pre">Row</span></code></a> yet. After youve done that,
stop the editing mechanism.</p>
</dd></dl>
</dd></dl>
</div>
</div>
<div class="bottomnav" role="navigation" aria-label="bottom navigation">
<p>
«&#160;&#160;<a href="selectable_list.html">hscommon.gui.selectable_list</a>
&#160;&#160;::&#160;&#160;
<a class="uplink" href="../../../index.html">Contents</a>
&#160;&#160;::&#160;&#160;
<a href="text_field.html">hscommon.gui.text_field</a>&#160;&#160;»
</p>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2016, Hardcoded Software.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.1.
</div>
</body>
</html>