--- as_assist.cpp 2002/11/26 14:15:05 1.19
+++ as_assist.cpp 2002/11/26 17:23:51 1.20
@@ -23,6 +23,11 @@
#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/cut.xpm" // static const char *s_kpcCut_xpm[]
+#include "gfx/copy.xpm" // static const char *s_kpcCopy_xpm[]
+#include "gfx/paste.xpm" // static const char *s_kpcPaste_xpm[]
+#include "gfx/rowadd.xpm" // static const char *s_kpcRowadd_xpm[]
+#include "gfx/rowdel.xpm" // static const char *s_kpcRowdel_xpm[]
#include "gfx/osspicon.xpm" // static const char *s_kpcOsspicon_xpm[]
#include "gfx/whatsthis.xpm" // static const char *s_kpcWhatsthis_xpm[]
@@ -80,6 +85,11 @@
QMimeSourceFactory::defaultFactory()->setPixmap("filenew", QPixmap(s_kpcFilenew_xpm));
QMimeSourceFactory::defaultFactory()->setPixmap("fileopen", QPixmap(s_kpcFileopen_xpm));
QMimeSourceFactory::defaultFactory()->setPixmap("filesave", QPixmap(s_kpcFilesave_xpm));
+ QMimeSourceFactory::defaultFactory()->setPixmap("cut", QPixmap(s_kpcCut_xpm));
+ QMimeSourceFactory::defaultFactory()->setPixmap("copy", QPixmap(s_kpcCopy_xpm));
+ QMimeSourceFactory::defaultFactory()->setPixmap("paste", QPixmap(s_kpcPaste_xpm));
+ QMimeSourceFactory::defaultFactory()->setPixmap("rowadd", QPixmap(s_kpcRowadd_xpm));
+ QMimeSourceFactory::defaultFactory()->setPixmap("rowdel", QPixmap(s_kpcRowdel_xpm));
// File new action
m_pFilenewact = new QAction(trUtf8("New File"), QPixmap(s_kpcFilenew_xpm), trUtf8("&New..."), CTRL+Key_N, this, "New");
@@ -127,41 +137,74 @@
// File close current action
m_pFilecloseact = new QAction(trUtf8("Close"), trUtf8("&Close"), CTRL+Key_W, this, "Close");
- if (m_pFilecloseact == NULL) // Sanity check
+ 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("E&xit"), CTRL+Key_Q, this, "Exit");
- if (m_pFilequitact == NULL) // Sanity check
+ if (m_pFilequitact == NULL) // Sanity check
throw Genexcept("Main window file quit action creation failed.");
connect(m_pFilequitact, SIGNAL(activated()), qApp, SLOT(quit()));
+ // Cut action
+ m_pCutact = new QAction(trUtf8("Cut"), QPixmap(s_kpcCut_xpm), trUtf8("&Cut"), 0, this, "Cut");
+ if (m_pCutact == NULL) // Sanity check
+ throw Genexcept("Main window cut edit action creation failed.");
+ connect(m_pCutact, SIGNAL(activated()), this, SLOT(cutEntry()));
+ const char *kszCuttext = "<p><img source=\"cut\"> "
+ "Click this button to cut an <em>entry</em>."
+ "You can also select the <b>Cut</b> command "
+ "from the <b>Edit</b> menu.</p>";
+ m_pCutact->setWhatsThis(kszCuttext);
+
+ // Copy action
+ m_pCopyact = new QAction(trUtf8("Copy"), QPixmap(s_kpcCopy_xpm), trUtf8("&Copy"), 0, this, "Copy");
+ if (m_pCopyact == NULL) // Sanity check
+ throw Genexcept("Main window copy edit action creation failed.");
+ connect(m_pCopyact, SIGNAL(activated()), this, SLOT(copyEntry()));
+ const char *kszCopytext = "<p><img source=\"copy\"> "
+ "Click this button to copy an <em>entry</em>."
+ "You can also select the <b>Copy</b> command "
+ "from the <b>Edit</b> menu.</p>";
+ m_pCopyact->setWhatsThis(kszCopytext);
+
+ // Paste action
+ m_pPasteact = new QAction(trUtf8("Paste"), QPixmap(s_kpcPaste_xpm), trUtf8("&Paste"), 0, this, "Paste");
+ if (m_pPasteact == NULL) // Sanity check
+ throw Genexcept("Main window paste edit action creation failed.");
+ connect(m_pPasteact, SIGNAL(activated()), this, SLOT(pasteEntry()));
+ const char *kszPastetext = "<p><img source=\"paste\"> "
+ "Click this button to paste an <em>entry</em>."
+ "You can also select the <b>Paste</b> command "
+ "from the <b>Edit</b> menu.</p>";
+ m_pPasteact->setWhatsThis(kszPastetext);
+
// Add data row action
- m_pAddrowact = new QAction(trUtf8("Add Row"), trUtf8("Add &row"), 0, this, "Addrow");
- if (m_pAddrowact == NULL) // Sanity check
+ m_pAddrowact = new QAction(trUtf8("Add Row"), QPixmap(s_kpcRowadd_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()));
- const char *kszAddrowtext = "<p><img source=\"ossplogo\"> "
+ const char *kszAddrowtext = "<p><img source=\"rowadd\"> "
"Click this button to add a <em>new row</em>."
"You can also select the <b>Add</b> command "
"from the <b>Edit</b> menu.</p>";
m_pAddrowact->setWhatsThis(kszAddrowtext);
// Delete data row action
- m_pDeleterowact = new QAction(trUtf8("Add Row"), trUtf8("Add &row"), 0, this, "Deleterow");
- if (m_pDeleterowact == NULL) // Sanity check
+ m_pDelrowact = new QAction(trUtf8("Del Row"), QPixmap(s_kpcRowdel_xpm), trUtf8("&Delete row"), 0, this, "Delrow");
+ if (m_pDelrowact == NULL) // Sanity check
throw Genexcept("Main window delete row action creation failed.");
- connect(m_pDeleterowact, SIGNAL(activated()), this, SLOT(delEntry()));
- const char *kszDeleterowtext = "<p><img source=\"ossplogo\"> "
+ connect(m_pDelrowact, SIGNAL(activated()), this, SLOT(delEntry()));
+ const char *kszDelrowtext = "<p><img source=\"rowdel\"> "
"Click this button to delete a <em>row</em>."
"You can also select the <b>Delete</b> command "
"from the <b>Edit</b> menu.</p>";
- m_pDeleterowact->setWhatsThis(kszDeleterowtext);
+ m_pDelrowact->setWhatsThis(kszDelrowtext);
// Write data action
- m_pWritedataact = new QAction(trUtf8("Add Row"), trUtf8("Add &row"), 0, this, "Writedata");
- if (m_pWritedataact == NULL) // Sanity check
+ m_pWritedataact = new QAction(trUtf8("Write Data"), trUtf8("&Write data"), 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()));
const char *kszWritedatatext = "<p><img source=\"ossplogo\"> "
@@ -176,6 +219,8 @@
//
void Titraqform::setupMenubar(void)
{
+ int nMenuid = 0; // Used to store id during menu item creation
+
m_pMenubar = menuBar(); // Grab menu bar owned by QMainWindow
if (m_pMenubar == NULL) // Sanity check
throw Genexcept("Main window menu bar nonexistant.");
@@ -203,24 +248,61 @@
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);
+ m_pCutact->addTo(pEditpopup);
+ m_pCopyact->addTo(pEditpopup);
+ m_pPasteact->addTo(pEditpopup);
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);
+ m_pAddrowact->addTo(pEditpopup);
+ m_pDelrowact->addTo(pEditpopup);
pEditpopup->insertSeparator();
pEditpopup->insertItem("Preferences...", this, SLOT(configPrefs()));
- // Construct and populate the view menu with subitems
+ // Construct the view menu
QPopupMenu *pViewpopup = new QPopupMenu(this);
- if (pViewpopup == NULL) // Sanity check
- throw Genexcept("Main window view popup creation failed.");
+ QPopupMenu *pTbarspopup = new QPopupMenu(this);
+ pTbarspopup->insertTearOffHandle();
+ pTbarspopup->setCheckable(true);
+ QPopupMenu *pColspopup = new QPopupMenu(this);
+ pColspopup->insertTearOffHandle();
+ pColspopup->setCheckable(true);
+
+ // Major sanity check wrapped in one call
+ if (!(pViewpopup && pTbarspopup && pColspopup))
+ throw Genexcept("Main window view popups creation failed.");
+
+ // Populate the view menu with subitems
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()));
+ nMenuid = pViewpopup->insertItem(trUtf8("&Timing"), this, SLOT(timingView()));
+ pViewpopup->setItemEnabled(nMenuid, false);
+ pViewpopup->insertSeparator();
+ pViewpopup->insertItem(trUtf8("&Toolbars"), pTbarspopup);
+ nMenuid = pTbarspopup->insertItem(trUtf8("&File"), this, SLOT(showFilebar()));
+ pTbarspopup->setItemChecked(nMenuid, true);
+ nMenuid = pTbarspopup->insertItem(trUtf8("&Edit"), this, SLOT(showEditbar()));
+ pTbarspopup->setItemChecked(nMenuid, true);
+ nMenuid = pTbarspopup->insertItem(trUtf8("&Whats this"), this, SLOT(showWhatsbar()));
+ pTbarspopup->setItemChecked(nMenuid, true);
+ pViewpopup->insertSeparator();
+ pViewpopup->insertItem(trUtf8("&Columns"), pColspopup);
+ nMenuid = pColspopup->insertItem(trUtf8("&Line number"), this, SLOT(showLinecol()));
+ pColspopup->setItemEnabled(nMenuid, false);
+ nMenuid = pColspopup->insertItem(trUtf8("&GUID"), this, SLOT(showGuidcol()));
+ pColspopup->setItemEnabled(nMenuid, false);
+ nMenuid = pColspopup->insertItem(trUtf8("&Date"), this, SLOT(showDatecol()));
+ pColspopup->setItemEnabled(nMenuid, false);
+ nMenuid = pColspopup->insertItem(trUtf8("&User"), this, SLOT(showUsercol()));
+ pColspopup->setItemEnabled(nMenuid, false);
+ nMenuid = pColspopup->insertItem(trUtf8("&Task"), this, SLOT(showTaskcol()));
+ pColspopup->setItemEnabled(nMenuid, false);
+ nMenuid = pColspopup->insertItem(trUtf8("&Start time"), this, SLOT(showStartcol()));
+ pColspopup->setItemEnabled(nMenuid, false);
+ nMenuid = pColspopup->insertItem(trUtf8("&Finish time"), this, SLOT(showFinishcol()));
+ pColspopup->setItemEnabled(nMenuid, false);
+ nMenuid = pColspopup->insertItem(trUtf8("&Amount time"), this, SLOT(showAmountcol()));
+ pColspopup->setItemEnabled(nMenuid, false);
+ nMenuid = pColspopup->insertItem(trUtf8("&Remark"), this, SLOT(showRemarkcol()));
+ pColspopup->setItemEnabled(nMenuid, false);
// Pad spacing to force help menu to appear far right
m_pMenubar->insertSeparator();
@@ -252,13 +334,25 @@
m_pFilenewact->addTo(m_pFiletools);
m_pFileopenact->addTo(m_pFiletools);
m_pFilesaveact->addTo(m_pFiletools);
- QWhatsThis::whatsThisButton(m_pFiletools); // Preconfigured whats this button
// Construct and populate the edit tool bar
m_pEdittools = new QToolBar("Tooledit", this, DockTop);
if (m_pEdittools == NULL) // Sanity check
throw Genexcept("Edit tool bar creation failed.");
m_pEdittools->setLabel(trUtf8("Edit Ops"));
+ m_pCutact->addTo(m_pEdittools);
+ m_pCopyact->addTo(m_pEdittools);
+ m_pPasteact->addTo(m_pEdittools);
+ m_pEdittools->addSeparator();
+ m_pAddrowact->addTo(m_pEdittools);
+ m_pDelrowact->addTo(m_pEdittools);
+
+ // Construct and populate the lonely whatsthis tool bar
+ m_pWhatstools = new QToolBar("Toolwhats", this, DockTop);
+ if (m_pWhatstools == NULL) // Sanity check
+ throw Genexcept("Whats this tool bar creation failed.");
+ m_pWhatstools->setLabel(trUtf8("Whats this"));
+ QWhatsThis::whatsThisButton(m_pWhatstools); // Preconfigured whats this button
}
//
|