[Kst] branches/work/kst/portto4/kst/src
Mike Fenton
mike at staikos.net
Thu Jun 19 18:11:09 CEST 2008
SVN commit 822242 by fenton:
Allow DirFile to function with Directories provider or format file in addition to .cur file.
Add disabled interfaced for providing directories to DataVector.
M +12 -7 datasources/dirfile/dirfile.cpp
M +33 -2 libkstapp/vectordialog.cpp
M +4 -0 libkstapp/vectordialog.h
M +39 -22 libkstapp/vectortab.ui
M +7 -3 widgets/filerequester.cpp
M +3 -0 widgets/filerequester.h
--- branches/work/kst/portto4/kst/src/datasources/dirfile/dirfile.cpp #822241:822242
@@ -296,13 +296,18 @@
QString DirFilePlugin::getDirectory(QString filepath) {
- QString properDirPath = QFileInfo(filepath).path();
- QFile file(filepath);
- if (file.open(QFile::ReadOnly)) {
- QTextStream stream(&file);
- QString directoryName = stream.readLine();
- properDirPath += "/";
- properDirPath += directoryName;
+ QFileInfo info(filepath);
+ QString properDirPath = info.path();
+ if (info.fileName() == "format") {
+ //do nothing... allows for format file to be selected.
+ } else {
+ QFile file(filepath);
+ if (file.open(QFile::ReadOnly)) {
+ QTextStream stream(&file);
+ QString directoryName = stream.readLine();
+ properDirPath += "/";
+ properDirPath += directoryName;
+ }
}
return properDirPath;
}
--- branches/work/kst/portto4/kst/src/libkstapp/vectordialog.cpp #822241:822242
@@ -38,14 +38,22 @@
connect(_readFromSource, SIGNAL(toggled(bool)), this, SLOT(readFromSourceChanged()));
connect(_fileName, SIGNAL(changed(const QString &)), this, SLOT(fileNameChanged(const QString &)));
+ connect(_directoryName, SIGNAL(changed(const QString &)), this, SLOT(fileNameChanged(const QString &)));
connect(_configure, SIGNAL(clicked()), this, SLOT(showConfigWidget()));
+ connect(_useDirectory, SIGNAL(stateChanged(int)), this, SLOT(directorySourceChanged()));
connect(_dataRange, SIGNAL(modified()), this, SIGNAL(modified()));
connect(_numberOfSamples, SIGNAL(valueChanged(int)), this, SIGNAL(modified()));
connect(_from, SIGNAL(textChanged(const QString&)), this, SIGNAL(modified()));
connect(_to, SIGNAL(textChanged(const QString&)), this, SIGNAL(modified()));
_fileName->setFile(QDir::currentPath());
+ _directoryName->setFile(QDir::currentPath());
+ _directoryName->setMode(QFileDialog::DirectoryOnly);
+ //Disable alternate Directory selector.
+ _useDirectory->setVisible(false);
+ _directoryName->setVisible(false);
+
_connect->setVisible(false);
}
@@ -77,7 +85,14 @@
void VectorTab::setFile(const QString &file) {
- _fileName->setFile(file);
+ QFileInfo info(file);
+ if (info.isDir()) {
+ _directoryName->setFile(file);
+ _useDirectory->setChecked(true);
+ } else {
+ _fileName->setFile(file);
+ _useDirectory->setChecked(false);
+ }
}
@@ -162,6 +177,13 @@
}
+void VectorTab::directorySourceChanged() {
+ _fileName->setEnabled(!_useDirectory->isChecked());
+ _directoryName->setEnabled(_useDirectory->isChecked());
+ updateDataSource();
+}
+
+
void VectorTab::hideGeneratedOptions() {
_sourceGroup->setVisible(false);
_generatedVectorGroup->setVisible(false);
@@ -190,9 +212,18 @@
}
+void VectorTab::updateDataSource() {
+ if (_useDirectory->isChecked()) {
+ fileNameChanged(_directoryName->file());
+ } else {
+ fileNameChanged(_fileName->file());
+ }
+}
+
+
void VectorTab::fileNameChanged(const QString &file) {
QFileInfo info(file);
- if (!info.exists() || !info.isFile())
+ if (!info.exists())
return;
_field->clear();
--- branches/work/kst/portto4/kst/src/libkstapp/vectordialog.h #822241:822242
@@ -76,10 +76,14 @@
private Q_SLOTS:
void readFromSourceChanged();
+ void directorySourceChanged();
void fileNameChanged(const QString &file);
void showConfigWidget();
private:
+ void updateDataSource();
+
+ private:
VectorMode _mode;
ObjectStore *_store;
DataSourcePtr _dataSource;
--- branches/work/kst/portto4/kst/src/libkstapp/vectortab.ui #822241:822242
@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>431</width>
- <height>413</height>
+ <width>694</width>
+ <height>579</height>
</rect>
</property>
<layout class="QGridLayout" >
@@ -61,16 +61,6 @@
</layout>
</widget>
</item>
- <item row="2" column="0" >
- <widget class="Kst::DataRange" native="1" name="_dataRange" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="MinimumExpanding" hsizetype="Preferred" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
<item row="1" column="0" >
<widget class="QGroupBox" name="_dataVectorGroup" >
<property name="sizePolicy" >
@@ -83,13 +73,13 @@
<string>Data Vector Parameters</string>
</property>
<layout class="QGridLayout" >
- <item row="1" column="0" >
- <widget class="QLabel" name="label_5" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label_4" >
<property name="text" >
- <string>Field or column:</string>
+ <string>File name:</string>
</property>
<property name="alignment" >
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap" >
<bool>false</bool>
@@ -99,27 +89,44 @@
<item row="0" column="1" >
<widget class="Kst::FileRequester" native="1" name="_fileName" />
</item>
- <item row="0" column="0" >
- <widget class="QLabel" name="label_4" >
+ <item row="1" column="0" >
+ <widget class="QCheckBox" name="_useDirectory" >
+ <property name="layoutDirection" >
+ <enum>Qt::LeftToRight</enum>
+ </property>
<property name="text" >
- <string>File name:</string>
+ <string>Use Directory</string>
</property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="Kst::FileRequester" native="1" name="_directoryName" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="label_5" >
+ <property name="text" >
+ <string>Field or column:</string>
+ </property>
<property name="alignment" >
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
- <item row="1" column="1" >
+ <item row="2" column="1" >
<widget class="Kst::ComboBox" name="_field" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
- <item row="2" column="0" colspan="2" >
+ <item row="3" column="0" colspan="2" >
<layout class="QHBoxLayout" >
<property name="leftMargin" >
<number>0</number>
@@ -174,6 +181,16 @@
</layout>
</widget>
</item>
+ <item row="2" column="0" >
+ <widget class="Kst::DataRange" native="1" name="_dataRange" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="MinimumExpanding" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
<item row="3" column="0" >
<widget class="QGroupBox" name="_generatedVectorGroup" >
<property name="enabled" >
--- branches/work/kst/portto4/kst/src/widgets/filerequester.cpp #822241:822242
@@ -24,7 +24,7 @@
namespace Kst {
FileRequester::FileRequester(QWidget *parent)
- : QWidget(parent) {
+ : QWidget(parent), _mode(QFileDialog::ExistingFile) {
setup();
}
@@ -84,8 +84,12 @@
void FileRequester::chooseFile() {
-
- QString file = QFileDialog::getOpenFileName(this, QString(), _file);
+ QString file;
+ if (_mode == QFileDialog::ExistingFile) {
+ file = QFileDialog::getOpenFileName(this, QString(), _file);
+ } else {
+ file = QFileDialog::getExistingDirectory(this, QString(), _file);
+ }
if (!file.isEmpty()) {
setFile(file);
}
--- branches/work/kst/portto4/kst/src/widgets/filerequester.h #822241:822242
@@ -13,6 +13,7 @@
#define FILEREQUESTER_H
#include <QWidget>
+#include <QFileDialog>
#include "kst_export.h"
@@ -30,6 +31,7 @@
virtual ~FileRequester();
QString file() const;
+ void setMode(QFileDialog::FileMode mode) { _mode = mode; }
public Q_SLOTS:
void setFile(const QString &file);
@@ -46,6 +48,7 @@
QLineEdit *_fileEdit;
QToolButton *_fileButton;
QString _file;
+ QFileDialog::FileMode _mode;
};
}
More information about the Kst
mailing list