Author: schubi2
Date: Fri Jun 29 17:13:18 2007
New Revision: 5857
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5857&view=rev
Log:
Prototype of a dependency viewer with QT
Added:
branches/tmp/schubi/solvertree/
branches/tmp/schubi/solvertree/Makefile
branches/tmp/schubi/solvertree/dialog.cpp
branches/tmp/schubi/solvertree/dialog.h
branches/tmp/schubi/solvertree/drawparams.cpp
branches/tmp/schubi/solvertree/drawparams.h
branches/tmp/schubi/solvertree/graphtree_defines.h
branches/tmp/schubi/solvertree/graphtreelabel.cpp
branches/tmp/schubi/solvertree/graphtreelabel.h
branches/tmp/schubi/solvertree/main.cpp
branches/tmp/schubi/solvertree/pannerview.cpp
branches/tmp/schubi/solvertree/pannerview.h
branches/tmp/schubi/solvertree/resgraphview.cpp
branches/tmp/schubi/solvertree/resgraphview.h
branches/tmp/schubi/solvertree/restreewidget.cpp
branches/tmp/schubi/solvertree/restreewidget.h
branches/tmp/schubi/solvertree/solver.dot
branches/tmp/schubi/solvertree/solvertree.cpp
branches/tmp/schubi/solvertree/solvertree.h
Added: branches/tmp/schubi/solvertree/Makefile
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/Makefile?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/Makefile (added)
+++ branches/tmp/schubi/solvertree/Makefile Fri Jun 29 17:13:18 2007
@@ -0,0 +1,214 @@
+#############################################################################
+# Makefile for building: solvertree
+# Generated by qmake (2.01a) (Qt 4.2.1) on: Do Jun 28 18:10:44 2007
+# Project: solvertree.pro
+# Template: app
+# Command: /usr/bin/qmake -unix -o Makefile solvertree.pro
+#############################################################################
+
+####### Compiler, tools and options
+
+CC = gcc
+CXX = g++
+LEX = flex
+YACC = yacc
+DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
+CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+LEXFLAGS =
+YACCFLAGS = -d
+INCPATH = -I/usr/include -I/opt/kde3/include -I/usr/lib/qt3/include -I. -I. -I.
+LINK = g++
+LFLAGS =
+LIBS = $(SUBLIBS) -L/usr/lib -L /usr/lib/qt3/lib -L/opt/kde3/lib -L/usr/X11R6/lib -lpng -lSM -lICE -lXi -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lz -lm -ldl -lpthread -lqt-mt -lkdecore -lkio -lkparts -lkdeui -lkwalletclient
+AR = ar cqs
+RANLIB =
+QMAKE = /usr/bin/qmake
+TAR = tar -cf
+COMPRESS = gzip -9f
+COPY = cp -f
+COPY_FILE = $(COPY)
+COPY_DIR = $(COPY) -r
+INSTALL_FILE = install -m 644 -p
+INSTALL_DIR = $(COPY_DIR)
+INSTALL_PROGRAM = install -m 755 -p
+DEL_FILE = rm -f
+SYMLINK = ln -sf
+DEL_DIR = rmdir
+MOVE = mv -f
+CHK_DIR_EXISTS= test -d
+MKDIR = mkdir -p
+
+####### Output directory
+
+OBJECTS_DIR = ./
+
+####### Files
+
+SOURCES = dialog.cpp \
+ drawparams.cpp \
+ graphtreelabel.cpp \
+ main.cpp \
+ pannerview.cpp \
+ resgraphview.cpp \
+ restreewidget.cpp \
+ solvertree.cpp
+OBJECTS = dialog.o \
+ drawparams.o \
+ graphtreelabel.o \
+ main.o \
+ pannerview.o \
+ resgraphview.o \
+ restreewidget.o \
+ solvertree.o
+DIST = /usr/share/qt4/mkspecs/common/unix.conf \
+ /usr/share/qt4/mkspecs/common/g++.conf \
+ /usr/share/qt4/mkspecs/common/linux.conf \
+ /usr/share/qt4/mkspecs/qconfig.pri \
+ /usr/share/qt4/mkspecs/features/qt_functions.prf \
+ /usr/share/qt4/mkspecs/features/qt_config.prf \
+ /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
+ /usr/share/qt4/mkspecs/features/default_pre.prf \
+ /usr/share/qt4/mkspecs/features/release.prf \
+ /usr/share/qt4/mkspecs/features/default_post.prf \
+ /usr/share/qt4/mkspecs/features/warn_on.prf \
+ /usr/share/qt4/mkspecs/features/qt.prf \
+ /usr/share/qt4/mkspecs/features/unix/thread.prf \
+ /usr/share/qt4/mkspecs/features/moc.prf \
+ /usr/share/qt4/mkspecs/features/resources.prf \
+ /usr/share/qt4/mkspecs/features/uic.prf \
+ solvertree.pro
+QMAKE_TARGET = solvertree
+DESTDIR =
+TARGET = solvertree
+
+first: all
+####### Implicit rules
+
+.SUFFIXES: .o .c .cpp .cc .cxx .C
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.C.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
+
+####### Build rules
+
+all: Makefile $(TARGET)
+
+$(TARGET): $(OBJECTS)
+ $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
+
+dist:
+ @$(CHK_DIR_EXISTS) .tmp/solvertree1.0.0 || $(MKDIR) .tmp/solvertree1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/solvertree1.0.0/ && $(COPY_FILE) --parents dialog.h drawparams.h graphtree_defines.h graphtreelabel.h pannerview.h resgraphview.h restreewidget.h solvertree.h .tmp/solvertree1.0.0/ && $(COPY_FILE) --parents dialog.cpp drawparams.cpp graphtreelabel.cpp main.cpp pannerview.cpp resgraphview.cpp restreewidget.cpp solvertree.cpp .tmp/solvertree1.0.0/ && (cd `dirname .tmp/solvertree1.0.0` && $(TAR) solvertree1.0.0.tar solvertree1.0.0 && $(COMPRESS) solvertree1.0.0.tar) && $(MOVE) `dirname .tmp/solvertree1.0.0`/solvertree1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/solvertree1.0.0
+
+
+yaccclean:
+lexclean:
+clean:compiler_clean
+ -$(DEL_FILE) $(OBJECTS)
+ -$(DEL_FILE) *~ core *.core
+
+
+####### Sub-libraries
+
+distclean: clean
+ -$(DEL_FILE) $(TARGET)
+ -$(DEL_FILE) Makefile
+
+
+/usr/bin/moc:
+ (cd $(QTDIR)/src/tools/moc && $(MAKE))
+
+mocclean: compiler_moc_header_clean compiler_moc_source_clean
+
+mocables: compiler_moc_header_make_all compiler_moc_source_make_all
+
+compiler_moc_header_make_all: moc_dialog.cpp moc_pannerview.cpp moc_resgraphview.cpp moc_restreewidget.cpp
+compiler_moc_header_clean:
+ -$(DEL_FILE) moc_dialog.cpp moc_pannerview.cpp moc_resgraphview.cpp moc_restreewidget.cpp
+dialog.moc: dialog.h \
+ /usr/bin/moc
+ /usr/lib/qt3/bin/moc dialog.h -o dialog.moc
+
+pannerview.moc: pannerview.h \
+ /usr/bin/moc
+ /usr/lib/qt3/bin/moc pannerview.h -o pannerview.moc
+
+resgraphview.moc: resgraphview.h \
+ /usr/bin/moc
+ /usr/lib/qt3/bin/moc resgraphview.h -o resgraphview.moc
+
+restreewidget.moc: restreewidget.h \
+ /usr/bin/moc
+ /usr/lib/qt3/bin/moc restreewidget.h -o restreewidget.moc
+
+compiler_rcc_make_all:
+compiler_rcc_clean:
+compiler_image_collection_make_all: qmake_image_collection.cpp
+compiler_image_collection_clean:
+ -$(DEL_FILE) qmake_image_collection.cpp
+compiler_moc_source_make_all:
+compiler_moc_source_clean:
+compiler_uic_make_all:
+compiler_uic_clean:
+compiler_clean: compiler_moc_header_clean compiler_rcc_clean compiler_image_collection_clean compiler_moc_source_clean compiler_uic_clean
+
+####### Compile
+
+dialog.o: dialog.cpp dialog.h \
+ dialog.moc
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o dialog.o dialog.cpp
+
+drawparams.o: drawparams.cpp drawparams.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o drawparams.o drawparams.cpp
+
+graphtreelabel.o: graphtreelabel.cpp graphtreelabel.h \
+ drawparams.h \
+ graphtree_defines.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o graphtreelabel.o graphtreelabel.cpp
+
+main.o: main.cpp dialog.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
+
+pannerview.o: pannerview.cpp pannerview.h \
+ pannerview.moc
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o pannerview.o pannerview.cpp
+
+resgraphview.o: resgraphview.cpp resgraphview.h \
+ graphtreelabel.h \
+ drawparams.h \
+ pannerview.h \
+ graphtree_defines.h \
+ resgraphview.moc
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o resgraphview.o resgraphview.cpp
+
+restreewidget.o: restreewidget.cpp restreewidget.h \
+ resgraphview.h \
+ restreewidget.moc
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o restreewidget.o restreewidget.cpp
+
+solvertree.o: solvertree.cpp solvertree.h \
+ restreewidget.h \
+ resgraphview.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o solvertree.o solvertree.cpp
+
+####### Install
+
+install: FORCE
+
+uninstall: FORCE
+
+FORCE:
+
Added: branches/tmp/schubi/solvertree/dialog.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/dialog.cpp?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/dialog.cpp (added)
+++ branches/tmp/schubi/solvertree/dialog.cpp Fri Jun 29 17:13:18 2007
@@ -0,0 +1,20 @@
+#include
+#include
+#include
+#include
+#include
+
+#include "dialog.h"
+#include "solvertree.h"
+
+
+Dialog::Dialog()
+ : QDialog(0,"Test dialog",true)
+{
+ SolverTree *solvertree = new SolverTree(this);
+}
+Dialog::~Dialog()
+{
+}
+
+#include "dialog.moc"
Added: branches/tmp/schubi/solvertree/dialog.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/dialog.h?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/dialog.h (added)
+++ branches/tmp/schubi/solvertree/dialog.h Fri Jun 29 17:13:18 2007
@@ -0,0 +1,20 @@
+#ifndef DIALOG_H
+ #define DIALOG_H
+
+ #include
+
+ class QLabel;
+ class QErrorMessage;
+
+ class Dialog : public QDialog
+ {
+ Q_OBJECT
+
+ public:
+ Dialog();
+ ~Dialog();
+
+
+ };
+
+ #endif
Added: branches/tmp/schubi/solvertree/drawparams.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/drawparams.cpp?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/drawparams.cpp (added)
+++ branches/tmp/schubi/solvertree/drawparams.cpp Fri Jun 29 17:13:18 2007
@@ -0,0 +1,708 @@
+/* This file is part of KCachegrind.
+ Copyright (C) 2002, 2003 Josef Weidendorfer
+ Adapted for the needs of kdesvn by Rajko Albrecht
+
+ KCachegrind 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, version 2.
+
+ 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; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+ * A Widget for visualizing hierarchical metrics as areas.
+ * The API is similar to QListView.
+ */
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include "drawparams.h"
+
+
+// set this to 1 to enable debug output
+#define DEBUG_DRAWING 0
+#define MAX_FIELD 12
+
+
+//
+// StoredDrawParams
+//
+StoredDrawParams::StoredDrawParams()
+{
+ _selected = false;
+ _current = false;
+ _shaded = true;
+ _rotated = false;
+
+ _backColor = Qt::white;
+
+ // field array has size 0
+}
+
+StoredDrawParams::StoredDrawParams(QColor c,
+ bool selected, bool current)
+{
+ _backColor = c;
+
+ _selected = selected;
+ _current = current;
+ _shaded = true;
+ _rotated = false;
+ _drawFrame = true;
+
+ // field array has size 0
+}
+
+QString StoredDrawParams::text(int f) const
+{
+ if ((f<0) || (f >= (int)_field.size()))
+ return QString::null;
+
+ return _field[f].text;
+}
+
+QPixmap StoredDrawParams::pixmap(int f) const
+{
+ if ((f<0) || (f >= (int)_field.size()))
+ return QPixmap();
+
+ return _field[f].pix;
+}
+
+DrawParams::Position StoredDrawParams::position(int f) const
+{
+ if ((f<0) || (f >= (int)_field.size()))
+ return Default;
+
+ return _field[f].pos;
+}
+
+int StoredDrawParams::maxLines(int f) const
+{
+ if ((f<0) || (f >= (int)_field.size()))
+ return 0;
+
+ return _field[f].maxLines;
+}
+
+const QFont& StoredDrawParams::font() const
+{
+ static QFont* f = 0;
+ if (!f) f = new QFont(QApplication::font());
+
+ return *f;
+}
+
+void StoredDrawParams::ensureField(int f)
+{
+ static Field* def = 0;
+ if (!def) {
+ def = new Field();
+ def->pos = Default;
+ def->maxLines = 0;
+ }
+
+ if (f<0 || f>=MAX_FIELD) return;
+
+ if ((int)_field.size() < f+1) _field.resize(f+1, *def);
+}
+
+
+void StoredDrawParams::setField(int f, QString t, QPixmap pm,
+ Position p, int maxLines)
+{
+ if (f<0 || f>=MAX_FIELD) return;
+ ensureField(f);
+
+ _field[f].text = t;
+ _field[f].pix = pm;
+ _field[f].pos = p;
+ _field[f].maxLines = maxLines;
+}
+
+void StoredDrawParams::setText(int f, QString t)
+{
+ if (f<0 || f>=MAX_FIELD) return;
+ ensureField(f);
+
+ _field[f].text = t;
+}
+
+void StoredDrawParams::setPixmap(int f, QPixmap pm)
+{
+ if (f<0 || f>=MAX_FIELD) return;
+ ensureField(f);
+
+ _field[f].pix = pm;
+}
+
+void StoredDrawParams::setPosition(int f, Position p)
+{
+ if (f<0 || f>=MAX_FIELD) return;
+ ensureField(f);
+
+ _field[f].pos = p;
+}
+
+void StoredDrawParams::setMaxLines(int f, int m)
+{
+ if (f<0 || f>=MAX_FIELD) return;
+ ensureField(f);
+
+ _field[f].maxLines = m;
+}
+
+
+
+//
+// RectDrawing
+//
+
+RectDrawing::RectDrawing(QRect r)
+{
+ _fm = 0;
+ _dp = 0;
+ setRect(r);
+}
+
+
+RectDrawing::~RectDrawing()
+{
+ delete _fm;
+ delete _dp;
+}
+
+DrawParams* RectDrawing::drawParams()
+{
+ if (!_dp)
+ _dp = new StoredDrawParams();
+
+ return _dp;
+}
+
+
+void RectDrawing::setDrawParams(DrawParams* dp)
+{
+ if (_dp) delete _dp;
+ _dp = dp;
+}
+
+void RectDrawing::setRect(QRect r)
+{
+ _rect = r;
+
+ _usedTopLeft = 0;
+ _usedTopCenter = 0;
+ _usedTopRight = 0;
+ _usedBottomLeft = 0;
+ _usedBottomCenter = 0;
+ _usedBottomRight = 0;
+
+ _fontHeight = 0;
+}
+
+QRect RectDrawing::remainingRect(DrawParams* dp)
+{
+ if (!dp) dp = drawParams();
+
+ if ((_usedTopLeft >0) ||
+ (_usedTopCenter >0) ||
+ (_usedTopRight >0)) {
+ if (dp->rotated())
+ _rect.setLeft(_rect.left() + _fontHeight);
+ else
+ _rect.setTop(_rect.top() + _fontHeight);
+ }
+
+ if ((_usedBottomLeft >0) ||
+ (_usedBottomCenter >0) ||
+ (_usedBottomRight >0)) {
+ if (dp->rotated())
+ _rect.setRight(_rect.right() - _fontHeight);
+ else
+ _rect.setBottom(_rect.bottom() - _fontHeight);
+ }
+ return _rect;
+}
+
+
+void RectDrawing::drawBack(QPainter* p, DrawParams* dp)
+{
+ if (!dp) dp = drawParams();
+ if (_rect.width()<=0 || _rect.height()<=0) return;
+
+ QRect r = _rect;
+ QColor normal = dp->backColor();
+ if (dp->selected()) normal = normal.light();
+ bool isCurrent = dp->current();
+
+ if (dp->drawFrame() || isCurrent) {
+ // 3D raised/sunken frame effect...
+ QColor high = normal.light();
+ QColor low = normal.dark();
+ p->setPen( isCurrent ? low:high);
+ p->drawLine(r.left(), r.top(), r.right(), r.top());
+ p->drawLine(r.left(), r.top(), r.left(), r.bottom());
+ p->setPen( isCurrent ? high:low);
+ p->drawLine(r.right(), r.top(), r.right(), r.bottom());
+ p->drawLine(r.left(), r.bottom(), r.right(), r.bottom());
+ r.setRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
+ }
+ if (r.width()<=0 || r.height()<=0) return;
+
+ if (dp->shaded()) {
+ // some shading
+ bool goDark = qGray(normal.rgb())>128;
+ int rBase, gBase, bBase;
+ normal.rgb(&rBase, &gBase, &bBase);
+ p->setBrush(QBrush::NoBrush);
+
+ // shade parameters:
+ int d = 7;
+ float factor = 0.1, forth=0.7, back1 =0.9, toBack2 = .7, back2 = 0.97;
+
+ // coefficient corrections because of rectangle size
+ int s = r.width();
+ if (s > r.height()) s = r.height();
+ if (s<100) {
+ forth -= .3 * (100-s)/100;
+ back1 -= .2 * (100-s)/100;
+ back2 -= .02 * (100-s)/100;
+ }
+
+
+ // maximal color difference
+ int rDiff = goDark ? -rBase/d : (255-rBase)/d;
+ int gDiff = goDark ? -gBase/d : (255-gBase)/d;
+ int bDiff = goDark ? -bBase/d : (255-bBase)/d;
+
+ QColor shadeColor;
+ while (factor<.95) {
+ shadeColor.setRgb((int)(rBase+factor*rDiff+.5),
+ (int)(gBase+factor*gDiff+.5),
+ (int)(bBase+factor*bDiff+.5));
+ p->setPen(shadeColor);
+ p->drawRect(r);
+ r.setRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
+ if (r.width()<=0 || r.height()<=0) return;
+ factor = 1.0 - ((1.0 - factor) * forth);
+ }
+
+ // and back (1st half)
+ while (factor>toBack2) {
+ shadeColor.setRgb((int)(rBase+factor*rDiff+.5),
+ (int)(gBase+factor*gDiff+.5),
+ (int)(bBase+factor*bDiff+.5));
+ p->setPen(shadeColor);
+ p->drawRect(r);
+ r.setRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
+ if (r.width()<=0 || r.height()<=0) return;
+ factor = 1.0 - ((1.0 - factor) / back1);
+ }
+
+ // and back (2nd half)
+ while ( factor>.01) {
+ shadeColor.setRgb((int)(rBase+factor*rDiff+.5),
+ (int)(gBase+factor*gDiff+.5),
+ (int)(bBase+factor*bDiff+.5));
+ p->setPen(shadeColor);
+ p->drawRect(r);
+ r.setRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
+ if (r.width()<=0 || r.height()<=0) return;
+
+ factor = factor * back2;
+ }
+ }
+
+ // fill inside
+ p->setPen(QPen::NoPen);
+ p->setBrush(normal);
+ p->drawRect(r);
+}
+
+
+bool RectDrawing::drawField(QPainter* p, int f, DrawParams* dp)
+{
+ if (!dp) dp = drawParams();
+
+ if (!_fm) {
+ _fm = new QFontMetrics(dp->font());
+ _fontHeight = _fm->height();
+ }
+
+ QRect r = _rect;
+
+ if (0) kdDebug(90100) << "DrawField: Rect " << r.x() << "/" << r.y()
+ << " - " << r.width() << "x" << r.height() << endl;
+
+ int h = _fontHeight;
+ bool rotate = dp->rotated();
+ int width = (rotate ? r.height() : r.width()) -4;
+ int height = (rotate ? r.width() : r.height());
+ int lines = height / h;
+
+ // stop if we have no space available
+ if (lines<1) return false;
+
+ // calculate free space in first line (<unused>)
+ int pos = dp->position(f);
+ if (pos == DrawParams::Default) {
+ switch(f%4) {
+ case 0: pos = DrawParams::TopLeft; break;
+ case 1: pos = DrawParams::TopRight; break;
+ case 2: pos = DrawParams::BottomRight; break;
+ case 3: pos = DrawParams::BottomLeft; break;
+ }
+ }
+
+ int unused = 0;
+ bool isBottom = false;
+ bool isCenter = false;
+ bool isRight = false;
+ int* used = 0;
+ switch(pos) {
+ case DrawParams::TopLeft:
+ used = &_usedTopLeft;
+ if (_usedTopLeft == 0) {
+ if (_usedTopCenter)
+ unused = (width - _usedTopCenter)/2;
+ else
+ unused = width - _usedTopRight;
+ }
+ break;
+
+ case DrawParams::TopCenter:
+ isCenter = true;
+ used = &_usedTopCenter;
+ if (_usedTopCenter == 0) {
+ if (_usedTopLeft > _usedTopRight)
+ unused = width - 2 * _usedTopLeft;
+ else
+ unused = width - 2 * _usedTopRight;
+ }
+ break;
+
+ case DrawParams::TopRight:
+ isRight = true;
+ used = &_usedTopRight;
+ if (_usedTopRight == 0) {
+ if (_usedTopCenter)
+ unused = (width - _usedTopCenter)/2;
+ else
+ unused = width - _usedTopLeft;
+ }
+ break;
+
+ case DrawParams::BottomLeft:
+ isBottom = true;
+ used = &_usedBottomLeft;
+ if (_usedBottomLeft == 0) {
+ if (_usedBottomCenter)
+ unused = (width - _usedBottomCenter)/2;
+ else
+ unused = width - _usedBottomRight;
+ }
+ break;
+
+ case DrawParams::BottomCenter:
+ isCenter = true;
+ isBottom = true;
+ used = &_usedBottomCenter;
+ if (_usedBottomCenter == 0) {
+ if (_usedBottomLeft > _usedBottomRight)
+ unused = width - 2 * _usedBottomLeft;
+ else
+ unused = width - 2 * _usedBottomRight;
+ }
+ break;
+
+ case DrawParams::BottomRight:
+ isRight = true;
+ isBottom = true;
+ used = &_usedBottomRight;
+ if (_usedBottomRight == 0) {
+ if (_usedBottomCenter)
+ unused = (width - _usedBottomCenter)/2;
+ else
+ unused = width - _usedBottomLeft;
+ }
+ break;
+ }
+
+ if (isBottom) {
+ if ((_usedTopLeft >0) ||
+ (_usedTopCenter >0) ||
+ (_usedTopRight >0))
+ lines--;
+ }
+ else if (!isBottom) {
+ if ((_usedBottomLeft >0) ||
+ (_usedBottomCenter >0) ||
+ (_usedBottomRight >0))
+ lines--;
+ }
+ if (lines<1) return false;
+
+
+ int y = isBottom ? height - h : 0;
+
+ if (unused < 0) unused = 0;
+ if (unused == 0) {
+ // no space available in last line at this position
+ y = isBottom ? (y-h) : (y+h);
+ lines--;
+
+ if (lines<1) return false;
+
+ // new line: reset used space
+ if (isBottom)
+ _usedBottomLeft = _usedBottomCenter = _usedBottomRight = 0;
+ else
+ _usedTopLeft = _usedTopCenter = _usedTopRight = 0;
+
+ unused = width;
+ }
+
+ // stop as soon as possible when there's no space for "..."
+ static int dotW = 0;
+ if (!dotW) dotW = _fm->width("...");
+ if (width < dotW) return false;
+
+ // get text and pixmap now, only if we need to, because it is possible
+ // that they are calculated on demand (and this can take some time)
+ QString name = dp->text(f);
+ if (name.isEmpty()) return 0;
+ QPixmap pix = dp->pixmap(f);
+
+ // check if pixmap can be drawn
+ int pixW = pix.width();
+ int pixH = pix.height();
+ int pixY = 0;
+ bool pixDrawn = true;
+ if (pixW>0) {
+ pixW += 2; // X distance from pix
+ if ((width < pixW + dotW) || (height < pixH)) {
+ // don't draw
+ pixW = 0;
+ }
+ else
+ pixDrawn = false;
+ }
+
+ // width of text and pixmap to be drawn
+ int w = pixW + _fm->width(name);
+
+ if (0) kdDebug(90100) << " For '" << name << "': Unused " << unused
+ << ", StrW " << w << ", Width " << width << endl;
+
+ // if we have limited space at 1st line:
+ // use it only if whole name does fit in last line...
+ if ((unused < width) && (w > unused)) {
+ y = isBottom ? (y-h) : (y+h);
+ lines--;
+
+ if (lines<1) return false;
+
+ // new line: reset used space
+ if (isBottom)
+ _usedBottomLeft = _usedBottomCenter = _usedBottomRight = 0;
+ else
+ _usedTopLeft = _usedTopCenter = _usedTopRight = 0;
+ }
+
+ p->save();
+ p->setPen( (qGray(dp->backColor().rgb())>100) ? Qt::black : Qt::white);
+ p->setFont(dp->font());
+ if (rotate) {
+ //p->translate(r.x()+2, r.y()+r.height());
+ p->translate(r.x(), r.y()+r.height()-2);
+ p->rotate(270);
+ }
+ else
+ p->translate(r.x()+2, r.y());
+
+
+ // adjust available lines according to maxLines
+ int max = dp->maxLines(f);
+ if ((max > 0) && (lines>max)) lines = max;
+
+ /* loop over name parts to break up string depending on available width.
+ * every char category change is supposed a possible break,
+ * with the exception Uppercase=>Lowercase.
+ * It's good enough for numbers, Symbols...
+ *
+ * If the text is to be written at the bottom, we start with the
+ * end of the string (so everything is reverted)
+ */
+ QString remaining;
+ int origLines = lines;
+ while (lines>0) {
+
+ if (w>width && lines>1) {
+ int lastBreakPos = name.length(), lastWidth = w;
+ int len = name.length();
+ QChar::Category caOld, ca;
+
+ if (!isBottom) {
+ // start with comparing categories of last 2 chars
+ caOld = name[len-1].category();
+ while (len>2) {
+ len--;
+ ca = name[len-1].category();
+ if (ca != caOld) {
+ // "Aa" has no break between...
+ if (ca == QChar::Letter_Uppercase &&
+ caOld == QChar::Letter_Lowercase) {
+ caOld = ca;
+ continue;
+ }
+ caOld = ca;
+ lastBreakPos = len;
+ w = pixW + _fm->width(name, len);
+ lastWidth = w;
+ if (w <= width) break;
+ }
+ }
+ w = lastWidth;
+ remaining = name.mid(lastBreakPos);
+ // remove space on break point
+ if (name[lastBreakPos-1].category() == QChar::Separator_Space)
+ name = name.left(lastBreakPos-1);
+ else
+ name = name.left(lastBreakPos);
+ }
+ else { // bottom
+ int l = len;
+ caOld = name[l-len].category();
+ while (len>2) {
+ len--;
+ ca = name[l-len].category();
+
+ if (ca != caOld) {
+ // "Aa" has no break between...
+ if (caOld == QChar::Letter_Uppercase &&
+ ca == QChar::Letter_Lowercase) {
+ caOld = ca;
+ continue;
+ }
+ caOld = ca;
+ lastBreakPos = len;
+ w = pixW + _fm->width(name.right(len));
+ lastWidth = w;
+ if (w <= width) break;
+ }
+ }
+ w = lastWidth;
+ remaining = name.left(l-lastBreakPos);
+ // remove space on break point
+ if (name[l-lastBreakPos].category() == QChar::Separator_Space)
+ name = name.right(lastBreakPos-1);
+ else
+ name = name.right(lastBreakPos);
+ }
+ }
+ else
+ remaining = QString::null;
+
+ /* truncate and add ... if needed */
+ if (w>width) {
+ int len = name.length();
+ w += dotW;
+ while (len>2 && (w > width)) {
+ len--;
+ w = pixW + _fm->width(name, len) + dotW;
+ }
+ // stop drawing: we cannot draw 2 chars + "..."
+ if (w>width) break;
+
+ name = name.left(len) + "...";
+ }
+
+ int x = 0;
+ if (isCenter)
+ x = (width - w)/2;
+ else if (isRight)
+ x = width - w;
+
+ if (!pixDrawn) {
+ pixY = y+(h-pixH)/2; // default: center vertically
+ if (pixH > h) pixY = isBottom ? y-(pixH-h) : y;
+
+ p->drawPixmap( x, pixY, pix);
+
+ // for distance to next text
+ pixY = isBottom ? (pixY - h - 2) : (pixY + pixH + 2);
+ pixDrawn = true;
+ }
+
+
+ if (0) kdDebug(90100) << " Drawing '" << name << "' at "
+ << x+pixW << "/" << y << endl;
+
+ p->drawText( x+pixW, y,
+ width - pixW, h,
+ Qt::AlignLeft, name);
+ y = isBottom ? (y-h) : (y+h);
+ lines--;
+
+ if (remaining.isEmpty()) break;
+ name = remaining;
+ w = pixW + _fm->width(name);
+ }
+
+ // make sure the pix stays visible
+ if (pixDrawn && (pixY>0)) {
+ if (isBottom && (pixYy)) y = pixY;
+ }
+
+ if (origLines > lines) {
+ // if only 1 line written, don't reset _used* vars
+ if (lines - origLines >1) {
+ if (isBottom)
+ _usedBottomLeft = _usedBottomCenter = _usedBottomRight = 0;
+ else
+ _usedTopLeft = _usedTopCenter = _usedTopRight = 0;
+ }
+
+ // take back one line
+ y = isBottom ? (y+h) : (y-h);
+ if (used) *used = w;
+ }
+
+ // update free space
+ if (!isBottom) {
+ if (rotate)
+ _rect.setRect(r.x()+y, r.y(), r.width()-y, r.height());
+ else
+ _rect.setRect(r.x(), r.y()+y, r.width(), r.height()-y);
+ }
+ else {
+ if (rotate)
+ _rect.setRect(r.x(), r.y(), y+h, r.height());
+ else
+ _rect.setRect(r.x(), r.y(), r.width(), y+h);
+ }
+
+ p->restore();
+
+ return true;
+}
Added: branches/tmp/schubi/solvertree/drawparams.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/drawparams.h?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/drawparams.h (added)
+++ branches/tmp/schubi/solvertree/drawparams.h Fri Jun 29 17:13:18 2007
@@ -0,0 +1,200 @@
+/* This file is part of KCachegrind.
+ Copyright (C) 2002, 2003 Josef Weidendorfer
+ Adapted for the needs of kdesvn by Rajko Albrecht
+
+ KCachegrind 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, version 2.
+
+ 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; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * A Widget for visualizing hierarchical metrics as areas.
+ * The API is similar to QListView.
+ *
+ * This file defines the following classes:
+ * DrawParams, RectDrawing, TreeMapItem, TreeMapWidget
+ *
+ * DrawParams/RectDrawing allows reusing of TreeMap drawing
+ * functions in other widgets.
+ */
+
+#ifndef DRAWPARAMS_H
+#define DRAWPARAMS_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+class QPopupMenu;
+class QString;
+
+class KConfigGroup;
+
+
+/**
+ * Drawing parameters for an object.
+ * A Helper Interface for RectDrawing.
+ */
+class DrawParams
+{
+public:
+ /**
+ * Positions for drawing into a rectangle.
+ *
+ * The specified position assumes no rotation.
+ * If there is more than one text for one position, it is put
+ * nearer to the center of the item.
+ *
+ * Drawing at top positions cuts free space from top,
+ * drawing at bottom positions cuts from bottom.
+ * Default usually gives positions clockwise according to field number.
+ */
+ enum Position { TopLeft, TopCenter, TopRight,
+ BottomLeft, BottomCenter, BottomRight,
+ Default, Unknown};
+
+ // no constructor as this is an abstract class
+ virtual ~DrawParams() {}
+
+ virtual QString text(int) const = 0;
+ virtual QPixmap pixmap(int) const = 0;
+ virtual Position position(int) const = 0;
+ // 0: no limit, negative: leave at least -maxLines() free
+ virtual int maxLines(int) const { return 0; }
+ virtual int fieldCount() const { return 0; }
+
+ virtual QColor backColor() const { return Qt::white; }
+ virtual const QFont& font() const = 0;
+
+ virtual bool selected() const { return false; }
+ virtual bool current() const { return false; }
+ virtual bool shaded() const { return true; }
+ virtual bool rotated() const { return false; }
+ virtual bool drawFrame() const { return true; }
+};
+
+
+/*
+ * DrawParam with attributes stored
+ */
+class StoredDrawParams: public DrawParams
+{
+public:
+ StoredDrawParams();
+ StoredDrawParams(QColor c,
+ bool selected = false, bool current = false);
+
+ // getters
+ QString text(int) const;
+ QPixmap pixmap(int) const;
+ Position position(int) const;
+ int maxLines(int) const;
+ int fieldCount() const { return _field.size(); }
+
+ QColor backColor() const { return _backColor; }
+ bool selected() const { return _selected; }
+ bool current() const { return _current; }
+ bool shaded() const { return _shaded; }
+ bool rotated() const { return _rotated; }
+ bool drawFrame() const { return _drawFrame; }
+
+ const QFont& font() const;
+
+ // attribute setters
+ void setField(int f, QString t, QPixmap pm = QPixmap(),
+ Position p = Default, int maxLines = 0);
+ void setText(int f, QString);
+ void setPixmap(int f, QPixmap);
+ void setPosition(int f, Position);
+ void setMaxLines(int f, int);
+ void setBackColor(QColor c) { _backColor = c; }
+ void setSelected(bool b) { _selected = b; }
+ void setCurrent(bool b) { _current = b; }
+ void setShaded(bool b) { _shaded = b; }
+ void setRotated(bool b) { _rotated = b; }
+ void drawFrame(bool b) { _drawFrame = b; }
+
+protected:
+ QColor _backColor;
+ bool _selected :1;
+ bool _current :1;
+ bool _shaded :1;
+ bool _rotated :1;
+ bool _drawFrame :1;
+
+private:
+ // resize field array if needed to allow to access field <f>
+ void ensureField(int f);
+
+ struct Field {
+ QString text;
+ QPixmap pix;
+ Position pos;
+ int maxLines;
+ };
+
+ QValueVector<Field> _field;
+};
+
+
+/* State for drawing on a rectangle.
+ *
+ * Following drawing functions are provided:
+ * - background drawing with shading and 3D frame
+ * - successive pixmap/text drawing at various positions with wrap-around
+ * optimized for minimal space usage (e.g. if a text is drawn at top right
+ * after text on top left, the same line is used if space allows)
+ *
+ */
+class RectDrawing
+{
+public:
+ RectDrawing(QRect);
+ ~RectDrawing();
+
+ // The default DrawParams object used.
+ DrawParams* drawParams();
+ // we take control over the given object (i.e. delete at destruction)
+ void setDrawParams(DrawParams*);
+
+ // draw on a given QPainter, use this class as info provider per default
+ void drawBack(QPainter*, DrawParams* dp = 0);
+ /* Draw field at position() from pixmap()/text() with maxLines().
+ * Returns true if something was drawn
+ */
+ bool drawField(QPainter*, int f, DrawParams* dp = 0);
+
+ // resets rectangle for free space
+ void setRect(QRect);
+
+ // Returns the rectangle area still free of text/pixmaps after
+ // a number of drawText() calls.
+ QRect remainingRect(DrawParams* dp = 0);
+
+private:
+ int _usedTopLeft, _usedTopCenter, _usedTopRight;
+ int _usedBottomLeft, _usedBottomCenter, _usedBottomRight;
+ QRect _rect;
+
+ // temporary
+ int _fontHeight;
+ QFontMetrics* _fm;
+ DrawParams* _dp;
+};
+
+#endif
Added: branches/tmp/schubi/solvertree/graphtree_defines.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/graphtree_defines.h?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/graphtree_defines.h (added)
+++ branches/tmp/schubi/solvertree/graphtree_defines.h Fri Jun 29 17:13:18 2007
@@ -0,0 +1,31 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Rajko Albrecht *
+ * ral@alwins-world.de *
+ * *
+ * 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) any later version. *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef __GRAPHTREE_DEFINES
+#define __GRAPHTREE_DEFINES
+
+enum {
+ GRAPHTREE_LABEL = 1100,
+ GRAPHTREE_LINE,
+ GRAPHTREE_ARROW,
+ GRAPHTREE_MARK
+};
+
+#endif
Added: branches/tmp/schubi/solvertree/graphtreelabel.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/graphtreelabel.cpp?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/graphtreelabel.cpp (added)
+++ branches/tmp/schubi/solvertree/graphtreelabel.cpp Fri Jun 29 17:13:18 2007
@@ -0,0 +1,220 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 by Rajko Albrecht *
+ * ral@alwins-world.de *
+ * *
+ * 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) any later version. *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#include "graphtreelabel.h"
+#include "graphtree_defines.h"
+#include
+
+GraphTreeLabel::GraphTreeLabel(const QString&text, const QString&_nodename,const QRect&r,QCanvas*c)
+ : QCanvasRectangle(r,c),StoredDrawParams()
+{
+ m_Nodename = _nodename;
+ m_SourceNode = QString::null;
+ setText(0,text);
+ setPosition(0, DrawParams::TopCenter);
+ drawFrame(true);
+}
+
+GraphTreeLabel::~GraphTreeLabel()
+{
+}
+
+const QString&GraphTreeLabel::nodename()const
+{
+ return m_Nodename;
+}
+
+int GraphTreeLabel::rtti()const
+{
+ return GRAPHTREE_LABEL;
+}
+
+void GraphTreeLabel::setBgColor(const QColor&c)
+{
+ _backColor=c;
+}
+
+void GraphTreeLabel::drawShape(QPainter& p)
+{
+ QRect r = rect();
+/*
+ p.setPen(blue);
+ p.drawRect(r);
+*/
+ RectDrawing d(r);
+ d.drawBack(&p,this);
+ d.drawField(&p, 0, this);
+ d.drawField(&p, 1, this);
+}
+
+void GraphTreeLabel::setSelected(bool s)
+{
+ QCanvasRectangle::setSelected(s);
+ StoredDrawParams::setSelected(s);
+ update();
+}
+
+const QString&GraphTreeLabel::source()const
+{
+ return m_SourceNode;
+}
+
+void GraphTreeLabel::setSource(const QString&_s)
+{
+ m_SourceNode=_s;
+}
+
+GraphEdge::GraphEdge(QCanvas*c)
+ : QCanvasSpline(c)
+{
+}
+
+GraphEdge::~GraphEdge()
+{
+}
+
+void GraphEdge::drawShape(QPainter& p)
+{
+ p.drawPolyline(poly);
+}
+
+QPointArray GraphEdge::areaPoints() const
+{
+ int minX = poly[0].x(), minY = poly[0].y();
+ int maxX = minX, maxY = minY;
+ int i;
+
+ if (0) qDebug("GraphEdge::areaPoints\n P 0: %d/%d", minX, minY);
+ int len = poly.count();
+ for (i=1;i maxX) maxX = poly[i].x();
+ if (poly[i].y() > maxY) maxY = poly[i].y();
+ if (0) qDebug(" P %d: %d/%d", i, poly[i].x(), poly[i].y());
+ }
+ QPointArray a = poly.copy(), b = poly.copy();
+ if (minX == maxX) {
+ a.translate(-2, 0);
+ b.translate(2, 0);
+ }
+ else {
+ a.translate(0, -2);
+ b.translate(0, 2);
+ }
+ a.resize(2*len);
+ for (i=0;iv2) {
+ r.setRect(r.x()-d, r.y()-d, r.width()+2*d, r.height()+2*d);
+ v /= f;
+ }
+
+ _p = new QPixmap(r.size());
+ _p->fill(Qt::white);
+ QPainter p(_p);
+ p.setPen(Qt::NoPen);
+
+ r.moveBy(-r.x(), -r.y());
+
+ while (vwidth(), _p->height());
+ move(n->rect().center().x()-_p->width()/2,
+ n->rect().center().y()-_p->height()/2);
+}
+
+GraphMark::~ GraphMark()
+{
+}
+
+bool GraphMark::hit(const QPoint&)const
+{
+ return false;
+}
+
+int GraphMark::rtti()const
+{
+ return GRAPHTREE_MARK;
+}
+
+void GraphMark::drawShape(QPainter&p)
+{
+ p.drawPixmap( int(x()), int(y()), *_p );
+}
Added: branches/tmp/schubi/solvertree/graphtreelabel.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/graphtreelabel.h?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/graphtreelabel.h (added)
+++ branches/tmp/schubi/solvertree/graphtreelabel.h Fri Jun 29 17:13:18 2007
@@ -0,0 +1,89 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 by Rajko Albrecht *
+ * ral@alwins-world.de *
+ * *
+ * 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) any later version. *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef GRAPHTREELABEL_H
+#define GRAPHTREELABEL_H
+
+#include "drawparams.h"
+#include
+
+/**
+ @author Rajko Albrecht
+*/
+class GraphTreeLabel : public QCanvasRectangle,StoredDrawParams
+{
+public:
+ GraphTreeLabel(const QString&,const QString&,const QRect&r,QCanvas*c);
+ virtual ~GraphTreeLabel();
+
+ virtual int rtti()const;
+ virtual void drawShape(QPainter& p);
+
+ void setBgColor(const QColor&);
+
+ const QString&nodename()const;
+ const QString&source()const;
+ void setSource(const QString&);
+ virtual void setSelected(bool);
+
+protected:
+ QString m_Nodename;
+ QString m_SourceNode;
+};
+
+class GraphEdge;
+
+class GraphEdgeArrow:public QCanvasPolygon
+{
+public:
+ GraphEdgeArrow(GraphEdge*,QCanvas*);
+ GraphEdge*edge();
+ virtual void drawShape(QPainter&);
+ virtual int rtti()const;
+
+private:
+ GraphEdge*_edge;
+};
+
+/* line */
+class GraphEdge:public QCanvasSpline
+{
+public:
+ GraphEdge(QCanvas*);
+ virtual ~GraphEdge();
+
+ virtual void drawShape(QPainter&);
+ QPointArray areaPoints() const;
+ virtual int rtti()const;
+};
+
+class GraphMark:public QCanvasRectangle
+{
+public:
+ GraphMark(GraphTreeLabel*,QCanvas*);
+ virtual ~GraphMark();
+ virtual int rtti()const;
+ virtual bool hit(const QPoint&)const;
+
+ virtual void drawShape(QPainter&);
+private:
+ static QPixmap*_p;
+};
+
+#endif
Added: branches/tmp/schubi/solvertree/main.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/main.cpp?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/main.cpp (added)
+++ branches/tmp/schubi/solvertree/main.cpp Fri Jun 29 17:13:18 2007
@@ -0,0 +1,20 @@
+#include
+#include
+#include
+#include
+#include
+
+#include "dialog.h"
+
+ int main(int argc, char *argv[])
+ {
+ QApplication app(argc, argv);
+
+ Dialog *dialog = new Dialog();
+ app.setMainWidget( dialog );
+ dialog->setCaption("Solvertree");
+ dialog->setMinimumSize ( 700, 700 );
+ dialog->show();
+
+ return app.exec();
+ }
Added: branches/tmp/schubi/solvertree/pannerview.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/pannerview.cpp?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/pannerview.cpp (added)
+++ branches/tmp/schubi/solvertree/pannerview.cpp Fri Jun 29 17:13:18 2007
@@ -0,0 +1,101 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 by Rajko Albrecht *
+ * ral@alwins-world.de *
+ * *
+ * 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) any later version. *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#include "pannerview.h"
+#include
+
+PannerView::PannerView(QWidget* parent, const char* name)
+ : QCanvasView(parent, name,WNoAutoErase | WStaticContents )
+{
+ m_Moving = false;
+ viewport()->setBackgroundMode(Qt::NoBackground);
+ setBackgroundMode(Qt::NoBackground);
+}
+
+PannerView::~PannerView()
+{
+}
+
+void PannerView::drawContents(QPainter* p, int clipx, int clipy, int clipw, int cliph)
+{
+ p->save();
+ QCanvasView::drawContents(p,clipx,clipy,clipw,cliph);
+ p->restore();
+ if (m_ZoomRect.isValid()) {
+ p->setPen(red.dark());
+ p->drawRect(m_ZoomRect);
+ p->setPen( red);
+ p->drawRect(QRect(m_ZoomRect.x()+1, m_ZoomRect.y()+1,
+ m_ZoomRect.width()-2, m_ZoomRect.height()-2));
+ }
+}
+
+void PannerView::setZoomRect(const QRect& theValue)
+{
+ QRect oldRect = m_ZoomRect;
+ m_ZoomRect = theValue;
+ updateContents(oldRect);
+ updateContents(m_ZoomRect);
+}
+
+/*!
+ \fn PannerView::contentsMouseMoveEvent(QMouseEvent* e)
+ */
+void PannerView::contentsMouseMoveEvent(QMouseEvent* e)
+{
+ if (m_Moving) {
+ emit zoomRectMoved(e->pos().x() - m_LastPos.x(), e->pos().y() - m_LastPos.y());
+ m_LastPos = e->pos();
+ }
+}
+
+/*!
+ \fn PannerView::contentsMousePressEvent(QMouseEvent* e)
+ */
+void PannerView::contentsMousePressEvent(QMouseEvent* e)
+{
+ if (m_ZoomRect.isValid()) {
+ if (!m_ZoomRect.contains(e->pos())) {
+ emit zoomRectMoved(e->pos().x() - m_ZoomRect.center().x(),
+ e->pos().y() - m_ZoomRect.center().y());
+ }
+ m_Moving = true;
+ m_LastPos = e->pos();
+ }
+}
+
+/*!
+ \fn PannerView::contentsMouseReleaseEvent(QMouseEvent*)
+ */
+void PannerView::contentsMouseReleaseEvent(QMouseEvent*)
+{
+ m_Moving = false;
+ emit zoomRectMoveFinished();
+}
+
+/*!
+ \fn PannerView::updateCurrentRect()
+ */
+void PannerView::updateCurrentRect()
+{
+ if (m_ZoomRect.isValid()) updateContents(m_ZoomRect);
+}
+
+#include "pannerview.moc"
+
Added: branches/tmp/schubi/solvertree/pannerview.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/pannerview.h?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/pannerview.h (added)
+++ branches/tmp/schubi/solvertree/pannerview.h Fri Jun 29 17:13:18 2007
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 by Rajko Albrecht *
+ * ral@alwins-world.de *
+ * *
+ * 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) any later version. *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef PANNERVIEW_H
+#define PANNERVIEW_H
+
+#include
+
+/**
+ @author Rajko Albrecht
+*/
+class PannerView : public QCanvasView
+{
+Q_OBJECT
+public:
+ PannerView(QWidget* parent=0, const char* name=0);
+ virtual ~PannerView();
+
+ void setZoomRect(const QRect& theValue);
+ void updateCurrentRect();
+
+signals:
+ void zoomRectMoved(int dx, int dy);
+ void zoomRectMoveFinished();
+
+protected:
+ virtual void drawContents(QPainter* p, int clipx, int clipy, int clipw, int cliph);
+ virtual void contentsMouseMoveEvent(QMouseEvent* e);
+ virtual void contentsMousePressEvent(QMouseEvent* e);
+ virtual void contentsMouseReleaseEvent(QMouseEvent*);
+protected:
+ QRect m_ZoomRect;
+ bool m_Moving;
+ QPoint m_LastPos;
+};
+
+#endif
Added: branches/tmp/schubi/solvertree/resgraphview.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/resgraphview.cpp?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/resgraphview.cpp (added)
+++ branches/tmp/schubi/solvertree/resgraphview.cpp Fri Jun 29 17:13:18 2007
@@ -0,0 +1,832 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 by Rajko Albrecht *
+ * ral@alwins-world.de *
+ * *
+ * 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) any later version. *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#include "resgraphview.h"
+#include "graphtreelabel.h"
+#include "pannerview.h"
+#include "graphtree_defines.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#define LABEL_WIDTH 160
+#define LABEL_HEIGHT 90
+
+static int globalDirection = 0;
+
+class GraphViewTipSolver:public QToolTip
+{
+public:
+ GraphViewTipSolver( QWidget* p ):QToolTip(p) {}
+ virtual ~GraphViewTipSolver(){}
+
+protected:
+ void maybeTip( const QPoint & );
+};
+
+void GraphViewTipSolver::maybeTip( const QPoint & pos)
+{
+ if (!parentWidget()->inherits( "ResGraphView" )) return;
+ ResGraphView* cgv = (ResGraphView*)parentWidget();
+ QPoint cPos = cgv->viewportToContents(pos);
+ QCanvasItemList l = cgv->canvas()->collisions(cPos);
+ if (l.count() == 0) return;
+ QCanvasItem* i = l.first();
+ if (i->rtti() == GRAPHTREE_LABEL) {
+ GraphTreeLabel*tl = (GraphTreeLabel*)i;
+ QString nm = tl->nodename();
+ QString tipStr = cgv->toolTip(nm);
+ if (tipStr.length()>0) {
+ QPoint vPosTL = cgv->contentsToViewport(i->boundingRect().topLeft());
+ QPoint vPosBR = cgv->contentsToViewport(i->boundingRect().bottomRight());
+ tip(QRect(vPosTL, vPosBR), tipStr);
+ }
+ }
+}
+
+ResGraphView::ResGraphView(QWidget * parent, const char * name, WFlags f)
+ : QCanvasView(parent,name,f)
+{
+ m_Canvas = 0L;
+ dotTmpFile = 0;
+ m_Selected = 0;
+ renderProcess = 0;
+ m_Marker = 0;
+ m_Tip = new GraphViewTipSolver(this);
+ m_CompleteView = new PannerView(this);
+
+ m_CompleteView->setVScrollBarMode(QScrollView::AlwaysOff);
+ m_CompleteView->setHScrollBarMode(QScrollView::AlwaysOff);
+ m_CompleteView->raise();
+ m_CompleteView->hide();
+ connect(this, SIGNAL(contentsMoving(int,int)),
+ this, SLOT(contentsMovingSlot(int,int)));
+ connect(m_CompleteView, SIGNAL(zoomRectMoved(int,int)),
+ this, SLOT(zoomRectMoved(int,int)));
+ connect(m_CompleteView, SIGNAL(zoomRectMoveFinished()),
+ this, SLOT(zoomRectMoveFinished()));
+ m_LastAutoPosition = TopLeft;
+ _isMoving = false;
+ _noUpdateZoomerPos = false;
+ m_LabelMap[""]="";
+}
+
+ResGraphView::~ResGraphView()
+{
+ setCanvas(0);
+ delete m_Canvas;
+ delete dotTmpFile;
+ delete m_CompleteView;
+ delete m_Tip;
+ delete renderProcess;
+}
+
+void ResGraphView::showText(const QString&s)
+{
+ clear();
+ m_Canvas = new QCanvas(QApplication::desktop()->width(),
+ QApplication::desktop()->height());
+
+ QCanvasText* t = new QCanvasText(s, m_Canvas);
+ t->move(5, 5);
+ t->show();
+ center(0,0);
+ setCanvas(m_Canvas);
+ m_Canvas->update();
+ m_CompleteView->hide();
+}
+
+void ResGraphView::clear()
+{
+ if (m_Selected) {
+ m_Selected->setSelected(false);
+ m_Selected=0;
+ }
+ if (m_Marker) {
+ m_Marker->hide();
+ delete m_Marker;
+ m_Marker=0;
+ }
+ if (!m_Canvas) return;
+ delete m_Canvas;
+ m_Canvas = 0;
+ setCanvas(0);
+ m_CompleteView->setCanvas(0);
+}
+
+void ResGraphView::beginInsert()
+{
+ viewport()->setUpdatesEnabled(false);
+}
+
+void ResGraphView::endInsert()
+{
+ if (m_Canvas) {
+ _cvZoom = 0;
+ updateSizes();
+ m_Canvas->update();
+ }
+ viewport()->setUpdatesEnabled(true);
+}
+
+void ResGraphView::readDotOutput(KProcess*,char * buffer,int buflen)
+{
+ dotOutput+=QString::fromLocal8Bit(buffer, buflen);
+}
+
+void ResGraphView::dotExit(KProcess*p)
+{
+ if (p!=renderProcess)return;
+ // remove line breaks when lines to long
+ QRegExp endslash("\\\\\\n");
+ dotOutput.replace(endslash,"");
+ double scale = 1.0, scaleX = 1.0, scaleY = 1.0;
+ double dotWidth, dotHeight;
+ QTextStream* dotStream;
+ dotStream = new QTextStream(dotOutput, IO_ReadOnly);
+ QString line,cmd;
+ int lineno=0;
+ clear();
+ beginInsert();
+ /* mostly taken from kcachegrind */
+ while (1) {
+ line = dotStream->readLine();
+ if (line.isNull()) break;
+ lineno++;
+ if (line.isEmpty()) continue;
+ QTextStream lineStream(line, IO_ReadOnly);
+ lineStream >> cmd;
+ if (cmd == "stop") {break; }
+
+ if (cmd == "graph") {
+ lineStream >> scale >> dotWidth >> dotHeight;
+ scaleX = scale * 60; scaleY = scale * 100;
+ int w = (int)(scaleX * dotWidth);
+ int h = (int)(scaleY * dotHeight);
+
+ _xMargin = 50;
+ if (w < QApplication::desktop()->width())
+ _xMargin += (QApplication::desktop()->width()-w)/2;
+ _yMargin = 50;
+ if (h < QApplication::desktop()->height())
+ _yMargin += (QApplication::desktop()->height()-h)/2;
+ m_Canvas = new QCanvas(int(w+2*_xMargin), int(h+2*_yMargin));
+ continue;
+ }
+ if ((cmd != "node") && (cmd != "edge")) {
+ kdWarning() << "Ignoring unknown command '" << cmd << "' from dot ("
+ << dotTmpFile->name() << ":" << lineno << ")" << endl;
+ continue;
+ }
+ if (cmd=="node") {
+ QString nodeName, label;
+ QString _x,_y,_w,_h;
+ double x, y, width, height;
+ lineStream >> nodeName >> _x >> _y >> _w >> _h;
+ x=_x.toDouble();
+ y=_y.toDouble();
+ width=_w.toDouble();
+ height=_h.toDouble();
+ // better here 'cause dot may scramble utf8 labels so we regenerate it better
+ // and do not read it in.
+ label = getLabelstring(nodeName);
+ int xx = (int)(scaleX * x + _xMargin);
+ int yy = (int)(scaleY * (dotHeight - y) + _yMargin);
+ int w = (int)(scaleX * width);
+ int h = (int)(scaleY * height);
+ QRect r(xx-w/2, yy-h/2, w, h);
+ GraphTreeLabel*t=new GraphTreeLabel(label,nodeName,r,m_Canvas);
+ if (isStart(nodeName)) {
+ ensureVisible(r.x(),r.y());
+ }
+ t->setBgColor(getBgColor(nodeName));
+ t->setZ(1.0);
+ t->show();
+ m_NodeList[nodeName]=t;
+ } else {
+ QString node1Name, node2Name, label;
+ QString _x,_y;
+ double x, y;
+ QPointArray pa;
+ int points, i;
+ lineStream >> node1Name >> node2Name;
+ lineStream >> points;
+ pa.resize(points);
+ for (i=0;i> _x >> _y;
+ x=_x.toDouble();
+ y=_y.toDouble();
+ int xx = (int)(scaleX * x + _xMargin);
+ int yy = (int)(scaleY * (dotHeight - y) + _yMargin);
+
+ if (0) qDebug(" P %d: ( %f / %f ) => ( %d / %d)",
+ i, x, y, xx, yy);
+ pa.setPoint(i, xx, yy);
+ }
+ if (i < points) {
+ qDebug("CallGraphView: Can't read %d spline points (%d)",
+ points, lineno);
+ continue;
+ }
+
+ GraphEdge * n = new GraphEdge(m_Canvas);
+ QColor arrowColor = Qt::black;
+ n->setPen(QPen(arrowColor,1));
+ n->setControlPoints(pa,false);
+ n->setZ(0.5);
+ n->show();
+
+ /* arrow */
+ QPoint arrowDir;
+ int indexHead = -1;
+
+ QMap::Iterator it;
+ it = m_NodeList.find(node2Name);
+ if (it!=m_NodeList.end()) {
+ it.data()->setSource(node1Name);
+ }
+ it = m_NodeList.find(node1Name);
+ if (it!=m_NodeList.end()) {
+ GraphTreeLabel*tlab = it.data();
+ if (tlab) {
+ QPoint toCenter = tlab->rect().center();
+ int dx0 = pa.point(0).x() - toCenter.x();
+ int dy0 = pa.point(0).y() - toCenter.y();
+ int dx1 = pa.point(points-1).x() - toCenter.x();
+ int dy1 = pa.point(points-1).y() - toCenter.y();
+ if (dx0*dx0+dy0*dy0 > dx1*dx1+dy1*dy1) {
+ // start of spline is nearer to call target node
+ indexHead=-1;
+ while(arrowDir.isNull() && (indexHead1)) {
+ indexHead--;
+ arrowDir = pa.point(indexHead) - pa.point(indexHead-1);
+ }
+ }
+ if (!arrowDir.isNull()) {
+ arrowDir *= 10.0/sqrt(double(arrowDir.x()*arrowDir.x() +
+ arrowDir.y()*arrowDir.y()));
+ QPointArray a(3);
+ a.setPoint(0, pa.point(indexHead) + arrowDir);
+ a.setPoint(1, pa.point(indexHead) + QPoint(arrowDir.y()/2,
+ -arrowDir.x()/2));
+ a.setPoint(2, pa.point(indexHead) + QPoint(-arrowDir.y()/2,
+ arrowDir.x()/2));
+ GraphEdgeArrow* aItem = new GraphEdgeArrow(n,m_Canvas);
+ aItem->setPoints(a);
+ aItem->setBrush(arrowColor);
+ aItem->setZ(1.5);
+ aItem->show();
+// sItem->setArrow(aItem);
+ }
+ }
+ }
+ if (!m_Canvas) {
+ QString s = i18n("Error running the graph layouting tool.\n");
+ s += i18n("Please check that 'dot' is installed (package GraphViz).");
+ showText(s);
+ } else {
+ setCanvas(m_Canvas);
+ m_CompleteView->setCanvas(m_Canvas);
+ }
+ endInsert();
+ delete p;
+ renderProcess=0;
+}
+
+bool ResGraphView::isStart(const QString&nodeName)const
+{
+ bool res = false;
+ trevTree::ConstIterator it;
+ it = m_Tree.find(nodeName);
+ if (it==m_Tree.end()) {
+ return res;
+ }
+
+ return res;
+}
+
+
+QColor ResGraphView::getBgColor(const QString&nodeName)const
+{
+ trevTree::ConstIterator it;
+ it = m_Tree.find(nodeName);
+ QColor res = Qt::white;
+ if (it==m_Tree.end()) {
+ return res;
+ }
+#if 0
+ switch (it.data().Action) {
+ case 'D':
+ res = Kdesvnsettings::tree_delete_color();
+ break;
+ case 'R':
+ case 'M':
+ res = Kdesvnsettings::tree_modify_color();
+ break;
+ case 'A':
+ res = Kdesvnsettings::tree_add_color();
+ break;
+ case 'C':
+ case 1:
+ res = Kdesvnsettings::tree_copy_color();
+ break;
+ case 2:
+ res = Kdesvnsettings::tree_rename_color();
+ break;
+ default:
+ res = Kdesvnsettings::tree_modify_color();
+ break;
+ }
+#endif
+ return res;
+}
+
+const QString&ResGraphView::getLabelstring(const QString&nodeName)
+{
+ QMap::ConstIterator nIt;
+ nIt = m_LabelMap.find(nodeName);
+ if (nIt!=m_LabelMap.end()) {
+ return nIt.data();
+ }
+ trevTree::ConstIterator it1;
+ it1 = m_Tree.find(nodeName);
+ if (it1==m_Tree.end()) {
+ return m_LabelMap[""];
+ }
+
+ m_LabelMap[nodeName]=it1.data().name + " Version: " + it1.data().version;
+ return m_LabelMap[nodeName];
+}
+
+void ResGraphView::dumpRevtree()
+{
+
+ delete dotTmpFile;
+ clear();
+ dotOutput = "";
+ QString filename = "solver.dot";
+ dotTmpFile = new QFile(filename); // FIXME to tmp
+
+ if (!dotTmpFile->open(IO_ReadWrite)) {
+ showText(i18n("Could not open tempfile %1 for writing.").arg(filename));
+ return;
+ }
+
+ QTextStream stream(dotTmpFile);
+
+ stream << "digraph \"callgraph\" {\n";
+ stream << " bgcolor=\"transparent\";\n";
+ int dir = globalDirection;
+ stream << QString(" rankdir=\"");
+ switch (dir) {
+ case 3:
+ stream << "TB";
+ break;
+ case 2:
+ stream << "RL";
+ break;
+ case 1:
+ stream << "BT";
+ break;
+ case 0:
+ default:
+ stream << "LR";
+ break;
+ }
+ stream << "\";\n";
+
+ //*stream << QString(" overlap=false;\n splines=true;\n");
+
+ ResGraphView::trevTree::ConstIterator it1;
+ for (it1=m_Tree.begin();it1!=m_Tree.end();++it1) {
+ stream << " " << it1.key()
+ << "[ "
+ << "shape=box, "
+ << "label=\""<"<<" "<setEnvironment("LANG","C");
+ *renderProcess << "dot";
+ *renderProcess << filename << "-Tplain";
+ connect(renderProcess,SIGNAL(processExited(KProcess*)),this,SLOT(dotExit(KProcess*)));
+ connect(renderProcess,SIGNAL(receivedStdout(KProcess*,char*,int)),
+ this,SLOT(readDotOutput(KProcess*,char*,int)) );
+ if (!renderProcess->start(KProcess::NotifyOnExit,KProcess::Stdout)) {
+ QString arguments;
+ for (unsigned c=0;c<renderProcess->args().count();++c) {
+ arguments+=QString(" %1").arg(renderProcess->args()[c]);
+ }
+ QString error = i18n("Could not start process \"%1\".").arg(arguments);
+ showText(error);
+ renderProcess=0;
+ //delete renderProcess;<
+ }
+}
+
+QString ResGraphView::toolTip(const QString&_nodename,bool full)const
+{
+ QString res = QString::null;
+ trevTree::ConstIterator it;
+ it = m_Tree.find(_nodename);
+ if (it==m_Tree.end()) {
+ return res;
+ }
+ QStringList sp = QStringList::split("\n",it.data().description);
+ QString sm;
+ if (sp.count()==0) {
+ sm = it.data().description;
+ } else {
+ if (!full) {
+ sm = sp[0]+"...";
+ } else {
+ for (unsigned j = 0; j0) sm+="<br>";
+ sm+=sp[j];
+ }
+ }
+ }
+ if (!full && sm.length()>50) {
+ sm.truncate(47);
+ sm+="...";
+ }
+ static QString csep = "</td><td>";
+ static QString rend = "</td></tr>";
+ static QString rstart = "<tr><td>";
+ res = QString("<html><body>");
+
+ if (!full) {
+ res+=QString("<b>%1</b>").arg(it.data().name);
+ res += i18n("<br>Kind: %1<br>Version: %2<br>Source: %3<br>Description: %4</html>")
+ .arg(it.data().kind)
+ .arg(it.data().version)
+ .arg(it.data().source)
+ .arg(sm);
+ } else {
+ res+="<table><tr><b>"+it.data().name+"</b></th></tr>";
+ res+=rstart;
+ res+=i18n("<b>Kind</b>%1%2%3").arg(csep).arg(it.data().kind).arg(rend);
+ res+=rstart+i18n("<b>Version</b>%1%2%3").arg(csep).arg(it.data().version).arg(rend);
+ res+=rstart+i18n("<b>Source</b>%1%2%3").arg(csep).arg(it.data().source).arg(rend);
+ res+=rstart+i18n("<b>Description</b>%1%2%3").arg(csep).arg(sm).arg(rend);
+ res+="</table></body></html>";
+ }
+ return res;
+}
+
+void ResGraphView::updateSizes(QSize s)
+{
+ if (!m_Canvas) return;
+ if (s == QSize(0,0)) s = size();
+
+ // the part of the canvas that should be visible
+ int cWidth = m_Canvas->width() - 2*_xMargin + 100;
+ int cHeight = m_Canvas->height() - 2*_yMargin + 100;
+
+ // hide birds eye view if no overview needed
+ if (((cWidth < s.width()) && cHeight < s.height())||m_NodeList.count()==0) {
+ m_CompleteView->hide();
+ return;
+ }
+
+ m_CompleteView->show();
+
+ // first, assume use of 1/3 of width/height (possible larger)
+ double zoom = .33 * s.width() / cWidth;
+ if (zoom * cHeight < .33 * s.height()) zoom = .33 * s.height() / cHeight;
+
+ // fit to widget size
+ if (cWidth * zoom > s.width()) zoom = s.width() / (double)cWidth;
+ if (cHeight * zoom > s.height()) zoom = s.height() / (double)cHeight;
+
+ // scale to never use full height/width
+ zoom = zoom * 3/4;
+
+ // at most a zoom of 1/3
+ if (zoom > .33) zoom = .33;
+
+ if (zoom != _cvZoom) {
+ _cvZoom = zoom;
+ if (0) qDebug("Canvas Size: %dx%d, Visible: %dx%d, Zoom: %f",
+ m_Canvas->width(), m_Canvas->height(),
+ cWidth, cHeight, zoom);
+
+ QWMatrix wm;
+ wm.scale( zoom, zoom );
+ m_CompleteView->setWorldMatrix(wm);
+
+ // make it a little bigger to compensate for widget frame
+ m_CompleteView->resize(int(cWidth * zoom) + 4,
+ int(cHeight * zoom) + 4);
+
+ // update ZoomRect in completeView
+ contentsMovingSlot(contentsX(), contentsY());
+ }
+
+ m_CompleteView->setContentsPos(int(zoom*(_xMargin-50)),
+ int(zoom*(_yMargin-50)));
+ updateZoomerPos();
+}
+
+void ResGraphView::updateZoomerPos()
+{
+ int cvW = m_CompleteView->width();
+ int cvH = m_CompleteView->height();
+ int x = width()- cvW - verticalScrollBar()->width() -2;
+ int y = height()-cvH - horizontalScrollBar()->height() -2;
+
+ QPoint oldZoomPos = m_CompleteView->pos();
+ QPoint newZoomPos = QPoint(0,0);
+
+#if 0
+ ZoomPosition zp = _zoomPosition;
+ if (zp == Auto) {
+#else
+ ZoomPosition zp = m_LastAutoPosition;
+#endif
+ QPoint tl1Pos = viewportToContents(QPoint(0,0));
+ QPoint tl2Pos = viewportToContents(QPoint(cvW,cvH));
+ QPoint tr1Pos = viewportToContents(QPoint(x,0));
+ QPoint tr2Pos = viewportToContents(QPoint(x+cvW,cvH));
+ QPoint bl1Pos = viewportToContents(QPoint(0,y));
+ QPoint bl2Pos = viewportToContents(QPoint(cvW,y+cvH));
+ QPoint br1Pos = viewportToContents(QPoint(x,y));
+ QPoint br2Pos = viewportToContents(QPoint(x+cvW,y+cvH));
+ int tlCols = m_Canvas->collisions(QRect(tl1Pos,tl2Pos)).count();
+ int trCols = m_Canvas->collisions(QRect(tr1Pos,tr2Pos)).count();
+ int blCols = m_Canvas->collisions(QRect(bl1Pos,bl2Pos)).count();
+ int brCols = m_Canvas->collisions(QRect(br1Pos,br2Pos)).count();
+ int minCols = tlCols;
+ zp = m_LastAutoPosition;
+ switch(zp) {
+ case TopRight: minCols = trCols; break;
+ case BottomLeft: minCols = blCols; break;
+ case BottomRight: minCols = brCols; break;
+ default:
+ case TopLeft: minCols = tlCols; break;
+ }
+ if (minCols > tlCols) { minCols = tlCols; zp = TopLeft; }
+ if (minCols > trCols) { minCols = trCols; zp = TopRight; }
+ if (minCols > blCols) { minCols = blCols; zp = BottomLeft; }
+ if (minCols > brCols) { minCols = brCols; zp = BottomRight; }
+
+ m_LastAutoPosition = zp;
+#if 0
+ }
+#endif
+ switch(zp) {
+ case TopRight:
+ newZoomPos = QPoint(x,0);
+ break;
+ case BottomLeft:
+ newZoomPos = QPoint(0,y);
+ break;
+ case BottomRight:
+ newZoomPos = QPoint(x,y);
+ break;
+ default:
+ break;
+ }
+ if (newZoomPos != oldZoomPos) m_CompleteView->move(newZoomPos);
+}
+
+void ResGraphView::contentsMovingSlot(int x,int y)
+{
+ QRect z(int(x * _cvZoom), int(y * _cvZoom),
+ int(visibleWidth() * _cvZoom)-1, int(visibleHeight() * _cvZoom)-1);
+ if (0) qDebug("moving: (%d,%d) => (%d/%d - %dx%d)",
+ x, y, z.x(), z.y(), z.width(), z.height());
+ m_CompleteView->setZoomRect(z);
+ if (!_noUpdateZoomerPos) {
+ updateZoomerPos();
+ }
+}
+
+void ResGraphView::zoomRectMoved(int dx,int dy)
+{
+ if (leftMargin()>0) dx = 0;
+ if (topMargin()>0) dy = 0;
+ _noUpdateZoomerPos = true;
+ scrollBy(int(dx/_cvZoom),int(dy/_cvZoom));
+ _noUpdateZoomerPos = false;
+}
+
+void ResGraphView::zoomRectMoveFinished()
+{
+#if 0
+ if (_zoomPosition == Auto)
+#endif
+ updateZoomerPos();
+}
+
+void ResGraphView::resizeEvent(QResizeEvent*e)
+{
+ QCanvasView::resizeEvent(e);
+ if (m_Canvas) updateSizes(e->size());
+}
+
+void ResGraphView::makeSelected(GraphTreeLabel*gtl)
+{
+ if (m_Selected) {
+ m_Selected->setSelected(false);
+ }
+ m_Selected=gtl;
+ if (m_Marker) {
+ m_Marker->hide();
+ delete m_Marker;
+ m_Marker=0;
+ }
+ if (gtl) {
+ m_Marker = new GraphMark(gtl,m_Canvas);
+ m_Marker->setZ(-1);
+ m_Marker->show();
+ m_Selected->setSelected(true);
+ }
+ m_Canvas->update();
+ m_CompleteView->updateCurrentRect();
+}
+
+void ResGraphView::contentsMouseDoubleClickEvent ( QMouseEvent * e )
+{
+ setFocus();
+ if (e->button() == Qt::LeftButton) {
+ QCanvasItemList l = canvas()->collisions(e->pos());
+ if (l.count()>0) {
+ QCanvasItem* i = l.first();
+ if (i->rtti()==GRAPHTREE_LABEL) {
+ makeSelected( (GraphTreeLabel*)i);
+ emit dispDetails(toolTip(((GraphTreeLabel*)i)->nodename(),true));
+ }
+ }
+ }
+}
+
+void ResGraphView::contentsMousePressEvent ( QMouseEvent * e )
+{
+ setFocus();
+ _isMoving = true;
+ _lastPos = e->globalPos();
+}
+
+void ResGraphView::contentsMouseReleaseEvent ( QMouseEvent * )
+{
+ _isMoving = false;
+ updateZoomerPos();
+}
+
+void ResGraphView::contentsMouseMoveEvent ( QMouseEvent * e )
+{
+ if (_isMoving) {
+ int dx = e->globalPos().x() - _lastPos.x();
+ int dy = e->globalPos().y() - _lastPos.y();
+ _noUpdateZoomerPos = true;
+ scrollBy(-dx, -dy);
+ _noUpdateZoomerPos = false;
+ _lastPos = e->globalPos();
+ }
+}
+
+void ResGraphView::setNewDirection(int dir)
+{
+ if (dir<0)dir=3;
+ else if (dir>3)dir=0;
+ globalDirection = dir;
+ dumpRevtree();
+}
+
+void ResGraphView::contentsContextMenuEvent(QContextMenuEvent* e)
+{
+ if (!m_Canvas) return;
+ QCanvasItemList l = canvas()->collisions(e->pos());
+ QCanvasItem* i = (l.count() == 0) ? 0 : l.first();
+
+ QPopupMenu popup;
+ if (i && i->rtti()==GRAPHTREE_LABEL) {
+ if (m_Selected == i) {
+ popup.insertItem(i18n("Unselect item"),401);
+ } else {
+ popup.insertItem(i18n("Select item"),402);
+ }
+ popup.insertSeparator();
+ popup.insertItem(i18n("Display details"),403);
+ popup.insertSeparator();
+ }
+ popup.insertItem(i18n("Rotate counter-clockwise"),101);
+ popup.insertItem(i18n("Rotate clockwise"),102);
+ popup.insertSeparator();
+ popup.setCheckable(true);
+ popup.insertItem(i18n("Save tree as png"),201);
+
+ int r = popup.exec(e->globalPos());
+
+ switch (r) {
+ case 101:
+ {
+ int dir = globalDirection;
+ setNewDirection(++dir);
+ }
+ break;
+ case 102:
+ {
+ int dir = globalDirection;
+ setNewDirection(--dir);
+ }
+ break;
+ case 201:
+ {
+ QString fn = KFileDialog::getSaveFileName(":","*.png");
+ if (!fn.isEmpty()) {
+ if (m_Marker) {
+ m_Marker->hide();
+ }
+ if (m_Selected) {
+ m_Selected->setSelected(false);
+ }
+ QPixmap pix(m_Canvas->size());
+ QPainter p(&pix);
+ m_Canvas->drawArea( m_Canvas->rect(), &p );
+ pix.save(fn,"PNG");
+ if (m_Marker) {
+ m_Marker->show();
+ }
+ if (m_Selected) {
+ m_Selected->setSelected(true);
+ m_Canvas->update();
+ m_CompleteView->updateCurrentRect();
+ }
+ }
+ }
+ case 401:
+ makeSelected(0);
+ break;
+ case 402:
+ makeSelected((GraphTreeLabel*)i);
+ break;
+ case 403:
+ emit dispDetails(toolTip(((GraphTreeLabel*)i)->nodename(),true));
+ break;
+ default:
+ break;
+ }
+}
+
+
+void ResGraphView::setBasePath(const QString&_path)
+{
+ _basePath = _path;
+}
+
+void ResGraphView::slotClientException(const QString&what)
+{
+ KMessageBox::sorry(KApplication::activeModalWidget(),what,i18n("SVN Error"));
+}
+
+#include "resgraphview.moc"
Added: branches/tmp/schubi/solvertree/resgraphview.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/resgraphview.h?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/resgraphview.h (added)
+++ branches/tmp/schubi/solvertree/resgraphview.h Fri Jun 29 17:13:18 2007
@@ -0,0 +1,145 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 by Rajko Albrecht *
+ * ral@alwins-world.de *
+ * *
+ * 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) any later version. *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef RESGRAPHVIEW_H
+#define RESGRAPHVIEW_H
+
+
+#include
+#include
+
+
+namespace svn {
+ class LogEntry;
+ class Client;
+}
+
+class KTempFile;
+class KProcess;
+class RevisionTree;
+class SolverTree;
+class GraphTreeLabel;
+class GraphViewTipSolver;
+class GraphMark;
+class PannerView;
+class CContextListener;
+
+/**
+ @author Rajko Albrecht
+*/
+class ResGraphView : public QCanvasView
+{
+ Q_OBJECT
+public:
+ enum ZoomPosition { TopLeft, TopRight, BottomLeft, BottomRight, Auto };
+ /* avoid large copy operations */
+ friend class RevisionTree;
+ friend class SolverTree;
+
+ ResGraphView(QWidget * parent = 0, const char * name = 0, WFlags f = 0);
+ virtual ~ResGraphView();
+
+ void showText(const QString&s);
+ void clear();
+
+ void beginInsert();
+ void endInsert();
+
+ struct targetData {
+ QString key;
+ targetData(const QString&n)
+ {
+ key = n;
+ }
+ targetData(){key="";}
+ };
+ typedef QValueList<targetData> tlist;
+
+ struct keyData {
+ QString name,
+ kind,
+ source,
+ version,
+ description;
+ tlist targets;
+ };
+
+ typedef QMap trevTree;
+
+ QString toolTip(const QString&nodename,bool full=false)const;
+
+ void setBasePath(const QString&);
+ void dumpRevtree();
+
+signals:
+ void dispDetails(const QString&);
+
+public slots:
+ virtual void contentsMovingSlot(int,int);
+ virtual void zoomRectMoved(int,int);
+ virtual void zoomRectMoveFinished();
+ virtual void slotClientException(const QString&what);
+
+protected slots:
+ virtual void readDotOutput(KProcess * proc,char * buffer,int buflen);
+ virtual void dotExit(KProcess*);
+
+protected:
+ QCanvas*m_Canvas;
+ GraphMark*m_Marker;
+ GraphTreeLabel*m_Selected;
+ QFile*dotTmpFile;
+ QString dotOutput;
+ KProcess*renderProcess;
+ trevTree m_Tree;
+ QColor getBgColor(const QString&nodeName)const;
+ bool isStart(const QString&nodeName)const;
+ const QString&getLabelstring(const QString&nodeName);
+
+ QMap m_NodeList;
+ QMap m_LabelMap;
+
+ int _xMargin,_yMargin;
+ GraphViewTipSolver*m_Tip;
+ PannerView*m_CompleteView;
+ double _cvZoom;
+ ZoomPosition m_LastAutoPosition;
+
+ virtual void resizeEvent(QResizeEvent*);
+ virtual void contentsMousePressEvent ( QMouseEvent * e );
+ virtual void contentsMouseReleaseEvent ( QMouseEvent * e );
+ virtual void contentsMouseMoveEvent ( QMouseEvent*e);
+ virtual void contentsContextMenuEvent(QContextMenuEvent*e);
+ virtual void contentsMouseDoubleClickEvent ( QMouseEvent * e );
+
+ bool _isMoving;
+ QPoint _lastPos;
+
+ bool _noUpdateZoomerPos;
+
+ QString _basePath;
+
+private:
+ void updateSizes(QSize s = QSize(0,0));
+ void updateZoomerPos();
+ void setNewDirection(int dir);
+ void makeSelected(GraphTreeLabel*);
+};
+
+#endif
Added: branches/tmp/schubi/solvertree/restreewidget.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/restreewidget.cpp?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/restreewidget.cpp (added)
+++ branches/tmp/schubi/solvertree/restreewidget.cpp Fri Jun 29 17:13:18 2007
@@ -0,0 +1,84 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 by Rajko Albrecht *
+ * ral@alwins-world.de *
+ * *
+ * 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) any later version. *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#include "restreewidget.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "resgraphview.h"
+#include "ktextbrowser.h"
+
+/*
+ * Constructs a ResTreeWidget as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ */
+ResTreeWidget::ResTreeWidget(QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+ if ( !name )
+ setName( "ResTreeWidget" );
+ ResTreeWidgetLayout = new QVBoxLayout( this, 11, 6, "ResTreeWidgetLayout");
+
+ m_Splitter = new QSplitter( this, "m_Splitter" );
+ m_Splitter->setOrientation( QSplitter::Vertical );
+
+ m_RevGraphView = new ResGraphView(m_Splitter, "m_RevGraphView" );
+ m_RevGraphView->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, 0, 2, m_RevGraphView->sizePolicy().hasHeightForWidth() ) );
+ connect(m_RevGraphView,SIGNAL(dispDetails(const QString&)),this,SLOT(setDetailText(const QString&)));
+
+ m_Detailstext = new KTextBrowser( m_Splitter, "m_Detailstext" );
+ m_Detailstext->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 0, m_Detailstext->sizePolicy().hasHeightForWidth() ) );
+ m_Detailstext->setResizePolicy( KTextBrowser::Manual );
+ ResTreeWidgetLayout->addWidget( m_Splitter );
+ resize( QSize(600, 480).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+ResTreeWidget::~ResTreeWidget()
+{
+}
+
+void ResTreeWidget::dumpRevtree()
+{
+ m_RevGraphView->dumpRevtree();
+}
+
+void ResTreeWidget::setDetailText(const QString&_s)
+{
+ m_Detailstext->setText(_s);
+ QValueList<int> list = m_Splitter->sizes();
+ if (list.count()!=2) return;
+ if (list[1]==0) {
+ int h = height();
+ int th = h/10;
+ list[0]=h-th;
+ list[1]=th;
+ m_Splitter->setSizes(list);
+ }
+}
+
+#include "restreewidget.moc"
+
Added: branches/tmp/schubi/solvertree/restreewidget.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/restreewidget.h?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/restreewidget.h (added)
+++ branches/tmp/schubi/solvertree/restreewidget.h Fri Jun 29 17:13:18 2007
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 by Rajko Albrecht *
+ * ral@alwins-world.de *
+ * *
+ * 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) any later version. *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef RESTREEWIDGET_H
+#define RESTREEWIDGET_H
+
+
+#include
+#include
+#include
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QSpacerItem;
+class ResGraphView;
+class QSplitter;
+class KTextBrowser;
+
+namespace svn {
+ class LogEntry;
+ class Client;
+}
+
+class ResTreeWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ ResTreeWidget(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ ~ResTreeWidget();
+
+ QSplitter* m_Splitter;
+ ResGraphView* m_RevGraphView;
+
+ void dumpRevtree();
+
+protected:
+ QVBoxLayout* ResTreeWidgetLayout;
+ KTextBrowser* m_Detailstext;
+
+
+protected slots:
+ virtual void setDetailText(const QString&);
+
+private:
+ QPixmap image0;
+
+};
+
+#endif // RESTREEWIDGET_H
Added: branches/tmp/schubi/solvertree/solver.dot
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/solver.dot?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/solver.dot (added)
+++ branches/tmp/schubi/solvertree/solver.dot Fri Jun 29 17:13:18 2007
@@ -0,0 +1,125 @@
+digraph "callgraph" {
+ bgcolor="transparent";
+ rankdir="TB";
+ 1[ shape=box, label="Pattern 1 Version: 1.0",];
+ 1 -> 11 [fontsize=10,style="solid"];
+ 1 -> 12 [fontsize=10,style="solid"];
+ 1 -> 13 [fontsize=10,style="solid"];
+ 1 -> 14 [fontsize=10,style="solid"];
+ 11[ shape=box, label="Package 11 Version: 1.0",];
+ 11 -> 111 [fontsize=10,style="solid"];
+ 111[ shape=box, label="Package 111 Version: 1.0",];
+ 12[ shape=box, label="Package 12 Version: 1.0",];
+ 12 -> 121 [fontsize=10,style="solid"];
+ 12 -> 122 [fontsize=10,style="solid"];
+ 121[ shape=box, label="Package 121 Version: 1.0",];
+ 122[ shape=box, label="Package 122 Version: 1.0",];
+ 13[ shape=box, label="Package 13 Version: 1.0",];
+ 13 -> 131 [fontsize=10,style="solid"];
+ 13 -> 132 [fontsize=10,style="solid"];
+ 13 -> 133 [fontsize=10,style="solid"];
+ 131[ shape=box, label="Package 131 Version: 1.0",];
+ 132[ shape=box, label="Package 132 Version: 1.0",];
+ 133[ shape=box, label="Package 133 Version: 1.0",];
+ 14[ shape=box, label="Package 14 Version: 1.0",];
+ 14 -> 141 [fontsize=10,style="solid"];
+ 14 -> 142 [fontsize=10,style="solid"];
+ 14 -> 143 [fontsize=10,style="solid"];
+ 14 -> 144 [fontsize=10,style="solid"];
+ 141[ shape=box, label="Package 141 Version: 1.0",];
+ 142[ shape=box, label="Package 142 Version: 1.0",];
+ 143[ shape=box, label="Package 143 Version: 1.0",];
+ 144[ shape=box, label="Package 144 Version: 1.0",];
+ 2[ shape=box, label="Pattern 2 Version: 1.0",];
+ 2 -> 21 [fontsize=10,style="solid"];
+ 2 -> 22 [fontsize=10,style="solid"];
+ 2 -> 23 [fontsize=10,style="solid"];
+ 2 -> 24 [fontsize=10,style="solid"];
+ 21[ shape=box, label="Package 21 Version: 1.0",];
+ 21 -> 211 [fontsize=10,style="solid"];
+ 211[ shape=box, label="Package 211 Version: 1.0",];
+ 22[ shape=box, label="Package 22 Version: 1.0",];
+ 22 -> 221 [fontsize=10,style="solid"];
+ 22 -> 222 [fontsize=10,style="solid"];
+ 221[ shape=box, label="Package 221 Version: 1.0",];
+ 222[ shape=box, label="Package 222 Version: 1.0",];
+ 23[ shape=box, label="Package 23 Version: 1.0",];
+ 23 -> 231 [fontsize=10,style="solid"];
+ 23 -> 232 [fontsize=10,style="solid"];
+ 23 -> 233 [fontsize=10,style="solid"];
+ 231[ shape=box, label="Package 231 Version: 1.0",];
+ 232[ shape=box, label="Package 232 Version: 1.0",];
+ 233[ shape=box, label="Package 233 Version: 1.0",];
+ 24[ shape=box, label="Package 24 Version: 1.0",];
+ 24 -> 241 [fontsize=10,style="solid"];
+ 24 -> 242 [fontsize=10,style="solid"];
+ 24 -> 243 [fontsize=10,style="solid"];
+ 24 -> 244 [fontsize=10,style="solid"];
+ 241[ shape=box, label="Package 241 Version: 1.0",];
+ 242[ shape=box, label="Package 242 Version: 1.0",];
+ 243[ shape=box, label="Package 243 Version: 1.0",];
+ 244[ shape=box, label="Package 244 Version: 1.0",];
+ 3[ shape=box, label="Pattern 3 Version: 1.0",];
+ 3 -> 31 [fontsize=10,style="solid"];
+ 3 -> 32 [fontsize=10,style="solid"];
+ 3 -> 33 [fontsize=10,style="solid"];
+ 3 -> 34 [fontsize=10,style="solid"];
+ 31[ shape=box, label="Package 31 Version: 1.0",];
+ 31 -> 311 [fontsize=10,style="solid"];
+ 311[ shape=box, label="Package 311 Version: 1.0",];
+ 32[ shape=box, label="Package 32 Version: 1.0",];
+ 32 -> 321 [fontsize=10,style="solid"];
+ 32 -> 322 [fontsize=10,style="solid"];
+ 321[ shape=box, label="Package 321 Version: 1.0",];
+ 322[ shape=box, label="Package 322 Version: 1.0",];
+ 33[ shape=box, label="Package 33 Version: 1.0",];
+ 33 -> 331 [fontsize=10,style="solid"];
+ 33 -> 332 [fontsize=10,style="solid"];
+ 33 -> 333 [fontsize=10,style="solid"];
+ 331[ shape=box, label="Package 331 Version: 1.0",];
+ 332[ shape=box, label="Package 332 Version: 1.0",];
+ 333[ shape=box, label="Package 333 Version: 1.0",];
+ 34[ shape=box, label="Package 34 Version: 1.0",];
+ 34 -> 341 [fontsize=10,style="solid"];
+ 34 -> 342 [fontsize=10,style="solid"];
+ 34 -> 343 [fontsize=10,style="solid"];
+ 34 -> 344 [fontsize=10,style="solid"];
+ 341[ shape=box, label="Package 341 Version: 1.0",];
+ 342[ shape=box, label="Package 342 Version: 1.0",];
+ 343[ shape=box, label="Package 343 Version: 1.0",];
+ 344[ shape=box, label="Package 344 Version: 1.0",];
+ 4[ shape=box, label="Pattern 4 Version: 1.0",];
+ 4 -> 41 [fontsize=10,style="solid"];
+ 4 -> 42 [fontsize=10,style="solid"];
+ 4 -> 43 [fontsize=10,style="solid"];
+ 4 -> 44 [fontsize=10,style="solid"];
+ 41[ shape=box, label="Package 41 Version: 1.0",];
+ 41 -> 411 [fontsize=10,style="solid"];
+ 411[ shape=box, label="Package 411 Version: 1.0",];
+ 42[ shape=box, label="Package 42 Version: 1.0",];
+ 42 -> 421 [fontsize=10,style="solid"];
+ 42 -> 422 [fontsize=10,style="solid"];
+ 421[ shape=box, label="Package 421 Version: 1.0",];
+ 422[ shape=box, label="Package 422 Version: 1.0",];
+ 43[ shape=box, label="Package 43 Version: 1.0",];
+ 43 -> 431 [fontsize=10,style="solid"];
+ 43 -> 432 [fontsize=10,style="solid"];
+ 43 -> 433 [fontsize=10,style="solid"];
+ 431[ shape=box, label="Package 431 Version: 1.0",];
+ 432[ shape=box, label="Package 432 Version: 1.0",];
+ 433[ shape=box, label="Package 433 Version: 1.0",];
+ 44[ shape=box, label="Package 44 Version: 1.0",];
+ 44 -> 441 [fontsize=10,style="solid"];
+ 44 -> 442 [fontsize=10,style="solid"];
+ 44 -> 443 [fontsize=10,style="solid"];
+ 44 -> 444 [fontsize=10,style="solid"];
+ 441[ shape=box, label="Package 441 Version: 1.0",];
+ 442[ shape=box, label="Package 442 Version: 1.0",];
+ 443[ shape=box, label="Package 443 Version: 1.0",];
+ 444[ shape=box, label="Package 444 Version: 1.0",];
+ product[ shape=box, label="SuSE SLES10 Version: 4.0",];
+ product -> 1 [fontsize=10,style="solid"];
+ product -> 2 [fontsize=10,style="solid"];
+ product -> 3 [fontsize=10,style="solid"];
+ product -> 4 [fontsize=10,style="solid"];
+}
Added: branches/tmp/schubi/solvertree/solvertree.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/solvertree.cpp?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/solvertree.cpp (added)
+++ branches/tmp/schubi/solvertree/solvertree.cpp Fri Jun 29 17:13:18 2007
@@ -0,0 +1,134 @@
+/***************************************************************************
+ * Copyright (C) 2005-2007 by Rajko Albrecht *
+ * ral@alwins-world.de *
+ * *
+ * 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) any later version. *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#include "solvertree.h"
+#include "restreewidget.h"
+#include "resgraphview.h"
+#include
+#include
+#include
+
+
+class StreeData
+{
+public:
+ StreeData();
+ virtual ~StreeData();
+
+ QTime m_stopTick;
+
+ ResTreeWidget *m_TreeDisplay;
+
+};
+
+StreeData::StreeData()
+{
+ m_TreeDisplay = 0;
+}
+
+StreeData::~StreeData()
+{
+}
+
+
+
+SolverTree::SolverTree( QWidget*treeParent)
+ :m_Valid(false)
+{
+ m_Data = new StreeData;
+
+ unsigned count = 0;
+ m_Data->m_stopTick.restart();
+ m_Data->m_TreeDisplay=new ResTreeWidget(treeParent);
+ m_Data->m_TreeDisplay->setMinimumSize ( 900, 700 );
+
+ QString n1 = "product";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n1].name="SuSE SLES10";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n1].kind="Product";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n1].source="nfs:://mounts/dist/....";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n1].version="4.0";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n1].description="Enterprise Server 10";
+
+ for (count=1; count <= 4 ; ++count) {
+
+ QString n2;
+
+ n2.setNum(count);
+
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n1].targets.append(ResGraphView::targetData(n2));
+
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n2].name="Pattern " + n2;
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n2].kind="Pattern";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n2].source="nfs:://mounts/dist/....";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n2].version="1.0";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n2].description="Patterndescription for " + n2;
+
+
+ for (int count2=1; count2 <= 4 ; ++count2) {
+
+ QString n3;
+
+ n3.setNum(count*10+count2);
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n2].targets.append(ResGraphView::targetData(n3));
+
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n3].name="Package " + n3;
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n3].kind="Package";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n3].source="nfs:://mounts/dist/....";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n3].version="1.0";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n3].description="Packagedescription for " + n3;
+
+ for (int count3=1; count3 <= count2 ; ++count3) {
+
+ QString n4;
+
+ n4.setNum(count*100+count2*10+count3);
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n3].targets.append(ResGraphView::targetData(n4));
+
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n4].name="Package " + n4;
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n4].kind="Package";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n4].source="nfs:://mounts/dist/....";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n4].version="1.0";
+ m_Data->m_TreeDisplay->m_RevGraphView->m_Tree[n4].description="Packagedescription for " + n4;
+
+ }
+ }
+ }
+
+ m_Valid=true;
+ m_Data->m_TreeDisplay->dumpRevtree();
+}
+
+SolverTree::~SolverTree()
+{
+ delete m_Data;
+}
+
+
+bool SolverTree::isValid()const
+{
+ return m_Valid;
+}
+
+
+
+QWidget*SolverTree::getView()
+{
+ return m_Data->m_TreeDisplay;
+}
+
Added: branches/tmp/schubi/solvertree/solvertree.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/schubi/solvertree/solvertree.h?rev=5857&view=auto
==============================================================================
--- branches/tmp/schubi/solvertree/solvertree.h (added)
+++ branches/tmp/schubi/solvertree/solvertree.h Fri Jun 29 17:13:18 2007
@@ -0,0 +1,44 @@
+/***************************************************************************
+ * Copyright (C) 2005-2007 by Rajko Albrecht *
+ * ral@alwins-world.de *
+ * *
+ * 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) any later version. *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef SOLVERTREE_H
+#define SOLVERTREE_H
+
+class StreeData;
+class QWidget;
+
+/**
+ @author Rajko Albrecht
+*/
+class SolverTree{
+public:
+ SolverTree( QWidget*treeParent);
+ virtual ~SolverTree();
+
+ bool isValid()const;
+ QWidget*getView();
+
+protected:
+ bool m_Valid;
+
+ StreeData*m_Data;
+
+};
+
+#endif
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org
Show replies by date
|