diff options
author | Mailson Menezes <mailson.menezes@openbossa.org> | 2012-03-07 18:31:57 -0300 |
---|---|---|
committer | Anselmo L. S. Melo <anselmo.melo@openbossa.org> | 2012-03-15 02:08:35 +0100 |
commit | f4b432196c8f06cde25fca1aab6fd14a868ff2dc (patch) | |
tree | e5c77504f20899afb9642e3b54e72e88b20de82a | |
parent | 4b6997cd55a070f405580a8d22b3a249e8637587 (diff) |
Rename QAction to UiAction and move it to utils
Change-Id: I69f04c3316e47bd58dc494d2e4c77bcd15b5117c
Reviewed-by: Anselmo L. S. Melo <anselmo.melo@openbossa.org>
-rw-r--r-- | src/action/action.pri | 15 | ||||
-rw-r--r-- | src/src.pro | 1 | ||||
-rw-r--r-- | src/utils/uiaction.cpp (renamed from src/action/qaction.cpp) | 198 | ||||
-rw-r--r-- | src/utils/uiaction.h (renamed from src/action/qaction.h) | 45 | ||||
-rw-r--r-- | src/utils/uiaction_p.h (renamed from src/action/qaction_p.h) | 20 | ||||
-rw-r--r-- | src/utils/uiactiongroup.cpp (renamed from src/action/qactiongroup.cpp) | 72 | ||||
-rw-r--r-- | src/utils/uiactiongroup.h (renamed from src/action/qactiongroup.h) | 28 | ||||
-rw-r--r-- | sync.profile | 2 | ||||
-rw-r--r-- | tests/auto/action/action.pro | 3 | ||||
-rw-r--r-- | tests/auto/action/qaction/.gitignore | 1 | ||||
-rw-r--r-- | tests/auto/auto.pro | 3 | ||||
-rw-r--r-- | tests/auto/utils/uiaction/.gitignore | 1 | ||||
-rw-r--r-- | tests/auto/utils/uiaction/tst_uiaction.cpp (renamed from tests/auto/action/qaction/tst_qaction.cpp) | 68 | ||||
-rw-r--r-- | tests/auto/utils/uiaction/uiaction.pro (renamed from tests/auto/action/qaction/qaction.pro) | 4 | ||||
-rw-r--r-- | tests/auto/utils/utils.pro | 3 |
15 files changed, 237 insertions, 227 deletions
diff --git a/src/action/action.pri b/src/action/action.pri deleted file mode 100644 index 2177271..0000000 --- a/src/action/action.pri +++ /dev/null @@ -1,15 +0,0 @@ -DEFINES += QT_NO_SHORTCUT - -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/qaction.h \ - $$PWD/qactiongroup.h - -HEADERS += \ - $$PWD/qaction_p.h - -SOURCES += \ - $$PWD/qaction.cpp \ - $$PWD/qactiongroup.cpp - diff --git a/src/src.pro b/src/src.pro index 8897458..96157e4 100644 --- a/src/src.pro +++ b/src/src.pro @@ -20,4 +20,3 @@ HEADERS += \ include(utils/utils.pri) include(models/models.pri) -include(action/action.pri) diff --git a/src/action/qaction.cpp b/src/utils/uiaction.cpp index d40ffb7..09f43fe 100644 --- a/src/action/qaction.cpp +++ b/src/utils/uiaction.cpp @@ -39,17 +39,17 @@ ** ****************************************************************************/ -#include "qaction.h" -#include "qactiongroup.h" +#include "uiaction.h" +#include "uiactiongroup.h" #ifndef QT_NO_ACTION -#include "qaction_p.h" -#include "qapplication.h" -#include "qevent.h" +#include "uiaction_p.h" +#include "qguiapplication.h" +//#include "qevent.h" #include "qlist.h" #include "qdebug.h" // #include <private/qshortcutmap_p.h> -#include <private/qapplication_p.h> +#include <private/qguiapplication_p.h> // #include <private/qmenu_p.h> #define QAPP_CHECK(functionName) \ @@ -60,6 +60,16 @@ QT_BEGIN_NAMESPACE_UIHELPERS +UiActionEvent::UiActionEvent(int type, UiAction *action, UiAction *before) + : QEvent(static_cast<QEvent::Type>(type)), act(action), bef(before) +{} + +/*! \internal +*/ +UiActionEvent::~UiActionEvent() +{ +} + /* internal: guesses a descriptive text from a text suited for a menu entry */ @@ -79,13 +89,13 @@ static QString qt_strippedText(QString s) } -QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), +UiActionPrivate::UiActionPrivate() : group(0), enabled(1), forceDisabled(0), // visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), checkable(0), checked(0), forceEnabledInSoftkeys(false), menuActionSoftkeys(false), // iconVisibleInMenu(-1), - menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::NoSoftKey), - priority(QAction::NormalPriority) + menuRole(UiAction::TextHeuristicRole), softKeyRole(UiAction::NoSoftKey), + priority(UiAction::NormalPriority) { #ifndef QT_NO_SHORTCUT shortcutId = 0; @@ -94,7 +104,7 @@ QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), #endif } -QActionPrivate::~QActionPrivate() +UiActionPrivate::~UiActionPrivate() { } @@ -113,10 +123,10 @@ QActionPrivate::~QActionPrivate() // return false; // } -void QActionPrivate::sendDataChanged() +void UiActionPrivate::sendDataChanged() { - Q_Q(QAction); - QActionEvent e(QEvent::ActionChanged, q); + Q_Q(UiAction); + UiActionEvent e(QEvent::ActionChanged, q); // for (int i = 0; i < widgets.size(); ++i) { // QWidget *w = widgets.at(i); // QApplication::sendEvent(w, &e); @@ -127,15 +137,15 @@ void QActionPrivate::sendDataChanged() // QApplication::sendEvent(w, &e); // } // #endif - QApplication::sendEvent(q, &e); + QGuiApplication::sendEvent(q, &e); emit q->changed(); } #ifndef QT_NO_SHORTCUT -void QActionPrivate::redoGrab(QShortcutMap &map) +void UiActionPrivate::redoGrab(QShortcutMap &map) { - Q_Q(QAction); + Q_Q(UiAction); if (shortcutId) map.removeShortcut(shortcutId, q); if (shortcut.isEmpty()) @@ -147,9 +157,9 @@ void QActionPrivate::redoGrab(QShortcutMap &map) map.setShortcutAutoRepeat(false, shortcutId, q); } -void QActionPrivate::redoGrabAlternate(QShortcutMap &map) +void UiActionPrivate::redoGrabAlternate(QShortcutMap &map) { - Q_Q(QAction); + Q_Q(UiAction); for (int i = 0; i < alternateShortcutIds.count(); ++i) { if (const int id = alternateShortcutIds.at(i)) map.removeShortcut(id, q); @@ -178,9 +188,9 @@ void QActionPrivate::redoGrabAlternate(QShortcutMap &map) } } -void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) +void UiActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) { - Q_Q(QAction); + Q_Q(UiAction); if (shortcutId) map.setShortcutEnabled(enable, shortcutId, q); for (int i = 0; i < alternateShortcutIds.count(); ++i) { @@ -306,11 +316,11 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) Constructs an action with \a parent. If \a parent is an action group the action will be automatically inserted into the group. */ -QAction::QAction(QObject* parent) - : QObject(*(new QActionPrivate), parent) +UiAction::UiAction(QObject* parent) + : QObject(*(new UiActionPrivate), parent) { - Q_D(QAction); - d->group = qobject_cast<QActionGroup *>(parent); + Q_D(UiAction); + d->group = qobject_cast<UiActionGroup *>(parent); if (d->group) d->group->addAction(this); } @@ -329,12 +339,12 @@ QAction::QAction(QObject* parent) setToolTip(). */ -QAction::QAction(const QString &text, QObject* parent) - : QObject(*(new QActionPrivate), parent) +UiAction::UiAction(const QString &text, QObject* parent) + : QObject(*(new UiActionPrivate), parent) { - Q_D(QAction); + Q_D(UiAction); d->text = text; - d->group = qobject_cast<QActionGroup *>(parent); + d->group = qobject_cast<UiActionGroup *>(parent); if (d->group) d->group->addAction(this); } @@ -365,11 +375,11 @@ QAction::QAction(const QString &text, QObject* parent) /*! \internal */ -QAction::QAction(QActionPrivate &dd, QObject *parent) +UiAction::UiAction(UiActionPrivate &dd, QObject *parent) : QObject(dd, parent) { - Q_D(QAction); - d->group = qobject_cast<QActionGroup *>(parent); + Q_D(UiAction); + d->group = qobject_cast<UiActionGroup *>(parent); if (d->group) d->group->addAction(this); } @@ -419,11 +429,11 @@ QAction::QAction(QActionPrivate &dd, QObject *parent) Valid keycodes for this property can be found in \l Qt::Key and \l Qt::Modifier. There is no default shortcut key. */ -void QAction::setShortcut(const QKeySequence &shortcut) +void UiAction::setShortcut(const QKeySequence &shortcut) { QAPP_CHECK("setShortcut"); - Q_D(QAction); + Q_D(UiAction); if (d->shortcut == shortcut) return; @@ -440,9 +450,9 @@ void QAction::setShortcut(const QKeySequence &shortcut) \sa shortcut */ -void QAction::setShortcuts(const QList<QKeySequence> &shortcuts) +void UiAction::setShortcuts(const QList<QKeySequence> &shortcuts) { - Q_D(QAction); + Q_D(UiAction); QList <QKeySequence> listCopy = shortcuts; @@ -472,7 +482,7 @@ void QAction::setShortcuts(const QList<QKeySequence> &shortcuts) \sa QKeySequence::keyBindings() */ -void QAction::setShortcuts(QKeySequence::StandardKey key) +void UiAction::setShortcuts(QKeySequence::StandardKey key) { QList <QKeySequence> list = QKeySequence::keyBindings(key); setShortcuts(list); @@ -483,9 +493,9 @@ void QAction::setShortcuts(QKeySequence::StandardKey key) \sa setShortcuts() */ -QKeySequence QAction::shortcut() const +QKeySequence UiAction::shortcut() const { - Q_D(const QAction); + Q_D(const UiAction); return d->shortcut; } @@ -497,9 +507,9 @@ QKeySequence QAction::shortcut() const \sa setShortcuts() */ -QList<QKeySequence> QAction::shortcuts() const +QList<QKeySequence> UiAction::shortcuts() const { - Q_D(const QAction); + Q_D(const UiAction); QList <QKeySequence> shortcuts; if (!d->shortcut.isEmpty()) shortcuts << d->shortcut; @@ -515,9 +525,9 @@ QList<QKeySequence> QAction::shortcuts() const Valid values for this property can be found in \l Qt::ShortcutContext. The default value is Qt::WindowShortcut. */ -void QAction::setShortcutContext(Qt::ShortcutContext context) +void UiAction::setShortcutContext(Qt::ShortcutContext context) { - Q_D(QAction); + Q_D(UiAction); if (d->shortcutContext == context) return; QAPP_CHECK("setShortcutContext"); @@ -527,9 +537,9 @@ void QAction::setShortcutContext(Qt::ShortcutContext context) d->sendDataChanged(); } -Qt::ShortcutContext QAction::shortcutContext() const +Qt::ShortcutContext UiAction::shortcutContext() const { - Q_D(const QAction); + Q_D(const UiAction); return d->shortcutContext; } @@ -543,9 +553,9 @@ Qt::ShortcutContext QAction::shortcutContext() const enabled on the system. The default value is true. */ -void QAction::setAutoRepeat(bool on) +void UiAction::setAutoRepeat(bool on) { - Q_D(QAction); + Q_D(UiAction); if (d->autorepeat == on) return; QAPP_CHECK("setAutoRepeat"); @@ -555,9 +565,9 @@ void QAction::setAutoRepeat(bool on) d->sendDataChanged(); } -bool QAction::autoRepeat() const +bool UiAction::autoRepeat() const { - Q_D(const QAction); + Q_D(const UiAction); return d->autorepeat; } #endif // QT_NO_SHORTCUT @@ -595,9 +605,9 @@ bool QAction::autoRepeat() const /*! Destroys the object and frees allocated resources. */ -QAction::~QAction() +UiAction::~UiAction() { - Q_D(QAction); + Q_D(UiAction); // for (int i = d->widgets.size()-1; i >= 0; --i) { // QWidget *w = d->widgets.at(i); // w->removeAction(this); @@ -629,9 +639,9 @@ QAction::~QAction() \sa QActionGroup, QAction::actionGroup() */ -void QAction::setActionGroup(QActionGroup *group) +void UiAction::setActionGroup(UiActionGroup *group) { - Q_D(QAction); + Q_D(UiAction); if (group == d->group) return; @@ -648,9 +658,9 @@ void QAction::setActionGroup(QActionGroup *group) \sa QActionGroup, QAction::setActionGroup() */ -QActionGroup *QAction::actionGroup() const +UiActionGroup *UiAction::actionGroup() const { - Q_D(const QAction); + Q_D(const UiAction); return d->group; } @@ -751,9 +761,9 @@ QActionGroup *QAction::actionGroup() const \sa iconText */ -void QAction::setText(const QString &text) +void UiAction::setText(const QString &text) { - Q_D(QAction); + Q_D(UiAction); if (d->text == text) return; @@ -761,9 +771,9 @@ void QAction::setText(const QString &text) d->sendDataChanged(); } -QString QAction::text() const +QString UiAction::text() const { - Q_D(const QAction); + Q_D(const UiAction); QString s = d->text; // if (s.isEmpty()) { // s = d->iconText; @@ -929,9 +939,9 @@ QString QAction::text() const mode set, then actions with LowPriority will not show the text labels. */ -void QAction::setPriority(Priority priority) +void UiAction::setPriority(Priority priority) { - Q_D(QAction); + Q_D(UiAction); if (d->priority == priority) return; @@ -939,9 +949,9 @@ void QAction::setPriority(Priority priority) d->sendDataChanged(); } -QAction::Priority QAction::priority() const +UiAction::Priority UiAction::priority() const { - Q_D(const QAction); + Q_D(const UiAction); return d->priority; } @@ -964,9 +974,9 @@ QAction::Priority QAction::priority() const \sa QAction::setChecked() */ -void QAction::setCheckable(bool b) +void UiAction::setCheckable(bool b) { - Q_D(QAction); + Q_D(UiAction); if (d->checkable == b) return; @@ -975,9 +985,9 @@ void QAction::setCheckable(bool b) d->sendDataChanged(); } -bool QAction::isCheckable() const +bool UiAction::isCheckable() const { - Q_D(const QAction); + Q_D(const UiAction); return d->checkable; } @@ -987,9 +997,9 @@ bool QAction::isCheckable() const This is a convenience function for the \l checked property. Connect to it to change the checked state to its opposite state. */ -void QAction::toggle() +void UiAction::toggle() { - Q_D(QAction); + Q_D(UiAction); setChecked(!d->checked); } @@ -1002,22 +1012,22 @@ void QAction::toggle() \sa checkable */ -void QAction::setChecked(bool b) +void UiAction::setChecked(bool b) { - Q_D(QAction); + Q_D(UiAction); if (!d->checkable || d->checked == b) return; - QPointer<QAction> guard(this); + QPointer<UiAction> guard(this); d->checked = b; d->sendDataChanged(); if (guard) emit toggled(b); } -bool QAction::isChecked() const +bool UiAction::isChecked() const { - Q_D(const QAction); + Q_D(const UiAction); return d->checked; } @@ -1050,9 +1060,9 @@ bool QAction::isChecked() const \sa text */ -void QAction::setEnabled(bool b) +void UiAction::setEnabled(bool b) { - Q_D(QAction); + Q_D(UiAction); if (b == d->enabled && b != d->forceDisabled) return; d->forceDisabled = !b; @@ -1067,9 +1077,9 @@ void QAction::setEnabled(bool b) d->sendDataChanged(); } -bool QAction::isEnabled() const +bool UiAction::isEnabled() const { - Q_D(const QAction); + Q_D(const UiAction); return d->enabled; } @@ -1112,13 +1122,13 @@ bool QAction::isEnabled() const \reimp */ bool -QAction::event(QEvent *e) +UiAction::event(QEvent *e) { #ifndef QT_NO_SHORTCUT if (e->type() == QEvent::Shortcut) { QShortcutEvent *se = static_cast<QShortcutEvent *>(e); Q_ASSERT_X(se->key() == d_func()->shortcut || d_func()->alternateShortcuts.contains(se->key()), - "QAction::event", + "UiAction::event", "Received shortcut event from incorrect shortcut"); if (se->isAmbiguous()) qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData()); @@ -1136,9 +1146,9 @@ QAction::event(QEvent *e) \sa setData() */ QVariant -QAction::data() const +UiAction::data() const { - Q_D(const QAction); + Q_D(const UiAction); return d->userData; } @@ -1150,9 +1160,9 @@ QAction::data() const \sa data() */ void -QAction::setData(const QVariant &data) +UiAction::setData(const QVariant &data) { - Q_D(QAction); + Q_D(UiAction); d->userData = data; d->sendDataChanged(); } @@ -1179,9 +1189,9 @@ QAction::setData(const QVariant &data) Action based widgets use this API to cause the QAction to emit signals as well as emitting their own. */ -void QAction::activate(ActionEvent event) +void UiAction::activate(ActionEvent event) { - Q_D(QAction); + Q_D(UiAction); if (event == Trigger) { QWeakPointer<QObject> guard = this; if (d->checkable) { @@ -1273,9 +1283,9 @@ void QAction::activate(ActionEvent event) bar in Mac OS X (usually just before the first application window is shown). */ -void QAction::setMenuRole(MenuRole menuRole) +void UiAction::setMenuRole(MenuRole menuRole) { - Q_D(QAction); + Q_D(UiAction); if (d->menuRole == menuRole) return; @@ -1283,9 +1293,9 @@ void QAction::setMenuRole(MenuRole menuRole) d->sendDataChanged(); } -QAction::MenuRole QAction::menuRole() const +UiAction::MenuRole UiAction::menuRole() const { - Q_D(const QAction); + Q_D(const UiAction); return d->menuRole; } @@ -1300,9 +1310,9 @@ QAction::MenuRole QAction::menuRole() const The softkey role can be changed any time. */ -void QAction::setSoftKeyRole(SoftKeyRole softKeyRole) +void UiAction::setSoftKeyRole(SoftKeyRole softKeyRole) { - Q_D(QAction); + Q_D(UiAction); if (d->softKeyRole == softKeyRole) return; @@ -1310,9 +1320,9 @@ void QAction::setSoftKeyRole(SoftKeyRole softKeyRole) d->sendDataChanged(); } -QAction::SoftKeyRole QAction::softKeyRole() const +UiAction::SoftKeyRole UiAction::softKeyRole() const { - Q_D(const QAction); + Q_D(const UiAction); return d->softKeyRole; } @@ -1360,6 +1370,6 @@ QAction::SoftKeyRole QAction::softKeyRole() const QT_END_NAMESPACE_UIHELPERS -#include "moc_qaction.cpp" +#include "moc_uiaction.cpp" #endif // QT_NO_ACTION diff --git a/src/action/qaction.h b/src/utils/uiaction.h index a1d146f..4de65b0 100644 --- a/src/action/qaction.h +++ b/src/utils/uiaction.h @@ -48,6 +48,7 @@ // #include <QtWidgets/qwidget.h> #include <QtCore/qvariant.h> // #include <QtWidgets/qicon.h> +#include <QtCore/QEvent> QT_BEGIN_HEADER @@ -57,14 +58,26 @@ QT_BEGIN_NAMESPACE_UIHELPERS #ifndef QT_NO_ACTION // class QMenu; -class QActionGroup; -class QActionPrivate; +class UiAction; +class UiActionGroup; +class UiActionPrivate; // class QGraphicsWidget; -class UIHELPERS_EXPORT QAction : public QObject +class UIHELPERS_EXPORT UiActionEvent : public QEvent +{ + UiAction *act, *bef; +public: + UiActionEvent(int type, UiAction *action, UiAction *before = 0); + ~UiActionEvent(); + + inline UiAction *action() const { return act; } + inline UiAction *before() const { return bef; } +}; + +class UIHELPERS_EXPORT UiAction : public QObject { Q_OBJECT - Q_DECLARE_PRIVATE(QAction) + Q_DECLARE_PRIVATE(UiAction) Q_ENUMS(MenuRole) Q_ENUMS(SoftKeyRole) @@ -98,14 +111,14 @@ public: enum Priority { LowPriority = 0, NormalPriority = 128, HighPriority = 256}; - explicit QAction(QObject* parent); - QAction(const QString &text, QObject* parent); + explicit UiAction(QObject* parent); + UiAction(const QString &text, QObject* parent); // QAction(const QIcon &icon, const QString &text, QObject* parent); - ~QAction(); + ~UiAction(); - void setActionGroup(QActionGroup *group); - QActionGroup *actionGroup() const; + void setActionGroup(UiActionGroup *group); + UiActionGroup *actionGroup() const; // void setIcon(const QIcon &icon); // QIcon icon() const; @@ -188,7 +201,7 @@ public: protected: bool event(QEvent *); - QAction(QActionPrivate &dd, QObject *parent); + UiAction(UiActionPrivate &dd, QObject *parent); public Q_SLOTS: void trigger() { activate(Trigger); } @@ -206,23 +219,23 @@ Q_SIGNALS: void toggled(bool); private: - Q_DISABLE_COPY(QAction) + Q_DISABLE_COPY(UiAction) // friend class QGraphicsWidget; // friend class QWidget; - friend class QActionGroup; + friend class UiActionGroup; // friend class QMenu; // friend class QMenuPrivate; // friend class QMenuBar; // friend class QToolButton; #ifdef Q_OS_MAC - friend void qt_mac_clear_status_text(QAction *action); + friend void qt_mac_clear_status_text(UiAction *action); #endif }; -QT_BEGIN_INCLUDE_NAMESPACE_UIHELPERS -#include <UiHelpers/qactiongroup.h> -QT_END_INCLUDE_NAMESPACE_UIHELPERS +//QT_BEGIN_INCLUDE_NAMESPACE_UIHELPERS +//#include <UiHelpers/uiactiongroup.h> +//QT_END_INCLUDE_NAMESPACE_UIHELPERS #endif // QT_NO_ACTION diff --git a/src/action/qaction_p.h b/src/utils/uiaction_p.h index e02c4a8..0e44213 100644 --- a/src/action/qaction_p.h +++ b/src/utils/uiaction_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include "UiHelpers/qaction.h" +#include "UiHelpers/uiaction.h" // #include "QtWidgets/qaction.h" // #include "QtWidgets/qmenu.h" // #include "private/qgraphicswidget_p.h" @@ -67,21 +67,21 @@ QT_BEGIN_NAMESPACE_UIHELPERS class QShortcutMap; -class UIHELPERS_EXPORT QActionPrivate : public QObjectPrivate +class UIHELPERS_EXPORT UiActionPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QAction) + Q_DECLARE_PUBLIC(UiAction) public: - QActionPrivate(); - ~QActionPrivate(); + UiActionPrivate(); + ~UiActionPrivate(); - static QActionPrivate *get(QAction *q) + static UiActionPrivate *get(UiAction *q) { return q->d_func(); } // bool showStatusText(QWidget *w, const QString &str); - QPointer<QActionGroup> group; + QPointer<UiActionGroup> group; QString text; // QString iconText; // QIcon icon; @@ -113,9 +113,9 @@ public: uint menuActionSoftkeys : 1; // int iconVisibleInMenu : 3; // Only has values -1, 0, and 1 - QAction::MenuRole menuRole; - QAction::SoftKeyRole softKeyRole; - QAction::Priority priority; + UiAction::MenuRole menuRole; + UiAction::SoftKeyRole softKeyRole; + UiAction::Priority priority; // QList<QWidget *> widgets; // #ifndef QT_NO_GRAPHICSVIEW diff --git a/src/action/qactiongroup.cpp b/src/utils/uiactiongroup.cpp index e211bd8..6521ab8 100644 --- a/src/action/qactiongroup.cpp +++ b/src/utils/uiactiongroup.cpp @@ -39,25 +39,25 @@ ** ****************************************************************************/ -#include "qactiongroup.h" +#include "uiactiongroup.h" #ifndef QT_NO_ACTION -#include "qaction_p.h" +#include "uiaction_p.h" // #include "qapplication.h" // #include "qevent.h" #include "qlist.h" QT_BEGIN_NAMESPACE_UIHELPERS -class QActionGroupPrivate : public QObjectPrivate +class UiActionGroupPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QActionGroup) + Q_DECLARE_PUBLIC(UiActionGroup) public: // QActionGroupPrivate() : exclusive(1), enabled(1), visible(1) { } - QActionGroupPrivate() : exclusive(1), enabled(1) { } - QList<QAction *> actions; - QPointer<QAction> current; + UiActionGroupPrivate() : exclusive(1), enabled(1) { } + QList<UiAction *> actions; + QPointer<UiAction> current; uint exclusive : 1; uint enabled : 1; // uint visible : 1; @@ -68,10 +68,10 @@ private: // void _q_actionHovered(); //private slot }; -void QActionGroupPrivate::_q_actionChanged() +void UiActionGroupPrivate::_q_actionChanged() { - Q_Q(QActionGroup); - QAction *action = qobject_cast<QAction*>(q->sender()); + Q_Q(UiActionGroup); + UiAction *action = qobject_cast<UiAction*>(q->sender()); Q_ASSERT_X(action != 0, "QWidgetGroup::_q_actionChanged", "internal error"); if (exclusive) { if (action->isChecked()) { @@ -86,10 +86,10 @@ void QActionGroupPrivate::_q_actionChanged() } } -void QActionGroupPrivate::_q_actionTriggered() +void UiActionGroupPrivate::_q_actionTriggered() { - Q_Q(QActionGroup); - QAction *action = qobject_cast<QAction*>(q->sender()); + Q_Q(UiActionGroup); + UiAction *action = qobject_cast<UiAction*>(q->sender()); Q_ASSERT_X(action != 0, "QWidgetGroup::_q_actionTriggered", "internal error"); emit q->triggered(action); } @@ -154,14 +154,14 @@ void QActionGroupPrivate::_q_actionTriggered() The action group is exclusive by default. Call setExclusive(false) to make the action group non-exclusive. */ -QActionGroup::QActionGroup(QObject* parent) : QObject(*new QActionGroupPrivate, parent) +UiActionGroup::UiActionGroup(QObject* parent) : QObject(*new UiActionGroupPrivate, parent) { } /*! Destroys the action group. */ -QActionGroup::~QActionGroup() +UiActionGroup::~UiActionGroup() { } @@ -175,9 +175,9 @@ QActionGroup::~QActionGroup() \sa QAction::setActionGroup() */ -QAction *QActionGroup::addAction(QAction* a) +UiAction *UiActionGroup::addAction(UiAction* a) { - Q_D(QActionGroup); + Q_D(UiActionGroup); if (!d->actions.contains(a)) { d->actions.append(a); QObject::connect(a, SIGNAL(triggered()), this, SLOT(_q_actionTriggered())); @@ -194,7 +194,7 @@ QAction *QActionGroup::addAction(QAction* a) // } if (a->isChecked()) d->current = a; - QActionGroup *oldGroup = a->d_func()->group; + UiActionGroup *oldGroup = a->d_func()->group; if (oldGroup != this) { if (oldGroup) oldGroup->removeAction(a); @@ -212,9 +212,9 @@ QAction *QActionGroup::addAction(QAction* a) \sa QAction::setActionGroup() */ -QAction *QActionGroup::addAction(const QString &text) +UiAction *UiActionGroup::addAction(const QString &text) { - return new QAction(text, this); + return new UiAction(text, this); } /*! @@ -237,9 +237,9 @@ QAction *QActionGroup::addAction(const QString &text) \sa QAction::setActionGroup() */ -void QActionGroup::removeAction(QAction *action) +void UiActionGroup::removeAction(UiAction *action) { - Q_D(QActionGroup); + Q_D(UiActionGroup); if (d->actions.removeAll(action)) { if (action == d->current) d->current = 0; @@ -253,9 +253,9 @@ void QActionGroup::removeAction(QAction *action) /*! Returns the list of this groups's actions. This may be empty. */ -QList<QAction*> QActionGroup::actions() const +QList<UiAction*> UiActionGroup::actions() const { - Q_D(const QActionGroup); + Q_D(const UiActionGroup); return d->actions; } @@ -270,15 +270,15 @@ QList<QAction*> QActionGroup::actions() const \sa QAction::checkable */ -void QActionGroup::setExclusive(bool b) +void UiActionGroup::setExclusive(bool b) { - Q_D(QActionGroup); + Q_D(UiActionGroup); d->exclusive = b; } -bool QActionGroup::isExclusive() const +bool UiActionGroup::isExclusive() const { - Q_D(const QActionGroup); + Q_D(const UiActionGroup); return d->exclusive; } @@ -299,11 +299,11 @@ bool QActionGroup::isExclusive() const \sa QAction::setEnabled() */ -void QActionGroup::setEnabled(bool b) +void UiActionGroup::setEnabled(bool b) { - Q_D(QActionGroup); + Q_D(UiActionGroup); d->enabled = b; - for (QList<QAction*>::const_iterator it = d->actions.constBegin(); it != d->actions.constEnd(); ++it) { + for (QList<UiAction*>::const_iterator it = d->actions.constBegin(); it != d->actions.constEnd(); ++it) { if (!(*it)->d_func()->forceDisabled) { (*it)->setEnabled(b); (*it)->d_func()->forceDisabled = false; @@ -311,9 +311,9 @@ void QActionGroup::setEnabled(bool b) } } -bool QActionGroup::isEnabled() const +bool UiActionGroup::isEnabled() const { - Q_D(const QActionGroup); + Q_D(const UiActionGroup); return d->enabled; } @@ -321,9 +321,9 @@ bool QActionGroup::isEnabled() const Returns the currently checked action in the group, or 0 if none are checked. */ -QAction *QActionGroup::checkedAction() const +UiAction *UiActionGroup::checkedAction() const { - Q_D(const QActionGroup); + Q_D(const UiActionGroup); return d->current; } @@ -412,6 +412,6 @@ QAction *QActionGroup::checkedAction() const QT_END_NAMESPACE_UIHELPERS -#include "moc_qactiongroup.cpp" +#include "moc_uiactiongroup.cpp" #endif // QT_NO_ACTION diff --git a/src/action/qactiongroup.h b/src/utils/uiactiongroup.h index c6fe924..b1f29ab 100644 --- a/src/action/qactiongroup.h +++ b/src/utils/uiactiongroup.h @@ -42,7 +42,9 @@ #ifndef QACTIONGROUP_H #define QACTIONGROUP_H -#include <UiHelpers/qaction.h> +#include "uihelpersglobal.h" +#include <UiHelpers/uiaction.h> +#include <QtCore/QObject> QT_BEGIN_HEADER @@ -51,28 +53,28 @@ QT_BEGIN_NAMESPACE_UIHELPERS #ifndef QT_NO_ACTION -class QActionGroupPrivate; +class UiActionGroupPrivate; -class UIHELPERS_EXPORT QActionGroup : public QObject +class UIHELPERS_EXPORT UiActionGroup : public QObject { Q_OBJECT - Q_DECLARE_PRIVATE(QActionGroup) + Q_DECLARE_PRIVATE(UiActionGroup) Q_PROPERTY(bool exclusive READ isExclusive WRITE setExclusive) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) // Q_PROPERTY(bool visible READ isVisible WRITE setVisible) public: - explicit QActionGroup(QObject* parent); - ~QActionGroup(); + explicit UiActionGroup(QObject* parent); + ~UiActionGroup(); - QAction *addAction(QAction* a); - QAction *addAction(const QString &text); + UiAction *addAction(UiAction* a); + UiAction *addAction(const QString &text); // QAction *addAction(const QIcon &icon, const QString &text); - void removeAction(QAction *a); - QList<QAction*> actions() const; + void removeAction(UiAction *a); + QList<UiAction*> actions() const; - QAction *checkedAction() const; + UiAction *checkedAction() const; bool isExclusive() const; bool isEnabled() const; // bool isVisible() const; @@ -85,11 +87,11 @@ public Q_SLOTS: void setExclusive(bool); Q_SIGNALS: - void triggered(QAction *); + void triggered(UiAction *); // void hovered(QAction *); private: - Q_DISABLE_COPY(QActionGroup) + Q_DISABLE_COPY(UiActionGroup) Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered()) Q_PRIVATE_SLOT(d_func(), void _q_actionChanged()) // Q_PRIVATE_SLOT(d_func(), void _q_actionHovered()) diff --git a/sync.profile b/sync.profile index bebd8f6..c5a4b13 100644 --- a/sync.profile +++ b/sync.profile @@ -9,6 +9,8 @@ "uiundogroup.h" => "UiUndoGroup", "uifilesystemmodel.h" => "UiFileSystemModel", "uistandarditemmodel.h" => "UiStandardModel", + "uiaction.h" => "UiAction", + "uiactiongroup.h" => "UiActionGroup", ); %mastercontent = ( ); diff --git a/tests/auto/action/action.pro b/tests/auto/action/action.pro deleted file mode 100644 index 40ad710..0000000 --- a/tests/auto/action/action.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE=subdirs -SUBDIRS=\ - qaction \ diff --git a/tests/auto/action/qaction/.gitignore b/tests/auto/action/qaction/.gitignore deleted file mode 100644 index bf81f5b..0000000 --- a/tests/auto/action/qaction/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qaction diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 2865d2a..6d6a9ad 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -2,5 +2,4 @@ TEMPLATE = subdirs SUBDIRS += \ utils \ - models \ - action + models diff --git a/tests/auto/utils/uiaction/.gitignore b/tests/auto/utils/uiaction/.gitignore new file mode 100644 index 0000000..ee29bcc --- /dev/null +++ b/tests/auto/utils/uiaction/.gitignore @@ -0,0 +1 @@ +tst_uiaction diff --git a/tests/auto/action/qaction/tst_qaction.cpp b/tests/auto/utils/uiaction/tst_uiaction.cpp index 51123af..2fa7adc 100644 --- a/tests/auto/action/qaction/tst_qaction.cpp +++ b/tests/auto/utils/uiaction/tst_uiaction.cpp @@ -41,6 +41,8 @@ #include <QtTest/QtTest> +#include <UiHelpers/UiAction> +#include <UiHelpers/UiActionGroup> #include <qapplication.h> #include <qevent.h> @@ -49,16 +51,16 @@ #include <qplatformtheme_qpa.h> #include <private/qguiapplication_p.h> -class tst_QAction : public QObject +class tst_UiAction : public QObject { Q_OBJECT public: - tst_QAction(); - virtual ~tst_QAction(); + tst_UiAction(); + virtual ~tst_UiAction(); - void updateState(QActionEvent *e); + // void updateState(QActionEvent *e); public slots: void initTestCase(); @@ -80,21 +82,21 @@ private slots: private: int m_lastEventType; int m_keyboardScheme; - QAction *m_lastAction; - QWidget *m_tstWidget; + UiAction *m_lastAction; + // QWidget *m_tstWidget; }; // Testing get/set functions -void tst_QAction::getSetCheck() +void tst_UiAction::getSetCheck() { - QAction obj1(0); + UiAction obj1(0); // QActionGroup * QAction::actionGroup() // void QAction::setActionGroup(QActionGroup *) - QActionGroup *var1 = new QActionGroup(0); + UiActionGroup *var1 = new UiActionGroup(0); obj1.setActionGroup(var1); QCOMPARE(var1, obj1.actionGroup()); - obj1.setActionGroup((QActionGroup *)0); - QCOMPARE((QActionGroup *)0, obj1.actionGroup()); + obj1.setActionGroup((UiActionGroup *)0); + QCOMPARE((UiActionGroup *)0, obj1.actionGroup()); delete var1; // QMenu * QAction::menu() @@ -106,36 +108,36 @@ void tst_QAction::getSetCheck() QCOMPARE((QMenu *)0, obj1.menu()); delete var2; - QCOMPARE(obj1.priority(), QAction::NormalPriority); - obj1.setPriority(QAction::LowPriority); - QCOMPARE(obj1.priority(), QAction::LowPriority); + QCOMPARE(obj1.priority(), UiAction::NormalPriority); + obj1.setPriority(UiAction::LowPriority); + QCOMPARE(obj1.priority(), UiAction::LowPriority); } -class MyWidget : public QWidget -{ - Q_OBJECT -public: - MyWidget(tst_QAction *tst, QWidget *parent = 0) : QWidget(parent) { this->tst = tst; } - -protected: - virtual void actionEvent(QActionEvent *e) { tst->updateState(e); } - -private: - tst_QAction *tst; -}; - -tst_QAction::tst_QAction() : m_keyboardScheme(QPlatformTheme::WindowsKeyboardScheme) +// class MyWidget : public QWidget +// { +// Q_OBJECT +// public: +// MyWidget(tst_QAction *tst, QWidget *parent = 0) : QWidget(parent) { this->tst = tst; } +// +// protected: +// virtual void actionEvent(QActionEvent *e) { tst->updateState(e); } +// +// private: +// tst_QAction *tst; +// }; + +tst_UiAction::tst_UiAction()// : m_keyboardScheme(QPlatformTheme::WindowsKeyboardScheme) { if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); } -tst_QAction::~tst_QAction() +tst_UiAction::~tst_UiAction() { } -void tst_QAction::initTestCase() +void tst_UiAction::initTestCase() { m_lastEventType = 0; m_lastAction = 0; @@ -146,7 +148,7 @@ void tst_QAction::initTestCase() qApp->setActiveWindow(mw); } -void tst_QAction::cleanupTestCase() +void tst_UiAction::cleanupTestCase() { QWidget *testWidget = m_tstWidget; if (testWidget) { @@ -378,5 +380,5 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup() QCOMPARE(actionSpy.count(), 1); } -QTEST_MAIN(tst_QAction) -#include "tst_qaction.moc" +QTEST_MAIN(tst_UiAction) +#include "tst_uiaction.moc" diff --git a/tests/auto/action/qaction/qaction.pro b/tests/auto/utils/uiaction/uiaction.pro index e8c9e2d..e543bda 100644 --- a/tests/auto/action/qaction/qaction.pro +++ b/tests/auto/utils/uiaction/uiaction.pro @@ -1,7 +1,7 @@ CONFIG += testcase -TARGET = tst_qaction +TARGET = tst_uiaction QT += testlib uihelpers QT += gui-private core-private widgets -SOURCES += tst_qaction.cpp +SOURCES += tst_uiaction.cpp diff --git a/tests/auto/utils/utils.pro b/tests/auto/utils/utils.pro index 14f244e..81a95e8 100644 --- a/tests/auto/utils/utils.pro +++ b/tests/auto/utils/utils.pro @@ -1,4 +1,5 @@ TEMPLATE=subdirs SUBDIRS=\ uiundogroup \ - uiundostack + uiundostack \ + uiaction |