--- as_assist.cpp 2002/11/19 08:17:44 1.3
+++ as_assist.cpp 2002/11/19 19:42:14 1.4
@@ -1,10 +1,9 @@
// Qt headers
#include <qtooltip.h>
#include <qwhatsthis.h>
-#include <qdatetimeedit.h>
-#include <qspinbox.h>
#include <qstringlist.h>
#include <qcombobox.h>
+#include <qlistbox.h>
#include <qcursor.h>
// User interface
@@ -12,9 +11,10 @@
#include "titrex.h" // Exception classes
// Icon pixel maps
-#include "gfx/cw.xpm" // static const char *s_kpcCw_xpm[]
+#include "gfx/cwlogo.xpm" // static const char *s_kpcCwlogo_xpm[]
+#include "gfx/osspicon.xpm" // static const char *s_kpcOsspicon_xpm[]
#include "gfx/ossplogo.xpm" // static const char *s_kpcOssplogo_xpm[]
-#include "gfx/qtlogo.xpm" // static const char *s_kpcQtlogo_xpm[]
+#include "gfx/qticon.xpm" // static const char *s_kpcQticon_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[]
@@ -27,9 +27,10 @@
void Titraqform::setupIcons(void)
{
// Initialize icon images
- m_pCwicon = new QImage(s_kpcCwlogo_xpm);
- m_pOsspicon = new QImage(s_kpcOssplogo_xpm);
- m_pQticon = new QImage(s_kpcQtlogo_xpm);
+ m_pCwlogo = new QImage(s_kpcCwlogo_xpm);
+ m_pOsspicon = new QImage(s_kpcOsspicon_xpm);
+ m_pOssplogo = new QImage(s_kpcOssplogo_xpm);
+ m_pQticon = new QImage(s_kpcQticon_xpm);
m_pNewicon = new QImage(s_kpcFilenew_xpm);
m_pOpenicon = new QImage(s_kpcFileopen_xpm);
m_pSaveicon = new QImage(s_kpcFilesave_xpm);
@@ -211,16 +212,21 @@
m_pCenframe->setFrameShadow(QFrame::Sunken);
setCentralWidget(m_pCenframe);
- // Layout controls for table, buttons, and status line
+ // Layout controls for table, editing widgets, and buttons
m_pMainlayout = new QVBoxLayout(m_pCenframe, 10, 6, "Mainlayout"); // For layouts
m_pPackagelayout = new QVBoxLayout(0, 0, 6, "Packagelayout"); // For table
+ m_pDatelayout = new QHBoxLayout(0, 0, 6, "Datelayout"); // For dates
+ m_pTasklayout = new QHBoxLayout(0, 0, 6, "Tasklayout"); // For tasks
m_pControllayout = new QHBoxLayout(0, 0, 6, "Controllayout"); // For buttons
- if (!(m_pMainlayout && m_pMainlayout && m_pMainlayout)) // Sanity check
+ // Major sanity check wrapped in one call
+ if (!(m_pMainlayout && m_pPackagelayout && m_pDatelayout && m_pTasklayout && m_pControllayout))
throw Genexcept("Main window layout creation failed.");
// Specify ordering of the layouts
m_pMainlayout->addLayout(m_pPackagelayout);
+ m_pMainlayout->addLayout(m_pDatelayout);
+ m_pMainlayout->addLayout(m_pTasklayout);
m_pMainlayout->addLayout(m_pControllayout);
}
@@ -245,125 +251,134 @@
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->setReadOnly(true); // Table is read only
+ m_pMaintable->setColumnMovingEnabled(false); // Ctrl-drag disabled
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);
+ m_pMaintable->setColumnStretchable(g_knCols - 1, true);
+ m_pMaintable->setSorting(true);
// Table header row
m_pTablehead = m_pMaintable->horizontalHeader();
+ m_pMaintable->setHScrollBarMode(QScrollView::AlwaysOff);
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);
- }
+// for (int i = 0; i < g_knRows; ++i)
+// m_pMaintable->setItem(i, 0, new QTableItem(m_pMaintable, QTableItem::WhenCurrent, NULL));
- // 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);
- }
+ m_pPackagelayout->addWidget(m_pMaintable); // Finally add the damn table
+}
- // 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);
- }
+//
+// Construct the bottom edit widgets
+//
+void Titraqform::setupEditlay(void)
+{
+ // Make the date selector
+ QDate Sylvestre(2002, 12, 31);
+ QDateEdit *m_pDateedit = new QDateEdit(Sylvestre, m_pCenframe, "Date");
+ if (m_pDateedit == NULL) // Sanity check
+ throw Genexcept("Main window date edit creation failed."); // Spew errors
+ m_pDatelayout->addWidget(m_pDateedit); // Finally add the date editor
+
+ QToolTip::add(m_pDateedit, trUtf8("Task Date"));
+
+ // Whatsthis info for the date editor
+ const char *kszDateedit = trUtf8("Edit the <em>task date</em> by clicking on"
+ " the year, month, or day, and then changing their"
+ " values with the arrow buttons.");
+ QWhatsThis::add(m_pDateedit, kszDateedit);
+
+ // Make the start time selector
+ QTimeEdit *m_pStarttime = new QTimeEdit(QTime::currentTime(), m_pCenframe, "StartTime");
+ if (m_pStarttime == NULL) // Sanity check
+ throw Genexcept("Main window start time creation failed."); // Spew errors
+ m_pDatelayout->addWidget(m_pStarttime); // Finally add the start editor
+
+ QToolTip::add(m_pStarttime, trUtf8("Task Starting Time"));
+
+ // Whatsthis info for the time editor
+ const char *kszStarttime = trUtf8("Edit the <em>task starting time</em> by clicking on"
+ " the hour and minute, and then changing their"
+ " values with the arrow buttons.");
+ QWhatsThis::add(m_pStarttime, kszStarttime);
+
+ // Make the end time selector
+ QTimeEdit *m_pEndtime = new QTimeEdit(QTime::currentTime(), m_pCenframe, "EndTime");
+ if (m_pEndtime == NULL) // Sanity check
+ throw Genexcept("Main window end time creation failed."); // Spew errors
+ m_pDatelayout->addWidget(m_pEndtime); // Finally add the end editor
+
+ QToolTip::add(m_pEndtime, trUtf8("Task Ending Time"));
+
+ // Whatsthis info for the time editor
+ const char *kszEndtime = trUtf8("Edit the <em>task ending time</em> by clicking on"
+ " the hour and minute, and then changing their"
+ " values with the arrow buttons.");
+ QWhatsThis::add(m_pEndtime, kszEndtime);
+
+ // Make the amount selector
+ QSpinBox *m_pAmount = new QSpinBox(m_pCenframe, "Amount");
+ if (m_pAmount == NULL) // Sanity check
+ throw Genexcept("Main window amount creation failed."); // Spew errors
+ m_pDatelayout->addWidget(m_pAmount); // Finally add the amount editor
+
+ QToolTip::add(m_pAmount, trUtf8("Task Amount"));
+
+ // Whatsthis info for the amount editor
+ const char *kszAmount = trUtf8("Edit the <em>task amount</em> by clicking on"
+ " the amount, and then changing its"
+ " value with the arrow buttons.");
+ QWhatsThis::add(m_pAmount, kszAmount);
- // Populate the task stringlist
+ // Populate the stringlist with fresh tasks
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 combobox task edit
+ QComboBox *m_pTasks = new QComboBox(true, m_pCenframe, "Tasks");
+ if (m_pTasks == NULL) // Sanity check
+ throw Genexcept("Main window task edit creation failed.");
+ m_pTasks->insertStringList(*m_pTaskentries);
+ m_pTasks->setCurrentText(NULL);
+ m_pTasks->setAutoCompletion(true);
+
+ // Fix the minimum width, and add an auto scroll bar to it
+ if (m_pTasks->listBox()) { // Motif style has no list box
+ m_pTasks->listBox()->setHScrollBarMode(QScrollView::Auto);
+ m_pTasks->setMinimumWidth(m_pTasks->listBox()->maxItemWidth());
}
-// // 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);
-// }
+ // Finally add the task edit
+ m_pTasklayout->addWidget(m_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); // Finally add the status bar
-
- // 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);
+ // Make the Remark line
+ m_pRemark = new QLineEdit(m_pCenframe, "Remark");
+ if (m_pRemark == NULL) // Sanity check
+ throw Genexcept("Main window remark line creation failed.");
+ m_pRemark->setText(trUtf8("Happy birthday to Ralf"));
+ m_pRemark->setFrameShape(QLineEdit::LineEditPanel);
+ m_pRemark->setFrameShadow(QLineEdit::Sunken);
+ m_pRemark->setFrame(true);
+ m_pRemark->setReadOnly(false);
+ QToolTip::add(m_pRemark, trUtf8("Remark Line"));
+ m_pTasklayout->addWidget(m_pRemark); // Finally add the remark line
+
+ // Whatsthis info for the remark line
+ const char *kszRemarktext = trUtf8("Edit the <em>task remarks</em> by clicking on"
+ " this line control and typing the remarks you"
+ " have about the task.");
+ QWhatsThis::add(m_pRemark, kszRemarktext);
}
//
|