00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 void TGo4LogInfo::init()
00018 {
00019 setAcceptDrops(FALSE);
00020 infoIcon = QPixmap::fromMimeSource("info.png");
00021 errorIcon = QPixmap::fromMimeSource("error.png");
00022 warnIcon = QPixmap::fromMimeSource("warn.png");
00023
00024 LogText->setSorting(0, FALSE);
00025 }
00026
00027 void TGo4LogInfo::WorkWithInfo(TGo4Slot* slot)
00028 {
00029 ResetWidget();
00030 AddLink(slot, "Loginfo");
00031 }
00032
00033 void TGo4LogInfo::linkedObjectUpdated( const char * linkname, TObject * obj )
00034 {
00035 if (obj==0) return;
00036
00037 QDateTime dt = QDateTime::currentDateTime();
00038 QString Name = obj->GetName();
00039 QString Date = dt.toString("dd.MM.yy ");
00040 QString Time = dt.toString("hh.mm.ss ");
00041
00042 QListViewItem *Item = new QListViewItem(LogText, Date, Time);
00043 if(Name.contains("GO4-*")) {
00044 Item->setText(3, "Info");
00045 Item->setPixmap(0, infoIcon);
00046 } else if (Name.contains("GO4-!")) {
00047 Item->setText(3, "Error");
00048 Item->setPixmap(0, errorIcon);
00049 } else if(Name.contains("GO4-#")) {
00050 Item->setText(3, "Warning");
00051 Item->setPixmap(0, warnIcon);
00052 }
00053 Name.remove(0, 6);
00054 Item->setText(2, Name);
00055 LogText->setSelected(Item, true);
00056 }
00057
00058
00059 void TGo4LogInfo::ClearLogInfo()
00060 {
00061 LogText->clear();
00062 }
00063
00064 void TGo4LogInfo::SaveLogInfo()
00065 {
00066 QString TextToSave;
00067 QFileDialog fd( this, "Save Log Information", TRUE );
00068 fd.setMode( QFileDialog::AnyFile );
00069 fd.setName( "Save Log Information ");
00070 fd.setCaption( "Save analysis log window");
00071 fd.setFilter( "Plain text (*.txt)" );
00072 if ( fd.exec() != QDialog::Accepted ) return;
00073
00074 QString fileName = fd.selectedFile();
00075 if(!fileName.endsWith(".txt")) fileName.append(".txt");
00076 QFile NewFile(fileName);
00077 NewFile.open( IO_ReadWrite | IO_Append );
00078 QTextStream t( &NewFile );
00079
00080 QListViewItemIterator it(LogText);
00081
00082 for ( ; it.current(); ++it ) {
00083 QListViewItem* itm = it.current();
00084 t << itm->text(0) << " " << itm->text(1) << " " << itm->text(2) << endl;
00085 }
00086 NewFile.close();
00087 }
00088
00089