[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [phoneblocker] frontends/blackberry/ui: Add the blocked item factory to the GUI
From: Laszlo Papp <lpapp () kde ! org>
Date: 2015-01-20 8:42:01
Message-ID: E1YDUNt-0008Q8-3j () scm ! kde ! org
[Download RAW message or body]
Git commit 8fb139c5d7ca904c83414738863e464f18138098 by Laszlo Papp.
Committed on 20/01/2015 at 08:36.
Pushed by lpapp into branch 'master'.
Add the blocked item factory to the GUI
M +1 -1 frontends/blackberry/ui/CMakeLists.txt
A +79 -0 frontends/blackberry/ui/blockeditem.cpp [License: UNKNOWN] *
A +37 -0 frontends/blackberry/ui/blockeditem.h [License: UNKNOWN] *
A +28 -0 frontends/blackberry/ui/blockeditemfactory.cpp [License: UNKNOWN] \
* A +25 -0 frontends/blackberry/ui/blockeditemfactory.h [License: UNKNOWN] \
* M +4 -6 frontends/blackberry/ui/mainwindow.cpp
M +1 -2 frontends/blackberry/ui/mainwindow.h
The files marked with a * at the end have a non valid license. Please read: \
http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are \
listed at that page.
http://commits.kde.org/phoneblocker/8fb139c5d7ca904c83414738863e464f18138098
diff --git a/frontends/blackberry/ui/CMakeLists.txt \
b/frontends/blackberry/ui/CMakeLists.txt index 4315420..3be7df7 100644
--- a/frontends/blackberry/ui/CMakeLists.txt
+++ b/frontends/blackberry/ui/CMakeLists.txt
@@ -3,6 +3,6 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(BBCascades REQUIRED)
include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} \
${CMAKE_CURRENT_SOURCE_DIR} ${BBCASCADES_INCLUDE_DIR} \
$ENV{QNX_TARGET}/usr/include)
-set(PhoneBlockerUi_SRCS main.cpp mainwindow.cpp socketwriter.cpp)
+set(PhoneBlockerUi_SRCS blockeditem.cpp blockeditemfactory.cpp main.cpp \
mainwindow.cpp socketwriter.cpp) add_executable(phoneblockerui \
${PhoneBlockerUi_SRCS} phoneblockerui.qrc) target_link_libraries(phoneblockerui \
${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${BBCASCADES_LIBRARY})
diff --git a/frontends/blackberry/ui/blockeditem.cpp \
b/frontends/blackberry/ui/blockeditem.cpp new file mode 100644
index 0000000..3b8d939
--- /dev/null
+++ b/frontends/blackberry/ui/blockeditem.cpp
@@ -0,0 +1,79 @@
+#include "blockeditem.h"
+
+#include <bb/cascades/Container>
+#include <bb/cascades/DockLayout>
+#include <bb/cascades/ImageView>
+#include <bb/cascades/ImagePaint>
+#include <bb/cascades/Label>
+#include <bb/cascades/StackLayout>
+#include <bb/cascades/SystemDefaults>
+#include <bb/cascades/TextStyle>
+#include <bb/cascades/UIConfig>
+
+using namespace bb::cascades;
+
+BlockedItem::BlockedItem(Container *parent) :
+ CustomListItem(HighlightAppearance::None, parent)
+{
+ Container *itemContainer = Container::create().layout(DockLayout::create())
+ \
.horizontal(HorizontalAlignment::Fill).vertical(VerticalAlignment::Fill); +
+ UIConfig *ui = itemContainer->ui();
+ itemContainer->setTopPadding(ui->du(0.2));
+ itemContainer->setBottomPadding(ui->du(0.6));
+ ImagePaint paint(QUrl("asset:///images/white_photo.amd"));
+ itemContainer->setBackground(paint);
+ m_highlighContainer = \
Container::create().background(Color::fromARGB(0xff75b5d3)) + \
.horizontal(HorizontalAlignment::Fill).vertical(VerticalAlignment::Fill) + \
.opacity(0.0); +
+ // Content Container containing an image and label with padding for the \
alignment + // on background image. Note that we disable implicit layout \
animations to avoid + // unsynchronized animations on the list items as the item \
image is asynchronously loaded. + Container *contentContainer = new Container();
+ contentContainer->setLeftPadding(ui->du(0.3));
+ contentContainer->setLayout(StackLayout::create().orientation(LayoutOrientation::LeftToRight));
+ contentContainer->setImplicitLayoutAnimationsEnabled(false);
+
+ m_phoneNumberLabel = Label::create();
+ m_phoneNumberLabel->setVerticalAlignment(VerticalAlignment::Center);
+ m_phoneNumberLabel->setLeftMargin(ui->du(3.0));
+ m_phoneNumberLabel->textStyle()->setBase(SystemDefaults::TextStyles::titleText());
+ m_phoneNumberLabel->textStyle()->setColor(Color::Black);
+ m_phoneNumberLabel->setImplicitLayoutAnimationsEnabled(false);
+
+ contentContainer->add(m_phoneNumberLabel);
+ contentContainer->add(m_callLabel);
+ contentContainer->add(m_smsLabel);
+
+ // Add the background image and the content to the full item container.
+ itemContainer->add(m_highlighContainer);
+ itemContainer->add(contentContainer);
+
+ setDividerVisible(false);
+ setPreferredHeight(ui->du(17.6));
+ setContent(itemContainer);
+}
+
+void BlockedItem::updateItem(const QString phoneNumber, bool call, bool sms)
+{
+ m_phoneNumberLabel->setText(phoneNumber);
+ if (call) m_callLabel->setText("Call");
+ if (sms) m_smsLabel->setText("Sms");
+}
+
+void BlockedItem::select(bool select)
+{
+ m_highlighContainer->setOpacity(select ? 0.9f : 0.0f);
+}
+
+void BlockedItem::reset(bool selected, bool activated)
+{
+ Q_UNUSED(activated);
+ select(selected);
+}
+
+void BlockedItem::activate(bool activate)
+{
+ select(activate);
+}
diff --git a/frontends/blackberry/ui/blockeditem.h \
b/frontends/blackberry/ui/blockeditem.h new file mode 100644
index 0000000..f85bcfa
--- /dev/null
+++ b/frontends/blackberry/ui/blockeditem.h
@@ -0,0 +1,37 @@
+#ifndef BLOCKEDITEM_H
+#define BLOCKEDITEM_H
+
+#include <bb/cascades/CustomListItem>
+#include <bb/cascades/ListItemListener>
+
+using namespace bb::cascades;
+
+namespace bb
+{
+ namespace cascades
+ {
+ class Container;
+ class Label;
+ }
+}
+
+class BlockedItem: public bb::cascades::CustomListItem, public ListItemListener
+{
+ Q_OBJECT
+
+public:
+ BlockedItem(Container *parent = 0);
+
+ void updateItem(const QString phoneNumber, bool call, bool sms);
+ void select(bool select);
+ void reset(bool selected, bool activated);
+ void activate(bool activate);
+
+private:
+ Label *m_phoneNumberLabel;
+ Label *m_callLabel;
+ Label *m_smsLabel;
+ Container *m_highlighContainer;
+};
+
+#endif
diff --git a/frontends/blackberry/ui/blockeditemfactory.cpp \
b/frontends/blackberry/ui/blockeditemfactory.cpp new file mode 100644
index 0000000..2ad11e6
--- /dev/null
+++ b/frontends/blackberry/ui/blockeditemfactory.cpp
@@ -0,0 +1,28 @@
+#include "blockeditemfactory.h"
+#include "blockeditem.h"
+
+using namespace bb::cascades;
+
+BlockedItemFactory::BlockedItemFactory()
+{
+}
+
+VisualNode *BlockedItemFactory::createItem(ListView* list, const QString &type)
+{
+ Q_UNUSED(type);
+ Q_UNUSED(list);
+ BlockedItem *blockedItem = new BlockedItem();
+ return blockedItem;
+}
+
+void BlockedItemFactory::updateItem(ListView* list, bb::cascades::VisualNode \
*listItem, + const QString &type, const QVariantList &indexPath, const \
QVariant &data) +{
+ Q_UNUSED(list);
+ Q_UNUSED(indexPath);
+ Q_UNUSED(type);
+
+ QVariantMap map = data.value<QVariantMap>();
+ BlockedItem *blockedItem = static_cast<BlockedItem *>(listItem);
+ blockedItem->updateItem(map["phoneNumber"].toString(), map["call"].toBool(), \
map["sms"].toBool()); +}
diff --git a/frontends/blackberry/ui/blockeditemfactory.h \
b/frontends/blackberry/ui/blockeditemfactory.h new file mode 100644
index 0000000..3e17d37
--- /dev/null
+++ b/frontends/blackberry/ui/blockeditemfactory.h
@@ -0,0 +1,25 @@
+#ifndef BLOCkEDITEMFACTORY_H
+#define BLOCKEDITEMFACTORY_H
+
+#include <bb/cascades/ListItemProvider>
+
+using namespace bb::cascades;
+
+namespace bb
+{
+ namespace cascades
+ {
+ class ListView;
+ }
+}
+
+class BlockedItemFactory: public bb::cascades::ListItemProvider
+{
+public:
+ BlockedItemFactory();
+ VisualNode *createItem(ListView* list, const QString &type);
+ void updateItem(ListView* list, VisualNode *listItem, const QString &type,
+ const QVariantList &indexPath, const QVariant &data);
+};
+
+#endif
diff --git a/frontends/blackberry/ui/mainwindow.cpp \
b/frontends/blackberry/ui/mainwindow.cpp index 23640c6..0e5777a 100644
--- a/frontends/blackberry/ui/mainwindow.cpp
+++ b/frontends/blackberry/ui/mainwindow.cpp
@@ -1,4 +1,5 @@
#include "mainwindow.h"
+#include "blockeditemfactory.h"
#include <bb/cascades/ActionItem>
#include <bb/cascades/Application>
@@ -168,16 +169,13 @@ void MainWindow::createBlockedListView()
}
m_blockedListView.setDataModel(&m_blockedListModel);
- // m_blockedListView.setListItemProvider(blockedItemManager);
+ BlockedItemFactory *blockedItemManager = new BlockedItemFactory();
+ m_blockedListView.setListItemProvider(blockedItemManager);
connect(&m_blockedListView, SIGNAL(triggered(const QVariantList)), \
SLOT(handleBlockedListTriggered(const QVariantList))); }
-void MainWindow::handleBlockedCallListTriggered(const QVariantList)
-{
-}
-
-void MainWindow::handleBlockedSmsListTriggered(const QVariantList)
+void MainWindow::handleBlockedListTriggered(const QVariantList)
{
}
diff --git a/frontends/blackberry/ui/mainwindow.h \
b/frontends/blackberry/ui/mainwindow.h index c988d57..a3f2ef2 100644
--- a/frontends/blackberry/ui/mainwindow.h
+++ b/frontends/blackberry/ui/mainwindow.h
@@ -45,8 +45,7 @@ public:
~MainWindow();
private Q_SLOTS:
- void handleBlockedCallListTriggered(const QVariantList);
- void handleBlockedSmsListTriggered(const QVariantList);
+ void handleBlockedListTriggered(const QVariantList);
void handleBlockButtonClicked();
void handleTopChanged(bb::cascades::Page* page);
void handlePopTransitionEnded(bb::cascades::Page *page);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic