~ubuntu-branches/ubuntu/intrepid/kdebluetooth/intrepid-proposed

« back to all changes in this revision

Viewing changes to kdebluetooth/kbtobexclient/fileview.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2008-08-07 09:49:47 UTC
  • mto: This revision was merged to the branch mainline in revision 56.
  • Revision ID: james.westby@ubuntu.com-20080807094947-pj6q3uxwuv7l844q
Tags: upstream-0.1
ImportĀ upstreamĀ versionĀ 0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
                          fileview.cpp  -  description
3
 
                             -------------------
4
 
    begin                : Sat Sep 20 2003
5
 
    copyright            : (C) 2003 by Simone Gotti
6
 
    email                : simone.gotti@email.it
7
 
 ***************************************************************************/
8
 
 
9
 
/***************************************************************************
10
 
 *                                                                         *
11
 
 *   This program is free software; you can redistribute it and/or modify  *
12
 
 *   it under the terms of the GNU General Public License as published by  *
13
 
 *   the Free Software Foundation; either version 2 of the License, or     *
14
 
 *   (at your option) any later version.                                   *
15
 
 *                                                                         *
16
 
 ***************************************************************************/
17
 
 
18
 
#include <unistd.h>
19
 
 
20
 
#include "fileview.h"
21
 
 
22
 
#include "mainwindow.h"
23
 
#include "diroperator.h"
24
 
 
25
 
#include <qwidget.h>
26
 
#include <qdragobject.h>
27
 
#include <qlayout.h>
28
 
#include <qvbox.h>
29
 
#include <qlabel.h>
30
 
 
31
 
#include <kurldrag.h>
32
 
#include <kfilefiltercombo.h>
33
 
#include <klocale.h>
34
 
#include <kfileitem.h>
35
 
#include <kmessagebox.h>
36
 
#include <kcombobox.h>
37
 
#include <kcompletionbox.h>
38
 
#include <kurlcompletion.h>
39
 
 
40
 
 
41
 
FileView::FileView(QWidget *parent, const char *name )
42
 
        : QWidget(parent,name)
43
 
{
44
 
    setupGUI();
45
 
}
46
 
 
47
 
 
48
 
FileView::~FileView()
49
 
{}
50
 
 
51
 
 
52
 
KActionCollection* FileView::actionCollection() const
53
 
{
54
 
    return m_dirOp->actionCollection();
55
 
}
56
 
 
57
 
 
58
 
void FileView::setupGUI()
59
 
{
60
 
    this->setMinimumHeight(200);
61
 
 
62
 
    QVBoxLayout* layout = new QVBoxLayout( this );
63
 
 
64
 
        KToolBar* toolbar2 = new KToolBar( this , "FileView::toolbar2", true);
65
 
 
66
 
        m_comboBox = new KComboBox(TRUE, toolbar2 );
67
 
    urlCompletion = new KURLCompletion();
68
 
    m_comboBox->setCompletionObject(urlCompletion);
69
 
        connect( m_comboBox, SIGNAL(returnPressed(const QString&)), this, SLOT(slotGoUrl(const QString&)) );
70
 
 
71
 
 
72
 
        QLabel* m_comboLabel = new QLabel(i18n("Location: "), toolbar2, "kde toolbar widget"); // With this name the label is styled !!!
73
 
 
74
 
        int m_comboLabel_id = toolbar2->count();
75
 
        toolbar2->insertWidget(m_comboLabel_id,-1,m_comboLabel);
76
 
        int m_comboBox_id = toolbar2->count();
77
 
        toolbar2->insertWidget(m_comboBox_id,-1,m_comboBox);
78
 
        toolbar2->setItemAutoSized(m_comboBox_id);
79
 
 
80
 
        m_dirOp = new DirOperator( QDir::home().absPath(), this );
81
 
    m_dirOp->readConfig( MainApp()->config(), "file view" );
82
 
    m_dirOp->setMode( KFile::Files );
83
 
    m_dirOp->setView( KFile::Default );
84
 
        //connect( m_dirOp, SIGNAL(urlEntered(const KURL &)), this, SLOT(slotUrlEntered(const KURL &)));
85
 
        //connect( m_dirOp, SIGNAL(completion (const QString &)), m_comboBox, SLOT(setCompletedText(const QString &)));
86
 
 
87
 
        KToolBar* toolbar = new KToolBar( this , "FileView::toolbar", true);
88
 
    toolbar->setFlat(true);
89
 
 
90
 
    KActionCollection *coll = m_dirOp->actionCollection();
91
 
 
92
 
    // plug nav items into the toolbar
93
 
    coll->action( "up" )->plug( toolbar );
94
 
    coll->action( "up" )->setWhatsThis(i18n("<qt>Click this button to enter the parent folder.<p>"
95
 
                                               "For instance, if the current location is file:/home/%1 clicking this "
96
 
                                               "button will take you to file:/home.</qt>").arg(getlogin()));
97
 
    coll->action( "back" )->plug( toolbar );
98
 
    coll->action( "back" )->setWhatsThis(i18n("Click this button to move backwards one step in the browsing history."));
99
 
    coll->action( "forward" )->plug( toolbar );
100
 
    coll->action( "forward" )->setWhatsThis(i18n("Click this button to move forward one step in the browsing history."));
101
 
    coll->action( "reload" )->plug( toolbar );
102
 
    coll->action( "reload" )->setWhatsThis(i18n("Click this button to reload the contents of the current location."));
103
 
    coll->action( "mkdir" )->setShortcut(Key_F10);
104
 
    coll->action( "mkdir" )->plug( toolbar );
105
 
    coll->action( "mkdir" )->setWhatsThis(i18n("Click this button to create a new folder."));
106
 
 
107
 
    KActionMenu *menu = new KActionMenu( i18n("Configure"), "configure", this, "extra menu" );
108
 
 
109
 
    menu->setWhatsThis(i18n("<qt>This is the configuration menu for the file dialog. "
110
 
                            "Various options can be accessed from this menu including: <ul>"
111
 
                            "<li>how files are sorted in the list</li>"
112
 
                            "<li>types of view, including icon and list</li>"
113
 
                            "<li>showing of hidden files</li>"
114
 
                            "<li>the Quick Access navigation panel</li>"
115
 
                            "<li>file previews</li>"
116
 
                            "<li>separating folders from files</li></ul></qt>"));
117
 
    menu->insert( coll->action( "sorting menu" ));
118
 
    menu->insert( coll->action( "separator" ));
119
 
    coll->action( "short view" )->setShortcut(Key_F6);
120
 
    menu->insert( coll->action( "short view" ));
121
 
    coll->action( "detailed view" )->setShortcut(Key_F7);
122
 
    menu->insert( coll->action( "detailed view" ));
123
 
    menu->insert( coll->action( "separator" ));
124
 
    coll->action( "show hidden" )->setShortcut(Key_F8);
125
 
    menu->insert( coll->action( "show hidden" ));
126
 
    //  menu->insert( showSidebarAction );
127
 
    coll->action( "preview" )->setShortcut(Key_F11);
128
 
    menu->insert( coll->action( "preview" ));
129
 
    coll->action( "separate dirs" )->setShortcut(Key_F12);
130
 
    menu->insert( coll->action( "separate dirs" ));
131
 
 
132
 
    menu->setDelayed( false );
133
 
    menu->plug( toolbar );
134
 
 
135
 
    // create filter selection combobox
136
 
        QLabel* filterLabel = new QLabel(i18n("Filter:"), toolbar, "kde toolbar widget");  // With this name the label is styled !!!
137
 
    toolbar->insertWidget( toolbar->count(), 0, filterLabel );
138
 
 
139
 
        m_filterWidget = new KFileFilterCombo( toolbar, "filterwidget" );
140
 
    toolbar->insertWidget( toolbar->count(), 0, m_filterWidget );
141
 
    m_filterWidget->setEditable( true );
142
 
    QString filter = i18n("*|All Files");
143
 
    filter += "\n" + i18n("image/jpeg |JPEG Image Files");
144
 
    m_filterWidget->setFilter(filter);
145
 
    connect( m_filterWidget, SIGNAL(filterChanged()), SLOT(slotFilterChanged()) );
146
 
 
147
 
        layout->addWidget( toolbar);
148
 
    layout->addWidget( toolbar2 );
149
 
    layout->addWidget( m_dirOp );
150
 
 
151
 
    layout->setStretchFactor( m_dirOp, 1 );
152
 
}
153
 
 
154
 
 
155
 
void FileView::slotGoUrl(const QString& text)
156
 
{
157
 
    setUrl(text, FALSE);
158
 
}
159
 
 
160
 
void FileView::setUrl(const KURL& url, bool forward)
161
 
{
162
 
    m_dirOp->setURL( url, forward );
163
 
}
164
 
 
165
 
KURL FileView::Url() const
166
 
{
167
 
    return m_dirOp->url();
168
 
}
169
 
 
170
 
void FileView::setAutoUpdate(bool b)
171
 
{
172
 
    m_dirOp->dirLister()->setAutoUpdate( b );
173
 
}
174
 
 
175
 
void FileView::slotFilterChanged()
176
 
{
177
 
    QString filter = m_filterWidget->currentFilter();
178
 
    m_dirOp->clearFilter();
179
 
 
180
 
    if( filter.find( '/' ) > -1 ) {
181
 
        QStringList types = QStringList::split( " ", filter );
182
 
        types.prepend( "inode/directory" );
183
 
        m_dirOp->setMimeFilter( types );
184
 
    } else
185
 
        m_dirOp->setNameFilter( filter );
186
 
 
187
 
    m_dirOp->rereadDir();
188
 
    //  emit filterChanged( filter );
189
 
}
190
 
 
191
 
/*void FileView::slotUrlEntered(const KURL &url)
192
 
{
193
 
        m_comboBox->setCompletedText(url.path());
194
 
}*/
195
 
 
196
 
void FileView::reload()
197
 
{
198
 
    m_dirOp->actionCollection()->action("reload")->activate();
199
 
}
200
 
 
201
 
void FileView::saveConfig( KConfig* c )
202
 
{
203
 
    m_dirOp->writeConfig( c, "file view" );
204
 
}
205
 
 
206
 
 
207
 
#include "fileview.moc"