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

KIO

kbuildsycocaprogressdialog.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 #include "kbuildsycocaprogressdialog.h"
00019 #include <ksycoca.h>
00020 #include <kprocess.h>
00021 #include <kstandarddirs.h>
00022 #include <klocale.h>
00023 #include <kapplication.h>
00024 #include <QtDBus/QtDBus>
00025 
00026 class KBuildSycocaProgressDialogPrivate
00027 {
00028 public:
00029     KBuildSycocaProgressDialogPrivate( KBuildSycocaProgressDialog *parent )
00030         : m_parent(parent)
00031     {
00032     }
00033 
00034     void _k_slotProgress();
00035     void _k_slotFinished();
00036 
00037     KBuildSycocaProgressDialog *m_parent;
00038     QTimer m_timer;
00039     int m_timeStep;
00040 };
00041 
00042 void KBuildSycocaProgressDialog::rebuildKSycoca(QWidget *parent)
00043 {
00044   KBuildSycocaProgressDialog dlg(parent,
00045                                  i18n("Updating System Configuration"),
00046                                  i18n("Updating system configuration."));
00047 
00048   QDBusInterface kbuildsycoca("org.kde.kded", "/kbuildsycoca",
00049                               "org.kde.kbuildsycoca");
00050   if (kbuildsycoca.isValid()) {
00051      kbuildsycoca.callWithCallback("recreate", QVariantList(), &dlg, SLOT(_k_slotFinished()));
00052   } else {
00053       // kded not running, e.g. when using keditfiletype out of a KDE session
00054       QObject::connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), &dlg, SLOT(_k_slotFinished()));
00055       KProcess* proc = new KProcess(&dlg);
00056       (*proc) << KStandardDirs::findExe(KBUILDSYCOCA_EXENAME);
00057       proc->start();
00058   }
00059   dlg.exec();
00060 }
00061 
00062 KBuildSycocaProgressDialog::KBuildSycocaProgressDialog(QWidget *_parent,
00063                           const QString &_caption, const QString &text)
00064  : QProgressDialog(_parent)
00065  , d( new KBuildSycocaProgressDialogPrivate(this) )
00066 {
00067   connect(&d->m_timer, SIGNAL(timeout()), this, SLOT(_k_slotProgress()));
00068   setWindowTitle(_caption);
00069   setModal(true);
00070   setLabelText(text);
00071   setRange(0, 20);
00072   d->m_timeStep = 700;
00073   d->m_timer.start(d->m_timeStep);
00074   setAutoClose(false);
00075 }
00076 
00077 KBuildSycocaProgressDialog::~KBuildSycocaProgressDialog()
00078 {
00079     delete d;
00080 }
00081 
00082 void KBuildSycocaProgressDialogPrivate::_k_slotProgress()
00083 {
00084   const int p = m_parent->value();
00085   if (p == 18)
00086   {
00087      m_parent->reset();
00088      m_parent->setValue(1);
00089      m_timeStep = m_timeStep * 2;
00090      m_timer.start(m_timeStep);
00091   }
00092   else
00093   {
00094      m_parent->setValue(p+1);
00095   }
00096 }
00097 
00098 void KBuildSycocaProgressDialogPrivate::_k_slotFinished()
00099 {
00100   m_parent->setValue(20);
00101   m_timer.stop();
00102   QTimer::singleShot(1000, m_parent, SLOT(close()));
00103 }
00104 
00105 
00106 #include "kbuildsycocaprogressdialog.moc"

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal