2 #include "mainwindow.h"
4 #include "locationbox.h"
5 #include "folderpanel.h"
6 #include "ui_folderpanel.h"
12 FolderPanel::FolderPanel(QWidget *parent) :
14 ui(new Ui::FolderPanel),
20 FolderPanel::~FolderPanel()
25 void FolderPanel::initialize(MainWindow *mainWnd)
27 qDebug() << "FolderPanel::initialize();";
31 connect(ui->searchBox, SIGNAL(textEdited(QString)), this, SLOT(searchItem(QString)));
32 connect(ui->folderView, SIGNAL(doubleClicked(QModelIndex)), mainWnd, SLOT(open(QModelIndex)));
33 connect(ui->folderView, SIGNAL(dropAccepted(QFileInfoList)), mainWnd, SLOT(dropAccept(QFileInfoList)));
34 connect(ui->folderView, SIGNAL(currentChanged(QFileInfo)), mainWnd, SLOT(currentChange(QFileInfo)));
35 connect(ui->folderView, SIGNAL(requestContextMenu(QContextMenuEvent*)), mainWnd, SLOT(showContextMenu(QContextMenuEvent*)));
36 connect(ui->folderView, SIGNAL(retrieveStarted(QString)), ui->locationBox, SLOT(setText(QString)));
37 connect(ui->folderView, SIGNAL(dataChanged()), this, SLOT(dataChange()));
38 connect(ui->folderView, SIGNAL(itemFound()), this, SLOT(itemFound()));
39 connect(ui->folderView, SIGNAL(itemNotFound()), this, SLOT(itemNotFound()));
40 connect(ui->bookmarkBtn, SIGNAL(clicked()), this, SLOT(addBookmark()));
43 ui->searchBox->setVisible(false);
46 ui->locationBox->initialize();
49 ui->folderView->initialize(mainWnd);
52 LocationBox *FolderPanel::locationBox() const
54 return ui->locationBox;
57 FolderView *FolderPanel::folderView() const
59 return ui->folderView;
62 SearchBox *FolderPanel::searchBox() const
67 QLabel *FolderPanel::filterLabel() const
69 return ui->filterLabel;
72 void FolderPanel::setNameFilters(const QString &filters)
74 QStringList list = filters.split(" ", QString::SkipEmptyParts);
78 ui->folderView->setNameFilters(list);
82 void FolderPanel::showNameFilters()
84 ui->filterLabel->setText(tr("フィルタ:") + ui->folderView->nameFilters().join(" "));
87 void FolderPanel::dataChange()
89 qDebug() << "FolderPanel::dataChange();";
91 FolderView *view = static_cast<FolderView*>(sender());
94 QFileInfoList list = view->checkedItems();
102 foreach (const QFileInfo &info, list) {
112 QString msg = QString::null;
113 if (numFolders > 0) {
114 msg += tr("%1個のフォルダ ").arg(numFolders);
117 msg += tr("%1個のファイル ").arg(numFiles);
120 if (!msg.isEmpty()) {
121 msg += tr("を選択 合計%1").arg(FilesizeToString(size));
124 ui->filterLabel->setText(msg);
128 void FolderPanel::addBookmark()
130 qDebug() << "FolderPanel::addBookmark();";
134 while (!settings.value(IniKey_BookmarkEntryName(i), "").toString().isEmpty()) {
138 QFileInfo info(ui->folderView->dir());
139 QString name = info.fileName();
140 if (name.isEmpty()) {
143 settings.setValue(IniKey_BookmarkEntryName(i), name);
144 settings.setValue(IniKey_BookmarkEntryPath(i), info.absoluteFilePath());
146 m_mainWnd->statusBar()->showMessage(tr("%1をブックマークに追加しました").arg(name));
149 void FolderPanel::itemFound()
151 qDebug() << "FolderPanel::itemFound";
153 QPalette pal = ui->searchBox->palette();
154 pal.setColor(QPalette::Text, QPalette().text().color());
155 ui->searchBox->setPalette(pal);
158 void FolderPanel::itemNotFound()
160 qDebug() << "FolderPanel::itemNotFound";
162 QPalette pal = ui->searchBox->palette();
163 pal.setColor(QPalette::Text, Qt::red);
164 ui->searchBox->setPalette(pal);
167 void FolderPanel::searchItem(const QString &text)
169 qDebug() << "FolderPanel::searchItem" << text;
171 if (text.right(1) == "/") {
173 ui->searchBox->setText(text.left(text.length() - 1));
174 ui->folderView->setFocus();
177 ui->folderView->searchItem(ui->searchBox->text());
181 void FolderPanel::focusInEvent(QFocusEvent *)
183 qDebug() << "FolderPanel::focusInEvent();";
185 ui->folderView->setFocus();