source: projects/punch-card/punch-card-editor/src/driver/driver.cc @ 53

Last change on this file since 53 was 53, checked in by sven, 10 years ago

Punch Card Editor, ongoing development

  • Extended new Deck interface, expanding the undo framework
  • Implemented editor changes via undo framework
  • revised the menu and toolbar actions and structure (now dynamic construction at deck load time), implemented undo viewer
  • Started implementation of device driver framework in menu
  • Embedded the Qextserialport library (http://qextserialport.sourceforge.net/)
  • Started the Documation M200 Client device driver (well, just created the directory structure and qmake project file infrastructure)
  • At the current state, the complete project compiles :-)

Statistics: About 3500 Lines of code (without libqextserialport)

-- sven @ workstation

File size: 1.3 KB
Line 
1#include "driver.h"
2
3#include <QLabel>
4
5using namespace QPunchCard;
6using namespace Device;
7
8Dock::Dock(QString driver_name, App::MainWindow* parent) : QDockWidget(parent), main(parent), driver_name(driver_name) {
9        setWindowTitle( tr("%1 Device Driver").arg(driver_name) );
10        connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(visibilityHook(bool)));
11}
12
13void Dock::visibilityHook(bool visible) {
14        // Singleton behaviour
15        if(!visible || controller)
16                return;
17
18        qDebug() << "Firing up device driver " << driver_name;
19        // first making visible. Create controller widget.
20        controller = DriverFactory::createController(driver_name, this);
21        if(!controller) {
22                // Bad name! So create an error message
23                controller = new QLabel(tr("<b>Bad controller:</b> <i>%1</i> doesn't exist").arg(driver_name), this);
24        }
25        setWidget(controller);
26        controller->setVisible(true);
27}
28
29QList<QString> DriverFactory::availableDrivers() {
30        QList<QString> ret;
31        ret << "Test";
32        return ret;
33}
34
35QWidget* DriverFactory::createController(const QString& name, QWidget* parent) {
36        if(name == "Test") {
37                return new QLabel("This is the Test driver :-)", parent);
38        } else {
39                qDebug() << "DriverFactory: Bad driver: " << name;
40                return 0;
41        }
42}
43
44Dock* DriverFactory::createDock(const QString& name, App::MainWindow* window) {
45        // yay, this is senseless...
46        return new Dock(name, window);
47}
48
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License