00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
#ifndef KNOTIFYDIALOG_H
00020
#define KNOTIFYDIALOG_H
00021
00022
#include <klistview.h>
00023
00024
#include <kdialogbase.h>
00025
#include <kinstance.h>
00026
#include <kglobal.h>
00027
00028
#include "knotifywidgetbase.h"
00029
00030
class QShowEvent;
00031
00032
namespace KNotify
00033 {
00034
class KNotifyWidget;
00035 }
00036
00053 class KNotifyDialog :
public KDialogBase
00054 {
00055 Q_OBJECT
00056
00057
public:
00072
KNotifyDialog(
QWidget *parent = 0,
const char *name = 0,
00073
bool modal =
true,
00074
const KAboutData *aboutData =
00075 KGlobal::instance()->aboutData() );
00079
virtual ~KNotifyDialog();
00080
00091
static int configure(
QWidget *parent = 0,
const char *name = 0,
00092
const KAboutData *aboutData = KGlobal::instance()->aboutData() );
00093
00103
virtual void addApplicationEvents(
const char *appName );
00104
00114
virtual void addApplicationEvents(
const QString& path );
00115
00120
virtual void clearApplicationEvents();
00121
00122
private slots:
00123
void slotDefault();
00124
00125
private:
00126
enum
00127 {
00128 COL_FILENAME = 1
00129 };
00130
00131
void updateView();
00132
00133 KNotify::KNotifyWidget * m_notifyWidget;
00134
00135
class Private;
00136 Private *d;
00137 };
00138
00139
00140
namespace KNotify
00141 {
00142
class Application;
00143
class Event;
00144
class ListViewItem;
00145
typedef QPtrList<Event> EventList;
00146
typedef QPtrListIterator<Application> ApplicationListIterator;
00147
typedef QPtrListIterator<Event> EventListIterator;
00148
00152
class Application
00153 {
00154
public:
00155 Application(
const QString &path );
00156 ~Application();
00157
00158
QString text()
const {
return m_description; }
00159
QString icon()
const {
return m_icon; }
00160
const EventList& eventList();
00161
void reloadEvents(
bool revertToDefaults =
false );
00162
void save();
00163
00164
QString appName()
const {
return m_appname; }
00165
00166
private:
00167
QString m_icon;
00168
QString m_description;
00169
QString m_appname;
00170
EventList *m_events;
00171
00172
KConfig *kc;
00173
KConfig *config;
00174 };
00175
00176
00177
class ApplicationList :
public QPtrList<Application>
00178 {
00179
virtual int compareItems ( QPtrCollection::Item item1,
00180 QPtrCollection::Item item2 )
00181 {
00182
return (static_cast<Application*>( item1 )->text() >=
00183 static_cast<Application*>( item2 )->text()) ? 1 : -1;
00184 }
00185 };
00186
00190
class KNotifyWidget :
public KNotifyWidgetBase
00191 {
00192 Q_OBJECT
00193
00194
public:
00195 KNotifyWidget(
QWidget* parent = 0,
const char* name = 0,
00196
bool handleAllApps =
false );
00197 ~KNotifyWidget();
00198
00199
KListView * eventsView() {
00200
return m_listview;
00201 }
00202
00203
void addVisibleApp( Application *app );
00204 ApplicationList& visibleApps() {
return m_visibleApps; }
00205 ApplicationList& allApps() {
return m_allApps; }
00206
00212 Application * addApplicationEvents(
const QString& path );
00213
00214
void resetDefaults(
bool ask );
00215
void sort(
bool ascending =
true );
00216
00217
public slots:
00221
virtual void clear();
00227
virtual void clearVisible();
00228
virtual void save();
00229
virtual void showAdvanced(
bool show );
00230
void toggleAdvanced();
00231
00232
00233 signals:
00234
void changed(
bool hasChanges );
00235
00236
protected:
00240 Event * currentEvent();
00241
virtual void showEvent(
QShowEvent * );
00242
virtual void enableAll(
int what,
bool enable );
00243
00244
void reload(
bool revertToDefaults =
false );
00245
00246
protected slots:
00247
void playSound();
00248
00249
private slots:
00250
void slotItemClicked(
QListViewItem *item,
const QPoint& point,
00251
int col );
00252
void slotEventChanged(
QListViewItem * );
00253
void soundToggled(
bool on );
00254
void loggingToggled(
bool on );
00255
void executeToggled(
bool on );
00256
void messageBoxChanged();
00257
void stderrToggled(
bool on );
00258
void taskbarToggled(
bool on );
00259
00260
void soundFileChanged(
const QString& text );
00261
void logfileChanged(
const QString& text );
00262
void commandlineChanged(
const QString& text );
00263
00264
void openSoundDialog(
KURLRequester * );
00265
void openLogDialog(
KURLRequester * );
00266
void openExecDialog(
KURLRequester * );
00267
00268
void enableAll();
00269
00270
private:
00271
void updateWidgets( ListViewItem *item );
00272
void updatePixmaps( ListViewItem *item );
00273
00274
static QString makeRelative(
const QString& );
00275
void addToView(
const EventList& events );
00276
void widgetChanged(
QListViewItem *item,
00277
int what,
bool on,
QWidget *buddy = 0L );
00278
void selectItem(
QListViewItem *item );
00279
00280 ApplicationList m_visibleApps;
00281 ApplicationList m_allApps;
00282
00283
class Private;
00284 Private *d;
00285
00286 };
00287
00288
00291
00292
00296
class Event
00297 {
00298
friend class Application;
00299
00300
public:
00301
QString text()
const {
return description; }
00302
00303
int presentation;
00304
int dontShow;
00305
QString logfile;
00306
QString soundfile;
00307
QString commandline;
00308
00309
const Application *application()
const {
return m_app; }
00310
00311
private:
00312 Event(
const Application *app ) {
00313 presentation = 0;
00314 dontShow = 0;
00315 m_app = app;
00316 }
00317
QString name;
00318
QString description;
00319
QString configGroup;
00320
00321
const Application *m_app;
00322 };
00323
00327
class ListViewItem :
public QListViewItem
00328 {
00329
public:
00330 ListViewItem(
QListView *view, Event *event );
00331
00332 Event&
event() {
return *m_event; }
00333
virtual int compare (
QListViewItem * i,
int col,
bool ascending)
const;
00334
00335
private:
00336 Event * m_event;
00337 };
00338
00339 }
00340
00341
00342
#endif