FougTools  0.7.0dev-046fb6a
Handy tools for C++, Qt and OpenCascade
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
qcombo_box_current_item_keeper.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** FougTools
3 ** Copyright Fougue (30 Mar. 2015)
4 ** contact@fougue.pro
5 **
6 ** This software is a computer program whose purpose is to provide utility
7 ** tools for the C++ language and the Qt toolkit.
8 **
9 ** This software is governed by the CeCILL-C license under French law and
10 ** abiding by the rules of distribution of free software. You can use,
11 ** modify and/ or redistribute the software under the terms of the CeCILL-C
12 ** license as circulated by CEA, CNRS and INRIA at the following URL
13 ** "http://www.cecill.info".
14 ****************************************************************************/
15 
16 #pragma once
17 
18 #include "gui.h"
19 #include <QtCore/QObject>
20 #include <QtCore/QVariant>
21 class QComboBox;
22 
23 namespace qtgui {
24 
26 {
27  Q_OBJECT
28 
29 public:
30  QComboBoxCurrentItemKeeper(QComboBox* comboBox = NULL);
31 
32  int columnForModelRowIdentifier() const;
33  void setColumnForModelRowIdentifier(int col);
34 
35 signals:
36  void currentIndexChanged(int row);
37 
38 private slots:
39  void onModelAboutToBeReset();
40  void onModelReset();
41 
42 private:
43  QComboBox* comboBox() const;
44  QVariant currentIdentifierValue() const;
45  QVariant identifierValue(int row) const;
46 
47  int m_oldCurrentIndex;
48  QVariant m_oldIdentifierValue;
49  int m_columnForModelRowIdentifier;
50 };
51 
52 } // namespace qtgui
Provides automatic preservation of a QComboBox's current item on reset of a QAbstractItemModel.
Definition: qcombo_box_current_item_keeper.h:25
Definition: abstract_length_editor.cpp:20
#define QTTOOLS_GUI_EXPORT
Definition: gui.h:27