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

KIO

  • sources
  • kde-4.14
  • kdelibs
  • kio
  • kio
kbuildsycocaprogressdialog.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 #include "kbuildsycocaprogressdialog.h"
19 #include <ksycoca.h>
20 #include <kprocess.h>
21 #include <kstandarddirs.h>
22 #include <klocale.h>
23 #include <QtDBus/QtDBus>
24 
25 class KBuildSycocaProgressDialogPrivate
26 {
27 public:
28  KBuildSycocaProgressDialogPrivate( KBuildSycocaProgressDialog *parent )
29  : m_parent(parent)
30  {
31  }
32 
33  void _k_slotProgress();
34  void _k_slotFinished();
35 
36  KBuildSycocaProgressDialog *m_parent;
37  QTimer m_timer;
38  int m_timeStep;
39 };
40 
41 void KBuildSycocaProgressDialog::rebuildKSycoca(QWidget *parent)
42 {
43  KBuildSycocaProgressDialog dlg(parent,
44  i18n("Updating System Configuration"),
45  i18n("Updating system configuration."));
46 
47  QDBusInterface kbuildsycoca("org.kde.kded", "/kbuildsycoca",
48  "org.kde.kbuildsycoca");
49  if (kbuildsycoca.isValid()) {
50  kbuildsycoca.callWithCallback("recreate", QVariantList(), &dlg, SLOT(_k_slotFinished()));
51  } else {
52  // kded not running, e.g. when using keditfiletype out of a KDE session
53  QObject::connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), &dlg, SLOT(_k_slotFinished()));
54  KProcess* proc = new KProcess(&dlg);
55  (*proc) << KStandardDirs::findExe(KBUILDSYCOCA_EXENAME);
56  proc->start();
57  }
58  dlg.exec();
59 }
60 
61 KBuildSycocaProgressDialog::KBuildSycocaProgressDialog(QWidget *_parent,
62  const QString &_caption, const QString &text)
63  : QProgressDialog(_parent)
64  , d( new KBuildSycocaProgressDialogPrivate(this) )
65 {
66  connect(&d->m_timer, SIGNAL(timeout()), this, SLOT(_k_slotProgress()));
67  setWindowTitle(_caption);
68  setModal(true);
69  setLabelText(text);
70  setRange(0, 20);
71  d->m_timeStep = 700;
72  d->m_timer.start(d->m_timeStep);
73  setAutoClose(false);
74 }
75 
76 KBuildSycocaProgressDialog::~KBuildSycocaProgressDialog()
77 {
78  delete d;
79 }
80 
81 void KBuildSycocaProgressDialogPrivate::_k_slotProgress()
82 {
83  const int p = m_parent->value();
84  if (p == 18)
85  {
86  m_parent->reset();
87  m_parent->setValue(1);
88  m_timeStep = m_timeStep * 2;
89  m_timer.start(m_timeStep);
90  }
91  else
92  {
93  m_parent->setValue(p+1);
94  }
95 }
96 
97 void KBuildSycocaProgressDialogPrivate::_k_slotFinished()
98 {
99  m_parent->setValue(20);
100  m_timer.stop();
101  QTimer::singleShot(1000, m_parent, SLOT(close()));
102 }
103 
104 
105 #include "kbuildsycocaprogressdialog.moc"
i18n
QString i18n(const char *text)
KBuildSycocaProgressDialog::rebuildKSycoca
static void rebuildKSycoca(QWidget *parent)
Rebuild KSycoca and show a progress dialog while doing so.
Definition: kbuildsycocaprogressdialog.cpp:41
QWidget
QDBusAbstractInterface::isValid
bool isValid() const
KProcess
QDialog::setModal
void setModal(bool modal)
timeout
int timeout
QProgressDialog::setLabelText
void setLabelText(const QString &text)
kbuildsycocaprogressdialog.h
KBuildSycocaProgressDialog
Progress dialog while ksycoca is being rebuilt (by kbuildsycoca).
Definition: kbuildsycocaprogressdialog.h:31
QDialog::exec
int exec()
klocale.h
kprocess.h
QTimer
QProgressDialog::setAutoClose
void setAutoClose(bool close)
QString
QProgressDialog::setRange
void setRange(int minimum, int maximum)
QStringList
KProcess::start
void start()
QDBusInterface
ksycoca.h
kstandarddirs.h
QDBusAbstractInterface::callWithCallback
bool callWithCallback(const QString &method, const QList< QVariant > &args, QObject *receiver, const char *returnMethod, const char *errorMethod)
QWidget::setWindowTitle
void setWindowTitle(const QString &)
KStandardDirs::findExe
static QString findExe(const QString &appname, const QString &pathstr=QString(), SearchOptions options=NoSearchOptions)
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
KBUILDSYCOCA_EXENAME
#define KBUILDSYCOCA_EXENAME
QProgressDialog
KSycoca::self
static KSycoca * self()
close
KAction * close(const QObject *recvr, const char *slot, QObject *parent)
QTimer::singleShot
singleShot
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • 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