Monitor
|
00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 00004 ** All rights reserved. 00005 ** Contact: Nokia Corporation (qt-info@nokia.com) 00006 ** 00007 ** This file is part of the examples of the Qt Toolkit. 00008 ** 00009 ** $QT_BEGIN_LICENSE:BSD$ 00010 ** You may use this file under the terms of the BSD license as follows: 00011 ** 00012 ** "Redistribution and use in source and binary forms, with or without 00013 ** modification, are permitted provided that the following conditions are 00014 ** met: 00015 ** * Redistributions of source code must retain the above copyright 00016 ** notice, this list of conditions and the following disclaimer. 00017 ** * Redistributions in binary form must reproduce the above copyright 00018 ** notice, this list of conditions and the following disclaimer in 00019 ** the documentation and/or other materials provided with the 00020 ** distribution. 00021 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 00022 ** the names of its contributors may be used to endorse or promote 00023 ** products derived from this software without specific prior written 00024 ** permission. 00025 ** 00026 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00027 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00028 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00029 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00030 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00031 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00032 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00033 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00034 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00035 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00036 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 00037 ** $QT_END_LICENSE$ 00038 ** 00039 ****************************************************************************/ 00040 00041 #ifndef EDGE_H 00042 #define EDGE_H 00043 00047 #define MAX_TIME 3000 00048 00049 #include <QGraphicsItem> 00050 #include "stub/my-commmodel.h" 00051 #include "mainwindow.h" 00052 00053 class Node; 00054 00058 class Edge : public QGraphicsItem 00059 { 00060 public: 00061 Edge(Node *sourceNode, Node *destNode, CommModel* comm, MainWindow* mw, bool highlight); 00062 00063 Node *sourceNode() const; 00064 Node *destNode() const; 00065 00066 void adjust(); 00067 00071 enum { Type = UserType + 2 }; 00072 int type() const { return Type; } 00073 00074 bool tooShort(); 00075 00076 protected: 00077 QRectF boundingRect() const; 00078 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); 00079 00080 private: 00081 00085 Node *source* 00086 00090 Node *dest; 00091 00095 QPointF sourcePoint; 00096 00100 QPointF destPoint; 00101 00105 qreal arrowSize; 00106 00110 CommModel* myComm; 00111 00115 MainWindow* myMW; 00116 00120 bool highlighted; 00121 }; 00122 00123 #endif