~noskcaj/ubuntu/saucy/sflphone/merge-1.2.3-2

« back to all changes in this revision

Viewing changes to kde/plasma/plasmoid/MainWidget.cpp

  • Committer: Package Import Robot
  • Author(s): Francois Marier
  • Date: 2012-02-18 21:47:09 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120218214709-6362d71gqdsdkrj5
Tags: 1.0.2-1
* New upstream release
  - remove logging patch (applied upstream)
  - update s390 patch since it was partially applied upstream
* Include the Evolution plugin as a separate binary package

* Fix compilation issues on SH4 (closes: #658987)
* Merge Ubuntu's binutils-gold linking fix

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "MainWidget.h"
 
2
 
 
3
#include "../../src/lib/sflphone_const.h"
 
4
#include "../../src/lib/callmanager_interface_singleton.h"
 
5
#include "../../src/lib/CallModel.h"
 
6
 
 
7
MainWidget::MainWidget() : Plasma::Frame(), m_mainLayout(0), frmCalls(0), frmContact(0), frmHistory(0),currentMode(CALL)
 
8
{
 
9
   mainTabs          = new Plasma::TabBar        ( this         );
 
10
   frmCalls          = new Plasma::Frame         ( this         );
 
11
   callLayout        = new QGraphicsLinearLayout ( Qt::Vertical );
 
12
   callScrollArea    = new Plasma::ScrollWidget  ( this         );
 
13
   frmContact        = new Plasma::Frame         ( this         );
 
14
   contactScrollArea = new Plasma::ScrollWidget  ( this         );
 
15
   frmHistory        = new Plasma::Frame         ( this         );
 
16
   historyLayout     = new QGraphicsLinearLayout ( Qt::Vertical );
 
17
   historyScrollArea = new Plasma::ScrollWidget  ( this         );
 
18
 
 
19
   mainLayout()->addItem(mainTabs);
 
20
   //connect(mainTabs, SIGNAL(currentChanged(int)), this, SLOT(modeChanged(int)));
 
21
 
 
22
   frmCalls->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 
23
   frmCalls->setLayout(callLayout);
 
24
 
 
25
   callScrollArea->setWidget(frmCalls);
 
26
 
 
27
   frmContact->setText("Contact");
 
28
   frmContact->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 
29
 
 
30
   contactScrollArea->setWidget(frmContact);
 
31
 
 
32
   frmHistory->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 
33
   frmHistory->setLayout(historyLayout);
 
34
 
 
35
   historyScrollArea->setWidget(frmHistory);
 
36
 
 
37
   dialPage = new DialPage();
 
38
   connect(dialPage, SIGNAL(call(QString)), this, SLOT(call(QString)));
 
39
 
 
40
   QGraphicsLinearLayout* callTabLayout    = new QGraphicsLinearLayout( Qt::Vertical );
 
41
   QGraphicsLinearLayout* historyTabLayout = new QGraphicsLinearLayout( Qt::Vertical );
 
42
   QGraphicsLinearLayout* contactTabLayout = new QGraphicsLinearLayout( Qt::Vertical );
 
43
   QGraphicsLinearLayout* addTabLayout     = new QGraphicsLinearLayout( Qt::Vertical );
 
44
 
 
45
   callTabLayout->addItem    ( callScrollArea    );
 
46
   historyTabLayout->addItem ( historyScrollArea );
 
47
   contactTabLayout->addItem ( contactScrollArea );
 
48
   addTabLayout->addItem(dialPage);
 
49
 
 
50
   mainTabs->addTab( "Call"            , callTabLayout    );
 
51
   mainTabs->addTab( "History"         , historyTabLayout );
 
52
   mainTabs->addTab( "Contact"         , contactTabLayout );
 
53
   mainTabs->addTab( KIcon("list-add") , "", addTabLayout );
 
54
 
 
55
   //mainLayout()->addItem(callTabLayout);
 
56
 
 
57
   //mainLayout()->addItem(callScrollArea);
 
58
   //mainLayout()->addItem(historyScrollArea);
 
59
   //mainLayout()->addItem(contactScrollArea);
 
60
 
 
61
   initPos = frmCalls->pos();
 
62
 
 
63
   frmCalls->setPos  ( initPos );
 
64
   frmHistory->setPos( initPos );
 
65
   frmContact->setPos( initPos );
 
66
 
 
67
   setMinimumSize(285,390);
 
68
}
 
69
 
 
70
void MainWidget::dataUpdated(const QString& source, const Plasma::DataEngine::Data& data)
 
71
{
 
72
   if ((source == "calls") && (frmCalls)) {
 
73
      QHash<QString, QVariant> value = data;
 
74
      bool modified = false;
 
75
      foreach(QVariant call, value) {
 
76
         if (!callWidgetList[value.key(call)]) {
 
77
            callWidgetList[ value.key(call) ] = new CallItem();
 
78
            callWidgetList[ value.key(call) ]->setCallId(value.key(call));
 
79
            callLayout->insertItem(0,callWidgetList[value.key(call)]);
 
80
            mainTabs->setCurrentIndex(CALL);
 
81
            modified = true;
 
82
         }
 
83
         callWidgetList[value.key(call)]->setCallerName(call.toHash()  [ "Name"   ].toString());
 
84
         callWidgetList[value.key(call)]->setCallerNumber(call.toHash()[ "Number" ].toString());
 
85
         callWidgetList[value.key(call)]->setState(call.toHash()       [ "State"  ].toInt());
 
86
 
 
87
         if (call.toHash()["State"].toInt() == CALL_STATE_INCOMING) {
 
88
            emit requierAttention();
 
89
         }
 
90
 
 
91
         topLevelItems[value.key(call)] = callWidgetList[value.key(call)];
 
92
      }
 
93
 
 
94
//       if (modified)
 
95
//         sflphoneEngine->connectSource("conferences", this,0/*Update only if something happen*/);
 
96
   }
 
97
   else if (source == "info") {
 
98
      if (!data["Account"].isNull() || data["Account"].isValid())
 
99
         currentAccountId = data["Account"].toString();
 
100
   }
 
101
   else if (source == "conferences") {
 
102
      QHash<QString, QVariant> value = data;
 
103
      foreach(QVariant call, value) {
 
104
         qDebug() << "Painting conference: " << call;//.toHash();
 
105
         if (!topLevelItems[value.key(call)]) {
 
106
            topLevelItems[value.key(call)] = new ConferenceItem();
 
107
            ((ConferenceItem*) topLevelItems[value.key(call)])->setConfId(value.key(call));
 
108
            callLayout->addItem((ConferenceItem*) topLevelItems[value.key(call)]);
 
109
            mainTabs->setCurrentIndex(CALL);
 
110
         }
 
111
         QList<CallItem*> toSend;
 
112
         foreach (QString callId, call.toStringList()) {
 
113
            if (callWidgetList[callId]) {
 
114
               toSend.push_back(callWidgetList[callId]);
 
115
               callWidgetList[callId]->setParent(0);
 
116
               if (topLevelItems[callId]) {
 
117
                   topLevelItems.remove(callId);
 
118
               }
 
119
            }
 
120
            else
 
121
               qDebug() << "Call not found";
 
122
         }
 
123
         ((ConferenceItem*)topLevelItems[value.key(call)])->setCallList(toSend);
 
124
      }
 
125
   }
 
126
   else if (source == "history") {
 
127
      QHash<QString, QVariant> value = data;
 
128
      for (QHash<QString, QVariant>::iterator i = value.begin(); i != value.end(); ++i) {
 
129
         QString key = i.key();
 
130
         //QHash<QString, CallItem*> historyWidgetList;
 
131
         if ( ! historyWidgetList[key]) {
 
132
            historyWidgetList[ i.key() ] = new CallItem();
 
133
            historyWidgetList[ i.key() ]->setCallId(i.key());
 
134
            historyLayout->addItem(historyWidgetList[i.key()]);
 
135
         }
 
136
         historyWidgetList[ i.key() ]->setCallerName(i.value().toHash()   [ "Name"   ].toString());
 
137
         historyWidgetList[ i.key() ]->setCallerNumber(i.value().toHash() [ "Number" ].toString());
 
138
         historyWidgetList[ i.key() ]->setDate(i.value().toHash()         [ "Date"   ].toInt())   ;
 
139
      }
 
140
   }
 
141
}
 
142
 
 
143
QGraphicsLinearLayout* MainWidget::mainLayout()
 
144
{
 
145
   if (!m_mainLayout) {
 
146
      m_mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
 
147
      m_mainLayout->setContentsMargins(0, 0, 0, 0);
 
148
      m_mainLayout->setSpacing(5);
 
149
      setLayout(m_mainLayout);
 
150
   }
 
151
   return m_mainLayout;
 
152
}
 
153
 
 
154
void MainWidget::call(QString number)
 
155
{
 
156
   Q_UNUSED(number);
 
157
//    qDebug() << "Calling " << number << " with account " << currentAccountId << ", " << CallModelConvenience::getAccountList()->size() << " account registred";
 
158
//    CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance();
 
159
//    callManager.placeCall(currentAccountId, CallModelConvenience::generateCallId(), number);
 
160
}