From 6c35d422242d1d47dcf535398d6f3afa18735506 Mon Sep 17 00:00:00 2001 From: konrad Date: Wed, 1 Dec 2010 21:30:46 +0000 Subject: [PATCH] add some stuff to ticket editor git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@649 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/templates/ticketedit.cpp | 58 +++++++++++++++++++++++++++++++++++++++++- src/templates/ticketedit.h | 16 +++++++++++- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/src/templates/ticketedit.cpp b/src/templates/ticketedit.cpp index fe0d37a..b357367 100644 --- a/src/templates/ticketedit.cpp +++ b/src/templates/ticketedit.cpp @@ -12,9 +12,32 @@ #include "ticketedit.h" +#include +#include +#include +#include +#include + MTicketEditor::MTicketEditor(QWidget* parent, Qt::WindowFlags f): QMainWindow(parent, f) { - + //menu + QMenuBar*mb=menuBar(); + QMenu*m=mb->addMenu(tr("&File")); + m->addAction(tr("&Open File..."),this,SLOT(openFile())); + m->addAction(tr("&Save"),this,SLOT(saveFile())); + m->addAction(tr("Save &as..."),this,SLOT(saveFileAs())); + m->addSeparator(); + m->addAction(tr("&Download from server..."),this,SLOT(download())); + m->addAction(tr("&Upload to server..."),this,SLOT(upload())); + m->addSeparator(); + m->addAction(tr("&Close"),this,SLOT(close())); + m=mb->addMenu(tr("&Edit")); + m->addAction(tr("Add Item")); + m->addAction(tr("Delete Item")); + + //statusbar + statusBar()->setSizeGripEnabled(true); + setAttribute(Qt::WA_DeleteOnClose); } void MTicketEditor::loadFile(QString ) @@ -24,8 +47,41 @@ void MTicketEditor::loadFile(QString ) void MTicketEditor::openFile() { + QString fn=QFileDialog::getOpenFileName(this,tr("Open Ticket Template")); + if(fn!=""){ + mFileName=fn; + loadFile(fn); + } +} + +void MTicketEditor::saveFile() +{ + if(mFileName.left(2)==":/" || mFileName=="") + saveFileAs(); + else + saveFile(mFileName); +} +void MTicketEditor::saveFile ( QString ) +{ + +} +void MTicketEditor::saveFileAs() +{ + QString fn=QFileDialog::getSaveFileName(this,tr("Save Ticket Template"),mFileName); + if(fn!=""){ + mFileName=fn; + saveFile(fn); + } +} +void MTicketEditor::download() +{ } +void MTicketEditor::upload() +{ + +} + void MTicketEditor::rerender() { diff --git a/src/templates/ticketedit.h b/src/templates/ticketedit.h index bf7bc8a..c2f34a8 100644 --- a/src/templates/ticketedit.h +++ b/src/templates/ticketedit.h @@ -15,19 +15,33 @@ #include +/**An editor for ticket templates.*/ class MTicketEditor:public QMainWindow { Q_OBJECT public: + ///instantiates the editor MTicketEditor(QWidget* parent = 0, Qt::WindowFlags f = 0); public slots: + ///loads a template file, this is a helper for openFile and download void loadFile(QString); + ///shows a file open dialog and then opens the selected file void openFile(); + ///saves the file - if it is local, otherwise calls saveFileAs + void saveFile(); + ///asks for a new file name + void saveFileAs(); + ///helper for saveFile and upload + void saveFile(QString); + ///downloads a file from the server + void download(); + ///sends the file to the server + void upload(); private slots: void rerender(); private: - + QString mFileName; }; #endif -- 1.7.2.5