Source: tableviewer.h


Annotated List
Files
Globals
Hierarchy
Index
// ##########################################################################
// ####                                                                  ####
// ####                         Prüfungsamt-Client                       ####
// ####                    ============================                  ####
// ####                                                                  ####
// #### Tabellen-Viewer                                                  ####
// ####                                                                  ####
// #### Version 1.00  --  25. Juni 2000                                  ####
// ####                                                                  ####
// #### Copyright (C) 2000  Thomas Dreibholz                             ####
// ####                     Universität Bonn                             ####
// ####                     EMail: Dreibholz@bigfoot.com                 ####
// ####                     WWW:   http://www.bigfoot.com/~dreibholz     ####
// ####                                                                  ####
// ##########################################################################


#ifndef TABLEVIEWER_H
#define TABLEVIEWER_H


#include "system.h"
#include "paclient.h"
#include "paviews.h"
#include "sqlconnectioninterface.h"
#include "tupleeditor.h"


#include <qapp.h>
#if QT_VERSION < 210
#error ERROR: QT Version 2.1 or better required!!!
#endif
#include <qlineedit.h>
#include <qlabel.h>
#include <qwhatsthis.h>
#include <qlistview.h>
#include <qstring.h>
#include <qlist.h>
#include <qdict.h>


class TupleEditor;
class AttributeEditor;


/**
  * TableViewer ist ein Qt-Widget zur Darstellung einer Tabelle.
  *
  * @short   Table Viewer
  * @author  Thomas Dreibholz (Dreibholz@bigfoot.com)
  * @version 1.0
  */
class TableViewer : public QWidget
{
   Q_OBJECT

   // ====== Konstanten =====================================================
   /**
     * Modus für den Viewer: Editieren der Tupel oder Selektion eines Tupels.
     */
   public:
   enum TableViewerMode {
      TVM_EditMode   = (1 << 0),
      TVM_SelectMode = (1 << 1),
      TVM_ReadOnly   = (1 << 10)
   };


   // ====== Constructor/Destructor =========================================
   /**
     * Constructor.
     *
     * @param connection Datenbank-Verbindung.
     * @param viewTable ViewTable-Struktur für den Viewer.
     * @param mode Modus des Viewers: Editier- oder Selektiermodus.
     * @param joinAttribute Attribut für Join.
     * @param joinValue Wert für Join.
     * @param selectAttribute Attribut für Selektion.
     * @param selectValue Start-Wert für Selektion.
     * @param parent Parent QWidget; default: NULL.
     * @param name Widget-Name; default: NULL.
     */
   TableViewer(SQLConnectionInterface* connection,
               const ViewTable*        viewTable,
               const cardinal          mode            = TVM_EditMode,
               const QString&          joinAttribute   = QString::null,
               const QString&          joinValue       = QString::null,
               const QString&          selectAttribute = QString::null,
               const QString&          selectValue     = QString::null,
               QWidget*                parent          = NULL,
               const char*             name            = NULL);

   /**
     * Destructor.
     */
   ~TableViewer();


   // ====== Tabelle laden ==================================================
   /**
     * Laden einer Tabelle aus der Datenbank.
     *
     * @param tableName Tabellen-Name.
     * @param orderBy Sortierung (z.B. 'Name, Vorname')
     */
   void TableViewer::loadTable(const char* tableName = NULL,
                               const char* orderBy   = NULL);


   // ====== Slots für Qt ===================================================
   public slots:
   /**
     * Qt-Slot: Datensuche.
     */
   void search(const QString& newText);

   /**
     * Qt-Slot: Header des ListView-Widget angeklickt.
     */
   void setSortAttribute(int section);

   /**
     * Qt-Slot: View ausgewählt.
     */
   void selectView(int selection);

   /**
     * Qt-Slot: Tupel ausgewählt.
     */
   void selectTuple(QListViewItem* item);

   /**
     * Qt-Slot: Einen geöffneten Tupel-Editor wieder schließen.
     */
   void closeEditor(TupleEditor* editor, const bool commited);

   /**
     * Qt-Slot: Neues Tupel einfügen.
     */
   void newClicked();

   /**
     * Qt-Slot: Tupel-Auswahl: Okay-Button geklickt.
     */
   void okayClicked();

   /**
     * Qt-Slot: Tupel-Auswahl: Null-Button geklickt.
     */
   void nullClicked();

   /**
     * Qt-Slot: Tupel-Auswahl: Abbruch-Button geklickt.
     */
   void cancelClicked();


   // ====== Signale für Qt =================================================
   signals:
   /**
     * Qt-Signal: Tupel-Auswahl: Auswahl durchgeführt.
     */
   void doneSelection(TableViewer* viewer, const bool selected, const QString& selected);



   // ====== Private Daten ==================================================
   private:
   void closeEvent(QCloseEvent* event);


   SQLConnectionInterface* Connection;
   QWhatsThis*             WhatsThis;
   QLabel*                 StatusBar;
   QDict<TupleEditor>      TupleEditors;

   cardinal                Mode;
   const ViewTable*        Views;
   const ViewEntry*        View;
   QString                 JoinAttribute;
   QString                 JoinValue;
   QString                 SelectAttribute;
   QString                 SelectValue;

   QListView*              TableView;
   QList<QString>          Attributes;
   QLabel*                 FindLabel;
   QLineEdit*              FindLineEdit;
   cardinal                FindSection;
   bool                    SkipNextUpdate;
   cardinal                MinNotFoundIndex;
};


#endif

Generated by: viper@odin on Wed Jul 12 17:11:55 2000, using kdoc 2.0a22.