# HG changeset patch # User Santeri Piippo # Date 1376684697 -10800 # Node ID df1b5b902eb74c25642c511f82dbe1e4cafda804 # Parent ce2009d50c61cd8ce45d859e36111b86ce389e8c Added action "add history line" for adding new history entries diff -r ce2009d50c61 -r df1b5b902eb7 changelog.txt --- a/changelog.txt Wed Aug 07 20:50:53 2013 +0300 +++ b/changelog.txt Fri Aug 16 23:24:57 2013 +0300 @@ -12,6 +12,7 @@ - Fixed: "Hi-Res" was not prepended to the names of 48/ primitives. - Fixed: Checking the Hi-Res option would not allow segment values over 16. - Added support for multiple spaces before the ring number. +- Added new action "Add History Line" for quickly inserting 0 !HISTORY lines to headers - Added support for '0 BFC CLIP' and '0 BFC NOCLIP' and added auto-correction from errorneous MLCAD syntax ('0 BFC CERTIFY CLIP'). - If the vertex snapper finds a vertex closer than 4 pixels, it likely is the vertex being looked for diff -r ce2009d50c61 -r df1b5b902eb7 src/actions.h --- a/src/actions.h Wed Aug 07 20:50:53 2013 +0300 +++ b/src/actions.h Fri Aug 16 23:24:57 2013 +0300 @@ -85,5 +85,6 @@ act (RotateZNeg) act (RotateZPos) act (RotationPoint) +act (AddHistoryLine) #undef act \ No newline at end of file diff -r ce2009d50c61 -r df1b5b902eb7 src/gui_editactions.cpp --- a/src/gui_editactions.cpp Wed Aug 07 20:50:53 2013 +0300 +++ b/src/gui_editactions.cpp Fri Aug 16 23:24:57 2013 +0300 @@ -33,6 +33,7 @@ #include "ui_replcoords.h" #include "ui_editraw.h" #include "ui_flip.h" +#include "ui_addhistoryline.h" cfg (bool, edit_schemanticinline, false); @@ -654,4 +655,59 @@ log (ForgeWindow::tr ("Auto-colored: new color is [%1] %2"), colnum, getColor (colnum)->name); g_win->refresh(); +} + +// ============================================================================= +// ----------------------------------------------------------------------------- +DEFINE_ACTION (AddHistoryLine, 0) { + LDObject* obj; + bool ishistory = false, + prevIsHistory = false; + + QDialog* dlg = new QDialog; + Ui_AddHistoryLine* ui = new Ui_AddHistoryLine; + ui->setupUi (dlg); + ui->m_date->setDate (QDate::currentDate()); + ui->m_comment->setFocus(); + + if (!dlg->exec()) + return; + + // Create the comment object based on input + str commentText = fmt ("!HISTORY %1 [%2] %3", + ui->m_date->date().toString("yyyy-MM-dd"), + ui->m_username->text(), + ui->m_comment->text()); + + LDCommentObject* comm = new LDCommentObject (commentText); + + // Find a spot to place the new comment + for ( + obj = LDFile::current()->object (0); + obj && obj->next() && !obj->next()->isScemantic(); + obj = obj->next() + ) { + LDCommentObject* comm = dynamic_cast (obj); + if (comm && comm->text.startsWith ("!HISTORY ")) + ishistory = true; + + if (prevIsHistory && !ishistory) { + // Last line was history, this isn't, thus insert the new history + // line here. + break; + } + + prevIsHistory = ishistory; + } + + int idx = obj ? obj->getIndex() : 0; + LDFile::current()->insertObj (idx++, comm); + + // If we're adding a history line right before a scemantic object, pad it + // an empty line + if (obj && obj->next() && obj->next()->isScemantic()) + LDFile::current()->insertObj (idx, new LDEmptyObject); + + g_win->buildObjList(); + delete ui; } \ No newline at end of file diff -r ce2009d50c61 -r df1b5b902eb7 src/ui/addhistoryline.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/addhistoryline.ui Fri Aug 16 23:24:57 2013 +0300 @@ -0,0 +1,98 @@ + + + AddHistoryLine + + + + 0 + 0 + 410 + 120 + + + + Add History Line + + + + + + + + Date: + + + + + + + + + + Username: + + + + + + + + + + Comment: + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + AddHistoryLine + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AddHistoryLine + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff -r ce2009d50c61 -r df1b5b902eb7 src/ui/ldforge.ui --- a/src/ui/ldforge.ui Wed Aug 07 20:50:53 2013 +0300 +++ b/src/ui/ldforge.ui Fri Aug 16 23:24:57 2013 +0300 @@ -70,7 +70,7 @@ 0 0 900 - 26 + 22 @@ -173,6 +173,8 @@ + + @@ -1264,6 +1266,11 @@ Download From... + + + Add History Line + +