Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 342479
Collapse All | Expand All

(-)plasma/applets/folderview/folderview.cpp (-15 / +128 lines)
Lines 21-30 Link Here
21
#include "folderview.h"
21
#include "folderview.h"
22
22
23
#include <QClipboard>
23
#include <QClipboard>
24
#include <QDebug>
25
#include <QDesktopServices>
26
#include <QDesktopWidget>
24
#include <QDesktopWidget>
27
#include <QDrag>
28
#include <QGraphicsLinearLayout>
25
#include <QGraphicsLinearLayout>
29
#include <QGraphicsView>
26
#include <QGraphicsView>
30
#include <QGraphicsSceneDragDropEvent>
27
#include <QGraphicsSceneDragDropEvent>
Lines 41-56 Link Here
41
#include <kfileplacesmodel.h>
38
#include <kfileplacesmodel.h>
42
#include <kfilepreviewgenerator.h>
39
#include <kfilepreviewgenerator.h>
43
#include <KGlobalSettings>
40
#include <KGlobalSettings>
44
#include <KMenu>
45
#include <KStandardDirs>
46
#include <KStandardShortcut>
41
#include <KStandardShortcut>
47
#include <KStringHandler>
42
#include <KStringHandler>
48
#include <KTemporaryFile>
43
#include <KTemporaryFile>
44
#include <KStandardDirs>
45
#include <KMenu>
49
46
50
#include <kio/copyjob.h>
47
#include <kio/copyjob.h>
51
#include <kio/fileundomanager.h>
48
#include <kio/fileundomanager.h>
52
#include <kio/paste.h>
49
#include <kio/paste.h>
53
#include <KParts/BrowserExtension>
54
50
55
#include <kfileitemactions.h>
51
#include <kfileitemactions.h>
56
#include <kfileitemlistproperties.h>
52
#include <kfileitemlistproperties.h>
Lines 360-366 Link Here
360
    m_model->setMimeTypeFilterList(m_filterFilesMimeList);
356
    m_model->setMimeTypeFilterList(m_filterFilesMimeList);
361
    m_model->setFileNameFilter(m_filterFiles);
357
    m_model->setFileNameFilter(m_filterFiles);
362
    m_model->setSortDirectoriesFirst(m_sortDirsFirst);
358
    m_model->setSortDirectoriesFirst(m_sortDirsFirst);
363
    m_model->setDynamicSortFilter(true);
359
    m_model->setDynamicSortFilter(m_sortColumn != -1);
364
    m_model->sort(m_sortColumn != -1 ? m_sortColumn : KDirModel::Name, Qt::AscendingOrder);
360
    m_model->sort(m_sortColumn != -1 ? m_sortColumn : KDirModel::Name, Qt::AscendingOrder);
365
361
366
    DirLister *lister = new DirLister(this);
362
    DirLister *lister = new DirLister(this);
Lines 420-429 Link Here
420
416
421
void FolderView::configChanged()
417
void FolderView::configChanged()
422
{
418
{
423
    //TODO: reload all other config values there
424
    KConfigGroup cg = config();
419
    KConfigGroup cg = config();
425
    setUrl(cg.readEntry("url", m_url));
420
426
    m_dirModel->dirLister()->openUrl(m_url);
421
    //Declare some variables that are used afterwards
422
    bool needReload = false;
423
    bool preserveIconPositions = false;
424
425
    //Reload m_customLabel values
426
    QString label = m_customLabel;
427
    m_customLabel = cg.readEntry("customLabel", m_customLabel);
428
    if (label != m_customLabel) {
429
        needReload = true;
430
    }
431
432
    //Reload m_customIconSize values
433
    const int size = m_customIconSize;
434
    m_customIconSize = cg.readEntry("customIconSize", m_customIconSize);
435
      if (size != iconSize().width()) {
436
              needReload = true;
437
438
      }
439
440
    m_showPreviews = cg.readEntry("showPreviews", m_showPreviews);
441
    m_drawShadows  = cg.readEntry("drawShadows", m_drawShadows);
442
    m_iconsLocked  = cg.readEntry("iconsLocked", m_iconsLocked);
443
    m_alignToGrid  = cg.readEntry("alignToGrid", m_alignToGrid);
444
    m_numTextLines = cg.readEntry("numTextLines", m_numTextLines);
445
446
    const int filterType = m_filterType;
447
    m_filterType   = cg.readEntry("filter", m_filterType);
448
    if (filterType != m_filterType) {
449
        needReload = true;
450
    }
451
452
    QColor color = m_textColor;
453
    m_textColor = cg.readEntry("textColor", m_textColor);
454
    if (color != m_textColor) {
455
        needReload = true;
456
    }
457
458
    m_previewPlugins = cg.readEntry("previewPlugins", m_previewPlugins);
459
460
    if (m_previewGenerator && m_previewPlugins != m_previewGenerator->enabledPlugins()) {
461
        m_previewGenerator->setEnabledPlugins(m_previewPlugins);
462
463
        //Changing the preview plugins will also need a reload to work, so we need to preserve
464
        //the icons position
465
        needReload = true;
466
        preserveIconPositions = true;
467
    }
468
469
    m_sortDirsFirst = cg.readEntry("sortDirsFirst", m_sortDirsFirst);
470
    toggleDirectoriesFirst(m_sortDirsFirst);
471
472
    const int sortColumn = m_sortColumn;
473
    m_sortColumn = cg.readEntry("sortColumn", m_sortColumn);
474
    if (m_sortColumn != sortColumn) {
475
        if (m_sortColumn != -1) {
476
            m_model->invalidate();
477
            m_model->sort(m_sortColumn, Qt::AscendingOrder);
478
            m_model->setDynamicSortFilter(true);
479
        } else if (m_iconView) {
480
            m_iconView->setCustomLayout(true);
481
            m_model->setDynamicSortFilter(false);
482
        }
483
        updateSortActionsState();
484
    }
485
486
    const QString filterFiles = m_filterFiles;
487
    m_filterFiles         = cg.readEntry("filterFiles", m_filterFiles);
488
489
    if (filterFiles != m_filterFiles) {
490
        needReload = true;
491
    }
492
493
    const QStringList mimeFilter = m_filterFilesMimeList;
494
    m_filterFilesMimeList = cg.readEntry("mimeFilter", m_filterFilesMimeList);
495
496
    if (mimeFilter != m_filterFilesMimeList) {
497
        needReload = true;
498
    }
499
500
    const KUrl url = m_url;
501
    m_url = cg.readEntry("url", m_url);
502
    if (url != m_url) {
503
        setUrl(m_url);
504
        needReload = true;
505
    }
506
507
508
    if (m_iconView) {
509
        updateIconViewState();
510
    }
511
512
    if (m_listView) {
513
        updateListViewState();
514
    }
515
516
    if (needReload) {
517
        //Manually save and restore the icon positions if we need it
518
        QStringList iconPositionsData;
519
        if (preserveIconPositions && m_iconView) {
520
            iconPositionsData = m_iconView->iconPositionsData();
521
522
        }
523
524
525
        if (preserveIconPositions && m_iconView) {
526
             m_iconView->setIconPositionsData(iconPositionsData);
527
        }
528
        // So the KFileItemActions will be recreated for the new URL.
529
        delete m_itemActions;
530
        m_itemActions = 0;
531
        m_dirModel->dirLister()->openUrl(m_url);
532
    }
427
}
533
}
428
534
429
FolderView::~FolderView()
535
FolderView::~FolderView()
Lines 712-719 Link Here
712
        if (m_sortColumn != -1) {
818
        if (m_sortColumn != -1) {
713
            m_model->invalidate();
819
            m_model->invalidate();
714
            m_model->sort(m_sortColumn, Qt::AscendingOrder);
820
            m_model->sort(m_sortColumn, Qt::AscendingOrder);
821
            m_model->setDynamicSortFilter(true);
715
        } else if (m_iconView) {
822
        } else if (m_iconView) {
716
            m_iconView->setCustomLayout(true);
823
            m_iconView->setCustomLayout(true);
824
            m_model->setDynamicSortFilter(false);
717
        }
825
        }
718
        updateSortActionsState();
826
        updateSortActionsState();
719
        cg.writeEntry("sortColumn", m_sortColumn);
827
        cg.writeEntry("sortColumn", m_sortColumn);
Lines 999-1017 Link Here
999
1107
1000
void FolderView::iconSettingsChanged(int group)
1108
void FolderView::iconSettingsChanged(int group)
1001
{
1109
{
1002
    if (group == KIconLoader::Desktop && m_iconView)
1110
    if (group == KIconLoader::Desktop && m_iconView) {
1003
    {
1004
        const int size = (m_customIconSize != 0) ?
1111
        const int size = (m_customIconSize != 0) ?
1005
                m_customIconSize : KIconLoader::global()->currentSize(KIconLoader::Desktop);
1112
                m_customIconSize : KIconLoader::global()->currentSize(KIconLoader::Desktop);
1006
1113
1007
        m_iconView->setIconSize(QSize(size, size));
1114
        m_iconView->setIconSize(QSize(size, size));
1008
    }
1115
        m_iconView->markAreaDirty(m_iconView->visibleArea());
1009
    else if (group == KIconLoader::Panel && m_listView)
1116
        m_iconView->update();
1010
    {
1117
    } else if (group == KIconLoader::Panel && m_listView) {
1011
        const int size = (m_customIconSize != 0) ?
1118
        const int size = (m_customIconSize != 0) ?
1012
                m_customIconSize : KIconLoader::global()->currentSize(KIconLoader::Panel);
1119
                m_customIconSize : KIconLoader::global()->currentSize(KIconLoader::Panel);
1013
1120
1014
        m_listView->setIconSize(QSize(size, size));
1121
        m_listView->setIconSize(QSize(size, size));
1122
        m_listView->markAreaDirty(m_listView->visibleArea());
1123
        m_listView->update();
1015
    }
1124
    }
1016
}
1125
}
1017
1126
Lines 1409-1414 Link Here
1409
1518
1410
        // Create the new menu
1519
        // Create the new menu
1411
        m_newMenu = new KNewFileMenu(&m_actionCollection, "new_menu", QApplication::desktop());
1520
        m_newMenu = new KNewFileMenu(&m_actionCollection, "new_menu", QApplication::desktop());
1521
//	m_newMenu->setModal(false);
1522
	
1412
        connect(m_newMenu->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShowCreateNew()));
1523
        connect(m_newMenu->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShowCreateNew()));
1413
1524
1414
        m_actionCollection.addAction("lock_icons", lockIcons);
1525
        m_actionCollection.addAction("lock_icons", lockIcons);
Lines 1583-1588 Link Here
1583
    if (column != m_sortColumn) {
1694
    if (column != m_sortColumn) {
1584
        m_model->invalidate();
1695
        m_model->invalidate();
1585
        m_model->sort(column, Qt::AscendingOrder);
1696
        m_model->sort(column, Qt::AscendingOrder);
1697
        m_model->setDynamicSortFilter(true);
1586
        m_sortColumn = column;
1698
        m_sortColumn = column;
1587
        config().writeEntry("sortColumn", m_sortColumn);
1699
        config().writeEntry("sortColumn", m_sortColumn);
1588
        emit configNeedsSaving();
1700
        emit configNeedsSaving();
Lines 1683-1688 Link Here
1683
    // If the user has rearranged the icons, the view is no longer sorted
1795
    // If the user has rearranged the icons, the view is no longer sorted
1684
    if (m_sortColumn != -1) {
1796
    if (m_sortColumn != -1) {
1685
        m_sortColumn = -1;
1797
        m_sortColumn = -1;
1798
        m_model->setDynamicSortFilter(false);
1686
        updateSortActionsState();
1799
        updateSortActionsState();
1687
        config().writeEntry("sortColumn", m_sortColumn);
1800
        config().writeEntry("sortColumn", m_sortColumn);
1688
        emit configNeedsSaving();
1801
        emit configNeedsSaving();

Return to bug 342479