diff --git a/src/qtgui/preview_w.cpp b/src/qtgui/preview_w.cpp index d5d18d7f..214e4477 100644 --- a/src/qtgui/preview_w.cpp +++ b/src/qtgui/preview_w.cpp @@ -330,6 +330,15 @@ PreviewTextEdit *Preview::currentEditor() return edit; } +// Save current document to file +void Preview::emitSaveDocToFile() +{ + PreviewTextEdit *ce = currentEditor(); + if (ce && !ce->m_dbdoc.url.empty()) { + emit saveDocToFile(ce->m_dbdoc); + } +} + // Perform text search. If next is true, we look for the next match of the // current search, trying to advance and possibly wrapping around. If next is // false, the search string has been modified, we search for the new string, @@ -891,6 +900,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum) if (!textempty) fdoc.text.clear(); editor->m_fdoc = fdoc; + editor->m_dbdoc = idoc; if (textempty) editor->displayFields(); @@ -998,6 +1008,11 @@ void PreviewTextEdit::createPopupMenu(const QPoint& pos) popup->addAction(tr("Select All"), this, SLOT(selectAll())); popup->addAction(tr("Copy"), this, SLOT(copy())); popup->addAction(tr("Print"), this, SLOT(print())); + // Need to check ipath until we fix the internfile bug that always + // has it convert to html for top level docs + if (!m_dbdoc.url.empty() && !m_dbdoc.ipath.empty()) + popup->addAction(tr("Save document to file"), + m_preview, SLOT(emitSaveDocToFile())); popup->popup(mapToGlobal(pos)); } diff --git a/src/qtgui/preview_w.h b/src/qtgui/preview_w.h index 0cdd6395..4ecd3b20 100644 --- a/src/qtgui/preview_w.h +++ b/src/qtgui/preview_w.h @@ -51,7 +51,9 @@ public slots: virtual void displayImage(); virtual void print(); virtual void createPopupMenu(const QPoint& pos); + friend class Preview; + protected: void mouseDoubleClickEvent(QMouseEvent *); @@ -65,6 +67,8 @@ private: // doc out of internfile (previous fields come from the index) with // main text erased (for space). Rcl::Doc m_fdoc; + // The input doc out of the index/query list + Rcl::Doc m_dbdoc; // Saved rich (or plain actually) text: the textedit seems to // sometimes (but not always) return its text stripped of tags, so // this is needed (for printing for example) @@ -115,6 +119,7 @@ public slots: virtual void prevPressed(); virtual void currentChanged(QWidget *tw); virtual void closeCurrentTab(); + virtual void emitSaveDocToFile(); signals: void previewClosed(Preview *); @@ -123,6 +128,7 @@ signals: void showPrev(Preview *w, int sid, int docnum); void previewExposed(Preview *w, int sid, int docnum); void printCurrentPreviewRequest(); + void saveDocToFile(Rcl::Doc); private: // Identifier of search in main window. This is used to check that diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index 291ca997..7cf6e8e1 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -808,6 +808,8 @@ void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod) this, SLOT(previewPrevInTab(Preview *, int, int))); connect(curPreview, SIGNAL(previewExposed(Preview *, int, int)), this, SLOT(previewExposed(Preview *, int, int))); + connect(curPreview, SIGNAL(saveDocToFile(Rcl::Doc)), + this, SLOT(saveDocToFile(Rcl::Doc))); curPreview->setWindowTitle(getQueryDescription()); curPreview->show(); }