ebuild, remove edge fix

master
Denes Matetelki 14 years ago
parent 77960e146a
commit 113c28dba3

@ -41,6 +41,12 @@ public:
const char* what() const throw(); const char* what() const throw();
}; };
class EdgeDoesntExistsBetweenNodesException : public std::exception
{
public:
const char* what() const throw();
};
// commands: // commands:

@ -8,7 +8,7 @@ inherit qt4-r2
DESCRIPTION="MindMap software written in Qt" DESCRIPTION="MindMap software written in Qt"
HOMEPAGE="https://gitorious.org/qtmindmap" HOMEPAGE="https://gitorious.org/qtmindmap"
SRC_URI="http://matetelki.com/qtmindmap/qtmindmap-qtmindmap-master.tar.gz" SRC_URI="http://matetelki.com/qtmindmap/qtmindmap-0.2.tar.gz"
LICENSE="GPL-2" LICENSE="GPL-2"
# some functions introduced in qt 4.6 # some functions introduced in qt 4.6

@ -34,6 +34,12 @@ const char* EdgeExistsBetweenNodesException::what() const throw()
toStdString().c_str(); toStdString().c_str();
} }
const char* EdgeDoesntExistsBetweenNodesException::what() const throw()
{
return QObject::tr("There is no edge between these two nodes.").
toStdString().c_str();
}
InsertNodeCommand::InsertNodeCommand(GraphLogic *graphLogic) InsertNodeCommand::InsertNodeCommand(GraphLogic *graphLogic)
: m_graphLogic(graphLogic) : m_graphLogic(graphLogic)
@ -102,7 +108,6 @@ void InsertNodeCommand::redo()
m_node->setPos(m_pos); m_node->setPos(m_pos);
// m_graphLogic->addEdge(m_activeNode, m_node);
m_edge->sourceNode()->addEdge(m_edge,true); m_edge->sourceNode()->addEdge(m_edge,true);
m_edge->destNode()->addEdge(m_edge,false); m_edge->destNode()->addEdge(m_edge,false);
m_graphLogic->m_graphWidget->scene()->addItem(m_edge); m_graphLogic->m_graphWidget->scene()->addItem(m_edge);
@ -209,9 +214,6 @@ AddEdgeCommand::AddEdgeCommand(GraphLogic *graphLogic, Node *source, Node *desti
, m_source(source) , m_source(source)
, m_destination(destinaion) , m_destination(destinaion)
{ {
if (!m_activeNode)
throw NoActiveNodeException();
if (m_destination == m_graphLogic->m_nodeList.first()) if (m_destination == m_graphLogic->m_nodeList.first())
throw BaseNodeCannotBeEdgeTargetException(); throw BaseNodeCannotBeEdgeTargetException();
@ -272,6 +274,9 @@ RemoveEdgeCommand::RemoveEdgeCommand(GraphLogic *graphLogic, Node *source, Node
, m_destination(destinaion) , m_destination(destinaion)
, m_edge(source->edgeTo(destinaion)) , m_edge(source->edgeTo(destinaion))
{ {
if (!m_source->isConnected(m_destination))
throw EdgeDoesntExistsBetweenNodesException();
setText(QObject::tr("Edge releted between \"").append( setText(QObject::tr("Edge releted between \"").append(
m_source->toPlainText()).append( m_source->toPlainText()).append(
QObject::tr("\" and \"").append( QObject::tr("\" and \"").append(

@ -91,6 +91,7 @@ bool GraphLogic::processKeyEvent(QKeyEvent *event)
if (m_showingNodeNumbers && if (m_showingNodeNumbers &&
event->key() >= Qt::Key_0 && event->key() <= Qt::Key_9) event->key() >= Qt::Key_0 && event->key() <= Qt::Key_9)
{ {
/// @todo remove magic number
appendNumber(event->key()-48); appendNumber(event->key()-48);
return true; return true;
} }
@ -713,22 +714,15 @@ void GraphLogic::addEdge(Node *source, Node *destination)
void GraphLogic::removeEdge(Node *source, Node *destination) void GraphLogic::removeEdge(Node *source, Node *destination)
{ {
if (!m_activeNode) try
{
emit notification(tr("No active node."));
return;
}
if (!source->isConnected(destination))
{ {
setActiveNode(destination); QUndoCommand *addEdgeCommand = new RemoveEdgeCommand(this, source, destination);
emit notification(tr("There no edge between these two nodes.")); m_undoStack->push(addEdgeCommand);
} }
else catch (std::exception &e)
{ {
source->deleteEdge(destination); emit notification(e.what());
setActiveNode(destination); return;
emit contentChanged();
} }
} }

Loading…
Cancel
Save