--- a/src/gui_actions.cpp Sat May 25 01:44:11 2013 +0300 +++ b/src/gui_actions.cpp Sat May 25 02:05:35 2013 +0300 @@ -297,7 +297,7 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -MAKE_ACTION (insertFrom, "Insert from File", "insert-from", "Insert LDraw data from a file.", (0)) { +MAKE_ACTION (insertFrom, "Insert from File", "file-import", "Insert LDraw data from a file.", (0)) { str fname = QFileDialog::getOpenFileName (); ulong idx = g_win->getInsertionPoint (); @@ -335,6 +335,30 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= +MAKE_ACTION (exportTo, "Export To File", "file-export", "Export current selection to file", (0)) { + if (g_win->sel ().size () == 0) + return; + + str fname = QFileDialog::getSaveFileName (); + if (fname.len () == 0) + return; + + QFile file (fname); + if (!file.open (QIODevice::WriteOnly | QIODevice::Text)) { + critical (fmt ("Unable to open %s for writing (%s)", fname.chars (), strerror (errno))); + return; + } + + for (LDObject* obj : g_win->sel ()) { + str contents = obj->getContents (); + file.write (contents, contents.len ()); + file.write ("\r\n", 2); + } +} + +// ============================================================================= +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +// ============================================================================= MAKE_ACTION (insertRaw, "Insert Raw", "insert-raw", "Type in LDraw code to insert.", (0)) { ulong idx = g_win->getInsertionPoint ();