Commit a7f4b835 authored by sebastien's avatar sebastien Committed by Romain Bignon
Browse files

ajout application qhandjoob


Signed-off-by: default avatarsebastien <sebastien@perso>
Signed-off-by: Romain Bignon's avatarRomain Bignon <romain@symlink.me>
parent 14b6d755
[Desktop Entry]
Name=QHandJoob
Comment=Search for jobs
Exec=qhandjoob
Icon=qhandjoob
Terminal=false
Type=Application
StartupNotify=true
Categories=Network;Qt;
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2010-2012 Sébastien Monel
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.applications.qhandjoob import QHandJoob
if __name__ == '__main__':
QHandJoob.run()
from .qhandjoob import QHandJoob
__all__ = ['QHandJoob']
# -*- coding: utf-8 -*-
# Copyright(C) 2010-2012 Sébastien Monel
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from PyQt4.QtGui import QListWidgetItem, QImage, QPixmap, QLabel, QIcon, QBrush, QColor
from PyQt4.QtCore import SIGNAL, Qt
from decimal import Decimal
from weboob.tools.application.qt import QtMainWindow, QtDo, HTMLDelegate
from weboob.tools.application.qt.backendcfg import BackendCfg
from weboob.capabilities.job import ICapJob, BaseJobAdvert
from weboob.capabilities.base import NotLoaded, NotAvailable
from .ui.main_window_ui import Ui_MainWindow
class JobListWidgetItem(QListWidgetItem):
def __init__(self, job, *args, **kwargs):
QListWidgetItem.__init__(self, *args, **kwargs)
self.job = job
def __lt__(self, other):
return self.job.publication_date < other.job.publication_date
def setAttrs(self, storage):
text = u'%s' % self.job.title
self.setText(text)
class MainWindow(QtMainWindow):
def __init__(self, config, storage, weboob, parent=None):
QtMainWindow.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.config = config
self.storage = storage
self.weboob = weboob
self.process = None
self.displayed_photo_idx = 0
self.process_photo = {}
self.process_bookmarks = {}
self.ui.jobFrame.hide()
self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig)
self.connect(self.ui.searchEdit, SIGNAL('returnPressed()'), self.doSearch)
self.connect(self.ui.jobList, SIGNAL('currentItemChanged(QListWidgetItem*, QListWidgetItem*)'), self.jobSelected)
if self.weboob.count_backends() == 0:
self.backendsConfig()
def doSearch(self):
pattern = unicode(self.ui.searchEdit.text())
self.ui.jobList.clear()
self.process = QtDo(self.weboob, self.addJob)
self.process.do('search_job', pattern)
def addJob(self, backend, job):
if not backend:
self.process = None
return
if not job:
return
item = JobListWidgetItem(job)
item.setAttrs(self.storage)
self.ui.jobList.addItem(item)
def closeEvent(self, event):
QtMainWindow.closeEvent(self, event)
def backendsConfig(self):
bckndcfg = BackendCfg(self.weboob, (ICapJob,), self)
if bckndcfg.run():
pass
def jobSelected(self, item, prev):
if item is not None:
job = item.job
self.ui.queriesFrame.setEnabled(False)
self.process = QtDo(self.weboob, self.gotJob)
self.process.do('fillobj', job, backends=job.backend)
else:
job = None
self.setJob(job)
if prev:
prev.setAttrs(self.storage)
def gotJob(self, backend, job):
if not backend:
self.ui.queriesFrame.setEnabled(True)
self.process = None
return
self.setJob(job)
def setJob(self, job):
if job:
self.ui.descriptionEdit.setText("%s" % job.description)
self.ui.titleLabel.setText("<h1>%s</h1>" % job.title)
self.ui.backendLabel.setText("%s" % job.backend)
self.ui.jobNameLabel.setText("%s" % job.job_name)
self.ui.publicationDateLabel.setText("%s" % job.publication_date)
self.ui.societyNameLabel.setText("%s" % job.society_name)
self.ui.placeLabel.setText("%s" % job.place)
self.ui.payLabel.setText("%s" % job.pay)
self.ui.contractTypeLabel.setText("%s" % job.contract_type)
self.ui.formationLabel.setText("%s" % job.formation)
self.ui.experienceLabel.setText("%s" % job.experience)
self.ui.urlLabel.setText("%s" % job.url)
self.ui.jobFrame.show()
else:
self.ui.jobFrame.hide()
# -*- coding: utf-8 -*-
# Copyright(C) 2010-2012 Bezleputh
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.job import ICapJob
from weboob.tools.application.qt import QtApplication
from weboob.tools.config.yamlconfig import YamlConfig
from .main_window import MainWindow
class QHandJoob(QtApplication):
APPNAME = 'qhandjoob'
VERSION = '0.g'
COPYRIGHT = 'Copyright(C) 2010-2012 Sébastien Monel'
DESCRIPTION = "Qt application to search for job."
SHORT_DESCRIPTION = "search for job"
CAPS = ICapJob
CONFIG = {'queries': {}}
STORAGE = {'bookmarks': [], 'read': [], 'notes': {}}
def main(self, argv):
self.load_backends(ICapJob)
self.create_storage()
self.load_config(klass=YamlConfig)
self.main_window = MainWindow(self.config, self.storage, self.weboob)
self.main_window.show()
return self.weboob.loop()
UI_FILES = $(wildcard *.ui)
UI_PY_FILES = $(UI_FILES:%.ui=%_ui.py)
PYUIC = pyuic4
all: $(UI_PY_FILES)
%_ui.py: %.ui
$(PYUIC) -o $@ $^
clean:
rm -f *.pyc
rm -f $(UI_PY_FILES)
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>709</width>
<height>572</height>
</rect>
</property>
<property name="windowTitle">
<string>QHandJoob</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSplitter" name="splitter_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QFrame" name="queriesFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLineEdit" name="searchEdit"/>
</item>
<item>
<widget class="QListWidget" name="jobList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="iconSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QFrame" name="jobFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QSplitter" name="splitter_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="titleLabel">
<property name="text">
<string>&lt;h1&gt;Loading...&lt;/h1&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Backend</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="backendLabel">
<property name="text">
<string>Loading...</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Job Name</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Publication Date</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Society Name</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Place</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Pay</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_9">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Contract Type</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Formation</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_11">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Experience</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_12">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>URL</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="jobNameLabel">
<property name="text">
<string>Loading...</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="publicationDateLabel">
<property name="text">
<string>Loading...</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="societyNameLabel">
<property name="text">
<string>Loading...</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="placeLabel">
<property name="text">
<string>Loading...</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="payLabel">
<property name="text">
<string>Loading...</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="contractTypeLabel">
<property name="text">
<string>Loading...</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="formationLabel">
<property name="text">
<string>Loading...</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="experienceLabel">
<property name="text">
<string>Loading...</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLabel" name="urlLabel">
<property name="text">
<string>Loading...</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QTextEdit" name="descriptionEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>50</verstretch>
</sizepolicy>
</property>