File indexing completed on 2024-04-14 03:53:41

0001 /*
0002     This file is part of the KDE desktop environment
0003     SPDX-FileCopyrightText: 2001, 2002 Michael Brade <brade@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef _KDIRLISTERTEST_GUI_H_
0009 #define _KDIRLISTERTEST_GUI_H_
0010 
0011 #include <QString>
0012 #include <QUrl>
0013 #include <QWidget>
0014 
0015 #include <kdirlister.h>
0016 #include <kfileitem.h>
0017 
0018 #include <iostream>
0019 
0020 using namespace std;
0021 
0022 class PrintSignals : public QObject
0023 {
0024     Q_OBJECT
0025 public:
0026     PrintSignals()
0027         : QObject()
0028     {
0029     }
0030 
0031 public Q_SLOTS:
0032     void started(const QUrl &url)
0033     {
0034         cout << "*** started( " << url.url().toLocal8Bit().data() << " )" << endl;
0035     }
0036     void canceled()
0037     {
0038         cout << "canceled()" << endl;
0039     }
0040     void listingDirCanceled(const QUrl &url)
0041     {
0042         cout << "*** canceled( " << url.toDisplayString().toLocal8Bit().data() << " )" << endl;
0043     }
0044     void completed()
0045     {
0046         cout << "*** completed()" << endl;
0047     }
0048     void listingDirCompleted(const QUrl &url)
0049     {
0050         cout << "*** completed( " << url.toDisplayString().toLocal8Bit().data() << " )" << endl;
0051     }
0052     void redirection(const QUrl &src, const QUrl &dest)
0053     {
0054         cout << "*** redirection( " << src.toDisplayString().toLocal8Bit().data() << ", " << dest.toDisplayString().toLocal8Bit().data() << " )" << endl;
0055     }
0056     void clear()
0057     {
0058         cout << "*** clear()" << endl;
0059     }
0060     void newItems(const KFileItemList &items)
0061     {
0062         cout << "*** newItems: " << endl;
0063         for (auto it = items.cbegin(), itEnd = items.constEnd(); it != itEnd; ++it) {
0064             cout << (*it).name().toLocal8Bit().data() << endl;
0065         }
0066     }
0067     void itemsDeleted(const KFileItemList &)
0068     {
0069         cout << "*** itemsDeleted: " << endl;
0070         // TODO
0071     }
0072     void refreshItems(const QList<QPair<KFileItem, KFileItem>> &)
0073     {
0074         cout << "*** refreshItems: " << endl;
0075         // TODO
0076     }
0077     void infoMessage(const QString &msg)
0078     {
0079         cout << "*** infoMessage: " << msg.toLocal8Bit().data() << endl;
0080     }
0081 
0082     void percent(int percent)
0083     {
0084         cout << "*** percent: " << percent << endl;
0085     }
0086 
0087     void totalSize(KIO::filesize_t size)
0088     {
0089         cout << "*** totalSize: " << (long)size << endl;
0090     }
0091 
0092     void processedSize(KIO::filesize_t size)
0093     {
0094         cout << "*** processedSize: " << (long)size << endl;
0095     }
0096 
0097     void speed(int bytes_per_second)
0098     {
0099         cout << "*** speed: " << bytes_per_second << endl;
0100     }
0101 };
0102 
0103 class KDirListerTest : public QWidget
0104 {
0105     Q_OBJECT
0106 public:
0107     KDirListerTest(QWidget *parent = nullptr, const QUrl &url = {});
0108     ~KDirListerTest() override;
0109 
0110 public Q_SLOTS:
0111     void startRoot();
0112     void startHome();
0113     void startTar();
0114     void test();
0115     void completed();
0116 
0117 private:
0118     KDirLister *lister;
0119     PrintSignals *debug;
0120 };
0121 
0122 #endif