DlgProjectInformationImp.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2006 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #include "PreCompiled.h"
00025 
00026 #include <App/Document.h>
00027 #include <App/PropertyStandard.h>
00028 
00029 #include "DlgProjectInformationImp.h"
00030 #include "Document.h"
00031 
00032 using namespace Gui::Dialog;
00033 
00034 /* TRANSLATOR Gui::Dialog::DlgProjectInformationImp */
00035 
00043 DlgProjectInformationImp::DlgProjectInformationImp( App::Document* doc, QWidget* parent, Qt::WFlags fl )
00044   : QDialog( parent, fl ), _doc(doc)
00045 {
00046     this->setupUi(this);
00047     lineEditName->setText(QString::fromUtf8(doc->Label.getValue()));
00048     lineEditPath->setText(QString::fromUtf8(doc->FileName.getValue()));
00049     lineEditCreator->setText(QString::fromUtf8(doc->CreatedBy.getValue()));
00050     lineEditDate->setText(QString::fromUtf8(doc->CreationDate.getValue()));
00051     lineEditLastMod->setText(QString::fromUtf8(doc->LastModifiedBy.getValue()));
00052     lineEditLastModDate->setText(QString::fromUtf8(doc->LastModifiedDate.getValue()));
00053     lineEditCompany->setText(QString::fromUtf8(doc->Company.getValue()));
00054 
00055     // When saving the text to XML the newlines get lost. So we store also the newlines as '\n'.
00056     // See also accept().
00057     QString comment = QString::fromUtf8(doc->Comment.getValue());
00058     QStringList lines = comment.split(QLatin1String("\\n"), QString::KeepEmptyParts);
00059     QString text = lines.join(QLatin1String("\n"));
00060     textEditComment->setPlainText( text );
00061 }
00062 
00066 DlgProjectInformationImp::~DlgProjectInformationImp()
00067 {
00068   // no need to delete child widgets, Qt does it all for us
00069 }
00070 
00074 void DlgProjectInformationImp::accept()
00075 {
00076     _doc->CreatedBy.setValue(lineEditCreator->text().toUtf8());
00077     _doc->LastModifiedBy.setValue(lineEditCreator->text().toUtf8());
00078     _doc->Company.setValue(lineEditCompany->text().toUtf8());
00079 
00080     // Replace newline escape sequence trough '\\n' string
00081     QStringList lines = textEditComment->toPlainText().split
00082         (QLatin1String("\n"), QString::KeepEmptyParts);
00083     QString text = lines.join(QLatin1String("\\n"));
00084     _doc->Comment.setValue(text.isEmpty() ? "" : text.toUtf8());
00085 
00086     QDialog::accept();
00087 }
00088 

Generated on Wed Nov 23 19:00:06 2011 for FreeCAD by  doxygen 1.6.1