diff options
author | Michael Hasselmann <michaelh@openismus.com> | 2010-07-13 19:49:32 +0300 |
---|---|---|
committer | Pekka Vuorela <pekka.ta.vuorela@nokia.com> | 2010-09-06 15:25:53 +0300 |
commit | 8545f651e6021cc4e1127e202819f132548482d3 (patch) | |
tree | f9dcaa4ebc1e081583f912d99ffe9a54e1ee620f /demos | |
parent | df4d722dd453fde06bcaf29cefc1cf421e8c3fc6 (diff) |
New: Add demo page for arrow key navigation
RevBy: Pekka Vuorela
Diffstat (limited to 'demos')
-rw-r--r-- | demos/widgetsgallery/mainpage.cpp | 3 | ||||
-rw-r--r-- | demos/widgetsgallery/textentrynavigationpage.cpp | 84 | ||||
-rw-r--r-- | demos/widgetsgallery/textentrynavigationpage.h | 20 | ||||
-rw-r--r-- | demos/widgetsgallery/widgetsgallery.pro | 6 |
4 files changed, 111 insertions, 2 deletions
diff --git a/demos/widgetsgallery/mainpage.cpp b/demos/widgetsgallery/mainpage.cpp index d7be7d9d..599d32c1 100644 --- a/demos/widgetsgallery/mainpage.cpp +++ b/demos/widgetsgallery/mainpage.cpp @@ -29,6 +29,7 @@ #include "applicationmenupage.h" #include "toolbarpage.h" #include "textentrypage.h" +#include "textentrynavigationpage.h" #include "mlistpage.h" #include "mgridpage.h" #include "sliderpage.h" @@ -152,6 +153,8 @@ public: addCategory(qtTrId("xx_wg_categories_user_input"), new MainCategoryPage(this, createIndex(5,0))); //% "Text Entries" addGalleryPage(index(5,0), qtTrId("xx_wg_user_input_text_entries"), new TextEntryPage()); + //% "Text Entries Navigation" + addGalleryPage(index(5,0), qtTrId("xx_wg_user_input_text_entries_navigation"), new TextEntryNavigationPage()); //% "Slider" addGalleryPage(index(5,0), qtTrId("xx_wg_user_input_slider"), new SliderPage()); //% "Input Feedback" diff --git a/demos/widgetsgallery/textentrynavigationpage.cpp b/demos/widgetsgallery/textentrynavigationpage.cpp new file mode 100644 index 00000000..6362f584 --- /dev/null +++ b/demos/widgetsgallery/textentrynavigationpage.cpp @@ -0,0 +1,84 @@ +#include "textentrynavigationpage.h" + +#include <QList> +#include <QPointer> +#include <MLabel> +#include <MLayout> +#include <MGridLayoutPolicy> + +namespace { + MTextEdit *createTextEdit(QObject *owner, + const QString &objName, + M::TextContentType contentType, + bool multi = false, + bool rich = false) + { + MTextEditModel::LineMode lm = (multi ? MTextEditModel::MultiLine + : MTextEditModel::SingleLine); + + MTextEdit *e = 0; + + e = (rich ? new MRichTextEdit(lm) + : new MTextEdit(lm)); + + e->setParent(owner); + e->setContentType(contentType); + + e->setObjectName(objName); + + return e; + } +} + +TextEntryNavigationPage::TextEntryNavigationPage() + : TemplatePage(TemplatePage::UserInput) +{} + +TextEntryNavigationPage::~TextEntryNavigationPage() +{} + +QString TextEntryNavigationPage::timedemoTitle() +{ + return "TextEntryNavigation"; +} + +void TextEntryNavigationPage::createContent() +{ + MApplicationPage::createContent(); + QGraphicsWidget *panel = centralWidget(); + MLayout *layout = new MLayout(panel); + panel->setLayout(layout); + + MGridLayoutPolicy *layoutPolicy = new MGridLayoutPolicy(layout); + layoutPolicy->setContentsMargins(20, 0, 20, 0); + + QList<MTextEdit *> edits; + // 1st row: + edits << createTextEdit(panel, "Numbers", M::NumberContentType) + << 0 + << createTextEdit(panel, "Multi-line rich text", M::FreeTextContentType, true, true) + << 0 + // 2nd row: + << createTextEdit(panel, "Default", M::FreeTextContentType) + << createTextEdit(panel, "Multi-line text", M::FreeTextContentType, true) + << 0 + << createTextEdit(panel, "Default", M::FreeTextContentType) + // 3rd row: + << createTextEdit(panel, "Default", M::FreeTextContentType) + << createTextEdit(panel, "Phone numbers", M::PhoneNumberContentType) + << 0 + << createTextEdit(panel, "Multi-line rich text", M::FreeTextContentType, true, true); + + int i = 0; + int j = 0; + foreach (MTextEdit *edit, edits) { + if (edit) { + layoutPolicy->addItem(new MLabel(edit->objectName(), edit), i, j % 4); + layoutPolicy->addItem(edit, i + 1, j % 4); + } + + if (++j % 4 == 0) { + i += 2; + } + } +} diff --git a/demos/widgetsgallery/textentrynavigationpage.h b/demos/widgetsgallery/textentrynavigationpage.h new file mode 100644 index 00000000..831d7c5b --- /dev/null +++ b/demos/widgetsgallery/textentrynavigationpage.h @@ -0,0 +1,20 @@ +#ifndef TEXTENTRYNAVIGATIONPAGE_H +#define TEXTENTRYNAVIGATIONPAGE_H + +#include "templatepage.h" +#include <MTextEdit> +#include <MRichTextEdit> + +class TextEntryNavigationPage : public TemplatePage +{ + Q_OBJECT + +public: + TextEntryNavigationPage(); + virtual ~TextEntryNavigationPage(); + virtual QString timedemoTitle(); + + virtual void createContent(); +}; + +#endif // TEXTENTRYNAVIGATIONPAGE_H diff --git a/demos/widgetsgallery/widgetsgallery.pro b/demos/widgetsgallery/widgetsgallery.pro index ba98ec09..ee462249 100644 --- a/demos/widgetsgallery/widgetsgallery.pro +++ b/demos/widgetsgallery/widgetsgallery.pro @@ -9,8 +9,8 @@ INCLUDEPATH += . \ $$MSRC/corelib QMAKE_LIBDIR += $$MLIB -win32|macx { - macx { +win32|macx { + macx { QMAKE_LFLAGS += -F../../lib LIBS += -framework meegotouchcore \ -framework meegotouchviews @@ -49,6 +49,7 @@ SOURCES += main.cpp \ applicationmenupage.cpp \ toolbarpage.cpp \ textentrypage.cpp \ + textentrynavigationpage.cpp \ mlistpage.cpp \ mgridpage.cpp \ gridmodel.cpp \ @@ -96,6 +97,7 @@ HEADERS += templatepage.h \ applicationmenupage.h \ toolbarpage.h \ textentrypage.h \ + textentrynavigationpage.h \ mlistpage.h \ mgridpage.h \ gridmodel.h \ |