Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • release/202005
  • release/202001
  • release/201912
  • release/201911
  • release/releaseWindowsTestOne
  • release/releaseTest
  • release/releaseWindowsTest
  • release/windowsReleaseTest
  • release/201910
  • release/qt/201910
  • release/windows-test/201910
  • release/201908
  • release/201906
  • release/201905
  • release/201904
  • release/201903
  • release/201902
  • release/201901
  • release/201812
  • 1.0.0
  • 0.3.0
  • 0.2.1
  • 0.2.0
  • 0.1.0
25 results

availableaccountmodel.h

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    availableaccountmodel.h 3.01 KiB
    /****************************************************************************
     *   Copyright (C) 2012-2017 Savoir-faire Linux                          *
     *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
     *                                                                          *
     *   This library is free software; you can redistribute it and/or          *
     *   modify it under the terms of the GNU Lesser General Public             *
     *   License as published by the Free Software Foundation; either           *
     *   version 2.1 of the License, or (at your option) any later version.     *
     *                                                                          *
     *   This library 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      *
     *   Lesser 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/>.  *
     ***************************************************************************/
    #pragma once
    
    #include <QtCore/QSortFilterProxyModel>
    
    #include <accountmodel.h>
    
    class AvailableAccountModelPrivate;
    
    //TODO Qt5 use QAbstractItemProxyModel
    /**
     * This model filter the account list to disable all unavailable accounts. It
     * also remove the enabled checkbox as it is no longer relevant.
     *
     * This model also handle all the logic behind the "current account" used by
     * default when passing a call. It use the first "READY" account in the
     * AccountModel list unless manually specified. To change the default
     * permanently, use the setDefaultAccount method.
     *
     * @todo Once the history is not saved by the daemon, implement setDefaultAccount
     */
    class LIB_EXPORT AvailableAccountModel : public QSortFilterProxyModel
    {
       Q_OBJECT
    public:
    
       virtual QVariant      data            (const QModelIndex& index,int role = Qt::DisplayRole       ) const override;
       virtual Qt::ItemFlags flags           (const QModelIndex& index                                  ) const override;
       virtual bool          filterAcceptsRow(int source_row, const QModelIndex& source_parent          ) const override;
    
       QItemSelectionModel* selectionModel() const;
    
       //Getter
       static Account* currentDefaultAccount(ContactMethod* method = nullptr);
       static Account* currentDefaultAccount(URI::SchemeType schemeType);
       static bool validAccountForScheme(Account* account, URI::SchemeType scheme);
    
       //Singleton
       static AvailableAccountModel& instance();
    
    Q_SIGNALS:
       void currentDefaultAccountChanged(Account*);
    
    private:
       virtual ~AvailableAccountModel();
       explicit AvailableAccountModel(QObject* parent = nullptr);
    
       AvailableAccountModelPrivate* d_ptr;
       Q_DECLARE_PRIVATE(AvailableAccountModel)
    };
    Q_DECLARE_METATYPE(AvailableAccountModel*)