1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : User interface for searches
9
* Copyright (C) 2008-2009 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
11
* This program is free software; you can redistribute it
12
* and/or modify it under the terms of the GNU General
13
* Public License as published by the Free Software Foundation;
14
* either version 2, or (at your option)
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* ============================================================ */
24
#ifndef SEARCHUTILITIES_H
25
#define SEARCHUTILITIES_H
35
#include <QDoubleSpinBox>
40
#include <ksqueezedtextlabel.h>
44
#include "comboboxutilities.h"
54
class AnimatedClearButton : public QWidget
60
AnimatedClearButton(QWidget* parent = 0);
62
QSize sizeHint () const;
64
void setPixmap(const QPixmap& p);
68
* Sets a primary condition for the button to be shown.
69
* If false, animateVisible() will have no effect.
71
void setShallBeShown(bool show);
73
/** This parameter determines the behavior when the animation
74
* to hide the widget has finished:
75
* If stayVisible is true, the widget remains visible,
77
* If stayVisible is false, setVisible(false) is called,
78
* which removes the widget for layouting etc.
80
void stayVisibleWhenAnimatedOut(bool stayVisible);
84
/// Set visible, possibly with animation
85
void animateVisible(bool visible);
86
/// Set visible without animation
87
void setDirectlyVisible(bool visible);
95
virtual void paintEvent(QPaintEvent* event);
96
virtual void mouseReleaseEvent(QMouseEvent* event);
100
void visibleChanged();
101
void updateAnimationSettings();
105
class AnimatedClearButtonPriv;
106
AnimatedClearButtonPriv* const d;
109
// -------------------------------------------------------------------------
111
class CustomStepsDoubleSpinBox : public QDoubleSpinBox
117
/** This is a normal QDoubleSpinBox which allows to
118
* customize the stepping behavior, for cases where
119
* linear steps are not applicable
122
CustomStepsDoubleSpinBox(QWidget* parent = 0);
124
virtual void stepBy(int steps);
126
/** Set a list of values that are usually applicable for the
127
* type of data of the combo box. The user can still type in
128
* any other value. Boundaries are not touched.
129
* Up or below the min and max values of the list given,
130
* default stepping is used.
132
void setSuggestedValues(const QList<double>& values);
134
/** Sets the value that should be set as first value
135
* when first moving away from the minimum value. */
136
void setSuggestedInitialValue(double initialValue);
138
/** Allows to set to different default single steps,
139
* for the range below m_values, the other for above */
140
void setSingleSteps(double smaller, double larger);
142
void setInvertStepping(bool invert);
144
/** Resets to minimum value */
149
void slotValueChanged(double d);
153
bool m_beforeInitialValue;
154
QList<double> m_values;
155
double m_initialValue;
156
double m_smallerStep;
158
bool m_invertStepping;
161
// -------------------------------------------------------------------------
163
class CustomStepsIntSpinBox : public QSpinBox
169
/** This is a normal QIntSpinBox which allows to
170
* customize the stepping behavior, for cases where
171
* linear steps are not applicable
174
CustomStepsIntSpinBox(QWidget* parent = 0);
176
virtual void stepBy(int steps);
178
/** Set a list of values that are usually applicable for the
179
* type of data of the combo box. The user can still type in
180
* any other value. Boundaries are not touched.
181
* Up or below the min and max values of the list given,
182
* default stepping is used.
184
void setSuggestedValues(const QList<int>& values);
186
/** Sets the value that should be set as first value
187
* when first moving away from the minimum value. */
188
void setSuggestedInitialValue(int initialValue);
190
/** Allows to set to different default single steps,
191
* for the range below m_values, the other for above */
192
void setSingleSteps(int smaller, int larger);
194
void setInvertStepping(bool invert);
196
/** Call this with a fraction prefix (like "1/") to enable
197
* magic handling of the value as fraction denominator. */
198
void enableFractionMagic(const QString& prefix);
200
/** Resets to minimum value */
203
/** value() and setValue() for fraction magic value. */
204
double fractionMagicValue() const;
205
void setFractionMagicValue(double value);
209
virtual QString textFromValue(int value) const;
210
virtual int valueFromText(const QString& text) const;
211
virtual StepEnabled stepEnabled() const;
215
void slotValueChanged(int d);
219
bool m_beforeInitialValue;
224
bool m_invertStepping;
225
QString m_fractionPrefix;
226
QString m_fractionSpecialValueText;
229
// -------------------------------------------------------------------------
231
class StyleSheetDebugger : public QWidget
237
/** This widget is for development purpose only:
238
* It allows the developer to change the style sheet
239
* on a widget dynamically.
240
* If you want to develop or debug the stylesheet on your widget,
241
* add temporary code:
242
* new StyleSheetDebugger(myWidget);
243
* That's all. Change the style sheet by editing it and pressing Ok. */
245
StyleSheetDebugger(QWidget* object);
249
void buttonClicked();
254
KPushButton* m_okButton;
258
} // namespace Digikam
260
#endif // SEARCHUTILITIES_H