Index: ossp-pkg/as/as-gui/as_gui.cpp RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_gui.cpp,v rcsdiff -q -kk '-r1.10' '-r1.11' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_gui.cpp,v' 2>/dev/null --- as_gui.cpp 2002/11/14 21:01:29 1.10 +++ as_gui.cpp 2002/11/14 22:26:30 1.11 @@ -13,6 +13,7 @@ #include "titraq.h" // Main classes #include "generic.h" // Generic classes #include "gfx/ossplogo.xpm" // OSSP logo: static const char *s_kpcOssplogo_xpm[] +#include "gfx/filenew.xpm" // static const char *s_kpcFilenew_xpm[] #include "gfx/fileopen.xpm" // static const char *s_kpcFileopen_xpm[] #include "gfx/filesave.xpm" // static const char *s_kpcFilesave_xpm[] @@ -22,7 +23,7 @@ // Set fill color of buttons m_pAddbutton->setPaletteBackgroundColor(QColor(196, 196, 176)); m_pDeletebutton->setPaletteBackgroundColor(QColor(196, 196, 176)); - m_pWritebutton->setPaletteBackgroundColor(QColor(196, 196, 176)); + m_pWritebutton->setPaletteBackgroundColor(QColor(206, 192, 176)); m_pQuitbutton->setPaletteBackgroundColor(QColor(196, 196, 176)); m_pMaintable->setCurrentCell(0, 0); // Set the initial focus m_pMaintable->setFocus(); // Focus on the table @@ -46,36 +47,52 @@ setName(trUtf8("Titraqform")); resize(600, 480); m_pMenubar = menuBar(); // Setup the menu bar -// m_pMenubar = new QMenuBar(this, "Menubar"); -// m_pStatbar = new QStatusBar(this, "Statusbar"); m_pStatbar = statusBar(); // Setup the status bar setCaption("OSSP Titraq"); +// // Lock down window size +// setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, +// (QSizePolicy::SizeType)0, 0, 0, sizePolicy().hasHeightForWidth())); + + // Early member initialization + m_bDirt = false; + m_szFilename = new QString(); + + // Make an easter egg ;-) + QToolTip::add(m_pMenubar, QRect(0, 0, 2, 2), "Easter egg"); + // File new action - m_pFilenewact = new QAction(trUtf8("New"), trUtf8("&New"), CTRL+Key_N, this, "New"); + m_pFilenewact = new QAction(trUtf8("New File"), QPixmap(s_kpcFilenew_xpm), trUtf8("&New"), CTRL+Key_N, this, "New"); connect(m_pFilenewact, SIGNAL(activated()), this, SLOT(newDoc())); + QMimeSourceFactory::defaultFactory()->setPixmap("filenew", m_pFilenewact->iconSet().pixmap()); + const char *kszFilenewtext = trUtf8("

" + "Click this button to make a blank file." + "You can also select the New command " + "from the File menu.

"); + m_pFilenewact->setWhatsThis(kszFilenewtext); // File open action m_pFileopenact = new QAction(trUtf8("Open File"), QPixmap(s_kpcFileopen_xpm), trUtf8("&Open"), CTRL+Key_O, this, "Open"); connect(m_pFileopenact, SIGNAL(activated()), this, SLOT(choose())); + QMimeSourceFactory::defaultFactory()->setPixmap("fileopen", m_pFileopenact->iconSet().pixmap()); const char *kszFileopentext = trUtf8("

" - "Click this button to open a new file.
" + "Click this button to open a new file." "You can also select the Open command " "from the File menu.

"); - QMimeSourceFactory::defaultFactory()->setPixmap("fileopen", m_pFileopenact->iconSet().pixmap()); m_pFileopenact->setWhatsThis(kszFileopentext); // File save current action m_pFilesaveact = new QAction(trUtf8("Save File"), QPixmap(s_kpcFilesave_xpm), trUtf8("&Save"), CTRL+Key_S, this, "Save"); connect(m_pFilesaveact, SIGNAL(activated()), this, SLOT(save())); - const char *kszFilesavetext = trUtf8("

Click this button to save the file you " + QMimeSourceFactory::defaultFactory()->setPixmap("filesave", m_pFilesaveact->iconSet().pixmap()); + const char *kszFilesavetext = trUtf8("

" + "Click this button to save the file you " "are editing. You will be prompted for a file name.\n" "You can also select the Save command " "from the File menu.

"); m_pFilesaveact->setWhatsThis(kszFilesavetext); // File save selected action - m_szFilename = new QString(); m_pFilesaveasact = new QAction(trUtf8("Save File As"), trUtf8("Save &as"), 0, this, "SaveAs"); connect(m_pFilesaveasact, SIGNAL(activated()), this, SLOT(saveAs())); m_pFilesaveasact->setWhatsThis(kszFilesavetext); @@ -88,12 +105,35 @@ m_pFilequitact = new QAction(trUtf8("Quit"), trUtf8("&Quit"), CTRL+Key_Q, this, "Quit"); connect(m_pFilequitact, SIGNAL(activated()), qApp, SLOT(quit())); -// // Lock down window size -// setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, -// (QSizePolicy::SizeType)0, 0, 0, sizePolicy().hasHeightForWidth())); - - // Make an easter egg ;-) - QToolTip::add(m_pMenubar, QRect(0, 0, 2, 2), "Easter egg"); + // Add data row action + m_pAddrowact = new QAction(trUtf8("Add Row"), QPixmap(s_kpcOssplogo_xpm), trUtf8("Add &row"), 0, this, "Addrow"); + connect(m_pAddrowact, SIGNAL(activated()), this, SLOT(addEntry())); + QMimeSourceFactory::defaultFactory()->setPixmap("ossplogo", m_pAddrowact->iconSet().pixmap()); + const char *kszAddrowtext = trUtf8("

" + "Click this button to add a new row." + "You can also select the Add row command " + "from the Accounting menu.

"); + m_pAddrowact->setWhatsThis(kszAddrowtext); + + // Delete data row action + m_pDeleterowact = new QAction(trUtf8("Add Row"), QPixmap(s_kpcOssplogo_xpm), trUtf8("Add &row"), 0, this, "Deleterow"); + connect(m_pDeleterowact, SIGNAL(activated()), this, SLOT(delEntry())); + QMimeSourceFactory::defaultFactory()->setPixmap("ossplogo", m_pDeleterowact->iconSet().pixmap()); + const char *kszDeleterowtext = trUtf8("

" + "Click this button to delete a row." + "You can also select the Delete row command " + "from the Accounting menu.

"); + m_pDeleterowact->setWhatsThis(kszDeleterowtext); + + // Write data action + m_pWritedataact = new QAction(trUtf8("Add Row"), QPixmap(s_kpcOssplogo_xpm), trUtf8("Add &row"), 0, this, "Writedata"); + connect(m_pWritedataact, SIGNAL(activated()), this, SLOT(writeEntry())); + QMimeSourceFactory::defaultFactory()->setPixmap("ossplogo", m_pWritedataact->iconSet().pixmap()); + const char *kszWritedatatext = trUtf8("

" + "Click this button to write out your accounting data." + "You can also select the Write data command " + "from the Accounting menu.

"); + m_pWritedataact->setWhatsThis(kszWritedatatext); // Construct and populate the file menu with actions QPopupMenu *pFilepopup = new QPopupMenu(this); @@ -117,6 +157,7 @@ // Construct and populate the main tool bar m_pToolbar = new QToolBar("Toolfile", this, DockTop); m_pToolbar->setLabel(trUtf8("File Ops")); + m_pFilenewact->addTo(m_pToolbar); m_pFileopenact->addTo(m_pToolbar); m_pFilesaveact->addTo(m_pToolbar); QWhatsThis::whatsThisButton(m_pToolbar); // Preconfigured whats this button @@ -232,7 +273,7 @@ // m_pMaintable->setItem(i, 4, pTasks); // } - m_pPackagelayout->addWidget(m_pMaintable); // Finally add the table widget + m_pPackagelayout->addWidget(m_pMaintable); // Finally add the damn table // Bottom output line m_pStatus = new QLineEdit(m_pCenframe, "Status"); @@ -244,6 +285,13 @@ QToolTip::add(m_pStatus, trUtf8("Status Line")); m_pPackagelayout->addWidget(m_pStatus); + // Whatsthis info for the output line + const char *kszStatouttext = trUtf8("

" + "This line shows the current row of your accounting data." + " You can also change the data in place, or above " + "from the Accounting table."); + QWhatsThis::add(m_pStatus, kszStatouttext); + // Tuple push button add m_pAddbutton = new QPushButton(m_pCenframe, "AddButton"); m_pAddbutton->setCursor(QCursor(13)); @@ -279,7 +327,7 @@ m_pControllayout->addWidget(m_pQuitbutton); init(); // Initialize signal and slot connections - m_pStatbar->message(trUtf8("Ready")); + m_pStatbar->message(trUtf8("Ready")); // Signal a ready condition } // @@ -384,6 +432,7 @@ 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 } // @@ -415,7 +464,7 @@ return; } - // Ask user to aknowlege a possibly data-damaging close event + // 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) { @@ -438,8 +487,7 @@ // bool Titraqform::isDirty(void) { - // FIXME: We're really not THAT dirty - return true; + return m_bDirt; } // Index: ossp-pkg/as/as-gui/as_gui.h RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_gui.h,v rcsdiff -q -kk '-r1.7' '-r1.8' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_gui.h,v' 2>/dev/null --- as_gui.h 2002/11/14 20:29:33 1.7 +++ as_gui.h 2002/11/14 22:26:30 1.8 @@ -15,13 +15,13 @@ // Main table size -const int g_knRows = 18; +const int g_knRows = 16; const int g_knCols = 6; // Main application form window class Titraqform : public QMainWindow { - Q_OBJECT // Needed for MOC object model generation + Q_OBJECT // Generate MOC object model stubs public: Titraqform(QWidget *pParent = 0, const char *kszName = 0, WFlags Flags = 0); @@ -31,6 +31,8 @@ QAction *m_pFilenewact, *m_pFileopenact; QAction *m_pFilesaveact, *m_pFilesaveasact; QAction *m_pFilecloseact, *m_pFilequitact; + QAction *m_pAddrowact, *m_pDeleterowact; + QAction *m_pWritedataact; // Table, cells, and entries in package layout QTable *m_pMaintable; @@ -74,10 +76,16 @@ private: // Don't destroy these, they are owned by QMainWindow QMenuBar *m_pMenubar; - QToolBar *m_pToolbar; QStatusBar *m_pStatbar; + + // Belong to us + QToolBar *m_pToolbar; QString *m_szFilename; + // Standard members + bool m_bDirt; // To track dirty and clean states + + // Standard methods bool isDirty(void); // Check for changed state danger };