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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
/* ============================================================
*
* This file is a part of digiKam project
* http://www.digikam.org
*
* Date : 2006-07-24
* Description : a dialog to select a camera folders.
*
* Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* 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.
*
* ============================================================ */
// TQt includes.
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqframe.h>
// KDE includes.
#include <tdelocale.h>
#include <kiconloader.h>
#include <tdeapplication.h>
// Local includes.
#include "ddebug.h"
#include "cameraiconview.h"
#include "camerafolderitem.h"
#include "camerafolderview.h"
#include "camerafolderdialog.h"
#include "camerafolderdialog.moc"
namespace Digikam
{
CameraFolderDialog::CameraFolderDialog(TQWidget *parent, CameraIconView *cameraView,
const TQStringList& cameraFolderList,
const TQString& cameraName, const TQString& rootPath)
: KDialogBase(parent, 0, true,
i18n("%1 - Select Camera Folder").arg(cameraName),
Help|Ok|Cancel, Ok, true)
{
setHelp("camerainterface.anchor", "digikam");
enableButtonOK(false);
m_rootPath = rootPath;
TQFrame *page = makeMainWidget();
TQGridLayout* grid = new TQGridLayout(page, 2, 1, 0, spacingHint());
m_folderView = new CameraFolderView(page);
TQLabel *logo = new TQLabel(page);
TQLabel *message = new TQLabel(page);
TDEIconLoader* iconLoader = TDEApplication::kApplication()->iconLoader();
logo->setPixmap(iconLoader->loadIcon("digikam", TDEIcon::NoGroup, 128, TDEIcon::DefaultState, 0, true));
message->setText(i18n("<p>Please select the camera folder "
"where you want to upload the images.</p>"));
grid->addMultiCellWidget(logo, 0, 0, 0, 0);
grid->addMultiCellWidget(message, 1, 1, 0, 0);
grid->addMultiCellWidget(m_folderView, 0, 2, 1, 1);
grid->setRowStretch(2, 10);
m_folderView->addVirtualFolder(cameraName);
m_folderView->addRootFolder("/", cameraView->countItemsByFolder(rootPath));
for (TQStringList::const_iterator it = cameraFolderList.begin();
it != cameraFolderList.end(); ++it)
{
TQString folder(*it);
if (folder.startsWith(rootPath) && rootPath != TQString("/"))
folder.remove(0, rootPath.length());
if (folder != TQString("/") && !folder.isEmpty())
{
TQString root = folder.section( '/', 0, -2 );
if (root.isEmpty()) root = TQString("/");
TQString sub = folder.section( '/', -1 );
m_folderView->addFolder(root, sub, cameraView->countItemsByFolder(*it));
DDebug() << "Camera folder: '" << folder << "' (root='" << root << "', sub='" <<sub <<"')" << endl;
}
}
connect(m_folderView, TQ_SIGNAL(signalFolderChanged(CameraFolderItem*)),
this, TQ_SLOT(slotFolderPathSelectionChanged(CameraFolderItem*)));
resize(500, 500);
}
CameraFolderDialog::~CameraFolderDialog()
{
}
TQString CameraFolderDialog::selectedFolderPath()
{
TQListViewItem *item = m_folderView->currentItem();
if (!item) return TQString();
CameraFolderItem *folderItem = static_cast<CameraFolderItem *>(item);
if (folderItem->isVirtualFolder())
return TQString(m_rootPath);
// Case of Gphoto2 cameras. No need to duplicate root '/'.
if (m_rootPath == TQString("/"))
return(folderItem->folderPath());
return(m_rootPath + folderItem->folderPath());
}
void CameraFolderDialog::slotFolderPathSelectionChanged(CameraFolderItem* item)
{
if (item)
{
enableButtonOK(true);
DDebug() << "Camera folder path: " << selectedFolderPath() << endl;
}
else
{
enableButtonOK(false);
}
}
} // namespace Digikam
|