diff --git a/src/autostart.cpp b/src/autostart.cpp index 188b3c9..9e68188 100644 --- a/src/autostart.cpp +++ b/src/autostart.cpp @@ -41,80 +41,72 @@ class CDesktopItem : public TDEListViewItem { public: - KService * service; - bool bisDesktop; + KService *mService; KURL fileName; int iStartOn; enum { AutoStart, Shutdown, ENV }; -CDesktopItem( TQString service, int startOn, TQListView *parent ): TDEListViewItem( parent ) { - iStartOn = startOn; - fileName = KURL(service); - if (service.endsWith(".desktop")) { - this->service = new KService(service); - bisDesktop = true; - } -} + CDesktopItem( TQString service, int startOn, TQListView *parent ): TDEListViewItem( parent ), + mService(NULL), iStartOn(startOn), fileName(KURL(service)) + { + if (service.endsWith(".desktop")) { + mService = new KService(service); + } + } -~CDesktopItem() { - if(service) { - delete service; - service = NULL; + ~CDesktopItem() { + if (mService) { + delete mService; + mService = NULL; + } } -} -bool isDesktop() { return bisDesktop; } - -int startOn() { return iStartOn; } - -TQString fStartOn() { - switch (iStartOn) { - case AutoStart: - return i18n("Startup"); - break; - case Shutdown: - return i18n("Shutdown"); - break; - case ENV: - return i18n("ENV"); - break; - default: - return ""; - break; - } -} + TQString fStartOn() { + switch (iStartOn) { + case AutoStart: + return i18n("Startup"); + break; + case Shutdown: + return i18n("Shutdown"); + break; + case ENV: + return i18n("ENV"); + break; + default: + return ""; + break; + } + } -void setStartOn(int start) { - iStartOn = start; - setText(2, fStartOn()); - TQString path; - switch (iStartOn) { - case AutoStart: - path = TDEGlobalSettings::autostartPath()+"/"; - break; - case Shutdown: - path = TDEGlobal::dirs()->localtdedir()+"shutdown/"; - break; - case ENV: - path = TDEGlobal::dirs()->localtdedir()+"env/"; - break; - } - TDEIO::file_move(fileName, KURL( path + fileName.fileName() )); - fileName = path + fileName.fileName(); -} + void setStartOn(int start) { + iStartOn = start; + setText(2, fStartOn()); + TQString path; + switch (iStartOn) { + case AutoStart: + path = TDEGlobalSettings::autostartPath()+"/"; + break; + case Shutdown: + path = TDEGlobal::dirs()->localtdedir()+"shutdown/"; + break; + case ENV: + path = TDEGlobal::dirs()->localtdedir()+"env/"; + break; + } + TDEIO::file_move(fileName, KURL( path + fileName.fileName() )); + fileName = path + fileName.fileName(); + } -void updateService() { - if (bisDesktop) { - if (service) { - delete service; - service = NULL; - } - service = new KService( fileName.path() ); - setText( 0, service->name() ); - setText( 1, service->exec() ); - setText( 2, fStartOn() ); - } -} + void updateService() { + if (mService) { + delete mService; + mService = NULL; + } + mService = new KService( fileName.path() ); + setText( 0, mService->name() ); + setText( 1, mService->exec() ); + setText( 2, fStartOn() ); + } }; //class CDesktopItem @@ -210,8 +202,8 @@ void CAutostart::load() TQFileInfo *fi; while ( (fi = it.current()) != 0 ) { TQString filename = fi->fileName(); - CDesktopItem * item = new CDesktopItem( fi->absFilePath(), x, listCMD ); - if ( ! item->isDesktop() ) { + CDesktopItem *item = new CDesktopItem( fi->absFilePath(), x, listCMD ); + if ( !item->mService ) { if ( fi->isSymLink() ) { TQString link = fi->readLink(); item->setText( 0, filename ); @@ -225,8 +217,8 @@ void CAutostart::load() } } else { - item->setText( 0, item->service->name() ); - item->setText( 1, item->service->exec() ); + item->setText( 0, item->mService->name() ); + item->setText( 1, item->mService->exec() ); item->setText( 2, item->fStartOn() ); } ++it; @@ -282,8 +274,8 @@ void CAutostart::addCMD() { } CDesktopItem * item = new CDesktopItem( TDEGlobalSettings::autostartPath() + service->name() + ".desktop", CDesktopItem::AutoStart, listCMD ); - item->setText( 0, item->service->name() ); - item->setText( 1, item->service->exec() ); + item->setText( 0, item->mService->name() ); + item->setText( 1, item->mService->exec() ); item->setText( 2, item->fStartOn() ); emit changed(true); } @@ -327,7 +319,7 @@ void CAutostart::setStartOn( int index ) { void CAutostart::selectionChanged(TQListViewItem* entry) { cmbStartOn->setEnabled( (entry != 0) ); - cmbStartOn->setCurrentItem( ((CDesktopItem*)entry)->startOn() ); + cmbStartOn->setCurrentItem( ((CDesktopItem*)entry)->iStartOn ); } void CAutostart::defaults(){}