Commit 8ef1ae91 authored by Bram Schoenmakers's avatar Bram Schoenmakers Committed by GitHub

Merge pull request #167 from mruwek/column-title

Prefer filterexpr if there is no title in config
parents 5e13411a 766acf4b
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import configparser from configparser import RawConfigParser, NoOptionError
from os.path import expanduser from os.path import expanduser
from topydo.lib.Config import home_config_path, config from topydo.lib.Config import home_config_path, config
...@@ -27,8 +27,15 @@ def columns(p_alt_layout_path=None): ...@@ -27,8 +27,15 @@ def columns(p_alt_layout_path=None):
def _get_column_dict(p_cp, p_column): def _get_column_dict(p_cp, p_column):
column_dict = dict() column_dict = dict()
column_dict['title'] = p_cp.get(p_column, 'title') filterexpr = p_cp.get(p_column, 'filterexpr')
column_dict['filterexpr'] = p_cp.get(p_column, 'filterexpr')
try:
title = p_cp.get(p_column, 'title')
except NoOptionError:
title = filterexpr
column_dict['title'] = title or 'Yet another column'
column_dict['filterexpr'] = filterexpr
column_dict['sortexpr'] = p_cp.get(p_column, 'sortexpr') column_dict['sortexpr'] = p_cp.get(p_column, 'sortexpr')
column_dict['groupexpr'] = p_cp.get(p_column, 'groupexpr') column_dict['groupexpr'] = p_cp.get(p_column, 'groupexpr')
column_dict['show_all'] = p_cp.getboolean(p_column, 'show_all') column_dict['show_all'] = p_cp.getboolean(p_column, 'show_all')
...@@ -36,14 +43,13 @@ def columns(p_alt_layout_path=None): ...@@ -36,14 +43,13 @@ def columns(p_alt_layout_path=None):
return column_dict return column_dict
defaults = { defaults = {
'title': 'Yet another column',
'filterexpr': '', 'filterexpr': '',
'sortexpr': config().sort_string(), 'sortexpr': config().sort_string(),
'groupexpr': config().group_string(), 'groupexpr': config().group_string(),
'show_all': '0', 'show_all': '0',
} }
cp = configparser.RawConfigParser(defaults) cp = RawConfigParser(defaults)
files = [ files = [
"topydo_columns.ini", "topydo_columns.ini",
"topydo_columns.conf", "topydo_columns.conf",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment