head 1.43; access; symbols AS_AFTER_RESTRUCTURING:1.23; locks; strict; comment @// @; 1.43 date 2004.05.27.21.48.41; author ms; state Exp; branches; next 1.42; 1.42 date 2004.05.27.21.42.26; author ms; state Exp; branches; next 1.41; 1.41 date 2003.11.20.11.31.20; author ms; state Exp; branches; next 1.40; 1.40 date 2003.02.14.17.31.54; author ms; state Exp; branches; next 1.39; 1.39 date 2003.02.04.19.30.31; author ms; state Exp; branches; next 1.38; 1.38 date 2003.01.31.18.48.57; author ms; state Exp; branches; next 1.37; 1.37 date 2003.01.29.17.05.31; author ms; state Exp; branches; next 1.36; 1.36 date 2003.01.28.17.33.55; author ms; state Exp; branches; next 1.35; 1.35 date 2003.01.28.16.41.15; author ms; state Exp; branches; next 1.34; 1.34 date 2003.01.16.08.37.40; author ms; state Exp; branches; next 1.33; 1.33 date 2002.12.19.20.46.26; author ms; state Exp; branches; next 1.32; 1.32 date 2002.12.18.14.50.58; author ms; state Exp; branches; next 1.31; 1.31 date 2002.12.12.21.24.07; author ms; state Exp; branches; next 1.30; 1.30 date 2002.12.12.21.13.29; author ms; state Exp; branches; next 1.29; 1.29 date 2002.12.12.20.52.13; author ms; state Exp; branches; next 1.28; 1.28 date 2002.12.12.13.35.45; author ms; state Exp; branches; next 1.27; 1.27 date 2002.12.12.12.45.46; author ms; state Exp; branches; next 1.26; 1.26 date 2002.12.12.12.19.48; author ms; state Exp; branches; next 1.25; 1.25 date 2002.12.04.11.41.55; author ms; state Exp; branches; next 1.24; 1.24 date 2002.12.02.13.25.36; author ms; state Exp; branches; next 1.23; 1.23 date 2002.11.28.20.44.36; author ms; state Exp; branches; next 1.22; 1.22 date 2002.11.26.20.38.19; author ms; state Exp; branches; next 1.21; 1.21 date 2002.11.26.14.10.32; author ms; state Exp; branches; next 1.20; 1.20 date 2002.11.24.23.11.56; author ms; state Exp; branches; next 1.19; 1.19 date 2002.11.24.20.39.32; author ms; state Exp; branches; next 1.18; 1.18 date 2002.11.24.17.56.54; author ms; state Exp; branches; next 1.17; 1.17 date 2002.11.20.11.06.32; author ms; state Exp; branches; next 1.16; 1.16 date 2002.11.19.19.42.14; author ms; state Exp; branches; next 1.15; 1.15 date 2002.11.18.23.34.17; author ms; state Exp; branches; next 1.14; 1.14 date 2002.11.18.22.38.04; author ms; state Exp; branches; next 1.13; 1.13 date 2002.11.18.22.31.12; author ms; state Exp; branches; next 1.12; 1.12 date 2002.11.18.22.13.56; author ms; state Exp; branches; next 1.11; 1.11 date 2002.11.14.22.26.30; author ms; state Exp; branches; next 1.10; 1.10 date 2002.11.14.21.01.29; author ms; state Exp; branches; next 1.9; 1.9 date 2002.11.14.20.56.51; author ms; state Exp; branches; next 1.8; 1.8 date 2002.11.14.20.29.33; author ms; state Exp; branches; next 1.7; 1.7 date 2002.11.14.18.19.29; author ms; state Exp; branches; next 1.6; 1.6 date 2002.11.13.16.36.58; author ms; state Exp; branches; next 1.5; 1.5 date 2002.11.13.12.38.25; author ms; state Exp; branches; next 1.4; 1.4 date 2002.11.13.08.41.09; author ms; state Exp; branches; next 1.3; 1.3 date 2002.11.12.19.16.00; author ms; state Exp; branches; next 1.2; 1.2 date 2002.11.11.21.39.08; author ms; state Exp; branches; next 1.1; 1.1 date 2002.11.08.12.27.57; author ms; state Exp; branches; next ; desc @@ 1.43 log @Modernize copyright text in source and graphic headers. @ text @// // OSSP asgui - Accounting system graphical user interface // Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/) // Copyright (c) 2002-2004 Ralf S. Engelschall // Copyright (c) 2002-2004 Michael Schloh von Bennewitz // Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH // // This file is part of OSSP asgui, an accounting system graphical user // interface which can be found at http://www.ossp.org/pkg/tool/asgui/. // // Permission to use, copy, modify, and distribute this software for // any purpose with or without fee is hereby granted, provided that // the above copyright notice and this permission notice appear in all // copies. // // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // as_gui.cpp: ISO C++ implementation // // User interface #include "as_gui.h" // Main classes #include "as_except.h" // Exception classes #include "as_table.h" // Class TiTable #include "as_const.h" // Application constants #include "as_pref.h" // Class Preferences // // 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, WFlags Flags) : QMainWindow(pParent, kszName, Flags) { // Early initializations m_pFiletools = NULL; m_pEdittools = NULL; m_pViewtools = NULL; m_pWhatstools = NULL; m_szFilename = NULL; // Atenzione! Order is very important in the following sequence. // FIXME: Reorganize this procedural mess into self contained objects try { setupPrefs(); // Load general preferences setupActions(); // Create and initialize actions setupMenubar(); // Create and initialize menu bar setupToolbars(); // Create and initialize tool bars setupCentralwidget(); // Format the layout of related widgets setupStatusbar(); // Create and initialize status bar setupTable(); // Create and initialize table and cells setupEditlay(); // Create and initialize edit controls setupColumns(); // Prepare columns for viewing, sorting enableIface(false); // Start things off in a empty state } catch (Genexcept& Genex) { Genex.reportErr(); exit(1); } // Postsetup manipulations m_pMaintable->setDirty(false); if (!kszName) this->setName(trUtf8("ASGuiapp")); this->resize(m_pPrefs->getNumber(TITRAQ_PREFFRAMEWIDTH, TITRAQ_DEFFRAMEWIDTH), m_pPrefs->getNumber(TITRAQ_PREFFRAMEHEIGHT, TITRAQ_DEFFRAMEHEIGHT)); connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(savePrefs())); this->setCaption(QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short); // Rehydrate main window layout and doc positions QString Laystring = m_pPrefs->getString(TITRAQ_PREFFRAMELAY, NULL); // FIXME: Handle first case better QTextStream Laystream(&Laystring, IO_ReadOnly); Laystream >> *this; // // Lock down window size // setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, // (QSizePolicy::SizeType)0, 0, 0, sizePolicy().hasHeightForWidth())); } // // Destroy the object and free any allocated resources // Titraqform::~Titraqform(void) { // Qt deletes child widgets for us m_pPrefs->flush(); delete m_pPrefs; } @ 1.42 log @Correct file names in source headers. @ text @d3 4 a6 4 // Copyright (c) 2002-2003 The OSSP Project (http://www.ossp.org/) // Copyright (c) 2002-2003 Ralf S. Engelschall // Copyright (c) 2002-2003 Michael Schloh von Bennewitz // Copyright (c) 2002-2003 Cable & Wireless Telecommunications Services GmbH @ 1.41 log @Handle the time consuming bureaucracy of changing a company name. @ text @d29 1 a29 1 // titraq.cpp: ISO C++ implementation @ 1.40 log @Moved preference data application from panel items to own method, added applyPrefs logic, and a new proxy method to handle applied signals, and reorganized file incusion in throughout to loosen source file coupling. @ text @a3 1 // Copyright (c) 2002-2003 Cable & Wireless Deutschland (http://www.cw.com/de/) d6 1 @ 1.39 log @Implemented auto field completion for start and finish and auto subtraction for amount, added period for GUID replacement, and added version text to widget labels. @ text @d35 3 @ 1.38 log @Close remaining release problems. @ text @d73 2 a74 2 setName(trUtf8("ASGuiapp")); resize(m_pPrefs->getNumber(TITRAQ_PREFFRAMEWIDTH, TITRAQ_DEFFRAMEWIDTH), d77 1 a77 1 setCaption("AS Accounting System"); @ 1.37 log @Fixed the scroll before show bug, causing a bad data screen position. @ text @d73 1 a73 1 setName(trUtf8("Titraqform")); d77 1 a77 1 setCaption("OSSP Titraq"); @ 1.36 log @Fix the initial data loading a little more, and remove the logic from the first level gui object. @ text @a53 1 int nUnhandled; // Holds number of unhandled cmd args a63 3 nUnhandled = setupCmdargs(); // Parse the command line, and init file setupInitdata(nUnhandled); // Possibly open an inital event data file @ 1.35 log @Implemented initial file loading by shell argument, and cleaned up some other small problems. @ text @a43 2 int nUnhandled; // Holds the number of unhandled command line arguments d54 1 d65 3 a67 1 nUnhandled = setupCmdargs(); // Parse the command line, and init file a90 4 // Logic left over from setupCmdargs to help decide what our cmd parsing did if (nUnhandled == 0) // Args handled, no initial file m_pStatbar->message(trUtf8("Ready")); // Signal a ready condition @ 1.34 log @Add logic to connect and syncronize with a CORBA server. Hard code usage of MICO libraries into build configuration. @ text @d44 2 d66 1 d91 3 a93 1 m_pStatbar->message(trUtf8("Ready")); // Signal a ready condition @ 1.33 log @Added full close document and disable handling, added new dimmed icons for showing disabled state, fixed status edit control pixmap redraw, fixed remaining edit pixmap on old data, fixed get/set empy Rowdata for cut/copy/paste ops, fixed member filename corruption and data loss problem, optimized addRow and pasteRow graphic drawing, added better file name handling by accessors, and streamlined widget enablement logic in slots. @ text @d41 1 a41 1 Titraqform::Titraqform(QWidget *pParent, const char *kszName, WFlags Flags) : @ 1.32 log @Fixed row shade logic and moved dirty flag to TiTable class. @ text @d44 9 d63 1 d70 1 a70 2 // Early initializations and manipulations m_szFilename = new QString(); d76 1 @ 1.31 log @Disabled normal view menu item, and other finishes. @ text @a43 4 // Early member initialization this->setDirty(false); m_szFilename = new QString(); d60 3 a62 1 // Initial widget manipulations @ 1.30 log @Implement persistent frame layout and dock positions. @ text @d74 1 a74 1 Laystream >> *this; // Persist the main window @ 1.29 log @Many layout and preference changes to support more flexibility. @ text @d71 5 @ 1.28 log @Document code. @ text @a47 10 // Initial widget manipulations if (!kszName) setName(trUtf8("Titraqform")); resize(TITRAQ_MAINWINWIDTH, TITRAQ_MAINWINHEIGHT); setCaption("OSSP Titraq"); // // Lock down window size // setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, // (QSizePolicy::SizeType)0, 0, 0, sizePolicy().hasHeightForWidth())); d63 11 @ 1.27 log @Implement persistent toolbar preferences. @ text @a57 1 // Abstractly build main widgets d59 9 a67 9 setupPrefs(); setupActions(); setupMenubar(); setupToolbars(); setupCentralwidget(); setupStatusbar(); setupTable(); setupEditlay(); setupColumns(); @ 1.26 log @Load column view preferences on init, and save them on exit. @ text @d63 1 a63 1 setupFiletools(); @ 1.25 log @Correct startup window and widget size defaults. @ text @d68 1 @ 1.24 log @Logic changes to correct the buildconf after CVS restructure. @ text @d51 1 a51 1 resize(600, 480); @ 1.23 log @Massive build configuration preparation, added boilerplate header text, and cleaned up whitespace. @ text @d33 2 a34 2 #include "titraq.h" // Main classes #include "titrex.h" // Exception classes @ 1.22 log @Remove all push button widgets, since the enhanced edit tool has the same functionality built in. Also remove the writeData callback, to favor a better approach. @ text @d1 31 @ 1.21 log @Add edit toolbar to eventually replace bottom button matrix, and correct edit control update logic to avoid needlessly updating controls from empty fields. @ text @a5 11 // Overload init for custom initialization of the app void Titraqform::init(void) { // Set fill color of buttons m_pAddbutton->setPaletteBackgroundColor(QColor(196, 196, 176)); m_pDeletebutton->setPaletteBackgroundColor(QColor(196, 196, 176)); m_pWritebutton->setPaletteBackgroundColor(QColor(206, 192, 176)); m_pQuitbutton->setPaletteBackgroundColor(QColor(196, 196, 176)); m_pMaintable->setFocus(); // Focus on the table } a36 1 setupButtons(); a42 1 init(); // Initialize signal and slot connections @ 1.20 log @Implemented table data saving to a local file, and began new accessor method group with setDirty(). @ text @a13 1 m_pMaintable->setCurrentCell(0, 0); // Set the initial focus @ 1.19 log @Improve new preference object handling. @ text @d26 1 a26 1 m_bDirt = false; @ 1.18 log @Add a DOM based configuration file. @ text @d41 1 a49 1 setupPrefs(); d66 2 @ 1.17 log @Save time and resources by loading pixmaps on demand only. Removed some icons to unclutter the screen estate. @ text @d49 1 @ 1.16 log @Radical optimization of widget initialization and refresh. Removal of excess baggage in daily table. Addition of editing section. Apply new image logic. Reworked layouts. Improved task selection. @ text @a40 1 setupIcons(); @ 1.15 log @Put this pig to bed, after some more restructuring, handling improvements, and display optimization. @ text @d48 1 a48 1 setupOutput(); @ 1.14 log @Move slot logic to its own file, making the pig widget even slimmer. @ text @d45 1 a46 1 setupCentralwidget(); @ 1.13 log @Move methods assiting in construction of the GUI to titassist. @ text @a0 4 // Qt headers #include #include d4 1 a4 1 #include "generic.h" // Generic classes a57 193 } // // Add a blank row entry to the current data window // void Titraqform::addEntry(void) { Prototype Unimp; Unimp.doMbox(); // if (!pTable->text().isEmpty()) { // QTableRow *pRow = new QTableRow; // pRow->setText(0, NULL); // pRow->setText(1, NULL); // pRow->setText(2, NULL); // pRow->setText(3, NULL); // } } // // Choose a file using a handy file dialog // void Titraqform::delEntry(void) { Prototype Unimp; Unimp.doMbox(); } // // Write current data to a meta device // void Titraqform::writeEntry(void) { Prototype Unimp; Unimp.doMbox(); } // // Make and display a new document window // void Titraqform::newDoc(void) { Prototype Unimp; Unimp.doMbox(); // Titraqform *pNewform = new Titraqform; // pNewform->show(); } // // Choose a file using a handy file dialog // void Titraqform::choose(void) { QString Filestring = QFileDialog::getOpenFileName(QString::null, QString::null, this); if (!Filestring.isEmpty()) load(Filestring); else m_pStatbar->message(trUtf8("Loading aborted"), 4000); } // // Load accounting data into main window // void Titraqform::load(const QString &Filestring) { QFile Filetemp(Filestring); // File to load if (!Filetemp.open(IO_ReadOnly)) // Need a wrapped exception here return; QTextStream Textstream(&Filetemp); // Convert the file contents to a stream m_pStatus->setText(Textstream.read()); m_pStatus->setEdited(false); setCaption(Filestring); m_pStatbar->message(trUtf8("Loaded document ") + Filestring, 4000); } // // Serialize current state to the current file // void Titraqform::save(void) { // First time saves are really just saveAs in disguise if (m_szFilename->isEmpty()) { saveAs(); return; } // Try to read the status text, and write it to a file QString Statustext = m_pStatus->text(); QFile Filetemp(*m_szFilename); if (!Filetemp.open(IO_WriteOnly)) { m_pStatbar->message(QString(trUtf8("Could not write to %1")).arg(*m_szFilename), 4000); return; } // Serialize file contents and write to text line QTextStream Filestream(&Filetemp); Filestream << Statustext; Filetemp.close(); // Reset the text line, and give output to main window m_pStatus->setEdited(FALSE); setCaption(*m_szFilename); m_pStatbar->message(QString(trUtf8("File %1 saved")).arg(*m_szFilename), 4000); m_bDirt = false; // Set the clean state to allow a close operation } // // Serialize current state to a selected file // void Titraqform::saveAs(void) { // First get the selected file name to save to QString Filestring = QFileDialog::getSaveFileName(QString::null, QString::null, this); if (!Filestring.isEmpty()) { *m_szFilename = Filestring; m_pStatus->setText(*m_szFilename); save(); // Finish off by calling the save action } else { // User did not select a valid file and push okay button m_pStatbar->message(trUtf8("Saving aborted"), 4000); } } // // Close current document, displaying in main window // void Titraqform::closeEvent(QCloseEvent *pClosit) { // Check modification state of current data if (!this->isDirty()) { pClosit->accept(); return; } // Ask user to acknowlege a possibly data-damaging close event switch(QMessageBox::information(this, "OSSP titraq", trUtf8("The document has been\nchanged since the last save.")), trUtf8("Save Now"), trUtf8("Cancel"), trUtf8("Leave Anyway"), 0, 1) { case 0: save(); pClosit->accept(); break; case 1: default: // Just for sanity pClosit->ignore(); break; case 2: pClosit->accept(); break; } } // // Check to see if state has changed since last save // bool Titraqform::isDirty(void) { return m_bDirt; } // // Learn more about this program itself // void Titraqform::about(void) { QMessageBox::about(this, "OSSP titraq", trUtf8("OSSP titraq is a time and task-based\n" "accounting system that acts as both a\n" "nwork-like punch card and time tracker.")); } // // Learn more about the OSSP // void Titraqform::aboutOSSP(void) { QMessageBox::about(this, "OSSP", trUtf8("The open source software project (OSSP) is\n" "a collective effort aimed at implementing\n" "high-quality Unix software components,\n" "ranging from networking, multi-threading\n" "and algorithmic libraries to networking\n" "servers and development tools.")); } // // Learn more about this program and Qt // void Titraqform::aboutQt(void) { QMessageBox::aboutQt(this, "OSSP titraq"); @ 1.12 log @Break the monolithic pig-constructor into smaller pigs. @ text @a1 7 #include #include #include #include #include #include #include a4 3 // System headers #include a8 6 #include "gfx/ossplogo.xpm" // static const char *s_kpcOssplogo_xpm[] #include "gfx/qtlogo.xpm" // static const char *s_kpcQtlogo_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[] #include "gfx/whatsthis.xpm" // static const char *s_kpcWhatsthis_xpm[] a32 8 // Initialize icon images m_pOsspicon = new QImage(s_kpcOssplogo_xpm); m_pQticon = new QImage(s_kpcQtlogo_xpm); m_pNewicon = new QImage(s_kpcFilenew_xpm); m_pOpenicon = new QImage(s_kpcFileopen_xpm); m_pSaveicon = new QImage(s_kpcFilesave_xpm); m_pWhatsicon = new QImage(s_kpcWhatsthis_xpm); d45 1 a254 371 } // // 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 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("&About"), this, SLOT(about()), Key_F1); pHelppopup->insertSeparator(); pHelppopup->insertItem(QPixmap(*m_pOsspicon), trUtf8("About &OSSP"), this, SLOT(aboutOSSP())); pHelppopup->insertItem(QPixmap(*m_pQticon), trUtf8("About &Qt"), this, SLOT(aboutQt())); pHelppopup->insertSeparator(); pHelppopup->insertItem(QPixmap(*m_pWhatsicon), trUtf8("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1); } // // Construct various actions // void Titraqform::setupActions(void) { // File new action m_pFilenewact = new QAction(trUtf8("New File"), QPixmap(s_kpcFilenew_xpm), trUtf8("&New"), CTRL+Key_N, this, "New"); if (m_pFilenewact == NULL) // Sanity check throw Genexcept("Main window file new action creation failed."); connect(m_pFilenewact, SIGNAL(activated()), this, SLOT(newDoc())); QMimeSourceFactory::defaultFactory()->setPixmap("filenew", m_pFilenewact->iconSet().pixmap()); const char *kszFilenewtext = trUtf8("

" "Click this button to make a blank file." "You can also select the New command " "from the File menu.

"); m_pFilenewact->setWhatsThis(kszFilenewtext); // File open action m_pFileopenact = new QAction(trUtf8("Open File"), QPixmap(s_kpcFileopen_xpm), trUtf8("&Open"), CTRL+Key_O, this, "Open"); if (m_pFileopenact == NULL) // Sanity check throw Genexcept("Main window file open action creation failed."); connect(m_pFileopenact, SIGNAL(activated()), this, SLOT(choose())); QMimeSourceFactory::defaultFactory()->setPixmap("fileopen", m_pFileopenact->iconSet().pixmap()); const char *kszFileopentext = trUtf8("

" "Click this button to open a new file." "You can also select the Open command " "from the File menu.

"); 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"); if (m_pFilesaveact == NULL) // Sanity check throw Genexcept("Main window file save action creation failed."); connect(m_pFilesaveact, SIGNAL(activated()), this, SLOT(save())); QMimeSourceFactory::defaultFactory()->setPixmap("filesave", m_pFilesaveact->iconSet().pixmap()); const char *kszFilesavetext = trUtf8("

" "Click this button to save the file you " "are editing. You will be prompted for a file name.\n" "You can also select the Save command " "from the File menu.

"); m_pFilesaveact->setWhatsThis(kszFilesavetext); // File save selected action m_pFilesaveasact = new QAction(trUtf8("Save File As"), trUtf8("Save &as"), 0, this, "SaveAs"); 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); // File close current action m_pFilecloseact = new QAction(trUtf8("Close"), trUtf8("&Close"), CTRL+Key_W, this, "Close"); 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("&Exit"), CTRL+Key_Q, this, "Exit"); if (m_pFilequitact == NULL) // Sanity check throw Genexcept("Main window file quit action creation failed."); connect(m_pFilequitact, SIGNAL(activated()), qApp, SLOT(quit())); // Add data row action m_pAddrowact = new QAction(trUtf8("Add Row"), QPixmap(s_kpcOssplogo_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())); QMimeSourceFactory::defaultFactory()->setPixmap("ossplogo", m_pAddrowact->iconSet().pixmap()); const char *kszAddrowtext = trUtf8("

" "Click this button to add a new row." "You can also select the Add row command " "from the Accounting menu.

"); m_pAddrowact->setWhatsThis(kszAddrowtext); // Delete data row action m_pDeleterowact = new QAction(trUtf8("Add Row"), QPixmap(s_kpcOssplogo_xpm), trUtf8("Add &row"), 0, this, "Deleterow"); if (m_pDeleterowact == NULL) // Sanity check throw Genexcept("Main window delete row action creation failed."); connect(m_pDeleterowact, SIGNAL(activated()), this, SLOT(delEntry())); QMimeSourceFactory::defaultFactory()->setPixmap("ossplogo", m_pDeleterowact->iconSet().pixmap()); const char *kszDeleterowtext = trUtf8("

" "Click this button to delete a row." "You can also select the Delete row command " "from the Accounting menu.

"); m_pDeleterowact->setWhatsThis(kszDeleterowtext); // Write data action m_pWritedataact = new QAction(trUtf8("Add Row"), QPixmap(s_kpcOssplogo_xpm), trUtf8("Add &row"), 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())); QMimeSourceFactory::defaultFactory()->setPixmap("ossplogo", m_pWritedataact->iconSet().pixmap()); const char *kszWritedatatext = trUtf8("

" "Click this button to write out your accounting data." "You can also select the Write data command " "from the Accounting menu.

"); m_pWritedataact->setWhatsThis(kszWritedatatext); } // // Construct the file tool bar // void Titraqform::setupFiletools(void) { // Construct and populate the main tool bar m_pToolbar = new QToolBar("Toolfile", this, DockTop); if (m_pToolbar == NULL) // Sanity check throw Genexcept("Main window tool bar creation failed."); m_pToolbar->setLabel(trUtf8("File Ops")); m_pFilenewact->addTo(m_pToolbar); m_pFileopenact->addTo(m_pToolbar); m_pFilesaveact->addTo(m_pToolbar); QWhatsThis::whatsThisButton(m_pToolbar); // Preconfigured whats this button } // // Construct the status bar // void Titraqform::setupStatusbar(void) { m_pStatbar = statusBar(); // Grab status bar owned by QMainWindow if (m_pStatbar == NULL) // Sanity check throw Genexcept("Main window status bar nonexistant."); } // // Construct the central widget // void Titraqform::setupCentralwidget(void) { // Create a central frame and associated layout for QMainWindow m_pCenframe = new QFrame(this, "Centralframe"); if (m_pCenframe == NULL) // Sanity check throw Genexcept("Main window central frame creation failed."); m_pCenframe->setFrameShape(QFrame::StyledPanel); m_pCenframe->setFrameShadow(QFrame::Sunken); setCentralWidget(m_pCenframe); // Layout controls for table, buttons, and status line m_pMainlayout = new QVBoxLayout(m_pCenframe, 10, 6, "Mainlayout"); // For layouts m_pPackagelayout = new QVBoxLayout(0, 0, 6, "Packagelayout"); // For table m_pControllayout = new QHBoxLayout(0, 0, 6, "Controllayout"); // For buttons if (!(m_pMainlayout && m_pMainlayout && m_pMainlayout)) // Sanity check throw Genexcept("Main window layout creation failed."); // Specify ordering of the layouts m_pMainlayout->addLayout(m_pPackagelayout); m_pMainlayout->addLayout(m_pControllayout); } // // Construct the table // void Titraqform::setupTable(void) { // The table itself m_pMaintable = new QTable(m_pCenframe, "Maintable"); if (m_pMaintable == NULL) // Sanity check 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->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); // Table header row m_pTablehead = m_pMaintable->horizontalHeader(); 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); } // 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); } // 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); } // Populate the task stringlist 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 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); // } 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); // Whatsthis info for the output line const char *kszStatouttext = trUtf8("

" "This line shows the current row of your accounting data." " You can also change the data in place, or above " "from the Accounting table."); QWhatsThis::add(m_pStatus, kszStatouttext); } // // Construct the buttons // void Titraqform::setupButtons(void) { // Tuple push button add m_pAddbutton = new QPushButton(m_pCenframe, "AddButton"); if (m_pAddbutton == NULL) // Sanity check throw Genexcept("Main window add button creation failed."); m_pAddbutton->setCursor(QCursor(13)); m_pAddbutton->setText(trUtf8("&Add")); QToolTip::add(m_pAddbutton, trUtf8("Add Entry")); connect(m_pAddbutton, SIGNAL(clicked()), this, SLOT(addEntry())); m_pControllayout->addWidget(m_pAddbutton); // Tuple push button delete m_pDeletebutton = new QPushButton(m_pCenframe, "Deletebutton"); if (m_pDeletebutton == NULL) // Sanity check throw Genexcept("Main window delete button creation failed."); m_pDeletebutton->setCursor(QCursor(13)); m_pDeletebutton->setText(trUtf8("&Delete")); m_pDeletebutton->setFlat(false); QToolTip::add(m_pDeletebutton, trUtf8("Delete Entry")); connect(m_pDeletebutton, SIGNAL(clicked()), this, SLOT(delEntry())); m_pControllayout->addWidget(m_pDeletebutton); // Tuple push button write m_pWritebutton = new QPushButton(m_pCenframe, "Writebutton"); if (m_pWritebutton == NULL) // Sanity check throw Genexcept("Main window write button creation failed."); m_pWritebutton->setCursor(QCursor(13)); m_pWritebutton->setText(trUtf8("&Write")); QToolTip::add(m_pWritebutton, trUtf8("Write Entry")); connect(m_pWritebutton, SIGNAL(clicked()), this, SLOT(writeEntry())); m_pControllayout->addWidget(m_pWritebutton); // Tuple push button quit m_pQuitbutton = new QPushButton(m_pCenframe, "Quitbutton"); if (m_pQuitbutton == NULL) // Sanity check throw Genexcept("Main window quit button creation failed."); m_pQuitbutton->setCursor(QCursor(13)); m_pQuitbutton->setText(trUtf8("&Quit")); m_pQuitbutton->setFlat(false); QToolTip::add(m_pQuitbutton, trUtf8("Quit titraq")); connect(m_pQuitbutton, SIGNAL(clicked()), qApp, SLOT(quit())); m_pControllayout->addWidget(m_pQuitbutton); @ 1.11 log @Actions added for push buttons, whatsthis text added for all actions, and more features added. Write button is now red. @ text @d1 1 a1 1 // System interface d12 3 d16 9 a24 6 #include "titraq.h" // Main classes #include "generic.h" // Generic classes #include "gfx/ossplogo.xpm" // OSSP logo: static const char *s_kpcOssplogo_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[] d45 11 a55 5 // // Abstract main widget building // setupMenubar(); // setupFiletools(); // setupStatusbar(); // setupCentralwidget(); a60 2 m_pMenubar = menuBar(); // Setup the menu bar m_pStatbar = statusBar(); // Setup the status bar d67 221 a287 3 // Early member initialization m_bDirt = false; m_szFilename = new QString(); d292 33 d327 2 d339 2 d351 2 d364 2 d371 2 d376 3 a378 1 m_pFilequitact = new QAction(trUtf8("Quit"), trUtf8("&Quit"), CTRL+Key_Q, this, "Quit"); d383 2 d395 2 d407 2 d416 1 d418 5 a422 19 // Construct and populate the file menu with actions QPopupMenu *pFilepopup = new QPopupMenu(this); m_pMenubar->insertItem(trUtf8("&File"), pFilepopup); m_pFilenewact->addTo(pFilepopup); m_pFileopenact->addTo(pFilepopup); m_pFilesaveact->addTo(pFilepopup); m_pFilesaveasact->addTo(pFilepopup); pFilepopup->insertSeparator(); m_pFilecloseact->addTo(pFilepopup); m_pFilequitact->addTo(pFilepopup); // Construct and populate the help menu with subitems QPopupMenu *pHelppopup = new QPopupMenu(this); m_pMenubar->insertItem(trUtf8("&Help"), pHelppopup); pHelppopup->insertItem(trUtf8("&About"), this, SLOT(about()), Key_F1); pHelppopup->insertItem(trUtf8("About &Qt"), this, SLOT(aboutQt())); pHelppopup->insertSeparator(); pHelppopup->insertItem(trUtf8("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1); d425 2 d432 1 d434 15 d451 2 d457 1 a457 1 // Layout controls for toolbar, table, buttons, and status line d462 3 d468 1 d470 5 d477 2 d500 1 a500 2 m_pIconimage = new QImage(s_kpcOssplogo_xpm); m_pIconpixmap = new QPixmap(m_pIconimage->scaleHeight(m_pMaintable->rowHeight(6))); d502 1 a502 1 m_pMaintable->setPixmap(0, 0, *m_pIconpixmap); d535 2 d575 1 d577 5 d584 2 d600 1 d602 5 d609 2 d619 2 d630 2 d640 2 a648 181 init(); // Initialize signal and slot connections m_pStatbar->message(trUtf8("Ready")); // Signal a ready condition } // // Add a blank row entry to the current data window // void Titraqform::addEntry(void) { Prototype Unimp; Unimp.doMbox(); // if (!pTable->text().isEmpty()) { // QTableRow *pRow = new QTableRow; // pRow->setText(0, NULL); // pRow->setText(1, NULL); // pRow->setText(2, NULL); // pRow->setText(3, NULL); // } } // // Choose a file using a handy file dialog // void Titraqform::delEntry(void) { Prototype Unimp; Unimp.doMbox(); } // // Write current data to a meta device // void Titraqform::writeEntry(void) { Prototype Unimp; Unimp.doMbox(); } // // Make and display a new document window // void Titraqform::newDoc(void) { Prototype Unimp; Unimp.doMbox(); // Titraqform *pNewform = new Titraqform; // pNewform->show(); } // // Choose a file using a handy file dialog // void Titraqform::choose(void) { QString Filestring = QFileDialog::getOpenFileName(QString::null, QString::null, this); if (!Filestring.isEmpty()) load(Filestring); else m_pStatbar->message(trUtf8("Loading aborted"), 4000); } // // Load accounting data into main window // void Titraqform::load(const QString &Filestring) { QFile Filetemp(Filestring); // File to load if (!Filetemp.open(IO_ReadOnly)) // Need a wrapped exception here return; QTextStream Textstream(&Filetemp); // Convert the file contents to a stream m_pStatus->setText(Textstream.read()); m_pStatus->setEdited(false); setCaption(Filestring); m_pStatbar->message(trUtf8("Loaded document ") + Filestring, 4000); } // // Serialize current state to the current file // void Titraqform::save(void) { // First time saves are really just saveAs in disguise if (m_szFilename->isEmpty()) { saveAs(); return; } // Try to read the status text, and write it to a file QString Statustext = m_pStatus->text(); QFile Filetemp(*m_szFilename); if (!Filetemp.open(IO_WriteOnly)) { m_pStatbar->message(QString(trUtf8("Could not write to %1")).arg(*m_szFilename), 4000); return; } // Serialize file contents and write to text line QTextStream Filestream(&Filetemp); Filestream << Statustext; Filetemp.close(); // Reset the text line, and give output to main window m_pStatus->setEdited(FALSE); setCaption(*m_szFilename); m_pStatbar->message(QString(trUtf8("File %1 saved")).arg(*m_szFilename), 4000); m_bDirt = false; // Set the clean state to allow a close operation } // // Serialize current state to a selected file // void Titraqform::saveAs(void) { // First get the selected file name to save to QString Filestring = QFileDialog::getSaveFileName(QString::null, QString::null, this); if (!Filestring.isEmpty()) { *m_szFilename = Filestring; m_pStatus->setText(*m_szFilename); save(); // Finish off by calling the save action } else { // User did not select a valid file and push okay button m_pStatbar->message(trUtf8("Saving aborted"), 4000); } } // // Close current document, displaying in main window // void Titraqform::closeEvent(QCloseEvent *pClosit) { // Check modification state of current data if (!this->isDirty()) { pClosit->accept(); return; } // Ask user to acknowlege a possibly data-damaging close event switch(QMessageBox::information(this, "OSSP titraq", trUtf8("The document has been\nchanged since the last save.")), trUtf8("Save Now"), trUtf8("Cancel"), trUtf8("Leave Anyway"), 0, 1) { case 0: save(); pClosit->accept(); break; case 1: default: // Just for sanity pClosit->ignore(); break; case 2: pClosit->accept(); break; } } // // Check to see if state has changed since last save // bool Titraqform::isDirty(void) { return m_bDirt; } // // Learn more about this program itself // void Titraqform::about(void) { QMessageBox::about(this, "OSSP titraq", trUtf8("OSSP titraq is a time and task-based\n" "accounting system that acts as both a\n" "nwork-like punch card and time tracker.")); } // // Learn more about this program and Qt // void Titraqform::aboutQt(void) { QMessageBox::aboutQt(this, "OSSP titraq"); @ 1.10 log @Cleanup and typo. @ text @d16 1 d26 1 a26 1 m_pWritebutton->setPaletteBackgroundColor(QColor(196, 196, 176)); a49 2 // m_pMenubar = new QMenuBar(this, "Menubar"); // m_pStatbar = new QStatusBar(this, "Statusbar"); d53 11 d65 1 a65 1 m_pFilenewact = new QAction(trUtf8("New"), trUtf8("&New"), CTRL+Key_N, this, "New"); d67 6 d77 1 d79 1 a79 1 "Click this button to open a new file.
" a81 1 QMimeSourceFactory::defaultFactory()->setPixmap("fileopen", m_pFileopenact->iconSet().pixmap()); d87 3 a89 1 const char *kszFilesavetext = trUtf8("

Click this button to save the file you " a95 1 m_szFilename = new QString(); d108 29 a136 6 // // Lock down window size // setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, // (QSizePolicy::SizeType)0, 0, 0, sizePolicy().hasHeightForWidth())); // Make an easter egg ;-) QToolTip::add(m_pMenubar, QRect(0, 0, 2, 2), "Easter egg"); d160 1 d276 1 a276 1 m_pPackagelayout->addWidget(m_pMaintable); // Finally add the table widget d288 7 d330 1 a330 1 m_pStatbar->message(trUtf8("Ready")); d435 1 d467 1 a467 1 // Ask user to aknowlege a possibly data-damaging close event d490 1 a490 2 // FIXME: We're really not THAT dirty return true; @ 1.9 log @Make 'Save As' and 'Save' work again by solving memory violation. Hmm, maybe I should rename that 'Save AS' for 'Save Application Services'. @ text @d354 1 a354 1 m_pStatus->setEdited(FALSE); @ 1.8 log @Improve layout of widgets by removing a layout and adding attributes to the central frame. @ text @d78 1 d239 1 d398 1 @ 1.7 log @Add actions, corresponding slots, use new bitmaps, add a toolbar, begin coding of data serialization logic. @ text @d38 6 d48 4 a51 3 m_pMenubar = this->menuBar(); m_pStatbar = this->statusBar(); m_pStatbar->message(trUtf8("Ready")); d94 3 d121 1 a121 3 // Add a preconfigured whats this button to our new tool bar QWhatsThis::whatsThisButton(m_pToolbar); d124 3 a126 1 m_pCenframe = new QFrame(this); d129 8 a136 4 // Control layouts for form, table, and status line m_pTitraqformlayout = new QVBoxLayout(m_pCenframe, 11, 6, "Titraqformlayout"); m_pMainlayout = new QVBoxLayout(0, 0, 6, "Mainlayout"); // For layouts m_pPackagelayout = new QVBoxLayout(0, 0, 6, "Packagelayout"); // For table d139 1 a139 1 m_pMaintable = new QTable(this, "Maintable"); d237 1 a237 1 m_pStatus = new QLineEdit(this, "Status"); a243 4 m_pMainlayout->addLayout(m_pPackagelayout); // Control layout for push buttons m_pControllayout = new QHBoxLayout(0, 0, 6, "Controllayout"); // For buttons d246 1 a246 1 m_pAddbutton = new QPushButton(this, "AddButton"); d254 1 a254 1 m_pDeletebutton = new QPushButton(this, "Deletebutton"); d263 1 a263 1 m_pWritebutton = new QPushButton(this, "Writebutton"); d271 1 a271 1 m_pQuitbutton = new QPushButton(this, "Quitbutton"); a278 3 m_pMainlayout->addLayout(m_pControllayout); m_pTitraqformlayout->addLayout(m_pMainlayout); d280 1 @ 1.6 log @First cut at a menu bar, tool bar, and status bar. @ text @d3 1 d9 2 d15 3 a17 1 #include "gfx/ossplogo.xpm" // OSSP logo: static const char *ossplogo_xpm[] d19 1 a19 1 // Used in initialization of the application d22 1 d45 1 a45 1 setCaption(trUtf8("OSSP Titraq")); d47 39 a85 3 // Lock down window size setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, sizePolicy().hasHeightForWidth())); d87 1 a87 1 // Work on the menu bar d89 16 a104 5 m_pMenubar->insertItem("&File", pFilepopup); // pFilepopup->insertItem("&Quit", this, SLOT(quit())); // pFilenewact->addTo(pFilepopup); // pFileopenact->addTo(pFilepopup); // pFilesaveact->addTo(pFilepopup); d106 1 a106 1 // Make a new tool bar d109 5 a113 3 // pFilenewact->addTo(m_pToolbar); // pFileopenact->addTo(m_pToolbar); // pFilesaveact->addTo(m_pToolbar); d120 3 a122 3 m_pTitraqformlayout = new QVBoxLayout(m_pCenframe, 11, 6, "pTitraqformlayout"); m_pMainlayout = new QVBoxLayout(0, 0, 6, "pMainlayout"); // For layouts m_pPackagelayout = new QVBoxLayout(0, 0, 6, "pPackagelayout"); // For table d125 1 a125 1 m_pMaintable = new QTable(this, "pMaintable"); d147 1 a147 1 m_pIconimage = new QImage(ossplogo_xpm); d223 1 a223 1 m_pStatus = new QLineEdit(this, "pStatus"); d233 1 a233 1 m_pControllayout = new QHBoxLayout(0, 0, 6, "pControllayout"); // For buttons d244 1 a244 1 m_pDeletebutton = new QPushButton(this, "pDeletebutton"); d253 1 a253 1 m_pWritebutton = new QPushButton(this, "pWritebutton"); d261 1 a261 1 m_pQuitbutton = new QPushButton(this, "pQuitbutton"); d275 3 d291 3 d300 3 d307 144 @ 1.5 log @Introduce prototypes, correct variable naming, and other cleanups. @ text @d33 2 d36 3 d40 19 a58 2 if (!kszName) setName(trUtf8("Titraqform")); @ 1.4 log @Fix Unicode inconsistencies. @ text @a1 1 #include a2 1 #include d11 1 d15 1 a15 1 void Titraqform::init() d17 6 a22 6 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 d32 1 a32 2 if (!kszName) setName(trUtf8("Titraqform")); d35 2 d39 2 a40 2 QFrame *pCenframe = new QFrame(this); this->setCentralWidget(pCenframe); d43 3 a45 3 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 d48 10 a57 10 pMaintable = new QTable(this, "pMaintable"); pMaintable->setNumRows(knRows); pMaintable->setNumCols(knCols); pMaintable->setReadOnly(false); // Not read only 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 pMaintable->horizontalHeader()->setResizeEnabled(false); pMaintable->setColumnStretchable(5, true); d60 8 a67 8 pTablehead = pMaintable->horizontalHeader(); pTablehead->setLabel(0, QObject::trUtf8("Date"), 96); pTablehead->setLabel(1, QObject::trUtf8("Begin"), 80); pTablehead->setLabel(2, QObject::trUtf8("End"), 80); pTablehead->setLabel(3, QObject::trUtf8("Amount"), 52); pTablehead->setLabel(4, QObject::trUtf8("Task"), 70); pTablehead->setLabel(5, QObject::trUtf8("Remark")); pTablehead->setMovingEnabled(true); d70 4 a73 4 pIconimage = new QImage(ossplogo_xpm); pIconpixmap = new QPixmap(pIconimage->scaleHeight(pMaintable->rowHeight(6))); pMaintable->setItem(0, 0, new QTableItem(pMaintable, QTableItem::Never, "OSSP trac")); pMaintable->setPixmap(0, 0, *pIconpixmap); d77 1 a77 1 // pMaintable->setItem(i, 0, new QTableItem(pMaintable, QTableItem::Always, ("Enter"))); d80 1 a80 1 for (int i = 1; i < knRows; ++i) { d82 2 a83 2 QDateEdit *pDateEdit = new QDateEdit(*pSylvestre, pMaintable, "Date"); pMaintable->setCellWidget(i, 0, pDateEdit); d87 3 a89 3 for (int i = 0; i < knRows; ++i) { QTimeEdit *pStart = new QTimeEdit(QTime::currentTime(), pMaintable, "Start"); pMaintable->setCellWidget(i, 1, pStart); d93 3 a95 3 for (int i = 0; i < knRows; ++i) { QTimeEdit *pEnd = new QTimeEdit(QTime::currentTime(), pMaintable, "End"); pMaintable->setCellWidget(i, 2, pEnd); d99 3 a101 3 for (int i = 0; i < knRows; ++i) { QSpinBox *pAmount = new QSpinBox(pMaintable, "Amount"); pMaintable->setCellWidget(i, 3, pAmount); d105 2 a106 2 pTaskentries = new QStringList; *pTaskentries << trUtf8("titraq") << trUtf8("opgui") << trUtf8("email") << trUtf8("admin") << trUtf8("pmod") << trUtf8("psod") << trUtf8("meeting") << trUtf8("training"); d109 3 a111 3 for (int i = 0; i < knRows; ++i) { QComboBox *pTasks = new QComboBox(true, pMaintable, "Tasks"); pTasks->insertStringList(*pTaskentries); d114 1 a114 1 pMaintable->setCellWidget(i, 4, pTasks); d119 1 a119 1 // QListBox *pTasks = new QListBox(pMaintable, "Tasks"); d122 1 a122 1 // pMaintable->setCellWidget(i, 4, pTasks); d126 1 a126 1 // QListBox *pListasks = new QListBox(pMaintable); d138 1 a138 1 // QComboTableItem *pTasks = new QComboTableItem(pMaintable, *pTaskentries, false); d140 1 a140 1 // pMaintable->setItem(i, 4, pTasks); d143 1 a143 1 pPackagelayout->addWidget(pMaintable); // Finally add the table widget d146 8 a153 8 pStatus = new QLineEdit(this, "pStatus"); pStatus->setFrameShape(QLineEdit::LineEditPanel); pStatus->setFrameShadow(QLineEdit::Sunken); pStatus->setFrame(true); pStatus->setReadOnly(true); QToolTip::add(pStatus, trUtf8("Status Line")); pPackagelayout->addWidget(pStatus); pMainlayout->addLayout(pPackagelayout); d156 1 a156 1 pControllayout = new QHBoxLayout(0, 0, 6, "pControllayout"); // For buttons d159 6 a164 6 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); d167 7 a173 7 pDeletebutton = new QPushButton(this, "pDeletebutton"); 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); d176 6 a181 6 pWritebutton = new QPushButton(this, "pWritebutton"); pWritebutton->setCursor(QCursor(13)); pWritebutton->setText(trUtf8("&Write")); QToolTip::add(pWritebutton, trUtf8("Write Entry")); connect(pWritebutton, SIGNAL(clicked()), this, SLOT(writeEntry())); pControllayout->addWidget(pWritebutton); d184 7 a190 7 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); d192 2 a193 2 pMainlayout->addLayout(pControllayout); pTitraqformlayout->addLayout(pMainlayout); d198 1 a198 1 void Titraqform::addEntry() d200 2 d211 1 a211 1 void Titraqform::delEntry() d213 2 d217 1 a217 1 void Titraqform::writeEntry() d219 2 d226 1 a226 1 Titraqform::~Titraqform() @ 1.3 log @Change from QDialog to QMainWindow, reframe widget layouts, add more buttons, add tool tips, handle quit action, fill table items with meaningful widgets, resize columns, add autocompletion of tasks, chew potatoes, cook rice. @ text @d34 1 a34 1 setName("Titraqform"); d61 6 a66 6 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"), 70); pTablehead->setLabel(5, QObject::tr("Remark")); d106 1 a106 1 *pTaskentries << "titraq" << "opgui" << "email"<< "admin" << "pmod" << "psod" << "meeting" << "training"; d151 1 a151 1 QToolTip::add(pStatus, trUtf8("&Status line")); d162 1 a162 1 QToolTip::add(pAddbutton, trUtf8("&Add entry")); d171 1 a171 1 QToolTip::add(pDeletebutton, trUtf8("&Delete entry")); d179 1 a179 1 QToolTip::add(pWritebutton, trUtf8("&Write entry")); d188 1 a188 1 QToolTip::add(pQuitbutton, trUtf8("&Quit")); @ 1.2 log @Flush changes ending in a more complete application frame. @ text @d2 1 d4 6 a9 1 #include d18 6 a23 2 pDeletebutton->setBackgroundColor(darkYellow); pMaintable->setFocus(); d30 2 a31 2 Titraqform::Titraqform(QWidget *pParent, const char *kszName, bool bModal, WFlags Flags) : QDialog(pParent, kszName, bModal, Flags) d38 4 d43 1 a43 1 pTitraqformlayout = new QVBoxLayout(this, 11, 6, "pTitraqformlayout"); d52 1 a52 1 pMaintable->setColumnMovingEnabled(true); d61 3 a63 3 pTablehead->setLabel(0, QObject::tr("Date"), 76); pTablehead->setLabel(1, QObject::tr("Begin")); pTablehead->setLabel(2, QObject::tr("End")); d65 1 a65 1 pTablehead->setLabel(4, QObject::tr("Task"), 60); d69 1 a69 1 // Icon table items d72 31 a102 2 pMaintable->setPixmap(3, 2, *pIconpixmap); pMaintable->setText(3, 2, "OSSP Titraq"); d104 3 a106 3 // Set contents of a generic combobox pComboentries = new QStringList; *pComboentries << "uno" << "dos" << "tres" << "quatro"; d110 5 a114 3 QComboTableItem *pComboitem = new QComboTableItem(pMaintable, *pComboentries, false); pComboitem->setCurrentItem(i % 4); pMaintable->setItem(i, 4, pComboitem); d117 25 a141 3 // Make the checkbox items for all rows for (int j = 0; j < knRows; ++j) pMaintable->setItem(j, 1, new QCheckTableItem(pMaintable, "Checkung")); d143 1 a143 1 pPackagelayout->addWidget(pMaintable); // Finally add the table widget d151 1 d162 2 d171 2 a176 1 pWritebutton->setPaletteBackgroundColor(QColor(186, 156, 144)); d179 2 d182 10 d196 19 @ 1.1 log @Write the general framework for the main control window. @ text @d1 1 a1 9 #include "titraq.h" #include #include #include #include #include #include #include d4 4 a7 2 #include #include d17 1 a17 1 // Construct a Titraqform which is a child of 'pParent', with the a19 1 d25 2 a26 6 resize(600, 480); setCaption(trUtf8("OpenPKG Friend")); pTitraqformlayout = new QVBoxLayout(this, 11, 6, "pTitraqformlayout"); // Contains the package layout and control layout pMainlayout = new QVBoxLayout(0, 0, 6, "pMainlayout"); d28 4 a31 2 // Contains the table control and status line control pPackagelayout = new QVBoxLayout(0, 0, 6, "pPackagelayout"); d33 1 d35 50 a84 11 pMaintable->setNumRows(10); pMaintable->setNumCols(6); pMaintable->setReadOnly(FALSE); pPackagelayout->addWidget(pMaintable); pStatusline = new QLineEdit(this, "pStatusline"); pStatusline->setFrameShape(QLineEdit::LineEditPanel); pStatusline->setFrameShadow(QLineEdit::Sunken); pStatusline->setFrame(TRUE); pStatusline->setReadOnly(TRUE); pPackagelayout->addWidget(pStatusline); d87 2 a88 2 // Contains all the push button controls pControllayout = new QHBoxLayout(0, 0, 6, "pControllayout"); d90 5 a94 5 pInstallbutton = new QPushButton(this, "pInstallbutton"); pInstallbutton->setCursor(QCursor(13)); pInstallbutton->setText(trUtf8("&Install")); pInstallbutton->setFlat(FALSE); pControllayout->addWidget(pInstallbutton); d96 1 d100 1 d103 6 a108 10 pVerifybutton = new QPushButton(this, "VerifyButton"); pVerifybutton->setCursor(QCursor(13)); pVerifybutton->setText(trUtf8("&Verify")); pControllayout->addWidget(pVerifybutton); pCommitbutton = new QPushButton(this, "pCommitbutton"); pCommitbutton->setPaletteBackgroundColor(QColor(186, 156, 144)); pCommitbutton->setCursor(QCursor(13)); pCommitbutton->setText(trUtf8("&Commit")); pControllayout->addWidget(pCommitbutton); d112 1 a112 1 init(); // signals and slots connections @