Logo Search packages:      
Sourcecode: qtractor version File versions


// qtractorTrackList.h
   Copyright (C) 2005-2007, rncbc aka Rui Nuno Capela. All rights reserved.

   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.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along
   with this program; if not, write to the Free Software Foundation, Inc.,
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


#ifndef __qtractorTrackList_h
#define __qtractorTrackList_h

#include "qtractorScrollView.h"

#include <QPixmap>

// Forward declarations.
class qtractorTrack;
class qtractorTracks;
class qtractorTrackItemWidget;
class qtractorRubberBand;

class QHeaderView;

class QResizeEvent;
class QMouseEvent;
class QKeyEvent;

// qtractorTrackList -- Track list widget.

class qtractorTrackList : public qtractorScrollView


      // Constructor.
      qtractorTrackList(qtractorTracks *pTracks, QWidget *pParent = 0);
      // Destructor.

      // Track list view column indexes.
      enum ColumnIndex {
            Number     = 0,
            Name       = 1,
            Bus        = 2,
            Channel    = 3,
            Patch      = 4,
            Instrument = 5

      // Main tracks widget accessor.
      qtractorTracks *tracks() const;

      // Header view accessor.
      QHeaderView *header() const;

      // Find the list view item from track pointer reference.
      int trackRow(qtractorTrack *pTrack) const;

      // Find track row/column of given viewport point...
      int trackRowAt(const QPoint& pos);
      int trackColumnAt(const QPoint& pos);

      // Find the track pointer reference from list view item row.
      qtractorTrack *track(int iTrack) const;

      // Insert/remove a track item; return actual track of incident.
      int insertTrack(int iTrack, qtractorTrack *pTrack);
      int removeTrack(int iTrack);

      // Select a track item.
      void selectTrack(int iTrack);

      // Retrieves current selected track reference.
      qtractorTrack *currentTrack() const;

      // Update the list view item from track pointer reference.
      void updateTrack(qtractorTrack *pTrack);

      // Main table cleaner.
      void clear();

      // Base item height (in pixels).
      enum { ItemHeightMin = 24, ItemHeightBase = 48 };

      // Update list content height.
      void updateContentsHeight();

      // Rectangular contents update.
      void updateContents(const QRect& rect);
      // Overall contents update.
      void updateContents();


      // Resize event handler.
      void resizeEvent(QResizeEvent *pResizeEvent);

      // Draw the time scale.
      void drawContents(QPainter *pPainter, const QRect& rect);

      // Retrive the given track row rectangular (in contents coordinates).
      QRect trackRect(int iTrack) const;

      // Draw table cell.
      void drawCell(QPainter *pPainter, int iRow, int iCol,
            const QRect& rect) const;

      // Context menu request slot.
      void contextMenuEvent(QContextMenuEvent *pContextMenuEvent);

      // Handle mouse double-clicks.
      void mouseDoubleClickEvent(QMouseEvent *pMouseEvent);

      // Handle item selection with mouse.
      void mousePressEvent(QMouseEvent *pMouseEvent);
      void mouseMoveEvent(QMouseEvent *pMouseEvent);
      void mouseReleaseEvent(QMouseEvent *pMouseEvent);

      // Show and move rubber-band item.
      void moveRubberBand(const QPoint& posDrag);

      // Keyboard event handler.
      void keyPressEvent(QKeyEvent *pKeyEvent);

      // Reset drag/select/move state.
      void resetDragState();


      // More like current row has changed.
      void selectionChanged();

protected slots:

      // To have timeline in h-sync with main track view.
      void contentsYMovingSlot(int cx, int cy);

      // (Re)create the time scale pixmap.
      void updatePixmap(int cx, int cy);

      // Update header extents.
      void updateHeader();


      // The logical parent binding.
      qtractorTracks *m_pTracks;

      // Local horizontal header.
      QHeaderView *m_pHeader;

      // Local double-buffering pixmap.
      QPixmap m_pixmap;

      // Model cache item.
      struct Item
            // Constructor
            Item(qtractorTrackList *pTrackList, qtractorTrack *pTrack);
            // Destructor.
            // Item updater.
            void update(qtractorTrackList *pTrackList);
            // Item members.
            qtractorTrack *track;
            QStringList    text;
            // Track-list item widget.
            qtractorTrackItemWidget *widget;

      // Model cache item list.
      QList<Item *> m_items;

      // Current selected row.
      int m_iCurrentTrack;

      // The current selecting/dragging item stuff.
      enum DragState {
            DragNone = 0, DragStart, DragMove, DragResize
      } m_dragState;

      // For whether we're resizing or moving an item;
      QPoint m_posDrag;
      int    m_iDragTrack;
      int    m_iDragY;

      qtractorRubberBand *m_pRubberBand;

      // Track icon pixmap stuff.
      enum { IconAudio = 0, IconMidi = 1, IconCount = 2 };

      QPixmap *m_pPixmap[IconCount];

#endif  // __qtractorTrackList_h

// end of qtractorTrackList.h

Generated by  Doxygen 1.6.0   Back to index