* viewer/viewer.cc,
* viewer/browser_widget.cc,
* viewer/browser_widget.hh:
Browse to the directory taken as first parameter.
* viewer/main.cc:
Add usage info.
---
viewer/browser_widget.cc | 5 ++++-
viewer/browser_widget.hh | 2 +-
viewer/main.cc | 13 ++++++++++++-
viewer/viewer.cc | 3 ++-
4 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/viewer/browser_widget.cc b/viewer/browser_widget.cc
index 643cf2f..24f93ca 100644
--- a/viewer/browser_widget.cc
+++ b/viewer/browser_widget.cc
@@ -14,7 +14,7 @@
#include "browser_widget.hh"
-BrowserWidget::BrowserWidget(QDirModel* files)
+BrowserWidget::BrowserWidget(QDirModel* files, QString dir)
: files_(files),
view_(new QListView()),
path_(new QLabel(""))
@@ -34,6 +34,9 @@ BrowserWidget::BrowserWidget(QDirModel* files)
| QDir::Readable | QDir::Drives);
view_->setRootIndex(files->index(QDir::currentPath()));
+ QDir d(dir);
+ if (d.isReadable())
+ view_->setRootIndex(files->index(d.absolutePath()));
view_->setRowHidden(0, true);
path_->setText(files->filePath(view_->rootIndex()));
connect(view_, SIGNAL(activated(const QModelIndex&)),
diff --git a/viewer/browser_widget.hh b/viewer/browser_widget.hh
index 954115f..bba438b 100644
--- a/viewer/browser_widget.hh
+++ b/viewer/browser_widget.hh
@@ -23,7 +23,7 @@ class BrowserWidget
Q_OBJECT
public:
- BrowserWidget(QDirModel* files);
+ BrowserWidget(QDirModel* files, QString dir = QString());
~BrowserWidget();
public slots:
diff --git a/viewer/main.cc b/viewer/main.cc
index 3bcc590..640ea0f 100644
--- a/viewer/main.cc
+++ b/viewer/main.cc
@@ -13,14 +13,25 @@
//
#include <QtGui>
+#include <iostream>
+
#include "viewer.hh"
int main(int argc, char** argv)
{
+ if (argc > 2 ||
+ (argc == 2 &&
+ (QString(argv[1]) == "--help" || QString(argv[1]) == "-h")))
+ {
+ std::cout << "Usage:" << std::endl
+ << argv[0] << " <image dir>" << std::endl;
+ return 0;
+ }
+
Viewer* viewer = Viewer::Instance(argc, argv);
if (!viewer)
- return 0;
+ return -1;
return viewer->exec();
}
diff --git a/viewer/viewer.cc b/viewer/viewer.cc
index 3b3b188..88d0525 100644
--- a/viewer/viewer.cc
+++ b/viewer/viewer.cc
@@ -119,7 +119,8 @@ Viewer::Viewer(int &argc, char** argv)
PropertyWidget* property_wgt = new PropertyWidget();
XmlWidget* xml_wgt = new XmlWidget();
- BrowserWidget* browser_wgt = new BrowserWidget(files_);
+ BrowserWidget* browser_wgt =
+ new BrowserWidget(files_, argc != 2 ? QString() : argv[1]);
ImageWidget* image_wgt = new ImageWidget(scene_);
key_wgt_ = new KeyWidget(key_map_);
--
1.5.6.5