summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/gui/filesystem.cpp
blob: d84e9f8992245d86b72d3031a7f116ffef9d2c71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * GPLv2 zecke@handhelds.org
 * No WArranty...
 */
#include <stdlib.h>
#include <qpopupmenu.h>
#include <qtoolbar.h>

#include <opie2/oresource.h>

#include <qpe/storage.h>


#include "filesystem.h"

PFileSystem::PFileSystem(  QToolBar* bar)
    : QToolButton( bar )
{
    setIconSet( Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ) );

    m_pop = new QPopupMenu( this );
    connect( m_pop, SIGNAL( activated( int ) ),
             this, SLOT(slotSelectDir( int ) ) );

    m_storage = new StorageInfo();
    connect(m_storage, SIGNAL(disksChanged() ),
            this, SLOT( changed() ) );
    changed();

    connect(this,SIGNAL(pressed()),SLOT(slotPopUp()));
}

PFileSystem::~PFileSystem() {
    delete m_storage;
}


void PFileSystem::changed() {
    m_pop->clear();
    m_dev.clear();

    /* home dir, too */
    QString f = getenv( "HOME" );
    if (!f.isEmpty()) {
        m_dev.insert("Home directory",f);
        m_pop->insertItem("Home directory");
    }

    const QList<FileSystem> &fs = m_storage->fileSystems();
    QListIterator<FileSystem> it(fs );
    for ( ; it.current(); ++it ) {
        const QString disk = (*it)->name();
        const QString path = (*it)->path();
        m_dev.insert( disk, path );
        m_pop->insertItem( disk );
    }
}

void PFileSystem::slotPopUp() {
    m_pop->exec(QCursor::pos());
    setDown(false);
}

void PFileSystem::slotSelectDir( int id ) {
    emit changeDir( m_dev[m_pop->text(id )] );
}