1 /***************************************************************************
2 * Copyright (C) 2008 by Montel Laurent <montel@kde.org> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
18 ***************************************************************************/
20 #include "autostartitem.h"
21 #include "autostart.h"
23 #include <QTreeWidgetItem>
24 #include <QTreeWidget>
25 #include <KIO/NetAccess>
26 #include <KIO/DeleteJob>
27 #include <KIO/CopyJob>
32 AutoStartItem::AutoStartItem( const QString
&service
, QTreeWidgetItem
*parent
, Autostart
* )
33 : QTreeWidgetItem( parent
)
35 m_fileName
= KUrl(service
);
38 AutoStartItem::~AutoStartItem()
43 KUrl
AutoStartItem::fileName() const
48 void AutoStartItem::setPath(const QString
&path
) {
49 if (path
== m_fileName
.directory(KUrl::AppendTrailingSlash
))
51 KIO::move(m_fileName
, KUrl( path
+ '/' + m_fileName
.fileName() ));
52 m_fileName
= KUrl(path
+ m_fileName
.fileName());
56 DesktopStartItem::DesktopStartItem( const QString
&service
, QTreeWidgetItem
*parent
, Autostart
*autostart
)
57 : AutoStartItem( service
, parent
,autostart
)
59 setCheckState ( Autostart::COL_STATUS
,Qt::Checked
);
62 DesktopStartItem::~DesktopStartItem()
66 ScriptStartItem::ScriptStartItem( const QString
&service
, QTreeWidgetItem
*parent
, Autostart
* autostart
)
67 : AutoStartItem( service
, parent
,autostart
)
69 m_comboBoxStartup
= new QComboBox
;
70 m_comboBoxStartup
->addItems( autostart
->listPathName() );
72 setText( 2, i18nc( "The program will be run", "Enabled" ) );
73 QObject::connect( m_comboBoxStartup
, SIGNAL(activated ( int ) ),autostart
,SLOT( slotChangeStartup( int ) ) );
74 treeWidget()->setItemWidget ( this, Autostart::COL_RUN
, m_comboBoxStartup
);
77 ScriptStartItem::~ScriptStartItem()
81 void ScriptStartItem::changeStartup(ScriptStartItem::ENV type
)
85 case ScriptStartItem::START
:
86 m_comboBoxStartup
->setCurrentIndex( 0 );
88 case ScriptStartItem::SHUTDOWN
:
89 m_comboBoxStartup
->setCurrentIndex( 1 );
91 case ScriptStartItem::PRE_START
:
92 m_comboBoxStartup
->setCurrentIndex( 2 );
95 kDebug()<<" type is not defined :"<<type
;