[Uml-devel] branches/work/soc-umbrello/umbrello/debug
Andi Fischer
andi.fischer at hispeed.ch
Sat Feb 12 21:43:20 UTC 2011
SVN commit 1220089 by fischer:
Some improvements added.
M +27 -26 debug_utils.cpp
M +25 -34 debug_utils.h
--- branches/work/soc-umbrello/umbrello/debug/debug_utils.cpp #1220088:1220089
@@ -1,22 +1,23 @@
-/***************************************************************************
- * Copyright (C) 2011 by Andi Fischer <andi.fischer at hispeed.ch> *
- * *
- * This is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2, or (at your option) *
- * any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this package; see the file COPYING. If not, write to *
- * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, *
- * Boston, MA 02110-1301, USA. *
- ***************************************************************************/
+/*
+ Copyright 2011 Andi Fischer <andi.fischer at hispeed.ch>
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License or (at your option) version 3 or any later version
+ accepted by the membership of KDE e.V. (or its successor approved
+ by the membership of KDE e.V.), which shall act as a proxy
+ defined in Section 14 of version 3 of the license.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#include "debug_utils.h"
#include <klocale.h>
@@ -40,7 +41,6 @@
{
setRootIsDecorated(true);
setAlternatingRowColors(true);
-// setSelectionMode(QAbstractItemView::SingleSelection);
setHeaderLabel(i18n("Class Name"));
setContextMenuPolicy(Qt::CustomContextMenu);
resize(300, 400);
@@ -57,16 +57,17 @@
/**
* ... .
*/
-void Tracer::registerClass(const char* name, const QString& folder)
+void Tracer::registerClass(const QString& name, const QString& folder)
{
- QString itemName = QString(name);
- uDebug() << itemName << " / folder = " << folder;
- QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(itemName));
+ uDebug() << name << " / folder = " << folder;
+ QList<QTreeWidgetItem*> items = findItems(name, Qt::MatchFixedString);
+ if (items.empty()) {
+ QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(name));
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
item->setCheckState(0, Qt::Checked);
-// m_treeMap[item] = itemName;
addTopLevelItem(item);
}
+}
/**
* ...
@@ -98,9 +99,9 @@
//:TODO:
}
-bool Tracer::isEnabled(const char * name)
+bool Tracer::isEnabled(const QString& name)
{
- QList<QTreeWidgetItem*> items = findItems(QString(name), Qt::MatchFixedString);
+ QList<QTreeWidgetItem*> items = findItems(name, Qt::MatchFixedString);
if (items.size() > 0) {
Qt::CheckState state = items.at(0)->checkState(0);
switch(state) {
--- branches/work/soc-umbrello/umbrello/debug/debug_utils.h #1220088:1220089
@@ -1,22 +1,23 @@
-/***************************************************************************
- * Copyright (C) 2011 by Andi Fischer <andi.fischer at hispeed.ch> *
- * *
- * This is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2, or (at your option) *
- * any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this package; see the file COPYING. If not, write to *
- * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, *
- * Boston, MA 02110-1301, USA. *
- ***************************************************************************/
+/*
+ Copyright 2011 Andi Fischer <andi.fischer at hispeed.ch>
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License or (at your option) version 3 or any later version
+ accepted by the membership of KDE e.V. (or its successor approved
+ by the membership of KDE e.V.), which shall act as a proxy
+ defined in Section 14 of version 3 of the license.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#ifndef DEBUG_UTILS_H
#define DEBUG_UTILS_H
@@ -35,7 +36,7 @@
~Tracer();
- void registerClass(const char* name, const QString& folder = QString());
+ void registerClass(const QString& name, const QString& folder = QString());
void enable(const QString& name);
void disable(const QString& name);
@@ -43,7 +44,7 @@
void enableAll();
void disableAll();
- bool isEnabled(const char * name);
+ bool isEnabled(const QString& name);
private:
static Tracer* m_instance;
@@ -60,20 +61,10 @@
#define uError() kError(8060)
#define uWarning() kWarning(8060)
-#define DBG_SRC metaObject()->className()
-#define uofDebug(DBG_SRC) Tracer::instance()->isEnabled(DBG_SRC)?kDebug(8060):kDebugDevNull()
-/*
-// uof == umbrello object filter
-static inline QDebug uofDebug(const char* name)
-{
- if (Tracer::instance()->isEnabled(name))
- return kDebugStream(QtDebugMsg, 8060);
-}
-*/
-//static inline QDebug uDebug()
-//{
-// return kDebugStream(QtDebugMsg, 8060);
-//}
+#define DBG_SRC QString(metaObject()->className())
+#define DEBUG_REGISTER(src) Tracer::instance()->registerClass(src);
+#define DEBUG_SHOW_FILTER() Tracer::instance()->show()
+#define DEBUG(src) if (Tracer::instance()->isEnabled(src)) uDebug()
#define uIgnoreZeroPointer(a) if (!a) { uDebug() << "zero pointer detected" << __FILE__ << __LINE__; continue; }
More information about the umbrello-devel
mailing list