/* traceview.cc */ #include "traceview.h" #include "trace.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "traceview.h" /* ----------------------------------------------------------------------- */ namespace MyModule { using namespace KDevelop; static TraceViewWidget * g_trace = NULL; static QTreeWidgetItem * g_current = NULL; /* ----------------------------------------------------------------------- */ TraceViewWidget::TraceViewWidget(QWidget* parent) : QWidget (parent), m_tree (NULL), m_info_icon (), m_error_icon () { setObjectName ("TraceView Tree"); setWindowTitle (i18n ("TraceView")); setWindowIcon (SmallIcon ("enum")); m_tree = new QTreeWidget (this); m_tree->header()->setResizeMode (0, QHeaderView::ResizeToContents); // m_tree->header()->setStretchLastSection(false); QVBoxLayout* vbox = new QVBoxLayout (this); vbox->setMargin (0); vbox->addWidget(m_tree); setLayout (vbox); setWhatsThis (i18n ("TraceView")); m_info_icon = SmallIcon ("info"); m_error_icon = SmallIcon ("emblem-important"); m_action = new KAction (this); m_action->setText (i18n ("Action Click")); connect (m_action, SIGNAL (triggered (bool)), this, SLOT (click ())); g_trace = this; g_current = NULL; } TraceViewWidget::~TraceViewWidget() { g_trace = NULL; g_current = NULL; } /* ----------------------------------------------------------------------- */ QTreeWidgetItem * TraceViewWidget::show (QTreeWidgetItem * branch, QString text, bool alert) { QTreeWidgetItem * item; if (branch == NULL) { item = new QTreeWidgetItem (); m_tree->addTopLevelItem (item); } else { item = new QTreeWidgetItem (branch); } item->setText (0, text); if (alert) item->setIcon (0, m_error_icon); else item->setIcon (0, m_info_icon); return item; } /* ----------------------------------------------------------------------- */ void trace_start (QString text) { g_current = NULL; trace_open (text); } void trace_open (QString text) { if (g_trace != NULL) g_current = g_trace->show (g_current, text); } void trace_close () { if (g_current != NULL) g_current = g_current->parent (); } void trace (QString text) { if (g_trace != NULL) g_trace->show (g_current, text); } void trace_alert (QString text) { if (g_trace != NULL) g_trace->show (NULL, text, true); } /* ----------------------------------------------------------------------- */ } // end of namespace #include "traceview.moc"