lineedit for setting the rootpath

crude but effective :)
This commit is contained in:
Chani Armitage
2010-06-29 03:23:37 -07:00
parent 7feaef6193
commit d365eae93b
2 changed files with 21 additions and 1 deletions
+20 -1
View File
@@ -9,6 +9,9 @@
#include <QtCore/QDir>
#include <QtCore/QDebug>
#include <QVBoxLayout>
#include <QLineEdit>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
@@ -37,11 +40,17 @@ MainWindow::MainWindow(QWidget *parent) :
dirmodel->setRootPath(rootpath);
const QModelIndex rootindex = dirmodel->index(rootpath);
dirview->setRootIndex(rootindex);
QLineEdit *dirPath = new QLineEdit(rootpath, this);
dirdock = new QDockWidget(this);
dirdock->setWidget(dirview);
QWidget *w = new QWidget(dirdock);
QVBoxLayout *layout = new QVBoxLayout(w);
dirdock->setWidget(w);
layout->addWidget(dirPath);
layout->addWidget(dirview);
addDockWidget(Qt::LeftDockWidgetArea, dirdock);
connect(dirview, SIGNAL(clicked(QModelIndex)), this, SLOT(loadOdf(QModelIndex)));
connect(dirPath, SIGNAL(textChanged(QString)), this, SLOT(setPath(QString)));
/*
OdfView *child = createOdfView();
if (child->loadFile("../kofficetests/odf/DanskTest01.odt")) {
@@ -150,3 +159,13 @@ MainWindow::loadOdf(const QModelIndex& index) {
path = QFileInfo(path).canonicalFilePath();
openFile(path);
}
void MainWindow::setPath(const QString &path)
{
dirmodel->setRootPath(path);
const QModelIndex rootindex = dirmodel->index(path);
dirview->setRootIndex(rootindex);
}
+1
View File
@@ -25,6 +25,7 @@ private slots:
void open();
OdfView *createOdfView();
void loadOdf(const QModelIndex& index);
void setPath(const QString &path);
private:
QMdiSubWindow *findMdiChild(const QString &fileName);