Commit 75ecfceb authored by David Jarvie's avatar David Jarvie
Browse files

Remove unnecessary macro

parent 43c16934
......@@ -22,15 +22,14 @@
#include "alarmlistdelegate.h"
#include "akonadimodel.h"
#define ITEM_LIST_MODEL AlarmListModel
#include "functions.h"
#include <kalarmcal/kacalendar.h>
#include <kcolorscheme.h>
#include <qdebug.h>
#include <QApplication>
#include <qdebug.h>
void AlarmListDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
......@@ -47,7 +46,7 @@ void AlarmListDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opt
}
switch (index.column())
{
case ITEM_LIST_MODEL::TimeColumn:
case AlarmListModel::TimeColumn:
{
QString str = index.data(Qt::DisplayRole).toString();
// Need to pad out spacing to align times without leading zeroes
......@@ -69,7 +68,7 @@ void AlarmListDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opt
}
break;
}
case ITEM_LIST_MODEL::ColourColumn:
case AlarmListModel::ColourColumn:
{
const KAEvent event = static_cast<const ItemListModel*>(index.model())->event(index);
if (event.isValid() && event.commandError() != KAEvent::CMD_NO_ERROR)
......@@ -93,7 +92,7 @@ QSize AlarmListDelegate::sizeHint(const QStyleOptionViewItem& option, const QMod
{
switch (index.column())
{
case ITEM_LIST_MODEL::TimeColumn:
case AlarmListModel::TimeColumn:
{
int h = option.fontMetrics.lineSpacing();
const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
......@@ -111,7 +110,7 @@ QSize AlarmListDelegate::sizeHint(const QStyleOptionViewItem& option, const QMod
w += option.fontMetrics.width(str);
return QSize(w, h);
}
case ITEM_LIST_MODEL::ColourColumn:
case AlarmListModel::ColourColumn:
{
int h = option.fontMetrics.lineSpacing();
return QSize(h * 3 / 4, h);
......
......@@ -21,15 +21,13 @@
#include "kalarm.h"
#include "alarmlistview.h"
#define ALARM_LIST_MODEL AlarmListModel
#include <ksharedconfig.h>
#include <kconfiggroup.h>
#include <kglobal.h>
#include <KSharedConfig>
#include <QHeaderView>
#include <QApplication>
#include <KSharedConfig>
AlarmListView::AlarmListView(const QByteArray& configGroup, QWidget* parent)
......@@ -49,16 +47,16 @@ void AlarmListView::setModel(QAbstractItemModel* model)
header()->restoreState(settings);
header()->setMovable(true);
header()->setStretchLastSection(false);
header()->setResizeMode(ALARM_LIST_MODEL::TimeColumn, QHeaderView::ResizeToContents);
header()->setResizeMode(ALARM_LIST_MODEL::TimeToColumn, QHeaderView::ResizeToContents);
header()->setResizeMode(ALARM_LIST_MODEL::RepeatColumn, QHeaderView::ResizeToContents);
header()->setResizeMode(ALARM_LIST_MODEL::ColourColumn, QHeaderView::Fixed);
header()->setResizeMode(ALARM_LIST_MODEL::TypeColumn, QHeaderView::Fixed);
header()->setResizeMode(ALARM_LIST_MODEL::TextColumn, QHeaderView::Stretch);
header()->setResizeMode(AlarmListModel::TimeColumn, QHeaderView::ResizeToContents);
header()->setResizeMode(AlarmListModel::TimeToColumn, QHeaderView::ResizeToContents);
header()->setResizeMode(AlarmListModel::RepeatColumn, QHeaderView::ResizeToContents);
header()->setResizeMode(AlarmListModel::ColourColumn, QHeaderView::Fixed);
header()->setResizeMode(AlarmListModel::TypeColumn, QHeaderView::Fixed);
header()->setResizeMode(AlarmListModel::TextColumn, QHeaderView::Stretch);
header()->setStretchLastSection(true); // necessary to ensure ResizeToContents columns do resize to contents!
const int margin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin);
header()->resizeSection(ALARM_LIST_MODEL::ColourColumn, viewOptions().fontMetrics.lineSpacing() * 3 / 4);
header()->resizeSection(ALARM_LIST_MODEL::TypeColumn, ALARM_LIST_MODEL::iconWidth() + 2*margin + 2);
header()->resizeSection(AlarmListModel::ColourColumn, viewOptions().fontMetrics.lineSpacing() * 3 / 4);
header()->resizeSection(AlarmListModel::TypeColumn, AlarmListModel::iconWidth() + 2*margin + 2);
}
/******************************************************************************
......@@ -80,30 +78,30 @@ void AlarmListView::selectTimeColumns(bool time, bool timeTo)
if (!time && !timeTo)
return; // always show at least one time column
// bool changed = false;
bool hidden = header()->isSectionHidden(ALARM_LIST_MODEL::TimeColumn);
bool hidden = header()->isSectionHidden(AlarmListModel::TimeColumn);
if (time && hidden)
{
// Unhide the time column
header()->setSectionHidden(ALARM_LIST_MODEL::TimeColumn, false);
header()->setSectionHidden(AlarmListModel::TimeColumn, false);
// changed = true;
}
else if (!time && !hidden)
{
// Hide the time column
header()->setSectionHidden(ALARM_LIST_MODEL::TimeColumn, true);
header()->setSectionHidden(AlarmListModel::TimeColumn, true);
// changed = true;
}
hidden = header()->isSectionHidden(ALARM_LIST_MODEL::TimeToColumn);
hidden = header()->isSectionHidden(AlarmListModel::TimeToColumn);
if (timeTo && hidden)
{
// Unhide the time-to-alarm column
header()->setSectionHidden(ALARM_LIST_MODEL::TimeToColumn, false);
header()->setSectionHidden(AlarmListModel::TimeToColumn, false);
// changed = true;
}
else if (!timeTo && !hidden)
{
// Hide the time-to-alarm column
header()->setSectionHidden(ALARM_LIST_MODEL::TimeToColumn, true);
header()->setSectionHidden(AlarmListModel::TimeToColumn, true);
// changed = true;
}
// if (changed)
......
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