#include "ticketedit.h"
+#include<QMenu>
+#include<QMenuBar>
+#include<QAction>
+#include<QStatusBar>
+#include<QFileDialog>
+
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 )
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()
{
#include <QMainWindow>
+/**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