3 // Originally part of QCad Community Edition by Andrew Mustun
4 // Extensively rewritten and refactored by James L. Hammons
5 // (C) 2010 Underground Software
7 // JLH = James L. Hammons <jlhamm@acm.org>
10 // --- ---------- -----------------------------------------------------------
11 // JLH 05/10/2010 Created this file. :-)
14 #include "blockdialog.h"
16 #include "rs_blocklist.h"
18 BlockDialog::BlockDialog(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
19 QDialog(parent, flags), blockList(NULL)
24 BlockDialog::~BlockDialog()
28 void BlockDialog::setBlockList(RS_BlockList * l)
30 RS_DEBUG->print("BlockDialog::setBlockList");
33 if (blockList != NULL)
35 RS_Block * block = blockList->getActive();
38 ui.leName->setText(block->getName());
40 RS_DEBUG->print(RS_Debug::D_ERROR, "BlockDialog::setBlockList: No block active.");
44 RS_BlockData BlockDialog::getBlockData()
46 /*if (blockList!=NULL) {
47 RS_Block* block = blockList->getActive();
49 return blockList->rename(block, leName->text().latin1());
55 return RS_BlockData(ui.leName->text(), Vector(0.0, 0.0), false);
58 void BlockDialog::validate()
60 QString name = ui.leName->text();
64 if (blockList != NULL && blockList->find(name) == NULL)
67 QMessageBox::warning(this, tr("Renaming Block"),
68 tr("Could not name block. A block named \"%1\" already exists.").arg(ui.leName->text()),
69 QMessageBox::Ok, Qt::NoButton);
73 void BlockDialog::cancel()
75 ui.leName->setText("");