3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/10/2010 Created this file. :-)
17 #include "blockdialog.h"
19 #include "blocklist.h"
22 BlockDialog::BlockDialog(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
23 QDialog(parent, flags), blockList(NULL)
28 BlockDialog::~BlockDialog()
32 void BlockDialog::setBlockList(BlockList * l)
34 DEBUG->print("BlockDialog::setBlockList");
37 if (blockList != NULL)
39 Block * block = blockList->getActive();
42 ui.leName->setText(block->getName());
44 DEBUG->print(Debug::D_ERROR, "BlockDialog::setBlockList: No block active.");
48 BlockData BlockDialog::getBlockData()
50 /*if (blockList!=NULL) {
51 Block* block = blockList->getActive();
53 return blockList->rename(block, leName->text().latin1());
59 return BlockData(ui.leName->text(), Vector(0.0, 0.0), false);
62 void BlockDialog::validate()
64 QString name = ui.leName->text();
68 if (blockList != NULL && blockList->find(name) == NULL)
71 QMessageBox::warning(this, tr("Renaming Block"),
72 tr("Could not name block. A block named \"%1\" already exists.").arg(ui.leName->text()),
73 QMessageBox::Ok, Qt::NoButton);
77 void BlockDialog::cancel()
79 ui.leName->setText("");