ginebra2/UrlSearchSnippet.h
changeset 0 1450b09d0cfd
child 3 0954f5dd2cd0
child 5 0f2326c2a325
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ginebra2/UrlSearchSnippet.h	Tue May 04 12:39:35 2010 +0300
@@ -0,0 +1,109 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __URLSEARCH_SNIPPET_H
+#define __URLSEARCH_SNIPPET_H
+
+#include "NativeChromeItem.h"
+
+namespace GVA {
+
+class ChromeWidget;
+
+class UrlEditorWidget : public QGraphicsTextItem
+{
+    Q_OBJECT
+
+public:
+    UrlEditorWidget(QGraphicsItem * parent);
+    virtual ~UrlEditorWidget();
+
+    void setText(const QString & text);
+
+    qreal cursorX();
+
+protected:
+    virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget);
+    virtual void keyPressEvent(QKeyEvent * event);
+
+signals:
+    void cursorXChanged(qreal newx);
+
+private:
+    QTextLine m_textLine;
+};
+
+class UrlSearchSnippet : public NativeChromeItem
+{
+    Q_OBJECT
+
+public:
+    UrlSearchSnippet(ChromeSnippet * snippet, ChromeWidget * chrome, QGraphicsItem * parent = 0);
+    virtual ~UrlSearchSnippet();
+
+protected:
+    virtual bool eventFilter(QObject * object, QEvent * event);
+    virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget);
+    virtual void resizeEvent(QGraphicsSceneResizeEvent * event);
+
+signals:
+    void activated();
+
+private slots:
+    void resize();
+    void setUrlText(const QString & text);
+    void setStarted();
+    void setProgress(int percent);
+    void setFinished(bool ok);
+    void clearProgress();
+    void viewChanged();
+    void makeVisible(qreal cursorX);
+
+private:
+    void internalScroll(qreal deltaX);
+
+private:
+    ChromeWidget * m_chrome;
+    QString m_text;
+    int m_percent;
+    int m_pendingClearCalls;
+
+    // Style parameters.
+
+    QColor m_textColor;
+    QColor m_backgroundColor;
+    QColor m_borderColor;
+
+    int m_border;
+    int m_padding;
+
+    // Cached values used for painting and scrolling.
+
+    qreal m_viewPortWidth;
+    qreal m_viewPortHeight;
+
+    // At runtime, UrlSearchSnippet is parent to a QGraphicsWidget
+    // (m_viewPort) that is parent to a UrlEditorWidget (m_editor).
+
+    QGraphicsWidget * m_viewPort;
+    UrlEditorWidget * m_editor;
+};
+
+} // namespace GVA
+
+#endif // __URLSEARCH_SNIPPET_H