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 #include <kdialogbase.h>
00024 #include <kinstance.h>
00025 #include <kglobal.h>
00026 
00027 #include "knotifywidgetbase.h"
00028 
00029 class QShowEvent;
00030 
00031 namespace KNotify
00032 {
00033     class KNotifyWidget;
00034 }
00035 
00052 class KIO_EXPORT KNotifyDialog : public KDialogBase
00053 {
00054     Q_OBJECT
00055 
00056 public:
00071     KNotifyDialog( QWidget *parent = 0, const char *name = 0,
00072                    bool modal = true,
00073                    const KAboutData *aboutData =
00074                    KGlobal::instance()->aboutData() );
00078     virtual ~KNotifyDialog();
00079 
00090     static int configure( QWidget *parent = 0, const char *name = 0,
00091                           const KAboutData *aboutData = KGlobal::instance()->aboutData() );
00092 
00102     virtual void addApplicationEvents( const char *appName );
00103 
00113     virtual void addApplicationEvents( const QString& path );
00114 
00119     virtual void clearApplicationEvents();
00120 
00121 private slots:
00122     void slotDefault();
00123 
00124 private:
00125     enum
00126     {
00127         COL_FILENAME = 1
00128     };
00129 
00130     void updateView();
00131 
00132     KNotify::KNotifyWidget * m_notifyWidget;
00133 
00134     class Private;
00135     Private *d;
00136 };
00137 
00138 
00139 namespace KNotify
00140 {
00141     class Application;
00142     class Event;
00143     class ListViewItem;
00144     typedef QPtrList<Event> EventList;
00145     typedef QPtrListIterator<Application> ApplicationListIterator;
00146     typedef QPtrListIterator<Event> EventListIterator;
00147 
00151     class KIO_EXPORT Application
00152     {
00153     public:
00154         Application( const QString &path );
00155         ~Application();
00156 
00157         QString text() const { return m_description; }
00158         QString icon() const { return m_icon; }
00159         const EventList& eventList();
00160         void reloadEvents( bool revertToDefaults = false );
00161         void save();
00162 
00163         QString appName() const { return m_appname; }
00164 
00165     private:
00166         QString m_icon;
00167         QString m_description;
00168         QString m_appname;
00169         EventList *m_events;
00170 
00171         KConfig *kc; // The file that defines the events.
00172         KConfig *config; // The file that contains the settings for the events
00173     };
00174 
00175 
00176     class KIO_EXPORT ApplicationList : public QPtrList<Application>
00177     {
00178         virtual int compareItems ( QPtrCollection::Item item1,
00179                                    QPtrCollection::Item item2 )
00180         {
00181             return (static_cast<Application*>( item1 )->text() >=
00182                 static_cast<Application*>( item2 )->text()) ? 1 : -1;
00183         }
00184     };
00185 
00189     class KIO_EXPORT KNotifyWidget : public KNotifyWidgetBase
00190     {
00191         Q_OBJECT
00192 
00193     public:
00194         KNotifyWidget( QWidget* parent = 0, const char* name = 0,
00195                        bool handleAllApps = false );
00196         ~KNotifyWidget();
00197 
00198         KListView * eventsView() {
00199             return m_listview;
00200         }
00201 
00202         void addVisibleApp( Application *app );
00203         ApplicationList& visibleApps() { return m_visibleApps; }
00204         ApplicationList& allApps() { return m_allApps; }
00205 
00211         Application * addApplicationEvents( const QString& path );
00212 
00213         void resetDefaults( bool ask );
00214         void sort( bool ascending = true );
00215 
00216     public slots:
00220         virtual void clear();
00226         virtual void clearVisible();
00227         virtual void save();
00228         virtual void showAdvanced( bool show );
00229         void toggleAdvanced();
00230 
00231 
00232     signals:
00233         void changed( bool hasChanges );
00234 
00235     protected:
00239         Event * currentEvent();
00240         virtual void showEvent( QShowEvent * );
00241         virtual void enableAll( int what, bool enable );
00242 
00243         void reload( bool revertToDefaults = false );
00244 
00245     protected slots:
00246         void playSound();
00247 
00248     private slots:
00249         void slotItemClicked( QListViewItem *item, const QPoint& point, 
00250                               int col );
00251         void slotEventChanged( QListViewItem * );
00252         void soundToggled( bool on );
00253         void loggingToggled( bool on );
00254         void executeToggled( bool on );
00255         void messageBoxChanged();
00256         void stderrToggled( bool on );
00257         void taskbarToggled( bool on );
00258 
00259         void soundFileChanged( const QString& text );
00260         void logfileChanged( const QString& text );
00261         void commandlineChanged( const QString& text );
00262 
00263         void openSoundDialog( KURLRequester * );
00264         void openLogDialog( KURLRequester * );
00265         void openExecDialog( KURLRequester * );
00266 
00267         void enableAll();
00268 
00269     private:
00270         void updateWidgets( ListViewItem *item );
00271         void updatePixmaps( ListViewItem *item );
00272 
00273         static QString makeRelative( const QString& );
00274         void addToView( const EventList& events );
00275         void widgetChanged( QListViewItem *item,
00276                             int what, bool on, QWidget *buddy = 0L );
00277         void selectItem( QListViewItem *item );
00278 
00279         ApplicationList m_visibleApps;
00280         ApplicationList m_allApps;
00281 
00282         class Private;
00283         Private *d;
00284 
00285     };
00286 
00287 
00290 
00291 
00295     class Event
00296     {
00297         friend class Application;
00298 
00299     public:
00300         QString text() const { return description; }
00301 
00302         int presentation;
00303         int dontShow;
00304         QString logfile;
00305         QString soundfile;
00306         QString commandline;
00307 
00308         const Application *application() const { return m_app; }
00309 
00310     private:
00311         Event( const Application *app ) {
00312             presentation = 0;
00313             dontShow = 0;
00314             m_app = app;
00315         }
00316         QString name;
00317         QString description;
00318         QString configGroup;
00319 
00320         const Application *m_app;
00321     };
00322 
00326     class ListViewItem : public QListViewItem
00327     {
00328     public:
00329         ListViewItem( QListView *view, Event *event );
00330 
00331         Event& event() { return *m_event; }
00332         virtual int compare (QListViewItem * i, int col, bool ascending) const;
00333 
00334     private:
00335         Event * m_event;
00336     };
00337 
00338 }
00339 
00340 
00341 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed May 4 06:55:19 2005 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003