Commit b4a5ae73 authored by Dan Pascu's avatar Dan Pascu

Added session model and view

parent 5c444b69
......@@ -13,6 +13,7 @@ from sipsimple.account import AccountManager
from blink.accounts import AccountModel, ActiveAccountModel
from blink.contacts import Contact, ContactGroup, ContactEditorDialog, ContactModel, ContactSearchModel
from blink.sessions import SessionModel
from blink.resources import Resources
......@@ -47,10 +48,14 @@ class MainWindow(base_class, ui_class):
self.contact_editor = ContactEditorDialog(self.contact_model, self)
self.session_model = SessionModel(self)
self.session_list.setModel(self.session_model)
self.session_model.test()
self.contacts_panel.sibling_panel = self.sessions_panel
self.contacts_panel.sibling_name = u'Sessions'
self.contacts_panel.sibling_name = u'Switch to Calls'
self.sessions_panel.sibling_panel = self.contacts_panel
self.sessions_panel.sibling_name = u'Contacts'
self.sessions_panel.sibling_name = u'Switch to Contacts'
self.main_view.setCurrentWidget(self.contacts_panel)
self.contacts_view.setCurrentWidget(self.contact_list_panel)
......@@ -113,7 +118,7 @@ class MainWindow(base_class, ui_class):
def search_box_text_changed(self, text):
if text:
self.main_view.setCurrentWidget(self.contacts_panel)
self.switch_view_button.setText(u"Sessions")
self.switch_view_button.setText(self.contacts_panel.sibling_name)
self.enable_call_buttons(True)
else:
selected_items = self.contact_list.selectionModel().selectedIndexes()
......
This diff is collapsed.
# Copyright (c) 2010 AG Projects. See LICENSE for details.
#
__all__ = ['ToolButton']
__all__ = ['ToolButton', 'SegmentButton', 'SingleSegment', 'LeftSegment', 'MiddleSegment', 'RightSegment']
from PyQt4.QtGui import QStyle, QStyleOptionToolButton, QStylePainter, QToolButton
from PyQt4.QtCore import pyqtSignal
from PyQt4.QtGui import QStyle, QStyleOptionToolButton, QStylePainter, QToolButton
class ToolButton(QToolButton):
......@@ -16,3 +17,113 @@ class ToolButton(QToolButton):
painter.drawComplexControl(QStyle.CC_ToolButton, option)
class SegmentTypeMeta(type):
def __repr__(cls):
return cls.__name__
class SegmentType(object):
__metaclass__ = SegmentTypeMeta
style_sheet = ''
class SingleSegment(SegmentType):
style_sheet = """
QToolButton {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #fafafa, stop:1 #bababa);
border-color: #545454;
border-radius: 4px;
border-width: 1px;
border-style: solid;
}
QToolButton:pressed {
background: qradialgradient(cx:0.5, cy:0.5, radius:1, fx:0.5, fy:0.5, stop:0 #dddddd, stop:1 #777777);
border-style: inset;
}
"""
class LeftSegment(SegmentType):
style_sheet = """
QToolButton {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #fafafa, stop:1 #bababa);
border-color: #545454;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
border-width: 1px;
border-style: solid;
}
QToolButton:pressed {
background: qradialgradient(cx:0.5, cy:0.5, radius:1, fx:0.5, fy:0.5, stop:0 #dddddd, stop:1 #777777);
border-style: inset;
}
"""
class MiddleSegment(SegmentType):
style_sheet = """
QToolButton {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #fafafa, stop:1 #bababa);
border-color: #545454;
border-width: 1px;
border-left-width: 0px;
border-style: solid;
}
QToolButton:pressed {
background: qradialgradient(cx:0.5, cy:0.5, radius:1, fx:0.5, fy:0.5, stop:0 #dddddd, stop:1 #777777);
border-style: inset;
}
"""
class RightSegment(SegmentType):
style_sheet = """
QToolButton {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #fafafa, stop:1 #bababa);
border-color: #545454;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-width: 1px;
border-left-width: 0px;
border-style: solid;
}
QToolButton:pressed {
background: qradialgradient(cx:0.5, cy:0.5, radius:1, fx:0.5, fy:0.5, stop:0 #dddddd, stop:1 #777777);
border-style: inset;
}
"""
class SegmentButton(QToolButton):
SingleSegment = SingleSegment
LeftSegment = LeftSegment
MiddleSegment = MiddleSegment
RightSegment = RightSegment
hidden = pyqtSignal()
shown = pyqtSignal()
def __init__(self, parent=None):
super(SegmentButton, self).__init__()
self.type = SingleSegment
def _get_type(self):
return self.__dict__['type']
def _set_type(self, value):
if not issubclass(value, SegmentType):
raise ValueError("Invalid type: %r" % value)
self.__dict__['type'] = value
self.setStyleSheet(value.style_sheet)
type = property(_get_type, _set_type)
del _get_type, _set_type
def hide(self):
super(SegmentButton, self).hide()
self.hidden.emit()
def show(self):
super(SegmentButton, self).show()
self.shown.emit()
......@@ -241,7 +241,7 @@
<enum>Qt::TabFocus</enum>
</property>
<property name="text">
<string>Sessions</string>
<string>Switch to Calls</string>
</property>
<property name="iconSize">
<size>
......@@ -254,7 +254,7 @@
<item>
<widget class="QStackedWidget" name="main_view">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="contacts_panel">
<layout class="QVBoxLayout" name="verticalLayout_8">
......@@ -267,7 +267,7 @@
<item>
<widget class="QStackedWidget" name="contacts_view">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="contact_list_panel">
<layout class="QVBoxLayout" name="verticalLayout_7">
......@@ -670,7 +670,17 @@ buttons below.</string>
<number>0</number>
</property>
<item>
<widget class="QListView" name="session_list"/>
<widget class="SessionListView" name="session_list">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="session_buttons_layout">
......@@ -841,6 +851,11 @@ buttons below.</string>
<extends>QToolButton</extends>
<header>blink.widgets.buttons</header>
</customwidget>
<customwidget>
<class>SessionListView</class>
<extends>QListView</extends>
<header>blink.sessions</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>search_box</tabstop>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment