SFLPhoneView.h 11.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
/***************************************************************************
 *   Copyright (C) 2009-2010 by Savoir-Faire Linux                         *
 *   Author : Jérémy Quentin <jeremy.quentin@savoirfairelinux.com>         *
 *            Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com>*
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 3 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program 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 this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef SFLPHONEVIEW_H
#define SFLPHONEVIEW_H

#include <QtGui/QWidget>
#include <QtCore/QString>
#include <QtCore/QVector>
#include <QtCore/QList>
#include <QtGui/QKeyEvent>
#include <QErrorMessage>
#include <KXmlGuiWindow>

#include "ui_SFLPhoneView_base.h"
#include "conf/ConfigurationDialog.h"
35
#include "widgets/CallTreeItem.h"
36
#include "AccountWizard.h"
37 38 39
#include "lib/Contact.h"
#include "lib/AccountList.h"
#include "CallView.h"
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

class ConfigurationDialog;


/**
 * This is the main view class for sflphone-client-kde.  Most of the non-menu,
 * non-toolbar, and non-statusbar (e.g., non frame) GUI code should go
 * here.
 * As the state of the view has effects on the window,
 * it emits some signals to ask for changes that the window has
 * to treat.
 *
 * @short Main view
 * @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com>
 * @version 0.9.6
 */
class SFLPhoneView : public QWidget, public Ui::SFLPhone_view
{
   Q_OBJECT
    
private:

62
   //static ConfigurationDialog * configDialog;
63 64 65 66 67 68
   AccountWizard * wizard;
   //List of calls in the window, and past ones.
   //Handles both current calls (dialing, ringing...) and history.
   //CallList * callList;
   QErrorMessage * errorWindow;
   //Account used prioritary if defined and registered. If not, the first registered account in accountList is used.
69
   
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
   bool historyLoaded;

protected:
   
   /**
    * override context menu handling
    * @param event
    */
   void contextMenuEvent(QContextMenuEvent *event);

public:
   //Constructors & Destructors
   /**
    *   This constructor does not load the window as it would
    *   better wait for the parent window to connect to the signals
    *   for updating it (statusMessageChangeAsked...).
    *   You should call the loadWindow() method once
    *   you have constructed the object and connected the
    *   expected signals.
    * @param parent 
    */
   SFLPhoneView(QWidget *parent);
   virtual ~SFLPhoneView();
   
   //Getters
   
96
   
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
   QErrorMessage * getErrorWindow();
   
   //Daemon getters
   /**
   * Used to sort contacts according to their types with Kabc.
   * @return the integer resulting to the flags of the types 
   * chosen to be displayed in SFLphone configuration.
   */
   int phoneNumberTypesDisplayed();
   
   /**
    * 
    * @return true if the address book is enabled in config
    */
   bool isAddressBookEnabled();
   
   QVector<Contact *> findContactsInKAddressBook(QString textSearched, bool & full);
   
   /**
    *   Save the settings to save in the daemon before exit
    */
   void saveState();
   
   //CallTreeView *callTree;
   //CallTreeView *historyTree;
   //CallTreeView *addressBookTree;
   //CallTreeWidget *callTree;
   //CallTreeWidget *historyTree;
125 126 127
   CallView addressBookTree;
   CallView callTreeModel;
   CallView historyTreeModel;
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232

private slots:
   /**
    *   Performs the action action on the call call, then updates window.
    *   The call object will handle the action with its "actionPerformed" method.
    *   See the documentation for more details.
    * @param call the call on which to perform the action
    * @param action the code of the action to perform
    */
   void action(Call * call, call_action action);
   
   /**
    *   Sets the account account to be the prior account.
    *   That means it's gonna be used when the user places a call
    *   if it's defined and registered, else the first registered of 
    *   accountList will be used.
    * @param account the account to use prior
    */
   void setAccountFirst(Account * account);
   
   /**
    *   Handles the behaviour when the user types something with
    *   the dialpad widget or his keyboard (normally it's a one char
    *   string but we use a string just in case).
    *   Adds str to the selected item if in the main window
    *   and creates a new item if no item is selected.
    *   Send DTMF if appropriate according to current item's state.
    *   Adds str to the search bar if in history or address book.
    * @param str the string sent by the user
    */
   void typeString(QString str);

   /**
    *   Handles the behaviour when the user types a backspace
    *   according to the current state (window, item selected...)
    */
   void backspace();

   /**
    *   Handles the behaviour when the user types escape
    *   according to the current state (window, item selected...)
    */
   void escape();

   /**
    *   Handles the behaviour when the user types enter
    *   according to the current state (window, item selected...)
    */
   void enter();

   /**
    *   Displays a message window with editable text of the selected
    *   phone number in history or address book.
    *   Once the user accepts, place a call with the chosen phone number.
    *   Keeps the peer name of the contact or past call.
    */
   void editBeforeCall();
   
   /**
    *   Alternates colors of the list widget with the application's palettes's
    *   base and alternateBase colors.
    * @param listWidget the list widget to which we alternate colors
    */
   void alternateColors(QListWidget * listWidget);
   
   /**
    *   Adds the call's item to the call-list's listwidget.
    *   This function doesn't add anything to the callList object.
    * @param call the call to add to the call-list's listwidget
    */
   //Call* addCallToCallList(Call * call);

   /**
    * Adds the call's history-item to the call-history's listwidget.
    * This function doesn't add anything to the callList object.
    * @param call the past call to add to the call-history's listwidget
    */
   //Call* addCallToCallHistory(Call * call);

   /**
    * Adds the contact's item to the addressbook's listwidget.
    * @param contact the contact to add to the addressbook's listwidget
    */
   void addContactToContactList(Contact * contact);
   
   /**
    *   Updates the toolbar's actions' display according to the selected 
    *   item's state.
    */
   void updateWindowCallState();

   /**
    * Updates the history's search bar's display according to the current
    * text searched. 
    * If empty, hide the search bar.
    */
   void updateSearchHistory();
   void updateCallHistory();
   void updateAddressBook();
   void updateRecordButton();
   void updateVolumeButton();
   void updateRecordBar();
   void updateVolumeBar();
   void updateVolumeControls();
   void updateDialpad();
233
   
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286

public slots:
   /**
    * Updates all the display
    * according to the settings.
    */
   void loadWindow();
   
   
   void updateStatusMessage();
   
   /**
    *   Enable the address book search line edit.
    *   To be called once the address book loading has finished.
    */
   void enableAddressBook();
   
   /**
    *   Loads the address book asynchronously.
    *   Calls enableAddressBook() once the address book
    *   loading has finished if it is not already loaded.
    * @return true if address book has finished loading
    */
   bool loadAddressBook();
   
   /**
    *   Chooses to enable/disable (show/hide) the address book 
    *   button according to the configuration's setting, and 
    *   returns to the main window if is in address book
    *   whereas it is disabled.
    */
   void updateAddressBookEnabled();
   
   
   virtual void keyPressEvent(QKeyEvent *event)
   {
      int key = event->key();
      if(key == Qt::Key_Escape)
         escape();
      else if(key == Qt::Key_Return || key == Qt::Key_Enter)
         enter();
      else if(key == Qt::Key_Backspace)
         backspace();
      else
      {
         QString text = event->text();
         if(! event->text().isEmpty())
         {
            typeString(text);
         }
      }
   }

287 288
   void displayVolumeControls(bool checked = true);
   void displayDialpad(bool checked = true);
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
   void configureSflPhone();
   void accountCreationWizard();
   void accept();
   void refuse();
   void hold();
   void transfer();
   void record();
   void mailBox();
   
   void on_widget_dialpad_typed(QString text);
   
   void on_lineEdit_searchHistory_textChanged();
   void on_lineEdit_addressBook_textChanged();
   
   void on_slider_recVol_valueChanged(int value);
   void on_slider_sndVol_valueChanged(int value);
   
   void on_toolButton_recVol_clicked(bool checked);
   void on_toolButton_sndVol_clicked(bool checked);
   
   void on_callTree_currentItemChanged();
   void on_callTree_itemChanged();
   void on_callTree_itemDoubleClicked(QTreeWidgetItem* item, int column);

   void on_listWidget_callHistory_currentItemChanged();
   void on_listWidget_callHistory_itemDoubleClicked(Call* item);

   void on_listWidget_addressBook_currentItemChanged();
   void on_listWidget_addressBook_itemDoubleClicked(CallTreeItem * item);
   
   void on_stackedWidget_screen_currentChanged(int index);
   
   void on1_callStateChanged(const QString &callID, const QString &state);
   void on1_error(MapStringString details);
   void on1_incomingCall(const QString &accountID, const QString &callID/*, const QString &from*/);
   void on1_incomingMessage(const QString &accountID, const QString &message);
   void on1_voiceMailNotify(const QString &accountID, int count);
   void on1_volumeChanged(const QString &device, double value);
   void on1_audioManagerChanged();
   void on1_incomingConference(const QString &confID);
   void on1_changingConference(const QString &confID, const QString &state);
   void on1_conferenceRemoved(const QString &confId);
   void changeScreen(int screen);
   
signals:
   void statusMessageChangeAsked(const QString & message);
   void windowTitleChangeAsked(const QString & title);
   void enabledActionsChangeAsked(const bool * enabledActions);
   void actionIconsChangeAsked(const QString * actionIcons);
   void actionTextsChangeAsked(const QString * actionTexts);
   void transferCheckStateChangeAsked(bool transferCheckState);
   void recordCheckStateChangeAsked(bool recordCheckState);
   void addressBookEnableAsked(bool enableAddressBook);
   void screenChanged(int screen);
   void incomingCall(const Call * call);
   

};

#endif // SFLPHONEVIEW_H