source: projects/punch-card/punch-card-editor/src/deckviewer/navigatordock.cc @ 52

Last change on this file since 52 was 52, checked in by sven, 14 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.3 KB
Line 
1#include "navigatordock.h"
2
3using namespace QPunchCard;
4using namespace Navigator;
5
6Dock::Dock(App::MainWindow* parent) : QDockWidget("Cards", parent), main(parent) {
7        model = new Model(this);
8        view = new View(this);
9        // mach das model selbst:
10        //model->setDock(main->deck);
11        // darf die view nicht selbst machen (erst nach model erstellt wird!)
12        view->setModel(model);
13
14        setWidget(view);
15        setFeatures(QDockWidget::AllDockWidgetFeatures);
16
17        // Signale zusammenpatscheln
18        connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(cardSelected_translator(QModelIndex)));
19        connect(this, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(setFlowOnLocationChange(Qt::DockWidgetArea)));
20        connect(main, SIGNAL(contentsChanged(DeckIndex,DeckIndex)), model, SLOT(contentsChanged(DeckIndex,DeckIndex)));
21
22        // Beim Klick auf Karte alle Views aktualisieren
23        connect(this, SIGNAL(cardSelected(DeckIndex)), main, SLOT(setCard(DeckIndex)));
24        connect(main, SIGNAL(cardSelected(DeckIndex)), this, SLOT(setCard(DeckIndex)));
25
26        // Beim Laden/Entladen eines Docks Model und View an/ausschalten
27        connect(main, SIGNAL(fileOpened(bool)), this, SLOT(setVisible(bool)));
28        connect(main, SIGNAL(fileOpened(bool)), model, SLOT(setDock(bool)));
29}
30
31void Dock::setFlowOnLocationChange(Qt::DockWidgetArea new_area) {
32        // Ausrichtung der Icons auf Basis der Ausrichtung des Docks
33        switch(new_area) {
34                case Qt::TopDockWidgetArea:
35                case Qt::BottomDockWidgetArea:
36                        view->setFlow(QListView::LeftToRight);
37                        break;
38                case Qt::LeftDockWidgetArea:
39                case Qt::RightDockWidgetArea:
40                default:
41                        view->setFlow(QListView::TopToBottom);
42                        break;
43        }
44        // in jedem Fall Icon-Groesse neu berechnen (etwas quick & dirty)
45        resizeEvent(0);
46}
47
48void Dock::setCard(DeckIndex i) {
49        if(i.isValid())
50                view->scrollTo( model->index(i), QAbstractItemView::PositionAtCenter);
51        else
52                qDebug("Dock invalid scroll to %d", (int)i);
53}
54
55void Dock::resizeEvent(QResizeEvent*) {
56        if(view->flow() == QListView::TopToBottom) {
57                model->setIconSizeByWidth( view->viewport()->contentsRect().width() - 40 );
58                view->setIconSize( model->getIconSize() );
59        } else if(view->flow() == QListView::LeftToRight) {
60                // bei Hoehe ist halt noch das Label irgendwie dabei -- schwierig zu berechnen
61                model->setIconSizeByHeight( view->viewport()->contentsRect().height() - 80);
62                view->setIconSize( model->getIconSize() );
63        }
64}
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