Ask filename for saved reports

This commit is contained in:
Mark Watkins 2011-12-02 01:57:06 +10:00
parent c330aa6eea
commit 66895f38a8
3 changed files with 21 additions and 1 deletions

View File

@ -2638,3 +2638,11 @@ gGraph *gGraphView::findGraph(QString name)
if (i==m_graphsbytitle.end()) return NULL;
return i.value();
}
int gGraphView::visibleGraphs()
{
int cnt=0;
for (int i=0;i<m_graphs.size();i++) {
if (!m_graphs[i]->isEmpty() && m_graphs[i]->visible()) cnt++;
}
return cnt;
}

View File

@ -433,6 +433,7 @@ public:
void updateScrollBar();
void updateScale(); // update scale & Scrollbar
void resetLayout();
int visibleGraphs();
int horizTravel() { return m_horiz_travel; }
void setEmptyText(QString s) { m_emptytext=s; }

View File

@ -651,8 +651,19 @@ EventList *packEventList(EventList *ev)
void MainWindow::PrintReport(gGraphView *gv,QString name)
{
if (!gv) return;
QDate d=QDate::currentDate();
QString filename=PREF.Get("{home}/"+name+"_{user}.pdf");
if (gv->visibleGraphs()==0) {
Notify("There are no graphs visible to print");
return;
}
QString filename=QFileDialog::getSaveFileName(this,"Select filename to save PDF report to",PREF.Get("{home}/"+name+"_{user}_"+d.toString(Qt::ISODate)+".pdf"),"PDF Files (*.pdf)");
if (filename.isEmpty())
return;
Notify("Saving "+name+" report as \""+filename+"\".");
//QString filename=PREF.Get("{home}/"+name+"_{user}.pdf");
QPrinter printer(QPrinter::ScreenResolution); //QPrinter::HighResolution); //QPrinter::ScreenResolution);
printer.setOutputFileName(filename);
printer.setOrientation(QPrinter::Portrait);