Fri, 16 Aug 2013 23:24:57 +0300
Added action "add history line" for adding new history entries
changelog.txt | file | annotate | diff | comparison | revisions | |
src/actions.h | file | annotate | diff | comparison | revisions | |
src/gui_editactions.cpp | file | annotate | diff | comparison | revisions | |
src/ui/addhistoryline.ui | file | annotate | diff | comparison | revisions | |
src/ui/ldforge.ui | file | annotate | diff | comparison | revisions |
--- 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
--- 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
--- 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<LDCommentObject*> (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
--- /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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>AddHistoryLine</class> + <widget class="QDialog" name="AddHistoryLine"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>410</width> + <height>120</height> + </rect> + </property> + <property name="windowTitle"> + <string>Add History Line</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Date:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QDateEdit" name="m_date"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Username:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="m_username"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Comment:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="m_comment"/> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>AddHistoryLine</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>AddHistoryLine</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</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 @@ <x>0</x> <y>0</y> <width>900</width> - <height>26</height> + <height>22</height> </rect> </property> <widget class="QMenu" name="menuFile"> @@ -173,6 +173,8 @@ <addaction name="actionInlineDeep"/> <addaction name="actionMakePrimitive"/> <addaction name="separator"/> + <addaction name="actionAddHistoryLine"/> + <addaction name="separator"/> <addaction name="actionSplitQuads"/> <addaction name="actionEditRaw"/> <addaction name="actionBorders"/> @@ -1264,6 +1266,11 @@ <string>Download From...</string> </property> </action> + <action name="actionAddHistoryLine"> + <property name="text"> + <string>Add History Line</string> + </property> + </action> </widget> <resources> <include location="../../ldforge.qrc"/>