~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kcontrol/autostart/autostartitem.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2008 by Montel Laurent <montel@kde.org>                 *
 
3
 *                                                                         *
 
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.                                   *
 
8
 *                                                                         *
 
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.                          *
 
13
 *                                                                         *
 
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
 ***************************************************************************/
 
19
 
 
20
#include "autostartitem.h"
 
21
#include "autostart.h"
 
22
#include <QComboBox>
 
23
#include <QTreeWidgetItem>
 
24
#include <QTreeWidget>
 
25
 
 
26
#include <klocale.h>
 
27
#include <KDebug>
 
28
#include <KIO/CopyJob>
 
29
 
 
30
AutoStartItem::AutoStartItem( const QString &service, QTreeWidgetItem *parent, Autostart* )
 
31
    : QTreeWidgetItem( parent )
 
32
{
 
33
    m_fileName = KUrl(service);
 
34
}
 
35
 
 
36
AutoStartItem::~AutoStartItem()
 
37
{
 
38
 
 
39
}
 
40
 
 
41
KUrl AutoStartItem::fileName() const
 
42
{
 
43
    return m_fileName;
 
44
}
 
45
 
 
46
void AutoStartItem::setPath(const QString &path) {
 
47
    if (path == m_fileName.directory(KUrl::AppendTrailingSlash))
 
48
        return;
 
49
    KIO::move(m_fileName, KUrl( path + '/' + m_fileName.fileName() ));
 
50
    m_fileName = KUrl(path + m_fileName.fileName());
 
51
}
 
52
 
 
53
 
 
54
DesktopStartItem::DesktopStartItem( const QString &service, QTreeWidgetItem *parent, Autostart*autostart )
 
55
    : AutoStartItem( service, parent,autostart )
 
56
{
 
57
    setCheckState ( Autostart::COL_STATUS,Qt::Checked );
 
58
}
 
59
 
 
60
DesktopStartItem::~DesktopStartItem()
 
61
{
 
62
}
 
63
 
 
64
ScriptStartItem::ScriptStartItem( const QString &service, QTreeWidgetItem *parent, Autostart* autostart )
 
65
    : AutoStartItem( service, parent,autostart )
 
66
{
 
67
    m_comboBoxStartup = new QComboBox;
 
68
    m_comboBoxStartup->addItems( autostart->listPathName() );
 
69
 
 
70
    setText( 2, i18nc( "The program will be run", "Enabled" ) );
 
71
    QObject::connect( m_comboBoxStartup, SIGNAL(activated ( int ) ),autostart,SLOT( slotChangeStartup( int ) ) );
 
72
    treeWidget()->setItemWidget ( this, Autostart::COL_RUN, m_comboBoxStartup );
 
73
}
 
74
 
 
75
ScriptStartItem::~ScriptStartItem()
 
76
{
 
77
}
 
78
 
 
79
void ScriptStartItem::changeStartup(ScriptStartItem::ENV type )
 
80
{
 
81
    switch( type )
 
82
    {
 
83
    case ScriptStartItem::START:
 
84
        m_comboBoxStartup->setCurrentIndex( 0 );
 
85
        break;
 
86
    case ScriptStartItem::SHUTDOWN:
 
87
        m_comboBoxStartup->setCurrentIndex( 1 );
 
88
        break;
 
89
    case ScriptStartItem::PRE_START:
 
90
        m_comboBoxStartup->setCurrentIndex( 2 );
 
91
        break;
 
92
    default:
 
93
        kDebug()<<" type is not defined :"<<type;
 
94
        break;
 
95
    }
 
96
}
 
97