1 | #include "editordock.h" |
---|
2 | |
---|
3 | #include <QPainter> |
---|
4 | #include <QTextBlock> |
---|
5 | #include <QBoxLayout> |
---|
6 | #include <QLabel> |
---|
7 | #include <QComboBox> |
---|
8 | #include <QPushButton> |
---|
9 | |
---|
10 | using namespace QPunchCard; |
---|
11 | |
---|
12 | Text::EditorDock::EditorDock(App::MainWindow* 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 | |
---|
39 | void 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 | |
---|
60 | void Text::EditorDock::create_color_bar() { |
---|
61 | color_bar = new QWidget(this); |
---|
62 | // usw. |
---|
63 | } |
---|
64 | |
---|
65 | void Text::EditorDock::setCard(DeckIndex i) { |
---|
66 | editor->highlightRow(i); |
---|
67 | } |
---|
68 | |
---|
69 | void 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 | |
---|
75 | void Text::EditorDock::showTextConverterDialog() { |
---|
76 | qDebug("Text Converter Dialog... PENDING"); |
---|
77 | } |
---|