[kalarm] /: Set defaults for list view columns to show; update documentation

David Jarvie null at kde.org
Tue Jun 25 12:15:10 BST 2019


Git commit 46cb5ec1ba4da84285c8fab3fcd4e17ea5503d1e by David Jarvie.
Committed on 25/06/2019 at 11:12.
Pushed by djarvie into branch 'master'.

Set defaults for list view columns to show; update documentation

M  +11   -11   doc/index.docbook
M  +16   -7    src/alarmlistview.cpp

https://commits.kde.org/kalarm/46cb5ec1ba4da84285c8fab3fcd4e17ea5503d1e

diff --git a/doc/index.docbook b/doc/index.docbook
index a97ce46f..f8b61689 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -31,7 +31,7 @@
 </authorgroup>
 
 <copyright>
-<year>2001</year><year>2002</year><year>2003</year><year>2004</year><year>2005</year><year>2006</year><year>2007</year><year>2008</year><year>2009</year><year>2010</year><year>2011</year><year>2012</year><year>2013</year><year>2016</year><year>2018</year>
+<year>2001</year><year>2002</year><year>2003</year><year>2004</year><year>2005</year><year>2006</year><year>2007</year><year>2008</year><year>2009</year><year>2010</year><year>2011</year><year>2012</year><year>2013</year><year>2016</year><year>2018</year><year>2019</year>
 <holder>&David.Jarvie;</holder>
 </copyright>
 
@@ -39,8 +39,8 @@
 
 <!-- Don't change format of date and version of the documentation -->
 
-<date>2018-04-16</date>
-<releaseinfo>2.12.0 (Applications 18.08)</releaseinfo>
+<date>2019-06-25</date>
+<releaseinfo>2.12.5 (Applications 19.08)</releaseinfo>
 
 <abstract>
 <para>&kalarm; is a personal alarm message, command and email scheduler by &kde;.</para>
@@ -223,14 +223,14 @@ type or text by clicking on the titlebar for the appropriate column.
 To reverse the sort order, click the column titlebar again.</para>
 
 <para>You can optionally show the remaining time until each alarm is
-due, together with, or instead of, the alarm's scheduled time.
-To show or hide the alarm time column, select
-<menuchoice><guimenu>View</guimenu><guimenuitem>Show Alarm
-Times</guimenuitem></menuchoice>.
-To show or hide the time-to-alarm column, select
-<menuchoice><guimenu>View</guimenu><guimenuitem>Show Time To
-Alarms</guimenuitem></menuchoice>. At least one of these columns is
-always shown.</para>
+due, together with, or instead of, the alarm's scheduled time.</para>
+
+<para>You can select which columns to display or hide by
+<mousebutton>Right</mousebutton> clicking on the column headings and
+using the context menu to set the columns to show. But note that the
+<guilabel>Message, File or Command</guilabel> column, and at least one
+of the <guilabel>Time</guilabel> or <guilabel>Time To</guilabel>
+columns, are always shown.</para>
 
 <para>If you use multiple alarm calendars, you can color code alarms
 according to which calendar they belong to, by selecting a different
diff --git a/src/alarmlistview.cpp b/src/alarmlistview.cpp
index 466ecfa1..a39351a4 100644
--- a/src/alarmlistview.cpp
+++ b/src/alarmlistview.cpp
@@ -61,6 +61,10 @@ void AlarmListView::setModel(QAbstractItemModel* model)
     connect(header(), &QWidget::customContextMenuRequested, this, &AlarmListView::headerContextMenuRequested);
 }
 
+/******************************************************************************
+* Return which of the optional columns are currently shown.
+* Note that the column order must be the same as in setColumnsVisible().
+*/
 QList<bool> AlarmListView::columnsVisible() const
 {
     if (!model())
@@ -72,16 +76,21 @@ QList<bool> AlarmListView::columnsVisible() const
              !header()->isSectionHidden(AlarmListModel::TypeColumn) };
 }
 
+/******************************************************************************
+* Set which of the optional columns are to be shown.
+* Note that the column order must be the same as in columnsVisible().
+*/
 void AlarmListView::setColumnsVisible(const QList<bool>& show)
 {
-    if (!model()  ||  show.size() < 5)
+    if (!model())
         return;
-    header()->setSectionHidden(AlarmListModel::TimeColumn,   !show[0]);
-    header()->setSectionHidden(AlarmListModel::TimeToColumn, !show[1]);
-    header()->setSectionHidden(AlarmListModel::RepeatColumn, !show[2]);
-    header()->setSectionHidden(AlarmListModel::ColourColumn, !show[3]);
-    header()->setSectionHidden(AlarmListModel::TypeColumn,   !show[4]);
-    sortByColumn(show[0] ? AlarmListModel::TimeColumn : AlarmListModel::TimeToColumn, Qt::AscendingOrder);
+    const QList<bool> vis = (show.size() < 5) ? QList<bool>{true, false, true, true, true} : show;
+    header()->setSectionHidden(AlarmListModel::TimeColumn,   !vis[0]);
+    header()->setSectionHidden(AlarmListModel::TimeToColumn, !vis[1]);
+    header()->setSectionHidden(AlarmListModel::RepeatColumn, !vis[2]);
+    header()->setSectionHidden(AlarmListModel::ColourColumn, !vis[3]);
+    header()->setSectionHidden(AlarmListModel::TypeColumn,   !vis[4]);
+    sortByColumn(vis[0] ? AlarmListModel::TimeColumn : AlarmListModel::TimeToColumn, Qt::AscendingOrder);
 }
 
 /******************************************************************************


More information about the kde-doc-english mailing list