OSSP CVS Repository

ossp - Check-in [2843]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2843
Date: 2002-Nov-18 23:31:12 (local)
2002-Nov-18 22:31:12 (UTC)
User:ms
Branch:
Comment: Move methods assiting in construction of the GUI to titassist.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/Makefile.in      1.7 -> 1.8     2 inserted, 2 deleted
ossp-pkg/as/as-gui/as_assist.cpp      added-> 1.1
ossp-pkg/as/as-gui/as_gui.cpp      1.12 -> 1.13     1 inserted, 395 deleted
ossp-pkg/as/as-gui/as_gui.h      1.9 -> 1.10     1 inserted, 0 deleted
ossp-pkg/titraq/Makefile.in      1.7 -> 1.8     2 inserted, 2 deleted
ossp-pkg/titraq/titassist.cpp      added-> 1.1
ossp-pkg/titraq/titraq.cpp      1.12 -> 1.13     1 inserted, 395 deleted
ossp-pkg/titraq/titraq.h      1.9 -> 1.10     1 inserted, 0 deleted

ossp-pkg/as/as-gui/Makefile.in 1.7 -> 1.8

--- Makefile.in  2002/11/18 22:12:45     1.7
+++ Makefile.in  2002/11/18 22:31:12     1.8
@@ -65,9 +65,9 @@
 TARGET_PROGS    = titraq
 TARGET_MANS     = titraq.1 titraq.conf.5
 
-SRCS            = main.cpp titraq.cpp titrex.cpp generic.cpp titraq_version.c
+SRCS            = main.cpp titraq.cpp titassist.cpp titrex.cpp generic.cpp titraq_version.c
 
-OBJS            = main.o titraq.o titrex.o generic.o titraq_version.o
+OBJS            = main.o titraq.o titassist.o titrex.o generic.o titraq_version.o
 
 GRAFX           = gfx/ossplogo.xpm
 


ossp-pkg/as/as-gui/as_assist.cpp -> 1.1

*** /dev/null    Sat Nov 23 02:09:21 2024
--- -    Sat Nov 23 02:09:37 2024
***************
*** 0 ****
--- 1,408 ----
+ // Qt headers
+ #include <qtooltip.h>
+ #include <qwhatsthis.h>
+ #include <qdatetimeedit.h>
+ #include <qspinbox.h>
+ #include <qstringlist.h>
+ #include <qcombobox.h>
+ #include <qcursor.h>
+ 
+ // User interface
+ #include "titraq.h"
+ #include "titrex.h"             // Exception classes
+ #include "gfx/ossplogo.xpm"     // static const char *s_kpcOssplogo_xpm[]
+ #include "gfx/qtlogo.xpm"       // static const char *s_kpcQtlogo_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[]
+ #include "gfx/whatsthis.xpm"    // static const char *s_kpcWhatsthis_xpm[]
+ 
+ 
+ //
+ // Construct the icon images
+ //
+ void Titraqform::setupIcons(void)
+ {
+     // Initialize icon images
+     m_pOsspicon = new QImage(s_kpcOssplogo_xpm);
+     m_pQticon = new QImage(s_kpcQtlogo_xpm);
+     m_pNewicon = new QImage(s_kpcFilenew_xpm);
+     m_pOpenicon = new QImage(s_kpcFileopen_xpm);
+     m_pSaveicon = new QImage(s_kpcFilesave_xpm);
+     m_pWhatsicon = new QImage(s_kpcWhatsthis_xpm);
+ 
+     // Lets test out our sanity
+     if (!(m_pOsspicon && m_pQticon && m_pNewicon && m_pNewicon && \
+           m_pOpenicon && m_pSaveicon && m_pWhatsicon))
+         throw Genexcept("Main window icon creation failed.");
+ }
+ 
+ //
+ // Construct the menu bar
+ //
+ void Titraqform::setupMenubar(void)
+ {
+     m_pMenubar = menuBar(); // Grab menu bar owned by QMainWindow
+     if (m_pMenubar == NULL) // Sanity check
+         throw Genexcept("Main window menu bar nonexistant.");
+ 
+     // Make an easter egg ;-)
+     QToolTip::add(m_pMenubar, QRect(0, 0, 2, 2), "Easter egg");
+ 
+     // Construct and populate the file menu with actions
+     QPopupMenu *pFilepopup = new QPopupMenu(this);
+     if (pFilepopup == NULL) // Sanity check
+         throw Genexcept("Main window file popup creation failed.");
+     m_pMenubar->insertItem(trUtf8("&File"), pFilepopup);
+     m_pFilenewact->addTo(pFilepopup);
+     m_pFileopenact->addTo(pFilepopup);
+     pFilepopup->insertSeparator();
+     m_pFilecloseact->addTo(pFilepopup);
+     pFilepopup->insertSeparator();
+     m_pFilesaveact->addTo(pFilepopup);
+     m_pFilesaveasact->addTo(pFilepopup);
+     pFilepopup->insertSeparator();
+     m_pFilequitact->addTo(pFilepopup);
+ 
+     // Construct and populate the help menu with subitems
+     QPopupMenu *pHelppopup = new QPopupMenu(this);
+     if (pHelppopup == NULL) // Sanity check
+         throw Genexcept("Main window help popup creation failed.");
+     m_pMenubar->insertItem(trUtf8("&Help"), pHelppopup);
+     pHelppopup->insertItem(trUtf8("&About"), this, SLOT(about()), Key_F1);
+     pHelppopup->insertSeparator();
+     pHelppopup->insertItem(QPixmap(*m_pOsspicon), trUtf8("About &OSSP"), this, SLOT(aboutOSSP()));
+     pHelppopup->insertItem(QPixmap(*m_pQticon), trUtf8("About &Qt"), this, SLOT(aboutQt()));
+     pHelppopup->insertSeparator();
+     pHelppopup->insertItem(QPixmap(*m_pWhatsicon), trUtf8("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1);
+ }
+ 
+ //
+ // Construct various actions
+ //
+ void Titraqform::setupActions(void)
+ {
+     // File new action
+     m_pFilenewact = new QAction(trUtf8("New File"), QPixmap(s_kpcFilenew_xpm), trUtf8("&New"), CTRL+Key_N, this, "New");
+     if (m_pFilenewact == NULL) // Sanity check
+         throw Genexcept("Main window file new action creation failed.");
+     connect(m_pFilenewact, SIGNAL(activated()), this, SLOT(newDoc()));
+     QMimeSourceFactory::defaultFactory()->setPixmap("filenew", m_pFilenewact->iconSet().pixmap());
+     const char *kszFilenewtext = trUtf8("<p><img source=\"filenew\"> "
+                                  "Click this button to make a <em>blank file</em>."
+                                  "You can also select the <b>New</b> command "
+                                  "from the <b>File</b> menu.</p>");
+     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");
+     if (m_pFileopenact == NULL) // Sanity check
+         throw Genexcept("Main window file open action creation failed.");
+     connect(m_pFileopenact, SIGNAL(activated()), this, SLOT(choose()));
+     QMimeSourceFactory::defaultFactory()->setPixmap("fileopen", m_pFileopenact->iconSet().pixmap());
+     const char *kszFileopentext = trUtf8("<p><img source=\"fileopen\"> "
+                                   "Click this button to open a <em>new file</em>."
+                                   "You can also select the <b>Open</b> command "
+                                   "from the <b>File</b> menu.</p>");
+     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");
+     if (m_pFilesaveact == NULL) // Sanity check
+         throw Genexcept("Main window file save action creation failed.");
+     connect(m_pFilesaveact, SIGNAL(activated()), this, SLOT(save()));
+     QMimeSourceFactory::defaultFactory()->setPixmap("filesave", m_pFilesaveact->iconSet().pixmap());
+     const char *kszFilesavetext = trUtf8("<p><img source=\"filesave\"> "
+                                   "Click this button to <em>save</em> the file you "
+                                   "are editing. You will be prompted for a file name.\n"
+                                   "You can also select the <b>Save</b> command "
+                                   "from the <b>File</b> menu.</p>");
+     m_pFilesaveact->setWhatsThis(kszFilesavetext);
+ 
+     // File save selected action
+     m_pFilesaveasact = new QAction(trUtf8("Save File As"), trUtf8("Save &as"), 0, this, "SaveAs");
+     if (m_pFilesaveasact == NULL) // Sanity check
+         throw Genexcept("Main window file save as action creation failed.");
+     connect(m_pFilesaveasact, SIGNAL(activated()), this, SLOT(saveAs()));
+     m_pFilesaveasact->setWhatsThis(kszFilesavetext);
+ 
+     // File close current action
+     m_pFilecloseact = new QAction(trUtf8("Close"), trUtf8("&Close"), CTRL+Key_W, this, "Close");
+     if (m_pFilecloseact == NULL) // Sanity check
+         throw Genexcept("Main window file close action creation failed.");
+     connect(m_pFilecloseact, SIGNAL(activated()), this, SLOT(close()));
+ 
+     // File quit action
+     m_pFilequitact = new QAction(trUtf8("Exit"), trUtf8("&Exit"), CTRL+Key_Q, this, "Exit");
+     if (m_pFilequitact == NULL) // Sanity check
+         throw Genexcept("Main window file quit action creation failed.");
+     connect(m_pFilequitact, SIGNAL(activated()), qApp, SLOT(quit()));
+ 
+     // Add data row action
+     m_pAddrowact = new QAction(trUtf8("Add Row"), QPixmap(s_kpcOssplogo_xpm), trUtf8("Add &row"), 0, this, "Addrow");
+     if (m_pAddrowact == NULL) // Sanity check
+         throw Genexcept("Main window add row action creation failed.");
+     connect(m_pAddrowact, SIGNAL(activated()), this, SLOT(addEntry()));
+     QMimeSourceFactory::defaultFactory()->setPixmap("ossplogo", m_pAddrowact->iconSet().pixmap());
+     const char *kszAddrowtext = trUtf8("<p><img source=\"ossplogo\"> "
+                                 "Click this button to add a <em>new row</em>."
+                                 "You can also select the <b>Add row</b> command "
+                                 "from the <b>Accounting</b> menu.</p>");
+     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");
+     if (m_pDeleterowact == NULL) // Sanity check
+         throw Genexcept("Main window delete row action creation failed.");
+     connect(m_pDeleterowact, SIGNAL(activated()), this, SLOT(delEntry()));
+     QMimeSourceFactory::defaultFactory()->setPixmap("ossplogo", m_pDeleterowact->iconSet().pixmap());
+     const char *kszDeleterowtext = trUtf8("<p><img source=\"ossplogo\"> "
+                                    "Click this button to delete a <em>row</em>."
+                                    "You can also select the <b>Delete row</b> command "
+                                    "from the <b>Accounting</b> menu.</p>");
+     m_pDeleterowact->setWhatsThis(kszDeleterowtext);
+ 
+     // Write data action
+     m_pWritedataact = new QAction(trUtf8("Add Row"), QPixmap(s_kpcOssplogo_xpm), trUtf8("Add &row"), 0, this, "Writedata");
+     if (m_pWritedataact == NULL) // Sanity check
+         throw Genexcept("Main window write data action creation failed.");
+     connect(m_pWritedataact, SIGNAL(activated()), this, SLOT(writeEntry()));
+     QMimeSourceFactory::defaultFactory()->setPixmap("ossplogo", m_pWritedataact->iconSet().pixmap());
+     const char *kszWritedatatext = trUtf8("<p><img source=\"ossplogo\"> "
+                                    "Click this button to <em>write out</em> your accounting data."
+                                    "You can also select the <b>Write data</b> command "
+                                    "from the <b>Accounting</b> menu.</p>");
+     m_pWritedataact->setWhatsThis(kszWritedatatext);
+ }
+ 
+ //
+ // Construct the file tool bar
+ //
+ void Titraqform::setupFiletools(void)
+ {
+     // Construct and populate the main tool bar
+     m_pToolbar = new QToolBar("Toolfile", this, DockTop);
+     if (m_pToolbar == NULL) // Sanity check
+         throw Genexcept("Main window tool bar creation failed.");
+     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
+ }
+ 
+ //
+ // Construct the status bar
+ //
+ void Titraqform::setupStatusbar(void)
+ {
+     m_pStatbar = statusBar();   // Grab status bar owned by QMainWindow
+     if (m_pStatbar == NULL)     // Sanity check
+         throw Genexcept("Main window status bar nonexistant.");
+ }
+ 
+ //
+ // Construct the central widget
+ //
+ void Titraqform::setupCentralwidget(void)
+ {
+     // Create a central frame and associated layout for QMainWindow
+     m_pCenframe = new QFrame(this, "Centralframe");
+     if (m_pCenframe == NULL)    // Sanity check
+         throw Genexcept("Main window central frame creation failed.");
+     m_pCenframe->setFrameShape(QFrame::StyledPanel);
+     m_pCenframe->setFrameShadow(QFrame::Sunken);
+     setCentralWidget(m_pCenframe);
+ 
+     // Layout controls for table, buttons, and status line
+     m_pMainlayout = new QVBoxLayout(m_pCenframe, 10, 6, "Mainlayout");  // For layouts
+     m_pPackagelayout = new QVBoxLayout(0, 0, 6, "Packagelayout");       // For table
+     m_pControllayout = new QHBoxLayout(0, 0, 6, "Controllayout");       // For buttons
+ 
+     if (!(m_pMainlayout && m_pMainlayout && m_pMainlayout))             // Sanity check
+         throw Genexcept("Main window layout creation failed.");
+ 
+     // Specify ordering of the layouts
+     m_pMainlayout->addLayout(m_pPackagelayout);
+     m_pMainlayout->addLayout(m_pControllayout);
+ }
+ 
+ //
+ // Construct the table
+ //
+ void Titraqform::setupTable(void)
+ {
+     // The table itself
+     m_pMaintable = new QTable(m_pCenframe, "Maintable");
+     if (m_pMaintable == NULL)   // Sanity check
+         throw Genexcept("Main window table creation failed.");
+     m_pMaintable->setNumRows(g_knRows);
+     m_pMaintable->setNumCols(g_knCols);
+     m_pMaintable->setReadOnly(false);                   // Not read only
+     m_pMaintable->setColumnMovingEnabled(true);         // Ctrl-drag of headers
+     m_pMaintable->setSelectionMode(QTable::MultiRow);   // Multi row selection
+     m_pMaintable->setLeftMargin(0);             // Get rid of the vertical header
+     m_pMaintable->verticalHeader()->hide();     // by hiding it with a margin of 0
+     m_pMaintable->horizontalHeader()->setResizeEnabled(false);
+     m_pMaintable->setColumnStretchable(5, true);
+ 
+     // Table header row
+     m_pTablehead = m_pMaintable->horizontalHeader();
+     m_pTablehead->setLabel(0, QObject::trUtf8("Date"), 96);
+     m_pTablehead->setLabel(1, QObject::trUtf8("Begin"), 80);
+     m_pTablehead->setLabel(2, QObject::trUtf8("End"), 80);
+     m_pTablehead->setLabel(3, QObject::trUtf8("Amount"), 52);
+     m_pTablehead->setLabel(4, QObject::trUtf8("Task"), 70);
+     m_pTablehead->setLabel(5, QObject::trUtf8("Remark"));
+     m_pTablehead->setMovingEnabled(true);
+ 
+     // Icon image items
+     QPixmap Osspminipix(QPixmap(m_pOsspicon->scaleHeight(m_pMaintable->rowHeight(6))));
+     m_pMaintable->setItem(0, 0, new QTableItem(m_pMaintable, QTableItem::Never, "OSSP trac"));
+     m_pMaintable->setPixmap(0, 0, Osspminipix);
+ 
+ //    // Make a generic table item for all rows
+ //    for (int i = 1; i < knRows; ++i)
+ //        m_pMaintable->setItem(i, 0, new QTableItem(m_pMaintable, QTableItem::Always, ("Enter")));
+ 
+     // Make the date selector for all rows
+     for (int i = 1; i < g_knRows; ++i) {
+         QDate *pSylvestre = new QDate(2002, 12, 31);
+         QDateEdit *pDateEdit = new QDateEdit(*pSylvestre, m_pMaintable, "Date");
+         m_pMaintable->setCellWidget(i, 0, pDateEdit);
+     }
+ 
+     // Make the time start selector for all rows
+     for (int i = 0; i < g_knRows; ++i) {
+         QTimeEdit *pStart = new QTimeEdit(QTime::currentTime(), m_pMaintable, "Start");
+         m_pMaintable->setCellWidget(i, 1, pStart);
+     }
+ 
+     // Make the time end selector for all rows
+     for (int i = 0; i < g_knRows; ++i) {
+         QTimeEdit *pEnd = new QTimeEdit(QTime::currentTime(), m_pMaintable, "End");
+         m_pMaintable->setCellWidget(i, 2, pEnd);
+     }
+ 
+     // Make the amount selector for all rows
+     for (int i = 0; i < g_knRows; ++i) {
+         QSpinBox *pAmount = new QSpinBox(m_pMaintable, "Amount");
+         m_pMaintable->setCellWidget(i, 3, pAmount);
+     }
+ 
+     // Populate the task stringlist
+     m_pTaskentries = new QStringList;
+     if (m_pTaskentries == NULL) // Sanity check
+         throw Genexcept("Main window task entries creation failed.");
+     *m_pTaskentries << trUtf8("titraq") << trUtf8("opgui") << trUtf8("email") << trUtf8("admin") << trUtf8("pmod") << trUtf8("psod") << trUtf8("meeting") << trUtf8("training");
+ 
+     // Make the combobox items for all rows
+     for (int i = 0; i < g_knRows; ++i) {
+         QComboBox *pTasks = new QComboBox(true, m_pMaintable, "Tasks");
+         pTasks->insertStringList(*m_pTaskentries);
+         pTasks->setCurrentText(NULL);
+         pTasks->setAutoCompletion(true);
+         m_pMaintable->setCellWidget(i, 4, pTasks);
+     }
+ 
+ //    // Make the listbox for all rows
+ //    for (int i = 0; i < knRows; ++i) {
+ //        QListBox *pTasks = new QListBox(m_pMaintable, "Tasks");
+ //        pTasks->insertStringList(*pTaskentries);
+ //        pTasks->setCurrentItem(i % 8);
+ //        m_pMaintable->setCellWidget(i, 4, pTasks);
+ //    }
+ 
+ //    // Populate a listbox for the task combobox
+ //    QListBox *pListasks = new QListBox(m_pMaintable);
+ //    pListasks->insertItem("titraq");
+ //    pListasks->insertItem("opgui");
+ //    pListasks->insertItem("email");
+ //    pListasks->insertItem("admin");
+ //    pListasks->insertItem("pmod");
+ //    pListasks->insertItem("psod");
+ //    pListasks->insertItem("meeting");
+ //    pListasks->insertItem("training");
+ 
+ //    // Make the combobox items for all rows
+ //    for (int i = 0; i < knRows; ++i) {
+ //        QComboTableItem *pTasks = new QComboTableItem(m_pMaintable, *m_pTaskentries, false);
+ //        pTasks->setCurrentItem(i % 8);
+ //        m_pMaintable->setItem(i, 4, pTasks);
+ //    }
+ 
+     m_pPackagelayout->addWidget(m_pMaintable);  // Finally add the damn table
+ }
+ 
+ //
+ // Construct the bottom output line
+ //
+ void Titraqform::setupOutput(void)
+ {
+     // Bottom output line
+     m_pStatus = new QLineEdit(m_pCenframe, "Status");
+     if (m_pStatus == NULL)   // Sanity check
+         throw Genexcept("Main window status output creation failed.");
+     m_pStatus->setText(trUtf8("Happy birthday to Ralf"));
+     m_pStatus->setFrameShape(QLineEdit::LineEditPanel);
+     m_pStatus->setFrameShadow(QLineEdit::Sunken);
+     m_pStatus->setFrame(true);
+     m_pStatus->setReadOnly(true);
+     QToolTip::add(m_pStatus, trUtf8("Status Line"));
+     m_pPackagelayout->addWidget(m_pStatus);
+ 
+     // Whatsthis info for the output line
+     const char *kszStatouttext = trUtf8("<p><img source=\"ossplogo\"> "
+                                 "This line shows the <em>current row</em> of your accounting data."
+                                 " You can also change the data in place, or above "
+                                 "from the <b>Accounting table</b>.");
+     QWhatsThis::add(m_pStatus, kszStatouttext);
+ }
+ 
+ //
+ // Construct the buttons
+ //
+ void Titraqform::setupButtons(void)
+ {
+     // Tuple push button add
+     m_pAddbutton = new QPushButton(m_pCenframe, "AddButton");
+     if (m_pAddbutton == NULL)   // Sanity check
+         throw Genexcept("Main window add button creation failed.");
+     m_pAddbutton->setCursor(QCursor(13));
+     m_pAddbutton->setText(trUtf8("&Add"));
+     QToolTip::add(m_pAddbutton, trUtf8("Add Entry"));
+     connect(m_pAddbutton, SIGNAL(clicked()), this, SLOT(addEntry()));
+     m_pControllayout->addWidget(m_pAddbutton);
+ 
+     // Tuple push button delete
+     m_pDeletebutton = new QPushButton(m_pCenframe, "Deletebutton");
+     if (m_pDeletebutton == NULL)    // Sanity check
+         throw Genexcept("Main window delete button creation failed.");
+     m_pDeletebutton->setCursor(QCursor(13));
+     m_pDeletebutton->setText(trUtf8("&Delete"));
+     m_pDeletebutton->setFlat(false);
+     QToolTip::add(m_pDeletebutton, trUtf8("Delete Entry"));
+     connect(m_pDeletebutton, SIGNAL(clicked()), this, SLOT(delEntry()));
+     m_pControllayout->addWidget(m_pDeletebutton);
+ 
+     // Tuple push button write
+     m_pWritebutton = new QPushButton(m_pCenframe, "Writebutton");
+     if (m_pWritebutton == NULL) // Sanity check
+         throw Genexcept("Main window write button creation failed.");
+     m_pWritebutton->setCursor(QCursor(13));
+     m_pWritebutton->setText(trUtf8("&Write"));
+     QToolTip::add(m_pWritebutton, trUtf8("Write Entry"));
+     connect(m_pWritebutton, SIGNAL(clicked()), this, SLOT(writeEntry()));
+     m_pControllayout->addWidget(m_pWritebutton);
+ 
+     // Tuple push button quit
+     m_pQuitbutton = new QPushButton(m_pCenframe, "Quitbutton");
+     if (m_pQuitbutton == NULL)  // Sanity check
+         throw Genexcept("Main window quit button creation failed.");
+     m_pQuitbutton->setCursor(QCursor(13));
+     m_pQuitbutton->setText(trUtf8("&Quit"));
+     m_pQuitbutton->setFlat(false);
+     QToolTip::add(m_pQuitbutton, trUtf8("Quit titraq"));
+     connect(m_pQuitbutton, SIGNAL(clicked()), qApp, SLOT(quit()));
+     m_pControllayout->addWidget(m_pQuitbutton);
+ }


ossp-pkg/as/as-gui/as_gui.cpp 1.12 -> 1.13

--- as_gui.cpp   2002/11/18 22:13:56     1.12
+++ as_gui.cpp   2002/11/18 22:31:12     1.13
@@ -1,27 +1,11 @@
 // Qt headers
-#include <qtooltip.h>
-#include <qwhatsthis.h>
-#include <qdatetimeedit.h>
-#include <qspinbox.h>
-#include <qstringlist.h>
-#include <qcombobox.h>
-#include <qcursor.h>
 #include <qfile.h>
 #include <qfiledialog.h>
 
-// System headers
-#include <iostream>
-
 // User interface
 #include "titraq.h"             // Main classes
 #include "titrex.h"             // Exception classes
 #include "generic.h"            // Generic classes
-#include "gfx/ossplogo.xpm"     // static const char *s_kpcOssplogo_xpm[]
-#include "gfx/qtlogo.xpm"       // static const char *s_kpcQtlogo_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[]
-#include "gfx/whatsthis.xpm"    // static const char *s_kpcWhatsthis_xpm[]
 
 // Overload init for custom initialization of the app
 void Titraqform::init(void)
@@ -46,14 +30,6 @@
     m_bDirt = false;
     m_szFilename = new QString();
 
-    // Initialize icon images
-    m_pOsspicon = new QImage(s_kpcOssplogo_xpm);
-    m_pQticon = new QImage(s_kpcQtlogo_xpm);
-    m_pNewicon = new QImage(s_kpcFilenew_xpm);
-    m_pOpenicon = new QImage(s_kpcFileopen_xpm);
-    m_pSaveicon = new QImage(s_kpcFilesave_xpm);
-    m_pWhatsicon = new QImage(s_kpcWhatsthis_xpm);
-
     // Initial widget manipulations
     if (!kszName)
         setName(trUtf8("Titraqform"));
@@ -66,6 +42,7 @@
 
     // Abstractly build main widgets
     try {
+        setupIcons();
         setupActions();
         setupMenubar();
         setupFiletools();
@@ -278,377 +255,6 @@
 }
 
 //
-// Construct the menu bar
-//
-void Titraqform::setupMenubar(void)
-{
-    m_pMenubar = menuBar(); // Grab menu bar owned by QMainWindow
-    if (m_pMenubar == NULL) // Sanity check
-        throw Genexcept("Main window menu bar nonexistant.");
-
-    // Make an easter egg ;-)
-    QToolTip::add(m_pMenubar, QRect(0, 0, 2, 2), "Easter egg");
-
-    // Construct and populate the file menu with actions
-    QPopupMenu *pFilepopup = new QPopupMenu(this);
-    if (pFilepopup == NULL) // Sanity check
-        throw Genexcept("Main window file popup creation failed.");
-    m_pMenubar->insertItem(trUtf8("&File"), pFilepopup);
-    m_pFilenewact->addTo(pFilepopup);
-    m_pFileopenact->addTo(pFilepopup);
-    pFilepopup->insertSeparator();
-    m_pFilecloseact->addTo(pFilepopup);
-    pFilepopup->insertSeparator();
-    m_pFilesaveact->addTo(pFilepopup);
-    m_pFilesaveasact->addTo(pFilepopup);
-    pFilepopup->insertSeparator();
-    m_pFilequitact->addTo(pFilepopup);
-
-    // Construct and populate the help menu with subitems
-    QPopupMenu *pHelppopup = new QPopupMenu(this);
-    if (pHelppopup == NULL) // Sanity check
-        throw Genexcept("Main window help popup creation failed.");
-    m_pMenubar->insertItem(trUtf8("&Help"), pHelppopup);
-    pHelppopup->insertItem(trUtf8("&About"), this, SLOT(about()), Key_F1);
-    pHelppopup->insertSeparator();
-    pHelppopup->insertItem(QPixmap(*m_pOsspicon), trUtf8("About &OSSP"), this, SLOT(aboutOSSP()));
-    pHelppopup->insertItem(QPixmap(*m_pQticon), trUtf8("About &Qt"), this, SLOT(aboutQt()));
-    pHelppopup->insertSeparator();
-    pHelppopup->insertItem(QPixmap(*m_pWhatsicon), trUtf8("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1);
-}
-
-//
-// Construct various actions
-//
-void Titraqform::setupActions(void)
-{
-    // File new action
-    m_pFilenewact = new QAction(trUtf8("New File"), QPixmap(s_kpcFilenew_xpm), trUtf8("&New"), CTRL+Key_N, this, "New");
-    if (m_pFilenewact == NULL) // Sanity check
-        throw Genexcept("Main window file new action creation failed.");
-    connect(m_pFilenewact, SIGNAL(activated()), this, SLOT(newDoc()));
-    QMimeSourceFactory::defaultFactory()->setPixmap("filenew", m_pFilenewact->iconSet().pixmap());
-    const char *kszFilenewtext = trUtf8("<p><img source=\"filenew\"> "
-                                 "Click this button to make a <em>blank file</em>."
-                                 "You can also select the <b>New</b> command "
-                                 "from the <b>File</b> menu.</p>");
-    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");
-    if (m_pFileopenact == NULL) // Sanity check
-        throw Genexcept("Main window file open action creation failed.");
-    connect(m_pFileopenact, SIGNAL(activated()), this, SLOT(choose()));
-    QMimeSourceFactory::defaultFactory()->setPixmap("fileopen", m_pFileopenact->iconSet().pixmap());
-    const char *kszFileopentext = trUtf8("<p><img source=\"fileopen\"> "
-                                  "Click this button to open a <em>new file</em>."
-                                  "You can also select the <b>Open</b> command "
-                                  "from the <b>File</b> menu.</p>");
-    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");
-    if (m_pFilesaveact == NULL) // Sanity check
-        throw Genexcept("Main window file save action creation failed.");
-    connect(m_pFilesaveact, SIGNAL(activated()), this, SLOT(save()));
-    QMimeSourceFactory::defaultFactory()->setPixmap("filesave", m_pFilesaveact->iconSet().pixmap());
-    const char *kszFilesavetext = trUtf8("<p><img source=\"filesave\"> "
-                                  "Click this button to <em>save</em> the file you "
-                                  "are editing. You will be prompted for a file name.\n"
-                                  "You can also select the <b>Save</b> command "
-                                  "from the <b>File</b> menu.</p>");
-    m_pFilesaveact->setWhatsThis(kszFilesavetext);
-
-    // File save selected action
-    m_pFilesaveasact = new QAction(trUtf8("Save File As"), trUtf8("Save &as"), 0, this, "SaveAs");
-    if (m_pFilesaveasact == NULL) // Sanity check
-        throw Genexcept("Main window file save as action creation failed.");
-    connect(m_pFilesaveasact, SIGNAL(activated()), this, SLOT(saveAs()));
-    m_pFilesaveasact->setWhatsThis(kszFilesavetext);
-
-    // File close current action
-    m_pFilecloseact = new QAction(trUtf8("Close"), trUtf8("&Close"), CTRL+Key_W, this, "Close");
-    if (m_pFilecloseact == NULL) // Sanity check
-        throw Genexcept("Main window file close action creation failed.");
-    connect(m_pFilecloseact, SIGNAL(activated()), this, SLOT(close()));
-
-    // File quit action
-    m_pFilequitact = new QAction(trUtf8("Exit"), trUtf8("&Exit"), CTRL+Key_Q, this, "Exit");
-    if (m_pFilequitact == NULL) // Sanity check
-        throw Genexcept("Main window file quit action creation failed.");
-    connect(m_pFilequitact, SIGNAL(activated()), qApp, SLOT(quit()));
-
-    // Add data row action
-    m_pAddrowact = new QAction(trUtf8("Add Row"), QPixmap(s_kpcOssplogo_xpm), trUtf8("Add &row"), 0, this, "Addrow");
-    if (m_pAddrowact == NULL) // Sanity check
-        throw Genexcept("Main window add row action creation failed.");
-    connect(m_pAddrowact, SIGNAL(activated()), this, SLOT(addEntry()));
-    QMimeSourceFactory::defaultFactory()->setPixmap("ossplogo", m_pAddrowact->iconSet().pixmap());
-    const char *kszAddrowtext = trUtf8("<p><img source=\"ossplogo\"> "
-                                "Click this button to add a <em>new row</em>."
-                                "You can also select the <b>Add row</b> command "
-                                "from the <b>Accounting</b> menu.</p>");
-    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");
-    if (m_pDeleterowact == NULL) // Sanity check
-        throw Genexcept("Main window delete row action creation failed.");
-    connect(m_pDeleterowact, SIGNAL(activated()), this, SLOT(delEntry()));
-    QMimeSourceFactory::defaultFactory()->setPixmap("ossplogo", m_pDeleterowact->iconSet().pixmap());
-    const char *kszDeleterowtext = trUtf8("<p><img source=\"ossplogo\"> "
-                                   "Click this button to delete a <em>row</em>."
-                                   "You can also select the <b>Delete row</b> command "
-                                   "from the <b>Accounting</b> menu.</p>");
-    m_pDeleterowact->setWhatsThis(kszDeleterowtext);
-
-    // Write data action
-    m_pWritedataact = new QAction(trUtf8("Add Row"), QPixmap(s_kpcOssplogo_xpm), trUtf8("Add &row"), 0, this, "Writedata");
-    if (m_pWritedataact == NULL) // Sanity check
-        throw Genexcept("Main window write data action creation failed.");
-    connect(m_pWritedataact, SIGNAL(activated()), this, SLOT(writeEntry()));
-    QMimeSourceFactory::defaultFactory()->setPixmap("ossplogo", m_pWritedataact->iconSet().pixmap());
-    const char *kszWritedatatext = trUtf8("<p><img source=\"ossplogo\"> "
-                                   "Click this button to <em>write out</em> your accounting data."
-                                   "You can also select the <b>Write data</b> command "
-                                   "from the <b>Accounting</b> menu.</p>");
-    m_pWritedataact->setWhatsThis(kszWritedatatext);
-}
-
-//
-// Construct the file tool bar
-//
-void Titraqform::setupFiletools(void)
-{
-    // Construct and populate the main tool bar
-    m_pToolbar = new QToolBar("Toolfile", this, DockTop);
-    if (m_pToolbar == NULL) // Sanity check
-        throw Genexcept("Main window tool bar creation failed.");
-    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
-}
-
-//
-// Construct the status bar
-//
-void Titraqform::setupStatusbar(void)
-{
-    m_pStatbar = statusBar();   // Grab status bar owned by QMainWindow
-    if (m_pStatbar == NULL)     // Sanity check
-        throw Genexcept("Main window status bar nonexistant.");
-}
-
-//
-// Construct the central widget
-//
-void Titraqform::setupCentralwidget(void)
-{
-    // Create a central frame and associated layout for QMainWindow
-    m_pCenframe = new QFrame(this, "Centralframe");
-    if (m_pCenframe == NULL)    // Sanity check
-        throw Genexcept("Main window central frame creation failed.");
-    m_pCenframe->setFrameShape(QFrame::StyledPanel);
-    m_pCenframe->setFrameShadow(QFrame::Sunken);
-    setCentralWidget(m_pCenframe);
-
-    // Layout controls for table, buttons, and status line
-    m_pMainlayout = new QVBoxLayout(m_pCenframe, 10, 6, "Mainlayout");  // For layouts
-    m_pPackagelayout = new QVBoxLayout(0, 0, 6, "Packagelayout");       // For table
-    m_pControllayout = new QHBoxLayout(0, 0, 6, "Controllayout");       // For buttons
-
-    if (!(m_pMainlayout && m_pMainlayout && m_pMainlayout))             // Sanity check
-        throw Genexcept("Main window layout creation failed.");
-
-    // Specify ordering of the layouts
-    m_pMainlayout->addLayout(m_pPackagelayout);
-    m_pMainlayout->addLayout(m_pControllayout);
-}
-
-//
-// Construct the table
-//
-void Titraqform::setupTable(void)
-{
-    // The table itself
-    m_pMaintable = new QTable(m_pCenframe, "Maintable");
-    if (m_pMaintable == NULL)   // Sanity check
-        throw Genexcept("Main window table creation failed.");
-    m_pMaintable->setNumRows(g_knRows);
-    m_pMaintable->setNumCols(g_knCols);
-    m_pMaintable->setReadOnly(false);                   // Not read only
-    m_pMaintable->setColumnMovingEnabled(true);         // Ctrl-drag of headers
-    m_pMaintable->setSelectionMode(QTable::MultiRow);   // Multi row selection
-    m_pMaintable->setLeftMargin(0);             // Get rid of the vertical header
-    m_pMaintable->verticalHeader()->hide();     // by hiding it with a margin of 0
-    m_pMaintable->horizontalHeader()->setResizeEnabled(false);
-    m_pMaintable->setColumnStretchable(5, true);
-
-    // Table header row
-    m_pTablehead = m_pMaintable->horizontalHeader();
-    m_pTablehead->setLabel(0, QObject::trUtf8("Date"), 96);
-    m_pTablehead->setLabel(1, QObject::trUtf8("Begin"), 80);
-    m_pTablehead->setLabel(2, QObject::trUtf8("End"), 80);
-    m_pTablehead->setLabel(3, QObject::trUtf8("Amount"), 52);
-    m_pTablehead->setLabel(4, QObject::trUtf8("Task"), 70);
-    m_pTablehead->setLabel(5, QObject::trUtf8("Remark"));
-    m_pTablehead->setMovingEnabled(true);
-
-    // Icon image items
-    QPixmap Osspminipix(QPixmap(m_pOsspicon->scaleHeight(m_pMaintable->rowHeight(6))));
-    m_pMaintable->setItem(0, 0, new QTableItem(m_pMaintable, QTableItem::Never, "OSSP trac"));
-    m_pMaintable->setPixmap(0, 0, Osspminipix);
-
-//    // Make a generic table item for all rows
-//    for (int i = 1; i < knRows; ++i)
-//        m_pMaintable->setItem(i, 0, new QTableItem(m_pMaintable, QTableItem::Always, ("Enter")));
-
-    // Make the date selector for all rows
-    for (int i = 1; i < g_knRows; ++i) {
-        QDate *pSylvestre = new QDate(2002, 12, 31);
-        QDateEdit *pDateEdit = new QDateEdit(*pSylvestre, m_pMaintable, "Date");
-        m_pMaintable->setCellWidget(i, 0, pDateEdit);
-    }
-
-    // Make the time start selector for all rows
-    for (int i = 0; i < g_knRows; ++i) {
-        QTimeEdit *pStart = new QTimeEdit(QTime::currentTime(), m_pMaintable, "Start");
-        m_pMaintable->setCellWidget(i, 1, pStart);
-    }
-
-    // Make the time end selector for all rows
-    for (int i = 0; i < g_knRows; ++i) {
-        QTimeEdit *pEnd = new QTimeEdit(QTime::currentTime(), m_pMaintable, "End");
-        m_pMaintable->setCellWidget(i, 2, pEnd);
-    }
-
-    // Make the amount selector for all rows
-    for (int i = 0; i < g_knRows; ++i) {
-        QSpinBox *pAmount = new QSpinBox(m_pMaintable, "Amount");
-        m_pMaintable->setCellWidget(i, 3, pAmount);
-    }
-
-    // Populate the task stringlist
-    m_pTaskentries = new QStringList;
-    if (m_pTaskentries == NULL) // Sanity check
-        throw Genexcept("Main window task entries creation failed.");
-    *m_pTaskentries << trUtf8("titraq") << trUtf8("opgui") << trUtf8("email") << trUtf8("admin") << trUtf8("pmod") << trUtf8("psod") << trUtf8("meeting") << trUtf8("training");
-
-    // Make the combobox items for all rows
-    for (int i = 0; i < g_knRows; ++i) {
-        QComboBox *pTasks = new QComboBox(true, m_pMaintable, "Tasks");
-        pTasks->insertStringList(*m_pTaskentries);
-        pTasks->setCurrentText(NULL);
-        pTasks->setAutoCompletion(true);
-        m_pMaintable->setCellWidget(i, 4, pTasks);
-    }
-
-//    // Make the listbox for all rows
-//    for (int i = 0; i < knRows; ++i) {
-//        QListBox *pTasks = new QListBox(m_pMaintable, "Tasks");
-//        pTasks->insertStringList(*pTaskentries);
-//        pTasks->setCurrentItem(i % 8);
-//        m_pMaintable->setCellWidget(i, 4, pTasks);
-//    }
-
-//    // Populate a listbox for the task combobox
-//    QListBox *pListasks = new QListBox(m_pMaintable);
-//    pListasks->insertItem("titraq");
-//    pListasks->insertItem("opgui");
-//    pListasks->insertItem("email");
-//    pListasks->insertItem("admin");
-//    pListasks->insertItem("pmod");
-//    pListasks->insertItem("psod");
-//    pListasks->insertItem("meeting");
-//    pListasks->insertItem("training");
-
-//    // Make the combobox items for all rows
-//    for (int i = 0; i < knRows; ++i) {
-//        QComboTableItem *pTasks = new QComboTableItem(m_pMaintable, *m_pTaskentries, false);
-//        pTasks->setCurrentItem(i % 8);
-//        m_pMaintable->setItem(i, 4, pTasks);
-//    }
-
-    m_pPackagelayout->addWidget(m_pMaintable);  // Finally add the damn table
-}
-
-//
-// Construct the bottom output line
-//
-void Titraqform::setupOutput(void)
-{
-    // Bottom output line
-    m_pStatus = new QLineEdit(m_pCenframe, "Status");
-    if (m_pStatus == NULL)   // Sanity check
-        throw Genexcept("Main window status output creation failed.");
-    m_pStatus->setText(trUtf8("Happy birthday to Ralf"));
-    m_pStatus->setFrameShape(QLineEdit::LineEditPanel);
-    m_pStatus->setFrameShadow(QLineEdit::Sunken);
-    m_pStatus->setFrame(true);
-    m_pStatus->setReadOnly(true);
-    QToolTip::add(m_pStatus, trUtf8("Status Line"));
-    m_pPackagelayout->addWidget(m_pStatus);
-
-    // Whatsthis info for the output line
-    const char *kszStatouttext = trUtf8("<p><img source=\"ossplogo\"> "
-                                "This line shows the <em>current row</em> of your accounting data."
-                                " You can also change the data in place, or above "
-                                "from the <b>Accounting table</b>.");
-    QWhatsThis::add(m_pStatus, kszStatouttext);
-}
-
-//
-// Construct the buttons
-//
-void Titraqform::setupButtons(void)
-{
-    // Tuple push button add
-    m_pAddbutton = new QPushButton(m_pCenframe, "AddButton");
-    if (m_pAddbutton == NULL)   // Sanity check
-        throw Genexcept("Main window add button creation failed.");
-    m_pAddbutton->setCursor(QCursor(13));
-    m_pAddbutton->setText(trUtf8("&Add"));
-    QToolTip::add(m_pAddbutton, trUtf8("Add Entry"));
-    connect(m_pAddbutton, SIGNAL(clicked()), this, SLOT(addEntry()));
-    m_pControllayout->addWidget(m_pAddbutton);
-
-    // Tuple push button delete
-    m_pDeletebutton = new QPushButton(m_pCenframe, "Deletebutton");
-    if (m_pDeletebutton == NULL)    // Sanity check
-        throw Genexcept("Main window delete button creation failed.");
-    m_pDeletebutton->setCursor(QCursor(13));
-    m_pDeletebutton->setText(trUtf8("&Delete"));
-    m_pDeletebutton->setFlat(false);
-    QToolTip::add(m_pDeletebutton, trUtf8("Delete Entry"));
-    connect(m_pDeletebutton, SIGNAL(clicked()), this, SLOT(delEntry()));
-    m_pControllayout->addWidget(m_pDeletebutton);
-
-    // Tuple push button write
-    m_pWritebutton = new QPushButton(m_pCenframe, "Writebutton");
-    if (m_pWritebutton == NULL) // Sanity check
-        throw Genexcept("Main window write button creation failed.");
-    m_pWritebutton->setCursor(QCursor(13));
-    m_pWritebutton->setText(trUtf8("&Write"));
-    QToolTip::add(m_pWritebutton, trUtf8("Write Entry"));
-    connect(m_pWritebutton, SIGNAL(clicked()), this, SLOT(writeEntry()));
-    m_pControllayout->addWidget(m_pWritebutton);
-
-    // Tuple push button quit
-    m_pQuitbutton = new QPushButton(m_pCenframe, "Quitbutton");
-    if (m_pQuitbutton == NULL)  // Sanity check
-        throw Genexcept("Main window quit button creation failed.");
-    m_pQuitbutton->setCursor(QCursor(13));
-    m_pQuitbutton->setText(trUtf8("&Quit"));
-    m_pQuitbutton->setFlat(false);
-    QToolTip::add(m_pQuitbutton, trUtf8("Quit titraq"));
-    connect(m_pQuitbutton, SIGNAL(clicked()), qApp, SLOT(quit()));
-    m_pControllayout->addWidget(m_pQuitbutton);
-
-}
-
-//
 // Destroy the object and free any allocated resources
 //
 Titraqform::~Titraqform(void)


ossp-pkg/as/as-gui/as_gui.h 1.9 -> 1.10

--- as_gui.h     2002/11/18 22:13:56     1.9
+++ as_gui.h     2002/11/18 22:31:12     1.10
@@ -99,6 +99,7 @@
     bool isDirty(void);                 // Check for changed state danger
 
     // Constructor helpers
+    void setupIcons(void);              // Icons
     void setupActions(void);            // Actions
     void setupMenubar(void);            // Menu bar
     void setupFiletools(void);          // Tool bar





CVSTrac 2.0.1