File indexing completed on 2025-01-19 03:59:38

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2008-01-20
0007  * Description : User interface for searches
0008  *
0009  * SPDX-FileCopyrightText: 2008-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  * SPDX-FileCopyrightText: 2011-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "searchfields_p.h"
0017 
0018 namespace Digikam
0019 {
0020 
0021 SearchFieldPageOrientation::SearchFieldPageOrientation(QObject* const parent)
0022     : SearchFieldComboBox(parent)
0023 {
0024 }
0025 
0026 void SearchFieldPageOrientation::setupValueWidgets(QGridLayout* layout, int row, int column)
0027 {
0028     SearchFieldComboBox::setupValueWidgets(layout, row, column);
0029     m_comboBox->addItem(i18n("Any Orientation"));
0030     m_comboBox->addItem(i18n("Landscape Orientation"), 1);
0031     m_comboBox->addItem(i18n("Portrait orientation"), 2);
0032 
0033     m_comboBox->setCurrentIndex(0);
0034 }
0035 
0036 void SearchFieldPageOrientation::read(SearchXmlCachingReader& reader)
0037 {
0038     SearchXml::Relation relation = reader.fieldRelation();
0039 
0040     if (relation == SearchXml::Equal)
0041     {
0042         int value = reader.valueToInt();
0043 
0044         if      (value == 1)
0045         {
0046             m_comboBox->setCurrentIndex(1);
0047         }
0048         else if (value == 2)
0049         {
0050             m_comboBox->setCurrentIndex(2);
0051         }
0052     }
0053 }
0054 
0055 } // namespace Digikam