266 title += fmt (": %1", basename (getCurrentDocument()->getName())); |
266 title += fmt (": %1", basename (getCurrentDocument()->getName())); |
267 else |
267 else |
268 title += fmt (": <anonymous>"); |
268 title += fmt (": <anonymous>"); |
269 |
269 |
270 if (getCurrentDocument()->getObjectCount() > 0 && |
270 if (getCurrentDocument()->getObjectCount() > 0 && |
271 getCurrentDocument()->getObject (0)->getType() == LDObject::EComment) |
271 getCurrentDocument()->getObject (0)->type() == LDObject::EComment) |
272 { |
272 { |
273 // Append title |
273 // Append title |
274 LDComment* comm = static_cast<LDComment*> (getCurrentDocument()->getObject (0)); |
274 LDComment* comm = static_cast<LDComment*> (getCurrentDocument()->getObject (0)); |
275 title += fmt (": %1", comm->text); |
275 title += fmt (": %1", comm->text); |
276 } |
276 } |
328 |
328 |
329 for (LDObject* obj : getCurrentDocument()->getObjects()) |
329 for (LDObject* obj : getCurrentDocument()->getObjects()) |
330 { |
330 { |
331 QString descr; |
331 QString descr; |
332 |
332 |
333 switch (obj->getType()) |
333 switch (obj->type()) |
334 { |
334 { |
335 case LDObject::EComment: |
335 case LDObject::EComment: |
336 { |
336 { |
337 descr = static_cast<LDComment*> (obj)->text; |
337 descr = static_cast<LDComment*> (obj)->text; |
338 |
338 |
339 // Remove leading whitespace |
339 // Remove leading whitespace |
340 while (descr[0] == ' ') |
340 while (descr[0] == ' ') |
341 descr.remove (0, 1); |
341 descr.remove (0, 1); |
342 } break; |
342 |
|
343 break; |
|
344 } |
343 |
345 |
344 case LDObject::EEmpty: |
346 case LDObject::EEmpty: |
345 break; // leave it empty |
347 break; // leave it empty |
346 |
348 |
347 case LDObject::ELine: |
349 case LDObject::ELine: |
352 for (int i = 0; i < obj->vertices(); ++i) |
354 for (int i = 0; i < obj->vertices(); ++i) |
353 { |
355 { |
354 if (i != 0) |
356 if (i != 0) |
355 descr += ", "; |
357 descr += ", "; |
356 |
358 |
357 descr += obj->getVertex (i).toString (true); |
359 descr += obj->vertex (i).toString (true); |
358 } |
360 } |
359 } break; |
361 break; |
|
362 } |
360 |
363 |
361 case LDObject::EError: |
364 case LDObject::EError: |
362 { |
365 { |
363 descr = fmt ("ERROR: %1", obj->raw()); |
366 descr = fmt ("ERROR: %1", obj->asText()); |
364 } break; |
367 break; |
|
368 } |
365 |
369 |
366 case LDObject::EVertex: |
370 case LDObject::EVertex: |
367 { |
371 { |
368 descr = static_cast<LDVertex*> (obj)->pos.toString (true); |
372 descr = static_cast<LDVertex*> (obj)->pos.toString (true); |
369 } break; |
373 break; |
|
374 } |
370 |
375 |
371 case LDObject::ESubfile: |
376 case LDObject::ESubfile: |
372 { |
377 { |
373 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
378 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
374 |
379 |
376 |
381 |
377 for (int i = 0; i < 9; ++i) |
382 for (int i = 0; i < 9; ++i) |
378 descr += fmt ("%1%2", ref->getTransform()[i], (i != 8) ? " " : ""); |
383 descr += fmt ("%1%2", ref->getTransform()[i], (i != 8) ? " " : ""); |
379 |
384 |
380 descr += ')'; |
385 descr += ')'; |
381 } break; |
386 break; |
|
387 } |
382 |
388 |
383 case LDObject::EBFC: |
389 case LDObject::EBFC: |
384 { |
390 { |
385 descr = LDBFC::statements[static_cast<LDBFC*> (obj)->type]; |
391 descr = LDBFC::k_statementStrings[static_cast<LDBFC*> (obj)->m_statement]; |
386 } break; |
392 break; |
|
393 } |
387 |
394 |
388 case LDObject::EOverlay: |
395 case LDObject::EOverlay: |
389 { |
396 { |
390 LDOverlay* ovl = static_cast<LDOverlay*> (obj); |
397 LDOverlay* ovl = static_cast<LDOverlay*> (obj); |
391 descr = fmt ("[%1] %2 (%3, %4), %5 x %6", g_CameraNames[ovl->getCamera()], |
398 descr = fmt ("[%1] %2 (%3, %4), %5 x %6", g_CameraNames[ovl->getCamera()], |
392 basename (ovl->getFileName()), ovl->getX(), ovl->getY(), |
399 basename (ovl->getFileName()), ovl->getX(), ovl->getY(), |
393 ovl->getWidth(), ovl->getHeight()); |
400 ovl->getWidth(), ovl->getHeight()); |
|
401 break; |
394 } |
402 } |
395 break; |
|
396 |
403 |
397 default: |
404 default: |
398 { |
405 { |
399 descr = obj->getTypeName(); |
406 descr = obj->typeName(); |
400 } break; |
407 break; |
|
408 } |
401 } |
409 } |
402 |
410 |
403 QListWidgetItem* item = new QListWidgetItem (descr); |
411 QListWidgetItem* item = new QListWidgetItem (descr); |
404 item->setIcon (getIcon (obj->getTypeName())); |
412 item->setIcon (getIcon (obj->typeName())); |
405 |
413 |
406 // Use italic font if hidden |
414 // Use italic font if hidden |
407 if (obj->isHidden()) |
415 if (obj->isHidden()) |
408 { |
416 { |
409 QFont font = item->font(); |
417 QFont font = item->font(); |
410 font.setItalic (true); |
418 font.setItalic (true); |
411 item->setFont (font); |
419 item->setFont (font); |
412 } |
420 } |
413 |
421 |
414 // Color gibberish orange on red so it stands out. |
422 // Color gibberish orange on red so it stands out. |
415 if (obj->getType() == LDObject::EError) |
423 if (obj->type() == LDObject::EError) |
416 { |
424 { |
417 item->setBackground (QColor ("#AA0000")); |
425 item->setBackground (QColor ("#AA0000")); |
418 item->setForeground (QColor ("#FFAA00")); |
426 item->setForeground (QColor ("#FFAA00")); |
419 } |
427 } |
420 elif (lv_colorize && obj->isColored() && obj->getColor() != maincolor && obj->getColor() != edgecolor) |
428 elif (lv_colorize && obj->isColored() && obj->getColor() != maincolor && obj->getColor() != edgecolor) |
534 // ----------------------------------------------------------------------------- |
542 // ----------------------------------------------------------------------------- |
535 int MainWindow::getInsertionPoint() |
543 int MainWindow::getInsertionPoint() |
536 { |
544 { |
537 // If we have a selection, put the item after it. |
545 // If we have a selection, put the item after it. |
538 if (!selection().isEmpty()) |
546 if (!selection().isEmpty()) |
539 return selection().last()->getIndex() + 1; |
547 return selection().last()->lineNumber() + 1; |
540 |
548 |
541 // Otherwise place the object at the end. |
549 // Otherwise place the object at the end. |
542 return getCurrentDocument()->getObjectCount(); |
550 return getCurrentDocument()->getObjectCount(); |
543 } |
551 } |
544 |
552 |
646 const bool single = (selection().size() == 1); |
654 const bool single = (selection().size() == 1); |
647 LDObject* singleObj = (single) ? selection()[0] : null; |
655 LDObject* singleObj = (single) ? selection()[0] : null; |
648 |
656 |
649 QMenu* contextMenu = new QMenu; |
657 QMenu* contextMenu = new QMenu; |
650 |
658 |
651 if (single && singleObj->getType() != LDObject::EEmpty) |
659 if (single && singleObj->type() != LDObject::EEmpty) |
652 { |
660 { |
653 contextMenu->addAction (ui->actionEdit); |
661 contextMenu->addAction (ui->actionEdit); |
654 contextMenu->addSeparator(); |
662 contextMenu->addSeparator(); |
655 } |
663 } |
656 |
664 |
735 obj = it; |
743 obj = it; |
736 break; |
744 break; |
737 } |
745 } |
738 } |
746 } |
739 |
747 |
740 AddObjectDialog::staticDialog (obj->getType(), obj); |
748 AddObjectDialog::staticDialog (obj->type(), obj); |
741 } |
749 } |
742 |
750 |
743 // ============================================================================= |
751 // ============================================================================= |
744 // ----------------------------------------------------------------------------- |
752 // ----------------------------------------------------------------------------- |
745 bool MainWindow::save (LDDocument* f, bool saveAs) |
753 bool MainWindow::save (LDDocument* f, bool saveAs) |