diff --git a/src/kactionselector.h b/src/kactionselector.h index 6e81644..41b7061 100644 --- a/src/kactionselector.h +++ b/src/kactionselector.h @@ -1,353 +1,354 @@ /* This file is part of the KDE project Copyright (C) 2002 Anders Lund This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _KACTION_SELECTOR_H_ #define _KACTION_SELECTOR_H_ #include #include class QListWidget; class QListWidgetItem; class QKeyEvent; class QEvent; class QIcon; class KActionSelectorPrivate; /** @short A widget for selecting and arranging actions/objects This widget allows the user to select from a set of objects and arrange the order of the selected ones using two list boxes labeled "Available" and "Used" with horizontal arrows in between to move selected objects between the two, and vertical arrows on the right to arrange the order of the selected objects. The widget moves objects to the other listbox when doubleclicked if the property moveOnDoubleClick is set to true (default). See moveOnDoubleClick() and setMoveOnDoubleClick(). The user control the widget using the keyboard if enabled (default), see keyboardEnabled. Note that this may conflict with keyboard selection in the selected list box, if you set that to anything else than QListWidget::Single (which is the default). To use it, simply construct an instance and then add items to the two listboxes, available through lbAvailable() and lbSelected(). Whenever you want, you can retrieve the selected options using QListWidget methods on lbSelected(). This way, you can use your own QListWidgetItem class, allowing you to easily store object data in those. When an item is moved to a listbox, it is placed below the current item of that listbox. Standard arrow icons are used, but you can use icons of your own choice if desired, see setButtonIcon(). It is also possible to set tooltips and whatsthis help for the buttons. See setButtonTooltip() and setButtonWhatsThis(). To set whatsthis or tooltips for the listboxes, access them through availableListWidget() and selectedListWidget(). All the moving buttons are automatically set enabled as expected. Signals are sent each time an item is moved, allowing you to follow the users actions if you need to. See addedToSelection(), removedFromSelection(), movedUp() and movedDown() \image html kactionselector.png "KDE Action Selector" @author Anders Lund */ class KWIDGETSADDONS_EXPORT KActionSelector : public QWidget { Q_OBJECT - Q_ENUMS(InsertionPolicy MoveButton) Q_PROPERTY(bool moveOnDoubleClick READ moveOnDoubleClick WRITE setMoveOnDoubleClick) Q_PROPERTY(bool keyboardEnabled READ keyboardEnabled WRITE setKeyboardEnabled) Q_PROPERTY(QString availableLabel READ availableLabel WRITE setAvailableLabel) Q_PROPERTY(QString selectedLabel READ selectedLabel WRITE setSelectedLabel) Q_PROPERTY(InsertionPolicy availableInsertionPolicy READ availableInsertionPolicy WRITE setAvailableInsertionPolicy) Q_PROPERTY(InsertionPolicy selectedInsertionPolicy READ selectedInsertionPolicy WRITE setSelectedInsertionPolicy) Q_PROPERTY(bool showUpDownButtons READ showUpDownButtons WRITE setShowUpDownButtons) public: explicit KActionSelector(QWidget *parent = 0); ~KActionSelector(); /** @return The QListWidget holding the available actions */ QListWidget *availableListWidget() const; /** @return The QListWidget holding the selected actions */ QListWidget *selectedListWidget() const; /** This enum identifies the moving buttons */ enum MoveButton { ButtonAdd, ButtonRemove, ButtonUp, ButtonDown }; + Q_ENUM(MoveButton) /** This enum defines policies for where to insert moved items in a listbox. The following policies are currently defined: @li BelowCurrent - The item is inserted below the listbox' currentItem() or at the end if there is no current item. @li Sorted - The listbox is sort()ed after one or more items are inserted. @li AtTop - The item is inserted at index 0 in the listbox. @li AtBottom - The item is inserted at the end of the listbox. @sa availableInsertionPolicy(), setAvailableInsertionPolicy(), selectedInsertionPolicy(), setSelectedInsertionPolicy(). */ enum InsertionPolicy { BelowCurrent, Sorted, AtTop, AtBottom }; + Q_ENUM(InsertionPolicy) /** @return Whether moveOnDoubleClcik is enabled. If enabled, an item in any listbox will be moved to the other one whenever double-clicked. This feature is enabled by default. @sa setMoveOnDoubleClick() */ bool moveOnDoubleClick() const; /** Sets moveOnDoubleClick to @p enable @sa moveOnDoubleClick() */ void setMoveOnDoubleClick(bool enable); /** @return Whether keyboard control is enabled. When Keyboard control is enabled, the widget will react to the following keyboard actions: @li CTRL + Right - simulate clicking the add button @li CTRL + Left - simulate clicking the remove button @li CTRL + Up - simulate clicking the up button @li CTRL + Down - simulate clicking the down button Additionally, pressing RETURN or ENTER on one of the list boxes will cause the current item of that listbox to be moved to the other listbox. The keyboard actions are enabled by default. @sa setKeyboardEnabled() */ bool keyboardEnabled() const; /** Sets the keyboard enabled depending on @p enable. @sa keyboardEnabled() */ void setKeyboardEnabled(bool enable); /** @return The text of the label for the available items listbox. */ QString availableLabel() const; /** Sets the label for the available items listbox to @p text. Note that this label has the listbox as its @e buddy, so that if you have a single ampersand in the text, the following character will become the accelerator to focus the listbox. */ void setAvailableLabel(const QString &text); /** @return the label of the selected items listbox. */ QString selectedLabel() const; /** Sets the label for the selected items listbox to @p text. Note that this label has the listbox as its @e buddy, so that if you have a single ampersand in the text, the following character will become the accelerator to focus the listbox. */ void setSelectedLabel(const QString &text); /** @return The current insertion policy for the available listbox. The default policy for the available listbox is Sorted. See also InsertionPolicy, setAvailableInsertionPolicy(). */ InsertionPolicy availableInsertionPolicy() const; /** Sets the insertion policy for the available listbox. See also InsertionPolicy, availableInsertionPolicy(). */ void setAvailableInsertionPolicy(InsertionPolicy policy); /** @return The current insertion policy for the selected listbox. The default policy for the selected listbox is BelowCurrent. See also InsertionPolicy, setSelectedInsertionPolicy(). */ InsertionPolicy selectedInsertionPolicy() const; /** Sets the insertion policy for the selected listbox. See also InsertionPolicy, selectedInsertionPolicy(). */ void setSelectedInsertionPolicy(InsertionPolicy policy); /** @return whether the Up and Down buttons should be displayed. */ bool showUpDownButtons() const; /** Sets whether the Up and Down buttons should be displayed according to @p show */ void setShowUpDownButtons(bool show); /** Sets the pixmap of the button @p button to @p icon. It calls SmallIconSet(pm) to generate the icon set. */ void setButtonIcon(const QString &icon, MoveButton button); /** Sets the iconset for button @p button to @p iconset. You can use this method to set a custom icon set. Either created by QIconSet, or use the application instance of KIconLoader (recommended). */ void setButtonIconSet(const QIcon &iconset, MoveButton button); /** Sets the tooltip for the button @p button to @p tip. */ void setButtonTooltip(const QString &tip, MoveButton button); /** Sets the whatsthis help for button @p button to @p text. */ void setButtonWhatsThis(const QString &text, MoveButton button); Q_SIGNALS: /** Emitted when an item is moved to the "selected" listbox. */ void added(QListWidgetItem *item); /** Emitted when an item is moved out of the "selected" listbox. */ void removed(QListWidgetItem *item); /** Emitted when an item is moved upwards in the "selected" listbox. */ void movedUp(QListWidgetItem *item); /** Emitted when an item is moved downwards in the "selected" listbox. */ void movedDown(QListWidgetItem *item); /** Emitted when an item is moved to the "selected" listbox. */ // void addedToSelection( QListWidgetItem *item ); public Q_SLOTS: /** Sets the enabled state of all moving buttons to reflect the current options. Be sure to call this if you add or removes items to either listbox after the widget is shown */ void setButtonsEnabled(); protected: /** Reimplemented for internal reasons. */ void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; /** Reimplemented for internal reasons. */ bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; private: /** Move selected item from available box to the selected box */ Q_PRIVATE_SLOT(d, void buttonAddClicked()) /** Move selected item from selected box to available box */ Q_PRIVATE_SLOT(d, void buttonRemoveClicked()) /** Move selected item in selected box upwards */ Q_PRIVATE_SLOT(d, void buttonUpClicked()) /** Move seleted item in selected box downwards */ Q_PRIVATE_SLOT(d, void buttonDownClicked()) /** Moves the item @p item to the other listbox if moveOnDoubleClick is enabled. */ Q_PRIVATE_SLOT(d, void itemDoubleClicked(QListWidgetItem *item)) /** connected to both list boxes to set the buttons enabled */ Q_PRIVATE_SLOT(d, void slotCurrentChanged(QListWidgetItem *)) private: /** @private Private data storage */ friend class KActionSelectorPrivate; KActionSelectorPrivate *const d; Q_DISABLE_COPY(KActionSelector) }; #endif // _KACTION_SELECTOR_H_ diff --git a/src/kcapacitybar.h b/src/kcapacitybar.h index 1fd1be6..6ebd35e 100644 --- a/src/kcapacitybar.h +++ b/src/kcapacitybar.h @@ -1,236 +1,236 @@ /* * This file is part of the KDE project * Copyright (C) 2008 Rafael Fernández López * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KCAPACITYBAR_H #define KCAPACITYBAR_H #include #include class QPaintEvent; /** * @brief This widget shows a bar which is filled to show the level of usage of * a certain device. * * This widget represents a bar which goal is to show the level of usage of a * device. Its look is similar to a progress bar, but different, because this * widget does not want to give a notion of progress. * * @since 4.2 * * \image html kcapacitybar.png "KDE Capacity Bar" * * @author Rafael Fernández López */ class KWIDGETSADDONS_EXPORT KCapacityBar : public QWidget { Q_OBJECT Q_PROPERTY(int value READ value WRITE setValue) Q_PROPERTY(QString text READ text WRITE setText) Q_PROPERTY(DrawTextMode drawTextMode READ drawTextMode WRITE setDrawTextMode) Q_PROPERTY(bool fillFullBlocks READ fillFullBlocks WRITE setFillFullBlocks) Q_PROPERTY(bool continuous READ continuous WRITE setContinuous) Q_PROPERTY(int barHeight READ barHeight WRITE setBarHeight) Q_PROPERTY(Qt::Alignment horizontalTextAlignment READ horizontalTextAlignment WRITE setHorizontalTextAlignment) - Q_ENUMS(DrawTextMode) public: enum DrawTextMode { DrawTextInline = 0, ///< If any text set, draw it into the capacity bar DrawTextOutline ///< If any text set, draw it out of the capacity bar }; + Q_ENUM(DrawTextMode) /** * Constructs a capacity bar with DrawTextOutline as draw text mode. * @param parent The parent of the widget. * @since 5.24 */ explicit KCapacityBar(QWidget *parent = Q_NULLPTR); /** * Capacity bar constructor. * * @param drawTextMode If any text set, whether to draw it into the capacity bar * or not. * @param parent The parent of the widget. */ explicit KCapacityBar(DrawTextMode drawTextMode, QWidget *parent = 0); ~KCapacityBar(); /** * Capacity bar fill value. * * @param value This parameter can take values from 0 to 100. * * @note Its value is 0 by default. */ void setValue(int value); /** * @return The fill value of the capacity bar. */ int value() const; /** * Sets the text for the capacity bar. * * @param text The text that the capacity bar will show. * * @note This is an empty string by default. */ void setText(const QString &text); /** * @return The text that the capacity bar will show. */ QString text() const; /** * When the capacity bar is non-continuous, sets whether the last block * shown should be drawn full or can be cut off (depending on the capacity * bar width, and the value set on it). * * @param fillFullBlocks If true, the last block drawn will be fully filled, * on other case, the last block drawn could be cut off. * * @note This method is only relevant if the capacity bar is in * non-continuous mode. * * @note Its value is true by default. * * @see setContinuous, continuous */ void setFillFullBlocks(bool fillFullBlocks); /** * @return Whether the last block shown can be cut off when necessary. */ bool fillFullBlocks() const; /** * Sets whether the fill of the capacity bar should be continuous or in * block mode. * * @param continuous If true, the fill of the capacity bar is done in a * continuous way. In other case, the fill is done with * separated blocks. * * @note Its value is true by default. */ void setContinuous(bool continuous); /** * @return Whether the fill of the capacity bar should be continuous or * block-based. */ bool continuous() const; /** * Sets the height (in pixels) of the bar. * * @param barHeight The preferred height (in pixels) of the capacity bar. * * @note If you set a certain text and the capacity bar is in inline mode, * the height of the bar will be the maximum of the font height and * this value. * * @note If you set a certain text and the capacity bar is in outline mode, * the height of the whole capacity bar will be bigger than this * value. Take in count the height of this widget is got from adding * the bar height, the font metrics height and a small separator * between the bar and the outline text. * * @note Its value is 12 pixels by default. */ void setBarHeight(int barHeight); /** * @return The preferred height of the capacity bar. */ int barHeight() const; /** * If the capacity bar is in outline text mode, draw the text with * @p textAlignment alignment. * * @param textAlignment Sets the horizontal alignment for the text if * the capacity bar is in outline text mode. * * @note If @p textAlignemt contains vertical alignment flags, they will be * ignored. * * @note If the capacity bar is in inline text mode, the text is always * centered, and both vertical and horizontal flags set through this * method are ignored. * * @note Its value is centered by default. */ void setHorizontalTextAlignment(Qt::Alignment textAlignment); /** * @return The horizontal alignment for the text that will be drawn. */ Qt::Alignment horizontalTextAlignment() const; /** * Set the way text is drawn if any is set * * @param drawTextMode If any text set, whether to draw it into the capacity bar * or not. */ void setDrawTextMode(DrawTextMode mode); /** * The way text is drawn, inside the capacity bar or outside of it */ DrawTextMode drawTextMode() const; /** * This method allows you to draw the widget, directly, for example on * item delegates. You only need the painter object and the rect where * this widget should be drawn. */ void drawCapacityBar(QPainter *p, const QRect &rect) const; // Reimplemented from QWidget QSize minimumSizeHint() const Q_DECL_OVERRIDE; protected: // Reimplemented from QWidget void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; // Reimplemented from QWidget void changeEvent(QEvent *event) Q_DECL_OVERRIDE; private: /** * @internal */ class Private; Private *const d; }; #endif diff --git a/src/kdatecombobox.h b/src/kdatecombobox.h index 458c701..3979600 100644 --- a/src/kdatecombobox.h +++ b/src/kdatecombobox.h @@ -1,311 +1,311 @@ /* Copyright 2011 John Layt This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDATECOMBOBOX_H #define KDATECOMBOBOX_H #include #include #include class KDateComboBoxPrivate; class KWIDGETSADDONS_EXPORT KDateComboBox : public QComboBox { Q_OBJECT Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged USER true) Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate RESET resetMinimumDate) Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate RESET resetMaximumDate) Q_PROPERTY(Options options READ options WRITE setOptions) - Q_FLAGS(Options) public: /** * Options provided by the widget * @see options() * @see setOptions() */ enum Option { EditDate = 0x0001, /**< Allow the user to manually edit the date in the combo line edit */ SelectDate = 0x0002, /**< Allow the user to select the date from a drop-down menu */ DatePicker = 0x0004, /**< Show a date picker in the drop-down */ DateKeywords = 0x0008, /**< Show date keywords in the drop-down */ WarnOnInvalid = 0x0010 /**< Show a warning on focus out if the date is invalid */ }; Q_DECLARE_FLAGS(Options, Option) + Q_FLAG(Options) /** * Create a new KDateComboBox widget * * By default the EditDate, SelectDate, DatePicker and DateKeywords options * are enabled, the ShortDate format is used and the date is set to the * current date. */ explicit KDateComboBox(QWidget *parent = 0); /** * Destroy the widget */ virtual ~KDateComboBox(); /** * Return the currently selected date * * @return the currently selected date */ QDate date() const; /** * Return if the current user input is valid * * If the user input is null then it is not valid * * @see isNull() * @return if the current user input is valid */ bool isValid() const; /** * Return if the current user input is null * * @see isValid() * @return if the current user input is null */ bool isNull() const; /** * Return the currently set widget options * * @return the currently set widget options */ Options options() const; /** * Return the currently set date display format * * By default this is the Short Format * * @return the currently set date format */ QLocale::FormatType displayFormat() const; /** * Return the current minimum date * * @return the current minimum date */ QDate minimumDate() const; /** * Return the current maximum date * * @return the current maximum date */ QDate maximumDate() const; /** * Return the map of dates listed in the drop-down and their displayed * string forms. * * @see setDateMap() * @return the select date map */ QMap dateMap() const; Q_SIGNALS: /** * Signal if the date has been manually entered or selected by the user. * * The returned date may be invalid. * * @param date the new date */ void dateEntered(const QDate &date); /** * Signal if the date has been changed either manually by the user * or programatically. * * The returned date may be invalid. * * @param date the new date */ void dateChanged(const QDate &date); /** * Signal if the date is being manually edited by the user. * * The returned date may be invalid. * * @param date the new date */ void dateEdited(const QDate &date); public Q_SLOTS: /** * Set the currently selected date * * You can set an invalid date or a date outside the valid range, validity * checking is only done via isValid(). * * @param date the new date */ void setDate(const QDate &date); /** * Set the new widget options * * @param options the new widget options */ void setOptions(Options options); /** * Sets the date format to display. * * By default is the Short Format. * * @param format the date format to use */ void setDisplayFormat(QLocale::FormatType format); /** * Set the valid date range to be applied by isValid(). * * Both dates must be valid and the minimum date must be less than or equal * to the maximum date, otherwise the date range will not be set. * * @param minDate the minimum date * @param maxDate the maximum date * @param minWarnMsg the minimum warning message * @param maxWarnMsg the maximum warning message */ void setDateRange(const QDate &minDate, const QDate &maxDate, const QString &minWarnMsg = QString(), const QString &maxWarnMsg = QString()); /** * Reset the minimum and maximum date to the default values. * @see setDateRange() */ void resetDateRange(); /** * Set the minimum allowed date. * * If the date is invalid, or greater than current maximum, * then the minimum will not be set. * * @see minimumDate() * @see maximumDate() * @see setMaximumDate() * @see setDateRange() * @param minDate the minimum date * @param minWarnMsg the minimum warning message */ void setMinimumDate(const QDate &minTime, const QString &minWarnMsg = QString()); /** * Reset the minimum date to the default. * * The default is to have no minimum date. */ void resetMinimumDate(); /** * Set the maximum allowed date. * * If the date is invalid, or less than current minimum, * then the maximum will not be set. * * @see minimumDate() * @see maximumDate() * @see setMaximumDate() * @see setDateRange() * @param maxDate the maximum date * @param maxWarnMsg the maximum warning message */ void setMaximumDate(const QDate &maxDate, const QString &maxWarnMsg = QString()); /** * Reset the maximum date to the default * * The default is to have no maximum date. */ void resetMaximumDate(); /** * Set the list of dates able to be selected from the drop-down and the * string form to display for those dates, e.g. "2010-01-01" and "Yesterday". * * Any invalid or duplicate dates will be used, the list will NOT be * sorted, and the minimum and maximum date will not be affected. * * The @p dateMap is keyed by the date to be listed and the value is the * string to be displayed. If you want the date to be displayed in the * default date format then the string should be null. If you want a * separator to be displayed then set the string to "separator". * * @see dateMap() * @param dateMap the map of dates able to be selected */ void setDateMap(QMap dateMap); protected: bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; void showPopup() Q_DECL_OVERRIDE; void hidePopup() Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE; void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; /** * Assign the date for the widget. * * Virtual to allow sub-classes to apply extra validation rules. * * @param date the new date */ virtual void assignDate(const QDate &date); private: friend class KDateComboBoxPrivate; KDateComboBoxPrivate *const d; Q_PRIVATE_SLOT(d, void clickDate()) Q_PRIVATE_SLOT(d, void selectDate(QAction *)) Q_PRIVATE_SLOT(d, void editDate(const QString &)) Q_PRIVATE_SLOT(d, void enterDate(const QDate &)) Q_PRIVATE_SLOT(d, void parseDate()) }; Q_DECLARE_OPERATORS_FOR_FLAGS(KDateComboBox::Options) #endif // KDATECOMBOBOX_H diff --git a/src/kdatetimeedit.h b/src/kdatetimeedit.h index c713456..6e809cc 100644 --- a/src/kdatetimeedit.h +++ b/src/kdatetimeedit.h @@ -1,600 +1,600 @@ /* Copyright 2011 John Layt This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDATETIMEEDIT_H #define KDATETIMEEDIT_H #include #include #include #include class KDateTimeEditPrivate; class KWIDGETSADDONS_EXPORT KDateTimeEdit : public QWidget { Q_OBJECT Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged USER true) Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY timeChanged USER true) Q_PROPERTY(int timeListInterval READ timeListInterval WRITE setTimeListInterval) Q_PROPERTY(Options options READ options WRITE setOptions) - Q_FLAGS(Options) public: /** * Options provided by the widget * @see options * @see setOptions */ enum Option { ShowCalendar = 0x00001, /**< If the Calendar System edit is displayed */ ShowDate = 0x00002, /**< If the Date is displayed */ ShowTime = 0x00004, /**< If the Time is displayed */ ShowTimeZone = 0x00008, /**< If the Time Zone is displayed */ //EditCalendar = 0x00010, /**< Allow the user to manually edit the calendar */ EditDate = 0x00020, /**< Allow the user to manually edit the date */ EditTime = 0x00040, /**< Allow the user to manually edit the time */ //EditTimeZone = 0x00080, /**< Allow the user to manually edit the time zone */ SelectCalendar = 0x00100, /**< Allow the user to select a calendar */ SelectDate = 0x00200, /**< Allow the user to select a date */ SelectTime = 0x00400, /**< Allow the user to select a time */ SelectTimeZone = 0x00800, /**< Allow the user to select a time zone */ DatePicker = 0x01000, /**< Show a date picker */ DateKeywords = 0x02000, /**< Show date keywords */ ForceTime = 0x04000, /**< The entered time can only be a selected time */ WarnOnInvalid = 0x08000 /**< Show a warning on focus out if the date or time is invalid */ }; Q_DECLARE_FLAGS(Options, Option) + Q_FLAG(Options) /** * Create a new KDateTimeEdit widget */ explicit KDateTimeEdit(QWidget *parent = 0); /** * Destroy the widget */ virtual ~KDateTimeEdit(); /** * Return the currently set widget options * * @return the currently set widget options */ Options options() const; /** * Return the currently selected date, time and time zone * * @return the currently selected date, time and time zone */ QDateTime dateTime() const; /** * Return the currently selected date * * @return the currently selected date */ QDate date() const; /** * Return the currently selected time * * @return the currently selected time */ QTime time() const; /** * Return the currently selected time zone * * @return the currently selected time zone */ QTimeZone timeZone() const; /** * Returns the list of Calendar Systems displayed. * * @param calendars the list of calendar systems to display */ QList calendarLocalesList() const; /** * Return the current minimum date and time * * @return the current minimum date and time */ QDateTime minimumDateTime() const; /** * Return the current maximum date and time * * @return the current maximum date and time */ QDateTime maximumDateTime() const; /** * Return the currently set date display format * * By default this is the Short Format * * @return the currently set date format */ QLocale::FormatType dateDisplayFormat() const; /** * Return the map of dates listed in the drop-down and their displayed * string forms. * * @see setDateMap() * @return the select date map */ QMap dateMap() const; /** * Return the currently set time format * * By default this is the Short Format * * @return the currently set time format */ QLocale::FormatType timeDisplayFormat() const; /** * Return the time list interval able to be selected * * @return the select time intervals in minutes */ int timeListInterval() const; /** * Return the list of times able to be selected in the drop-down. * * @see setTimeList() * @see timeListInterval() * @see setTimeListInterval() * @return the select time list */ QList timeList() const; /** * Return the list of time zones able to be selected * * @param zones the time zones to display */ QList timeZones() const; /** * Return if the current user input is valid * * If the user input is null then it is not valid * * @see isNull() * @return if the current user input is valid */ bool isValid() const; /** * Return if the current user input is null * * @see isValid() * @return if the current user input is null */ bool isNull() const; /** * Return if the current user input date is valid * * If the user input date is null then it is not valid * * @see isNullDate() * @return if the current user input date is valid */ bool isValidDate() const; /** * Return if the current user input date is null * * @see isValidDate() * @return if the current user input date is null */ bool isNullDate() const; /** * Return if the current user input time is valid * * If the user input time is null then it is not valid * * @see isNullTime() * @return if the current user input time is valid */ bool isValidTime() const; /** * Return if the current user input time is null * * @see isValidTime() * @return if the current user input time is null */ bool isNullTime() const; Q_SIGNALS: /** * Signal if the date or time has been manually entered by the user. * * The returned date and time may be invalid. * * @param dateTime the new date, time and time zone */ void dateTimeEntered(const QDateTime &dateTime); /** * Signal if the date or time has been changed either manually by the user * or programatically. * * The returned date and time may be invalid. * * @param dateTime the new date, time and time zone */ void dateTimeChanged(const QDateTime &dateTime); /** * Signal if the date or time is being manually edited by the user. * * The returned date and time may be invalid. * * @param dateTime the new date, time and time zone */ void dateTimeEdited(const QDateTime &dateTime); /** * Signal if the Calendar Locale has been manually entered by the user. * * @param calendarLocale the new calendar locale */ void calendarEntered(const QLocale &calendarLocale); /** * Signal if the Calendar Locale has been changed either manually by the user * or programatically. * * @param calendarLocale the new calendar locale */ void calendarChanged(const QLocale &calendarLocale); /** * Signal if the date has been manually entered by the user. * * The returned date may be invalid. * * @param date the new date */ void dateEntered(const QDate &date); /** * Signal if the date has been changed either manually by the user * or programatically. * * The returned date may be invalid. * * @param date the new date */ void dateChanged(const QDate &date); /** * Signal if the date is being manually edited by the user. * * The returned date may be invalid. * * @param date the new date */ void dateEdited(const QDate &date); /** * Signal if the time has been manually entered by the user. * * The returned time may be invalid. * * @param time the new time */ void timeEntered(const QTime &time); /** * Signal if the time has been changed either manually by the user * or programatically. * * The returned time may be invalid. * * @param time the new time */ void timeChanged(const QTime &time); /** * Signal if the time is being manually edited by the user. * * The returned time may be invalid. * * @param time the new time */ void timeEdited(const QTime &time); /** * Signal if the time zone has been changed manually by the user. * * @param timeZone the new time zone */ void timeZoneEntered(const QTimeZone &zone); /** * Signal if the time zone has been changed either manually by the user * or programatically. * * @param timeZone the new time zone */ void timeZoneChanged(const QTimeZone &zone); public Q_SLOTS: /** * Set the new widget options * * @param options the new widget options */ void setOptions(Options options); /** * Set the currently selected date, time and time zone * * @param dateTime the new date, time and time zone */ void setDateTime(const QDateTime &dateTime); /** * Set the currently selected date * * @param date the new date */ void setDate(const QDate &date); /** * Set the currently selected time * * @param time the new time */ void setTime(const QTime &time); /** * Set the current time zone * * @param zone the new zone */ void setTimeZone(const QTimeZone &zone); /** * Set the minimum and maximum date and time range * * To enable range checking provide two valid dates. * To disable range checking provide two invalid dates, or call * clearDateRange; * * @param minDateTime the minimum date and time * @param maxDateTime the maximum date and time * @param minWarnMsg the minimum warning message * @param maxWarnMsg the maximum warning message */ void setDateTimeRange(const QDateTime &minDateTime, const QDateTime &maxDateTime, const QString &minWarnMsg = QString(), const QString &maxWarnMsg = QString()); /** * Reset the minimum and maximum date and time to the default */ void resetDateTimeRange(); /** * Set the minimum allowed date. * * If the date is invalid, or more than current maximum, * then the minimum will not be set. * * @see setMaximumDateTime() * @see setDateRange() * @param maxDate the minimum date * @param maxWarnMsg the minimum warning message */ void setMinimumDateTime(const QDateTime &minDateTime, const QString &minWarnMsg = QString()); /** * Reset the minimum date and time to the default */ void resetMinimumDateTime(); /** * Set the maximum allowed date. * * If the date is invalid, or less than current minimum, * then the maximum will not be set. * * @see setMinimumDateTime() * @see setDateRange() * @param maxDate the maximum date * @param maxWarnMsg the maximum warning message */ void setMaximumDateTime(const QDateTime &maxDateTime, const QString &maxWarnMsg = QString()); /** * Reset the minimum date and time to the default */ void resetMaximumDateTime(); /** * Sets the date format to display. * * By default is the Short Format. * * @param format the date format to use */ void setDateDisplayFormat(QLocale::FormatType format); /** * Set the list of Calendar Locales to display. * * @param calendarLocales the list of calendar locales to display */ void setCalendarLocalesList(const QList &calendarLocales); /** * Set the list of dates able to be selected from the drop-down and the * string form to display for those dates, e.g. "2010-01-01" and "Yesterday". * * Any invalid or duplicate dates will be used, the list will NOT be * sorted, and the minimum and maximum date will not be affected. * * The @p dateMap is keyed by the date to be listed and the value is the * string to be displayed. If you want the date to be displayed in the * default date format then the string should be null. If you want a * separator to be displayed then set the string to "separator". * * @see dateMap() * @param dateMap the map of dates able to be selected */ void setDateMap(QMap dateMap); /** * Sets the time format to display. * * By default is the Short Format. * * @param format the time format to use */ void setTimeDisplayFormat(QLocale::FormatType formatOptions); /** * Set the interval between times able to be selected from the drop-down. * * The combo drop-down will be populated with times every @param minutes * apart, starting from the minimumTime() and ending at maximumTime(). * * If the ForceInterval option is set then any time manually typed into the * combo line edit will be forced to the nearest interval. * * This interval must be an exact divisor of the valid time range hours. * For example with the default 24 hour range @p interval must divide 1440 * minutes exactly, meaning 1, 6 and 90 are valid but 7, 31 and 91 are not. * * Setting the time list interval will override any time list previously set * via setTimeList(). * * @see timeListInterval() * @param minutes the time list interval to display */ void setTimeListInterval(int minutes); /** * Set the list of times able to be selected from the drop-down. * * Setting the time list will override any time interval previously set via * setTimeListInterval(). * * Any invalid or duplicate times will be ignored, and the list will be * sorted. * * The minimum and maximum time will automatically be set to the earliest * and latest value in the list. * * @see timeList() * @param timeList the list of times able to be selected * @param minWarnMsg the minimum warning message * @param maxWarnMsg the maximum warning message */ void setTimeList(QList timeList, const QString &minWarnMsg = QString(), const QString &maxWarnMsg = QString()); /** * Set the time zones able to be selected * * @param zones the time zones to display */ void setTimeZones(const QList &zones); protected: bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE; void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; /** * Assign the date, time and time zone for the widget. * * Virtual to allow sub-classes to apply extra validation rules, * but reimplementations must call the parent method at the end. * * @param datetime the new date and time */ virtual void assignDateTime(const QDateTime &dateTime); /** * Assign the date for the widget. * * Virtual to allow sub-classes to apply extra validation rules, * but reimplementations must call the parent method at the end. * * @param date the new date */ virtual void assignDate(const QDate &date); /** * Assign the time for the widget. * * Virtual to allow sub-classes to apply extra validation rules, * but reimplementations must call the parent method at the end. * * @param time the new time */ virtual void assignTime(const QTime &time); /** * Assign the time zone for the widget. * * Virtual to allow sub-classes to apply extra validation rules, * but reimplementations must call the parent method at the end. * * @param zone the new time zone */ void assignTimeZone(const QTimeZone &zone); private: friend class KDateTimeEditPrivate; KDateTimeEditPrivate *const d; Q_PRIVATE_SLOT(d, void selectCalendar(int)) Q_PRIVATE_SLOT(d, void enterCalendar(const QLocale &)) Q_PRIVATE_SLOT(d, void selectTimeZone(int)) Q_PRIVATE_SLOT(d, void enterTimeZone(const QByteArray &)) }; Q_DECLARE_OPERATORS_FOR_FLAGS(KDateTimeEdit::Options) #endif // KDATETIMEEDIT_H diff --git a/src/keditlistwidget.h b/src/keditlistwidget.h index ceb5f19..85bfc34 100644 --- a/src/keditlistwidget.h +++ b/src/keditlistwidget.h @@ -1,270 +1,270 @@ /* This file is part of the KDE libraries Copyright (C) 2000 David Faure , Alexander Neundorf (C) 2010 Sebastian Trueg This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KEDITLISTWIDGET_H #define KEDITLISTWIDGET_H #include #include class QLineEdit; class QComboBox; class QListView; class QPushButton; class QItemSelection; class KEditListWidgetPrivate; /** * An editable listbox * * This class provides an editable listbox, this means * a listbox which is accompanied by a line edit to enter new * items into the listbox and pushbuttons to add and remove * items from the listbox and two buttons to move items up and down. * * \image html keditlistbox.png "KDE Edit List Box Widget" * * @since 4.6 */ class KWIDGETSADDONS_EXPORT KEditListWidget : public QWidget { Q_OBJECT - Q_FLAGS(Buttons) Q_PROPERTY(Buttons buttons READ buttons WRITE setButtons) Q_PROPERTY(QStringList items READ items WRITE setItems NOTIFY changed USER true) Q_PROPERTY(bool checkAtEntering READ checkAtEntering WRITE setCheckAtEntering) public: class CustomEditorPrivate; /** * Custom editor class **/ class KWIDGETSADDONS_EXPORT CustomEditor { public: CustomEditor(); CustomEditor(QWidget *repWidget, QLineEdit *edit); CustomEditor(QComboBox *combo); virtual ~CustomEditor(); void setRepresentationWidget(QWidget *repWidget); void setLineEdit(QLineEdit *edit); virtual QWidget *representationWidget() const; virtual QLineEdit *lineEdit() const; private: friend class CustomEditorPrivate; CustomEditorPrivate *const d; Q_DISABLE_COPY(CustomEditor) }; public: /** * Enumeration of the buttons, the listbox offers. Specify them in the * constructor in the buttons parameter, or in setButtons. */ enum Button { Add = 0x0001, Remove = 0x0002, UpDown = 0x0004, All = Add | Remove | UpDown }; Q_DECLARE_FLAGS(Buttons, Button) + Q_FLAG(Buttons) /** * Create an editable listbox. */ explicit KEditListWidget(QWidget *parent = 0); /** * Constructor which allows to use a custom editing widget * instead of the standard QLineEdit widget. E.g. you can use a * KUrlRequester or a QComboBox as input widget. The custom * editor must consist of a lineedit and optionally another widget that * is used as representation. A QComboBox or a KUrlRequester have a * QLineEdit as child-widget for example, so the QComboBox is used as * the representation widget. * * @see KUrlRequester::customEditor(), setCustomEditor */ KEditListWidget(const CustomEditor &customEditor, QWidget *parent = 0, bool checkAtEntering = false, Buttons buttons = All); virtual ~KEditListWidget(); /** * @returns a pointer to the embedded QListView. */ QListView *listView() const; /** * @returns a pointer to the embedded QLineEdit. */ QLineEdit *lineEdit() const; /** * @returns a pointer to the Add button */ QPushButton *addButton() const; /** * @returns a pointer to the Remove button */ QPushButton *removeButton() const; /** * @returns a pointer to the Up button */ QPushButton *upButton() const; /** * @returns a pointer to the Down button */ QPushButton *downButton() const; /** * @returns the count of elements in the list */ int count() const; /** * Inserts a @p list of elements from the @p index element * If @p index is negative, the elements will be appended */ void insertStringList(const QStringList &list, int index = -1); /** * Inserts a @p text element at the @p index position * If @p index is negative, the element will be appended */ void insertItem(const QString &text, int index = -1); /** * Clears both the listbox and the line edit. */ void clear(); /** * @returns the text at the @p index position */ QString text(int index) const; /** * @returns the currently selected item */ int currentItem() const; /** * @returns the currently selected item's text */ QString currentText() const; /** * @returns a list with the text of all items in the listbox */ QStringList items() const; /** * Clears the listbox and sets the contents to @p items */ void setItems(const QStringList &items); /** * @returns which buttons are visible */ Buttons buttons() const; /** * Specifies which @p buttons are visible */ void setButtons(Buttons buttons); /** * If @p check is true, after every character you type * in the line edit KEditListWidget will enable or disable * the Add-button, depending whether the current content of the * line edit is already in the listbox. Maybe this can become a * performance hit with large lists on slow machines. * If @p check is false, * it will be checked if you press the Add-button. It is not * possible to enter items twice into the listbox. * Default is false. */ void setCheckAtEntering(bool check); /** * @returns true if check at entering is enabled. */ bool checkAtEntering(); /** * Allows to use a custom editing widget * instead of the standard QLineEdit widget. E.g. you can use a * KUrlRequester or a QComboBox as input widget. The custom * editor must consist of a lineedit and optionally another widget that * is used as representation. A QComboBox or a KUrlRequester have a * QLineEdit as child-widget for example, so the QComboBox is used as * the representation widget. */ void setCustomEditor(const CustomEditor &editor); /** * Reimplented for interal reasons. The API is not affected. */ bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE; Q_SIGNALS: void changed(); /** * This signal is emitted when the user adds a new string to the list, * the parameter is the added string. */ void added(const QString &text); /** * This signal is emitted when the user removes a string from the list, * the parameter is the removed string. */ void removed(const QString &text); private Q_SLOTS: void moveItemUp(); void moveItemDown(); void addItem(); void removeItem(); void enableMoveButtons(const QModelIndex &, const QModelIndex &); void typedSomething(const QString &text); void slotSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); private: friend class KEditListWidgetPrivate; KEditListWidgetPrivate *const d; Q_DISABLE_COPY(KEditListWidget) }; Q_DECLARE_OPERATORS_FOR_FLAGS(KEditListWidget::Buttons) #endif diff --git a/src/kled.h b/src/kled.h index 34f98fb..97f8720 100644 --- a/src/kled.h +++ b/src/kled.h @@ -1,260 +1,262 @@ /* This file is part of the KDE libraries Copyright (C) 1998 Jörg Habenicht (j.habenicht@europemail.com) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KLED_H #define KLED_H #include #include class QColor; /** * @short An LED widget. * * Displays a round or rectangular light emitting diode. * * It is configurable to arbitrary colors, the two on/off states and three * styles (or "looks"); * * It may display itself in a performant flat view, a round view with * light spot or a round view sunken in the screen. * * \image html kled.png "KDE LED Widget" * * @author Joerg Habenicht, Richard J. Moore (rich@kde.org) 1998, 1999 */ class KWIDGETSADDONS_EXPORT KLed : public QWidget { Q_OBJECT - Q_ENUMS(State Shape Look) Q_PROPERTY(State state READ state WRITE setState) Q_PROPERTY(Shape shape READ shape WRITE setShape) Q_PROPERTY(Look look READ look WRITE setLook) Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(int darkFactor READ darkFactor WRITE setDarkFactor) public: /** * Status of the light is on/off. * @short LED on/off. */ enum State { Off, On }; + Q_ENUM(State) /** * Shades of the lamp. * @short LED shape */ enum Shape { Rectangular, Circular }; + Q_ENUM(Shape) /** * Displays a flat, round or sunken LED. * * @short LED look. */ enum Look { Flat, Raised, Sunken }; + Q_ENUM(Look) /** * Constructs a green, round LED widget which will initially * be turned on. * * @param parent The parent widget. */ explicit KLed(QWidget *parent = 0); /** * Constructs a round LED widget with the supplied color which will * initially be turned on. * * @param color Initial color of the LED. * @param parent The parent widget. * @short Constructor */ explicit KLed(const QColor &color, QWidget *parent = 0); /** * Constructor with the color, state and look. * * Differs from above only in the parameters, which configure all settings. * * @param color Initial color of the LED. * @param state Sets the State. * @param look Sets the Look. * @param shape Sets the Shape (rectangular or circular). * @param parent The parent widget. * @short Constructor */ KLed(const QColor &color, KLed::State state, KLed::Look look, KLed::Shape shape, QWidget *parent = 0); /** * Destroys the LED widget. * @short Destructor */ ~KLed(); /** * Returns the current color of the widget. * * @see Color * @short Returns LED color. */ QColor color() const; /** * Returns the current state of the widget (on/off). * * @see State * @short Returns LED state. */ State state() const; /** * Returns the current look of the widget. * * @see Look * @short Returns LED look. */ Look look() const; /** * Returns the current shape of the widget. * * @see Shape * @short Returns LED shape. */ Shape shape() const; /** * Returns the factor to darken the LED. * * @see setDarkFactor() * @short Returns dark factor. */ int darkFactor() const; /** * Set the color of the widget. * * The LED is shown with Color when in the KLed::On state * or with the darken Color (@see setDarkFactor) in KLed::Off * state. * * The widget calls the update() method, so it will * be updated when entering the main event loop. * * @see Color * * @param color New color of the LED. * @short Sets the LED color. */ void setColor(const QColor &color); /** * Sets the state of the widget to On or Off. * * @see on() off() toggle() * * @param state The LED state: on or off. * @short Set LED state. */ void setState(State state); /** * Sets the look of the widget. * * The look may be Flat, Raised or Sunken. * * The widget calls the update() method, so it will * be updated when entering the main event loop. * * @see Look * * @param look New look of the LED. * @short Sets LED look. */ void setLook(Look look); /** * Set the shape of the LED. * * @param shape The LED shape. * @short Set LED shape. */ void setShape(Shape shape); /** * Sets the factor to darken the LED in KLed::Off state. * * The @param darkFactor should be greater than 100, otherwise the LED * becomes lighter in KLed::Off state. * * Defaults to 300. * * @see QColor * * @param darkFactor Sets the factor to darken the LED. * @short Sets the factor to darken the LED. */ void setDarkFactor(int darkFactor); QSize sizeHint() const Q_DECL_OVERRIDE; QSize minimumSizeHint() const Q_DECL_OVERRIDE; public Q_SLOTS: /** * Toggles the state of the led from Off to On or vice versa. */ void toggle(); /** * Sets the state of the widget to On. * * @see off() toggle() setState() */ void on(); /** * Sets the state of the widget to Off. * * @see on() toggle() setState() */ void off(); protected: void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; /** * @internal * invalidates caches after property changes and calls update() */ void updateCachedPixmap(); private: class Private; Private *const d; void updateAccessibleName(); }; #endif diff --git a/src/kmessagewidget.h b/src/kmessagewidget.h index de0fdc6..ce073ef 100644 --- a/src/kmessagewidget.h +++ b/src/kmessagewidget.h @@ -1,344 +1,344 @@ /* This file is part of the KDE libraries * * Copyright (c) 2011 Aurélien Gâteau * Copyright (c) 2014 Dominik Haumann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef KMESSAGEWIDGET_H #define KMESSAGEWIDGET_H #include #include class KMessageWidgetPrivate; /** * @short A widget to provide feedback or propose opportunistic interactions. * * KMessageWidget can be used to provide inline positive or negative * feedback, or to implement opportunistic interactions. * * As a feedback widget, KMessageWidget provides a less intrusive alternative * to "OK Only" message boxes. If you want to avoid a modal KMessageBox, * consider using KMessageWidget instead. * * Examples of KMessageWidget look as follows, all of them having an icon set * with setIcon(), and the first three show a close button: * * \image html kmessagewidget.png "KMessageWidget with different message types" * * Negative feedback * * The KMessageWidget can be used as a secondary indicator of failure: the * first indicator is usually the fact the action the user expected to happen * did not happen. * * Example: User fills a form, clicks "Submit". * * @li Expected feedback: form closes * @li First indicator of failure: form stays there * @li Second indicator of failure: a KMessageWidget appears on top of the * form, explaining the error condition * * When used to provide negative feedback, KMessageWidget should be placed * close to its context. In the case of a form, it should appear on top of the * form entries. * * KMessageWidget should get inserted in the existing layout. Space should not * be reserved for it, otherwise it becomes "dead space", ignored by the user. * KMessageWidget should also not appear as an overlay to prevent blocking * access to elements the user needs to interact with to fix the failure. * * Positive feedback * * KMessageWidget can be used for positive feedback but it shouldn't be * overused. It is often enough to provide feedback by simply showing the * results of an action. * * Examples of acceptable uses: * * @li Confirm success of "critical" transactions * @li Indicate completion of background tasks * * Example of unadapted uses: * * @li Indicate successful saving of a file * @li Indicate a file has been successfully removed * * Opportunistic interaction * * Opportunistic interaction is the situation where the application suggests to * the user an action he could be interested in perform, either based on an * action the user just triggered or an event which the application noticed. * * Example of acceptable uses: * * @li A browser can propose remembering a recently entered password * @li A music collection can propose ripping a CD which just got inserted * @li A chat application may notify the user a "special friend" just connected * * @author Aurélien Gâteau * @since 4.7 */ class KWIDGETSADDONS_EXPORT KMessageWidget : public QFrame { Q_OBJECT - Q_ENUMS(MessageType) Q_PROPERTY(QString text READ text WRITE setText) Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap) Q_PROPERTY(bool closeButtonVisible READ isCloseButtonVisible WRITE setCloseButtonVisible) Q_PROPERTY(MessageType messageType READ messageType WRITE setMessageType) Q_PROPERTY(QIcon icon READ icon WRITE setIcon) public: /** * Available message types. * The background colors are chosen depending on the message type. */ enum MessageType { Positive, Information, Warning, Error }; + Q_ENUM(MessageType) /** * Constructs a KMessageWidget with the specified @p parent. */ explicit KMessageWidget(QWidget *parent = 0); /** * Constructs a KMessageWidget with the specified @p parent and * contents @p text. */ explicit KMessageWidget(const QString &text, QWidget *parent = 0); /** * Destructor. */ ~KMessageWidget(); /** * Get the text of this message widget. * @see setText() */ QString text() const; /** * Check whether word wrap is enabled. * * If word wrap is enabled, the message widget wraps the displayed text * as required to the available width of the widget. This is useful to * avoid breaking widget layouts. * * @see setWordWrap() */ bool wordWrap() const; /** * Check whether the close button is visible. * * @see setCloseButtonVisible() */ bool isCloseButtonVisible() const; /** * Get the type of this message. * By default, the type is set to KMessageWidget::Information. * * @see KMessageWidget::MessageType, setMessageType() */ MessageType messageType() const; /** * Add @p action to the message widget. * For each action a button is added to the message widget in the * order the actions were added. * * @param action the action to add * @see removeAction(), QWidget::actions() */ void addAction(QAction *action); /** * Remove @p action from the message widget. * * @param action the action to remove * @see KMessageWidget::MessageType, addAction(), setMessageType() */ void removeAction(QAction *action); /** * Returns the preferred size of the message widget. */ QSize sizeHint() const Q_DECL_OVERRIDE; /** * Returns the minimum size of the message widget. */ QSize minimumSizeHint() const Q_DECL_OVERRIDE; /** * Returns the required height for @p width. * @param width the width in pixels */ int heightForWidth(int width) const Q_DECL_OVERRIDE; /** * The icon shown on the left of the text. By default, no icon is shown. * @since 4.11 */ QIcon icon() const; /** * Check whether the hide animation started by calling animatedHide() * is still running. If animations are disabled, this function always * returns @e false. * * @see animatedHide(), hideAnimationFinished() * @since 5.0 */ bool isHideAnimationRunning() const; /** * Check whether the show animation started by calling animatedShow() * is still running. If animations are disabled, this function always * returns @e false. * * @see animatedShow(), showAnimationFinished() * @since 5.0 */ bool isShowAnimationRunning() const; public Q_SLOTS: /** * Set the text of the message widget to @p text. * If the message widget is already visible, the text changes on the fly. * * @param text the text to display, rich text is allowed * @see text() */ void setText(const QString &text); /** * Set word wrap to @p wordWrap. If word wrap is enabled, the text() * of the message widget is wrapped to fit the available width. * If word wrap is disabled, the message widget's minimum size is * such that the entire text fits. * * @param wordWrap disable/enable word wrap * @see wordWrap() */ void setWordWrap(bool wordWrap); /** * Set the visibility of the close button. If @p visible is @e true, * a close button is shown that calls animatedHide() if clicked. * * @see closeButtonVisible(), animatedHide() */ void setCloseButtonVisible(bool visible); /** * Set the message type to @p type. * By default, the message type is set to KMessageWidget::Information. * * @see messageType(), KMessageWidget::MessageType */ void setMessageType(KMessageWidget::MessageType type); /** * Show the widget using an animation. */ void animatedShow(); /** * Hide the widget using an animation. */ void animatedHide(); /** * Define an icon to be shown on the left of the text * @since 4.11 */ void setIcon(const QIcon &icon); Q_SIGNALS: /** * This signal is emitted when the user clicks a link in the text label. * The URL referred to by the href anchor is passed in contents. * @param contents text of the href anchor * @see QLabel::linkActivated() * @since 4.10 */ void linkActivated(const QString &contents); /** * This signal is emitted when the user hovers over a link in the text label. * The URL referred to by the href anchor is passed in contents. * @param contents text of the href anchor * @see QLabel::linkHovered() * @since 4.11 */ void linkHovered(const QString &contents); /** * This signal is emitted when the hide animation is finished, started by * calling animatedHide(). If animations are disabled, this signal is * emitted immediately after the message widget got hidden. * * @note This signal is @e not emitted if the widget was hidden by * calling hide(), so this signal is only useful in conjunction * with animatedHide(). * * @see animatedHide() * @since 5.0 */ void hideAnimationFinished(); /** * This signal is emitted when the show animation is finished, started by * calling animatedShow(). If animations are disabled, this signal is * emitted immediately after the message widget got shown. * * @note This signal is @e not emitted if the widget was shown by * calling show(), so this signal is only useful in conjunction * with animatedShow(). * * @see animatedShow() * @since 5.0 */ void showAnimationFinished(); protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; bool event(QEvent *event) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; private: KMessageWidgetPrivate *const d; friend class KMessageWidgetPrivate; Q_PRIVATE_SLOT(d, void slotTimeLineChanged(qreal)) Q_PRIVATE_SLOT(d, void slotTimeLineFinished()) }; #endif /* KMESSAGEWIDGET_H */ diff --git a/src/kmultitabbar.h b/src/kmultitabbar.h index bf7d52c..5549c93 100644 --- a/src/kmultitabbar.h +++ b/src/kmultitabbar.h @@ -1,292 +1,293 @@ /*************************************************************************** kmultitabbar.h - description ------------------- begin : 2001 copyright : (C) 2001,2002,2003 by Joseph Wenninger ***************************************************************************/ /*************************************************************************** This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***************************************************************************/ #ifndef _KMultitabbar_h_ #define _KMultitabbar_h_ #include #include #include #include #include class QPixmap; class QPainter; class QMenu; class QStyleOptionToolButton; class KMultiTabBarPrivate; class KMultiTabBarTabPrivate; class KMultiTabBarButtonPrivate; class KMultiTabBarInternal; /** * A Widget for horizontal and vertical tabs. * (Note that in Qt4, QTabBar can be vertical as well) * * It is possible to add normal buttons to the top/left * The handling if only one tab at a time or multiple tabs * should be raisable is left to the "user". * * \image html kmultitabbar.png "KDE Multi Tab Bar Widget" * * @author Joseph Wenninger */ class KWIDGETSADDONS_EXPORT KMultiTabBar: public QWidget { Q_OBJECT - Q_ENUMS(KMultiTabBarPosition KMultiTabBarStyle) Q_PROPERTY(KMultiTabBarPosition position READ position WRITE setPosition) Q_PROPERTY(KMultiTabBarStyle tabStyle READ tabStyle WRITE setStyle) public: enum KMultiTabBarPosition { Left, Right, Top, Bottom }; + Q_ENUM(KMultiTabBarPosition) /** * The list of available styles for KMultiTabBar * - VSNET - Visual Studio .Net like, always shows icon, only show the text of active tabs * - KDEV3ICON - Kdevelop 3 like, always shows the text and icons */ enum KMultiTabBarStyle {VSNET = 0, KDEV3ICON = 2, STYLELAST = 0xffff}; + Q_ENUM(KMultiTabBarStyle) /** * Create a KMultiTabBar with Left as KMultiTabBar position. * @param parent The parent of the widget. * @since 5.24 */ explicit KMultiTabBar(QWidget *parent = Q_NULLPTR); explicit KMultiTabBar(KMultiTabBarPosition pos, QWidget *parent = 0); virtual ~KMultiTabBar(); /** * append a new button to the button area. The button can later on be accessed with button(ID) * eg for connecting signals to it * @param icon a icon for the button * @param id an arbitraty ID value. It will be emitted in the clicked signal for identifying the button * if more than one button is connected to a signals. * @param popup A popup menu which should be displayed if the button is clicked * @param not_used_yet will be used for a popup text in the future */ int appendButton(const QIcon &icon, int id = -1, QMenu *popup = 0, const QString ¬_used_yet = QString()); #ifndef KWIDGETSADDONS_NO_DEPRECATED /** * append a new button to the button area. The button can later on be accessed with button(ID) * eg for connecting signals to it * * @deprecated since 5.13, use the appendButton() with QIcon * * @param pic a pixmap for the button * @param id an arbitraty ID value. It will be emitted in the clicked signal for identifying the button * if more than one button is connected to a signals. * @param popup A popup menu which should be displayed if the button is clicked * @param not_used_yet will be used for a popup text in the future */ KWIDGETSADDONS_DEPRECATED int appendButton(const QPixmap &pic, int id = -1, QMenu *popup = 0, const QString ¬_used_yet = QString()); #endif /** * remove a button with the given ID */ void removeButton(int id); /** * append a new tab to the tab area. It can be accessed lateron with tabb(id); * @param icon a icon for the tab * @param id an arbitrary ID which can be used later on to identify the tab * @param text if a mode with text is used it will be the tab text, otherwise a mouse over hint */ int appendTab(const QIcon &icon, int id = -1, const QString &text = QString()); #ifndef KWIDGETSADDONS_NO_DEPRECATED /** * append a new tab to the tab area. It can be accessed lateron with tabb(id); * * @deprecated since 5.13, use the appendTab() with QIcon * * @param pic a bitmap for the tab * @param id an arbitrary ID which can be used later on to identify the tab * @param text if a mode with text is used it will be the tab text, otherwise a mouse over hint */ KWIDGETSADDONS_DEPRECATED int appendTab(const QPixmap &pic, int id = -1, const QString &text = QString()); #endif /** * remove a tab with a given ID */ void removeTab(int id); /** * set a tab to "raised" * @param id The ID of the tab to manipulate * @param state true == activated/raised, false == not active */ void setTab(int id, bool state); /** * return the state of a tab, identified by its ID */ bool isTabRaised(int id) const; /** * get a pointer to a button within the button area identified by its ID */ class KMultiTabBarButton *button(int id) const; /** * get a pointer to a tab within the tab area, identiifed by its ID */ class KMultiTabBarTab *tab(int id) const; /** * set the real position of the widget. * @param pos if the mode is horizontal, only use top, bottom, if it is vertical use left or right */ void setPosition(KMultiTabBarPosition pos); /** * get the tabbar position. * @return position */ KMultiTabBarPosition position() const; /** * set the display style of the tabs */ void setStyle(KMultiTabBarStyle style); /** * get the display style of the tabs * @return display style */ KMultiTabBarStyle tabStyle() const; protected: friend class KMultiTabBarButton; virtual void fontChange(const QFont &); void updateSeparator(); private: KMultiTabBarPrivate *const d; }; /** * Use KMultiTabBar::appendButton to append a button, which creates a KMultiTabBarButton instance */ class KWIDGETSADDONS_EXPORT KMultiTabBarButton: public QPushButton { Q_OBJECT public: int id() const; virtual ~KMultiTabBarButton(); public Q_SLOTS: void setText(const QString &text); Q_SIGNALS: /** * this is emitted if the button is clicked * @param id the ID identifying the button */ void clicked(int id); protected Q_SLOTS: virtual void slotClicked(); protected: void hideEvent(class QHideEvent *) Q_DECL_OVERRIDE; void showEvent(class QShowEvent *) Q_DECL_OVERRIDE; void paintEvent(class QPaintEvent *) Q_DECL_OVERRIDE; /** Should not be created directly. Use KMultiTabBar::appendButton */ KMultiTabBarButton(const QIcon &icon, const QString &, int id, QWidget *parent); /** Should not be created directly. Use KMultiTabBar::appendButton */ KMultiTabBarButton(const QPixmap &pic, const QString &, int id, QWidget *parent); private: friend class KMultiTabBar; int m_id; KMultiTabBarButtonPrivate *const d; }; /** * Use KMultiTabBar::appendTab to append a tab, which creates a KMultiTabBarTab instance */ class KWIDGETSADDONS_EXPORT KMultiTabBarTab: public KMultiTabBarButton { Q_OBJECT public: virtual ~KMultiTabBarTab(); QSize sizeHint() const Q_DECL_OVERRIDE; QSize minimumSizeHint() const Q_DECL_OVERRIDE; public Q_SLOTS: /** * this is used internaly, but can be used by the user, if (s)he wants to * It the according call of KMultiTabBar is invoked though this modifications will be overwritten */ void setPosition(KMultiTabBar::KMultiTabBarPosition); /** * this is used internaly, but can be used by the user, if (s)he wants to * It the according call of KMultiTabBar is invoked though this modifications will be overwritten */ void setStyle(KMultiTabBar::KMultiTabBarStyle); /** * set the active state of the tab * @param state true==active false==not active */ void setState(bool state); void setIcon(const QString &); void setIcon(const QPixmap &); protected: void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; private: KMultiTabBar::KMultiTabBarPosition m_position; KMultiTabBar::KMultiTabBarStyle m_style; void computeMargins(int *hMargin, int *vMargin) const; QSize computeSizeHint(bool withText) const; bool shouldDrawText() const; bool isVertical() const; QPixmap iconPixmap() const; void initStyleOption(QStyleOptionToolButton *opt) const; friend class KMultiTabBarInternal; /** * This class should never be created except with the appendTab call of KMultiTabBar */ KMultiTabBarTab(const QIcon &icon, const QString &, int id, QWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style); /** * This class should never be created except with the appendTab call of KMultiTabBar */ KMultiTabBarTab(const QPixmap &pic, const QString &, int id, QWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style); KMultiTabBarTabPrivate *const d; }; #endif diff --git a/src/knewpasswordwidget.h b/src/knewpasswordwidget.h index f63493f..9f55a1e 100644 --- a/src/knewpasswordwidget.h +++ b/src/knewpasswordwidget.h @@ -1,238 +1,238 @@ // vi: ts=8 sts=4 sw=4 /* This file is part of the KDE libraries Copyright (C) 1998 Pietro Iglio Copyright (C) 1999,2000 Geert Jansen Copyright (C) 2004,2005 Andrew Coles Copyright (C) 2006,2007 Olivier Goffart Copyright (C) 2015 Elvis Angelaccio This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KNEWPASSWORDWIDGET_H #define KNEWPASSWORDWIDGET_H #include #include /** * @short A password input widget. * * This widget allows the user to enter a new password. * * The password has to be entered twice to check if the passwords * match. A hint about the strength of the entered password is also * shown. * * In order to embed this widget in your custom password dialog, * you may want to connect to the passwordStatus() signal. * This way you can e.g. disable the OK button if the passwords * don't match, warn the user if the password is too weak, and so on. * * \section usage Usage Example * \subsection Setup * * \code * KNewPasswordWidget *m_passwordWidget = new KNewPasswordWidget(this); * // set a background warning color (taken from the current color scheme) * KColorScheme colorScheme(QPalette::Active, KColorScheme::View); * m_passwordWidget->setBackgroundWarningColor(colorScheme.background(KColorScheme::NegativeBackground).color()); * // listen to password status updates * connect(m_passwordWidget, &KNewPasswordWidget::passwordStatusChanged, this, &MyCustomDialog::slotPasswordStatusChanged); * ... * \endcode * * \subsection update Update your custom dialog * * @snippet knewpasswordwidget_test.cpp update_custom_dialog * * \subsection accept Accept your custom dialog * * @snippet knewpasswordwidget_test.cpp accept_custom_dialog * * @author Geert Jansen * @author Olivier Goffart * @author Elvis Angelaccio * @since 5.16 */ class KWIDGETSADDONS_EXPORT KNewPasswordWidget : public QWidget { Q_OBJECT - Q_ENUMS(PasswordStatus) Q_PROPERTY(PasswordStatus passwordStatus READ passwordStatus) Q_PROPERTY(bool allowEmptyPasswords READ allowEmptyPasswords WRITE setAllowEmptyPasswords) Q_PROPERTY(int minimumPasswordLength READ minimumPasswordLength WRITE setMinimumPasswordLength) Q_PROPERTY(int maximumPasswordLength READ maximumPasswordLength WRITE setMaximumPasswordLength) Q_PROPERTY(int reasonablePasswordLength READ reasonablePasswordLength WRITE setReasonablePasswordLength) Q_PROPERTY(int passwordStrengthWarningLevel READ passwordStrengthWarningLevel WRITE setPasswordStrengthWarningLevel) Q_PROPERTY(QColor backgroundWarningColor READ backgroundWarningColor WRITE setBackgroundWarningColor) Q_PROPERTY(bool passwordStrengthMeterVisible READ isPasswordStrengthMeterVisible WRITE setPasswordStrengthMeterVisible) public: /** * Status of the password being typed in the widget. */ enum PasswordStatus { EmptyPasswordNotAllowed, /**< Both passwords fields empty, but minimum length > 0. */ PasswordTooShort, /**< Password length is too low. */ PasswordNotVerified, /**< Password and verification password don't match. */ WeakPassword, /**< Passwords match but the strength level is not enough. */ StrongPassword, /**< Passwords match and the strength level is good. */ }; + Q_ENUM(PasswordStatus) /** * Constructs a password widget. * * @param parent Passed to lower level constructor. */ explicit KNewPasswordWidget(QWidget *parent = Q_NULLPTR); /** * Destructs the password widget. */ virtual ~KNewPasswordWidget(); /** * The current status of the password in the widget. */ PasswordStatus passwordStatus() const; /** * Allow empty passwords? * * @return true if minimumPasswordLength() == 0 */ bool allowEmptyPasswords() const; /** * Minimum acceptable password length. */ int minimumPasswordLength() const; /** * Maximum acceptable password length. */ int maximumPasswordLength() const; /** * Password length that is expected to be reasonably safe. */ int reasonablePasswordLength() const; /** * Password strength level below which a warning is given */ int passwordStrengthWarningLevel() const; /** * The color used as warning for the verification password field's background. */ QColor backgroundWarningColor() const; /** * Whether the password strength meter is visible. */ bool isPasswordStrengthMeterVisible() const; /** * Returns the password entered. * @note Only returns meaningful data when passwordStatus * is either WeakPassword or StrongPassword. */ QString password() const; public Q_SLOTS: /** * Allow empty passwords? - Default: true * * same as setMinimumPasswordLength( allowed ? 0 : 1 ) */ void setAllowEmptyPasswords(bool allowed); /** * Minimum acceptable password length. * * Default: 0 * * @param minLength The new minimum password length */ void setMinimumPasswordLength(int minLength); /** * Maximum acceptable password length. * * @param maxLength The new maximum password length. */ void setMaximumPasswordLength(int maxLength); /** * Password length that is expected to be reasonably safe. * The value is guaranteed to be in the range from 1 to maximumPasswordLength(). * * Used to compute the strength level * * Default: 8 - the standard UNIX password length * * @param reasonableLength The new reasonable password length. */ void setReasonablePasswordLength(int reasonableLength); /** * Set the password strength level below which a warning is given * The value is guaranteed to be in the range from 0 to 99. Empty passwords score 0; * non-empty passwords score up to 100, depending on their length and whether they * contain numbers, mixed case letters and punctuation. * * Default: 1 - warn if the password has no discernable strength whatsoever * @param warningLevel The level below which a warning should be given. */ void setPasswordStrengthWarningLevel(int warningLevel); /** * When the verification password does not match, the background color * of the verification field is set to @p color. As soon as the passwords match, * the original color of the verification field is restored. */ void setBackgroundWarningColor(const QColor &color); /** * Whether to show the password strength meter (label and progress bar). * Default is true. */ void setPasswordStrengthMeterVisible(bool visible); Q_SIGNALS: /** * Notify about the current status of the password being typed. */ void passwordStatusChanged(); private: class KNewPasswordWidgetPrivate; KNewPasswordWidgetPrivate *const d; Q_PRIVATE_SLOT(d, void _k_textChanged()) Q_PRIVATE_SLOT(d, void _k_toggleEchoMode()) Q_PRIVATE_SLOT(d, void _k_showToggleEchoModeAction(const QString &text)) Q_DISABLE_COPY(KNewPasswordWidget) }; #endif // KNEWPASSWORDWIDGET_H diff --git a/src/kpageview.h b/src/kpageview.h index 60a4557..c4188c8 100644 --- a/src/kpageview.h +++ b/src/kpageview.h @@ -1,198 +1,198 @@ /* This file is part of the KDE Libraries Copyright (C) 2006 Tobias Koenig (tokoe@kde.org) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPAGEVIEW_H #define KPAGEVIEW_H #include #include class KPageModel; class QAbstractItemDelegate; class QAbstractItemView; class QModelIndex; class KPageViewPrivate; class QAbstractItemModel; /** * @short A base class which can handle multiple pages. * * This class provides a widget base class which handles multiple * pages and allows the user to switch between these pages in * different ways. * * Currently, @p Auto, @p Plain, @p List, @p Tree and @p Tabbed face * types are available. @see KPageWidget * * Example:\n * * \code * KPageModel *model = new MyPageModel(); * * KPageView *view = new KPageView( this ); * view->setModel( model ); * * view->setFaceType( KPageView::List ); * \endcode * * @author Tobias Koenig (tokoe@kde.org) */ class KWIDGETSADDONS_EXPORT KPageView : public QWidget { Q_OBJECT - Q_ENUMS(FaceType) Q_PROPERTY(FaceType faceType READ faceType WRITE setFaceType) Q_DECLARE_PRIVATE(KPageView) public: /** * This enum is used to decide which type of navigation view * shall be used in the page view. * * @li Auto - Depending on the number of pages in the model, * the Plain (one page), the List (several pages) * or the Tree face (nested pages) will be used. * This is the default face type. * @li Plain - No navigation view will be visible and only the * first page of the model will be shown. * * @li List - An icon list is used as navigation view. * * @li Tree - A tree list is used as navigation view. * * @li Tabbed - A tab widget is used as navigation view. */ enum FaceType { Auto, Plain, List, Tree, Tabbed }; + Q_ENUM(FaceType) /** * Creates a page view with given parent. */ explicit KPageView(QWidget *parent = 0); /** * Destroys the page view. */ virtual ~KPageView(); /** * Sets the @p model of the page view. * * The model has to provide data for the roles defined in KPageModel::Role. */ void setModel(QAbstractItemModel *model); /** * Returns the model of the page view. */ QAbstractItemModel *model() const; /** * Sets the face type of the page view. */ void setFaceType(FaceType faceType); /** * Returns the face type of the page view. */ FaceType faceType() const; /** * Sets the page with @param index to be the current page and emits * the @see currentPageChanged signal. */ void setCurrentPage(const QModelIndex &index); /** * Returns the index for the current page or an invalid index * if no current page exists. */ QModelIndex currentPage() const; /** * Sets the item @param delegate which can be used customize * the page view. */ void setItemDelegate(QAbstractItemDelegate *delegate); /** * Returns the item delegate of the page view. */ QAbstractItemDelegate *itemDelegate() const; /** * Sets the @p widget which will be shown when a page is selected * that has no own widget set. */ void setDefaultWidget(QWidget *widget); Q_SIGNALS: /** * This signal is emitted whenever the current page changes. * The previous page index is replaced by the current index. */ void currentPageChanged(const QModelIndex ¤t, const QModelIndex &previous); protected: /** * Returns the navigation view, depending on the current * face type. * * This method can be reimplemented to provide custom * navigation views. */ virtual QAbstractItemView *createView(); /** * Returns whether the page header should be visible. * * This method can be reimplemented for adapting custom * views. */ virtual bool showPageHeader() const; /** * Returns the position where the navigation view should be * located according to the page stack. * * This method can be reimplemented for adapting custom * views. */ virtual Qt::Alignment viewPosition() const; KPageView(KPageViewPrivate &dd, QWidget *parent); KPageViewPrivate *const d_ptr; private: Q_PRIVATE_SLOT(d_func(), void _k_rebuildGui()) Q_PRIVATE_SLOT(d_func(), void _k_modelChanged()) Q_PRIVATE_SLOT(d_func(), void _k_pageSelected(const QItemSelection &, const QItemSelection &)) Q_PRIVATE_SLOT(d_func(), void _k_dataChanged(const QModelIndex &, const QModelIndex &)) }; #endif diff --git a/src/kruler.h b/src/kruler.h index bb7f858..8c0b6bb 100644 --- a/src/kruler.h +++ b/src/kruler.h @@ -1,384 +1,384 @@ /* -*- c++ -*- */ /* This file is part of the KDE libraries Copyright (C) 1998 Jörg Habenicht (j.habenicht@europemail.com) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KRULER_H #define KRULER_H #include #include /** * A ruler widget. * * The vertical ruler looks similar to this: * *\code * meters inches * * ------ <--- end mark ---> ------ * -- - * -- <---little mark---> -- * -- - * -- --- * --- <---medium mark - * -- -- * -- tiny mark----> - * -- ---- * -- - * ---- <-----big mark -- * -- - * |>-- <--ruler pointer--> |>-- * * \endcode * * There are tiny marks, little marks, medium marks, and big marks along the * ruler. * * To receive mouse clicks or mouse moves, the class has to be overloaded. * * \image html kruler.png "KDE Ruler Widget" * * @short A ruler widget. * @author Jörg Habenicht */ class KWIDGETSADDONS_EXPORT KRuler : public QAbstractSlider { Q_OBJECT Q_PROPERTY(bool showTinyMarks READ showTinyMarks WRITE setShowTinyMarks) Q_PROPERTY(bool showLittleMarks READ showLittleMarks WRITE setShowLittleMarks) Q_PROPERTY(bool showMediumMarks READ showMediumMarks WRITE setShowMediumMarks) Q_PROPERTY(bool showBigMarks READ showBigMarks WRITE setShowBigMarks) Q_PROPERTY(bool showPointer READ showPointer WRITE setShowPointer) Q_PROPERTY(bool showEndLabel READ showEndLabel WRITE setShowEndLabel) Q_PROPERTY(int tinyMarkDistance READ tinyMarkDistance WRITE setTinyMarkDistance) Q_PROPERTY(int littleMarkDistance READ littleMarkDistance WRITE setLittleMarkDistance) Q_PROPERTY(int mediumMarkDistance READ mediumMarkDistance WRITE setBigMarkDistance) Q_PROPERTY(int bigMarkDistance READ bigMarkDistance WRITE setBigMarkDistance) Q_PROPERTY(double pixelPerMark READ pixelPerMark WRITE setPixelPerMark) Q_PROPERTY(bool lengthFixed READ lengthFixed WRITE setLengthFixed) Q_PROPERTY(QString endLabel READ endLabel WRITE setEndLabel) - Q_ENUMS(MetricStyle) Q_PROPERTY(int length READ length WRITE setLength) Q_PROPERTY(int offset READ offset) Q_PROPERTY(int endOffset READ endOffset) public: /** * The types of units used. **/ enum MetricStyle { Custom = 0, Pixel, Inch, Millimetres, Centimetres, Metres }; + Q_ENUM(MetricStyle) /** * Constructs a horizontal ruler. */ explicit KRuler(QWidget *parent = 0); /** * Constructs a ruler with orientation @p orient. * * @p parent and @p f are passed to QFrame. * The default look is a raised widget * but may be changed with the inherited QFrame methods. * * @param orient Orientation of the ruler. * @param parent Will be handed over to QFrame. * @param f Will be handed over to QFrame. * **/ explicit KRuler(Qt::Orientation orient, QWidget *parent = 0, Qt::WindowFlags f = 0); /** * Constructs a ruler with orientation @p orient and initial width @p widgetWidth. * * The width sets the fixed width of the widget. This is useful if you * want to draw the ruler bigger or smaller than the default size. * Note: The size of the marks doesn't change. * @p parent and @p f are passed to QFrame. * * @param orient Orientation of the ruler. * @param widgetWidth Fixed width of the widget. * @param parent Will be handed over to QFrame. * @param f Will be handed over to QFrame. * */ KRuler(Qt::Orientation orient, int widgetWidth, QWidget *parent = 0, Qt::WindowFlags f = 0); /** * Destructor. */ ~KRuler(); /** * Sets the minimal value of the ruler pointer (default is 0). * * This method calls update() so that the widget is painted after leaving * to the main event loop. * **/ #ifndef KWIDGETSADDONS_NO_DEPRECATED KWIDGETSADDONS_DEPRECATED void setMinValue(int); #endif /** * Returns the minimal value of the ruler pointer. **/ #ifndef KWIDGETSADDONS_NO_DEPRECATED KWIDGETSADDONS_DEPRECATED int minValue() const; #endif /** * Sets the maximum value of the ruler pointer (default is 100). * * This method calls update() so that the widget is painted after leaving * to the main event loop. */ #ifndef KWIDGETSADDONS_NO_DEPRECATED KWIDGETSADDONS_DEPRECATED void setMaxValue(int); #endif /** * Returns the maximal value of the ruler pointer. */ #ifndef KWIDGETSADDONS_NO_DEPRECATED KWIDGETSADDONS_DEPRECATED int maxValue() const; #endif /** * Sets the distance between tiny marks. * * This is mostly used in the English system (inches) with distance of 1. */ void setTinyMarkDistance(int); /** * Returns the distance between tiny marks. **/ int tinyMarkDistance() const; /** * Sets the distance between little marks. * * The default value is 1 in the metric system and 2 in the English (inches) system. */ void setLittleMarkDistance(int); /** * Returns the distance between little marks. */ int littleMarkDistance() const; /** * Sets the distance between medium marks. * * For English (inches) styles it defaults to twice the little mark distance. * For metric styles it defaults to five times the little mark distance. **/ void setMediumMarkDistance(int); int mediumMarkDistance() const; /** * Sets distance between big marks. * * For English (inches) or metric styles it is twice the medium mark distance. **/ void setBigMarkDistance(int); /** * Returns the distance between big marks. **/ int bigMarkDistance() const; /** * Shows/hides tiny marks. **/ void setShowTinyMarks(bool); bool showTinyMarks() const; /** * Shows/hides little marks. **/ void setShowLittleMarks(bool); bool showLittleMarks() const; /** * Shows/hides medium marks. **/ void setShowMediumMarks(bool); bool showMediumMarks() const; /** * Shows/hides big marks. **/ void setShowBigMarks(bool); bool showBigMarks() const; /** * Shows/hides end marks. **/ void setShowEndMarks(bool); bool showEndMarks() const; /** * Shows/hides the pointer. */ void setShowPointer(bool); bool showPointer() const; #ifndef KWIDGETSADDONS_NO_DEPRECATED KWIDGETSADDONS_DEPRECATED void setFrameStyle(int); #endif /** * Show/hide number values of the end marks. * * Default is @p false. **/ void setShowEndLabel(bool); bool showEndLabel() const; /** * Sets the label this is drawn at the beginning of the visible part * of the ruler to @p label **/ void setEndLabel(const QString &); QString endLabel() const; /** * Sets up the necessary tasks for the provided styles. * * A convenience method. **/ void setRulerMetricStyle(KRuler::MetricStyle); /** * Sets the number of pixels between two base marks. * * Calling this method stretches or shrinks your ruler. * * For pixel display ( MetricStyle) the value is 10.0 marks * per pixel ;-) * For English (inches) it is 9.0, and for centimetres ~2.835 -> 3.0 . * If you want to magnify your part of display, you have to * adjust the mark distance @p here. * Notice: The double type is only supported to give the possibility * of having some double values. * It should be used with care. Using values below 10.0 * shows visible jumps of markpositions (e.g. 2.345). * Using whole numbers is highly recommended. * To use @p int values use setPixelPerMark((int)your_int_value); * default: 1 mark per 10 pixels */ void setPixelPerMark(double rate); /** * Returns the number of pixels between two base marks. **/ double pixelPerMark() const; /** * Sets the length of the ruler, i.e. the difference between * the begin mark and the end mark of the ruler. * * Same as (width() - offset()) * * when the length is not locked, it gets adjusted with the * length of the widget. */ void setLength(int); int length() const; /** * Locks the length of the ruler, i.e. the difference between * the two end marks doesn't change when the widget is resized. * * @param fix fixes the length, if true */ void setLengthFixed(bool fix); bool lengthFixed() const; /** * Sets the number of pixels by which the ruler may slide up or left. * The number of pixels moved is realive to the previous position. * The Method makes sense for updating a ruler, which is working with * a scrollbar. * * This doesn't affect the position of the ruler pointer. * Only the visible part of the ruler is moved. * * @param count Number of pixel moving up or left relative to the previous position **/ void slideUp(int count = 1); /** * Sets the number of pixels by which the ruler may slide down or right. * The number of pixels moved is realive to the previous position. * The Method makes sense for updating a ruler, which is working with * a scrollbar. * * This doesn't affect the position of the ruler pointer. * Only the visible part of the ruler is moved. * * @param count Number of pixel moving up or left relative to the previous position **/ void slideDown(int count = 1); /** * Sets the ruler slide offset. * * This is like slideup() or slidedown() with an absolute offset * from the start of the ruler. * * @param offset Number of pixel to move the ruler up or left from the beginning **/ void setOffset(int offset); /** * Returns the current ruler offset. **/ int offset() const; int endOffset() const; public Q_SLOTS: /** * Sets the pointer to a new position. * * The offset is NOT updated. * QWidget::repaint() is called afterwards. **/ void slotNewValue(int); /** * Sets the ruler marks to a new position. * * The pointer is NOT updated. * QWidget::repaint() is called afterwards. **/ void slotNewOffset(int); void slotEndOffset(int); protected: void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; private: void initWidget(Qt::Orientation orientation); private: class KRulerPrivate; KRulerPrivate *const d; }; #endif diff --git a/src/kselectaction.h b/src/kselectaction.h index ca69a28..92eb45c 100644 --- a/src/kselectaction.h +++ b/src/kselectaction.h @@ -1,398 +1,398 @@ /* This file is part of the KDE libraries Copyright (C) 1999 Reginald Stadlbauer (C) 1999 Simon Hausmann (C) 2000 Nicolas Hadacek (C) 2000 Kurt Granroth (C) 2000 Michael Koch (C) 2001 Holger Freyther (C) 2002 Ellis Whitehead (C) 2003 Andras Mantia (C) 2005-2006 Hamish Rodda (C) 2006 Albert Astals Cid (C) 2006 Clarence Dang (C) 2006 Michel Hermier (C) 2007 Nick Shaforostoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KSELECTACTION_H #define KSELECTACTION_H #include #include #include class KSelectActionPrivate; /** * @short Action for selecting one of several items * * Action for selecting one of several items. * * This action shows up a submenu with a list of items. * One of them can be checked. If the user clicks on an item * this item will automatically be checked, * the formerly checked item becomes unchecked. * There can be only one item checked at a time. */ class KWIDGETSADDONS_EXPORT KSelectAction : public QWidgetAction { Q_OBJECT Q_PROPERTY(QAction *currentAction READ currentAction WRITE setCurrentAction) Q_PROPERTY(bool editable READ isEditable WRITE setEditable) Q_PROPERTY(int comboWidth READ comboWidth WRITE setComboWidth) Q_PROPERTY(QString currentText READ currentText) - Q_ENUMS(ToolBarMode) Q_PROPERTY(ToolBarMode toolBarMode READ toolBarMode WRITE setToolBarMode) Q_PROPERTY(QToolButton::ToolButtonPopupMode toolButtonPopupMode READ toolButtonPopupMode WRITE setToolButtonPopupMode) Q_PROPERTY(int currentItem READ currentItem WRITE setCurrentItem) Q_PROPERTY(QStringList items READ items WRITE setItems) Q_DECLARE_PRIVATE(KSelectAction) public: /** * Constructs a selection action with the specified parent. * * @param parent The action's parent object. */ explicit KSelectAction(QObject *parent); /** * Constructs a selection action with text; a shortcut may be specified by * the ampersand character (e.g. \"&Option\" creates a shortcut with key \e O ) * * This is the most common KSelectAction used when you do not have a * corresponding icon (note that it won't appear in the current version * of the "Edit ToolBar" dialog, because an action needs an icon to be * plugged in a toolbar...). * * @param text The text that will be displayed. * @param parent The action's parent object. */ KSelectAction(const QString &text, QObject *parent); /** * Constructs a selection action with text and an icon; a shortcut may be specified by * the ampersand character (e.g. \"&Option\" creates a shortcut with key \e O ) * * This is the other common KSelectAction used. Use it when you * \e do have a corresponding icon. * * @param icon The icon to display. * @param text The text that will be displayed. * @param parent The action's parent object. */ KSelectAction(const QIcon &icon, const QString &text, QObject *parent); /** * Destructor */ virtual ~KSelectAction(); enum ToolBarMode { /// Creates a button which pops up a menu when interacted with, as defined by toolButtonPopupMode(). MenuMode, /// Creates a combo box which contains the actions. /// This is the default. ComboBoxMode }; + Q_ENUM(ToolBarMode) /** * Returns which type of widget (combo box or button with drop-down menu) will be inserted * in a toolbar. */ ToolBarMode toolBarMode() const; /** * Set the type of widget to be inserted in a toolbar to \a mode. */ void setToolBarMode(ToolBarMode mode); /** * Returns the style for the list of actions, when this action is plugged * into a KToolBar. The default value is QToolButton::InstantPopup * * \sa QToolButton::setPopupMode() */ QToolButton::ToolButtonPopupMode toolButtonPopupMode() const; /** * Set how this list of actions should behave when in popup mode and plugged into a toolbar. */ void setToolButtonPopupMode(QToolButton::ToolButtonPopupMode mode); /** * The action group used to create exclusivity between the actions associated with this action. */ QActionGroup *selectableActionGroup() const; /** * Returns the current QAction. * @see setCurrentAction */ QAction *currentAction() const; /** * Returns the index of the current item. * * @sa currentItem and currentAction */ int currentItem() const; /** * Returns the text of the currently selected item. * * @sa currentItem and currentAction */ QString currentText() const; /** * Returns the list of selectable actions */ QList actions() const; /** * Returns the action at \a index, if one exists. */ QAction *action(int index) const; /** * Searches for an action with the specified \a text, using a search whose * case sensitivity is defined by \a cs. */ QAction *action(const QString &text, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; /** * Sets the currently checked item. * * @param action the QAction to become the currently checked item. * * \return \e true if a corresponding action was found and successfully checked. */ bool setCurrentAction(QAction *action); /** * \overload setCurrentAction(QAction*) * * Convenience function to set the currently checked action to be the action * at index \p index. * * If there is no action at that index, the currently checked action (if any) will * be deselected. * * \return \e true if a corresponding action was found and thus set to the current action, otherwise \e false */ bool setCurrentItem(int index); /** * \overload setCurrentAction(QAction*) * * Convenience function to set the currently checked action to be the action * which has \p text as its text(). * * If there is no action at that index, the currently checked action (if any) will * be deselected. * * \return \e true if a corresponding action was found, otherwise \e false */ bool setCurrentAction(const QString &text, Qt::CaseSensitivity cs = Qt::CaseSensitive); /** * Add \a action to the list of selectable actions. */ void addAction(QAction *action); /** * \overload addAction(QAction* action) * * Convenience function which creates an action from \a text and inserts it into * the list of selectable actions. * * The newly created action is checkable and not user configurable. */ QAction *addAction(const QString &text); /** * \overload addAction(QAction* action) * * Convenience function which creates an action from \a text and \a icon and inserts it into * the list of selectable actions. * * The newly created action is checkable and not user configurable. */ QAction *addAction(const QIcon &icon, const QString &text); /** * Remove the specified \a action from this action selector. * * You take ownership here, so save or delete it in order to not leak the action. */ virtual QAction *removeAction(QAction *action); /** * Inserts the action action to this widget's list of actions, before the action before. * It appends the action if before is 0 or before is not a valid action for this widget. * * @since 5.0 */ virtual void insertAction(QAction *before, QAction *action); /** * Convenience function to create the list of selectable items. * Any previously existing items will be cleared. */ void setItems(const QStringList &lst); /** * Convenience function which returns the items that can be selected with this action. * It is the same as iterating selectableActionGroup()->actions() and looking at each * action's text(). */ QStringList items() const; /** * When this action is plugged into a toolbar, it creates a combobox. * @return true if the combo editable. */ bool isEditable() const; /** * When this action is plugged into a toolbar, it creates a combobox. * This makes the combo editable or read-only. */ void setEditable(bool); /** * When this action is plugged into a toolbar, it creates a combobox. * This returns the maximum width set by setComboWidth */ int comboWidth() const; /** * When this action is plugged into a toolbar, it creates a combobox. * This gives a _maximum_ size to the combobox. * The minimum size is automatically given by the contents (the items). */ void setComboWidth(int width); /** * Sets the maximum items that are visible at once if the action * is a combobox, that is the number of items in the combobox's viewport */ void setMaxComboViewCount(int n); /** * Remove and delete all the items in this action. * * @see removeAllActions() */ void clear(); /** * Remove all the items in this action. * * Unlike clear(), this will not delete the actions. * * @see clear() */ void removeAllActions(); /** * Sets whether any occurrence of the ampersand character ( & ) in items * should be interpreted as keyboard accelerator for items displayed in a * menu or not. Only applies to (overloaded) methods dealing with QStrings, * not those dealing with QActions. * * Defaults to true. * * \param b true if ampersands indicate a keyboard accelerator, otherwise false. */ void setMenuAccelsEnabled(bool b); /** * Returns whether ampersands passed to methods using QStrings are interpreted * as keyboard accelerator indicators or as literal ampersands. */ bool menuAccelsEnabled() const; /** * Changes the text of item @param index to @param text . */ void changeItem(int index, const QString &text); Q_SIGNALS: /** * This signal is emitted when an item is selected; @param action * indicates the item selected. */ void triggered(QAction *action); /** * This signal is emitted when an item is selected; @param index indicates * the item selected. */ void triggered(int index); /** * This signal is emitted when an item is selected; @param text indicates * the item selected. */ void triggered(const QString &text); protected Q_SLOTS: /** * This function is called whenever an action from the selections is triggered. */ virtual void actionTriggered(QAction *action); /** * For structured menu building. Deselects all items if the action was unchecked by the top menu */ void slotToggled(bool); protected: /** * Reimplemented from @see QWidgetAction. */ QWidget *createWidget(QWidget *parent) Q_DECL_OVERRIDE; /** * Reimplemented from @see QWidgetAction. */ void deleteWidget(QWidget *widget) Q_DECL_OVERRIDE; bool event(QEvent *event) Q_DECL_OVERRIDE; bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; /** * @internal * Creates a new KSelectAction object. * * @param dd the private d member * @param parent The action's parent object. */ KSelectAction(KSelectActionPrivate &dd, QObject *parent); KSelectActionPrivate *d_ptr; private: Q_PRIVATE_SLOT(d_func(), void _k_comboBoxDeleted(QObject *)) Q_PRIVATE_SLOT(d_func(), void _k_comboBoxCurrentIndexChanged(int)) }; #endif diff --git a/src/ktimecombobox.h b/src/ktimecombobox.h index 8f40136..68a944d 100644 --- a/src/ktimecombobox.h +++ b/src/ktimecombobox.h @@ -1,336 +1,336 @@ /* Copyright 2011 John Layt This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KTIMECOMBOBOX_H #define KTIMECOMBOBOX_H #include #include #include class KTimeComboBoxPrivate; class KWIDGETSADDONS_EXPORT KTimeComboBox : public QComboBox { Q_OBJECT Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY timeChanged USER true) Q_PROPERTY(QTime minimumTime READ minimumTime WRITE setMinimumTime RESET resetMinimumTime) Q_PROPERTY(QTime maximumTime READ maximumTime WRITE setMaximumTime RESET resetMaximumTime) Q_PROPERTY(int timeListInterval READ timeListInterval WRITE setTimeListInterval) Q_PROPERTY(Options options READ options WRITE setOptions) - Q_FLAGS(Options) public: /** * Options provided by the widget * @see options * @see setOptions */ enum Option { EditTime = 0x0001, /**< Allow the user to manually edit the time in the combo line edit */ SelectTime = 0x0002, /**< Allow the user to select the time from a drop-down menu */ ForceTime = 0x0004, /**< Any set or entered time will be forced to one of the drop-down times */ WarnOnInvalid = 0x0008 /**< Show a warning box on focus out if the user enters an invalid time */ }; Q_DECLARE_FLAGS(Options, Option) + Q_FLAG(Options) /** * Create a new KTimeComboBox widget */ explicit KTimeComboBox(QWidget *parent = 0); /** * Destroy the widget */ virtual ~KTimeComboBox(); /** * Return the currently selected time * * @return the currently selected time */ QTime time() const; /** * Return if the current user input is valid * * If the user input is null then it is not valid * * @see isNull() * @return if the current user input is valid */ bool isValid() const; /** * Return if the current user input is null * * @see isValid() * @return if the current user input is null */ bool isNull() const; /** * Return the currently set widget options * * @return the currently set widget options */ Options options() const; /** * Return the currently set time format * * By default this is the Short Format * * @return the currently set time format */ QLocale::FormatType displayFormat() const; /** * Return the current minimum time * * @return the current minimum time */ QTime minimumTime() const; /** * Reset the minimum time to the default of 00:00:00.000 */ void resetMinimumTime(); /** * Return the current maximum time * * @return the current maximum time */ QTime maximumTime() const; /** * Reset the maximum time to the default of 23:59:59.999 */ void resetMaximumTime(); /** * Set the minimum and maximum time range. * * If either time is invalid, or min > max then the range will not be set. * * @param minTime the minimum time * @param maxTime the maximum time * @param minWarnMsg the minimum warning message * @param maxWarnMsg the maximum warning message */ void setTimeRange(const QTime &minTime, const QTime &maxTime, const QString &minWarnMsg = QString(), const QString &maxWarnMsg = QString()); /** * Reset the minimum and maximum time to the default values. */ void resetTimeRange(); /** * Return the interval between select time list entries if set by setTimeListInterval(). * * Returns -1 if not set. * * @see setTimeListInterval() * @return the select time list interval in minutes */ int timeListInterval() const; /** * Return the list of times able to be selected in the drop-down. * * @see setTimeList() * @see timeListInterval() * @see setTimeListInterval() * @return the select time list */ QList timeList() const; Q_SIGNALS: /** * Signal if the time has been manually entered or selected by the user. * * The returned time may be invalid. * * @param time the new time */ void timeEntered(const QTime &time); /** * Signal if the time has been changed either manually by the user * or programatically. * * The returned time may be invalid. * * @param time the new time */ void timeChanged(const QTime &time); /** * Signal if the time is being manually edited by the user. * * The returned time may be invalid. * * @param time the new time */ void timeEdited(const QTime &time); public Q_SLOTS: /** * Set the currently selected time * * You can set an invalid time or a time outside the valid range, validity * checking is only done via isValid(). * * @param time the new time */ void setTime(const QTime &time); /** * Set the new widget options * * @param options the new widget options */ void setOptions(Options options); /** * Sets the time format to display. * * By default is the Short Format. * * @param format the time format to use */ void setDisplayFormat(QLocale::FormatType formatOptions); /** * Set the minimum allowed time. * * If the time is invalid, or greater than current maximum, * then the minimum will not be set. * * @see minimumTime() * @see maximumTime() * @see setMaximumTime() * @see setTimeRange() * @param minTime the minimum time * @param minWarnMsg the minimum warning message */ void setMinimumTime(const QTime &minTime, const QString &minWarnMsg = QString()); /** * Set the maximum allowed time. * * If the time is invalid, or less than current minimum, * then the maximum will not be set. * * @see minimumTime() * @see maximumTime() * @see setMaximumTime() * @see setTimeRange() * @param maxTime the maximum time * @param maxWarnMsg the maximum warning message */ void setMaximumTime(const QTime &maxTime, const QString &maxWarnMsg = QString()); /** * Set the interval between times able to be selected from the drop-down. * * The combo drop-down will be populated with times every @param minutes * apart, starting from the minimumTime() and ending at maximumTime(). * * If the ForceInterval option is set then any time manually typed into the * combo line edit will be forced to the nearest interval. * * This interval must be an exact divisor of the valid time range hours. * For example with the default 24 hour range @p interval must divide 1440 * minutes exactly, meaning 1, 6 and 90 are valid but 7, 31 and 91 are not. * * Setting the time list interval will override any time list previously set * via setTimeList(). * * @see timeListInterval() * @param minutes the time list interval to display */ void setTimeListInterval(int minutes); /** * Set the list of times able to be selected from the drop-down. * * Setting the time list will override any time interval previously set via * setTimeListInterval(). * * Any invalid or duplicate times will be ignored, and the list will be * sorted. * * The minimum and maximum time will automatically be set to the earliest * and latest value in the list. * * @see timeList() * @param timeList the list of times able to be selected * @param minWarnMsg the minimum warning message * @param maxWarnMsg the maximum warning message */ void setTimeList(QList timeList, const QString &minWarnMsg = QString(), const QString &maxWarnMsg = QString()); protected: bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; void showPopup() Q_DECL_OVERRIDE; void hidePopup() Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE; void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; /** * Assign the time for the widget. * * Virtual to allow sub-classes to apply extra validation rules. * * @param time the new time */ virtual void assignTime(const QTime &time); private: friend class KTimeComboBoxPrivate; KTimeComboBoxPrivate *const d; Q_PRIVATE_SLOT(d, void selectTime(int index)) Q_PRIVATE_SLOT(d, void editTime(const QString &)) Q_PRIVATE_SLOT(d, void enterTime(const QTime &)) Q_PRIVATE_SLOT(d, void parseTime()) }; Q_DECLARE_OPERATORS_FOR_FLAGS(KTimeComboBox::Options) #endif // KTIMECOMBOBOX_H diff --git a/src/ktitlewidget.h b/src/ktitlewidget.h index 50b1569..f084ecd 100644 --- a/src/ktitlewidget.h +++ b/src/ktitlewidget.h @@ -1,212 +1,212 @@ /* This file is part of the KDE libraries Copyright (C) 2007-2009 Urs Wolfer This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KTITLEWIDGET_H #define KTITLEWIDGET_H #include #include /** * @short Standard title widget. * * This class provides a widget often used for dialog titles. * \image html ktitlewidget.png "KTitleWidget with title and icon" * * KTitleWidget uses the general application font at 1.4 times its size to * style the text. This is a visual change from 4.x. * * @section Usage * KTitleWidget is very simple to use. You can either use its default text * (and pixmap) properties or display your own widgets in the title widget. * * A title text with a right-aligned pixmap: * @code KTitleWidget *titleWidget = new KTitleWidget(this); titleWidget->setText(i18n("Title")); titleWidget->setPixmap(QIcon::fromTheme("screen").pixmap(22, 22)); * @endcode * * Use it with an own widget: * @code KTitleWidget *checkboxTitleWidget = new KTitleWidget(this); QWidget *checkBoxTitleMainWidget = new QWidget(this); QVBoxLayout *titleLayout = new QVBoxLayout(checkBoxTitleMainWidget); titleLayout->setMargin(6); QCheckBox *checkBox = new QCheckBox("Text Checkbox", checkBoxTitleMainWidget); titleLayout->addWidget(checkBox); checkboxTitleWidget->setWidget(checkBoxTitleMainWidget); * @endcode * * @see KPageView * @author Urs Wolfer \ */ class KWIDGETSADDONS_EXPORT KTitleWidget : public QWidget { Q_OBJECT - Q_ENUMS(ImageAlignment) Q_PROPERTY(QString text READ text WRITE setText) Q_PROPERTY(QString comment READ comment WRITE setComment) Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap) Q_PROPERTY(int autoHideTimeout READ autoHideTimeout WRITE setAutoHideTimeout) public: /** * Possible title pixmap alignments. * * @li ImageLeft: Display the pixmap left * @li ImageRight: Display the pixmap right (default) */ enum ImageAlignment { ImageLeft, /**< Display the pixmap on the left */ ImageRight /**< Display the pixmap on the right */ }; + Q_ENUM(ImageAlignment) /** * Comment message types */ enum MessageType { PlainMessage, /**< Normal comment */ InfoMessage, /**< Information the user should be alerted to */ WarningMessage, /**< A warning the user should be alerted to */ ErrorMessage /**< An error message */ }; /** * Constructs a title widget with the given @param parent. */ explicit KTitleWidget(QWidget *parent = 0); virtual ~KTitleWidget(); /** * @param widget Widget displayed on the title widget. */ void setWidget(QWidget *widget); /** * @return the text displayed in the title * @see setText() */ QString text() const; /** * @return the text displayed in the comment below the title, if any * @see setComment() */ QString comment() const; /** * @return the pixmap displayed in the title * @see setPixmap() */ const QPixmap *pixmap() const; /** * Sets this label's buddy to buddy. * When the user presses the shortcut key indicated by the label in this * title widget, the keyboard focus is transferred to the label's buddy * widget. * @param buddy the widget to activate when the shortcut key is activated */ void setBuddy(QWidget *buddy); /** * Get the current timeout value in milliseconds * @return timeout value in msecs */ int autoHideTimeout() const; public Q_SLOTS: /** * @param text Text displayed on the label. It can either be plain text or rich text. If it * is plain text, the text is displayed as a bold title text. * @param alignment Alignment of the text. Default is left and vertical centered. * @see text() */ void setText(const QString &text, Qt::Alignment alignment = Qt::AlignLeft | Qt::AlignVCenter); /** * @param text Text displayed on the label. It can either be plain text or rich text. If it * is plain text, the text is displayed as a bold title text. * @param type The sort of message it is; will also set the icon accordingly @see MessageType * @see text() */ void setText(const QString &text, MessageType type); /** * @param comment Text displayed beneath the main title as a comment. * It can either be plain text or rich text. * @param type The sort of message it is. @see MessageType * @see comment() */ void setComment(const QString &comment, MessageType type = PlainMessage); /** * @param pixmap Pixmap displayed in the header. The pixmap is by default right, but * @param alignment can be used to display it also left. * @see pixmap() */ void setPixmap(const QPixmap &pixmap, ImageAlignment alignment = ImageRight); /** * @param icon name of the icon to display in the header. The pixmap is by default right, but * @param alignment can be used to display it also left. * @see pixmap() */ void setPixmap(const QString &icon, ImageAlignment alignment = ImageRight); /** * @param pixmap the icon to display in the header. The pixmap is by default right, but * @param alignment can be used to display it also left. * @see pixmap() */ void setPixmap(const QIcon &icon, ImageAlignment alignment = ImageRight); /** * @param pixmap the icon to display in the header. The pixmap is by default right, but * @param alignment can be used to display it also left. * @see pixmap() */ void setPixmap(MessageType type, ImageAlignment alignment = ImageRight); /** * Set the autohide timeout of the label * Set value to 0 to disable autohide, which is the default. * @param msecs timeout value in milliseconds */ void setAutoHideTimeout(int msecs); protected: void changeEvent(QEvent *e) Q_DECL_OVERRIDE; void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; private: class Private; Private *const d; Q_PRIVATE_SLOT(d, void _k_timeoutFinished()) Q_DISABLE_COPY(KTitleWidget) }; #endif