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