File indexing completed on 2024-05-12 16:44:03
0001 /* 0002 SPDX-FileCopyrightText: 2009-2010 Cristian Oneț <onet.cristian@gmail.com> 0003 SPDX-FileCopyrightText: 2009-2010 Alvaro Soliverez <asoliverez@gmail.com> 0004 SPDX-FileCopyrightText: 2011-2017 Thomas Baumgart <tbaumgart@kde.org> 0005 SPDX-FileCopyrightText: 2017 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #include "kmymoneypayeecombo.h" 0010 0011 // ---------------------------------------------------------------------------- 0012 // QT Includes 0013 0014 // ---------------------------------------------------------------------------- 0015 // KDE Includes 0016 0017 // ---------------------------------------------------------------------------- 0018 // Project Includes 0019 0020 #include "mymoneypayee.h" 0021 0022 KMyMoneyPayeeCombo::KMyMoneyPayeeCombo(QWidget* parent) : 0023 KMyMoneyMVCCombo(true, parent) 0024 { 0025 } 0026 0027 KMyMoneyPayeeCombo::~KMyMoneyPayeeCombo() 0028 { 0029 } 0030 0031 void KMyMoneyPayeeCombo::loadPayees(const QList<MyMoneyPayee>& list) 0032 { 0033 clear(); 0034 0035 //add a blank item, since the field is optional 0036 addItem(QString(), QVariant(QString())); 0037 0038 //add all payees 0039 QList<MyMoneyPayee>::const_iterator it; 0040 for (it = list.constBegin(); it != list.constEnd(); ++it) { 0041 addItem((*it).name(), QVariant((*it).id())); 0042 } 0043 0044 //sort the model, which will sort the list in the combo 0045 model()->sort(Qt::DisplayRole, Qt::AscendingOrder); 0046 0047 //set the text to empty and the index to the first item on the list 0048 setCurrentIndex(0); 0049 clearEditText(); 0050 }