summaryrefslogtreecommitdiffstats
path: root/src/app/Queue
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2025-08-28 22:44:34 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2025-08-31 23:30:34 +0900
commitf9abd9d505434c9244c03eac708e29a0ca042f6b (patch)
tree30a197ab4c413849188bc131ff859212e636c821 /src/app/Queue
parent14d42d284de233f9937becf3fc9ee0dabede3b21 (diff)
downloadkrusader-r14.1.x.tar.gz
krusader-r14.1.x.zip
Restructure source foldersr14.1.x
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit 086012dcad8a976a0dabbb7cbc20c9cb612cdfa9)
Diffstat (limited to 'src/app/Queue')
-rw-r--r--src/app/Queue/Makefile.am10
-rw-r--r--src/app/Queue/queue.cpp22
-rw-r--r--src/app/Queue/queue.h33
-rw-r--r--src/app/Queue/queue_mgr.cpp31
-rw-r--r--src/app/Queue/queue_mgr.h26
-rw-r--r--src/app/Queue/queuewidget.cpp10
-rw-r--r--src/app/Queue/queuewidget.h15
7 files changed, 147 insertions, 0 deletions
diff --git a/src/app/Queue/Makefile.am b/src/app/Queue/Makefile.am
new file mode 100644
index 0000000..1630c6a
--- /dev/null
+++ b/src/app/Queue/Makefile.am
@@ -0,0 +1,10 @@
+noinst_LIBRARIES = libQueue.a
+
+INCLUDES = $(all_includes)
+
+libQueue_a_METASOURCES = AUTO
+
+libQueue_a_SOURCES = \
+ queue.cpp \
+ queue_mgr.cpp \
+ queuewidget.cpp
diff --git a/src/app/Queue/queue.cpp b/src/app/Queue/queue.cpp
new file mode 100644
index 0000000..f6677f6
--- /dev/null
+++ b/src/app/Queue/queue.cpp
@@ -0,0 +1,22 @@
+#include "queue.h"
+
+Queue::Queue(const TQString& name): _name(name)
+{
+}
+
+Queue::~Queue()
+{
+ // TODO: save queue on delete? or just delete jobs
+}
+
+void Queue::enqueue(TDEIO::Job *job)
+{
+ _jobs.append(job);
+
+ dumpQueue();
+}
+
+void Queue::dumpQueue()
+{
+ tqDebug("Queue: %s", name().latin1());
+}
diff --git a/src/app/Queue/queue.h b/src/app/Queue/queue.h
new file mode 100644
index 0000000..8f3a598
--- /dev/null
+++ b/src/app/Queue/queue.h
@@ -0,0 +1,33 @@
+#ifndef QUEUE_H
+#define QUEUE_H
+
+#include <tqobject.h>
+#include <tdeio/jobclasses.h>
+#include <tqptrlist.h>
+
+/**
+ * Queue can hold anything which inherits TDEIO::Job, and schedule it, start it, stop etc...
+ * the main reason to hold the Job itself (at least for phase 1) is to keep the code
+ * in krusader relatively unchaged, and allow to create the job as usual and choose if
+ * to start it, or queue it.
+ *
+ */
+class Queue: public TQObject
+{
+ TQ_OBJECT
+
+public:
+ Queue(const TQString& name);
+ virtual ~Queue();
+
+ inline const TQString& name() const { return _name; }
+ void enqueue(TDEIO::Job *job);
+
+protected:
+ void dumpQueue();
+
+ TQString _name;
+ TQPtrList<TDEIO::Job> _jobs;
+};
+
+#endif // QUEUE_H
diff --git a/src/app/Queue/queue_mgr.cpp b/src/app/Queue/queue_mgr.cpp
new file mode 100644
index 0000000..f7f0b27
--- /dev/null
+++ b/src/app/Queue/queue_mgr.cpp
@@ -0,0 +1,31 @@
+#include "queue_mgr.h"
+
+const TQString QueueManager::defaultName="default";
+TQMap<TQString, Queue*> QueueManager::_queues;
+
+QueueManager::QueueManager()
+{
+ Queue *defaultQ = new Queue(defaultName);
+ _queues.insert(defaultQ->name(), defaultQ);
+}
+
+QueueManager::~QueueManager()
+{
+ TQMap<TQString, Queue*>::iterator it;
+ for (it = _queues.begin(); it != _queues.end(); ++it )
+ delete it.data();
+ _queues.clear();
+}
+
+Queue* QueueManager::queue(const TQString& queueName)
+{
+ if (!_queues.contains(queueName))
+ return 0;
+ return _queues[queueName];
+}
+
+TQValueList<TQString> QueueManager::queues() const
+{
+ return _queues.keys();
+}
+
diff --git a/src/app/Queue/queue_mgr.h b/src/app/Queue/queue_mgr.h
new file mode 100644
index 0000000..c2b8bc9
--- /dev/null
+++ b/src/app/Queue/queue_mgr.h
@@ -0,0 +1,26 @@
+#ifndef QUEUE_MGR_H
+#define QUEUE_MGR_H
+
+#include "queue.h"
+#include <tqmap.h>
+
+/**
+ * QueueManager holds multiple queues and has a static
+ * method that fetches a queue by name. calling it with
+ * no arguments will fetch the default queue
+ */
+class QueueManager
+{
+ static const TQString defaultName;
+public:
+ QueueManager();
+ ~QueueManager();
+
+ static Queue* queue(const TQString& queueName=defaultName);
+ TQValueList<TQString> queues() const;
+
+protected:
+ static TQMap<TQString, Queue*> _queues;
+};
+
+#endif // QUEUE_MGR_H
diff --git a/src/app/Queue/queuewidget.cpp b/src/app/Queue/queuewidget.cpp
new file mode 100644
index 0000000..65c11da
--- /dev/null
+++ b/src/app/Queue/queuewidget.cpp
@@ -0,0 +1,10 @@
+#include "queuewidget.h"
+
+QueueWidget::QueueWidget(): KTabWidget()
+{
+}
+
+
+QueueWidget::~QueueWidget()
+{
+}
diff --git a/src/app/Queue/queuewidget.h b/src/app/Queue/queuewidget.h
new file mode 100644
index 0000000..090622e
--- /dev/null
+++ b/src/app/Queue/queuewidget.h
@@ -0,0 +1,15 @@
+#ifndef QUEUE_WIDGET_H
+#define QUEUE_WIDGET_H
+
+#include <ktabwidget.h>
+
+class QueueWidget: public KTabWidget
+{
+ TQ_OBJECT
+
+public:
+ QueueWidget();
+ ~QueueWidget();
+};
+
+#endif // QUEUE_WIDGET_H