[uml-devel-fr] pb programmation

[ Thread Index | Date Index | More lists.tuxfamily.org/uml-devel Archives ]


Salut tout le monde !

J'ai un petit pb de compil de la classe que j'ai développé...

J'ai un attribut de type CombinedFragmentWidget dans cette classe, mais le compilo ne détecte pas que c'est un type existant (d'ailleurs ce gland croit que c'est une fonction parce que c'est même un pointeur, et il me sort que j'ai pas mis de type de retour... bref !)... pourtant j'ai inclus le fichier "combinedfragmentwidget.h" dans le header mais rien n'y fait...

J'ai essayé de détourner le truc en déclarant class CombinedFragmentWidget; en forward declaration dans le .h et en incluant "combinedfragmentwidget.h" dans le .cpp, et là ça compile mais y a une erreur lors du linking...

Est-ce que vous avez déjà eu ce genre de merde ? Je suis pas expert du C++ mais j'ai cherché sur le net et rien n'y fait !!! Je vous joins les fichiers sur lesquels je bosse si qqn veut s'y pencher pour m'aider, sinon je vous montrerai ça dans la semaine...

++


Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.
/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   copyright (C) 2002-2006                                               *
 *   Umbrello UML Modeller Authors <uml-devel@xxxxxxxxxx>                  *
 ***************************************************************************/

// own header
#include "combinedfragmentwidget.h"

// qt includes
#include <qpainter.h>

// kde includes
#include <klocale.h>
#include <kdebug.h>
#include <kinputdialog.h>
#include <kmessagebox.h>

// app includes
#include "uml.h"
#include "umldoc.h"
#include "docwindow.h"
#include "umlview.h"
#include "listpopupmenu.h"
#include "dialogs/activitydialog.h"
#include "dialog_utils.h"
#include "floatingdashlinewidget.h"

//Added by qt3to4:
#include <QMouseEvent>
#include <QPolygon>

CombinedFragmentWidget::CombinedFragmentWidget(UMLView * view, CombinedFragmentType combinedfragmentType, Uml::IDType id ) : UMLWidget(view, id)
{
    UMLWidget::setBaseType( Uml::wt_Combined_Fragment );
    setCombinedFragmentType( combinedfragmentType );
    updateComponentSize();
    // dash line if alternative or parallel
    if (m_CombinedFragment == Alt || m_CombinedFragment == Par)
    {
        m_dashLine = new FloatingDashLineWidget(this);
    }
}

CombinedFragmentWidget::~CombinedFragmentWidget()
{
    delete(m_dashLine);
}

void CombinedFragmentWidget::draw(QPainter & p, int offsetX, int offsetY) {
    int w = width();
    int h = height();

    UMLWidget::setPen(p);

     if ( m_CombinedFragment == Ref )
     {
	if ( UMLWidget::getUseFillColour() ) {
		p.setBrush( UMLWidget::getFillColour() );
	}
     }
{
	const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
	const int fontHeight  = fm.lineSpacing();
	const QString combined_fragment_value =  getName();
	int textStartY = (h / 2) - (fontHeight / 2);
	p.drawRect(offsetX, offsetY, w, h );

	p.drawLine(offsetX,      offsetY + 20, offsetX + 45, offsetY + 20);
	p.drawLine(offsetX + 45, offsetY + 20, offsetX + 55, offsetY + 10);
	p.drawLine(offsetX + 55, offsetY + 10, offsetX + 55, offsetY);

	p.setPen(Qt::black);
	p.setFont( UMLWidget::getFont() );

    switch ( m_CombinedFragment )
    {
        case Ref :

		p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY + textStartY, w - COMBINED_FRAGMENT_MARGIN * 2 + 50, fontHeight, Qt::AlignCenter, combined_fragment_value);
	
		p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY , w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "ref");
        break;

        case Opt :
		p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
			w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "opt");
        break;

        case Break :
		p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
			w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "break");
        break;

        case Loop :
		p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
			w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "loop");
        break;

        case Neg :
		p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
			w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "neg");
        break;

        case Crit :
		p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
			w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "critical");
        break;

        case Ass :
		p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
			w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "assert");
        break;

        case Alt :
                p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
			w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "alt");
                // dash line
                m_dashLine->draw(p, offsetX, offsetY);
                
        break;

        case Par :
                p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
			w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "parallel");
                // dash line
                m_dashLine->draw(p, offsetX, offsetY);
                
        break;

	default : break;
    }
}
    if(m_bSelected)
        drawSelected(&p, offsetX, offsetY);
}

QSize CombinedFragmentWidget::calculateSize() {
    int width = 10, height = 10;
    const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
    const int fontHeight  = fm.lineSpacing();
    const int textWidth = fm.width(getName());
    height = fontHeight;
    width = textWidth + 60 > COMBINED_FRAGMENT_WIDTH ? textWidth + 60: COMBINED_FRAGMENT_WIDTH;
    height = height > COMBINED_FRAGMENT_HEIGHT ? height : COMBINED_FRAGMENT_HEIGHT;
    width += COMBINED_FRAGMENT_MARGIN * 2;
    height += COMBINED_FRAGMENT_MARGIN * 2;
    return QSize(width, height);
}

CombinedFragmentWidget::CombinedFragmentType CombinedFragmentWidget::getCombinedFragmentType() const {
    return m_CombinedFragment;
}

void CombinedFragmentWidget::setCombinedFragmentType( CombinedFragmentType combinedfragmentType ) {

    m_CombinedFragment = combinedfragmentType;
    UMLWidget::m_bResizable =  true ; //(m_CombinedFragment == Normal);
}

CombinedFragmentWidget::CombinedFragmentType CombinedFragmentWidget::getCombinedFragmentType(QString type) const {
    if(type == "Reference")
        return (CombinedFragmentWidget::Ref);
    if(type == "Option")
        return (CombinedFragmentWidget::Opt);
    if(type == "Break")
        return (CombinedFragmentWidget::Break);
    if(type == "Loop")
        return (CombinedFragmentWidget::Loop);
    if(type == "Negative")
        return (CombinedFragmentWidget::Neg);
    if(type == "Critical")
        return (CombinedFragmentWidget::Crit);
    if(type == "Assertion")
        return (CombinedFragmentWidget::Ass);
    if(type == "Alternative")
        return (CombinedFragmentWidget::Alt);

}

void CombinedFragmentWidget::setCombinedFragmentType( QString combinedfragmentType ) {

    setCombinedFragmentType(getCombinedFragmentType(combinedfragmentType) );
}

void CombinedFragmentWidget::slotMenuSelection(int sel) {
    bool done = false;

    bool ok = false;
    QString name = m_Text;

    switch( sel ) {
    case ListPopupMenu::mt_Rename:
        name = KInputDialog::getText( i18n("Enter combined Fragment Name"), i18n("Enter the name of the new combined Fragment:"), m_Text, &ok );
        if( ok && name.length() > 0 )
            m_Text = name;
        done = true;
        break;

    case ListPopupMenu::mt_Properties:
        showProperties();
        done = true;
        break;
    }

    if( !done )
        UMLWidget::slotMenuSelection( sel );
}

bool CombinedFragmentWidget::showProperties() {
//     DocWindow *docwindow = UMLApp::app()->getDocWindow();
//     docwindow->updateDocumentation(false);
// 
//     ActivityDialog dialog(m_pView, this);
//     bool modified = false;
//     if (dialog.exec() && dialog.getChangesMade()) {
//         docwindow->showDocumentation(this, true);
//         UMLApp::app()->getDocument()->setModified(true);
//         modified = true;
//     }

    return true;
}

// bool CombinedFragmentWidget::isCombinedFragment(WorkToolBar::ToolBar_Buttons tbb, CombinedFragmentType& resultType)
// {
//     bool status = true;
//     switch (tbb) {
// ;
//     case WorkToolBar::tbb_Seq_Combined_Fragment:
//         resultType = m_CombinedFragment;
//         break;
//     default:
//         status = false;
//         break;
//     }
//     return status;
// }


void CombinedFragmentWidget::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) {
    QDomElement combinedFragmentElement = qDoc.createElement( "combinedFragmentwidget" );
    UMLWidget::saveToXMI( qDoc, combinedFragmentElement );
    combinedFragmentElement.setAttribute( "combinedFragmentname", m_Text );
    combinedFragmentElement.setAttribute( "documentation", m_Doc );
    combinedFragmentElement.setAttribute( "CombinedFragmenttype", m_CombinedFragment );
    qElement.appendChild( combinedFragmentElement );
}

bool CombinedFragmentWidget::loadFromXMI( QDomElement & qElement ) {
    if( !UMLWidget::loadFromXMI( qElement ) )
        return false;
    m_Text = qElement.attribute( "combinedFragmentname", "" );
    m_Doc = qElement.attribute( "documentation", "" );
    QString type = qElement.attribute( "combinedFragmenttype", "1" );
    setCombinedFragmentType( (CombinedFragmentType)type.toInt() );
    return true;
}


#include "combinedfragmentwidget.moc"

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   copyright (C) 2002-2006                                               *
 *   Umbrello UML Modeller Authors <uml-devel@xxxxxxxxxx>                  *
 ***************************************************************************/

#ifndef COMBINEDFRAGMENTWIDGET_H
#define COMBINEDFRAGMENTWIDGET_H

#include "umlwidget.h"
#include "worktoolbar.h"
#include "floatingdashlinewidget.h"

#define COMBINED_FRAGMENT_MARGIN 5
#define COMBINED_FRAGMENT_WIDTH 100
#define COMBINED_FRAGMENT_HEIGHT 50

/**
 * This class is the graphical version of a UML combined fragment.  A combinedfragmentWidget is created
 * by a @ref UMLView.  An combinedfragmentWidget belongs to only one @ref UMLView instance.
 * When the @ref UMLView instance that this class belongs to, it will be automatically deleted.
 *
 * The combinedfragmentWidget class inherits from the @ref UMLWidget class which adds most of the functionality
 * to this class.
 *
 * @short  A graphical version of a UML combined fragment.
 * @author Hassan KOUCH <hkouch@xxxxxxxxxxx>
 * Bugs and comments to uml-devel@xxxxxxxxxxxx or http://bugs.kde.org
 */
class CombinedFragmentWidget : public UMLWidget {
    Q_OBJECT

private:
    FloatingDashLineWidget *m_dashLine ;       // dash line of an alternative or parallel combined fragment

public:
    enum CombinedFragmentType
    {
        Ref = 0,
        Opt,
        Break,
        Loop,
        Neg,
        Crit,
        Ass,
        Alt,
        Par
    };

    /**
     * Creates a Activity widget.
     *
     * @param view              The parent of the widget.
     * @param combinedfragmentType      The type of combined fragment.
     * @param id                The ID to assign (-1 will prompt a new ID.)
     */
    CombinedFragmentWidget( UMLView * view, CombinedFragmentType combinedfragmentType = Opt, Uml::IDType id = Uml::id_None );


    /**
     *  destructor
     */
    virtual ~CombinedFragmentWidget();

    /**
     * Overrides the standard paint event.
     */
    void draw(QPainter & p, int offsetX, int offsetY);

    /**
     * Returns the type of combined fragment.
     */
    CombinedFragmentType getCombinedFragmentType() const;
    CombinedFragmentType getCombinedFragmentType(QString combinedfragmentType) const;

    /**
     * Sets the type of combined fragment.
     */
    void setCombinedFragmentType( CombinedFragmentType combinedfragmentType );
    void setCombinedFragmentType( QString combinedfragmentType );
    /**
     * Show a properties dialog for a CombinedFragmentWidget.
     *
     * @return  True if we modified the Combined Fragment.
     */
    bool showProperties();

    /**
     * Determines whether a toolbar button represents a combined fragment.
     * CHECK: currently unused - can this be removed?
     *
     * @param tbb               The toolbar button enum input value.
     * @param resultType        The CombinedFragmentType corresponding to tbb.
     *                  This is only set if tbb is a CombinedFragment.
     * @return  True if tbb represents a CombinedFragment.
     */
    static bool isCombinedFragment( WorkToolBar::ToolBar_Buttons tbb,
                            CombinedFragmentType& resultType );

    /**
     * Saves the widget to the <combinedFragmentwidget> XMI element.
     */
    void saveToXMI( QDomDocument & qDoc, QDomElement & qElement );

    /**
     * Loads the widget from the <CombinedFragmentwidget> XMI element.
     */
    bool loadFromXMI( QDomElement & qElement );

protected:
    /**
     * Overrides method from UMLWidget
     */
    QSize calculateSize();

    /**
     * Type of CombinedFragment.
     */
    CombinedFragmentType m_CombinedFragment;

public slots:

    /**
     * Captures any popup menu signals for menus it created.
     */
    void slotMenuSelection(int sel);
};

#endif
/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   copyright (C) 2002-2006                                               *
 *   Umbrello UML Modeller Authors <uml-devel@xxxxxxxxxx>                  *
 ***************************************************************************/

// own header
#include "floatingdashlinewidget.h"

// app includes
#include "combinedfragmentwidget.h"

FloatingDashLineWidget::FloatingDashLineWidget(CombinedFragmentWidget *cf)
{
    m_cf = cf;
    m_y = m_cf->height() / 2;
}

FloatingDashLineWidget::~FloatingDashLineWidget(){}

void FloatingDashLineWidget::draw(QPainter & p, int offsetX, int offsetY)
{
    p.setPen(*(new QPen(UMLWidget::getLineColor(), 0, Qt::DashLine)));
    p.drawLine(offsetX, offsetY + m_y, offsetX + m_cf->width(), offsetY + m_y);
}

void FloatingDashLineWidget::setY(int y)
{
    m_y = y;
}
/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   copyright (C) 2002-2006                                               *
 *   Umbrello UML Modeller Authors <uml-devel@xxxxxxxxxx>                  *
 ***************************************************************************/

#ifndef FLOATINGDASHLINEWIDGET_H
#define FLOATINGDASHLINEWIDGET_H

#include "combinedfragmentwidget.h"

/**
 * This class is used to draw dash lines for UML combined fragments. A FloatingDashLineWidget
 * belongs to one @ref CombinedFragmentWidget instance.
 *
 * The FloatingDashLineWidget class inherits from the @ref UMLWidget class.
 *
 * @short  A dash line for UML combined fragments.
 * @author Thomas GALLINARI <tg8187@xxxxxxxx>
 * Bugs and comments to uml-devel@xxxxxxxxxxxx or http://bugs.kde.org
 */

class FloatingDashLineWidget : public UMLWidget {

public:
    /**
     * Creates a floating dash line.
     * @param cf combined fragment that the dash line belongs to
     */
    FloatingDashLineWidget(CombinedFragmentWidget *cf);

    /**
     * destructor
     */
    ~FloatingDashLineWidget();

    /**
     * Overrides the standard paint event.
     */
    void draw(QPainter & p, int offsetX, int offsetY);

    /**
     * Sets m_y
     */
    void setY(int y);

private:
    /**
     * Combined fragment that the dash line belongs to
     */
    CombinedFragmentWidget m_cf;
    
    /**
     * Value added to the y-coordinate of m_cf to obtain the y-coordinate of the dash line
     */
    int m_y;
};

#endif


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/