mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-24 20:27:22 +01:00
refs #889
This commit is contained in:
parent
c2bf2b0be9
commit
e5ef064c0e
@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#include "FWCmdBasic.h"
|
||||
#include <QDebug>
|
||||
|
||||
using namespace libfwbuilder;
|
||||
|
||||
@ -34,10 +35,35 @@ FWCmdBasic::FWCmdBasic(ProjectPanel *project)
|
||||
|
||||
FWObject* FWCmdBasic::getObject()
|
||||
{
|
||||
return getObject(id);
|
||||
return getObject(obj_id);
|
||||
}
|
||||
|
||||
FWObject* FWCmdBasic::getObject(int id)
|
||||
{
|
||||
return project->db()->findInIndex(id);
|
||||
}
|
||||
|
||||
bool FWCmdBasic::mergeWith(const QUndoCommand *other)
|
||||
{
|
||||
qDebug() << "FWCmdBasic::mergeWith(const QUndoCommand *other)";
|
||||
qDebug() << "cmd:" << other->text();
|
||||
|
||||
const FWCmdTerm* term = dynamic_cast<const FWCmdTerm*> (other);
|
||||
|
||||
return term != 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void undoAndRemoveLastCommand(QUndoStack* undoStack)
|
||||
{
|
||||
qDebug() << "undoAndRemoveLastCommand(QUndoStack undoStack)";
|
||||
undoStack->undo();
|
||||
qDebug() << "count:" << undoStack->count();
|
||||
if (undoStack->count() == 1) {
|
||||
undoStack->clear();
|
||||
} else {
|
||||
FWCmdTerm* cmd = new FWCmdTerm();
|
||||
undoStack->push(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,8 @@
|
||||
#define FWCMDBASIC_H
|
||||
|
||||
#include <QUndoCommand>
|
||||
#include <QUndoStack>
|
||||
#include <QDebug>
|
||||
|
||||
#include "ProjectPanel.h"
|
||||
|
||||
@ -34,18 +36,29 @@
|
||||
|
||||
class FWCmdBasic : public QUndoCommand
|
||||
{
|
||||
int id;
|
||||
int obj_id;
|
||||
protected:
|
||||
|
||||
ProjectPanel *project;
|
||||
|
||||
public:
|
||||
FWCmdBasic(ProjectPanel *project);
|
||||
int objectId() {return id;}
|
||||
void setObject(libfwbuilder::FWObject *object) {id = object->getId();}
|
||||
int objectId() {return obj_id;}
|
||||
void setObject(libfwbuilder::FWObject *object) {obj_id = object->getId();}
|
||||
libfwbuilder::FWObject* getObject();
|
||||
libfwbuilder::FWObject* getObject(int id);
|
||||
int id() const {return 1;}
|
||||
bool mergeWith(const QUndoCommand *other);
|
||||
|
||||
};
|
||||
|
||||
class FWCmdTerm : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
FWCmdTerm() : QUndoCommand() {setText("Terminator");}
|
||||
int id() const {return 1;}
|
||||
};
|
||||
|
||||
void undoAndRemoveLastCommand(QUndoStack* undoStack);
|
||||
|
||||
#endif // FWCMDBASIC_H
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user