Added searchItem class friend_searchfield
authorlampehe-local <henri.lampela@ixonos.com>
Fri, 30 Jul 2010 07:35:26 +0000 (10:35 +0300)
committerlampehe-local <henri.lampela@ixonos.com>
Fri, 30 Jul 2010 07:35:26 +0000 (10:35 +0300)
src/src.pro
src/ui/searchitem.cpp [new file with mode: 0644]
src/ui/searchitem.h [new file with mode: 0644]

index 785be90..de26c1d 100644 (file)
@@ -66,7 +66,8 @@ SOURCES += main.cpp \
     ui/listitem.cpp \
     ui/listitemdelegate.cpp \
     ui/friendlistitemdelegate.cpp \
-    ui/searchdialog.cpp
+    ui/searchdialog.cpp \
+    ui/searchitem.cpp
 HEADERS += application.h \
     common.h \
     engine/engine.h \
@@ -133,7 +134,8 @@ HEADERS += application.h \
     ui/listitemdelegate.h \
     ui/friendlistitemdelegate.h \
     ui/listcommon.h \
-    ui/searchdialog.h
+    ui/searchdialog.h \
+    ui/searchitem.h
 QT += network \
     webkit
 
diff --git a/src/ui/searchitem.cpp b/src/ui/searchitem.cpp
new file mode 100644 (file)
index 0000000..2130a69
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+      Henri Lampela - henri.lampela@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare 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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#include <QDebug>
+#include <QHBoxLayout>
+#include <QLineEdit>
+#include <QPushButton>
+#include "common.h"
+
+#include "searchitem.h"
+
+SearchItem::SearchItem(QWidget *parent)
+        : QWidget(parent)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    /// @todo fix sizes and position and add graphics (maybe even an animation?)
+
+    m_searchField = new QLineEdit(this);
+    m_searchField->setFixedWidth(DEFAULT_SCREEN_WIDTH - 200);
+    m_searchField->setFocus();
+
+
+    QPushButton *button = new QPushButton(tr("X"), this); /// @todo add icon etc.
+    connect(button, SIGNAL(clicked()),
+            this, SLOT(hide()));
+
+
+    button->setFixedWidth(150);
+
+    QHBoxLayout *layout = new QHBoxLayout(this);
+
+    layout->addWidget(m_searchField, 0, Qt::AlignLeft);
+    layout->addWidget(button, 0, Qt::AlignRight);
+
+    setLayout(layout);
+
+    setFixedSize((DEFAULT_SCREEN_WIDTH - 50), 70);
+    move(0, (DEFAULT_SCREEN_HEIGHT - 130));
+}
+
+void SearchItem::searchButtonPressed()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    emit searchLocation(m_searchField->text());
+    m_searchField->setText(""); // clear() method bugging in Qt 4.6, it leaves "dead" cursor
+    hide();
+}
+
+void SearchItem::showItem()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_searchField->setFocus();
+    show();
+}
diff --git a/src/ui/searchitem.h b/src/ui/searchitem.h
new file mode 100644 (file)
index 0000000..dda0479
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+      Henri Lampela - henri.lampela@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare 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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#ifndef SEARCHITEM_H
+#define SEARCHITEM_H
+
+#include <QPaintEvent>
+#include <QPixmap>
+#include <QRect>
+#include <QSize>
+#include <QWidget>
+
+class QLineEdit;
+
+/**
+ * @brief Class for drawing search field and button
+ *
+ * @author Henri Lampela - henri.lampela@ixonos.com
+ *
+ * @class SearchItem searchitem.h "ui/searchitem.h"
+ */
+class SearchItem : public QWidget
+{
+    Q_OBJECT
+
+public:
+
+    /**
+    * @brief Constructor
+    *
+    * @param parent Instance of parent widget
+    */
+    SearchItem(QWidget *parent = 0);
+
+    /**
+    * @brief shows search item and focuses lineEdit
+    *
+    */
+    void showItem();
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+private slots:
+
+    /**
+    * @brief Interscepts clicked() signal from search button
+    *
+    */
+    void searchButtonPressed();
+
+signals:
+
+    /**
+    * @brief Signal to emit user's input
+    *
+    */
+    void searchLocation(QString location);
+
+private:
+
+    QLineEdit *m_searchField;       ///< pointer to search field
+};
+
+#endif // SEARCHITEM_H