~ubuntu-branches/ubuntu/natty/kde4libs/natty-proposed

« back to all changes in this revision

Viewing changes to kio/kfile/tests/kfstest.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell, Scott Kitterman, Jonathan Riddell
  • Date: 2010-11-22 17:59:02 UTC
  • mfrom: (1.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101122175902-yubxubd0pg6hn11z
Tags: 4:4.5.80a-0ubuntu1
[ Scott Kitterman ]
* New upstream beta release
  - Refreshed all patches
  - Updated debian/patches/10_make_libkdeinit4_private.diff to use Qfile
    instead of Qstring in kdecore/kernel/kstandarddirs_unix.cpp
  - Updated debian/patches/kubuntu_01_kubuntu_useragent.diff to provide
    Kubuntu in the Konqueror user agen string with the changes in
    kio/kio/kprotocolmanager.cpp
  - Partially updated debian/patches/kubuntu_05_langpack_desktop_files.diff
    and left the balance in kdecore/localization/klocale.cpp.rej for later
    revision
  - Update debian/patches/kubuntu_06_user_disk_mounting.diff for changes in
    solid/solid/backends/hal/halstorageaccess.cpp
  - Remove debian/patches/kubuntu_71_backport_plasma_webview_changes.diff
    (backported from upstream, so already present now)
  - Add minimum version for libattica-dev of 0.1.90 to build-depends
  - Bump minimum version for libsoprano-dev build-depend to 2.5.60
  - Add minimum version for shared-desktop-ontologies of 0.5 in build-dep

[ Jonathan Riddell ]
* Add build-depends on grantlee, libudev-dev, hupnp (FIXME needs packaging fixes)
* Update kubuntu_04_add_langpack_path.diff 28_find_old_kde4_html_documentation.diff
  22_hack_in_etc_kde4_in_kstandarddirs.diff for QT_NO_CAST_FROM_ASCII
* Update kubuntu_05_langpack_desktop_files.diff for new upstream code
* Add kubuntu_78_solid_trunk.diff to fix solid linking
* Add libnepomukutils4 package for new library
* Don't install kcm_ssl for now, e-mailed upstream to suggest moving to kdebase
* Add kubuntu_79_knewstuff_fix.diff to fix compile broken by non-trunk commit
  http://websvn.kde.org/?view=revision&revision=1199825
* kdelibs5-data replaces old kdebase-runtime-data due to moved file
* Add kubuntu_80_find_hupnp.diff to find hupnp include files, committed upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of the KDE libraries
2
 
    Copyright (C) 1997, 1998 Richard Moore <rich@kde.org>
3
 
                  1998 Stephan Kulow <coolo@kde.org>
4
 
 
5
 
    This library is free software; you can redistribute it and/or
6
 
    modify it under the terms of the GNU Library General Public
7
 
    License as published by the Free Software Foundation; either
8
 
    version 2 of the License, or (at your option) any later version.
9
 
 
10
 
    This library is distributed in the hope that it will be useful,
11
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 
    Library General Public License for more details.
14
 
 
15
 
    You should have received a copy of the GNU Library General Public License
16
 
    along with this library; see the file COPYING.LIB.  If not, write to
17
 
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
 
    Boston, MA 02110-1301, USA.
19
 
*/
20
 
 
21
 
#include <unistd.h>
22
 
#include <stdlib.h>
23
 
#include <sys/stat.h>
24
 
#include <QtCore/QDir>
25
 
#include <QtGui/QLayout>
26
 
#include <QtCore/QMutableStringListIterator>
27
 
#include <QtGui/QWidget>
28
 
 
29
 
#include <kfiledialog.h>
30
 
#include <kmessagebox.h>
31
 
#include <kconfig.h>
32
 
#include <kapplication.h>
33
 
#include <kcmdlineargs.h>
34
 
#include <kurl.h>
35
 
#if 0 // SPLIT-TODO
36
 
#include <kurlbar.h>
37
 
#include <kdiroperator.h>
38
 
#endif
39
 
#include <kfile.h>
40
 
#include <kdebug.h>
41
 
#include <kicondialog.h>
42
 
 
43
 
#include "kfdtest.h"
44
 
#include <kconfiggroup.h>
45
 
 
46
 
int main(int argc, char **argv)
47
 
{
48
 
    KCmdLineOptions options;
49
 
    options.add("+[cmd]");
50
 
    options.add("+[url]");
51
 
 
52
 
    KCmdLineArgs::init(argc, argv, "kfstest", 0, ki18n("kfstest"), "0", ki18n("test app"));
53
 
    KCmdLineArgs::addCmdLineOptions(options);
54
 
    KApplication a;
55
 
    a.setQuitOnLastWindowClosed(false);
56
 
 
57
 
    QString name1;
58
 
    QStringList names;
59
 
 
60
 
    QString argv1;
61
 
    KUrl startDir;
62
 
    if (argc > 1)
63
 
        argv1 = QLatin1String(argv[1]);
64
 
    if ( argc > 2 )
65
 
        startDir = KUrl( argv[2] );
66
 
 
67
 
#if 0 // SPLIT-TODO
68
 
    if (argv1 == QLatin1String("diroperator")) {
69
 
        KDirOperator *op = new KDirOperator(startDir, 0);
70
 
        KConfigGroup grp(KGlobal::config(), "TestGroup" );
71
 
        op->setViewConfig(grp);
72
 
        op->setView(KFile::Simple);
73
 
        op->show();
74
 
        a.exec();
75
 
    } else
76
 
#endif
77
 
    if (argv1 == QLatin1String("localonly")) {
78
 
        QString name = KFileDialog::getOpenFileName(startDir);
79
 
        qDebug("filename=%s",name.toLatin1().constData());
80
 
    }
81
 
    else if (argv1 == QLatin1String("oneurl")) {
82
 
        KUrl url = KFileDialog::getOpenUrl(startDir);
83
 
        qDebug() << "url=" << url;
84
 
    }
85
 
 
86
 
    else if (argv1 == QLatin1String("existingDirectoryUrl")) {
87
 
        KUrl url = KFileDialog::getExistingDirectoryUrl();
88
 
        qDebug("URL=%s",url.url().toLatin1().constData());
89
 
        name1 = url.url();
90
 
    }
91
 
 
92
 
    else if (argv1 == QLatin1String("preview")) {
93
 
        KUrl u =  KFileDialog::getImageOpenUrl();
94
 
        qDebug("filename=%s", u.url().toLatin1().constData());
95
 
    }
96
 
 
97
 
    else if (argv1 == QLatin1String("preselect")) {
98
 
        names = KFileDialog::getOpenFileNames(KUrl("/etc/passwd"));
99
 
        QStringList::Iterator it = names.begin();
100
 
        while ( it != names.end() ) {
101
 
            qDebug("selected file: %s", (*it).toLatin1().constData());
102
 
            ++it;
103
 
        }
104
 
    }
105
 
 
106
 
    else if (argv1 == QLatin1String("dirs"))
107
 
        name1 = KFileDialog::getExistingDirectory();
108
 
 
109
 
    else if (argv1 == QLatin1String("heap")) {
110
 
        KFileDialog *dlg = new KFileDialog( startDir, QString(), 0L);
111
 
        dlg->setMode( KFile::File);
112
 
        dlg->setOperationMode( KFileDialog::Saving );
113
 
        QStringList filter;
114
 
        filter << "all/allfiles" << "text/plain";
115
 
        dlg->setMimeFilter( filter, "all/allfiles" );
116
 
#if 0 // SPLIT-TODO
117
 
        KUrlBar *urlBar = dlg->speedBar();
118
 
        if ( urlBar )
119
 
        {
120
 
            urlBar->insertDynamicItem( KUrl("ftp://ftp.kde.org"),
121
 
                                       QLatin1String("KDE FTP Server") );
122
 
        }
123
 
#endif
124
 
        if ( dlg->exec() == KDialog::Accepted )
125
 
            name1 = dlg->selectedUrl().url();
126
 
    }
127
 
 
128
 
    else if ( argv1 == QLatin1String("eventloop") )
129
 
    {
130
 
        new KFDTest( startDir );
131
 
        return a.exec();
132
 
    }
133
 
 
134
 
    else if (argv1 == QLatin1String("save")) {
135
 
        KUrl u = KFileDialog::getSaveUrl(startDir);
136
 
//        QString(QDir::homePath() + QLatin1String("/testfile")),
137
 
//        QString(), 0L);
138
 
        name1 = u.url();
139
 
    }
140
 
 
141
 
    else if (argv1 == QLatin1String("icon")) {
142
 
        KIconDialog dlg;
143
 
        QString icon = dlg.getIcon();
144
 
        kDebug() << icon;
145
 
    }
146
 
 
147
 
//     else if ( argv1 == QLatin1String("dirselect") ) {
148
 
//         KUrl url;
149
 
//         url.setPath( "/" );
150
 
//         KUrl selected = KDirSelectDialog::selectDirectory( url );
151
 
//         name1 = selected.url();
152
 
//         qDebug("*** selected: %s", selected.url().toLatin1().constData());
153
 
//     }
154
 
 
155
 
    else {
156
 
        KFileDialog dlg(startDir,
157
 
                        QString::fromLatin1("*|All Files\n"
158
 
                                            "*.lo *.o *.la|All libtool Files"),0);
159
 
//    dlg.setFilter( "*.kdevelop" );
160
 
        dlg.setMode( KFile::Files |
161
 
                     KFile::Directory |
162
 
                     KFile::ExistingOnly |
163
 
                     KFile::LocalOnly );
164
 
//        QStringList filter;
165
 
//        filter << "text/plain" << "text/html" << "image/png";
166
 
//        dlg.setMimeFilter( filter );
167
 
//        KMimeType::List types;
168
 
//        types.append( KMimeType::mimeType( "text/plain" ) );
169
 
//        types.append( KMimeType::mimeType( "text/html" ) );
170
 
//        dlg.setFilterMimeType( "Filetypes:", types, types.first() );
171
 
        if ( dlg.exec() == QDialog::Accepted ) {
172
 
            const KUrl::List list = dlg.selectedUrls();
173
 
            KUrl::List::ConstIterator it = list.constBegin();
174
 
            qDebug("*** selectedUrls(): ");
175
 
            while ( it != list.constEnd() ) {
176
 
                name1 = (*it).url();
177
 
                qDebug("  -> %s", name1.toLatin1().constData());
178
 
                ++it;
179
 
            }
180
 
            qDebug("*** selectedFile: %s", dlg.selectedFile().toLatin1().constData());
181
 
            qDebug("*** selectedUrl: %s", dlg.selectedUrl().url().toLatin1().constData());
182
 
            qDebug("*** selectedFiles: ");
183
 
            QStringList l = dlg.selectedFiles();
184
 
            QStringList::Iterator it2 = l.begin();
185
 
            while ( it2 != l.end() ) {
186
 
                qDebug("  -> %s", (*it2).toLatin1().constData());
187
 
                ++it2;
188
 
            }
189
 
        }
190
 
    }
191
 
 
192
 
    if (!(name1.isNull()))
193
 
        KMessageBox::information(0, QLatin1String("You selected the file " ) + name1,
194
 
                                 QLatin1String("Your Choice"));
195
 
    return 0;
196
 
}