messagingapp/msgui/unifiededitor/inc/msgunifiededitorlineedit.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 14 May 2010 15:49:35 +0300
changeset 27 e4592d119491
parent 25 84d9eb65b26f
permissions -rw-r--r--
Revision: 201017 Kit: 201019

/*
* Copyright (c) 2009 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: Derieved HbLineEdit class for custom address editor
*
*/

#ifndef MSGUNIFIEDEDITORLINEEDIT_H
#define MSGUNIFIEDEDITORLINEEDIT_H

#include <HbLineEdit>
#include<QBasicTimer>


class MsgUnifiedEditorLineEdit : public HbLineEdit
{
    Q_OBJECT

public:
    /**
     * Constructor
     */
    MsgUnifiedEditorLineEdit(const QString& label, QGraphicsItem* parent=0);
    
    /**
     * Destructor
     */
    ~MsgUnifiedEditorLineEdit();
    
    /**
     * seeker method for getting address list
     */
    QStringList addresses();

    /**
     * Flag to retain or override base-class behaviour
     * Needed because address & subject field classes derieve
     * from this class, but have different behaviour
     */
    void setDefaultBehaviour(bool defaultBehaviour = false);
    
    /**
     * seeker method for getting the text content held by editing field
     */
    QString content() const;
    
    /**
     * setter method to clear text content of the editing field
     */
    void clearContent();
    
    /**
     * set highlight on invalid contact
     * @param invalidStr, String to be highlighted
     */
    void highlightInvalidString(QString invalidStr);

signals:
    void contentsChanged(const QString& text);

public slots:
    void setText(const QString &text, bool underlined = true);
    void cut();
    void selectAll();

private slots:
    void selectionChanged(const QTextCursor &oldCursor, const QTextCursor& newCursor);
    void onContentsChanged();
    
protected: // from HbLineEdit
    void inputMethodEvent(QInputMethodEvent *event);
    void keyPressEvent(QKeyEvent *event);
    void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
    void focusInEvent(QFocusEvent* event);
    void focusOutEvent(QFocusEvent *event);
    void timerEvent (QTimerEvent *event);


private:
    void setHighlight(int currentPos);
    QString text() const;

private:
    QRegExp mLabelExpr;
    QString mLabel;
    QBasicTimer mSelectionSnapTimer;

    int mSelectionStart;
    int mSelectionEnd;
    bool mDefaultBehaviour;
};

#endif // MSGUNIFIEDEDITORLINEEDIT_H