2 Copyright (c) 2009 Volker Krause <vkrause@kde.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 #include "notificationmonitor.h"
21 #include "notificationmodel.h"
23 #include <Akonadi/Control>
27 #include <QHeaderView>
30 #include <QVBoxLayout>
32 NotificationMonitor::NotificationMonitor(QWidget
* parent
) :
35 QVBoxLayout
*layout
= new QVBoxLayout( this );
37 QTreeView
*tv
= new QTreeView( this );
38 m_model
= new NotificationModel( this );
39 tv
->setModel( m_model
);
41 tv
->setAlternatingRowColors( true );
42 tv
->setContextMenuPolicy( Qt::CustomContextMenu
);
43 tv
->header()->setResizeMode( QHeaderView::ResizeToContents
);
44 connect( tv
, SIGNAL(customContextMenuRequested(QPoint
)), SLOT(contextMenu(QPoint
)) );
45 layout
->addWidget( tv
);
46 m_model
->setEnabled( false ); // since it can be slow, default to off
48 Akonadi::Control::widgetNeedsAkonadi( this );
51 void NotificationMonitor::contextMenu(const QPoint
& pos
)
54 menu
.addAction( i18n( "Clear View" ), m_model
, SLOT(clear()) );
55 QAction
*action
= new QAction(&menu
);
56 action
->setCheckable( true );
57 action
->setChecked( m_model
->isEnabled() );
58 action
->setText( i18n("Enabled") );
59 connect( action
, SIGNAL(toggled(bool)), m_model
, SLOT(setEnabled(bool)) );
60 menu
.addAction( action
);
61 menu
.exec( mapToGlobal( pos
) );
64 #include "notificationmonitor.moc"