summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/tutorials/gettingStarted/parts/part5/filedialog')
-rw-r--r--examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/dialogPlugin.cpp6
-rw-r--r--examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/dialogPlugin.h2
-rw-r--r--examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/directory.cpp22
-rw-r--r--examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/directory.h30
-rw-r--r--examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/file.h12
-rw-r--r--examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/filedialog.pro12
6 files changed, 42 insertions, 42 deletions
diff --git a/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/dialogPlugin.cpp b/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/dialogPlugin.cpp
index 452124f5..84ebdced 100644
--- a/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/dialogPlugin.cpp
+++ b/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/dialogPlugin.cpp
@@ -44,11 +44,11 @@
#include <QtDeclarative/qdeclarative.h>
void DialogPlugin::registerTypes(const char *uri){
-
+
//register the class Directory into QML as a "Directory" element version 1.0
qmlRegisterType<Directory>(uri, 1, 0, "Directory");
qmlRegisterType<File>(uri,1,0,"File");
-
+
//qRegisterMetaType<QDeclarativeListProperty<QString> > ("QDeclarativeListProperty<QString>");
-
+
}
diff --git a/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/dialogPlugin.h b/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/dialogPlugin.h
index 68c6076e..0a5bc9ef 100644
--- a/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/dialogPlugin.h
+++ b/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/dialogPlugin.h
@@ -51,7 +51,7 @@ class DialogPlugin : public QDeclarativeExtensionPlugin
public:
//registerTypes is inherited from QDeclarativeExtensionPlugin
void registerTypes(const char *uri);
-
+
};
#endif
diff --git a/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/directory.cpp b/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/directory.cpp
index bdf450eb..dd4a5546 100644
--- a/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/directory.cpp
+++ b/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/directory.cpp
@@ -48,10 +48,10 @@ Initialize the saves directory and creates the file list
*/
Directory::Directory(QObject *parent) : QObject(parent)
{
-
+
m_dir.cd( QDir::currentPath());
-
+
//go to the saved directory. if not found, create save directory
m_saveDir = "saves";
if (m_dir.cd(m_saveDir) == 0){
@@ -144,7 +144,7 @@ void Directory::setFileContent(const QString &str){
if(str != m_fileContent){
m_fileContent = str;
emit fileContentChanged();
- }
+ }
}
/*
@@ -152,17 +152,17 @@ Called from QML to save the file using the filename and file content.
Saving makes sure that the file has a .txt extension.
*/
void Directory::saveFile(){
-
+
if(currentFile.name().size() == 0){
qWarning()<< "Empty filename. no save";
return;
}
-
+
QString extendedName = currentFile.name();
if(!currentFile.name().endsWith(".txt")){
extendedName.append(".txt");
}
-
+
QFile file( m_dir.filePath(extendedName) );
if (file.open(QFile::WriteOnly | QFile::Truncate)){
QTextStream outStream(&file);
@@ -184,11 +184,11 @@ void Directory::loadFile(){
if(!currentFile.name().endsWith(".txt")){
extendedName.append(".txt");
}
-
+
QFile file( m_dir.filePath(extendedName) );
if (file.open(QFile::ReadOnly )){
QTextStream inStream(&file);
-
+
QString line;
do{
line = inStream.read(75);
@@ -205,12 +205,12 @@ created files are added onto the list.
void Directory::refresh(){
m_dirFiles = m_dir.entryList(m_filterList,QDir::Files,QDir::Name);
m_fileList.clear();
-
+
File * file;
for(int i = 0; i < m_dirFiles.size() ; i ++){
-
+
file = new File();
-
+
if(m_dirFiles.at(i).endsWith(".txt")){
QString name = m_dirFiles.at(i);
file->setName( name.remove(".txt",Qt::CaseSensitive));
diff --git a/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/directory.h b/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/directory.h
index b5a7bbe1..a8997ee2 100644
--- a/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/directory.h
+++ b/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/directory.h
@@ -52,22 +52,22 @@
class Directory : public QObject{
Q_OBJECT
-
+
//number of files in the directory
Q_PROPERTY(int filesCount READ filesCount)
-
+
//list property containing file names as QString
Q_PROPERTY(QDeclarativeListProperty<File> files READ files CONSTANT )
-
+
//file name of the text file to read/write
Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged)
-
+
//text content of the file
Q_PROPERTY(QString fileContent READ fileContent WRITE setFileContent NOTIFY fileContentChanged)
-
+
public:
Directory(QObject *parent = 0);
-
+
//properties' read functions
int filesCount() const;
QString filename() const;
@@ -77,30 +77,30 @@ class Directory : public QObject{
//properties' write functions
void setFilename(const QString &str);
void setFileContent(const QString &str);
-
+
//accessible from QML
Q_INVOKABLE void saveFile();
Q_INVOKABLE void loadFile();
-
+
signals:
void directoryChanged();
void filenameChanged();
void fileContentChanged();
-
+
private:
QDir m_dir;
- QStringList m_dirFiles;
- File currentFile;
+ QStringList m_dirFiles;
+ File currentFile;
QString m_saveDir;
- QStringList m_filterList;
-
+ QStringList m_filterList;
+
//contains the file data in QString format
QString m_fileContent;
-
+
//Registered to QML in a plugin. Accessible from QML as a property of Directory
QList<File *> m_fileList;
- //refresh content of the directory
+ //refresh content of the directory
void refresh();
};
diff --git a/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/file.h b/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/file.h
index ef1551a3..f3afb6ff 100644
--- a/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/file.h
+++ b/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/file.h
@@ -46,20 +46,20 @@
#include <QObject>
class File : public QObject{
-
+
Q_OBJECT
-
+
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
-
+
public:
File(QObject *parent = 0);
-
+
QString name() const;
void setName(const QString &str);
-
+
signals:
void nameChanged();
-
+
private:
QString m_name;
};
diff --git a/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/filedialog.pro b/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/filedialog.pro
index f9229a3b..856221bc 100644
--- a/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/filedialog.pro
+++ b/examples/declarative/tutorials/gettingStarted/parts/part5/filedialog/filedialog.pro
@@ -8,10 +8,10 @@ MOC_DIR = tmp
TARGET = FileDialog
-HEADERS += directory.h \
- file.h \
- dialogPlugin.h
+HEADERS += directory.h \
+ file.h \
+ dialogPlugin.h
-SOURCES += directory.cpp \
- file.cpp \
- dialogPlugin.cpp
+SOURCES += directory.cpp \
+ file.cpp \
+ dialogPlugin.cpp