So I'm not opposed to adding this... but reading the code I can't help but
feel that this is a bit incomplete...

On Mon, Oct 03, 2016 at 09:31:03PM +0200, Robert Helling wrote:
> 
> diff --git a/desktop-widgets/divelogexportdialog.cpp 
> b/desktop-widgets/divelogexportdialog.cpp
> index 5b58d0c..395c494 100644
> --- a/desktop-widgets/divelogexportdialog.cpp
> +++ b/desktop-widgets/divelogexportdialog.cpp
> @@ -86,6 +86,8 @@ void DiveLogExportDialog::showExplanation()
>               ui->description->setText(tr("Subsurface native XML format."));
>       } else if (ui->exportImageDepths->isChecked()) {
>               ui->description->setText(tr("Write depths of images to file."));
> +     } else if (ui->exportTeX->isChecked()) {
> +             ui->description->setText(tr("Write dive as TeX macros to 
> file."));
>       }
>  }
>  
> @@ -162,6 +164,10 @@ void DiveLogExportDialog::on_buttonBox_accepted()
>                       filename = QFileDialog::getSaveFileName(this, tr("Save 
> image depths"), lastDir);
>                       if (!filename.isNull() && !filename.isEmpty())
>                               export_depths(filename.toUtf8().data(), 
> ui->exportSelected->isChecked());
> +             } else if (ui->exportTeX->isChecked()) {
> +                     filename = QFileDialog::getSaveFileName(this, 
> tr("Export to TeX file"), lastDir, tr("TeX files(*.tex)"));
> +                     if (!filename.isNull() && !filename.isEmpty())
> +                             export_TeX(filename.toUtf8().data(), 
> ui->exportSelected->isChecked());
>               }
>               break;
>       case 1:

OK, so we add the UI handling

> @@ -223,3 +229,30 @@ void DiveLogExportDialog::export_depths(const char 
> *filename, const bool selecte
>       }
>       free_buffer(&buf);
>  }
> +
> +void DiveLogExportDialog::export_TeX(const char *filename, const bool 
> selected_only)
> +{
> +     FILE *f;
> +     struct dive *dive;
> +     depth_t depth;
> +     int i;
> +     const char *unit = NULL;
> +
> +     struct membuffer buf = {};
> +
> +     for_each_dive (i, dive) {
> +             if (selected_only && !dive->selected)
> +                     continue;
> +
> +             put_format(&buf, "\\number{%d}\n", dive->number);
> +     }
> +
> +     f = subsurface_fopen(filename, "w+");
> +     if (!f) {
> +             report_error(tr("Can't open file %s").toUtf8().data(), 
> filename);
> +     } else {
> +             flush_buffer(&buf, f); /*check for writing errors? */
> +             fclose(f);
> +     }
> +     free_buffer(&buf);
> +}

We write the dive numbers.

> diff --git a/desktop-widgets/divelogexportdialog.h 
> b/desktop-widgets/divelogexportdialog.h
> index e7cde31..5d5ad14 100644
> --- a/desktop-widgets/divelogexportdialog.h
> +++ b/desktop-widgets/divelogexportdialog.h
> @@ -33,6 +33,7 @@ private:
>       void showExplanation();
>       void exportHtmlInit(const QString &filename);
>       void export_depths(const char *filename, const bool selected_only);
> +     void export_TeX(const char *filename, const bool selected_only);
>  };
>  
>  #endif // DIVELOGEXPORTDIALOG_H
> diff --git a/desktop-widgets/divelogexportdialog.ui 
> b/desktop-widgets/divelogexportdialog.ui
> index 4713bf0..d01f817 100644
> --- a/desktop-widgets/divelogexportdialog.ui
> +++ b/desktop-widgets/divelogexportdialog.ui
> @@ -192,6 +192,16 @@
>             </widget>
>            </item>
>            <item>
> +           <widget class="QRadioButton" name="exportTeX">
> +            <property name="text">
> +             <string>TeX</string>
> +            </property>
> +            <attribute name="buttonGroup">
> +             <string notr="true">exportGroup</string>
> +            </attribute>
> +           </widget>
> +          </item>
> +          <item>
>             <widget class="QRadioButton" name="exportImageDepths">
>              <property name="text">
>               <string>I&amp;mage depths</string>

Add the UI


Ummm. There is more TeX somewhere, right?

/D
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to