1.1 Binary file demos/vym-contribute.vym has changed
2.1 --- a/exporthtmldialog.cpp Mon Mar 08 12:22:15 2010 +0000
2.2 +++ b/exporthtmldialog.cpp Mon Mar 08 12:24:26 2010 +0000
2.3 @@ -254,7 +254,7 @@
2.4 settings.setLocalEntry
2.5 (filepath,"/export/html/saveSettingsInMap","yes");
2.6
2.7 - // Provide a smaller URL-icon to improve Layout //FIXME-1 add option to choose this
2.8 + // Provide a smaller URL-icon to improve Layout //FIXME-2 add option to choose this
2.9 QPixmap pm;
2.10 if (!pm.load(ipath,"PNG") )
2.11 QMessageBox::warning( 0, tr( "Warning" ),tr("Could not open %1").arg(ipath));
3.1 --- a/findresultitem.cpp Mon Mar 08 12:22:15 2010 +0000
3.2 +++ b/findresultitem.cpp Mon Mar 08 12:24:26 2010 +0000
3.3 @@ -1,11 +1,15 @@
3.4 #include <QStringList>
3.5
3.6 #include "findresultitem.h"
3.7 +#include "treeitem.h"
3.8 +#include "vymmodel.h"
3.9
3.10 FindResultItem::FindResultItem(const QVector<QVariant> &data, FindResultItem *parent)
3.11 {
3.12 parentItem = parent;
3.13 itemData = data;
3.14 + orgID=-1;
3.15 + orgModel=NULL;
3.16 }
3.17
3.18 FindResultItem::~FindResultItem()
3.19 @@ -41,6 +45,15 @@
3.20 return itemData.value(column);
3.21 }
3.22
3.23 +int FindResultItem::row() const
3.24 +{
3.25 + if (parentItem)
3.26 + return parentItem->childItems.indexOf(const_cast<FindResultItem*>(this));
3.27 +
3.28 + return 0;
3.29 +}
3.30 +
3.31 +
3.32 bool FindResultItem::insertChildren(int position, int count, int columns)
3.33 {
3.34 if (position < 0 || position > childItems.size())
3.35 @@ -107,3 +120,20 @@
3.36 itemData[column] = value;
3.37 return true;
3.38 }
3.39 +
3.40 +void FindResultItem::setOriginal (TreeItem *ti)
3.41 +{
3.42 + orgModel=ti->getModel();
3.43 + orgID=ti->getID();
3.44 +}
3.45 +
3.46 +uint FindResultItem::getOrgID()
3.47 +{
3.48 + return orgID;
3.49 +}
3.50 +
3.51 +VymModel* FindResultItem::getOrgModel()
3.52 +{
3.53 + return orgModel;
3.54 +}
3.55 +
4.1 --- a/findresultitem.h Mon Mar 08 12:22:15 2010 +0000
4.2 +++ b/findresultitem.h Mon Mar 08 12:24:26 2010 +0000
4.3 @@ -5,6 +5,9 @@
4.4 #include <QVariant>
4.5 #include <QVector>
4.6
4.7 +class TreeItem;
4.8 +class VymModel;
4.9 +
4.10 class FindResultItem
4.11 {
4.12 public:
4.13 @@ -15,6 +18,7 @@
4.14 int childCount() const;
4.15 int columnCount() const;
4.16 QVariant data(int column) const;
4.17 + int row() const;
4.18 bool insertChildren(int position, int count, int columns);
4.19 bool insertColumns(int position, int columns);
4.20 FindResultItem *parent();
4.21 @@ -22,11 +26,17 @@
4.22 bool removeColumns(int position, int columns);
4.23 int childNumber() const;
4.24 bool setData(int column, const QVariant &value);
4.25 + void setOriginal (TreeItem *ti);
4.26 + uint getOrgID();
4.27 + VymModel* getOrgModel();
4.28
4.29 private:
4.30 QList<FindResultItem*> childItems;
4.31 QVector<QVariant> itemData;
4.32 FindResultItem *parentItem;
4.33 +
4.34 + uint orgID;
4.35 + VymModel *orgModel;
4.36 };
4.37
4.38 #endif
5.1 --- a/findresultmodel.cpp Mon Mar 08 12:22:15 2010 +0000
5.2 +++ b/findresultmodel.cpp Mon Mar 08 12:24:26 2010 +0000
5.3 @@ -2,23 +2,32 @@
5.4
5.5 #include "findresultitem.h"
5.6 #include "findresultmodel.h"
5.7 +#include "treeitem.h"
5.8
5.9 FindResultModel::FindResultModel( QObject *parent)
5.10 : QAbstractItemModel(parent)
5.11 {
5.12 QVector<QVariant> rootData;
5.13 - rootData << "Foo"<<"bar";
5.14 + rootData << "Heading";
5.15
5.16 rootItem = new FindResultItem(rootData);
5.17 //setupModelData(data.split(QString("\n")), rootItem);
5.18 }
5.19
5.20 -
5.21 FindResultModel::~FindResultModel()
5.22 {
5.23 delete rootItem;
5.24 }
5.25
5.26 +void FindResultModel::clear()
5.27 +{
5.28 + if (rootItem->childCount()>0)
5.29 + {
5.30 + //QModelIndex ix=createIndex(0,0,rootItem);
5.31 + removeRows (0,rowCount (QModelIndex ()));
5.32 + }
5.33 +}
5.34 +
5.35 int FindResultModel::columnCount(const QModelIndex & /* parent */) const
5.36 {
5.37 return rootItem->columnCount();
5.38 @@ -63,6 +72,15 @@
5.39 return QVariant();
5.40 }
5.41
5.42 +QModelIndex FindResultModel::index (FindResultItem *fri)
5.43 +{
5.44 + if (!fri->parent())
5.45 + return QModelIndex();
5.46 + else
5.47 + return createIndex (fri->row(),0,fri);
5.48 +}
5.49 +
5.50 +
5.51 QModelIndex FindResultModel::index(int row, int column, const QModelIndex &parent) const
5.52 {
5.53 if (parent.isValid() && parent.column() != 0)
5.54 @@ -176,54 +194,38 @@
5.55 return result;
5.56 }
5.57
5.58 -void FindResultModel::setupModelData(const QStringList &lines, FindResultItem *parent)
5.59 +void FindResultModel::addItem (TreeItem *ti)
5.60 {
5.61 - QList<FindResultItem*> parents;
5.62 - QList<int> indentations;
5.63 - parents << parent;
5.64 - indentations << 0;
5.65 + if (ti)
5.66 + {
5.67 + QModelIndex ix (index (rootItem));
5.68 + //QAbstractItemModel *resultsModel = view->model();
5.69 +
5.70 + if (!insertRow(ix.row()+1, ix.parent()))
5.71 + return;
5.72
5.73 - int number = 0;
5.74 + for (int column = 0; column < columnCount(ix.parent()); ++column) {
5.75 + QModelIndex child = index(ix.row()+1, column, ix.parent());
5.76 + setData(child, QVariant(ti->getHeading()), Qt::EditRole);
5.77 + getItem(child)->setOriginal (ti);
5.78 + }
5.79 + }
5.80 +}
5.81
5.82 - while (number < lines.count()) {
5.83 - int position = 0;
5.84 - while (position < lines[number].length()) {
5.85 - if (lines[number].mid(position, 1) != " ")
5.86 - break;
5.87 - position++;
5.88 - }
5.89 +void FindResultModel::addItem (const QString &s)
5.90 +{
5.91 + if (!s.isEmpty())
5.92 + {
5.93 + QModelIndex ix ( index (rootItem));
5.94 +
5.95 + if (!insertRow(ix.row()+1, ix.parent()))
5.96 + return;
5.97
5.98 - QString lineData = lines[number].mid(position).trimmed();
5.99 + for (int column = 0; column < columnCount(ix.parent()); ++column) {
5.100 + QModelIndex child = index(ix.row()+1, column, ix.parent());
5.101 + setData(child, QVariant(s), Qt::EditRole);
5.102 + }
5.103 + }
5.104 +}
5.105
5.106 - if (!lineData.isEmpty()) {
5.107 - // Read the column data from the rest of the line.
5.108 - QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
5.109 - QVector<QVariant> columnData;
5.110 - for (int column = 0; column < columnStrings.count(); ++column)
5.111 - columnData << columnStrings[column];
5.112
5.113 - if (position > indentations.last()) {
5.114 - // The last child of the current parent is now the new parent
5.115 - // unless the current parent has no children.
5.116 -
5.117 - if (parents.last()->childCount() > 0) {
5.118 - parents << parents.last()->child(parents.last()->childCount()-1);
5.119 - indentations << position;
5.120 - }
5.121 - } else {
5.122 - while (position < indentations.last() && parents.count() > 0) {
5.123 - parents.pop_back();
5.124 - indentations.pop_back();
5.125 - }
5.126 - }
5.127 -
5.128 - // Append a new item to the current parent's list of children.
5.129 - FindResultItem *parent = parents.last();
5.130 - parent->insertChildren(parent->childCount(), 1, rootItem->columnCount());
5.131 - for (int column = 0; column < columnData.size(); ++column)
5.132 - parent->child(parent->childCount() - 1)->setData(column, columnData[column]);
5.133 - }
5.134 -
5.135 - number++;
5.136 - }
5.137 -}
6.1 --- a/findresultmodel.h Mon Mar 08 12:22:15 2010 +0000
6.2 +++ b/findresultmodel.h Mon Mar 08 12:24:26 2010 +0000
6.3 @@ -6,6 +6,7 @@
6.4 #include <QVariant>
6.5
6.6 class FindResultItem;
6.7 +class TreeItem;
6.8
6.9 class FindResultModel : public QAbstractItemModel
6.10 {
6.11 @@ -14,11 +15,13 @@
6.12 public:
6.13 FindResultModel( QObject *parent = 0);
6.14 ~FindResultModel();
6.15 + void clear();
6.16
6.17 QVariant data(const QModelIndex &index, int role) const;
6.18 QVariant headerData(int section, Qt::Orientation orientation,
6.19 int role = Qt::DisplayRole) const;
6.20
6.21 + QModelIndex index (FindResultItem *fri);
6.22 QModelIndex index(int row, int column,
6.23 const QModelIndex &parent = QModelIndex()) const;
6.24 QModelIndex parent(const QModelIndex &index) const;
6.25 @@ -41,9 +44,12 @@
6.26 bool removeRows(int position, int rows,
6.27 const QModelIndex &parent = QModelIndex());
6.28
6.29 + FindResultItem *getItem(const QModelIndex &index) const;
6.30 +
6.31 + void addItem (TreeItem *ti);
6.32 + void addItem (const QString &s);
6.33 +
6.34 private:
6.35 - void setupModelData(const QStringList &lines, FindResultItem *parent);
6.36 - FindResultItem *getItem(const QModelIndex &index) const;
6.37
6.38 FindResultItem *rootItem;
6.39 };
7.1 --- a/findresultwidget.cpp Mon Mar 08 12:22:15 2010 +0000
7.2 +++ b/findresultwidget.cpp Mon Mar 08 12:24:26 2010 +0000
7.3 @@ -1,54 +1,104 @@
7.4 #include "findresultwidget.h"
7.5
7.6 -#include <QLineEdit>
7.7 #include <QVBoxLayout>
7.8 -#include <QPushButton>
7.9 #include <QTreeView>
7.10
7.11 -#include <QMenuBar>
7.12 -#include <QDebug>
7.13 -
7.14 +#include "findresultitem.h"
7.15 #include "findresultmodel.h"
7.16 +#include "vymmodel.h"
7.17
7.18 extern QString iconPath;
7.19
7.20 -FindResultWidget::FindResultWidget(QWidget *)
7.21 +FindResultWidget::FindResultWidget(VymModel *m, QWidget *)
7.22 {
7.23 - // Create model
7.24 - model=new FindResultModel;
7.25 + model=m;
7.26 +
7.27 + // Create results model
7.28 + resultsModel=new FindResultModel;
7.29
7.30 // Create TreeView
7.31 - view = new QTreeView;
7.32 - view->setModel (model);
7.33 + view = new QTreeView (this);
7.34 + view->setModel (resultsModel);
7.35
7.36 QVBoxLayout* mainLayout = new QVBoxLayout;
7.37 - QHBoxLayout *row2Layout = new QHBoxLayout;
7.38
7.39 - // Create Buttons
7.40 - cancelbutton = new QPushButton;
7.41 - //cancelbutton->setText(tr("Cancel"));
7.42 - cancelbutton->setIcon (QIcon (iconPath+"fileclose.png"));
7.43 - cancelbutton->setShortcut (Qt::Key_Escape);
7.44 - connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
7.45 + // FIXME-4 feature: show number of hits at bottom of FindResultWidget
7.46
7.47 - row2Layout->addWidget (cancelbutton);
7.48 - //row2Layout->addWidget(findcombo);
7.49 - //row2Layout->addWidget(nextbutton);
7.50 -
7.51 - QMenuBar *mb=new QMenuBar;
7.52 + /* FIXME-3 testing QMenuBar *mb=new QMenuBar;
7.53 QAction *a=new QAction ("Foo action",NULL);
7.54 mb->addAction (a);
7.55 mb->insertSeparator();
7.56 mainLayout->addWidget(mb);
7.57 + */
7.58 mainLayout->addWidget(view);
7.59 - mainLayout->addLayout (row2Layout);
7.60
7.61 setLayout (mainLayout);
7.62 +
7.63 + model=m;
7.64 +
7.65 + // Selection
7.66 + connect (view->selectionModel(),SIGNAL (selectionChanged (QItemSelection,QItemSelection)),
7.67 + this, SLOT (updateSelection (QItemSelection,QItemSelection)));
7.68 +}
7.69 +
7.70 +void FindResultWidget::addItem (TreeItem *ti)
7.71 +{
7.72 + if (ti)
7.73 + {
7.74 + QModelIndex index = view->selectionModel()->currentIndex();
7.75 + //QAbstractItemModel *resultsModel = view->model();
7.76 +
7.77 + if (!resultsModel->insertRow(index.row()+1, index.parent()))
7.78 + return;
7.79 +
7.80 + for (int column = 0; column < resultsModel->columnCount(index.parent()); ++column) {
7.81 + QModelIndex child = resultsModel->index(index.row()+1, column, index.parent());
7.82 + resultsModel->setData(child, QVariant(ti->getHeading()), Qt::EditRole);
7.83 + resultsModel->getItem(child)->setOriginal (ti);
7.84 + }
7.85 + }
7.86 +}
7.87 +
7.88 +void FindResultWidget::addItem (const QString &s)
7.89 +{
7.90 + if (!s.isEmpty())
7.91 + {
7.92 + QModelIndex index = view->selectionModel()->currentIndex();
7.93 +
7.94 + if (!resultsModel->insertRow(index.row()+1, index.parent()))
7.95 + return;
7.96 +
7.97 + for (int column = 0; column < resultsModel->columnCount(index.parent()); ++column) {
7.98 + QModelIndex child = resultsModel->index(index.row()+1, column, index.parent());
7.99 + resultsModel->setData(child, QVariant(s), Qt::EditRole);
7.100 + }
7.101 + }
7.102 +}
7.103 +
7.104 +void FindResultWidget::setModel (VymModel *m)
7.105 +{
7.106 + if (model !=NULL && m!=model)
7.107 + qWarning ("FindResultWidget::setModel m!=model");
7.108 + model=m;
7.109 +}
7.110 +
7.111 +FindResultModel* FindResultWidget::getResultModel()
7.112 +{
7.113 + return resultsModel;
7.114 +}
7.115 +
7.116 +void FindResultWidget::addResult (const QString &category, TreeItem *ti)
7.117 +{
7.118 + if (!category.isEmpty())
7.119 + addItem (category);
7.120 + else
7.121 + addItem (model->getSelectedItem());
7.122 }
7.123
7.124 void FindResultWidget::popup()
7.125 {
7.126 show();
7.127 + parentWidget()->show();
7.128 }
7.129
7.130 void FindResultWidget::cancelPressed()
7.131 @@ -56,10 +106,19 @@
7.132 emit (hideFindResultWidget() );
7.133 }
7.134
7.135 -#include <QHideEvent>
7.136 -void FindResultWidget::hideEvent(QHideEvent *event) //FIXME-2 testing only
7.137 +void FindResultWidget::updateSelection(QItemSelection newsel,QItemSelection)
7.138 {
7.139 - qDebug()<<"FRW::hideEvent()";
7.140 - event->ignore();
7.141 + QModelIndex ix;
7.142 + foreach (ix,newsel.indexes() )
7.143 + {
7.144 + FindResultItem *fri= static_cast<FindResultItem*>(ix.internalPointer());
7.145 + if (fri->getOrgModel() && fri->getOrgID()>0)
7.146 + {
7.147 + TreeItem *ti=fri->getOrgModel()->findID(fri->getOrgID() );
7.148 + if (ti)
7.149 + fri->getOrgModel()->select (ti);
7.150 + }
7.151 + }
7.152 }
7.153
7.154 +
8.1 --- a/findresultwidget.h Mon Mar 08 12:22:15 2010 +0000
8.2 +++ b/findresultwidget.h Mon Mar 08 12:24:26 2010 +0000
8.3 @@ -1,34 +1,39 @@
8.4 #ifndef FINDRESULTWIDGET_H
8.5 #define FINDRESULTWIDGET_H
8.6
8.7 +#include <QItemSelection>
8.8 #include <QWidget>
8.9
8.10 +class FindResultModel;
8.11 +class TreeItem;
8.12 +class VymModel;
8.13 class QTreeView;
8.14 class QPushButton;
8.15 -class FindResultModel;
8.16
8.17 class FindResultWidget: public QWidget
8.18 {
8.19 Q_OBJECT
8.20
8.21 public:
8.22 - FindResultWidget (QWidget *parent=NULL);
8.23 + FindResultWidget (VymModel *m=NULL, QWidget *parent=NULL);
8.24 + void setModel (VymModel *m);
8.25 + FindResultModel* getResultModel();
8.26 + void addItem (TreeItem *ti);
8.27 + void addItem (const QString &s);
8.28 + void addResult (const QString &category, TreeItem *ti);
8.29
8.30 public slots:
8.31 void popup();
8.32 void cancelPressed();
8.33 -
8.34 -protected:
8.35 - virtual void hideEvent (QHideEvent *event);
8.36 -
8.37 + void updateSelection(QItemSelection ,QItemSelection);
8.38
8.39 signals:
8.40 void hideFindResultWidget();
8.41
8.42 private:
8.43 - FindResultModel *model;
8.44 + VymModel *model;
8.45 + FindResultModel *resultsModel;
8.46 QTreeView *view;
8.47 - QPushButton *cancelbutton;
8.48 };
8.49
8.50 #endif
9.1 --- a/findwidget.cpp Mon Mar 08 12:22:15 2010 +0000
9.2 +++ b/findwidget.cpp Mon Mar 08 12:24:26 2010 +0000
9.3 @@ -1,3 +1,5 @@
9.4 +#include <QAction>
9.5 +#include <QDebug>
9.6 #include <QLineEdit>
9.7 #include <QVBoxLayout>
9.8 #include <QLabel>
9.9 @@ -9,9 +11,11 @@
9.10
9.11
9.12 #include "findwidget.h"
9.13 +#include "mainwindow.h"
9.14
9.15
9.16 extern QString iconPath;
9.17 +extern Main *mainWindow;
9.18
9.19 FindWidget::FindWidget(QWidget *)
9.20 {
9.21 @@ -44,13 +48,18 @@
9.22 nextbutton->setText (tr("Next","Find widget"));
9.23 nextbutton->setDefault (true);
9.24 nextbutton->setShortcut (Qt::Key_Return);
9.25 - //nextbutton->setShortcutContext (Qt::WidgetShortcut);
9.26 connect ( nextbutton, SIGNAL( clicked() ), this, SLOT( nextPressed() ) );
9.27
9.28 + showAllButton = new QPushButton;
9.29 + showAllButton->setText (tr("Show all","Find widget"));
9.30 + //connect ( showAllButton, SIGNAL( clicked() ), this, SLOT( showAllPressed() ) );
9.31 + connect ( showAllButton, SIGNAL( clicked() ), mainWindow, SLOT( editOpenFindWidget() ) );
9.32 +
9.33 row2Layout->addWidget (cancelbutton);
9.34 row2Layout->addWidget (label);
9.35 row2Layout->addWidget(findcombo);
9.36 row2Layout->addWidget(nextbutton);
9.37 + row2Layout->addWidget(showAllButton);
9.38
9.39 mainLayout->addLayout (row2Layout);
9.40
9.41 @@ -69,7 +78,7 @@
9.42 void FindWidget::cancelPressed()
9.43 {
9.44 hide();
9.45 - emit (hideFindWidget() );
9.46 + emit (hideFindWidget() );//Restore focus
9.47 }
9.48
9.49 void FindWidget::nextPressed()
9.50 @@ -82,6 +91,11 @@
9.51 setStatus (Undefined);
9.52 }
9.53
9.54 +void FindWidget::setFocus()
9.55 +{
9.56 + findcombo->setFocus();
9.57 +}
9.58 +
9.59 void FindWidget::setStatus (Status st)
9.60 {
9.61 if (st==status) return;
10.1 --- a/findwidget.h Mon Mar 08 12:22:15 2010 +0000
10.2 +++ b/findwidget.h Mon Mar 08 12:24:26 2010 +0000
10.3 @@ -3,6 +3,7 @@
10.4
10.5 #include <QWidget>
10.6
10.7 +class QAction;
10.8 class QGroupBox;
10.9 class QComboBox;
10.10 class QPushButton;
10.11 @@ -21,6 +22,7 @@
10.12 void cancelPressed();
10.13 void nextPressed();
10.14 void findTextChanged(const QString&);
10.15 + void setFocus();
10.16 void setStatus (Status st);
10.17
10.18 private:
10.19 @@ -35,6 +37,7 @@
10.20 QGroupBox *findbox;
10.21 QComboBox *findcombo;
10.22 QPushButton *nextbutton;
10.23 + QPushButton *showAllButton;
10.24 QPushButton *cancelbutton;
10.25 };
10.26
11.1 --- a/main.cpp Mon Mar 08 12:22:15 2010 +0000
11.2 +++ b/main.cpp Mon Mar 08 12:24:26 2010 +0000
11.3 @@ -4,6 +4,8 @@
11.4 #include <iostream>
11.5 using namespace std;
11.6
11.7 +#include "findwidget.h"
11.8 +#include "findresultwidget.h"
11.9 #include "flagrow.h"
11.10 #include "flagrowobj.h"
11.11 #include "mainwindow.h"
11.12 @@ -29,10 +31,11 @@
11.13 QString vymInstanceName;
11.14
11.15 Main *mainWindow; // used in BranchObj::select()
11.16 +FindWidget *findWidget;
11.17 +FindResultWidget *findResultWidget;
11.18
11.19 QDBusConnection dbusConnection= QDBusConnection::sessionBus();
11.20
11.21 -
11.22 QString tmpVymDir; // All temp files go there, created in mainwindow
11.23 QString clipboardDir; // Clipboard used in all mapEditors
11.24 QString clipboardFile; // Clipboard used in all mapEditors
12.1 --- a/mainwindow.cpp Mon Mar 08 12:22:15 2010 +0000
12.2 +++ b/mainwindow.cpp Mon Mar 08 12:24:26 2010 +0000
12.3 @@ -12,6 +12,7 @@
12.4 #include "exports.h"
12.5 #include "file.h"
12.6 #include "findresultwidget.h"
12.7 +#include "findwidget.h"
12.8 #include "flagrow.h"
12.9 #include "historywindow.h"
12.10 #include "imports.h"
12.11 @@ -42,6 +43,8 @@
12.12
12.13 extern TextEditor *textEditor;
12.14 extern Main *mainWindow;
12.15 +extern FindWidget *findWidget;
12.16 +extern FindResultWidget *findResultWidget;
12.17 extern QString tmpVymDir;
12.18 extern QString clipboardDir;
12.19 extern QString clipboardFile;
12.20 @@ -124,15 +127,16 @@
12.21 makeSubDirs (clipboardDir);
12.22 clipboardEmpty=true;
12.23
12.24 + // Remember PID of our friendly webbrowser
12.25 browserPID=new qint64;
12.26 *browserPID=0;
12.27
12.28 - // Dock widgets //FIXME-2 testing...
12.29 -
12.30 - FindResultWidget *findResultWidget=new FindResultWidget;
12.31 - QDockWidget *dw= new QDockWidget ("Dock Widget",this);
12.32 + // Dock widgets
12.33 + findResultWidget=new FindResultWidget ();
12.34 + QDockWidget *dw= new QDockWidget (tr ("Search results","FindResultWidget"),this);
12.35 dw->setWidget (findResultWidget);
12.36 - dw->hide();
12.37 + dw->setObjectName ("FindResultWidget");
12.38 + dw->hide();
12.39 addDockWidget (Qt::RightDockWidgetArea,dw);
12.40
12.41 // Satellite windows //////////////////////////////////////////
12.42 @@ -197,12 +201,28 @@
12.43 // width of xLinksMenu
12.44 xLinkMenuWidth=60;
12.45
12.46 + // Create Layout
12.47 + QWidget* centralWidget = new QWidget (this);
12.48 + QVBoxLayout *layout=new QVBoxLayout (centralWidget);
12.49 + setCentralWidget(centralWidget);
12.50 +
12.51 // Create tab widget which holds the maps
12.52 - tabWidget= new QTabWidget (this);
12.53 + tabWidget= new QTabWidget (centralWidget);
12.54 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
12.55 this, SLOT( editorChanged( QWidget * ) ) );
12.56
12.57 - setCentralWidget(tabWidget);
12.58 + // Create findWidget
12.59 + findWidget = new FindWidget (centralWidget);
12.60 + findWidget->hide();
12.61 + layout->addWidget (tabWidget);
12.62 + layout->addWidget (findWidget);
12.63 +
12.64 + connect (
12.65 + findWidget, SIGNAL (nextButton (QString) ),
12.66 + this, SLOT (editFindNext(QString) ) );
12.67 + connect (
12.68 + findWidget , SIGNAL (hideFindWidget() ),
12.69 + this, SLOT (editHideFindWidget() ) );
12.70
12.71 setupFileActions();
12.72 setupEditActions();
12.73 @@ -753,7 +773,7 @@
12.74 a->addTo( tb );
12.75 switchboard.addConnection(a,tr("Edit","Shortcut group"));
12.76 editMenu->addAction (a);
12.77 - actionSortBackChildren=a;
12.78 + actionSortBackChildren=a; //FIXME-2 is toggle action? why?
12.79
12.80 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
12.81 alt->setShortcut ( Qt::Key_S ); // Scroll branch
12.82 @@ -1675,7 +1695,7 @@
12.83 // Test Actions
12.84 void Main::setupTestActions()
12.85 {
12.86 - QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
12.87 + QMenu *testMenu = menuBar()->addMenu( tr( "Test" ));
12.88
12.89 QAction *a;
12.90 a = new QAction( "Test function 1" , this);
12.91 @@ -1905,8 +1925,9 @@
12.92 return NULL;
12.93 }
12.94
12.95 -VymModel* Main::getModel(uint id) const
12.96 +VymModel* Main::getModel(uint id) const //FIXME-2 id not used
12.97 {
12.98 + // Used in BugAgent
12.99 if ( tabWidget->currentPage())
12.100 return vymViews.at(tabWidget->currentIndex())->getModel();
12.101 return NULL;
12.102 @@ -2667,13 +2688,49 @@
12.103 if (m) m->cut();
12.104 }
12.105
12.106 -void Main::editOpenFindWidget()
12.107 +void Main::editOpenFindWidget()
12.108 {
12.109 + if (!findWidget->isVisible())
12.110 + {
12.111 + findWidget->show();
12.112 + findWidget->setFocus();
12.113 + } else if (!findResultWidget->parentWidget()->isVisible())
12.114 + findResultWidget->parentWidget()->show();
12.115 + else
12.116 + {
12.117 + findWidget->hide();
12.118 + findResultWidget->parentWidget()->hide();
12.119 + }
12.120 +}
12.121 +
12.122 +void Main::editHideFindWidget()
12.123 +{
12.124 + // findWidget hides itself, but we want
12.125 + // to have focus back at mapEditor usually
12.126 + MapEditor *me=currentMapEditor();
12.127 + if (me) me->setFocus();
12.128 +}
12.129 +
12.130 +void Main::editFindNext(QString s)
12.131 +{
12.132 + Qt::CaseSensitivity cs=Qt::CaseInsensitive;
12.133 + QTextCursor cursor;
12.134 VymModel *m=currentModel();
12.135 - if (m) m->emitShowFindWidget();
12.136 + if (m)
12.137 + {
12.138 + m->findAll (findResultWidget->getResultModel(),s,cs);
12.139 +
12.140 + BranchItem *bi=m->findText(s, cs,cursor);
12.141 + if (bi)
12.142 + {
12.143 + findWidget->setStatus (FindWidget::Success);
12.144 + }
12.145 + else
12.146 + findWidget->setStatus (FindWidget::Failed);
12.147 + }
12.148 }
12.149
12.150 -void Main::editFindDuplicateURLs()
12.151 +void Main::editFindDuplicateURLs() //FIXME-4 feature: use FindResultWidget for display
12.152 {
12.153 VymModel *m=currentModel();
12.154 if (m) m->findDuplicateURLs();
12.155 @@ -3925,6 +3982,11 @@
12.156
12.157 void Main::testFunction2()
12.158 {
12.159 + findResultWidget->setModel (currentModel());
12.160 + findResultWidget->addResult ("Test",currentModel()->getSelectedItem());
12.161 +
12.162 + return;
12.163 +
12.164 if (!currentMapEditor()) return;
12.165 currentMapEditor()->testFunction2();
12.166 }
13.1 --- a/mainwindow.h Mon Mar 08 12:22:15 2010 +0000
13.2 +++ b/mainwindow.h Mon Mar 08 12:24:26 2010 +0000
13.3 @@ -16,7 +16,6 @@
13.4 #include "texteditor.h"
13.5 #include "vymview.h"
13.6
13.7 -
13.8 class Main : public QMainWindow
13.9 {
13.10 Q_OBJECT
13.11 @@ -123,6 +122,8 @@
13.12 void editPaste();
13.13 void editCut();
13.14 void editOpenFindWidget();
13.15 + void editHideFindWidget();
13.16 + void editFindNext(QString s);
13.17 void editFindDuplicateURLs();
13.18 private:
13.19 void openTabs(QStringList);
14.1 --- a/texteditor.cpp Mon Mar 08 12:22:15 2010 +0000
14.2 +++ b/texteditor.cpp Mon Mar 08 12:24:26 2010 +0000
14.3 @@ -232,12 +232,18 @@
14.4 setFontHint (note.getFontHint() );
14.5 }
14.6
14.7 -bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags)
14.8 +bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags, QTextCursor &cursor)
14.9 {
14.10 if (e->find (t,flags))
14.11 + {
14.12 + cursor=e->textCursor();
14.13 return true;
14.14 + }
14.15 else
14.16 + {
14.17 + cursor=QTextCursor();
14.18 return false;
14.19 + }
14.20 }
14.21
14.22 void TextEditor::setupFileActions()
15.1 --- a/texteditor.h Mon Mar 08 12:22:15 2010 +0000
15.2 +++ b/texteditor.h Mon Mar 08 12:24:26 2010 +0000
15.3 @@ -28,7 +28,7 @@
15.4 NoteObj getNoteObj();
15.5 void setNote(const NoteObj ¬e);
15.6
15.7 - bool findText(const QString &, const QTextDocument::FindFlags &); // find Text
15.8 + bool findText(const QString &, const QTextDocument::FindFlags &,QTextCursor &cursor);
15.9
15.10 protected:
15.11 void setupFileActions();
16.1 --- a/version.h Mon Mar 08 12:22:15 2010 +0000
16.2 +++ b/version.h Mon Mar 08 12:24:26 2010 +0000
16.3 @@ -7,7 +7,7 @@
16.4 #define __VYM_VERSION "1.13.0"
16.5 //#define __VYM_CODENAME "Codename: RC-1"
16.6 #define __VYM_CODENAME "Codename: development version, not for production!"
16.7 -#define __VYM_BUILD_DATE "2010-02-26"
16.8 +#define __VYM_BUILD_DATE "2010-03-08"
16.9
16.10
16.11 bool checkVersion(const QString &);
17.1 --- a/vymmodel.cpp Mon Mar 08 12:22:15 2010 +0000
17.2 +++ b/vymmodel.cpp Mon Mar 08 12:24:26 2010 +0000
17.3 @@ -12,6 +12,7 @@
17.4 #include "exporthtmldialog.h"
17.5 #include "exportxhtmldialog.h"
17.6 #include "file.h"
17.7 +#include "findresultmodel.h"
17.8 #include "geometry.h" // for addBBox
17.9 #include "mainwindow.h"
17.10 #include "misc.h"
17.11 @@ -1608,7 +1609,24 @@
17.12 }
17.13 }
17.14
17.15 -BranchItem* VymModel::findText (QString s, bool cs)
17.16 +void VymModel::findAll (FindResultModel *rmodel, QString s, Qt::CaseSensitivity cs)
17.17 +{
17.18 + rmodel->clear();
17.19 + BranchItem *cur=NULL;
17.20 + BranchItem *prev=NULL;
17.21 + nextBranch(cur,prev);
17.22 + while (cur)
17.23 + {
17.24 + if (cur->getHeading().contains (s,cs))
17.25 + {
17.26 + rmodel->addItem (cur);
17.27 + }
17.28 + //if (cur->getNote().contains (s,cs)) //FIXME-2 does not detect multiple occurences
17.29 + nextBranch(cur,prev);
17.30 + }
17.31 +}
17.32 +
17.33 +BranchItem* VymModel::findText (QString s,Qt::CaseSensitivity cs,QTextCursor &cursor)
17.34 {
17.35 if (!s.isEmpty() && s!=findString)
17.36 {
17.37 @@ -1617,7 +1635,7 @@
17.38 }
17.39
17.40 QTextDocument::FindFlags flags=0;
17.41 - if (cs) flags=QTextDocument::FindCaseSensitively;
17.42 + if (cs==Qt::CaseSensitive) flags=QTextDocument::FindCaseSensitively;
17.43
17.44 if (!findCurrent)
17.45 { // Nothing found or new find process
17.46 @@ -1638,14 +1656,7 @@
17.47 if (findCurrent->getNote().contains(findString,cs))
17.48 {
17.49 select (findCurrent);
17.50 - /*
17.51 - if (getSelectedBranch()!=itFind)
17.52 - {
17.53 - select(itFind);
17.54 - emitShowSelection();
17.55 - }
17.56 - */
17.57 - if (textEditor->findText(findString,flags))
17.58 + if (textEditor->findText(findString,flags,cursor))
17.59 {
17.60 searching=false;
17.61 foundNote=true;
17.62 @@ -1663,7 +1674,6 @@
17.63 if (!nextBranch(findCurrent,findPrevious) )
17.64 EOFind=true;
17.65 }
17.66 - //cout <<"still searching... "<<qPrintable( itFind->getHeading())<<endl;
17.67 }
17.68 if (!searching)
17.69 return getSelectedBranch();
17.70 @@ -1679,11 +1689,6 @@
17.71 EOFind=false;
17.72 }
17.73
17.74 -void VymModel::emitShowFindWidget()
17.75 -{
17.76 - emit (showFindWidget());
17.77 -}
17.78 -
17.79 void VymModel::setScene (QGraphicsScene *s)
17.80 {
17.81 mapScene=s;
17.82 @@ -2549,7 +2554,7 @@
17.83 if (selbi->depth()<2) return;
17.84
17.85 pi=(BranchItem*)(selbi->parent());
17.86 - // Check if we have childs at all to keep
17.87 + // Check if we have children at all to keep
17.88 if (selbi->branchCount()==0)
17.89 {
17.90 deleteSelection();
18.1 --- a/vymmodel.h Mon Mar 08 12:22:15 2010 +0000
18.2 +++ b/vymmodel.h Mon Mar 08 12:24:26 2010 +0000
18.3 @@ -7,6 +7,8 @@
18.4 #include <QtDBus/QDBusAbstractAdaptor>
18.5 #include <QtDBus/QDBusVariant>
18.6
18.7 +#include <QTextCursor>
18.8 +
18.9 #include "adaptormodel.h"
18.10 #include "file.h"
18.11 #include "imageitem.h"
18.12 @@ -17,6 +19,7 @@
18.13
18.14 class AttributeItem;
18.15 class BranchItem;
18.16 +class FindResultModel;
18.17 class MapEditor;
18.18 class XLinkItem;
18.19
18.20 @@ -269,13 +272,11 @@
18.21
18.22 public:
18.23 void findDuplicateURLs(); // find duplicate URLs, testing only so far
18.24 - BranchItem* findText(QString,bool); // Find object
18.25 + void findAll (FindResultModel*, QString s, Qt::CaseSensitivity cs); // Search all objects at once, also notes
18.26 + BranchItem* findText(QString s,Qt::CaseSensitivity cs,QTextCursor &cursor); // Find object, also in note
18.27 void findReset(); // Reset Search
18.28 - void emitShowFindWidget(); // Tell views to show FindWidget
18.29 private:
18.30 QString findString;
18.31 -signals:
18.32 - void showFindWidget();
18.33
18.34 public:
18.35 void setURL(const QString &url);
19.1 --- a/vymview.cpp Mon Mar 08 12:22:15 2010 +0000
19.2 +++ b/vymview.cpp Mon Mar 08 12:24:26 2010 +0000
19.3 @@ -1,7 +1,6 @@
19.4 #include "vymview.h"
19.5
19.6 #include "branchitem.h"
19.7 -#include "findwidget.h"
19.8 #include "mainwindow.h"
19.9 #include "mapeditor.h"
19.10 #include "treeeditor.h"
19.11 @@ -13,10 +12,6 @@
19.12 {
19.13 model=m;
19.14
19.15 - // Create findWidget
19.16 - findWidget=new FindWidget (this);
19.17 - findWidget->hide();
19.18 -
19.19 // Create TreeView
19.20 treeEditor=new TreeEditor (model);
19.21 //treeEditor->setModel ((QAbstractItemModel*)model);
19.22 @@ -25,10 +20,8 @@
19.23 treeEditor->setColumnWidth (0,150);
19.24 treeEditor->setAnimated (true);
19.25
19.26 - // FIXME-3 use proxySelModel=treeEditor->selectionModel();
19.27 selModel=new QItemSelectionModel (model);
19.28
19.29 - //model->setSelectionModel (proxySelModel);
19.30 model->setSelectionModel (selModel);
19.31 treeEditor->setSelectionModel (selModel);
19.32
19.33 @@ -37,26 +30,15 @@
19.34 if (!mapEditor) mapEditor=new MapEditor (model);
19.35
19.36 // Create Layout
19.37 - QVBoxLayout* mainLayout = new QVBoxLayout (this);
19.38 - QSplitter *splitter= new QSplitter;
19.39 + QVBoxLayout* mainLayout = new QVBoxLayout (this); //FIXME-4 not needed
19.40 + QSplitter *splitter= new QSplitter (this);
19.41
19.42 QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
19.43 - //sizePolicy.setHorizontalStretch(0);
19.44 - //sizePolicy.setVerticalStretch(0);
19.45 - //sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth());
19.46 splitter->setSizePolicy(sizePolicy);
19.47 mainLayout->addWidget (splitter);
19.48 - mainLayout->addWidget (findWidget);
19.49
19.50 // Connect selections
19.51
19.52 - // Proxymodel changed
19.53 - /*
19.54 - connect (
19.55 - proxySelModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
19.56 - this,SLOT (changeProxySelection(const QItemSelection &,const QItemSelection &)));
19.57 -*/
19.58 -
19.59 // Selection in Model changed
19.60 connect (
19.61 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
19.62 @@ -103,19 +85,6 @@
19.63 model, SIGNAL (showSelection() ),
19.64 this, SLOT (showSelection() ) );
19.65
19.66 - // Find
19.67 - connect (
19.68 - model, SIGNAL (showFindWidget() ),
19.69 - this, SLOT (showFindWidget() ) );
19.70 -
19.71 - connect (
19.72 - findWidget , SIGNAL (hideFindWidget() ),
19.73 - this, SLOT (hideFindWidget() ) );
19.74 -
19.75 - connect (
19.76 - findWidget, SIGNAL (nextButton (QString) ),
19.77 - this, SLOT (findNext(QString) ) );
19.78 -
19.79 mapEditor->setAntiAlias (mainWindow->isAliased());
19.80 mapEditor->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
19.81
19.82 @@ -159,11 +128,6 @@
19.83 if (newsel.indexes().count()>0)
19.84 {
19.85
19.86 - /* FIXME-3 use proxymodel
19.87 - proxySelModel->select (
19.88 - treeEditor->getProxyModel()->mapSelectionFromSource (newsel),
19.89 - QItemSelectionModel::ClearAndSelect );
19.90 - */
19.91
19.92 QModelIndex ix=newsel.indexes().first();
19.93 selModel->setCurrentIndex (ix,QItemSelectionModel::ClearAndSelect );
19.94 @@ -173,30 +137,6 @@
19.95 }
19.96 }
19.97
19.98 -void VymView::changeProxySelection (const QItemSelection &newsel, const QItemSelection &)
19.99 -{
19.100 - // Notify mainwindow to update satellites, but map selection to
19.101 - // original model first
19.102 -
19.103 - //cout << "VV::changeProxySelection newsel.count="<<newsel.indexes().count()<<endl;
19.104 - if (!newsel.indexes().isEmpty())
19.105 - {
19.106 - /* FIXME-3 need to set current, too
19.107 - */
19.108 - proxySelModel->setCurrentIndex (
19.109 - newsel.indexes().first(),
19.110 - QItemSelectionModel::ClearAndSelect );
19.111 - treeEditor->setCurrentIndex (newsel.indexes().first() );
19.112 - }
19.113 -
19.114 - // Re-emit but map selection first
19.115 - selModel->select (
19.116 - treeEditor->getProxyModel()->mapSelectionToSource (newsel),
19.117 - QItemSelectionModel::ClearAndSelect );
19.118 -
19.119 - showSelection();
19.120 -}
19.121 -
19.122 void VymView::expandAll()
19.123 {
19.124 treeEditor->expandAll();
19.125 @@ -214,7 +154,6 @@
19.126 model->nextBranch(cur,prev);
19.127 while (cur)
19.128 {
19.129 - // FIXME-3 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
19.130 pix=model->index (cur);
19.131 d=cur->depth();
19.132 if (!treeEditor->isExpanded(pix) && d < level)
19.133 @@ -228,7 +167,6 @@
19.134 model->nextBranch(cur,prev);
19.135 while (cur)
19.136 {
19.137 - // FIXME-3 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
19.138 pix=model->index (cur);
19.139 d=cur->depth();
19.140 if (!treeEditor->isExpanded(pix) && d <= level && cur->branchCount()>0)
19.141 @@ -258,7 +196,6 @@
19.142 model->nextBranch(cur,prev);
19.143 while (cur)
19.144 {
19.145 - // FIXME-3 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
19.146 pix=model->index (cur);
19.147 d=cur->depth();
19.148 if (treeEditor->isExpanded(pix) && d > level)
19.149 @@ -272,7 +209,6 @@
19.150 model->nextBranch(cur,prev);
19.151 while (cur)
19.152 {
19.153 - // FIXME-3 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
19.154 pix=model->index (cur);
19.155 d=cur->depth();
19.156 if (treeEditor->isExpanded(pix) && d >= level)
19.157 @@ -288,34 +224,6 @@
19.158 mapEditor->scrollTo ( ix); // FIXME-3 also called from MapEditor::updateSelection...
19.159 }
19.160
19.161 -void VymView::showFindWidget()
19.162 -{
19.163 - findWidget->popup();
19.164 -}
19.165 -
19.166 -void VymView::hideFindWidget()
19.167 -{
19.168 - // findWidget hides itself, but we want to have focus back at mapEditor usually
19.169 - if (mapEditor) mapEditor->setFocus();
19.170 -}
19.171 -
19.172 -void VymView::findNext (QString s)
19.173 -{
19.174 - bool cs=false;
19.175 - BranchItem *bi=model->findText(s, cs);
19.176 - if (bi)
19.177 - findWidget->setStatus (FindWidget::Success);
19.178 - else
19.179 - findWidget->setStatus (FindWidget::Failed);
19.180 -
19.181 -}
19.182 -
19.183 -void VymView::findReset()
19.184 -{
19.185 - model->findReset();
19.186 - if (mapEditor) mapEditor->setFocus();
19.187 -}
19.188 -
19.189 void VymView::toggleTreeEditor()
19.190 {
19.191 if (treeEditor->isVisible() )
20.1 --- a/vymview.h Mon Mar 08 12:22:15 2010 +0000
20.2 +++ b/vymview.h Mon Mar 08 12:24:26 2010 +0000
20.3 @@ -7,7 +7,6 @@
20.4 class VymModel;
20.5 class MapEditor;
20.6 class TreeEditor;
20.7 -class FindWidget;
20.8
20.9 class QTreeView;
20.10
20.11 @@ -23,24 +22,17 @@
20.12
20.13 public slots:
20.14 void changeSelection (const QItemSelection &newSel, const QItemSelection &delSel);
20.15 - void changeProxySelection (const QItemSelection &newSel, const QItemSelection &delSel);
20.16 void expandAll ();
20.17 void expandOneLevel ();
20.18 void collapseOneLevel ();
20.19 void showSelection ();
20.20 - void showFindWidget();
20.21 - void hideFindWidget();
20.22 - void findNext (QString s);
20.23 - void findReset();
20.24 void toggleTreeEditor();
20.25
20.26 private:
20.27 VymModel *model;
20.28 TreeEditor *treeEditor;
20.29 - QItemSelectionModel *proxySelModel;
20.30 QItemSelectionModel *selModel;
20.31 MapEditor *mapEditor;
20.32 - FindWidget *findWidget;
20.33 };
20.34
20.35