Minor formatting and documenting

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2848 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
abhishekm71
2014-02-11 05:10:16 +00:00
parent 0888f6e347
commit dd9c313914
5 changed files with 32 additions and 8 deletions

View File

@@ -488,6 +488,8 @@ void Createdxf::drawText(QString fileName, QString text,double x, double y, doub
}
/* draw aligned text in DXF Format */
// leftAlign flag added. If the alignment requested is 'fit to width' and the text length is very small,
// then the text is either centered or left-aligned, depnding on the value of leftAlign.
void Createdxf::drawTextAligned(QString fileName, QString text,double x, double y, double height, double rotation, double oblique,int hAlign, int vAlign, double xAlign,int colour,
bool leftAlign, float scale)
{

View File

@@ -24,6 +24,7 @@ qreal DiagramFolioList::colWidths[4] = {0.1, 0.55, 0.2, 0.15};
/**
* @brief DiagramFolioList::DiagramFolioList
* Constructor
* @param project QETproject *: The project from which this constructor was called. Important to setProject().
* @param parent parent QObject
*/
DiagramFolioList::DiagramFolioList( QETProject *project, QObject *parent) : Diagram(parent) {

View File

@@ -651,8 +651,7 @@ bool QETDiagramEditor::newProject() {
new_project -> setDefaultTitleBlockProperties(defaultTitleBlockProperties());
new_project -> setDefaultReportProperties(defaultReportProperties());
// add summary and new diagram
//new_project -> addNewDiagramFolioList();
// add new diagram
new_project -> addNewDiagram();
return(addProject(new_project));
@@ -1682,6 +1681,8 @@ void QETDiagramEditor::addDiagramToProject() {
void QETDiagramEditor::addDiagramFolioListToProject() {
ProjectView *current_project = currentProject();
if (current_project && current_project -> project() -> getFolioSheetsQuantity() == 0) {
// The number of folio sheets depend on the number of diagrams in the project.
int diagram_qty = current_project -> diagrams().size();
for (int i = 0; i <= diagram_qty/58; i++)
current_project -> addNewDiagramFolioList();
@@ -1805,23 +1806,28 @@ void QETDiagramEditor::removeDiagramFromProject() {
if (DiagramView *current_diagram = current_project -> currentDiagram()) {
can_update_actions = false;
bool isFolioList = false;
// if diagram to remove is a "folio list sheet", then set a flag.
if (DiagramFolioList *ptr = dynamic_cast<DiagramFolioList *>(current_diagram -> diagram()))
isFolioList = true;
current_project -> removeDiagram(current_diagram);
// if the removed diagram was a folio sheet, then delete all the remaining folio sheets also.
if (isFolioList) {
foreach (DiagramView *diag, current_project -> diagrams()) {
if (DiagramFolioList *ptr = dynamic_cast<DiagramFolioList *>(diag -> diagram())) {
current_project -> removeDiagram(diag);
}
}
//current_project ->project() ->setFolioSheetsQuantity(0);
// else if after diagram removal, the total diagram quantity becomes a factor of 58, then
// remove one (last) folio sheet.
} else if (current_project -> diagrams().size() % 58 == 0) {
foreach (DiagramView *diag, current_project -> diagrams()) {
DiagramFolioList *ptr = dynamic_cast<DiagramFolioList *>(diag -> diagram());
if (ptr && ptr -> getId() == current_project -> project() -> getFolioSheetsQuantity() - 1) {
current_project -> removeDiagram(diag);
//int folioQuantity = current_project -> project() -> getFolioSheetsQuantity();
//current_project -> project() -> setFolioSheetsQuantity(folioQuantity - 1);
}
}
}

View File

@@ -172,10 +172,18 @@ QETProject::ProjectState QETProject::state() const {
return(state_);
}
/**
Get the folioSheetQuantity
@return folio Sheets Quantity.
*/
int QETProject::getFolioSheetsQuantity() const {
return(folioSheetsQuantity);
}
/**
Set the folioSheetQuantity to quantity
@param New value of quantity to be set.
*/
void QETProject::setFolioSheetsQuantity(int quantity) {
folioSheetsQuantity = quantity;
}
@@ -453,6 +461,8 @@ QDomDocument QETProject::toXml() {
QDomElement project_root = xml_doc.createElement("project");
project_root.setAttribute("version", QET::version);
project_root.setAttribute("title", project_title_);
// write the present value of folioSheetsQuantity to XML.
project_root.setAttribute("folioSheetQuantity", QString::number(folioSheetsQuantity));
xml_doc.appendChild(project_root);
@@ -481,6 +491,8 @@ QDomDocument QETProject::toXml() {
// qDebug() << "Export XML de" << diagrams_.count() << "schemas";
int order_num = 1;
foreach(Diagram *diagram, diagrams_) {
// Write the diagram to XML only if it is not of type DiagramFolioList.
DiagramFolioList *ptr = dynamic_cast<DiagramFolioList *>(diagram);
if ( !ptr ) {
qDebug() << qPrintable(QString("QETProject::toXml() : exporting diagram \"%1\" [%2]").arg(diagram -> title()).arg(QET::pointerString(diagram)));
@@ -966,6 +978,8 @@ void QETProject::readProjectXml() {
// la racine du document XML est sensee etre un element "project"
if (root_elmt.tagName() == "project") {
// if there is an attribute for folioSheetQuantity, then set it accordingly.
// If not, then the value remains at the initial value of zero.
if (root_elmt.hasAttribute("folioSheetQuantity"))
setFolioSheetsQuantity(root_elmt.attribute("folioSheetQuantity","0").toInt());
@@ -1065,6 +1079,7 @@ void QETProject::readDiagramsXml() {
d->initElementsLinks();
}
// If the folio sheets quantity is non-zero, then add the folio sheets
if (getFolioSheetsQuantity()) {
setFolioSheetsQuantity(0);
int diagCount = diagrams().size();

View File

@@ -74,8 +74,8 @@ class QETProject : public QObject {
public:
ProjectState state() const;
QList<Diagram *> diagrams() const;
int getFolioSheetsQuantity() const;
void setFolioSheetsQuantity(int);
int getFolioSheetsQuantity() const; /// get the folio sheets quantity for this project
void setFolioSheetsQuantity(int); /// set the folio sheets quantity for this project
int folioIndex(const Diagram *) const;
ElementsCollection *embeddedCollection() const;
TitleBlockTemplatesProjectCollection *embeddedTitleBlockTemplatesCollection();
@@ -177,7 +177,7 @@ class QETProject : public QObject {
QDomDocument document_root_;
/// Diagrams carried by the project
QList<Diagram *> diagrams_;
/// Folio List Sheet is added to this project.
/// Folio List Sheets quantity for this project.
int folioSheetsQuantity;
/// Embedded elements collection
XmlElementsCollection *collection_;