File indexing completed on 2024-06-16 06:57:01

0001 /*
0002     This file is or will be part of KDE desktop environment
0003     SPDX-FileCopyrightText: 1999 Matt Koss <koss@miesto.sk>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #ifndef _KIOWORKERTEST_H
0009 #define _KIOWORKERTEST_H
0010 
0011 #include <QButtonGroup>
0012 #include <QLabel>
0013 #include <QLineEdit>
0014 #include <QMainWindow>
0015 #include <QPushButton>
0016 #include <QRadioButton>
0017 #include <QWidget>
0018 
0019 #include "kio/global.h"
0020 #include <kio/simplejob.h>
0021 #include <kio/udsentry.h>
0022 
0023 #include <KStatusBarJobTracker>
0024 
0025 class KioWorkerTest : public QMainWindow
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     KioWorkerTest(QString src, QString dest, uint op, uint pr);
0031 
0032     ~KioWorkerTest() override
0033     {
0034         if (job) {
0035             job->kill(KJob::Quietly); // kill the job quietly
0036         }
0037     }
0038 
0039     enum Operations { List = 0, ListRecursive, Stat, Get, Put, Copy, Move, Delete, Mkdir, Mimetype };
0040 
0041     enum ProgressModes { ProgressNone = 0, ProgressDefault, ProgressStatus };
0042 
0043 protected:
0044     void printUDSEntry(const KIO::UDSEntry &entry);
0045 
0046     // info stuff
0047     QLabel *lb_from;
0048     QLineEdit *le_source;
0049 
0050     QLabel *lb_to;
0051     QLineEdit *le_dest;
0052 
0053     // operation stuff
0054     QButtonGroup *opButtons;
0055 
0056     QRadioButton *rbList;
0057     QRadioButton *rbListRecursive;
0058     QRadioButton *rbStat;
0059     QRadioButton *rbGet;
0060     QRadioButton *rbPut;
0061     QRadioButton *rbCopy;
0062     QRadioButton *rbMove;
0063     QRadioButton *rbDelete;
0064     QRadioButton *rbMkdir;
0065     QRadioButton *rbMimetype;
0066 
0067     // progress stuff
0068     QButtonGroup *progressButtons;
0069 
0070     QRadioButton *rbProgressNone;
0071     QRadioButton *rbProgressDefault;
0072     QRadioButton *rbProgressStatus;
0073 
0074     QPushButton *pbStart;
0075     QPushButton *pbStop;
0076 
0077     QPushButton *close;
0078 
0079 protected Q_SLOTS:
0080     void changeOperation(QAbstractButton *b);
0081     void changeProgressMode(QAbstractButton *b);
0082 
0083     void startJob();
0084     void stopJob();
0085 
0086     void slotResult(KJob *);
0087     void slotEntries(KIO::Job *, const KIO::UDSEntryList &);
0088     void slotData(KIO::Job *, const QByteArray &data);
0089     void slotDataReq(KIO::Job *, QByteArray &data);
0090 
0091     void slotQuit();
0092 
0093 private:
0094     KIO::Job *job;
0095     QWidget *main_widget;
0096 
0097     KStatusBarJobTracker *statusTracker;
0098 
0099     int selectedOperation;
0100     int progressMode;
0101     int putBuffer;
0102 };
0103 
0104 #endif // _KIOWORKERTEST_H