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 slotEventChanged( QListViewItem * );
00249         void soundToggled( bool on );
00250         void loggingToggled( bool on );
00251         void executeToggled( bool on );
00252         void messageBoxChanged();
00253         void stderrToggled( bool on );
00254 
00255         void soundFileChanged( const QString& text );
00256         void logfileChanged( const QString& text );
00257         void commandlineChanged( const QString& text );
00258 
00259         void openSoundDialog( KURLRequester * );
00260         void openLogDialog( KURLRequester * );
00261         void openExecDialog( KURLRequester * );
00262 
00263         void enableAll();
00264 
00265     private:
00266         void updateWidgets( ListViewItem *item );
00267         void updatePixmaps( ListViewItem *item );
00268 
00269         static QString makeRelative( const QString& );
00270         void addToView( const EventList& events );
00271         void widgetChanged( QListViewItem *item,
00272                             int what, bool on, QWidget *buddy = 0L );
00273         void selectItem( QListViewItem *item );
00274 
00275         ApplicationList m_visibleApps;
00276         ApplicationList m_allApps;
00277 
00278         class Private;
00279         Private *d;
00280 
00281     };
00282 
00283 
00286 
00287 
00291     class Event
00292     {
00293         friend class Application;
00294 
00295     public:
00296         QString text() const { return description; }
00297 
00298         int presentation;
00299         int dontShow;
00300         QString logfile;
00301         QString soundfile;
00302         QString commandline;
00303 
00304         const Application *application() const { return m_app; }
00305 
00306     private:
00307         Event( const Application *app ) {
00308             presentation = 0;
00309             dontShow = 0;
00310             m_app = app;
00311         }
00312         QString name;
00313         QString description;
00314         QString configGroup;
00315 
00316         const Application *m_app;
00317     };
00318 
00322     class ListViewItem : public QListViewItem
00323     {
00324     public:
00325         ListViewItem( QListView *view, Event *event );
00326 
00327         Event& event() { return *m_event; }
00328         virtual int compare (QListViewItem * i, int col, bool ascending) const;
00329 
00330     private:
00331         Event * m_event;
00332     };
00333 
00334 };
00335 
00336 
00337 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:30 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001