]>
cloud.milkyroute.net Git - dolphin.git/blob - src/viewpropsprogressinfo.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "viewpropsprogressinfo.h"
22 #include "viewpropsapplier.h"
23 #include "viewproperties.h"
26 #include <QProgressBar>
28 #include <QVBoxLayout>
33 #include <kio/jobclasses.h>
35 ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget
* parent
,
37 const ViewProperties
* viewProps
) :
42 m_viewProps(viewProps
),
48 setCaption(i18n("Applying view properties"));
49 setButtons(KDialog::Cancel
);
51 QWidget
* main
= new QWidget();
52 QVBoxLayout
* topLayout
= new QVBoxLayout();
54 m_label
= new QLabel(i18n("Counting folders: %1", 0), main
);
55 m_progressBar
= new QProgressBar(main
);
57 topLayout
->addWidget(m_label
);
58 topLayout
->addWidget(m_progressBar
);
60 main
->setLayout(topLayout
);
63 ViewPropsApplier
* applier
= new ViewPropsApplier(dir
);
64 connect(applier
, SIGNAL(progress(const KUrl
&, int)),
65 this, SLOT(countDirs(const KUrl
&, int)));
66 connect(applier
, SIGNAL(completed()),
67 this, SLOT(applyViewProperties()));
69 // TODO: use KDirSize job instead. Current issue: the signal
70 // 'result' is not emitted with kdelibs 2006-12-05.
72 /*m_dirSizeJob = KDirSize::dirSizeJob(dir);
73 connect(m_dirSizeJob, SIGNAL(result(KJob*)),
74 this, SLOT(slotResult(KJob*)));
76 m_timer = new QTimer(this);
77 connect(m_timer, SIGNAL(timeout()),
78 this, SLOT(updateDirCounter()));
79 m_timer->start(300);*/
82 ViewPropsProgressInfo::~ViewPropsProgressInfo()
86 void ViewPropsProgressInfo::countDirs(const KUrl
& /*dir*/, int count
)
89 m_label
->setText(i18n("Counting folders: %1", m_dirCount
));
92 /*void ViewPropsProgressInfo::updateDirCounter()
94 const int subdirs = m_dirSizeJob->totalSubdirs();
95 m_label->setText(i18n("Counting folders: %1", subdirs));
98 void ViewPropsProgressInfo::slotResult(KJob*)
100 QTimer::singleShot(0, this, SLOT(applyViewProperties()));
103 void ViewPropsProgressInfo::applyViewProperties()
106 //const int subdirs = m_dirSizeJob->totalSubdirs();
107 //m_label->setText(i18n("Folders: %1", subdirs));
108 //m_progressBar->setMaximum(subdirs);
110 m_label
->setText(i18n("Folders: %1", m_dirCount
));
111 m_progressBar
->setMaximum(m_dirCount
);
113 ViewPropsApplier
* applier
= new ViewPropsApplier(m_dir
, m_viewProps
);
114 connect(applier
, SIGNAL(progress(const KUrl
&, int)),
115 this, SLOT(showProgress(const KUrl
&, int)));
116 connect(applier
, SIGNAL(completed()),
117 this, SLOT(close()));
120 void ViewPropsProgressInfo::showProgress(const KUrl
& url
, int count
)
122 m_applyCount
+= count
;
123 m_progressBar
->setValue(m_applyCount
);
126 #include "viewpropsprogressinfo.moc"