source: projects/punch-card/punch-card-editor/src/text/editordock.cc @ 52

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

Punch Card Editor: Code reordering and class renaming, rewriting.
Now using the namespace QPunchCard everywhere.

Parted the whole application into 5 parts/directories:

  • app: The application core with MainWindow and main() function
  • qpunchcard: Everything directly binary card related (no interpretation): modeling, input/output, view. Most important classes are Card, Deck, FileFormat, Widget
  • text: Everything related to text interpretation of Cards/Card Decks. Having the abstract Codec classes and the Text::Editor, Text::EditorDock
  • deckviewer: Application components like binary card editing central widget (CardEditor) and Navigator (Model View Controller classes)
  • driver: Basis for the driver framework, must be written soon.

Deck now hides the complete Storage to implement frontend methods that
implement versioning (Undo framework). All code was cleaned up, but doesn't
compile right now (still quite some non heavy errors).

-- Sven @ workstation

File size: 2.5 KB
Line 
1#include "editordock.h"
2
3#include <QPainter>
4#include <QTextBlock>
5#include <QBoxLayout>
6#include <QLabel>
7#include <QComboBox>
8#include <QPushButton>
9
10using namespace QPunchCard;
11
12Text::EditorDock::EditorDock(EditorWindow* parent) : QDockWidget(parent), main(parent) {
13        // Title grundsaetzlich angeben (wird ueberall angezeigt)
14        setWindowTitle(tr("Text Editor"));
15
16        editor = new Text::Editor(main);
17
18        // Signal weiterleiten
19        connect(editor, SIGNAL(cursorRowChanged(DeckIndex)), this, SIGNAL(cardSelected(DeckIndex)));
20        connect(main, SIGNAL(contentsChanged(DeckIndex,DeckIndex)), editor, SLOT(contentsChanged(DeckIndex,DeckIndex)));
21
22        // urhm... Codebar erstellen
23        create_code_bar();
24        create_color_bar();
25
26        // Container-Widget erstellen
27        QWidget* container = new QWidget(this);
28        QVBoxLayout* layout = new QVBoxLayout(container);
29
30        //layout->addWidget(code_bar);
31        layout->addWidget(editor);
32        layout->addWidget(color_bar);
33
34        setWidget(container);
35        setTitleBarWidget(code_bar);
36        setFeatures(QDockWidget::AllDockWidgetFeatures);
37}
38
39void Text::EditorDock::create_code_bar() {
40        code_bar = new QWidget(this);
41        QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight, code_bar);
42
43        // Label fuer Fenster
44        layout->addWidget(new QLabel(tr("Card Text"), code_bar));
45
46        // Codec-Auswahlbox
47        QComboBox* codec_selection = new QComboBox(code_bar);
48        codec_selection->addItems( CodecFactory::availableCodecs() );
49        codec_selection->setStatusTip(tr("Use another codec to display the decks contents as ASCII text. This won't change the cards contents"));
50        connect(codec_selection, SIGNAL(currentIndexChanged(QString)), this, SLOT(setCodec(QString)));
51        layout->addWidget(codec_selection);
52
53        // Button zur Codec-Umwandlung
54        QPushButton* text_converter = new QPushButton(tr("Convert text..."), code_bar);
55        text_converter->setStatusTip(tr("Convert the current deck (or selection) to another punch card code"));
56        connect(text_converter, SIGNAL(clicked()), this, SLOT(showTextConverterDialog()));
57        layout->addWidget(text_converter);
58}
59
60void Text::EditorDock::create_color_bar() {
61        color_bar = new QWidget(this);
62        // usw.
63}
64
65void Text::EditorDock::setCard(DeckIndex i) {
66        editor->highlightRow(i);
67}
68
69void Text::EditorDock::setCodec(QString by_name) {
70        // QSharedPointer: Durch Assignment wird das alte Objekt geloescht :-)
71        editor->codec = QSharedPointer<const Codec>( CodecFactory::createCodec(by_name) );
72        // jetzt: Text komplett neu auswerten. Todo...
73}
74
75void Text::EditorDock::showTextConverterDialog() {
76        qDebug("Text Converter Dialog... PENDING");
77}
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