]> ruin.nu Git - hbs.git/blobdiff - bs/bs.cpp
Some small changes
[hbs.git] / bs / bs.cpp
index 42dc30a8d295b34eb3c8eda071facac9bba178dd..eeea37a1926ed07fe5497580b75af79cdd4bf513 100644 (file)
--- a/bs/bs.cpp
+++ b/bs/bs.cpp
-/***************************************************************************
-                          bc.cpp  -  description
-                             -------------------
-    begin                : Sun May 27 22:13:58 CEST 2001
-    copyright            : (C) 2001 by Michael Andreen
-    email                : whale@linux.nu
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "../config.h"
-
-#include <qaccel.h>
 #include "bs.h"
-#include "filesave.xpm"
-#include "fileopen.xpm"
-#include "filenew.xpm"
-
-BSApp::BSApp()
-{
-  setCaption(tr("Bc " VERSION));
 
-  ///////////////////////////////////////////////////////////////////
-  // call inits to invoke all other construction parts
-  initActions();
-  initMenuBar();
-  initToolBar();
-  initStatusBar();
+//Own includes
+#include "bsview.h"
+#include "bsdoc.h"
 
-  initDoc();
-  initView();
-
-  viewToolBar->setOn(true);
-  viewStatusBar->setOn(true);
-}
-
-BSApp::~BSApp()
+/* 
+ *  Constructs a BSApp which is a child of 'parent', with the 
+ *  name 'name' and widget flags set to 'f' 
+ */
+BSApp::BSApp( QWidget* parent,  const char* name, WFlags fl )
+    : BSAppBase( parent, name, fl )
 {
+       doc = new BSDoc();
+       view = new BSView(this,doc);
+       setCentralWidget(view);
 }
 
-/** initializes all QActions of the application */
-void BSApp::initActions(){
-
-  QPixmap openIcon, saveIcon, newIcon;
-  newIcon = QPixmap(filenew);
-  openIcon = QPixmap(fileopen);
-  saveIcon = QPixmap(filesave);
-
-
-  fileNew = new QAction(tr("New File"), newIcon, tr("&New"), QAccel::stringToKey(tr("Ctrl+N")), this);
-  fileNew->setStatusTip(tr("Creates a new document"));
-  fileNew->setWhatsThis(tr("New File\n\nCreates a new document"));
-  connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew()));
-
-  fileOpen = new QAction(tr("Open File"), openIcon, tr("&Open..."), 0, this);
-  fileOpen->setStatusTip(tr("Opens an existing document"));
-  fileOpen->setWhatsThis(tr("Open File\n\nOpens an existing document"));
-  connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen()));
-
-  fileSave = new QAction(tr("Save File"), saveIcon, tr("&Save"), QAccel::stringToKey(tr("Ctrl+S")), this);
-  fileSave->setStatusTip(tr("Saves the actual document"));
-  fileSave->setWhatsThis(tr("Save File.\n\nSaves the actual document"));
-  connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave()));
-
-  fileSaveAs = new QAction(tr("Save File As"), tr("Save &as..."), 0, this);
-  fileSaveAs->setStatusTip(tr("Saves the actual document under a new filename"));
-  fileSaveAs->setWhatsThis(tr("Save As\n\nSaves the actual document under a new filename"));
-  connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSave()));
-
-  fileClose = new QAction(tr("Close File"), tr("&Close"), QAccel::stringToKey(tr("Ctrl+W")), this);
-  fileClose->setStatusTip(tr("Closes the actual document"));
-  fileClose->setWhatsThis(tr("Close File\n\nCloses the actual document"));
-  connect(fileClose, SIGNAL(activated()), this, SLOT(slotFileClose()));
-
-  filePrint = new QAction(tr("Print File"), tr("&Print"), QAccel::stringToKey(tr("Ctrl+P")), this);
-  filePrint->setStatusTip(tr("Prints out the actual document"));
-  filePrint->setWhatsThis(tr("Print File\n\nPrints out the actual document"));
-  connect(filePrint, SIGNAL(activated()), this, SLOT(slotFilePrint()));
-
-  fileQuit = new QAction(tr("Exit"), tr("E&xit"), QAccel::stringToKey(tr("Ctrl+Q")), this);
-  fileQuit->setStatusTip(tr("Quits the application"));
-  fileQuit->setWhatsThis(tr("Exit\n\nQuits the application"));
-  connect(fileQuit, SIGNAL(activated()), this, SLOT(slotFileQuit()));
-
-  editCut = new QAction(tr("Cut"), tr("Cu&t"), QAccel::stringToKey(tr("Ctrl+X")), this);
-  editCut->setStatusTip(tr("Cuts the selected section and puts it to the clipboard"));
-  editCut->setWhatsThis(tr("Cut\n\nCuts the selected section and puts it to the clipboard"));
-  connect(editCut, SIGNAL(activated()), this, SLOT(slotEditCut()));
-
-  editCopy = new QAction(tr("Copy"), tr("&Copy"), QAccel::stringToKey(tr("Ctrl+C")), this);
-  editCopy->setStatusTip(tr("Copies the selected section to the clipboard"));
-  editCopy->setWhatsThis(tr("Copy\n\nCopies the selected section to the clipboard"));
-  connect(editCopy, SIGNAL(activated()), this, SLOT(slotEditCopy()));
-
-  editPaste = new QAction(tr("Paste"), tr("&Paste"), QAccel::stringToKey(tr("Ctrl+V")), this);
-  editPaste->setStatusTip(tr("Pastes the clipboard contents to actual position"));
-  editPaste->setWhatsThis(tr("Paste\n\nPastes the clipboard contents to actual position"));
-  connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste()));
-
-  viewToolBar = new QAction(tr("Toolbar"), tr("Tool&bar"), 0, this, 0, true);
-  viewToolBar->setStatusTip(tr("Enables/disables the toolbar"));
-  viewToolBar->setWhatsThis(tr("Toolbar\n\nEnables/disables the toolbar"));
-  connect(viewToolBar, SIGNAL(toggled(bool)), this, SLOT(slotViewToolBar(bool)));
-
-  viewStatusBar = new QAction(tr("Statusbar"), tr("&Statusbar"), 0, this, 0, true);
-  viewStatusBar->setStatusTip(tr("Enables/disables the statusbar"));
-  viewStatusBar->setWhatsThis(tr("Statusbar\n\nEnables/disables the statusbar"));
-  connect(viewStatusBar, SIGNAL(toggled(bool)), this, SLOT(slotViewStatusBar(bool)));
-
-  helpAboutApp = new QAction(tr("About"), tr("&About..."), 0, this);
-  helpAboutApp->setStatusTip(tr("About the application"));
-  helpAboutApp->setWhatsThis(tr("About\n\nAbout the application"));
-  connect(helpAboutApp, SIGNAL(activated()), this, SLOT(slotHelpAbout()));
-
-}
-
-void BSApp::initMenuBar()
-{
-  ///////////////////////////////////////////////////////////////////
-  // MENUBAR
-
-  ///////////////////////////////////////////////////////////////////
-  // menuBar entry fileMenu
-  fileMenu=new QPopupMenu();
-  fileNew->addTo(fileMenu);
-  fileOpen->addTo(fileMenu);
-  fileClose->addTo(fileMenu);
-  fileMenu->insertSeparator();
-  fileSave->addTo(fileMenu);
-  fileSaveAs->addTo(fileMenu);
-  fileMenu->insertSeparator();
-  filePrint->addTo(fileMenu);
-  fileMenu->insertSeparator();
-  fileQuit->addTo(fileMenu);
-
-  ///////////////////////////////////////////////////////////////////
-  // menuBar entry editMenu
-  editMenu=new QPopupMenu();
-  editCut->addTo(editMenu);
-  editCopy->addTo(editMenu);
-  editPaste->addTo(editMenu);
-
-  ///////////////////////////////////////////////////////////////////
-  // menuBar entry viewMenu
-  viewMenu=new QPopupMenu();
-  viewMenu->setCheckable(true);
-  viewToolBar->addTo(viewMenu);
-  viewStatusBar->addTo(viewMenu);
-  ///////////////////////////////////////////////////////////////////
-  // EDIT YOUR APPLICATION SPECIFIC MENUENTRIES HERE
-
-  ///////////////////////////////////////////////////////////////////
-  // menuBar entry helpMenu
-  helpMenu=new QPopupMenu();
-  helpAboutApp->addTo(helpMenu);
-
-  ///////////////////////////////////////////////////////////////////
-  // MENUBAR CONFIGURATION
-  menuBar()->insertItem(tr("&File"), fileMenu);
-  menuBar()->insertItem(tr("&Edit"), editMenu);
-  menuBar()->insertItem(tr("&View"), viewMenu);
-  menuBar()->insertSeparator();
-  menuBar()->insertItem(tr("&Help"), helpMenu);
-
-}
-
-void BSApp::initToolBar()
+/*  
+ *  Destroys the object and frees any allocated resources
+ */
+BSApp::~BSApp()
 {
-  ///////////////////////////////////////////////////////////////////
-  // TOOLBAR
-  fileToolbar = new QToolBar(this, "file operations");
-  fileNew->addTo(fileToolbar);
-  fileOpen->addTo(fileToolbar);
-  fileSave->addTo(fileToolbar);
-  fileToolbar->addSeparator();
-  QWhatsThis::whatsThisButton(fileToolbar);
-
+    // no need to delete child widgets, Qt does it all for us
 }
 
-void BSApp::initStatusBar()
+/* 
+ * public slot
+ */
+void BSApp::fileNew()
 {
-  ///////////////////////////////////////////////////////////////////
-  //STATUSBAR
-  statusBar()->message(tr("Ready."), 2000);
+    qWarning( "BSApp::fileNew() not yet implemented!" ); 
 }
 
-void BSApp::initDoc()
+/* 
+ * public slot
+ */
+void BSApp::fileOpen()
 {
-   doc=new BSDoc();
+    qWarning( "BSApp::fileOpen() not yet implemented!" ); 
 }
 
-void BSApp::initView()
+/* 
+ * public slot
+ */
+void BSApp::fileSave()
 {
-  ////////////////////////////////////////////////////////////////////
-  // set the main widget here
-  view=new BSView(this, doc);
-  setCentralWidget(view);
+    qWarning( "BSApp::fileSave() not yet implemented!" ); 
 }
 
-bool BSApp::queryExit()
+/* 
+ * public slot
+ */
+void BSApp::fileSaveAs()
 {
-  int exit=QMessageBox::information(this, tr("Quit..."),
-                                    tr("Do your really want to quit?"),
-                                    QMessageBox::Ok, QMessageBox::Cancel);
-
-  if (exit==1)
-  {
-
-  }
-  else
-  {
-
-  };
-
-  return (exit==1);
+    qWarning( "BSApp::fileSaveAs() not yet implemented!" ); 
 }
 
-/////////////////////////////////////////////////////////////////////
-// SLOT IMPLEMENTATION
-/////////////////////////////////////////////////////////////////////
-
-
-void BSApp::slotFileNew()
+/* 
+ * public slot
+ */
+void BSApp::filePrint()
 {
-  statusBar()->message(tr("Creating new file..."));
-  doc->newDoc();
-  statusBar()->message(tr("Ready."));
+    qWarning( "BSApp::filePrint() not yet implemented!" ); 
 }
 
-void BSApp::slotFileOpen()
+/* 
+ * public slot
+ */
+void BSApp::fileExit()
 {
-  statusBar()->message(tr("Opening file..."));
-
-  QString fileName = QFileDialog::getOpenFileName(0,0,this);
-  if (!fileName.isEmpty())
-  {
-    doc->load(fileName);
-    setCaption(fileName);
-    QString message=tr("Loaded document: ")+fileName;
-    statusBar()->message(message, 2000);
-  }
-  else
-  {
-    statusBar()->message(tr("Opening aborted"), 2000);
-  }
+    qWarning( "BSApp::fileExit() not yet implemented!" ); 
 }
 
-
-void BSApp::slotFileSave()
+/* 
+ * public slot
+ */
+void BSApp::editUndo()
 {
-  statusBar()->message(tr("Saving file..."));
-  doc->save();
-  statusBar()->message(tr("Ready."));
+    qWarning( "BSApp::editUndo() not yet implemented!" ); 
 }
 
-void BSApp::slotFileSaveAs()
+/* 
+ * public slot
+ */
+void BSApp::editRedo()
 {
-  statusBar()->message(tr("Saving file under new filename..."));
-  QString fn = QFileDialog::getSaveFileName(0, 0, this);
-  if (!fn.isEmpty())
-  {
-    doc->saveAs(fn);
-  }
-  else
-  {
-    statusBar()->message(tr("Saving aborted"), 2000);
-  }
-
-  statusBar()->message(tr("Ready."));
+    qWarning( "BSApp::editRedo() not yet implemented!" ); 
 }
 
-void BSApp::slotFileClose()
+/* 
+ * public slot
+ */
+void BSApp::editCut()
 {
-  statusBar()->message(tr("Closing file..."));
-
-  statusBar()->message(tr("Ready."));
+    qWarning( "BSApp::editCut() not yet implemented!" ); 
 }
 
-void BSApp::slotFilePrint()
+/* 
+ * public slot
+ */
+void BSApp::editCopy()
 {
-  statusBar()->message(tr("Printing..."));
-  QPrinter printer;
-  if (printer.setup(this))
-  {
-    QPainter painter;
-    painter.begin(&printer);
-
-    ///////////////////////////////////////////////////////////////////
-    // TODO: Define printing by using the QPainter methods here
-
-    painter.end();
-  };
-
-  statusBar()->message(tr("Ready."));
+    qWarning( "BSApp::editCopy() not yet implemented!" ); 
 }
 
-void BSApp::slotFileQuit()
+/* 
+ * public slot
+ */
+void BSApp::editPaste()
 {
-  statusBar()->message(tr("Exiting application..."));
-  ///////////////////////////////////////////////////////////////////
-  // exits the Application
-  if(doc->isModified())
-  {
-    if(queryExit())
-    {
-      qApp->quit();
-    }
-    else
-    {
-
-    };
-  }
-  else
-  {
-    qApp->quit();
-  };
-
-  statusBar()->message(tr("Ready."));
-}
-
-void BSApp::slotEditCut()
-{
-  statusBar()->message(tr("Cutting selection..."));
-
-  statusBar()->message(tr("Ready."));
-}
-
-void BSApp::slotEditCopy()
-{
-  statusBar()->message(tr("Copying selection to clipboard..."));
-
-  statusBar()->message(tr("Ready."));
+    qWarning( "BSApp::editPaste() not yet implemented!" ); 
 }
 
-void BSApp::slotEditPaste()
+/* 
+ * public slot
+ */
+void BSApp::editFind()
 {
-  statusBar()->message(tr("Inserting clipboard contents..."));
-
-  statusBar()->message(tr("Ready."));
+    qWarning( "BSApp::editFind() not yet implemented!" ); 
 }
 
-
-void BSApp::slotViewToolBar(bool toggle)
+/* 
+ * public slot
+ */
+void BSApp::helpIndex()
 {
-  statusBar()->message(tr("Toggle toolbar..."));
-  ///////////////////////////////////////////////////////////////////
-  // turn Toolbar on or off
-
-  if (toggle== false)
-  {
-    fileToolbar->hide();
-  }
-  else
-  {
-    fileToolbar->show();
-  };
-
-  statusBar()->message(tr("Ready."));
+    qWarning( "BSApp::helpIndex() not yet implemented!" ); 
 }
 
-void BSApp::slotViewStatusBar(bool toggle)
+/* 
+ * public slot
+ */
+void BSApp::helpContents()
 {
-  statusBar()->message(tr("Toggle statusbar..."));
-  ///////////////////////////////////////////////////////////////////
-  //turn Statusbar on or off
-
-  if (toggle == false)
-  {
-    statusBar()->hide();
-  }
-  else
-  {
-    statusBar()->show();
-  }
-
-  statusBar()->message(tr("Ready."));
+    qWarning( "BSApp::helpContents() not yet implemented!" ); 
 }
 
-void BSApp::slotHelpAbout()
+/* 
+ * public slot
+ */
+void BSApp::helpAbout()
 {
-  QMessageBox::about(this,tr("About..."),
-                      tr("Bc\nVersion " VERSION "\n(c) 2001 by Michael Andreen") );
+    qWarning( "BSApp::helpAbout() not yet implemented!" ); 
 }