mirror of
https://github.com/webodf/WebODF.git
synced 2026-11-30 16:47:58 +01:00
Add option to open files from the commandline.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <QtGui/QFileSystemModel>
|
||||
#include <QtGui/QTreeView>
|
||||
#include <QtGui/QDockWidget>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
@@ -32,7 +33,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
for (int i = 1; i < dirmodel->columnCount(); i++) {
|
||||
dirview->setColumnHidden(i, true);
|
||||
}
|
||||
QString rootpath = "/home/oever/work/odfkit/odfkit/javascriptzip/kofficetests";
|
||||
QString rootpath = QDir::homePath();
|
||||
dirmodel->setRootPath(rootpath);
|
||||
const QModelIndex rootindex = dirmodel->index(rootpath);
|
||||
dirview->setRootIndex(rootindex);
|
||||
@@ -54,6 +55,25 @@ MainWindow::~MainWindow()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::openFile(const QString& path)
|
||||
{
|
||||
QMdiSubWindow* w = findMdiChild(path);
|
||||
OdfView* v = (w) ?dynamic_cast<OdfView*>(w->widget()) :0;
|
||||
if (v == 0) {
|
||||
w = ui->mdiArea->activeSubWindow();
|
||||
v = (w) ?dynamic_cast<OdfView*>(w->widget()) :0;
|
||||
}
|
||||
if (v == 0) {
|
||||
v = new OdfView(this);
|
||||
v->showMaximized();
|
||||
w = ui->mdiArea->addSubWindow(v);
|
||||
w->showMaximized();
|
||||
}
|
||||
ui->mdiArea->setActiveSubWindow(w);
|
||||
v->loadFile(path);
|
||||
}
|
||||
|
||||
void MainWindow::changeEvent(QEvent *e)
|
||||
{
|
||||
QMainWindow::changeEvent(e);
|
||||
@@ -128,18 +148,5 @@ MainWindow::loadOdf(const QModelIndex& index) {
|
||||
}
|
||||
QString path = dirmodel->filePath(index);
|
||||
path = QFileInfo(path).canonicalFilePath();
|
||||
QMdiSubWindow* w = findMdiChild(path);
|
||||
OdfView* v = (w) ?dynamic_cast<OdfView*>(w->widget()) :0;
|
||||
if (v == 0) {
|
||||
w = ui->mdiArea->activeSubWindow();
|
||||
v = (w) ?dynamic_cast<OdfView*>(w->widget()) :0;
|
||||
}
|
||||
if (v == 0) {
|
||||
v = new OdfView(this);
|
||||
v->showMaximized();
|
||||
w = ui->mdiArea->addSubWindow(v);
|
||||
w->showMaximized();
|
||||
}
|
||||
ui->mdiArea->setActiveSubWindow(w);
|
||||
v->loadFile(path);
|
||||
openFile(path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user