# HG changeset patch # User insilmaril # Date 1242400935 0 # Node ID a6931cd6309a902c500f364d121f969288fa43d4 # Parent 382a444f5b0cb56768c4131a87e0cd3ad98a3d4b more changes on views diff -r 382a444f5b0c -r a6931cd6309a branchitem.cpp --- a/branchitem.cpp Thu May 14 12:42:58 2009 +0000 +++ b/branchitem.cpp Fri May 15 15:22:15 2009 +0000 @@ -47,7 +47,6 @@ QString BranchItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) //FIXME-1 { - cout << "BI::saveToDir: "<<getHeadingStd()<<endl; // Cloudy stuff can be hidden during exports if (hidden) return QString(); @@ -55,7 +54,6 @@ BranchObj *bo=(BranchObj*)lmo; // Update of note is usually done while unselecting a branch - // if (isNoteInEditor) getNoteFromTextEditor(); // FIXME-0 check that this still works... QString scrolledAttr; if (scrolled) diff -r 382a444f5b0c -r a6931cd6309a mainwindow.cpp --- a/mainwindow.cpp Thu May 14 12:42:58 2009 +0000 +++ b/mainwindow.cpp Fri May 15 15:22:15 2009 +0000 @@ -228,6 +228,7 @@ restoreState (settings.value("/mainwindow/state",0).toByteArray()); updateGeometry(); + } Main::~Main() @@ -882,52 +883,6 @@ actionListBranches.append(a); actionDeleteChildren=a; - // Shortcuts for navigating with cursor: - a = new QAction(tr( "Select upper branch","Edit menu" ), this); - a->setStatusTip ( tr( "Select upper branch" )); - a->setShortcut (Qt::Key_Up ); - a->setShortcutContext (Qt::WindowShortcut); - addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) ); - a = new QAction( tr( "Select lower branch","Edit menu" ),this); - a->setStatusTip (tr( "Select lower branch" )); - a->setShortcut ( Qt::Key_Down ); - a->setShortcutContext (Qt::WindowShortcut); - addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) ); - a = new QAction(tr( "Select left branch","Edit menu" ), this); - a->setStatusTip ( tr( "Select left branch" )); - a->setShortcut (Qt::Key_Left ); - a->setShortcutContext (Qt::WindowShortcut); - addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) ); - a = new QAction( tr( "Select child branch","Edit menu" ), this); - a->setStatusTip (tr( "Select right branch" )); - a->setShortcut (Qt::Key_Right); - a->setShortcutContext (Qt::WindowShortcut); - addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) ); - a = new QAction( tr( "Select first branch","Edit menu" ), this); - a->setStatusTip (tr( "Select first branch" )); - a->setShortcut (Qt::Key_Home ); - a->setShortcutContext (Qt::WindowShortcut); - addAction (a); - a->setEnabled (false); - editMenu->addAction (a); - actionListBranches.append(a); - actionSelectFirst=a; - connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) ); - a = new QAction( tr( "Select last branch","Edit menu" ),this); - a->setStatusTip (tr( "Select last branch" )); - a->setShortcut ( Qt::Key_End ); - a->setShortcutContext (Qt::WindowShortcut); - addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) ); - a->setEnabled (false); - editMenu->addAction (a); - actionListBranches.append(a); - actionSelectLast=a; - a = new QAction( tr( "Add Image...","Edit menu" ), this); a->setStatusTip (tr( "Add Image" )); connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) ); @@ -1766,24 +1721,19 @@ updateActions(); } -VymView *Main::createView (VymModel *model) -{ - VymView *vm=new VymView (model); - return vm; -} - void Main::fileNew() { - VymModel *m=new VymModel; - tabModel.append (m); - //MapEditor* me = new MapEditor (m); - //me->setObjectName ("MapEditor"); - - tabWidget->addTab (createView (m),tr("unnamed","MainWindow: name for new and empty file")); + VymModel *vm=new VymModel; + tabModel.append (vm); + + VymView *vv=new VymView (vm); + tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file")); tabWidget->setCurrentIndex (tabModel.count() ); + vv->initFocus(); + // For the very first map we do not have flagrows yet... - m->select("mc:"); + vm->select("mc:"); } void Main::fileNewCopy() @@ -1860,10 +1810,12 @@ if ( lmode==NewMap && (!vm || !vm->isDefault() ) ) { vm=new VymModel; + VymView *vv=new VymView (vm); tabModel.append (vm); - tabWidget->addTab (createView (vm),fn); + tabWidget->addTab (vv,fn); tabIndex=tabWidget->count()-1; tabWidget->setCurrentPage (tabIndex); + vv->initFocus(); } // Check, if file exists (important for creating new files @@ -2965,43 +2917,6 @@ m->deleteSelection(); } -void Main::editUpperBranch() -{ - VymModel *m=currentModel(); - if (m) m->selectUpperBranch(); // FIXME-3 check also lower... this probably should go into view... -} - -void Main::editLowerBranch() // FIXME-3 check also lower... this probably should go into view... - -{ - VymModel *m=currentModel(); - if (m) m->selectLowerBranch(); -} - -void Main::editLeftBranch() -{ - VymModel *m=currentModel(); - if (m) m->selectLeftBranch(); -} - -void Main::editRightBranch() -{ - VymModel *m=currentModel(); - if (m) m->selectRightBranch(); -} - -void Main::editFirstBranch() -{ - VymModel *m=currentModel(); - if (m) m->selectFirstBranch(); -} - -void Main::editLastBranch() -{ - VymModel *m=currentModel(); - if (m) m->selectLastBranch(); -} - void Main::editLoadImage() { VymModel *m=currentModel(); @@ -3693,14 +3608,13 @@ void Main::testFunction1() { if (!currentMapEditor()) return; - currentMapEditor()->testFunction1(); - //editAttribute(); + currentMapEditor()->testFunction1(); } void Main::testFunction2() { if (!currentMapEditor()) return; - currentMapEditor()->testFunction2(); + currentMapEditor()->setFocus(); } void Main::testCommand() diff -r 382a444f5b0c -r a6931cd6309a mainwindow.h --- a/mainwindow.h Thu May 14 12:42:58 2009 +0000 +++ b/mainwindow.h Fri May 15 15:22:15 2009 +0000 @@ -42,9 +42,6 @@ void setProgressValue (int v); void removeProgressBar(); -private: - VymView* createView (VymModel*); - public slots: void fileNew(); void fileNewCopy(); @@ -159,12 +156,6 @@ void editDeleteKeepChildren(); void editDeleteChildren(); void editDeleteSelection(); - void editUpperBranch(); - void editLowerBranch(); - void editLeftBranch(); - void editRightBranch(); - void editFirstBranch(); - void editLastBranch(); void editLoadImage(); void editSaveImage(); void editFollowXLink (QAction *); @@ -317,8 +308,6 @@ QAction *actionImportAdd; QAction *actionImportReplace; QAction *actionSaveBranch; - QAction *actionSelectFirst; - QAction *actionSelectLast; QAction *actionLoadImage; QAction* actionFormatColor; diff -r 382a444f5b0c -r a6931cd6309a mapcenteritem.cpp --- a/mapcenteritem.cpp Thu May 14 12:42:58 2009 +0000 +++ b/mapcenteritem.cpp Fri May 15 15:22:15 2009 +0000 @@ -17,24 +17,19 @@ QString MapCenterItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) //FIXME-1 { - cout << "MCI::saveToDir: "<<getHeadingStd()<<endl; - // Cloudy stuff can be hidden during exports if (hidden) return QString(); QString s,a; BranchObj *bo=(BranchObj*)lmo; - /* - // Update of note is usually done while unselecting a branch - if (isNoteInEditor) getNoteFromTextEditor(); - QString scrolledAttr; if (scrolled) scrolledAttr=attribut ("scrolled","yes"); else scrolledAttr=""; + /* // save area, if not scrolled QString areaAttr; if (!((BranchObj*)(parObj))->isScrolled() ) @@ -59,7 +54,7 @@ s=beginElement ("mapcenter" +getAttr() // +getOrnXMLAttr() - // +scrolledAttr + +scrolledAttr // +areaAttr // +idAttr // +getIncludeImageAttr() diff -r 382a444f5b0c -r a6931cd6309a mapeditor.cpp --- a/mapeditor.cpp Thu May 14 12:42:58 2009 +0000 +++ b/mapeditor.cpp Fri May 15 15:22:15 2009 +0000 @@ -45,7 +45,6 @@ model=vm; model->setScene (mapScene); model->registerEditor(this); -// model->addMapCenter(); // FIXME-3 create this in MapEditor until BO and MCO are independent of scene model->makeDefault(); // No changes in model so far setScene (mapScene); @@ -58,7 +57,7 @@ CopyCursor=QCursor ( QPixmap(iconPath+"cursorcopy.png"), 1,1 ); XLinkCursor=QCursor ( QPixmap(iconPath+"cursorxlink.png"), 1,7 ); - setFocusPolicy (Qt::StrongFocus); + //setFocusPolicy (Qt::StrongFocus); //FIXME-3 pickingColor=false; drawingLink=false; @@ -75,6 +74,45 @@ //model->reposition(); //FIXME-3 really still needed? + // Shortcuts and actions + QAction *a; + a = new QAction("Select upper branch", this); + a->setShortcut (Qt::Key_Up ); + a->setShortcutContext (Qt::WidgetShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( cursorUp() ) ); + + a = new QAction( "Select lower branch",this); + a->setShortcut ( Qt::Key_Down ); + a->setShortcutContext (Qt::WidgetShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( cursorDown() ) ); + + a = new QAction( "Select left branch", this); + a->setShortcut (Qt::Key_Left ); +// a->setShortcutContext (Qt::WindowShortcut); + a->setShortcutContext (Qt::WidgetWithChildrenShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( cursorLeft() ) ); + + a = new QAction( "Select child branch", this); + a->setShortcut (Qt::Key_Right); + a->setShortcutContext (Qt::WidgetWithChildrenShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( cursorRight() ) ); + + a = new QAction( "Select first branch", this); + a->setShortcut (Qt::Key_Home ); + a->setShortcutContext (Qt::WidgetWithChildrenShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( cursorFirst() ) ); + + a = new QAction( "Select last branch",this); + a->setShortcut ( Qt::Key_End ); + a->setShortcutContext (Qt::WidgetWithChildrenShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( cursorLast() ) ); + // Action to embed LineEdit for heading in Scene editingHeading=false; lineEdit=new QLineEdit; @@ -82,7 +120,7 @@ QGraphicsProxyWidget *pw=scene()->addWidget (lineEdit); pw->setZValue (100); - QAction *a = new QAction( tr( "Edit heading","MapEditor" ), this); + a = new QAction( tr( "Edit heading","MapEditor" ), this); a->setShortcut ( Qt::Key_Return ); //Edit heading addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); @@ -131,10 +169,6 @@ MapEditor::~MapEditor() { //cout <<"Destructor MapEditor for "<<model->getMapName().toStdString()<<endl; - // No need to remove tmp files: - // tmpMapDir is in tmpVymDir, - // so it gets removed automagically when vym closes - model->unregisterEditor(this); } @@ -476,6 +510,38 @@ */ } +void MapEditor::cursorUp() +{ + model->selectUpperBranch(); +} + +void MapEditor::cursorDown() + +{ + model->selectLowerBranch(); +} + +void MapEditor::cursorLeft() +{ + model->selectLeftBranch(); +} + +void MapEditor::cursorRight() +{ + model->selectRightBranch(); +} + +void MapEditor::cursorFirst() +{ + model->selectFirstBranch(); +} + +void MapEditor::cursorLast() +{ + model->selectLastBranch(); +} + + void MapEditor::editHeading() { if (editingHeading) diff -r 382a444f5b0c -r a6931cd6309a mapeditor.h --- a/mapeditor.h Thu May 14 12:42:58 2009 +0000 +++ b/mapeditor.h Fri May 15 15:22:15 2009 +0000 @@ -58,6 +58,12 @@ void testFunction2(); // just testing new stuff public slots: + void cursorUp(); + void cursorDown(); + void cursorLeft(); + void cursorRight(); + void cursorFirst(); + void cursorLast(); void editHeading(); void editHeadingFinished(); private: diff -r 382a444f5b0c -r a6931cd6309a treeeditor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/treeeditor.cpp Fri May 15 15:22:15 2009 +0000 @@ -0,0 +1,52 @@ +#include "treeeditor.h" + +#include <QAction> +#include <iostream> +using namespace std; + +#include "vymmodel.h" + +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// +TreeEditor::TreeEditor(VymModel *m) +{ + //cout << "Constructor TreeEditor "<<this<<endl; + + model=m; + + QAction *a; + // Shortcuts for navigating with cursor: + a = new QAction(tr( "Select upper object","Tree Editor" ), this); + a->setStatusTip ( tr( "Select upper object" )); + a->setShortcut (Qt::Key_Up ); +// a->setShortcutContext (Qt::WindowShortcut); + a->setShortcutContext (Qt::WidgetShortcut); +// a->setShortcutContext (Qt::WidgetWithChildrenShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( cursorUp() ) ); + + a = new QAction( tr( "Select lower object","Tree Editor" ),this); + a->setStatusTip (tr( "Select lower object" )); + a->setShortcut ( Qt::Key_Down ); +// a->setShortcutContext (Qt::WindowShortcut); +// a->setShortcutContext (Qt::WidgetWithChildrenShortcut); + a->setShortcutContext (Qt::WidgetShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( cursorDown() ) ); +} + +TreeEditor::~TreeEditor() +{ + //cout <<"Destructor TreeEditor for "<<model->getMapName().toStdString()<<endl; +} + +void TreeEditor::cursorUp() +{ + model->select (indexAbove (model->getSelectedIndex() )); +} + +void TreeEditor::cursorDown() +{ + model->select (indexBelow (model->getSelectedIndex() )); +} + diff -r 382a444f5b0c -r a6931cd6309a treeeditor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/treeeditor.h Fri May 15 15:22:15 2009 +0000 @@ -0,0 +1,28 @@ +#ifndef TREEEDITOR_H +#define TREEEDITOR_H + +#include <QTreeView> + +class VymModel; + +/*! \brief TreeView widget in vym to display and edit a map, based on + * QTreeView */ + + +class TreeEditor : public QTreeView { + Q_OBJECT + +public: + TreeEditor(VymModel *m); + ~TreeEditor(); + +private slots: + void cursorUp(); + void cursorDown(); + +private: + VymModel *model; +}; + +#endif + diff -r 382a444f5b0c -r a6931cd6309a version.h --- a/version.h Thu May 14 12:42:58 2009 +0000 +++ b/version.h Fri May 15 15:22:15 2009 +0000 @@ -7,7 +7,7 @@ #define __VYM_VERSION "1.13.0" //#define __VYM_CODENAME "Codename: RC-1" #define __VYM_CODENAME "Codename: development version, not for production!" -#define __VYM_BUILD_DATE "2009-05-13" +#define __VYM_BUILD_DATE "2009-05-15" bool checkVersion(const QString &); diff -r 382a444f5b0c -r a6931cd6309a vym.pro --- a/vym.pro Thu May 14 12:42:58 2009 +0000 +++ b/vym.pro Fri May 15 15:22:15 2009 +0000 @@ -78,6 +78,7 @@ showtextdialog.h\ simplescripteditor.h\ texteditor.h \ + treeeditor.h \ version.h \ vymmodel.h \ xlinkobj.h \ @@ -140,6 +141,7 @@ showtextdialog.cpp \ simplescripteditor.cpp \ texteditor.cpp \ + treeeditor.cpp \ treeitem.cpp \ treemodel.cpp \ version.cpp \ diff -r 382a444f5b0c -r a6931cd6309a vymmodel.cpp --- a/vymmodel.cpp Thu May 14 12:42:58 2009 +0000 +++ b/vymmodel.cpp Fri May 15 15:22:15 2009 +0000 @@ -238,7 +238,6 @@ // TODO constr. of FIO creates lots of objects, better do this in some other way... FloatImageObj (mapScene).resetSaveCounter();// FIXME-2 this can be done local to vymmodel maybe... - cout << "VM::saveToDir 0 " <<saveSel<<endl; // Build xml recursivly if (!saveSel || saveSel->getType()==TreeItem::MapCenter) // Save all mapcenters as complete map, if saveSel not set @@ -2211,7 +2210,6 @@ { if (branch && dst) { - cout << "VM::relinkBranch "<<branch->getHeadingStd()<<" to "<<dst->getHeadingStd()<<" at "<<pos<<endl; emit (layoutAboutToBeChanged() ); BranchItem *branchpi=(BranchItem*)branch->parent(); // Remove at current position @@ -4603,11 +4601,16 @@ bool VymModel::select (TreeItem *ti) { - if (ti) + if (ti) return select (index(ti)); + return false; +} + +bool VymModel::select (const QModelIndex &index) +{ + if (index.isValid() ) { - QModelIndex ix=index(ti); - selModel->select (ix,QItemSelectionModel::ClearAndSelect ); - ti->setLastSelectedBranch(); + selModel->select (index,QItemSelectionModel::ClearAndSelect ); + getSelectedItem()->setLastSelectedBranch(); return true; } return false; diff -r 382a444f5b0c -r a6931cd6309a vymmodel.h --- a/vymmodel.h Thu May 14 12:42:58 2009 +0000 +++ b/vymmodel.h Fri May 15 15:22:15 2009 +0000 @@ -552,10 +552,11 @@ void setSelectionBlocked(bool); bool isSelectionBlocked(); - bool select (); // select by using common QItemSlectionModel - bool select (const QString &); // Select by string - bool select (LinkableMapObj *lmo); // Select by pointer tog LMO - bool select (TreeItem *ti ); // Select by point to TreeItem + bool select (); //! select by using common QItemSelectionModel + bool select (const QString &); //! Select by string + bool select (LinkableMapObj *lmo); //! Select by pointer to LMO + bool select (TreeItem *ti ); //! Select by pointer to TreeItem + bool select (const QModelIndex &index); //! Select by ModelIndex void unselect(); void reselect(); diff -r 382a444f5b0c -r a6931cd6309a vymview.cpp --- a/vymview.cpp Thu May 14 12:42:58 2009 +0000 +++ b/vymview.cpp Fri May 15 15:22:15 2009 +0000 @@ -6,6 +6,7 @@ #include "linkablemapobj.h" #include "mainwindow.h" #include "mapeditor.h" +#include "treeeditor.h" extern Main *mainWindow; @@ -15,13 +16,13 @@ model=m; // Create TreeView - treeview=new QTreeView; - treeview->setModel ((QAbstractItemModel*)model); - //treeview->setMinimumWidth (50); + treeEditor=new TreeEditor (model); + treeEditor->setModel ((QAbstractItemModel*)model); + //treeEditor->setMinimumWidth (50); - treeview->setColumnWidth (0,350); + treeEditor->setColumnWidth (0,350); - selModel=treeview->selectionModel(); + selModel=treeEditor->selectionModel(); model->setSelectionModel (selModel); connect ( selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), @@ -62,11 +63,10 @@ this, SLOT (showSelection() ) ); - //mapEditor->viewport()->setFocus(); //FIXmapEditor-3 needed? mapEditor->setAntiAlias (mainWindow->isAliased()); mapEditor->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform()); - addWidget (treeview); + addWidget (treeEditor); addWidget (mapEditor); // Set geometry @@ -76,12 +76,17 @@ setSizes(widths); } +void VymView::initFocus() +{ + mapEditor->setFocus(); +} + QItemSelectionModel* VymView::selectionModel() { - if (treeview) + if (treeEditor) return selModel; else - std::cout <<"VymView::selectionModel: hey, no treeview so far???\n"; + std::cout <<"VymView::selectionModel: hey, no treeEditor so far???\n"; return NULL; } @@ -104,12 +109,12 @@ void VymView::expandAll() { - treeview->expandAll(); + treeEditor->expandAll(); } void VymView::showSelection() { - treeview->scrollTo( + treeEditor->scrollTo( model->getSelectedIndex(), //QAbstractItemView::PositionAtCenter QAbstractItemView::EnsureVisible diff -r 382a444f5b0c -r a6931cd6309a vymview.h --- a/vymview.h Thu May 14 12:42:58 2009 +0000 +++ b/vymview.h Fri May 15 15:22:15 2009 +0000 @@ -3,10 +3,11 @@ #include <QItemSelectionModel> #include <QSplitter> -#include <QTreeView> + class VymModel; class MapEditor; +class TreeEditor; class VymView : public QSplitter @@ -14,6 +15,7 @@ Q_OBJECT public: VymView(VymModel *model); + void initFocus(); QItemSelectionModel* selectionModel(); public slots: @@ -23,7 +25,7 @@ private: VymModel *model; - QTreeView *treeview; + TreeEditor *treeEditor; QItemSelectionModel *selModel; MapEditor *mapEditor; };