Diffstat (limited to 'noncore/games/backgammon/filedialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/backgammon/filedialog.cpp | 129 |
1 files changed, 65 insertions, 64 deletions
diff --git a/noncore/games/backgammon/filedialog.cpp b/noncore/games/backgammon/filedialog.cpp index 6c858a2..a5e71c9 100644 --- a/noncore/games/backgammon/filedialog.cpp +++ b/noncore/games/backgammon/filedialog.cpp | |||
@@ -1,64 +1,65 @@ | |||
1 | #include "filedialog.h" | 1 | #include "filedialog.h" |
2 | 2 | ||
3 | #include <qdir.h> | 3 | #include <qdir.h> |
4 | #include <qfileinfo.h> | 4 | #include <qfileinfo.h> |
5 | #include <qmessagebox.h> | 5 | #include <qmessagebox.h> |
6 | #include <qpixmap.h> | 6 | #include <qpixmap.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | 9 | ||
10 | FileDialog::FileDialog(QWidget* parent,QString header,QString extension,const char* name,bool modal,WFlags f) | 10 | FileDialog::FileDialog(QWidget* parent,QString header,QString extension,const char* name,bool modal,WFlags f) |
11 | :QDialog(parent,name,modal,f) | 11 | :QDialog(parent,name,modal,f) |
12 | { | 12 | { |
13 | setCaption(header); | 13 | setCaption(header); |
14 | ext=extension; | 14 | ext=extension; |
15 | dirselector=new QListView(this); | 15 | dirselector=new QListView(this); |
16 | dirselector->setGeometry(1,10,235,200); | 16 | dirselector->setGeometry(1,10,235,200); |
17 | dirselector->addColumn("Files"); | 17 | dirselector->addColumn("Files"); |
18 | connect(dirselector,SIGNAL(clicked(QListViewItem*)),this,SLOT(selectorclicked(QListViewItem*))); | 18 | connect(dirselector,SIGNAL(clicked(QListViewItem*)),this,SLOT(selectorclicked(QListViewItem*))); |
19 | 19 | ||
20 | getCurrentDir(); | 20 | getCurrentDir(); |
21 | 21 | ||
22 | file_name="user"; | 22 | file_name="user"; |
23 | fileinput=new QLineEdit(file_name,this); | 23 | fileinput=new QLineEdit(file_name,this); |
24 | fileinput->setGeometry(1,220,235,20); | 24 | fileinput->setGeometry(1,220,235,20); |
25 | showMaximized(); | 25 | |
26 | } | 26 | QPEApplication::showDialog( this ); |
27 | 27 | } | |
28 | FileDialog::~FileDialog() | 28 | |
29 | {} | 29 | FileDialog::~FileDialog() |
30 | 30 | {} | |
31 | 31 | ||
32 | void FileDialog::selectorclicked(QListViewItem* entry) | 32 | |
33 | { | 33 | void FileDialog::selectorclicked(QListViewItem* entry) |
34 | if(entry==NULL) | 34 | { |
35 | return; | 35 | if(entry==NULL) |
36 | file_name=entry->text(0); | 36 | return; |
37 | fileinput->setText(file_name); | 37 | file_name=entry->text(0); |
38 | } | 38 | fileinput->setText(file_name); |
39 | 39 | } | |
40 | void FileDialog::getCurrentDir() | 40 | |
41 | { | 41 | void FileDialog::getCurrentDir() |
42 | dirselector->clear(); | 42 | { |
43 | QDir dir(QPEApplication::qpeDir()+"/backgammon"); | 43 | dirselector->clear(); |
44 | dir.setFilter(QDir::Files); | 44 | QDir dir(QPEApplication::qpeDir()+"/backgammon"); |
45 | QFileInfoListIterator it(*(dir.entryInfoList())); | 45 | dir.setFilter(QDir::Files); |
46 | QFileInfo* fi; | 46 | QFileInfoListIterator it(*(dir.entryInfoList())); |
47 | 47 | QFileInfo* fi; | |
48 | int ext_length=ext.length(); | 48 | |
49 | while((fi=it.current())) // go through all file and subdirs | 49 | int ext_length=ext.length(); |
50 | { | 50 | while((fi=it.current())) // go through all file and subdirs |
51 | QString file=fi->fileName(); | 51 | { |
52 | if(file.right(ext_length)==ext && file) | 52 | QString file=fi->fileName(); |
53 | { | 53 | if(file.right(ext_length)==ext && file) |
54 | file=file.left(file.length()-ext_length); | 54 | { |
55 | new QListViewItem(dirselector,file); | 55 | file=file.left(file.length()-ext_length); |
56 | } | 56 | new QListViewItem(dirselector,file); |
57 | ++it; | 57 | } |
58 | } | 58 | ++it; |
59 | } | 59 | } |
60 | 60 | } | |
61 | QString FileDialog::filename() | 61 | |
62 | { | 62 | QString FileDialog::filename() |
63 | return file_name; | 63 | { |
64 | } | 64 | return file_name; |
65 | } | ||