19 #include <QFileDialog>
20 #include <QTextStream>
21 #include <QHeaderView>
28 setAcceptDrops(
false);
30 LogText->sortByColumn(1, Qt::DescendingOrder);
32 #if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
33 LogText->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
34 LogText->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
35 LogText->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
37 LogText->header()->setResizeMode(0, QHeaderView::ResizeToContents);
38 LogText->header()->setResizeMode(1, QHeaderView::ResizeToContents);
39 LogText->header()->setResizeMode(2, QHeaderView::ResizeToContents);
41 LogText->header()->setStretchLastSection(
true);
52 QString Date = dt.toString(
"dd.MM.yy ");
53 QString Time = dt.toString(
"hh.mm.ss ");
55 QTreeWidgetItem* Item =
new QTreeWidgetItem();
56 Item->setText(0, Date);
57 Item->setText(1, Time);
60 if(msg.contains(
"GO4-*")) level=1;
else
61 if(msg.contains(
"GO4-#")) level=2;
else
62 if(msg.contains(
"GO4-!")) level=3;
68 Item->setText(2,
"Warning");
69 Item->setIcon(0, QIcon(
":/icons/warn.png"));
72 Item->setText(2,
"Error");
73 Item->setIcon(0, QIcon(
":/icons/error.png"));
76 Item->setText(2,
"Info");
77 Item->setIcon(0, QIcon(
":/icons/info.png"));
81 Item->setText(3, msg);
83 LogText->addTopLevelItem(Item);
84 Item->setSelected(
true);
85 LogText->setCurrentItem(Item);
86 LogText->scrollToItem(Item);
91 TList* lst =
dynamic_cast<TList*
>(obj);
93 TListIter iter(lst, kFALSE);
95 while ((obj = iter()) != 0) {
97 if (obj==lst->First())
continue;
99 const char*
msg = obj->GetName();
101 const char* separ = strchr(msg,
':');
102 if ((separ==0) || (strlen(separ)<3))
continue;
104 Long64_t tm = TString(msg, separ-msg).Atoll();
107 dt.setTime_t((time_t) tm);
111 if (*separ==
'2') level=2;
else
112 if (*separ==
'3') level=3;
118 AddMessage(QDateTime::currentDateTime(), 0, obj->GetName());
131 QFileDialog fd(
this,
"Save analysis log window", QString(),
132 "Plain text (*.txt)");
133 fd.setFileMode( QFileDialog::AnyFile );
134 fd.setAcceptMode(QFileDialog::AcceptSave);
136 if ( fd.exec() != QDialog::Accepted )
return;
138 QStringList flst = fd.selectedFiles();
139 if (flst.isEmpty())
return;
141 QString fileName = flst[0];
142 if(!fileName.endsWith(
".txt")) fileName.append(
".txt");
143 QFile NewFile(fileName);
144 NewFile.open( QIODevice::ReadWrite | QIODevice::Append );
145 QTextStream t( &NewFile );
147 QTreeWidgetItemIterator it(LogText);
149 QTreeWidgetItem* itm = *it++;
150 t << itm->text(0) <<
" " << itm->text(1) <<
" " << itm->text(3) <<
"\n";
virtual void ClearLogInfo()
void linkedObjectUpdated(const char *linkname, TObject *obj)
void AddMessage(const QDateTime &dt, int level, QString msg)
virtual void SaveLogInfo()
void WorkWithInfo(TGo4Slot *slot)
TGo4LogInfo(QWidget *parent=0, const char *name=0)