8#include "GuiEditFile.h"
9#include "UserInterface.h"
81 QStatusBar *statusBar =
new QStatusBar(
m_editWin);
85 QMenuBar *menuBar =
new QMenuBar(
m_editWin);
86 QMenu *fileMenu = menuBar->addMenu(
"&File");
90 m_open->setShortcut(Qt::CTRL + Qt::Key_O);
91 m_open->setText(
"&Open...");
92 m_open->setToolTip(
"Open File");
93 QString whatsThis =
"Open a file to edit";
94 m_open->setWhatsThis(whatsThis);
95 connect(
m_open, SIGNAL(triggered()),
this, SLOT(
open()));
96 fileMenu->addAction(
m_open);
100 m_save->setShortcut(Qt::CTRL + Qt::Key_S);
101 m_save->setText(
"&Save...");
102 m_save->setToolTip(
"Save File");
103 m_save->setWhatsThis(
"Save the current file");
105 fileMenu->addAction(
m_save);
110 m_saveAs->setShortcut(Qt::CTRL + Qt::Key_A);
111 m_saveAs->setToolTip(
"Save As File");
112 m_saveAs->setWhatsThis(
"Save the current file into another file");
119 m_close->setShortcut(Qt::CTRL + Qt::Key_C);
120 m_close->setToolTip(
"Close File");
121 m_close->setWhatsThis(
"Close the current file");
126 m_exit = menuBar->addAction(
"&Exit");
127 m_exit->setShortcut(Qt::CTRL + Qt::Key_E);
128 m_exit->setText(
"&Exit...");
129 m_exit->setToolTip(
"Exit");
130 m_exit->setWhatsThis(
"Exit the Editor");
197 if(QMessageBox::question((
QWidget *)parent(), tr(
"Save File?"),
198 tr(
"Are you sure you want to save this file?"),
199 tr(
"&Save"), tr(
"&Cancel"),
205 QString sFilterList(
"All files (*)");
206 QDir currDir = QDir::current();
207 QString sOpen(
"Open");
210 connect(fileDialog, SIGNAL(fileSelected(QString)),
this, SLOT(
OpenFile(QString)));
220 if(QMessageBox::question((
QWidget *)parent(), tr(
"Save File?"),
221 tr(
"Changes have been made to the file. Do you want to Save?"),
222 QMessageBox::Save, QMessageBox::No) == QMessageBox::Save) {
241 if(psOutFile.isEmpty()){
242 QMessageBox::information((
QWidget *)parent(),
"Error",
"No output file selected");
257 qint64 lineLength =
m_editFile->readLine(buf,
sizeof(buf));
258 while (lineLength != -1) {
259 bufStr = QString(buf);
263 lineLength =
m_editFile->readLine(buf,
sizeof(buf));
267 m_txtEdit->append(
"\nThis file cannot be edited. Please check the file's Write permissions");
281 out <<
m_txtEdit->document()->toPlainText();
292 QString sFilterList(
"All files (*)");
293 QDir currDir = QDir::current();
294 QString sOpen(
"Open");
299 allPButtons[0]->setText(
"&Save");
301 allPButtons[1]->setText(
"&Close");
303 saveAsDialog->show();
304 connect(saveAsDialog, SIGNAL(fileSelected(QString)),
this, SLOT(
saveAsFile(QString)));
333 m_editFile->open(QFile::ReadWrite | QFile::Truncate);
File name manipulation and expansion.
Opens a window in Gui Application to be able to edit, save and create text files.
QAction * m_exit
Action Exit.
bool m_textChanged
Flag to indicate text changed.
static void EditFile(UserInterface &pUI, QString psFile="")
Creates a single instance of the GuiEditFile.
void saveAsFile(QString)
Save the contents of text editor to another file.
void showWindow(QString psFile="")
If there is already an instance of this object, then display the window.
QString m_fileName
Current file open.
QAction * m_close
Action Close.
void saveAs()
For action File->Save As.
void clearFile()
Delete the contents of a file.
QAction * m_open
Actioons.
QMainWindow * m_editWin
Editor window.
void OpenFile(QString)
To display the contents of an opened file.
void windowTitle(QString &psfile)
display only the file base name
GuiEditFile(UserInterface &pUI, QString psFile="")
Constructor.
void setTextChanged()
Indicator that the text has changed.
QAction * m_save
Action Save.
QWidget * m_parent
Parent widget.
static GuiEditFile * m_instance
Instance of this object - singleton.
void closeFile()
For action File->Close.
~GuiEditFile()
Destructor.
QFile * m_editFile
File pointer to current file.
void closeWin()
For action Exit (close the window)
void saveFile()
For action File->Save.
QTextEdit * m_txtEdit
Text Editor.
void open()
For action File->Open.
QAction * m_saveAs
Action Save As.
Command Line and Xml loader, validation, and access.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.