--- as_gui.cpp 2002/11/11 21:39:08 1.2
+++ as_gui.cpp 2002/11/12 19:16:00 1.3
@@ -1,6 +1,12 @@
// System interface
+#include <qapplication.h>
#include <qtooltip.h>
-#include <qwhatsthis.h>
+#include <qdatetime.h>
+#include <qdatetimeedit.h>
+#include <qspinbox.h>
+#include <qstringlist.h>
+#include <qcombobox.h>
+#include <qcursor.h>
// User interface
#include "titraq.h" // Main classes
@@ -9,24 +15,32 @@
// Used in initialization of the application
void Titraqform::init()
{
- pDeletebutton->setBackgroundColor(darkYellow);
- pMaintable->setFocus();
+ pAddbutton->setPaletteBackgroundColor(QColor(196, 196, 176));
+ pDeletebutton->setPaletteBackgroundColor(QColor(196, 196, 176));
+ pWritebutton->setPaletteBackgroundColor(QColor(196, 196, 176));
+ pQuitbutton->setPaletteBackgroundColor(QColor(196, 196, 176));
+ pMaintable->setCurrentCell(0, 0); // Set the initial focus
+ pMaintable->setFocus(); // Focus on the table
}
//
// Construct a Titraqform which is a child of 'pParent', with the
// name 'kszName' and widget flags set to 'Flags'
//
-Titraqform::Titraqform(QWidget *pParent, const char *kszName, bool bModal,
- WFlags Flags) : QDialog(pParent, kszName, bModal, Flags)
+Titraqform::Titraqform(QWidget *pParent, const char *kszName, WFlags Flags) :
+ QMainWindow(pParent, kszName, Flags)
{
if (!kszName)
setName("Titraqform");
resize(600, 480);
setCaption(trUtf8("OSSP Titraq"));
+ // Create a central frame and associated layout for QMainWindow
+ QFrame *pCenframe = new QFrame(this);
+ this->setCentralWidget(pCenframe);
+
// Control layouts for form, table, and status line
- pTitraqformlayout = new QVBoxLayout(this, 11, 6, "pTitraqformlayout");
+ pTitraqformlayout = new QVBoxLayout(pCenframe, 11, 6, "pTitraqformlayout");
pMainlayout = new QVBoxLayout(0, 0, 6, "pMainlayout"); // For layouts
pPackagelayout = new QVBoxLayout(0, 0, 6, "pPackagelayout"); // For table
@@ -35,7 +49,7 @@
pMaintable->setNumRows(knRows);
pMaintable->setNumCols(knCols);
pMaintable->setReadOnly(false); // Not read only
- pMaintable->setColumnMovingEnabled(true);
+ pMaintable->setColumnMovingEnabled(true); // Ctrl-drag of headers
pMaintable->setSelectionMode(QTable::MultiRow); // Multi row selection
pMaintable->setLeftMargin(0); // Get rid of the vertical header
pMaintable->verticalHeader()->hide(); // by hiding it with a margin of 0
@@ -44,36 +58,89 @@
// Table header row
pTablehead = pMaintable->horizontalHeader();
- pTablehead->setLabel(0, QObject::tr("Date"), 76);
- pTablehead->setLabel(1, QObject::tr("Begin"));
- pTablehead->setLabel(2, QObject::tr("End"));
+ pTablehead->setLabel(0, QObject::tr("Date"), 96);
+ pTablehead->setLabel(1, QObject::tr("Begin"), 80);
+ pTablehead->setLabel(2, QObject::tr("End"), 80);
pTablehead->setLabel(3, QObject::tr("Amount"), 52);
- pTablehead->setLabel(4, QObject::tr("Task"), 60);
+ pTablehead->setLabel(4, QObject::tr("Task"), 70);
pTablehead->setLabel(5, QObject::tr("Remark"));
pTablehead->setMovingEnabled(true);
- // Icon table items
+ // Icon image items
pIconimage = new QImage(ossplogo_xpm);
pIconpixmap = new QPixmap(pIconimage->scaleHeight(pMaintable->rowHeight(6)));
- pMaintable->setPixmap(3, 2, *pIconpixmap);
- pMaintable->setText(3, 2, "OSSP Titraq");
+ pMaintable->setItem(0, 0, new QTableItem(pMaintable, QTableItem::Never, "OSSP trac"));
+ pMaintable->setPixmap(0, 0, *pIconpixmap);
+
+// // Make a generic table item for all rows
+// for (int i = 1; i < knRows; ++i)
+// pMaintable->setItem(i, 0, new QTableItem(pMaintable, QTableItem::Always, ("Enter")));
+
+ // Make the date selector for all rows
+ for (int i = 1; i < knRows; ++i) {
+ QDate *pSylvestre = new QDate(2002, 12, 31);
+ QDateEdit *pDateEdit = new QDateEdit(*pSylvestre, pMaintable, "Date");
+ pMaintable->setCellWidget(i, 0, pDateEdit);
+ }
+
+ // Make the time start selector for all rows
+ for (int i = 0; i < knRows; ++i) {
+ QTimeEdit *pStart = new QTimeEdit(QTime::currentTime(), pMaintable, "Start");
+ pMaintable->setCellWidget(i, 1, pStart);
+ }
+
+ // Make the time end selector for all rows
+ for (int i = 0; i < knRows; ++i) {
+ QTimeEdit *pEnd = new QTimeEdit(QTime::currentTime(), pMaintable, "End");
+ pMaintable->setCellWidget(i, 2, pEnd);
+ }
+
+ // Make the amount selector for all rows
+ for (int i = 0; i < knRows; ++i) {
+ QSpinBox *pAmount = new QSpinBox(pMaintable, "Amount");
+ pMaintable->setCellWidget(i, 3, pAmount);
+ }
- // Set contents of a generic combobox
- pComboentries = new QStringList;
- *pComboentries << "uno" << "dos" << "tres" << "quatro";
+ // Populate the task stringlist
+ pTaskentries = new QStringList;
+ *pTaskentries << "titraq" << "opgui" << "email"<< "admin" << "pmod" << "psod" << "meeting" << "training";
// Make the combobox items for all rows
for (int i = 0; i < knRows; ++i) {
- QComboTableItem *pComboitem = new QComboTableItem(pMaintable, *pComboentries, false);
- pComboitem->setCurrentItem(i % 4);
- pMaintable->setItem(i, 4, pComboitem);
+ QComboBox *pTasks = new QComboBox(true, pMaintable, "Tasks");
+ pTasks->insertStringList(*pTaskentries);
+ pTasks->setCurrentText(NULL);
+ pTasks->setAutoCompletion(true);
+ pMaintable->setCellWidget(i, 4, pTasks);
}
- // Make the checkbox items for all rows
- for (int j = 0; j < knRows; ++j)
- pMaintable->setItem(j, 1, new QCheckTableItem(pMaintable, "Checkung"));
+// // Make the listbox for all rows
+// for (int i = 0; i < knRows; ++i) {
+// QListBox *pTasks = new QListBox(pMaintable, "Tasks");
+// pTasks->insertStringList(*pTaskentries);
+// pTasks->setCurrentItem(i % 8);
+// pMaintable->setCellWidget(i, 4, pTasks);
+// }
+
+// // Populate a listbox for the task combobox
+// QListBox *pListasks = new QListBox(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(pMaintable, *pTaskentries, false);
+// pTasks->setCurrentItem(i % 8);
+// pMaintable->setItem(i, 4, pTasks);
+// }
- pPackagelayout->addWidget(pMaintable); // Finally add the table widget
+ pPackagelayout->addWidget(pMaintable); // Finally add the table widget
// Bottom output line
pStatus = new QLineEdit(this, "pStatus");
@@ -81,6 +148,7 @@
pStatus->setFrameShadow(QLineEdit::Sunken);
pStatus->setFrame(true);
pStatus->setReadOnly(true);
+ QToolTip::add(pStatus, trUtf8("&Status line"));
pPackagelayout->addWidget(pStatus);
pMainlayout->addLayout(pPackagelayout);
@@ -91,6 +159,8 @@
pAddbutton = new QPushButton(this, "AddButton");
pAddbutton->setCursor(QCursor(13));
pAddbutton->setText(trUtf8("&Add"));
+ QToolTip::add(pAddbutton, trUtf8("&Add entry"));
+ connect(pAddbutton, SIGNAL(clicked()), this, SLOT(addEntry()));
pControllayout->addWidget(pAddbutton);
// Tuple push button delete
@@ -98,20 +168,52 @@
pDeletebutton->setCursor(QCursor(13));
pDeletebutton->setText(trUtf8("&Delete"));
pDeletebutton->setFlat(false);
+ QToolTip::add(pDeletebutton, trUtf8("&Delete entry"));
+ connect(pDeletebutton, SIGNAL(clicked()), this, SLOT(delEntry()));
pControllayout->addWidget(pDeletebutton);
// Tuple push button write
pWritebutton = new QPushButton(this, "pWritebutton");
- pWritebutton->setPaletteBackgroundColor(QColor(186, 156, 144));
pWritebutton->setCursor(QCursor(13));
pWritebutton->setText(trUtf8("&Write"));
+ QToolTip::add(pWritebutton, trUtf8("&Write entry"));
+ connect(pWritebutton, SIGNAL(clicked()), this, SLOT(writeEntry()));
pControllayout->addWidget(pWritebutton);
+
+ // Tuple push button quit
+ pQuitbutton = new QPushButton(this, "pQuitbutton");
+ pQuitbutton->setCursor(QCursor(13));
+ pQuitbutton->setText(trUtf8("&Quit"));
+ pQuitbutton->setFlat(false);
+ QToolTip::add(pQuitbutton, trUtf8("&Quit"));
+ connect(pQuitbutton, SIGNAL(clicked()), qApp, SLOT(quit()));
+ pControllayout->addWidget(pQuitbutton);
+
pMainlayout->addLayout(pControllayout);
pTitraqformlayout->addLayout(pMainlayout);
init(); // Initialize signal and slot connections
}
+void Titraqform::addEntry()
+{
+// if (!pTable->text().isEmpty()) {
+// QTableRow *pRow = new QTableRow;
+// pRow->setText(0, NULL);
+// pRow->setText(1, NULL);
+// pRow->setText(2, NULL);
+// pRow->setText(3, NULL);
+// }
+}
+
+void Titraqform::delEntry()
+{
+}
+
+void Titraqform::writeEntry()
+{
+}
+
//
// Destroy the object and free any allocated resources
//
|