summaryrefslogtreecommitdiffstats
path: root/kipi-plugins/kameraklient/camerafolderview.cpp
blob: 1e51545d6e6f7a5ddb9f4e2a28a151dceae723c2 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* ============================================================
 * File  : camerafolderview.cpp
 * Author: Renchi Raju <renchi@pooh.tam.uiuc.edu>
 * Date  : 2003-01-23
 * Description : 
 * 
 * Copyright 2003 by Renchi Raju <renchi@pooh.tam.uiuc.edu>

 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option)
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * ============================================================ */

// KDE
#include <tdelocale.h>
#include <kiconloader.h>
// Local
#include "camerafolderitem.h"
#include "camerafolderview.h"

namespace KIPIKameraKlientPlugin
{

CameraFolderView::CameraFolderView(TQWidget* parent) : TDEListView(parent) {
    addColumn(i18n("Camera Folders"));
    setFullWidth(true);
    setDragEnabled(false);
    setDropVisualizer(false);
    setDropHighlighter(false);
    setAcceptDrops(true);
    cameraName_ = "Camera";
    virtualFolder_ = 0;
    rootFolder_    = 0;
    setupConnections();
}

CameraFolderView::~CameraFolderView() {
    
}

void CameraFolderView::setupConnections() {
    connect(this, TQT_SIGNAL(selectionChanged(TQListViewItem*)), this, TQT_SLOT(slotSelectionChanged(TQListViewItem*)));
}

void CameraFolderView::addVirtualFolder(const TQString& name) {
    cameraName_ = name;
    virtualFolder_ = new CameraFolderItem(this, cameraName_);
    virtualFolder_->setOpen(true);
}

void CameraFolderView::addRootFolder(const TQString& folder) {
    rootFolder_ = new CameraFolderItem(virtualFolder_, folder, folder);
    rootFolder_->setOpen(true);
}

CameraFolderItem* CameraFolderView::addFolder(const TQString& folder, const TQString& subFolder) {
    CameraFolderItem *parentItem = findFolder(folder);
    if (parentItem) {
        TQString path(folder);
        if (!folder.endsWith("/")) {
            path += "/";
	}
        path += subFolder;
        CameraFolderItem* item = new CameraFolderItem(parentItem, subFolder, path);
        item->setOpen(true);
        return item;
    } else {
        return 0;
    }
}

CameraFolderItem* CameraFolderView::findFolder(const TQString& folderPath) {
    TQListViewItemIterator it(this);
    for( ; it.current(); ++it) {
        CameraFolderItem* item = static_cast<CameraFolderItem*>(it.current());
        if (item->folderPath() == folderPath) {
            return item;
	}
    }
    return 0;
}

void CameraFolderView::slotSelectionChanged(TQListViewItem* item) {
    if (!item) {
	return;
    }
    emit signalFolderChanged(static_cast<CameraFolderItem *>(item));
}

CameraFolderItem* CameraFolderView::virtualFolder() {
    return virtualFolder_;    
}

CameraFolderItem* CameraFolderView::rootFolder() {
    return rootFolder_;
}

void CameraFolderView::clear() {
    TDEListView::clear();
    virtualFolder_ = 0;
    rootFolder_    = 0;
    emit signalCleared();
}

}  // NameSpace KIPIKameraKlientPlugin

#include "camerafolderview.moc"