File indexing completed on 2024-12-15 04:54:44

0001 /******************************************************************************
0002  *
0003  *  SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
0004  *
0005  *  SPDX-License-Identifier: GPL-2.0-or-later
0006  *
0007  *******************************************************************************/
0008 
0009 #pragma once
0010 
0011 #include "utils/optionseteditor.h"
0012 
0013 class QComboBox;
0014 
0015 namespace MessageList
0016 {
0017 namespace Core
0018 {
0019 class Aggregation;
0020 } // namespace Core
0021 
0022 namespace Utils
0023 {
0024 /**
0025  * A widget that allows editing a single MessageList::Aggregation.
0026  *
0027  * Used by ConfigureAggregationsDialog.
0028  */
0029 class AggregationEditor : public OptionSetEditor
0030 {
0031     Q_OBJECT
0032 public:
0033     explicit AggregationEditor(QWidget *parent);
0034     ~AggregationEditor() override;
0035 
0036 private:
0037     Core::Aggregation *mCurrentAggregation = nullptr; // shallow, may be null!
0038 
0039     // Grouping, Threading and Sorting tab
0040     QComboBox *mGroupingCombo = nullptr;
0041     QComboBox *mGroupExpandPolicyCombo = nullptr;
0042     QComboBox *mThreadingCombo = nullptr;
0043     QComboBox *mThreadLeaderCombo = nullptr;
0044     QComboBox *mThreadExpandPolicyCombo = nullptr;
0045     // Advanced tab
0046     QComboBox *mFillViewStrategyCombo = nullptr;
0047 
0048 public:
0049     /**
0050      * Sets the Aggregation to be edited.
0051      * Saves and forgets any previously Aggregation that was being edited.
0052      * The set parameter may be 0: in this case the editor is simply disabled.
0053      */
0054     void editAggregation(Core::Aggregation *set);
0055 
0056     /**
0057      * Returns the Aggregation currently edited by this AggregationEditor.
0058      * May be 0.
0059      */
0060     Core::Aggregation *editedAggregation() const
0061     {
0062         return mCurrentAggregation;
0063     }
0064 
0065     /**
0066      * Explicitly commits the changes in the editor to the edited Aggregation, if any.
0067      */
0068     void commit();
0069 
0070 Q_SIGNALS:
0071     /**
0072      * This is triggered when the aggregation name changes in the editor text field.
0073      * It's connected to the Aggregation configuration dialog which updates
0074      * the list of aggregations with the new name.
0075      */
0076     void aggregationNameChanged();
0077 
0078 private:
0079     // Helpers for filling the various editing elements
0080 
0081     void fillGroupingCombo();
0082     void fillGroupExpandPolicyCombo();
0083     void fillThreadingCombo();
0084     void fillThreadLeaderCombo();
0085     void fillThreadExpandPolicyCombo();
0086     void fillFillViewStrategyCombo();
0087     void setReadOnly(bool readOnly);
0088 
0089 private Q_SLOTS:
0090 
0091     // Internal handlers for editing element interaction
0092 
0093     void groupingComboActivated(int idx);
0094     void threadingComboActivated(int idx);
0095     void slotNameEditTextEdited(const QString &newName) override;
0096 };
0097 } // namespace Utils
0098 } // namespace MessageList