1 /***************************************************************************
2 * Copyright (C) 2003 by Hideki Ikemoto *
3 * ikemo@users.sourceforge.jp *
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. *
9 ***************************************************************************/
20 #include <kprotocolmanager.h>
22 #include <kstandarddirs.h>
24 #include <kio/slaveconfig.h>
25 #include <kio/jobclasses.h>
26 #include <kio/scheduler.h>
27 #include <kio/netaccess.h>
30 #include <qapplication.h>
34 #include "kita_misc.h"
35 #include "qcp932codec.h"
36 #include "threadinfo.h"
40 QDict<Thread>* Thread::m_threadDict = 0;
45 Thread::Thread( const QString& datURL, const QString& threadName )
46 : m_datURL( datURL ), m_threadName( threadName )
52 const QString& Thread::datURL() const
57 const QString Thread::url() const
59 return datToThread( m_datURL );
62 const QString Thread::datID() const
64 return KURL( m_datURL ).filename().section( ".", 0, 0 );
67 int Thread::resNum() const
69 return KitaThreadInfo::resNum( m_datURL );
72 const QString& Thread::name() const
74 if ( ! Kita::Thread::getByURL( m_datURL ) ->m_threadName.isEmpty() ) {
75 return Kita::Thread::getByURL( m_datURL ) ->m_threadName;
80 void Thread::setResNum( int resNum )
82 KitaThreadInfo::setResNum( m_datURL, resNum );
85 const QString& Thread::boardName() const
87 return Kita::Board::getName( boardURL() );
90 const QString Thread::boardURL() const
92 return datToBoard( m_datURL );
95 const QString Thread::boardID() const
97 return KURL( datToBoard( m_datURL ) ).fileName();
100 Thread* Thread::getByURL( const QString& datURL )
102 if ( m_threadDict == 0 ) {
103 m_threadDict = new QDict<Thread>();
106 if ( m_threadDict->find( datURL ) ) {
107 return m_threadDict->find( datURL );
110 Thread* newThread = new Thread( datURL );
111 m_threadDict->insert( datURL, newThread );
116 void Thread::setName( const QString& datURL, const QString& threadName )
118 if ( datURL.isNull() ) {
122 if ( m_threadDict == 0 ) {
123 m_threadDict = new QDict<Thread>();
126 if ( m_threadDict->find( datURL ) ) {
127 Thread * thread = getByURL( datURL );
128 thread->m_threadName = threadName;
130 Thread* newThread = new Thread( datURL, threadName );
131 m_threadDict->insert( datURL, newThread );
137 void Thread::replace( const QString& fromURL, const QString& toURL )
139 QDictIterator<Kita::Thread> it( *m_threadDict );
140 for( ; it.current(); ++it ) {
141 QString url = it.currentKey();
142 Kita::Thread* thread = it.current();
143 if ( url.find( fromURL ) == 0 ) {
144 m_threadDict->remove( url );
145 url = url.replace( 0, fromURL.length(), toURL );
146 thread->m_datURL = url;
147 Kita::Board::replace( fromURL, toURL );
148 m_threadDict->insert( url, thread );
154 NullThread::NullThread()
157 NullThread::~NullThread()