--- as_gui.cpp 2002/11/18 22:31:12 1.13
+++ as_gui.cpp 2002/11/18 22:38:04 1.14
@@ -1,11 +1,7 @@
-// Qt headers
-#include <qfile.h>
-#include <qfiledialog.h>
-
// User interface
#include "titraq.h" // Main classes
#include "titrex.h" // Exception classes
-#include "generic.h" // Generic classes
+
// Overload init for custom initialization of the app
void Titraqform::init(void)
@@ -62,199 +58,6 @@
}
//
-// Add a blank row entry to the current data window
-//
-void Titraqform::addEntry(void)
-{
- Prototype Unimp;
- Unimp.doMbox();
-// if (!pTable->text().isEmpty()) {
-// QTableRow *pRow = new QTableRow;
-// pRow->setText(0, NULL);
-// pRow->setText(1, NULL);
-// pRow->setText(2, NULL);
-// pRow->setText(3, NULL);
-// }
-}
-
-//
-// Choose a file using a handy file dialog
-//
-void Titraqform::delEntry(void)
-{
- Prototype Unimp;
- Unimp.doMbox();
-}
-
-//
-// Write current data to a meta device
-//
-void Titraqform::writeEntry(void)
-{
- Prototype Unimp;
- Unimp.doMbox();
-}
-
-//
-// Make and display a new document window
-//
-void Titraqform::newDoc(void)
-{
- Prototype Unimp;
- Unimp.doMbox();
-// Titraqform *pNewform = new Titraqform;
-// pNewform->show();
-}
-
-//
-// Choose a file using a handy file dialog
-//
-void Titraqform::choose(void)
-{
- QString Filestring = QFileDialog::getOpenFileName(QString::null, QString::null, this);
- if (!Filestring.isEmpty())
- load(Filestring);
- else
- m_pStatbar->message(trUtf8("Loading aborted"), 4000);
-}
-
-//
-// Load accounting data into main window
-//
-void Titraqform::load(const QString &Filestring)
-{
- QFile Filetemp(Filestring); // File to load
-
- if (!Filetemp.open(IO_ReadOnly)) // Need a wrapped exception here
- return;
-
- QTextStream Textstream(&Filetemp); // Convert the file contents to a stream
- m_pStatus->setText(Textstream.read());
- m_pStatus->setEdited(false);
- setCaption(Filestring);
- m_pStatbar->message(trUtf8("Loaded document ") + Filestring, 4000);
-}
-
-//
-// Serialize current state to the current file
-//
-void Titraqform::save(void)
-{
- // First time saves are really just saveAs in disguise
- if (m_szFilename->isEmpty()) {
- saveAs();
- return;
- }
-
- // Try to read the status text, and write it to a file
- QString Statustext = m_pStatus->text();
- QFile Filetemp(*m_szFilename);
- if (!Filetemp.open(IO_WriteOnly)) {
- m_pStatbar->message(QString(trUtf8("Could not write to %1")).arg(*m_szFilename), 4000);
- return;
- }
-
- // Serialize file contents and write to text line
- QTextStream Filestream(&Filetemp);
- Filestream << Statustext;
- Filetemp.close();
-
- // Reset the text line, and give output to main window
- m_pStatus->setEdited(FALSE);
- setCaption(*m_szFilename);
- m_pStatbar->message(QString(trUtf8("File %1 saved")).arg(*m_szFilename), 4000);
- m_bDirt = false; // Set the clean state to allow a close operation
-}
-
-//
-// Serialize current state to a selected file
-//
-void Titraqform::saveAs(void)
-{
- // First get the selected file name to save to
- QString Filestring = QFileDialog::getSaveFileName(QString::null, QString::null, this);
- if (!Filestring.isEmpty()) {
- *m_szFilename = Filestring;
- m_pStatus->setText(*m_szFilename);
- save(); // Finish off by calling the save action
- }
- else {
- // User did not select a valid file and push okay button
- m_pStatbar->message(trUtf8("Saving aborted"), 4000);
- }
-}
-
-//
-// Close current document, displaying in main window
-//
-void Titraqform::closeEvent(QCloseEvent *pClosit)
-{
- // Check modification state of current data
- if (!this->isDirty()) {
- pClosit->accept();
- return;
- }
-
- // Ask user to acknowlege a possibly data-damaging close event
- switch(QMessageBox::information(this, "OSSP titraq",
- trUtf8("The document has been\nchanged since the last save.")),
- trUtf8("Save Now"), trUtf8("Cancel"), trUtf8("Leave Anyway"), 0, 1) {
- case 0:
- save();
- pClosit->accept();
- break;
- case 1:
- default: // Just for sanity
- pClosit->ignore();
- break;
- case 2:
- pClosit->accept();
- break;
- }
-}
-
-//
-// Check to see if state has changed since last save
-//
-bool Titraqform::isDirty(void)
-{
- return m_bDirt;
-}
-
-//
-// Learn more about this program itself
-//
-void Titraqform::about(void)
-{
- QMessageBox::about(this, "OSSP titraq",
- trUtf8("OSSP titraq is a time and task-based\n"
- "accounting system that acts as both a\n"
- "nwork-like punch card and time tracker."));
-}
-
-//
-// Learn more about the OSSP
-//
-void Titraqform::aboutOSSP(void)
-{
- QMessageBox::about(this, "OSSP",
- trUtf8("The open source software project (OSSP) is\n"
- "a collective effort aimed at implementing\n"
- "high-quality Unix software components,\n"
- "ranging from networking, multi-threading\n"
- "and algorithmic libraries to networking\n"
- "servers and development tools."));
-}
-
-//
-// Learn more about this program and Qt
-//
-void Titraqform::aboutQt(void)
-{
- QMessageBox::aboutQt(this, "OSSP titraq");
-}
-
-//
// Destroy the object and free any allocated resources
//
Titraqform::~Titraqform(void)
|