Changeset View
Changeset View
Standalone View
Standalone View
kcms/autostart/autostartitem.cpp
Show All 23 Lines | |||||
24 | #include <QTreeWidgetItem> | 24 | #include <QTreeWidgetItem> | ||
25 | #include <QTreeWidget> | 25 | #include <QTreeWidget> | ||
26 | #include <QDir> | 26 | #include <QDir> | ||
27 | #include <QDebug> | 27 | #include <QDebug> | ||
28 | 28 | | |||
29 | #include <KLocalizedString> | 29 | #include <KLocalizedString> | ||
30 | #include <KIO/CopyJob> | 30 | #include <KIO/CopyJob> | ||
31 | 31 | | |||
32 | AutoStartItem::AutoStartItem( const QString &service, QTreeWidgetItem *parent, Autostart* ) | 32 | AutoStartItem::AutoStartItem(const QString &service, QTreeWidgetItem *parent, Autostart *) | ||
33 | : QTreeWidgetItem( parent ) | 33 | : QTreeWidgetItem(parent), m_fileName(QUrl::fromLocalFile(service)) | ||
34 | , m_fileName(QUrl::fromLocalFile(service)) | | |||
35 | { | 34 | { | ||
36 | } | 35 | } | ||
37 | 36 | | |||
38 | AutoStartItem::~AutoStartItem() | 37 | AutoStartItem::~AutoStartItem() | ||
39 | { | 38 | { | ||
40 | 39 | | |||
41 | } | 40 | } | ||
42 | 41 | | |||
43 | QUrl AutoStartItem::fileName() const | 42 | QUrl AutoStartItem::fileName() const | ||
44 | { | 43 | { | ||
45 | return m_fileName; | 44 | return m_fileName; | ||
46 | } | 45 | } | ||
47 | 46 | | |||
48 | void AutoStartItem::setPath(const QString &path) | 47 | void AutoStartItem::setPath(const QString &path) | ||
49 | { | 48 | { | ||
50 | Q_ASSERT( path.endsWith(QDir::separator()) ); | 49 | Q_ASSERT(path.endsWith(QDir::separator())); | ||
51 | 50 | | |||
52 | if (QUrl(path) == m_fileName.adjusted(QUrl::RemoveFilename)) | 51 | if (QUrl(path) == m_fileName.adjusted(QUrl::RemoveFilename)) { | ||
53 | return; | 52 | return; | ||
53 | } | ||||
54 | 54 | | |||
55 | const QString& newFileName = path + m_fileName.fileName(); | 55 | const QString &newFileName = path + m_fileName.fileName(); | ||
56 | KIO::move(m_fileName, QUrl::fromLocalFile(newFileName)); | 56 | KIO::move(m_fileName, QUrl::fromLocalFile(newFileName)); | ||
57 | 57 | | |||
58 | m_fileName = QUrl::fromLocalFile(newFileName); | 58 | m_fileName = QUrl::fromLocalFile(newFileName); | ||
59 | } | 59 | } | ||
60 | 60 | | |||
61 | DesktopStartItem::DesktopStartItem( const QString &service, QTreeWidgetItem *parent, Autostart*autostart ) | 61 | DesktopStartItem::DesktopStartItem(const QString &service, QTreeWidgetItem *parent, Autostart *autostart) | ||
62 | : AutoStartItem( service, parent,autostart ) | 62 | : AutoStartItem(service, parent, autostart) | ||
63 | { | 63 | { | ||
64 | setCheckState ( Autostart::COL_STATUS,Qt::Checked ); | 64 | setCheckState(Autostart::COL_STATUS, Qt::Checked); | ||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | DesktopStartItem::~DesktopStartItem() | 67 | DesktopStartItem::~DesktopStartItem() | ||
68 | { | 68 | { | ||
69 | } | 69 | } | ||
70 | 70 | | |||
71 | ScriptStartItem::ScriptStartItem( const QString &service, QTreeWidgetItem *parent, Autostart* autostart ) | 71 | ScriptStartItem::ScriptStartItem(const QString &service, QTreeWidgetItem *parent, Autostart *autostart) | ||
72 | : AutoStartItem( service, parent,autostart ) | 72 | : AutoStartItem(service, parent, autostart) | ||
73 | { | 73 | { | ||
74 | m_comboBoxStartup = new QComboBox; | 74 | m_comboBoxStartup = new QComboBox; | ||
75 | m_comboBoxStartup->addItems( autostart->listPathName() ); | 75 | m_comboBoxStartup->addItems(autostart->listPathName()); | ||
76 | 76 | | |||
77 | setText( 2, i18nc( "The program will be run", "Enabled" ) ); | 77 | setText(2, i18nc("The program will be run", "Enabled")); | ||
78 | QObject::connect(m_comboBoxStartup, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &ScriptStartItem::slotStartupChanged); | 78 | QObject::connect(m_comboBoxStartup, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), | ||
79 | this, &ScriptStartItem::slotStartupChanged); | ||||
79 | QObject::connect( this,&ScriptStartItem::askChangeStartup,autostart,&Autostart::slotChangeStartup ); | 80 | QObject::connect(this, &ScriptStartItem::askChangeStartup, autostart, &Autostart::slotChangeStartup); | ||
80 | treeWidget()->setItemWidget ( this, Autostart::COL_RUN, m_comboBoxStartup ); | 81 | treeWidget()->setItemWidget(this, Autostart::COL_RUN, m_comboBoxStartup); | ||
81 | } | 82 | } | ||
82 | 83 | | |||
83 | ScriptStartItem::~ScriptStartItem() | 84 | ScriptStartItem::~ScriptStartItem() | ||
84 | { | 85 | { | ||
85 | } | 86 | } | ||
86 | 87 | | |||
87 | void ScriptStartItem::slotStartupChanged(int index) | 88 | void ScriptStartItem::slotStartupChanged(int index) | ||
88 | { | 89 | { | ||
89 | emit askChangeStartup(this, index); | 90 | emit askChangeStartup(this, index); | ||
90 | } | 91 | } | ||
91 | 92 | | |||
92 | void ScriptStartItem::changeStartup(ScriptStartItem::ENV type ) | 93 | void ScriptStartItem::changeStartup(ScriptStartItem::ENV type) | ||
93 | { | 94 | { | ||
94 | switch( type ) | 95 | switch (type) { | ||
95 | { | | |||
96 | case ScriptStartItem::START: | 96 | case ScriptStartItem::START: | ||
97 | m_comboBoxStartup->setCurrentIndex( 0 ); | 97 | m_comboBoxStartup->setCurrentIndex(0); | ||
98 | break; | 98 | break; | ||
99 | case ScriptStartItem::SHUTDOWN: | 99 | case ScriptStartItem::SHUTDOWN: | ||
100 | m_comboBoxStartup->setCurrentIndex( 1 ); | 100 | m_comboBoxStartup->setCurrentIndex(1); | ||
101 | break; | 101 | break; | ||
102 | case ScriptStartItem::PRE_START: | 102 | case ScriptStartItem::PRE_START: | ||
103 | m_comboBoxStartup->setCurrentIndex( 2 ); | 103 | m_comboBoxStartup->setCurrentIndex(2); | ||
104 | break; | 104 | break; | ||
105 | default: | 105 | default: | ||
106 | qWarning() << " startup type is not defined :" << type; | 106 | qWarning() << " startup type is not defined :" << type; | ||
107 | break; | 107 | break; | ||
108 | } | 108 | } | ||
109 | } | 109 | } |