~ubuntu-branches/ubuntu/jaunty/kdebase/jaunty-backports

« back to all changes in this revision

Viewing changes to apps/dolphin/src/dolphinviewcontainer.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve Stalcup
  • Date: 2009-01-08 09:49:20 UTC
  • mfrom: (1.1.22 upstream)
  • Revision ID: james.westby@ubuntu.com-20090108094920-zbm1d1y0y3t5rpff
Tags: 4:4.1.96-0ubuntu1
* New upstream release
* Updated various .install files:
  + dolphin.install
  + kappfinder.install
  + kfind.install
  + konqueror.install
* Bumped build-dep versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
            this, SLOT(showInfoMessage(const QString&)));
118
118
    connect(m_dirLister, SIGNAL(errorMessage(const QString&)),
119
119
            this, SLOT(showErrorMessage(const QString&)));
 
120
    connect(m_dirLister, SIGNAL(urlIsFileError(const KUrl&)),
 
121
            this, SLOT(openFile(const KUrl&)));
120
122
 
121
123
    m_view = new DolphinView(this,
122
124
                             url,
176
178
void DolphinViewContainer::setUrl(const KUrl& newUrl)
177
179
{
178
180
    m_urlNavigator->setUrl(newUrl);
179
 
 
180
 
    // Temporary disable the 'File'->'Create New...' menu until
181
 
    // the write permissions can be checked in a fast way at
182
 
    // DolphinViewContainer::slotDirListerCompleted().
183
 
    m_mainWindow->newMenu()->menu()->setEnabled(false);
 
181
    if (newUrl != m_urlNavigator->url()) {
 
182
        // Temporary disable the 'File'->'Create New...' menu until
 
183
        // the write permissions can be checked in a fast way at
 
184
        // DolphinViewContainer::slotDirListerCompleted().
 
185
        m_mainWindow->newMenu()->menu()->setEnabled(false);
 
186
    }
184
187
}
185
188
 
186
189
const KUrl& DolphinViewContainer::url() const
211
214
    return m_filterBar->isVisible();
212
215
}
213
216
 
 
217
void DolphinViewContainer::showFilterBar(bool show)
 
218
{
 
219
    Q_ASSERT(m_filterBar != 0);
 
220
    if (show) {
 
221
        m_filterBar->show();
 
222
    } else {
 
223
        closeFilterBar();
 
224
    }
 
225
}
 
226
 
214
227
bool DolphinViewContainer::isUrlEditable() const
215
228
{
216
229
    return m_urlNavigator->isUrlEditable();
245
258
    }
246
259
 
247
260
    updateStatusBar();
248
 
    QTimer::singleShot(100, this, SLOT(restoreContentsPos()));
 
261
    QMetaObject::invokeMethod(this, "restoreContentsPos", Qt::QueuedConnection);
249
262
 
250
263
    // Enable the 'File'->'Create New...' menu only if the directory
251
264
    // supports writing.
288
301
{
289
302
    m_filterBar->hide();
290
303
    m_filterBar->clear();
 
304
    m_view->setFocus();
291
305
    emit showFilterBarChanged(false);
292
306
}
293
307
 
294
 
void DolphinViewContainer::showFilterBar(bool show)
295
 
{
296
 
    Q_ASSERT(m_filterBar != 0);
297
 
    m_filterBar->setVisible(show);
298
 
}
299
 
 
300
308
void DolphinViewContainer::updateStatusBar()
301
309
{
302
310
    // As the item count information is less important
355
363
{
356
364
    if (KProtocolManager::supportsListing(url)) {
357
365
        m_view->updateView(url, m_urlNavigator->savedRootUrl());
 
366
        if (isActive()) {
 
367
            // When an URL has been entered, the view should get the focus.
 
368
            // The focus must be requested asynchronously, as changing the URL might create
 
369
            // a new view widget. Using QTimer::singleShow() works reliable, however
 
370
            // QMetaObject::invokeMethod() with a queued connection does not work, which might
 
371
            // indicate that we should pass a hint to DolphinView::updateView()
 
372
            // regarding the focus instead. To test: Enter an URL and press CTRL+Enter.
 
373
            // Expected result: The view should get the focus.
 
374
            QTimer::singleShot(0, this, SLOT(requestFocus()));
 
375
        }
358
376
    } else if (KProtocolManager::isSourceProtocol(url)) {
359
377
        QString app = "konqueror";
360
378
        if (url.protocol().startsWith(QLatin1String("http"))) {
367
385
            }
368
386
        } else {
369
387
            showErrorMessage(i18nc("@info:status",
370
 
                                   "Protocol not supported by Dolphin, Konqueror has been launched"));        
 
388
                                   "Protocol not supported by Dolphin, Konqueror has been launched"));
371
389
        }
372
390
        const QString command = app + ' ' + url.pathOrUrl();
373
391
        KRun::runCommand(command, app, app, this);
396
414
    m_urlNavigator->blockSignals(block);
397
415
}
398
416
 
 
417
void DolphinViewContainer::requestFocus()
 
418
{
 
419
    m_view->setFocus();
 
420
}
 
421
 
399
422
void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
400
423
{
401
424
    KUrl url = item.targetUrl();
424
447
    item.run();
425
448
}
426
449
 
 
450
void DolphinViewContainer::openFile(const KUrl& url)
 
451
{
 
452
    // Using m_dolphinModel for getting the file item instance is not possible
 
453
    // here: openFile() is triggered by an error of the directory lister
 
454
    // job, so the file item must be received "manually".
 
455
    const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
 
456
    slotItemTriggered(item);
 
457
}
 
458
 
427
459
#include "dolphinviewcontainer.moc"