~ubuntu-branches/ubuntu/precise/fritzing/precise

« back to all changes in this revision

Viewing changes to src/partseditor/partseditormainwindow.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Georges Khaznadar
  • Date: 2011-08-26 10:11:05 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110826101105-w5hmn7zcf93ig5v6
Tags: 0.6.3b-1
* upgrapded to the newer upstream version
* parameters of the function GraphicsUtils::distanceFromLine in 
  src/svg/groundplanegenerator.cpp:767 are now declared as doubles,
  which Closes: #636441
* the new version fixes src/utils/folderutils.cpp, which
  Closes: #636061

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
********************************************************************
20
20
 
21
 
$Revision: 5143 $:
 
21
$Revision: 5388 $:
22
22
$Author: cohen@irascible.com $:
23
 
$Date: 2011-07-01 02:37:01 +0200 (Fri, 01 Jul 2011) $
 
23
$Date: 2011-08-11 15:17:12 +0200 (Thu, 11 Aug 2011) $
24
24
 
25
25
********************************************************************/
26
26
 
59
59
QString PartsEditorMainWindow::UntitledPartName;
60
60
QString PartsEditorMainWindow::___partsEditorName___;
61
61
 
62
 
const QString PartsEditorMainWindow::templatePath = "/docs/templates/";
63
 
 
64
62
int PartsEditorMainWindow::UntitledPartIndex = 1;
65
63
QPointer<PartsEditorMainWindow> PartsEditorMainWindow::m_lastOpened = NULL;
66
64
int PartsEditorMainWindow::m_closedBeforeCount = 0;
69
67
#ifdef QT_NO_DEBUG
70
68
        #define CORE_EDITION_ENABLED false
71
69
#else
72
 
        #define CORE_EDITION_ENABLED true
 
70
        #define CORE_EDITION_ENABLED false
73
71
#endif
74
72
 
75
73
 
134
132
        m_paletteModel = new PaletteModel(false, false, false);
135
133
 
136
134
        if(modelPart == NULL){
137
 
                if (fromTemplate && !createTemplate()){
138
 
                        QMessageBox::critical(this, tr("Parts Editor"),
139
 
                                   tr("Error! Cannot create part file.\n"),
140
 
                                   QMessageBox::Close);
141
 
                // this seems hacky but maybe it's ok
142
 
                QTimer::singleShot(60, this, SLOT(close()));
143
 
                        return;
144
 
                }
145
135
                m_lastOpened = this;
146
136
                m_updateEnabled = true;
147
137
        } else {
461
451
        return item;
462
452
}
463
453
 
464
 
// creates a temp directory and copies all template .fz and .svg files
465
 
// returns false if directory can't be created
466
 
bool PartsEditorMainWindow::createTemplate(){
467
 
        QDir srcDir = QDir(":/resources/part-template");
468
 
        DebugDialog::debug("template source: " + srcDir.path());
469
 
 
470
 
        QDir randDir = createTempFolderIfNecessary();
471
 
 
472
 
        FolderUtils::replicateDir(srcDir,randDir);
473
 
 
474
 
        QFile tempFile(QCoreApplication::applicationDirPath() + templatePath);
475
 
        tempFile.copy(randDir.path() + "/core/template" + FritzingPartExtension);
476
 
 
477
 
        m_fileName = randDir.path() + "/core/template" + FritzingPartExtension;
478
 
        DebugDialog::debug("created temp part: " + m_fileName);
479
 
 
480
 
        return true;
481
 
}
482
 
 
483
454
const QDir& PartsEditorMainWindow::createTempFolderIfNecessary() {
484
455
        if(m_tempDir.path() == ".") {
485
456
                QString randext = FolderUtils::getRandText();
503
474
 
504
475
bool PartsEditorMainWindow::save() {
505
476
        if(validateMinRequirements() && wannaSaveAfterWarning(false)) {
506
 
                bool result = FritzingWindow::save();
 
477
                bool result = (m_saveButton->isEnabled()) ? FritzingWindow::save() : saveAs();
507
478
                if(result) {
508
479
                        m_cancelCloseButton->setText(tr("close"));
509
480
                        if(m_closeAfterSaving) close();
789
760
                        event->ignore();
790
761
                        ProcessEventBlocker::processEvents();
791
762
#ifdef Q_WS_MAC
792
 
                        FritzingWindow *parent = dynamic_cast<FritzingWindow*>(parentWidget());
 
763
                        FritzingWindow *parent = qobject_cast<FritzingWindow*>(parentWidget());
793
764
                        if(parent) {
794
765
                                parent->notClosableForAWhile();
795
766
                        }