* demo/viewer/browser_widget.cc,
* demo/viewer/browser_widget.hh: Improve picture browser.
* demo/viewer/step_widget.cc,
* demo/viewer/step_widget.hh: Add a "step chooser" to load
several XML files related to one picture.
---
scribo/ChangeLog | 5 +
scribo/demo/viewer/browser_widget.cc | 14 ++-
scribo/demo/viewer/browser_widget.hh | 3 +-
scribo/demo/viewer/step_widget.cc | 122 ++++++++++++++++++++
.../src/result_widget.hh => viewer/step_widget.hh} | 47 ++++----
5 files changed, 165 insertions(+), 26 deletions(-)
create mode 100644 scribo/demo/viewer/step_widget.cc
copy scribo/demo/{wizard/src/result_widget.hh => viewer/step_widget.hh} (72%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 43a08c0..1a38228 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -39,8 +39,13 @@
* io/xml/save_text_lines.hh: Rename as...
* io/xml/save.hh: ...this.
+<<<<<<< HEAD:scribo/ChangeLog
* src/pbm_text_in_doc.cc: update call to io::xml::save.
+=======
+
+ * src/pbm_text_in_doc.cc: Update call to io::xml::save.
+>>>>>>> New features in Qt interface.:scribo/ChangeLog
2010-06-18 green <jacquelet(a)lrde.epita.fr>
diff --git a/scribo/demo/viewer/browser_widget.cc b/scribo/demo/viewer/browser_widget.cc
index 7316708..d69fea0 100644
--- a/scribo/demo/viewer/browser_widget.cc
+++ b/scribo/demo/viewer/browser_widget.cc
@@ -17,7 +17,7 @@
BrowserWidget::BrowserWidget(QDirModel* files, QString dir)
: files_(files),
view_(new QListView()),
- path_(new QLabel(""))
+ path_(new QLineEdit(""))
{
QLabel* title = new QLabel(tr("Images"));
title->setAlignment(Qt::AlignHCenter);
@@ -41,6 +41,8 @@ BrowserWidget::BrowserWidget(QDirModel* files, QString dir)
path_->setText(files->filePath(view_->rootIndex()));
connect(view_, SIGNAL(activated(const QModelIndex&)),
this, SLOT(activate(const QModelIndex&)));
+ connect(path_, SIGNAL(returnPressed()),
+ this, SLOT(path_return_pressed()));
QStringList files_filters;
files_filters << "*.png" << "*.jpg"
@@ -49,6 +51,16 @@ BrowserWidget::BrowserWidget(QDirModel* files, QString dir)
}
void
+BrowserWidget::path_return_pressed()
+{
+ QString path = path_->text();
+ QDir d(path);
+
+ if (d.isReadable())
+ activate(files_->index(QString(path)));
+}
+
+void
BrowserWidget::activate(const QModelIndex& index)
{
if (files_->isDir(index))
diff --git a/scribo/demo/viewer/browser_widget.hh b/scribo/demo/viewer/browser_widget.hh
index bba438b..23930cd 100644
--- a/scribo/demo/viewer/browser_widget.hh
+++ b/scribo/demo/viewer/browser_widget.hh
@@ -28,6 +28,7 @@ public:
public slots:
void activate(const QModelIndex& index);
+ void path_return_pressed();
signals:
void activated(QString filename);
@@ -35,7 +36,7 @@ signals:
private:
QDirModel* files_;
QListView* view_;
- QLabel* path_;
+ QLineEdit* path_;
};
#endif /* !BROWSER_WIDGET_HH_ */
diff --git a/scribo/demo/viewer/step_widget.cc b/scribo/demo/viewer/step_widget.cc
new file mode 100644
index 0000000..7d35543
--- /dev/null
+++ b/scribo/demo/viewer/step_widget.cc
@@ -0,0 +1,122 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+# include "step_widget.hh"
+
+StepWidget::StepWidget()
+ : view_(new QListWidget())
+{
+ QLabel* title = new QLabel(tr("Steps"));
+ title->setAlignment(Qt::AlignHCenter);
+
+ QVBoxLayout* layout = new QVBoxLayout;
+
+ layout->addWidget(title);
+ layout->addWidget(view_);
+
+ view_->setSortingEnabled(true);
+
+ setLayout(layout);
+
+ connect(view_, SIGNAL(itemActivated(QListWidgetItem*)),
+ this, SLOT(activate(QListWidgetItem*)));
+}
+
+void StepWidget::activate(QListWidgetItem* item)
+{
+ QString key, value;
+
+ StepQMap::iterator iter = map_.find(item->text());
+
+ if (iter != map_.end())
+ {
+ key = iter.key();
+ value = iter.value();
+ }
+
+ emit load_xml(value);
+
+}
+
+void StepWidget::fill_steps(QString file)
+{
+ view_->clear();
+ map_.clear();
+
+ // image is loaded once
+ emit load_image(file);
+
+ int cut = file.lastIndexOf(QChar('/'));
+ QString path = file.left(cut+1);
+ QString filename = file.mid(cut+1);
+
+ cut = filename.lastIndexOf(QChar('.'));
+ QString file_with_no_ext = filename.left(cut);
+ // view_->addItem(file_with_no_ext);
+
+ QDir dir(path);
+
+ if (dir.isReadable())
+ {
+ QStringList filter;
+ filter << "*.xml";
+ QStringList xml_list = dir.entryList(filter);
+ for (int i = 0; i < xml_list.size(); ++i)
+ {
+ if (xml_list.at(i).startsWith(file_with_no_ext))
+ {
+ cut = xml_list.at(i).lastIndexOf(QChar('.'));
+ QString key = xml_list.at(i).left(cut);
+ key.replace(file_with_no_ext + QString("_"), QString(""));
+ key.replace(QRegExp("^step([0-9])"), "Step \\1");
+ key.replace(QRegExp("^Step ([0-9])_"), "Step \\1 : ");
+ key.replace("_", " ");
+ QString value = path;
+ map_.insertMulti(key, value.append(xml_list.at(i)));
+ view_->addItem(key);
+ }
+ }
+ }
+}
+
+void StepWidget::add_element(const QString& element)
+{
+ view_->addItem(element);
+}
+
+StepWidget::~StepWidget()
+{
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/scribo/demo/wizard/src/result_widget.hh b/scribo/demo/viewer/step_widget.hh
similarity index 72%
copy from scribo/demo/wizard/src/result_widget.hh
copy to scribo/demo/viewer/step_widget.hh
index 4472238..829f814 100644
--- a/scribo/demo/wizard/src/result_widget.hh
+++ b/scribo/demo/viewer/step_widget.hh
@@ -23,36 +23,35 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_DEMO_SHARED_SRC_RESULT_WIDGET_HH
-# define SCRIBO_DEMO_SHARED_SRC_RESULT_WIDGET_HH
-# include <QtGui>
-
-namespace scribo
-{
-
- namespace demo
- {
+#ifndef STEP_WIDGET_HH_
+# define STEP_WIDGET_HH_
+# include <QtGui>
- class result_widget : public QWidget
- {
- Q_OBJECT;
-
- public:
- result_widget(QWidget *parent = 0);
- void reset();
-
- void load(const QString& filename);
+typedef QMap<QString, QString> StepQMap;
- private:
- QTextEdit *text_;
- };
+class StepWidget
+ : public QWidget
+{
+ Q_OBJECT
+public:
+ StepWidget();
+ ~StepWidget();
+ void add_element(const QString& element);
- } // end of namespace scribo::demo
+signals:
+ void load_image(QString);
+ void load_xml(QString);
-} // end of namespace scribo
+public slots:
+ void fill_steps(QString file);
+ void activate(QListWidgetItem* item);
+private:
+ QListWidget* view_;
+ StepQMap map_;
+};
-#endif // ! SCRIBO_DEMO_SHARED_SRC_RESULT_WIDGET_HH
+#endif /* !STEP_WIDGET_HH_ */
--
1.5.6.5