kstars
stardatasink.cpp
Go to the documentation of this file.00001 /*************************************************************************** 00002 stardatasink.cpp - description 00003 ------------------- 00004 begin : Son Feb 10 2002 00005 copyright : (C) 2002 by Thomas Kabelmann 00006 email : tk78@gmx.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #include "stardatasink.h" 00019 00020 #include "dms.h" 00021 #include "kstarsdata.h" 00022 00023 StarDataSink::StarDataSink(KStarsData *parent, const char *name) : QObject(parent, name) { 00024 ksData = parent; 00025 receivedBlocks = 0; 00026 nameListCount = ksData->ObjNames.count(); 00027 } 00028 00029 StarDataSink::~StarDataSink(){ 00030 } 00031 00032 int StarDataSink::readyToReceive(){ 00033 // return a value != NULL, to show that the object is ready for receiveing data. 00034 return 1; 00035 } 00036 00037 void StarDataSink::eof() { 00038 // update skymap at the end of reloading 00039 emit updateSkymap(); 00040 // clear cached finddialog if new objects were appended to the list 00041 if (nameListCount != ksData->ObjNames.count()) emit clearCache(); 00042 // end of data transmission 00043 emit done(); 00044 } 00045 00046 void StarDataSink::receive( const uchar *data, int entries ) { 00047 receivedBlocks++; 00048 // Pointer was send as const uchar* so it must be converted explicitly to QString* 00049 QString *line = (QString *) data; 00050 int counter = -1; 00051 while (++counter < entries) { // run counter from 0 to entries -1 00052 ksData->processStar(line, true); 00053 line++; 00054 } 00055 00056 // update the skymap every tenth block 00057 if (receivedBlocks % 10 == 0) emit updateSkymap(); 00058 } 00059 00060 #include "stardatasink.moc"