Commit 3cf52412 authored by Christoph Cullmann's avatar Christoph Cullmann

add worker thread

parent a037b2a1
......@@ -9,7 +9,7 @@ if (NOT QJSON_FOUND)
return()
endif (NOT QJSON_FOUND)
set(kateprojectplugin_PART_SRCS plugin_kateproject.cpp kateproject.cpp kateprojectitem.cpp kateprojectview.cpp kateprojectpluginview.cpp)
set(kateprojectplugin_PART_SRCS plugin_kateproject.cpp kateproject.cpp kateprojectthread.cpp kateprojectitem.cpp kateprojectview.cpp kateprojectpluginview.cpp)
kde4_add_plugin(kateprojectplugin ${kateprojectplugin_PART_SRCS})
......
......@@ -19,6 +19,7 @@
*/
#include "kateproject.h"
#include "kateprojectthread.h"
#include <QDir>
#include <QDirIterator>
......@@ -33,12 +34,23 @@
KateProject::KateProject ()
: QObject ()
, m_thread (new KateProjectThread (this))
, m_model (new QStandardItemModel (this))
{
/**
* start our worker thread
*/
m_thread->start ();
}
KateProject::~KateProject ()
{
/**
* quit the thread event loop, wait for completion and delete it
*/
m_thread->quit ();
m_thread->wait ();
delete m_thread;
}
bool KateProject::load (const QString &fileName)
......
......@@ -132,6 +132,11 @@ class KateProject : public QObject
void loadFilesEntry (QStandardItem *parent, const QVariantMap &filesEntry);
private:
/**
* our internal thread to load stuff and do things in background
*/
class KateProjectThread *m_thread;
/**
* project file name
*/
......
/* This file is part of the Kate project.
*
* Copyright (C) 2012 Christoph Cullmann <cullmann@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "kateprojectthread.h"
KateProjectThread::KateProjectThread (KateProject *project)
: QThread ()
, m_project (project)
{
}
KateProjectThread::~KateProjectThread ()
{
}
void KateProjectThread::run ()
{
/**
* execute event loop
*/
exec ();
}
// kate: space-indent on; indent-width 2; replace-tabs on;
/* This file is part of the Kate project.
*
* Copyright (C) 2010 Christoph Cullmann <cullmann@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KATE_PROJECT_THREAD_H
#define KATE_PROJECT_THREAD_H
#include <QThread>
#include "kateproject.h"
/**
* Class representing a project background thread.
* This thread will build up the model for the project on load and do other stuff in the background.
*/
class KateProjectThread : public QThread
{
Q_OBJECT
public:
/**
* construct project thread for given project
* @param project our project
*/
KateProjectThread (KateProject *project);
/**
* deconstruct project
*/
~KateProjectThread ();
protected:
/**
* Overwritten run method
*/
void run ();
private:
/**
* our project
*/
KateProject *m_project;
};
#endif
// kate: space-indent on; indent-width 2; replace-tabs on;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment