add some stuff to ticket editor
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Wed, 1 Dec 2010 21:30:46 +0000 (21:30 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Wed, 1 Dec 2010 21:30:46 +0000 (21:30 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@649 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

src/templates/ticketedit.cpp
src/templates/ticketedit.h

index fe0d37a..b357367 100644 (file)
 
 #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 )
@@ -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()
 {
index bf7bc8a..c2f34a8 100644 (file)
 
 #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