mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 08:34:38 +03:00
fix #7 Дизайнер падает при удалении нескольких объектов
This commit is contained in:
parent
8d6e9d36e4
commit
8c32925b85
@ -503,6 +503,27 @@ CommandIf::Ptr createBandDeleteCommand(PageDesignIntf* page, BandDesignIntf* ban
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CommandIf::Ptr PageDesignIntf::removeReportItemCommand(BaseDesignIntf *item){
|
||||||
|
BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(item);
|
||||||
|
if (band){
|
||||||
|
CommandIf::Ptr command = createBandDeleteCommand(this,band);
|
||||||
|
return command;
|
||||||
|
} else {
|
||||||
|
LayoutDesignIntf* layout = dynamic_cast<LayoutDesignIntf*>(item->parent());
|
||||||
|
if (layout && (layout->childrenCount()==2)){
|
||||||
|
CommandGroup::Ptr commandGroup = CommandGroup::create();
|
||||||
|
commandGroup->addCommand(DeleteLayoutCommand::create(this, layout),false);
|
||||||
|
commandGroup->addCommand(DeleteItemCommand::create(this,item),false);
|
||||||
|
return commandGroup;
|
||||||
|
} else {
|
||||||
|
CommandIf::Ptr command = (dynamic_cast<LayoutDesignIntf*>(item))?
|
||||||
|
DeleteLayoutCommand::create(this, dynamic_cast<LayoutDesignIntf*>(item)) :
|
||||||
|
DeleteItemCommand::create(this, item) ;
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PageDesignIntf::removeReportItem(BaseDesignIntf *item, bool createComand)
|
void PageDesignIntf::removeReportItem(BaseDesignIntf *item, bool createComand)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1117,22 +1138,52 @@ void PageDesignIntf::paste()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageDesignIntf::deleteSelected(bool createCommand)
|
void PageDesignIntf::deleteSelected()
|
||||||
{
|
{
|
||||||
int bandCount = 0;
|
if (selectedItems().count()==1){
|
||||||
foreach(QGraphicsItem* item, selectedItems()){
|
saveCommand(removeReportItemCommand(dynamic_cast<BaseDesignIntf*>(selectedItems().at(0))));
|
||||||
BandDesignIntf* bd = dynamic_cast<BandDesignIntf*>(item);
|
} else {
|
||||||
if (bd) bandCount++;
|
|
||||||
|
QList<QGraphicsItem*> itemsToDelete = selectedItems();
|
||||||
|
|
||||||
|
|
||||||
|
CommandGroup::Ptr commandGroup = CommandGroup::create();
|
||||||
|
|
||||||
|
QList<BandDesignIntf*> bands;
|
||||||
|
QList<QGraphicsItem*>::iterator it;
|
||||||
|
|
||||||
|
for(it = itemsToDelete.begin(); it != itemsToDelete.end();){
|
||||||
|
BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(*it);
|
||||||
|
if (band) {
|
||||||
|
bands.append(band);
|
||||||
|
it = itemsToDelete.erase(it);
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
if (bandCount>1) {
|
|
||||||
QMessageBox::warning(0,tr("Warning"),tr("Multi band deletion not allowed"));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(QGraphicsItem* item, selectedItems()){
|
foreach (BandDesignIntf* band, bands){
|
||||||
if (!dynamic_cast<PageItemDesignIntf*>(item))
|
foreach (QGraphicsItem* bandItem, band->childItems()) {
|
||||||
removeReportItem(dynamic_cast<BaseDesignIntf*>(item),createCommand);
|
itemsToDelete.removeOne(bandItem);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!itemsToDelete.isEmpty()){
|
||||||
|
foreach(QGraphicsItem* item, itemsToDelete){
|
||||||
|
if (!dynamic_cast<PageItemDesignIntf*>(item))
|
||||||
|
commandGroup->addCommand(removeReportItemCommand(dynamic_cast<BaseDesignIntf*>(item)),false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bands.isEmpty()){
|
||||||
|
foreach (BandDesignIntf* band, bands) {
|
||||||
|
commandGroup->addCommand(removeReportItemCommand(band),false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
saveCommand(commandGroup);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageDesignIntf::cut()
|
void PageDesignIntf::cut()
|
||||||
|
@ -111,6 +111,7 @@ namespace LimeReport {
|
|||||||
BaseDesignIntf* addReportItem(const QString& itemType, QObject *owner=0, BaseDesignIntf *parent=0);
|
BaseDesignIntf* addReportItem(const QString& itemType, QObject *owner=0, BaseDesignIntf *parent=0);
|
||||||
BaseDesignIntf* createReportItem(const QString& itemType, QObject *owner=0, BaseDesignIntf *parent=0);
|
BaseDesignIntf* createReportItem(const QString& itemType, QObject *owner=0, BaseDesignIntf *parent=0);
|
||||||
void removeReportItem(BaseDesignIntf* item, bool createComand = true);
|
void removeReportItem(BaseDesignIntf* item, bool createComand = true);
|
||||||
|
CommandIf::Ptr removeReportItemCommand(BaseDesignIntf *item);
|
||||||
bool saveCommand(CommandIf::Ptr command, bool runCommand = true);
|
bool saveCommand(CommandIf::Ptr command, bool runCommand = true);
|
||||||
|
|
||||||
bool isCanRedo();
|
bool isCanRedo();
|
||||||
@ -194,7 +195,7 @@ namespace LimeReport {
|
|||||||
void redo();
|
void redo();
|
||||||
void copy();
|
void copy();
|
||||||
void paste();
|
void paste();
|
||||||
void deleteSelected(bool createCommand);
|
void deleteSelected();
|
||||||
void cut();
|
void cut();
|
||||||
void setToSaved();
|
void setToSaved();
|
||||||
void bringToFront();
|
void bringToFront();
|
||||||
|
@ -251,7 +251,7 @@ void ReportDesignWidget::deleteItem(QGraphicsItem *item){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ReportDesignWidget::deleteSelectedItems(){
|
void ReportDesignWidget::deleteSelectedItems(){
|
||||||
activePage()->deleteSelected(true);
|
activePage()->deleteSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ReportDesignWidget::datasourcesNames(){
|
QStringList ReportDesignWidget::datasourcesNames(){
|
||||||
@ -405,7 +405,6 @@ void ReportDesignWidget::setFont(const QFont& font)
|
|||||||
|
|
||||||
void ReportDesignWidget::setTextAlign(const bool& horizontalAlign, const Qt::AlignmentFlag& alignment)
|
void ReportDesignWidget::setTextAlign(const bool& horizontalAlign, const Qt::AlignmentFlag& alignment)
|
||||||
{
|
{
|
||||||
//activePage()->setTextAlign(alignment);
|
|
||||||
activePage()->changeSelectedGrpoupTextAlignPropperty(horizontalAlign, alignment);
|
activePage()->changeSelectedGrpoupTextAlignPropperty(horizontalAlign, alignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user