kio Library API Documentation

knotifydialog.h

00001 /*
00002   Copyright (C) 2000,2002 Carsten Pfeiffer <pfeiffer@kde.org>
00003   Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com>
00004 
00005   This program is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Library General Public
00007   License version 2 as published by the Free Software Foundation;
00008 
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012   General Public License for more details.
00013 
00014   You should have received a copy of the GNU Library General Public License
00015   along with this library,  If not, write to the Free Software Foundation,
00016   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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:
00070     KNotifyDialog( QWidget *parent = 0, const char *name = 0,
00071                    bool modal = true,
00072                    const KAboutData *aboutData =
00073                    KGlobal::instance()->aboutData() );
00077     virtual ~KNotifyDialog();
00078 
00089     static int configure( QWidget *parent = 0, const char *name = 0,
00090                           const KAboutData *aboutData = KGlobal::instance()->aboutData() );
00091 
00101     virtual void addApplicationEvents( const char *appName );
00102 
00112     virtual void addApplicationEvents( const QString& path );
00113 
00118     virtual void clearApplicationEvents();
00119 
00120 private slots:
00121     void slotDefault();
00122 
00123 private:
00124     enum
00125     {
00126         COL_FILENAME = 1
00127     };
00128 
00129     void updateView();
00130 
00131     KNotify::KNotifyWidget * m_notifyWidget;
00132 
00133     class Private;
00134     Private *d;
00135 };
00136 
00137 
00138 namespace KNotify
00139 {
00140     class Application;
00141     class Event;
00142     class ListViewItem;
00143     typedef QPtrList<Event> EventList;
00144     typedef QPtrListIterator<Application> ApplicationListIterator;
00145     typedef QPtrListIterator<Event> EventListIterator;
00146 
00150     class Application
00151     {
00152     public:
00153         Application( const QString &path );
00154         ~Application();
00155 
00156         QString text() const { return m_description; }
00157         QString icon() const { return m_icon; }
00158         const EventList& eventList();
00159         void reloadEvents( bool revertToDefaults = false );
00160         void save();
00161 
00162         QString appName() const { return m_appname; }
00163 
00164     private:
00165         QString m_icon;
00166         QString m_description;
00167         QString m_appname;
00168         EventList *m_events;
00169 
00170         KConfig *kc; // The file that defines the events.
00171         KConfig *config; // The file that contains the settings for the events
00172     };
00173 
00174 
00175     class ApplicationList : public QPtrList<Application>
00176     {
00177         virtual int compareItems ( QPtrCollection::Item item1,
00178                                    QPtrCollection::Item item2 )
00179         {
00180             return (static_cast<Application*>( item1 )->text() >=
00181                 static_cast<Application*>( item2 )->text()) ? 1 : -1;
00182         }
00183     };
00184 
00188     class KNotifyWidget : public KNotifyWidgetBase
00189     {
00190         Q_OBJECT
00191 
00192     public:
00193         KNotifyWidget( QWidget* parent = 0, const char* name = 0,
00194                        bool handleAllApps = false );
00195         ~KNotifyWidget();
00196 
00197         KListView * eventsView() {
00198             return m_listview;
00199         }
00200 
00201         void addVisibleApp( Application *app );
00202         ApplicationList& visibleApps() { return m_visibleApps; }
00203         ApplicationList& allApps() { return m_allApps; }
00204 
00210         Application * addApplicationEvents( const QString& path );
00211 
00212         void resetDefaults( bool ask );
00213         void sort( bool ascending = true );
00214 
00215     public slots:
00219         virtual void clear();
00225         virtual void clearVisible();
00226         virtual void save();
00227         virtual void showAdvanced( bool show );
00228         void toggleAdvanced();
00229 
00230 
00231     signals:
00232         void changed( bool hasChanges );
00233 
00234     protected:
00238         Event * currentEvent();
00239         virtual void showEvent( QShowEvent * );
00240         virtual void enableAll( int what, bool enable );
00241 
00242         void reload( bool revertToDefaults = false );
00243 
00244     protected slots:
00245         void playSound();
00246 
00247     private slots:
00248         void slotItemClicked( QListViewItem *item, const QPoint& point, 
00249                               int col );
00250         void slotEventChanged( QListViewItem * );
00251         void soundToggled( bool on );
00252         void loggingToggled( bool on );
00253         void executeToggled( bool on );
00254         void messageBoxChanged();
00255         void stderrToggled( bool on );
00256 
00257         void soundFileChanged( const QString& text );
00258         void logfileChanged( const QString& text );
00259         void commandlineChanged( const QString& text );
00260 
00261         void openSoundDialog( KURLRequester * );
00262         void openLogDialog( KURLRequester * );
00263         void openExecDialog( KURLRequester * );
00264 
00265         void enableAll();
00266 
00267     private:
00268         void updateWidgets( ListViewItem *item );
00269         void updatePixmaps( ListViewItem *item );
00270 
00271         static QString makeRelative( const QString& );
00272         void addToView( const EventList& events );
00273         void widgetChanged( QListViewItem *item,
00274                             int what, bool on, QWidget *buddy = 0L );
00275         void selectItem( QListViewItem *item );
00276 
00277         ApplicationList m_visibleApps;
00278         ApplicationList m_allApps;
00279 
00280         class Private;
00281         Private *d;
00282 
00283     };
00284 
00285 
00288 
00289 
00293     class Event
00294     {
00295         friend class Application;
00296 
00297     public:
00298         QString text() const { return description; }
00299 
00300         int presentation;
00301         int dontShow;
00302         QString logfile;
00303         QString soundfile;
00304         QString commandline;
00305 
00306         const Application *application() const { return m_app; }
00307 
00308     private:
00309         Event( const Application *app ) {
00310             presentation = 0;
00311             dontShow = 0;
00312             m_app = app;
00313         }
00314         QString name;
00315         QString description;
00316         QString configGroup;
00317 
00318         const Application *m_app;
00319     };
00320 
00324     class ListViewItem : public QListViewItem
00325     {
00326     public:
00327         ListViewItem( QListView *view, Event *event );
00328 
00329         Event& event() { return *m_event; }
00330         virtual int compare (QListViewItem * i, int col, bool ascending) const;
00331 
00332     private:
00333         Event * m_event;
00334     };
00335 
00336 }
00337 
00338 
00339 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:31 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001