--- as_assist.cpp 2002/12/18 14:50:58 1.75
+++ as_assist.cpp 2002/12/19 20:46:26 1.76
@@ -55,18 +55,23 @@
// User interface
#include "as_gui.h" // Main classes
-#include "as_except.h" // Exception classes
#include "as_amount.h" // AmountBox class
// Icon pixel maps
#include "as_gfx/filenew.xpm" // static const char *s_kpcFilenew_xpm[]
#include "as_gfx/fileopen.xpm" // static const char *s_kpcFileopen_xpm[]
#include "as_gfx/filesave.xpm" // static const char *s_kpcFilesave_xpm[]
+#include "as_gfx/filesaved.xpm" // static const char *s_kpcDfilesave_xpm[]
#include "as_gfx/cut.xpm" // static const char *s_kpcCut_xpm[]
+#include "as_gfx/cutd.xpm" // static const char *s_kpcDcut_xpm[]
#include "as_gfx/copy.xpm" // static const char *s_kpcCopy_xpm[]
+#include "as_gfx/copyd.xpm" // static const char *s_kpcDcopy_xpm[]
#include "as_gfx/paste.xpm" // static const char *s_kpcPaste_xpm[]
+#include "as_gfx/pasted.xpm" // static const char *s_kpcDcaste_xpm[]
#include "as_gfx/rowadd.xpm" // static const char *s_kpcRowadd_xpm[]
#include "as_gfx/rowdel.xpm" // static const char *s_kpcRowdel_xpm[]
+#include "as_gfx/rowaddd.xpm" // static const char *s_kpcDrowadd_xpm[]
+#include "as_gfx/rowdeld.xpm" // static const char *s_kpcDrowdel_xpm[]
#include "as_gfx/osspicon.xpm" // static const char *s_kpcOsspicon_xpm[]
#include "as_gfx/whatsthis.xpm" // static const char *s_kpcWhatsthis_xpm[]
#include "as_gfx/statok.xpm" // static const char *s_kpcStatokay_xpm[]
@@ -74,6 +79,7 @@
#include "as_gfx/statwrn.xpm" // static const char *s_kpcStatwarn_xpm[]
#include "as_gfx/statvoid.xpm" // static const char *s_kpcStatvoid_xpm[]
#include "as_gfx/refresh.xpm" // static const char *s_kpcRefresh_xpm[]
+#include "as_gfx/refreshd.xpm" // static const char *s_kpcDrefresh_xpm[]
//
@@ -169,6 +175,25 @@
//
void Titraqform::setupActions(void)
{
+ QIconSet Saveiset, Cutiset, Copyiset, Pasteiset;
+ QIconSet Rowaddiset, Rowdeliset, Refreshiset;
+
+ // Construct iconsets to use later for multistate action images
+ Saveiset.setPixmap(QPixmap(s_kpcFilesave_xpm), QIconSet::Automatic, QIconSet::Normal);
+ Saveiset.setPixmap(QPixmap(s_kpcDfilesave_xpm), QIconSet::Automatic, QIconSet::Disabled);
+ Cutiset.setPixmap(QPixmap(s_kpcCut_xpm), QIconSet::Automatic, QIconSet::Normal);
+ Cutiset.setPixmap(QPixmap(s_kpcDcut_xpm), QIconSet::Automatic, QIconSet::Disabled);
+ Copyiset.setPixmap(QPixmap(s_kpcCopy_xpm), QIconSet::Automatic, QIconSet::Normal);
+ Copyiset.setPixmap(QPixmap(s_kpcDcopy_xpm), QIconSet::Automatic, QIconSet::Disabled);
+ Pasteiset.setPixmap(QPixmap(s_kpcPaste_xpm), QIconSet::Automatic, QIconSet::Normal);
+ Pasteiset.setPixmap(QPixmap(s_kpcDpaste_xpm), QIconSet::Automatic, QIconSet::Disabled);
+ Rowaddiset.setPixmap(QPixmap(s_kpcRowadd_xpm), QIconSet::Automatic, QIconSet::Normal);
+ Rowaddiset.setPixmap(QPixmap(s_kpcDrowadd_xpm), QIconSet::Automatic, QIconSet::Disabled);
+ Rowdeliset.setPixmap(QPixmap(s_kpcRowdel_xpm), QIconSet::Automatic, QIconSet::Normal);
+ Rowdeliset.setPixmap(QPixmap(s_kpcDrowdel_xpm), QIconSet::Automatic, QIconSet::Disabled);
+ Refreshiset.setPixmap(QPixmap(s_kpcRefresh_xpm), QIconSet::Automatic, QIconSet::Normal);
+ Refreshiset.setPixmap(QPixmap(s_kpcDrefresh_xpm), QIconSet::Automatic, QIconSet::Disabled);
+
// First associate the graphics with MIME types
QMimeSourceFactory::defaultFactory()->setPixmap("osspicon", QPixmap(s_kpcOsspicon_xpm));
QMimeSourceFactory::defaultFactory()->setPixmap("filenew", QPixmap(s_kpcFilenew_xpm));
@@ -206,7 +231,7 @@
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");
+ m_pFilesaveact = new QAction(trUtf8("Save File"), Saveiset, 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(saveFile()));
@@ -220,7 +245,7 @@
// File save selected action
m_pFilesaveasact = new QAction(trUtf8("Save File As"), trUtf8("Save &As..."), 0, this, "SaveAs");
- if (m_pFilesaveasact == NULL) // Sanity check
+ 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);
@@ -236,9 +261,10 @@
if (m_pFilequitact == NULL) // Sanity check
throw Genexcept("Main window file quit action creation failed.");
connect(m_pFilequitact, SIGNAL(activated()), this, SLOT(close()));
+ connect(m_pFilequitact, SIGNAL(activated()), qApp, SLOT(quit()));
// Cut action
- m_pCutact = new QAction(trUtf8("Cut"), QPixmap(s_kpcCut_xpm), trUtf8("&Cut"), CTRL+Key_X, this, "Cut");
+ m_pCutact = new QAction(trUtf8("Cut"), Cutiset, trUtf8("&Cut"), CTRL+Key_X, 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()));
@@ -249,7 +275,7 @@
m_pCutact->setWhatsThis(kszCuttext);
// Copy action
- m_pCopyact = new QAction(trUtf8("Copy"), QPixmap(s_kpcCopy_xpm), trUtf8("&Copy"), CTRL+Key_C, this, "Copy");
+ m_pCopyact = new QAction(trUtf8("Copy"), Copyiset, trUtf8("&Copy"), CTRL+Key_C, 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()));
@@ -260,7 +286,7 @@
m_pCopyact->setWhatsThis(kszCopytext);
// Paste action
- m_pPasteact = new QAction(trUtf8("Paste"), QPixmap(s_kpcPaste_xpm), trUtf8("&Paste"), CTRL+Key_V, this, "Paste");
+ m_pPasteact = new QAction(trUtf8("Paste"), Pasteiset, trUtf8("&Paste"), CTRL+Key_V, 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()));
@@ -271,7 +297,7 @@
m_pPasteact->setWhatsThis(kszPastetext);
// Add data row action
- m_pAddrowact = new QAction(trUtf8("Add Row"), QPixmap(s_kpcRowadd_xpm), trUtf8("&Add row"), Key_Insert, this, "Addrow");
+ m_pAddrowact = new QAction(trUtf8("Add Row"), Rowaddiset, trUtf8("&Add row"), Key_Insert, 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()));
@@ -282,7 +308,7 @@
m_pAddrowact->setWhatsThis(kszAddrowtext);
// Delete data row action
- m_pDelrowact = new QAction(trUtf8("Delete Row"), QPixmap(s_kpcRowdel_xpm), trUtf8("&Delete row"), Key_Delete, this, "Delrow");
+ m_pDelrowact = new QAction(trUtf8("Delete Row"), Rowdeliset, trUtf8("&Delete row"), Key_Delete, this, "Delrow");
if (m_pDelrowact == NULL) // Sanity check
throw Genexcept("Main window delete row action creation failed.");
connect(m_pDelrowact, SIGNAL(activated()), this, SLOT(delEntry()));
@@ -293,7 +319,7 @@
m_pDelrowact->setWhatsThis(kszDelrowtext);
// Refresh data display action
- m_pRefreshact = new QAction(trUtf8("Refresh Display"), QPixmap(s_kpcRefresh_xpm), trUtf8("&Refresh display"), CTRL+Key_R, this, "Refresh");
+ m_pRefreshact = new QAction(trUtf8("Refresh Display"), Refreshiset, trUtf8("&Refresh display"), CTRL+Key_R, this, "Refresh");
if (m_pRefreshact == NULL) // Sanity check
throw Genexcept("Main window refresh action creation failed.");
connect(m_pRefreshact, SIGNAL(activated()), this, SLOT(refreshDisplay()));
@@ -487,7 +513,7 @@
throw Genexcept("Main window central frame creation failed.");
m_pCenframe->setFrameShape(QFrame::StyledPanel);
m_pCenframe->setFrameShadow(QFrame::Sunken);
- setCentralWidget(m_pCenframe);
+ this->setCentralWidget(m_pCenframe);
// Layout controls for table, editing widgets
m_pMainlayout = new QVBoxLayout(m_pCenframe, TITRAQ_MARGIN, TITRAQ_SPACING, "Mainlayout"); // For layouts
@@ -518,16 +544,15 @@
//
void Titraqform::setupTable(void)
{
- // The table itself
+ // Create, configure, and setup the table itself
m_pMaintable = new TiTable(m_pCenframe, "Maintable");
if (m_pMaintable == NULL) // Sanity check
throw Genexcept("Main window table creation failed.");
m_pMaintable->setNumCols(TITRAQ_IDXTAIL);
+ m_pMaintable->setDirty(false); // Reset data to clean state
m_pMaintable->setReadOnly(true); // Table is read only
- m_pMaintable->setEnabled(false); // Table starts disabled
m_pMaintable->setColumnMovingEnabled(false); // Ctrl-drag disabled
m_pMaintable->setSelectionMode(QTable::MultiRow); // Multi row selection
- m_pMaintable->setCurrentCell(-1, 0); // Initial row value -1
m_pMaintable->setFocusStyle(QTable::FollowStyle); // How cells are drawn
m_pMaintable->setLeftMargin(0); // Get rid of the vertical header
m_pMaintable->verticalHeader()->hide(); // by hiding it with a margin of 0
@@ -889,3 +914,41 @@
m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXWHATBAR), false);
}
}
+
+//
+// [En|dis]able most ui pieces to suit or restrict user
+//
+void Titraqform::enableIface(bool bTurned)
+{
+ if (!bTurned)
+ m_pMaintable->setNumRows(0); // Remove table data
+
+ // Enable or disable the widgets
+ m_pMaintable->setEnabled(bTurned);
+ m_pLineedit->setEnabled(bTurned);
+ m_pUseredit->setEnabled(bTurned);
+ m_pGuidedit->setEnabled(bTurned);
+ m_pCrcedit->setEnabled(bTurned);
+ m_pRevedit->setEnabled(bTurned);
+ m_pDateedit->setEnabled(bTurned);
+ m_pStarttime->setEnabled(bTurned);
+ m_pEndtime->setEnabled(bTurned);
+ m_pAmount->setEnabled(bTurned);
+ m_pTasks->setEnabled(bTurned);
+ m_pRemark->setEnabled(bTurned);
+
+ // Enable or disable the actions
+ m_pFilesaveact->setEnabled(bTurned);
+ m_pFilesaveasact->setEnabled(bTurned);
+ m_pFilecloseact->setEnabled(bTurned);
+ m_pAddrowact->setEnabled(bTurned);
+ m_pDelrowact->setEnabled(bTurned);
+ m_pRefreshact->setEnabled(bTurned);
+ m_pCutact->setEnabled(bTurned);
+ m_pCopyact->setEnabled(bTurned);
+ m_pPasteact->setEnabled(bTurned);
+
+ // Unconditional settings
+ this->updEdit(0, 0); // Update edit controls
+ m_pMaintable->setDirty(false); // Reset to clean data
+}
|