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 void taskbarToggled( bool on ); 00257 00258 void soundFileChanged( const QString& text ); 00259 void logfileChanged( const QString& text ); 00260 void commandlineChanged( const QString& text ); 00261 00262 void openSoundDialog( KURLRequester * ); 00263 void openLogDialog( KURLRequester * ); 00264 void openExecDialog( KURLRequester * ); 00265 00266 void enableAll(); 00267 00268 private: 00269 void updateWidgets( ListViewItem *item ); 00270 void updatePixmaps( ListViewItem *item ); 00271 00272 static QString makeRelative( const QString& ); 00273 void addToView( const EventList& events ); 00274 void widgetChanged( QListViewItem *item, 00275 int what, bool on, QWidget *buddy = 0L ); 00276 void selectItem( QListViewItem *item ); 00277 00278 ApplicationList m_visibleApps; 00279 ApplicationList m_allApps; 00280 00281 class Private; 00282 Private *d; 00283 00284 }; 00285 00286 00289 00290 00294 class Event 00295 { 00296 friend class Application; 00297 00298 public: 00299 QString text() const { return description; } 00300 00301 int presentation; 00302 int dontShow; 00303 QString logfile; 00304 QString soundfile; 00305 QString commandline; 00306 00307 const Application *application() const { return m_app; } 00308 00309 private: 00310 Event( const Application *app ) { 00311 presentation = 0; 00312 dontShow = 0; 00313 m_app = app; 00314 } 00315 QString name; 00316 QString description; 00317 QString configGroup; 00318 00319 const Application *m_app; 00320 }; 00321 00325 class ListViewItem : public QListViewItem 00326 { 00327 public: 00328 ListViewItem( QListView *view, Event *event ); 00329 00330 Event& event() { return *m_event; } 00331 virtual int compare (QListViewItem * i, int col, bool ascending) const; 00332 00333 private: 00334 Event * m_event; 00335 }; 00336 00337 } 00338 00339 00340 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Aug 30 22:54:40 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003