examples/keepintouch/addressfinder.h
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:BSD$
       
    10 ** You may use this file under the terms of the BSD license as follows:
       
    11 **
       
    12 ** "Redistribution and use in source and binary forms, with or without
       
    13 ** modification, are permitted provided that the following conditions are
       
    14 ** met:
       
    15 **   * Redistributions of source code must retain the above copyright
       
    16 **     notice, this list of conditions and the following disclaimer.
       
    17 **   * Redistributions in binary form must reproduce the above copyright
       
    18 **     notice, this list of conditions and the following disclaimer in
       
    19 **     the documentation and/or other materials provided with the
       
    20 **     distribution.
       
    21 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
       
    22 **     the names of its contributors may be used to endorse or promote
       
    23 **     products derived from this software without specific prior written
       
    24 **     permission.
       
    25 **
       
    26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
       
    27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
       
    28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
       
    29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
       
    30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
       
    31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
       
    32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
       
    33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
       
    34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
       
    36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
       
    37 ** $QT_END_LICENSE$
       
    38 **
       
    39 ****************************************************************************/
       
    40 #ifndef ADDRESSFINDER_H
       
    41 #define ADDRESSFINDER_H
       
    42 
       
    43 #include "qmessageservice.h"
       
    44 
       
    45 #include <QMap>
       
    46 #include <QObject>
       
    47 #include <QPair>
       
    48 #include <QSet>
       
    49 #include <QWidget>
       
    50 #include <QMainWindow>
       
    51 
       
    52 QT_BEGIN_NAMESPACE
       
    53 class QCheckBox;
       
    54 class QComboBox;
       
    55 class QListWidget;
       
    56 class QPushButton;
       
    57 class QTabWidget;
       
    58 QT_END_NAMESPACE
       
    59 
       
    60 #if !defined(Q_OS_WIN) || !defined(_WIN32_WCE)
       
    61 // Don't use a 'Search' Button in CE
       
    62 #define USE_SEARCH_BUTTON
       
    63 #endif
       
    64 
       
    65 #ifdef Q_WS_MAEMO_5
       
    66 #define USE_CONTACTS_COMBOBOX
       
    67 #endif
       
    68 
       
    69 QTM_USE_NAMESPACE
       
    70 
       
    71 class AddressFinder : public QMainWindow
       
    72 {
       
    73     Q_OBJECT
       
    74 
       
    75 public:
       
    76     AddressFinder(QWidget *parent = 0, Qt::WindowFlags flags = 0);
       
    77     ~AddressFinder();
       
    78 
       
    79 private slots:
       
    80     void includePeriodChanged(int);
       
    81     void excludePeriodEnabled(int);
       
    82     void addressSelected(const QString&);
       
    83     void searchMessages();
       
    84     void stateChanged(QMessageService::State a);
       
    85     void messagesFound(const QMessageIdList &ids);
       
    86     void continueSearch();
       
    87 #ifndef USE_SEARCH_BUTTON
       
    88     void tabChanged(int index);
       
    89 #endif
       
    90     void messageIndexChanged(int index);
       
    91     void showMessage();
       
    92     void forwardMessage();
       
    93 
       
    94 private:
       
    95     void setupUi();
       
    96     void setSearchActionEnabled(bool val);
       
    97 
       
    98 private:
       
    99     QTabWidget *tabWidget;
       
   100     QComboBox *includePeriod;
       
   101     QComboBox *excludePeriod;
       
   102     QCheckBox *excludeCheckBox;
       
   103 
       
   104     QAction *searchAction;
       
   105     QPushButton *searchButton;
       
   106 
       
   107 #ifdef USE_CONTACTS_COMBOBOX
       
   108     QComboBox *contactList;
       
   109 #else
       
   110     QListWidget *contactList;
       
   111 #endif
       
   112     QComboBox *messageCombo;
       
   113     QPushButton *showButton;
       
   114     QPushButton *forwardButton;
       
   115 
       
   116     QMessageService service;
       
   117 
       
   118     QMessageFilter inclusionFilter;
       
   119 
       
   120     QMessageIdList inclusionMessages;
       
   121     QMessageIdList exclusionMessages;
       
   122 
       
   123     QSet<QString> excludedAddresses;
       
   124     
       
   125     QStringList addressList;
       
   126     QMap<QString, QList<QPair<QString, QMessageId> > > addressMessages;
       
   127 };
       
   128 
       
   129 #endif