/*
    This file is part of kenvy24 KDE multimedia utility
    Copyright (c) 2007  Valentin RUSU kenvy24@rusu.info

    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) version 3 or, at the discretion of KDE e.V. (which shall
    act as a proxy as in section 14 of the GPLv3), 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
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    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, see <http://www.gnu.org/licenses/>.
*/
#ifndef _MAINVIEWIMPL_H_INCLUDED_
#define _MAINVIEWIMPL_H_INCLUDED_

#include <kdeversion.h>

#include "ui_mainview.h"
#include "envystructs.h"

#include <vector>

class EnvyCard;
class QTimer;
class Q3ListBoxItem;

class MainViewImpl;

class PatchbayRoute : public QObject {
    Q_OBJECT

            int index;
    QLabel* label;
    QComboBox*  leftCombo;
    QComboBox*  rightCombo;
    MainViewImpl*  view;
    RouteKind      kind;
    public:

        PatchbayRoute( RouteKind kind, int index, QLabel* label, QComboBox* leftCombo, QComboBox* rightCombo, MainViewImpl* view );
        void patchBayUpdated() const;

    private slots:
        void leftComboActivated( int );
        void rightComboActivated( int );

    private:
        void fillCombos();
};

class MainViewImpl : public QWidget, Ui_MainView {
  Q_OBJECT

    public:

  private:
    EnvyCard*       envyCard;
    QTimer*         updateTimer;
    std::vector< PatchbayRoute* >  patchAnalog;
    std::vector< PatchbayRoute* >  patchSPDIF;
    Q3ListBoxItem*   currentProfileItem;
    friend class PatchbayRoute;

  public:
    MainViewImpl( QWidget* parent =0 );
    ~MainViewImpl();

  public slots:
    void updateMeters();
    void patchBayUpdated();
    void newProfile();
    void updateProfile();
    void deleteProfile();
    void loadProfile(Q3ListBoxItem*);
    void dac0Changed(int);
    void dac1Changed(int);
    void adc0Changed(int);
    void adc1Changed(int);
    void wikiURLClicked(const QString&);

  private:
      void setupTimer();
      void setupPatchbay();
      QString getProfileConfigName( const QString& ) const;
};

#endif // _MAINVIEWIMPL_H_INCLUDED_
