• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kalarm

alarmlistview.cpp

Go to the documentation of this file.
00001 /*
00002  *  alarmlistview.cpp  -  widget showing list of alarms
00003  *  Program:  kalarm
00004  *  Copyright © 2007,2008 by David Jarvie <djarvie@kde.org>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #include "kalarm.h"
00022 
00023 #include <QHeaderView>
00024 #include <QMouseEvent>
00025 #include <QApplication>
00026 
00027 #include <kconfiggroup.h>
00028 
00029 #include "eventlistmodel.h"
00030 #include "alarmlistfiltermodel.h"
00031 #include "alarmlistview.moc"
00032 
00033 
00034 AlarmListView::AlarmListView(const QByteArray& configGroup, QWidget* parent)
00035     : EventListView(parent),
00036       mConfigGroup(configGroup)
00037 {
00038     setEditOnSingleClick(true);
00039     connect(header(), SIGNAL(sectionMoved(int, int, int)), SLOT(sectionMoved()));
00040 }
00041 
00042 void AlarmListView::setModel(QAbstractItemModel* model)
00043 {
00044     EventListView::setModel(model);
00045     KConfigGroup config(KGlobal::config(), mConfigGroup.constData());
00046     QByteArray settings = config.readEntry("ListHead", QByteArray());
00047     if (!settings.isEmpty())
00048         header()->restoreState(settings);
00049     header()->setMovable(true);
00050     header()->setStretchLastSection(false);
00051     header()->setResizeMode(EventListModel::TimeColumn, QHeaderView::ResizeToContents);
00052     header()->setResizeMode(EventListModel::TimeToColumn, QHeaderView::ResizeToContents);
00053     header()->setResizeMode(EventListModel::RepeatColumn, QHeaderView::ResizeToContents);
00054     header()->setResizeMode(EventListModel::ColourColumn, QHeaderView::Fixed);
00055     header()->setResizeMode(EventListModel::TypeColumn, QHeaderView::Fixed);
00056     header()->setResizeMode(EventListModel::TextColumn, QHeaderView::Stretch);
00057     header()->setStretchLastSection(true);   // necessary to ensure ResizeToContents columns do resize to contents!
00058     const int margin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin);
00059     header()->resizeSection(EventListModel::ColourColumn, viewOptions().fontMetrics.lineSpacing() * 3 / 4);
00060     header()->resizeSection(EventListModel::TypeColumn, EventListModel::iconWidth() + 2*margin + 2);
00061 }
00062 
00063 /******************************************************************************
00064 * Called when the column order is changed.
00065 * Save the new order for restoration on program restart.
00066 */
00067 void AlarmListView::sectionMoved()
00068 {
00069     KConfigGroup config(KGlobal::config(), mConfigGroup.constData());
00070     config.writeEntry("ListHead", header()->saveState());
00071     config.sync();
00072 }
00073 
00074 /******************************************************************************
00075 * Set which time columns are to be displayed.
00076 */
00077 void AlarmListView::selectTimeColumns(bool time, bool timeTo)
00078 {
00079     if (!time  &&  !timeTo)
00080         return;       // always show at least one time column
00081 //  bool changed = false;
00082     bool hidden = header()->isSectionHidden(EventListModel::TimeColumn);
00083     if (time  &&  hidden)
00084     {
00085         // Unhide the time column
00086         header()->setSectionHidden(EventListModel::TimeColumn, false);
00087 //      changed = true;
00088     }
00089     else if (!time  &&  !hidden)
00090     {
00091         // Hide the time column
00092         header()->setSectionHidden(EventListModel::TimeColumn, true);
00093 //      changed = true;
00094     }
00095     hidden = header()->isSectionHidden(EventListModel::TimeToColumn);
00096     if (timeTo  &&  hidden)
00097     {
00098         // Unhide the time-to-alarm column
00099         header()->setSectionHidden(EventListModel::TimeToColumn, false);
00100 //      changed = true;
00101     }
00102     else if (!timeTo  &&  !hidden)
00103     {
00104         // Hide the time-to-alarm column
00105         header()->setSectionHidden(EventListModel::TimeToColumn, true);
00106 //      changed = true;
00107     }
00108 //  if (changed)
00109 //  {
00110 //      resizeLastColumn();
00111 //      triggerUpdate();   // ensure scroll bar appears if needed
00112 //  }
00113 }
00114 
00115 /*
00116 void AlarmListView::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
00117 {
00118     for (int col = topLeft.column();  col < bottomRight.column();  ++col)
00119     {
00120         if (col != header()->resizeMode(col) == QHeaderView::ResizeToContents)
00121             resizeColumnToContents(col);
00122     }
00123 }
00124 */

kalarm

Skip menu "kalarm"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal