OSSP CVS Repository

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

Check-in Number: 2883
Date: 2002-Nov-24 21:39:31 (local)
2002-Nov-24 20:39:31 (UTC)
User:ms
Branch:
Comment: Improve new preference object handling.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/TODO      1.12 -> 1.13     3 inserted, 1 deleted
ossp-pkg/as/as-gui/as_assist.cpp      1.12 -> 1.13     114 inserted, 78 deleted
ossp-pkg/as/as-gui/as_const.h      1.1 -> 1.2     1 inserted, 1 deleted
ossp-pkg/as/as-gui/as_gui.cpp      1.18 -> 1.19     3 inserted, 1 deleted
ossp-pkg/as/as-gui/as_gui.h      1.20 -> 1.21     12 inserted, 1 deleted
ossp-pkg/as/as-gui/as_main.cpp      1.5 -> 1.6     3 inserted, 8 deleted
ossp-pkg/titraq/TODO      1.12 -> 1.13     3 inserted, 1 deleted
ossp-pkg/titraq/main.cpp      1.5 -> 1.6     3 inserted, 8 deleted
ossp-pkg/titraq/titassist.cpp      1.12 -> 1.13     114 inserted, 78 deleted
ossp-pkg/titraq/titconst.h      1.1 -> 1.2     1 inserted, 1 deleted
ossp-pkg/titraq/titraq.cpp      1.18 -> 1.19     3 inserted, 1 deleted
ossp-pkg/titraq/titraq.h      1.20 -> 1.21     12 inserted, 1 deleted

ossp-pkg/as/as-gui/TODO 1.12 -> 1.13

--- TODO 2002/11/24 17:56:54     1.12
+++ TODO 2002/11/24 20:39:31     1.13
@@ -19,10 +19,12 @@
 Ensure rethrows from second loadData on upwards
 Report errors in all slot code
 Add preferences file format XML
-Read username from Betriebsysteme
+Read username and homedir from Betriebsysteme
+  Use homedir as one of many possible locations of titraq.conf
 Rework error handling in prefs
 Generally maintain Preference class
   Implement missing interface methods
+Review destruction of all members, compare with setupPrefs
 
 Dreams
 ------


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

--- as_assist.cpp        2002/11/24 18:03:24     1.12
+++ as_assist.cpp        2002/11/24 20:39:31     1.13
@@ -1,4 +1,12 @@
-// Qt headers
+// Qt style headers
+#include <qcdestyle.h>
+#include <qsgistyle.h>
+#include <qmotifstyle.h>
+#include <qmotifplusstyle.h>
+#include <qplatinumstyle.h>
+#include <qwindowsstyle.h>
+
+// Qt general headers
 #include <qtooltip.h>
 #include <qwhatsthis.h>
 #include <qstringlist.h>
@@ -19,71 +27,46 @@
 
 
 //
-// Construct the menu bar
+// Construct the preferences
 //
-void Titraqform::setupMenubar(void)
+void Titraqform::setupPrefs(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 edit menu with subitems
-    QPopupMenu *pEditpopup = new QPopupMenu(this);
-    if (pEditpopup == NULL) // Sanity check
-        throw Genexcept("Main window edit popup creation failed.");
-    m_pMenubar->insertItem(trUtf8("&Edit"), pEditpopup);
-    pEditpopup->insertItem("Cu&t", this, SLOT(cut()), CTRL+Key_X);
-    pEditpopup->insertItem("&Copy", this, SLOT(copy()), CTRL+Key_C);
-    pEditpopup->insertItem("&Paste", this, SLOT(paste()), CTRL+Key_V);
-    pEditpopup->insertSeparator();
-    pEditpopup->insertItem("&Add", this, SLOT(addEntry()), CTRL+Key_A);
-    pEditpopup->insertItem("&Delete", this, SLOT(delEntry()), Key_Delete);
-    pEditpopup->insertItem("Select &All", this, SLOT(selAll()), CTRL+Key_A);
-    pEditpopup->insertSeparator();
-    pEditpopup->insertItem("Preferences...", this, SLOT(configPrefs()));
-
-    // Construct and populate the view menu with subitems
-    QPopupMenu *pViewpopup = new QPopupMenu(this);
-    if (pViewpopup == NULL) // Sanity check
-        throw Genexcept("Main window view popup creation failed.");
-    m_pMenubar->insertItem(trUtf8("&View"), pViewpopup);
-    pViewpopup->insertItem(trUtf8("&Normal"), this, SLOT(normalView()));
-    pViewpopup->insertItem(trUtf8("&Editing"), this, SLOT(editingView()));
-    pViewpopup->insertItem(trUtf8("&Timing"), this, SLOT(timingView()));
-
-    // Pad spacing to force help menu to appear far right
-    m_pMenubar->insertSeparator();
+    m_pPrefs = new Preferences(TITRAQ_PREFNAME, TITRAQ_APPTITLE, TITRAQ_PREFVER);
+    if (!m_pPrefs->fileState()) { // No file was found, so assume a null state
+        m_pPrefs->setString(TITRAQ_PREFASFILE, TITRAQ_DEFASFILE);
+        m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE);
+        m_pPrefs->setString(TITRAQ_PREFVIEW, TITRAQ_DEFVIEW);
+        m_pPrefs->setString(TITRAQ_PREFREMOTELOG, TITRAQ_DEFREMOTELOG);
+        m_pPrefs->setString(TITRAQ_PREFLOCALLOG, TITRAQ_DEFLOCALLOG);
+        m_pPrefs->flush();  // Write the new conf file
+        QTextStream cerr(stderr, IO_WriteOnly);
+        cerr << trUtf8("Created new preferences file ") << trUtf8(TITRAQ_PREFNAME) << endl;
+    }
 
-    // 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("&Contents"), this, SLOT(helpContents()), Key_F1);
-    pHelppopup->insertSeparator();
-    pHelppopup->insertItem(trUtf8("About &Titraq"), this, SLOT(aboutTitraq()));
-    pHelppopup->insertItem(trUtf8("About &OSSP"), this, SLOT(aboutOSSP()));
-    pHelppopup->insertItem(trUtf8("About &Qt"), this, SLOT(aboutQt()));
-    pHelppopup->insertSeparator();
-    pHelppopup->insertItem(QPixmap(s_kpcWhatsthis_xpm), trUtf8("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1);
+    // Use the preferred configuration values to initialize titraq
+    switch (m_pPrefs->getNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE)) {
+    case TITRAQ_STYLECDE:
+        qApp->setStyle(new QCDEStyle);
+        break;
+    case TITRAQ_STYLESGI:
+        qApp->setStyle(new QSGIStyle);
+        break;
+    case TITRAQ_STYLEMOTIF:
+        qApp->setStyle(new QMotifStyle);
+        break;
+    case TITRAQ_STYLEMPLUS:
+        qApp->setStyle(new QMotifPlusStyle);
+        break;
+    case TITRAQ_STYLEPLAT:
+        qApp->setStyle(new QPlatinumStyle);
+        break;
+    case TITRAQ_STYLEMSOFT:
+        qApp->setStyle(new QWindowsStyle);
+        break;
+    default:
+        qApp->setStyle(new QCDEStyle);
+        break;
+    }
 }
 
 //
@@ -188,6 +171,74 @@
 }
 
 //
+// 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 edit menu with subitems
+    QPopupMenu *pEditpopup = new QPopupMenu(this);
+    if (pEditpopup == NULL) // Sanity check
+        throw Genexcept("Main window edit popup creation failed.");
+    m_pMenubar->insertItem(trUtf8("&Edit"), pEditpopup);
+    pEditpopup->insertItem("Cu&t", this, SLOT(cut()), CTRL+Key_X);
+    pEditpopup->insertItem("&Copy", this, SLOT(copy()), CTRL+Key_C);
+    pEditpopup->insertItem("&Paste", this, SLOT(paste()), CTRL+Key_V);
+    pEditpopup->insertSeparator();
+    pEditpopup->insertItem("&Add", this, SLOT(addEntry()), CTRL+Key_A);
+    pEditpopup->insertItem("&Delete", this, SLOT(delEntry()), Key_Delete);
+    pEditpopup->insertItem("Select &All", this, SLOT(selAll()), CTRL+Key_A);
+    pEditpopup->insertSeparator();
+    pEditpopup->insertItem("Preferences...", this, SLOT(configPrefs()));
+
+    // Construct and populate the view menu with subitems
+    QPopupMenu *pViewpopup = new QPopupMenu(this);
+    if (pViewpopup == NULL) // Sanity check
+        throw Genexcept("Main window view popup creation failed.");
+    m_pMenubar->insertItem(trUtf8("&View"), pViewpopup);
+    pViewpopup->insertItem(trUtf8("&Normal"), this, SLOT(normalView()));
+    pViewpopup->insertItem(trUtf8("&Editing"), this, SLOT(editingView()));
+    pViewpopup->insertItem(trUtf8("&Timing"), this, SLOT(timingView()));
+
+    // Pad spacing to force help menu to appear far right
+    m_pMenubar->insertSeparator();
+
+    // 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("&Contents"), this, SLOT(helpContents()), Key_F1);
+    pHelppopup->insertSeparator();
+    pHelppopup->insertItem(trUtf8("About &Titraq"), this, SLOT(aboutTitraq()));
+    pHelppopup->insertItem(trUtf8("About &OSSP"), this, SLOT(aboutOSSP()));
+    pHelppopup->insertItem(trUtf8("About &Qt"), this, SLOT(aboutQt()));
+    pHelppopup->insertSeparator();
+    pHelppopup->insertItem(QPixmap(s_kpcWhatsthis_xpm), trUtf8("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1);
+}
+
+//
 // Construct the file tool bar
 //
 void Titraqform::setupFiletools(void)
@@ -427,18 +478,3 @@
     connect(m_pQuitbutton, SIGNAL(clicked()), qApp, SLOT(quit()));
     m_pControllayout->addWidget(m_pQuitbutton);
 }
-
-//
-// Construct the preferences
-//
-void Titraqform::setupPrefs(void)
-{
-    m_pPrefs = new Preferences(TITRAQ_PREFNAME, TITRAQ_APPTITLE, TITRAQ_PREFVER);
-    if (m_pPrefs->fileState()) { // No file was found, so create a new one
-        m_pPrefs->setString(TITRAQ_PREFASFILE, TITRAQ_DEFASFILE);
-        m_pPrefs->setString(TITRAQ_PREFSTYLE, TITRAQ_DEFSTYLE);
-        m_pPrefs->setString(TITRAQ_PREFVIEW, TITRAQ_DEFVIEW);
-        m_pPrefs->setString(TITRAQ_PREFREMOTELOG, TITRAQ_DEFREMOTELOG);
-        m_pPrefs->setString(TITRAQ_PREFLOCALLOG, TITRAQ_DEFLOCALLOG);
-    }
-}


ossp-pkg/as/as-gui/as_const.h 1.1 -> 1.2

--- as_const.h   2002/11/24 17:55:55     1.1
+++ as_const.h   2002/11/24 20:39:32     1.2
@@ -1,10 +1,10 @@
+// Preferences string constants
 #define TITRAQ_PREFNAME         "titraq.conf"
 #define TITRAQ_APPTITLE         "Titraq"
 #define TITRAQ_PREFVER          "0.5"
 #define TITRAQ_PREFASFILE       "asfile"
 #define TITRAQ_DEFASFILE        "/e/dev/as"
 #define TITRAQ_PREFSTYLE        "uistyle"
-#define TITRAQ_DEFSTYLE         "CDE"
 #define TITRAQ_PREFVIEW         "view"
 #define TITRAQ_DEFVIEW          "normal"
 #define TITRAQ_PREFREMOTELOG    "logremote"


ossp-pkg/as/as-gui/as_gui.cpp 1.18 -> 1.19

--- as_gui.cpp   2002/11/24 17:56:54     1.18
+++ as_gui.cpp   2002/11/24 20:39:32     1.19
@@ -38,6 +38,7 @@
 
     // Abstractly build main widgets
     try {
+        setupPrefs();
         setupActions();
         setupMenubar();
         setupFiletools();
@@ -46,7 +47,6 @@
         setupTable();
         setupEditlay();
         setupButtons();
-        setupPrefs();
     }
     catch (Genexcept& Genex) {
         Genex.reportErr();
@@ -63,4 +63,6 @@
 Titraqform::~Titraqform(void)
 {
     // Qt deletes child widgets for us
+    m_pPrefs->flush();
+    delete m_pPrefs;
 }


ossp-pkg/as/as-gui/as_gui.h 1.20 -> 1.21

--- as_gui.h     2002/11/24 18:02:43     1.20
+++ as_gui.h     2002/11/24 20:39:32     1.21
@@ -27,6 +27,17 @@
 const int g_knBlocks = 32;
 const int g_knCols = 6;
 
+// Styles enumeration
+typedef enum
+{
+    TITRAQ_STYLECDE,
+    TITRAQ_STYLESGI,
+    TITRAQ_STYLEMOTIF,
+    TITRAQ_STYLEMPLUS,
+    TITRAQ_STYLEPLAT,
+    TITRAQ_STYLEMSOFT
+} styles_t;
+
 // Main application form window
 class Titraqform : public QMainWindow
 {
@@ -115,6 +126,7 @@
     bool isDirty(void);                 // Check for changed state danger
 
     // Constructor helpers
+    void setupPrefs(void);              // Preferences
     void setupActions(void);            // Actions
     void setupMenubar(void);            // Menu bar
     void setupFiletools(void);          // Tool bar
@@ -124,7 +136,6 @@
     void setupEditlay(void);            // Editing lay
     void setupButtons(void);            // Push button widgets
     void setupPieces(void);             // Assemble widget pieces
-    void setupPrefs(void);              // Preferences
 
     // Data processing
     void loadData(QFile &);             // Load accounting data from file


ossp-pkg/as/as-gui/as_main.cpp 1.5 -> 1.6

--- as_main.cpp  2002/11/13 12:38:25     1.5
+++ as_main.cpp  2002/11/24 20:39:31     1.6
@@ -1,16 +1,11 @@
-#include <qcdestyle.h>
-
 #include "titraq.h"
 
 int main(int argc, char **argv)
 {
     QApplication App(argc, argv);
 
-    // The main Titraq application window
-    Titraqform *pMainform = new Titraqform;
-    App.setMainWidget(pMainform);
-    App.setStyle(new QCDEStyle);    // Change style to CDE
-    pMainform->show();              // Finally start the show
-
+    Titraqform Mainform;            // Main app window
+    App.setMainWidget(&Mainform);
+    Mainform.show();                // Finally start the show
     return App.exec();
 }







CVSTrac 2.0.1