• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • sources
  • kde-4.12
  • kdelibs
  • nepomuk-core
  • services
  • filewatch
removabledeviceindexnotification.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Nepomuk KDE project.
3  Copyright (C) 2011 Sebastian Trueg <trueg@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) version 3, or any
9  later version accepted by the membership of KDE e.V. (or its
10  successor approved by the membership of KDE e.V.), which shall
11  act as a proxy defined in Section 6 of version 3 of the license.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #include "removabledeviceindexnotification.h"
23 #include "fileindexerinterface.h"
24 
25 #include <KLocale>
26 #include <KConfig>
27 #include <KConfigGroup>
28 #include <KIcon>
29 #include <KDebug>
30 #include <KToolInvocation>
31 
32 #include <Solid/StorageAccess>
33 
34 RemovableDeviceIndexNotification::RemovableDeviceIndexNotification(const Nepomuk2::RemovableMediaCache::Entry* medium,
35  QObject *parent)
36  : KNotification(QLatin1String("nepomuk_new_removable_device"),
37  KNotification::Persistent,
38  parent),
39  m_medium(medium)
40 {
41  setTitle(i18nc("@title", "New removable device detected"));
42  setText(i18nc("@info", "Do you want files on removable device <resource>%1</resource> to be indexed for fast desktop searches?", m_medium->device().description()));
43  setPixmap(KIcon(QLatin1String("nepomuk")).pixmap(32, 32));
44 
45  setActions(QStringList()
46  << i18nc("@action", "Index files")
47  << i18nc("@action", "Ignore device")
48  << i18nc("@action", "Configure"));
49  connect(this, SIGNAL(activated(uint)), this, SLOT(slotActionActivated(uint)));
50 
51  // as soon as the device is unmounted this notification becomes pointless
52  if ( const Solid::StorageAccess* storage = m_medium->device().as<Solid::StorageAccess>() ) {
53  connect(storage, SIGNAL(accessibilityChanged(bool,QString)), SLOT(close()));
54  }
55 }
56 
57 void RemovableDeviceIndexNotification::slotActionDoIndexActivated()
58 {
59  KConfig fileIndexerConfig( "nepomukstrigirc" );
60  KConfigGroup group = fileIndexerConfig.group( QByteArray("Device-") + m_medium->url().toUtf8() );
61  group.writeEntry( "mount path", m_medium->mountPath() );
62  group.writePathEntry( "folders", QStringList() << QLatin1String("/") );
63 
64  // We don't need to inform the fileindexer. The configuration file would have
65  // changed and the file indexer will update itself
66  close();
67 }
68 
69 void RemovableDeviceIndexNotification::slotActionDoNotIndexActivated()
70 {
71  KConfig fileIndexerConfig( "nepomukstrigirc" );
72  KConfigGroup group = fileIndexerConfig.group( QByteArray("Device-") + m_medium->url().toUtf8() );
73  group.writeEntry( "mount path", m_medium->mountPath() );
74  group.writePathEntry( "exclude folders", QStringList() << QLatin1String("/") );
75 
76  close();
77 }
78 
79 void RemovableDeviceIndexNotification::slotActionConfigureActivated()
80 {
81  QStringList args;
82  args << "kcm_nepomuk" << "--args" << "1";
83  KToolInvocation::kdeinitExec("kcmshell4", args);
84 }
85 
86 void RemovableDeviceIndexNotification::slotActionActivated(uint action)
87 {
88  kDebug() << action;
89  switch(action) {
90  case 1:
91  slotActionDoIndexActivated();
92  break;
93  case 2:
94  slotActionDoNotIndexActivated();
95  break;
96  case 3:
97  slotActionConfigureActivated();
98  break;
99  }
100 }
101 
102 #include "removabledeviceindexnotification.moc"
RemovableDeviceIndexNotification::RemovableDeviceIndexNotification
RemovableDeviceIndexNotification(const Nepomuk2::RemovableMediaCache::Entry *medium, QObject *parent=0)
Definition: removabledeviceindexnotification.cpp:34
Nepomuk2::RemovableMediaCache::Entry::mountPath
QString mountPath() const
Definition: removablemediacache.cpp:322
QObject
Nepomuk2::RemovableMediaCache::Entry::device
Solid::Device device() const
Definition: removablemediacache.h:66
Nepomuk2::RemovableMediaCache::Entry
Definition: removablemediacache.h:53
KNotification
removabledeviceindexnotification.h
Nepomuk2::RemovableMediaCache::Entry::url
QString url() const
Definition: removablemediacache.h:67
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk-Core

Skip menu "Nepomuk-Core"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal