# HG changeset patch # User insilmaril # Date 1254489895 0 # Node ID f076fdec767d0b48ab4e5b1abd0a529d72426c6f # Parent 16a8ef1d82b29cfd970c67eb5da579aa7822c128 More fixes for using proxy diff -r 16a8ef1d82b2 -r f076fdec767d mainwindow.cpp --- a/mainwindow.cpp Fri Oct 02 09:40:57 2009 +0000 +++ b/mainwindow.cpp Fri Oct 02 13:24:55 2009 +0000 @@ -138,10 +138,6 @@ connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag())); connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions())); - // Connect HistoryWindow, so that we can update flags - connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions())); - - // Initialize script editor scriptEditor = new SimpleScriptEditor(); scriptEditor->move (50,50); @@ -1066,7 +1062,7 @@ a = new QAction(tr( "Antialiasing","View action" ),this ); a->setStatusTip ( tr( "Antialiasing" )); a->setToggleAction(true); - a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool()); + a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool()); viewMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) ); actionViewToggleAntiAlias=a; @@ -1074,7 +1070,7 @@ a = new QAction(tr( "Smooth pixmap transformations","View action" ),this ); a->setStatusTip (a->text()); a->setToggleAction(true); - a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool()); + a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool()); viewMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) ); actionViewToggleSmoothPixmapTransform=a; @@ -1108,7 +1104,7 @@ a->setStatusTip ( tr( "Use modifier to color branches" )); a->setToggleAction(true); a->addTo (tb); - a->setOn(true); + a->setChecked(true); actionModModeColor=a; a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes ); @@ -1399,7 +1395,7 @@ a = new QAction( tr( "Autosave","Settings action"), this); a->setStatusTip( tr( "Autosave")); a->setToggleAction(true); - a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool()); + a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool()); connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) ); settingsMenu->addAction (a); actionSettingsAutosaveToggle=a; @@ -1413,7 +1409,7 @@ a = new QAction( tr( "Write backup file on save","Settings action"), this); a->setStatusTip( tr( "Write backup file on save")); a->setToggleAction(true); - a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool()); + a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool()); connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) ); settingsMenu->addAction (a); actionSettingsWriteBackupFile=a; @@ -1423,28 +1419,28 @@ a = new QAction( tr( "Edit branch after adding it","Settings action" ), this ); a->setStatusTip( tr( "Edit branch after adding it" )); a->setToggleAction(true); - a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool()); + a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool()); settingsMenu->addAction (a); actionSettingsAutoEditNewBranch=a; a= new QAction( tr( "Select branch after adding it","Settings action" ), this ); a->setStatusTip( tr( "Select branch after adding it" )); a->setToggleAction(true); - a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() ); + a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() ); settingsMenu->addAction (a); actionSettingsAutoSelectNewBranch=a; a= new QAction(tr( "Select existing heading","Settings action" ), this); a->setStatusTip( tr( "Select heading before editing" )); a->setToggleAction(true); - a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() ); + a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() ); settingsMenu->addAction (a); actionSettingsAutoSelectText=a; a= new QAction( tr( "Delete key","Settings action" ), this); a->setStatusTip( tr( "Delete key for deleting branches" )); a->setToggleAction(true); - a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() ); + a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() ); settingsMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) ); actionSettingsUseDelKey=a; @@ -1452,21 +1448,21 @@ a= new QAction( tr( "Exclusive flags","Settings action" ), this); a->setStatusTip( tr( "Use exclusive flags in flag toolbars" )); a->setToggleAction(true); - a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() ); + a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() ); settingsMenu->addAction (a); actionSettingsUseFlagGroups=a; a= new QAction( tr( "Use hide flags","Settings action" ), this); a->setStatusTip( tr( "Use hide flag during exports " )); a->setToggleAction(true); - a->setOn ( settings.value ("/export/useHideExport",true).toBool() ); + a->setChecked ( settings.value ("/export/useHideExport",true).toBool() ); settingsMenu->addAction (a); actionSettingsUseHideExport=a; a = new QAction( tr( "Animation","Settings action"), this); a->setStatusTip( tr( "Animation")); a->setToggleAction(true); - a->setOn (settings.value("/animation/use",false).toBool() ); + a->setChecked (settings.value("/animation/use",true).toBool() ); connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) ); settingsMenu->addAction (a); actionSettingsUseAnimation=a; @@ -2992,7 +2988,7 @@ if (m) { m->setMapLinkStyle("StyleLine"); - actionFormatLinkStyleLine->setOn(true); + actionFormatLinkStyleLine->setChecked(true); } } @@ -3002,7 +2998,7 @@ if (m) { m->setMapLinkStyle("StyleParabel"); - actionFormatLinkStyleParabel->setOn(true); + actionFormatLinkStyleParabel->setChecked(true); } } @@ -3012,7 +3008,7 @@ if (m) { m->setMapLinkStyle("StylePolyLine"); - actionFormatLinkStylePolyLine->setOn(true); + actionFormatLinkStylePolyLine->setChecked(true); } } @@ -3022,7 +3018,7 @@ if (m) { m->setMapLinkStyle("StylePolyParabel"); - actionFormatLinkStylePolyParabel->setOn(true); + actionFormatLinkStylePolyParabel->setChecked(true); } } @@ -3327,6 +3323,11 @@ void Main::updateActions() { + // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed + actionViewToggleNoteEditor->setChecked (textEditor->isVisible()); + actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible()); + actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible()); + VymModel *m =currentModel(); if (m) { @@ -3337,16 +3338,16 @@ switch (m->getMapLinkStyle()) { case LinkableMapObj::Line: - actionFormatLinkStyleLine->setOn(true); + actionFormatLinkStyleLine->setChecked(true); break; case LinkableMapObj::Parabel: - actionFormatLinkStyleParabel->setOn(true); + actionFormatLinkStyleParabel->setChecked(true); break; case LinkableMapObj::PolyLine: - actionFormatLinkStylePolyLine->setOn(true); + actionFormatLinkStylePolyLine->setChecked(true); break; case LinkableMapObj::PolyParabel: - actionFormatLinkStylePolyParabel->setOn(true); + actionFormatLinkStylePolyParabel->setChecked(true); break; default: break; @@ -3370,15 +3371,10 @@ actionFilePrint->setEnabled (false); } - // updateActions is also called when NoteEditor is closed - actionViewToggleNoteEditor->setOn (textEditor->isVisible()); - actionViewToggleHistoryWindow->setOn (historyWindow->isVisible()); - actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible()); - if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor) - actionFormatLinkColorHint->setOn(true); + actionFormatLinkColorHint->setChecked(true); else - actionFormatLinkColorHint->setOn(false); + actionFormatLinkColorHint->setChecked(false); if (m && m->hasChanged() ) @@ -3403,7 +3399,7 @@ { if (selbi || selti->getType()==TreeItem::Image) { - actionFormatHideLinkUnselected->setOn (((MapItem*)selti)->getHideLinkUnselected()); + actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected()); actionFormatHideLinkUnselected->setEnabled (true); } @@ -3435,9 +3431,9 @@ // System Flags actionToggleScroll->setEnabled (true); if ( selbi->isScrolled() ) - actionToggleScroll->setOn(true); + actionToggleScroll->setChecked(true); else - actionToggleScroll->setOn(false); + actionToggleScroll->setChecked(false); if ( selti->getURL().isEmpty() ) { @@ -3471,7 +3467,7 @@ actionSortChildren->setEnabled (true); actionToggleHideExport->setEnabled (true); - actionToggleHideExport->setOn (selbi->hideInExport() ); + actionToggleHideExport->setChecked (selbi->hideInExport() ); actionCopy->setEnabled (true); actionCut->setEnabled (true); @@ -3489,7 +3485,7 @@ actionOpenVymLink->setEnabled (false); actionDeleteVymLink->setEnabled (false); actionToggleHideExport->setEnabled (true); - actionToggleHideExport->setOn (selti->hideInExport() ); + actionToggleHideExport->setChecked (selti->hideInExport() ); actionCopy->setEnabled (true); @@ -3547,14 +3543,14 @@ { textEditor->setShowWithMain(true); textEditor->show(); - actionViewToggleNoteEditor->setOn (true); + actionViewToggleNoteEditor->setChecked (true); } void Main::windowHideNoteEditor() { textEditor->setShowWithMain(false); textEditor->hide(); - actionViewToggleNoteEditor->setOn (false); + actionViewToggleNoteEditor->setChecked (false); } void Main::setScript (const QString &script) diff -r 16a8ef1d82b2 -r f076fdec767d mapeditor.cpp --- a/mapeditor.cpp Fri Oct 02 09:40:57 2009 +0000 +++ b/mapeditor.cpp Fri Oct 02 13:24:55 2009 +0000 @@ -185,7 +185,7 @@ return mapScene; } -void MapEditor::scrollTo (const QModelIndex &index) //FIXME-1 problems with locating stuff in big maps +void MapEditor::scrollTo (const QModelIndex &index) { if (index.isValid()) { @@ -196,7 +196,8 @@ if (lmo) { QRectF r=lmo->getBBox(); - setScrollBarPosTarget (lmo->getBBox() ); + if (debug) cout << "ME::scrollTo "<getHeadingStd()<<" bbox="<value(); qreal bottom = top + height; + scrollBarPosTarget=getScrollBarPos(); + if (viewRect.left() <= left + xmargin) { // need to scroll from the left // if (!d->leftIndent) @@ -237,17 +240,24 @@ scrollBarPosTarget.setY(int(viewRect.bottom() - height + ymargin + 0.5)); } + if (scrollBarPosTarget==getScrollBarPos()) return; + if (scrollBarPosAnimation.state()==QtAbstractAnimation::Running) scrollBarPosAnimation.stop(); - scrollBarPosAnimation.setTargetObject (this); - scrollBarPosAnimation.setPropertyName ("scrollBarPos"); - scrollBarPosAnimation.setDuration(1000); - scrollBarPosAnimation.setEasingCurve ( QtEasingCurve::OutQuint); - scrollBarPosAnimation.setStartValue( - QPointF (horizontalScrollBar()->value() , - verticalScrollBar()->value() ) ); - scrollBarPosAnimation.setEndValue(scrollBarPosTarget); - scrollBarPosAnimation.start(); + + if (settings.value ("/animation/use/",true).toBool() ) + { + scrollBarPosAnimation.setTargetObject (this); + scrollBarPosAnimation.setPropertyName ("scrollBarPos"); + scrollBarPosAnimation.setDuration(1000); + scrollBarPosAnimation.setEasingCurve ( QtEasingCurve::OutQuint); + scrollBarPosAnimation.setStartValue( + QPointF (horizontalScrollBar()->value() , + verticalScrollBar()->value() ) ); + scrollBarPosAnimation.setEndValue(scrollBarPosTarget); + scrollBarPosAnimation.start(); + } else + setScrollBarPos (scrollBarPosTarget); } QPointF MapEditor::getScrollBarPosTarget() @@ -265,7 +275,8 @@ QPointF MapEditor::getScrollBarPos() { - return scrollBarPos; + return QPointF (horizontalScrollBar()->value(),verticalScrollBar()->value()); + //return scrollBarPos; } void MapEditor::setZoomFactorTarget (const qreal &zft) @@ -273,14 +284,18 @@ zoomFactorTarget=zft; if (zoomAnimation.state()==QtAbstractAnimation::Running) zoomAnimation.stop(); - //zoomAnimation=QtPropertyAnimation(this, "zoomFactor"); - zoomAnimation.setTargetObject (this); - zoomAnimation.setPropertyName ("zoomFactor"); - zoomAnimation.setDuration(1000); - zoomAnimation.setEasingCurve ( QtEasingCurve::OutQuint); - zoomAnimation.setStartValue(zoomFactor); - zoomAnimation.setEndValue(zft); - zoomAnimation.start(); + if (settings.value ("/animation/use/",true).toBool() ) + { + //zoomAnimation=QtPropertyAnimation(this, "zoomFactor"); + zoomAnimation.setTargetObject (this); + zoomAnimation.setPropertyName ("zoomFactor"); + zoomAnimation.setDuration(1000); + zoomAnimation.setEasingCurve ( QtEasingCurve::OutQuint); + zoomAnimation.setStartValue(zoomFactor); + zoomAnimation.setEndValue(zft); + zoomAnimation.start(); + } else + setZoomFactor (zft); } qreal MapEditor::getZoomFactorTarget() @@ -1483,7 +1498,12 @@ void MapEditor::mouseDoubleClickEvent(QMouseEvent* e) { - if (debug) cout << "ME p="<pos())< -using namespace std; +//! [3] bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { - return true; -cout << "MSFPM sM="<index(sourceRow, 0, sourceParent); QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent); + QModelIndex index2 = sourceModel()->index(sourceRow, 2, sourceParent); - return (sourceModel()->data(index0).toString().contains(filterRegExp()) ); + return (sourceModel()->data(index0).toString().contains(filterRegExp()) + || sourceModel()->data(index1).toString().contains(filterRegExp())) + && dateInRange(sourceModel()->data(index2).toDate()); } +//! [3] -/* +//! [4] //! [5] bool MySortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { QVariant leftData = sourceModel()->data(left); QVariant rightData = sourceModel()->data(right); +//! [4] + +//! [6] if (leftData.type() == QVariant::DateTime) { return leftData.toDateTime() < rightData.toDateTime(); } else { @@ -91,9 +105,12 @@ return QString::localeAwareCompare(leftString, rightString) < 0; } } +//! [5] //! [6] + +//! [7] bool MySortFilterProxyModel::dateInRange(const QDate &date) const { return (!minDate.isValid() || date > minDate) && (!maxDate.isValid() || date < maxDate); } -*/ +//! [7] diff -r 16a8ef1d82b2 -r f076fdec767d mysortfilterproxymodel.h --- a/mysortfilterproxymodel.h Fri Oct 02 09:40:57 2009 +0000 +++ b/mysortfilterproxymodel.h Fri Oct 02 13:24:55 2009 +0000 @@ -1,37 +1,41 @@ /**************************************************************************** ** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the example classes of the Qt Toolkit. +** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -49,15 +53,15 @@ public: MySortFilterProxyModel(QObject *parent = 0); - // QDate filterMinimumDate() const { return minDate; } -// void setFilterMinimumDate(const QDate &date); + QDate filterMinimumDate() const { return minDate; } + void setFilterMinimumDate(const QDate &date); -// QDate filterMaximumDate() const { return maxDate; } -// void setFilterMaximumDate(const QDate &date); + QDate filterMaximumDate() const { return maxDate; } + void setFilterMaximumDate(const QDate &date); protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; -// bool lessThan(const QModelIndex &left, const QModelIndex &right) const; + bool lessThan(const QModelIndex &left, const QModelIndex &right) const; private: bool dateInRange(const QDate &date) const; diff -r 16a8ef1d82b2 -r f076fdec767d treeeditor.cpp --- a/treeeditor.cpp Fri Oct 02 09:40:57 2009 +0000 +++ b/treeeditor.cpp Fri Oct 02 13:24:55 2009 +0000 @@ -16,15 +16,11 @@ { model=m; -/* -*/ // MySortFilterProxyModel *proxyModel = new MySortFilterProxyModel(this); // FIXME-1 trying to use proxy... proxyModel = new QSortFilterProxyModel (this); -// proxyModel->setDynamicSortFilter (false); setModel(proxyModel); proxyModel->setSourceModel(model); -// setModel(model); QAction *a; // Shortcuts for navigating with cursor: diff -r 16a8ef1d82b2 -r f076fdec767d version.h --- a/version.h Fri Oct 02 09:40:57 2009 +0000 +++ b/version.h Fri Oct 02 13:24:55 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-10-01" +#define __VYM_BUILD_DATE "2009-10-02" bool checkVersion(const QString &); diff -r 16a8ef1d82b2 -r f076fdec767d vymview.cpp --- a/vymview.cpp Fri Oct 02 09:40:57 2009 +0000 +++ b/vymview.cpp Fri Oct 02 13:24:55 2009 +0000 @@ -124,7 +124,9 @@ // original model first // Re-emit but map selection first - model->emitSelectionChanged (treeEditor->getProxyModel()->mapSelectionToSource (newsel)); + selModel->select (treeEditor->getProxyModel()->mapSelectionToSource (newsel), + QItemSelectionModel::ClearAndSelect ); + //showSelection(); } void VymView::expandAll()