|
a/dirbrowser/dirbrowser.cpp |
|
b/dirbrowser/dirbrowser.cpp |
|
... |
|
... |
19 |
#include <QTabBar>
|
19 |
#include <QTabBar>
|
20 |
#include <QIcon>
|
20 |
#include <QIcon>
|
21 |
#include <QTimer>
|
21 |
#include <QTimer>
|
22 |
#include <QShortcut>
|
22 |
#include <QShortcut>
|
23 |
#include <QLineEdit>
|
23 |
#include <QLineEdit>
|
|
|
24 |
#include <QCompleter>
|
24 |
|
25 |
|
25 |
#include "dirbrowser.h"
|
26 |
#include "dirbrowser.h"
|
26 |
#include "application.h"
|
27 |
#include "application.h"
|
27 |
#include "HelperStructs/Helper.h"
|
28 |
#include "HelperStructs/Helper.h"
|
28 |
#include "upadapt/upputils.h"
|
29 |
#include "upadapt/upputils.h"
|
29 |
#include "GUI/prefs/sortprefs.h"
|
30 |
#include "GUI/prefs/sortprefs.h"
|
30 |
#include "HelperStructs/CSettingsStorage.h"
|
31 |
#include "HelperStructs/CSettingsStorage.h"
|
31 |
|
32 |
|
|
|
33 |
static const QString cstr_searchhistorykey("/Upplay/dirbrowser/searchhistory");
|
|
|
34 |
|
32 |
DirBrowser::DirBrowser(QWidget *parent, std::shared_ptr<Playlist> pl)
|
35 |
DirBrowser::DirBrowser(QWidget *parent, std::shared_ptr<Playlist> pl)
|
33 |
: QWidget(parent), ui(new Ui::DirBrowser), m_pl(pl), m_insertactive(false),
|
36 |
: QWidget(parent), ui(new Ui::DirBrowser), m_pl(pl)
|
34 |
m_randplayer(0)
|
|
|
35 |
{
|
37 |
{
|
36 |
QKeySequence seq;
|
38 |
QKeySequence seq;
|
37 |
QShortcut *sc;
|
39 |
QShortcut *sc;
|
38 |
|
40 |
|
39 |
ui->setupUi(this);
|
41 |
ui->setupUi(this);
|
|
... |
|
... |
90 |
sc = new QShortcut(seq, this);
|
92 |
sc = new QShortcut(seq, this);
|
91 |
connect(sc, SIGNAL(activated()), this, SLOT(toggleSearchKind()));
|
93 |
connect(sc, SIGNAL(activated()), this, SLOT(toggleSearchKind()));
|
92 |
connect(ui->serverSearchCB, SIGNAL(stateChanged(int)),
|
94 |
connect(ui->serverSearchCB, SIGNAL(stateChanged(int)),
|
93 |
this, SLOT(onSearchKindChanged(int)));
|
95 |
this, SLOT(onSearchKindChanged(int)));
|
94 |
connect(ui->execSearchPB, SIGNAL(clicked()), this, SLOT(serverSearch()));
|
96 |
connect(ui->execSearchPB, SIGNAL(clicked()), this, SLOT(serverSearch()));
|
95 |
|
|
|
96 |
onSearchKindChanged(int(ui->serverSearchCB->checkState()));
|
97 |
onSearchKindChanged(int(ui->serverSearchCB->checkState()));
|
|
|
98 |
|
|
|
99 |
ui->searchCMB->setInsertPolicy(QComboBox::NoInsert);
|
|
|
100 |
QSettings settings;
|
|
|
101 |
m_searchHistory =
|
|
|
102 |
settings.value(cstr_searchhistorykey).toStringList();
|
|
|
103 |
ui->searchCMB->addItems(m_searchHistory);
|
|
|
104 |
ui->searchCMB->setEditText("");
|
|
|
105 |
ui->searchCMB->completer()->setModel(0);
|
|
|
106 |
|
97 |
ui->execSearchPB->hide();
|
107 |
ui->execSearchPB->hide();
|
98 |
setPlaylist(pl);
|
108 |
setPlaylist(pl);
|
99 |
}
|
109 |
}
|
100 |
|
110 |
|
101 |
void DirBrowser::setPlaylist(std::shared_ptr<Playlist> pl)
|
111 |
void DirBrowser::setPlaylist(std::shared_ptr<Playlist> pl)
|
|
... |
|
... |
216 |
} else {
|
226 |
} else {
|
217 |
qDebug() << "changeTabTitle: Widget not found in tabs: " << w;
|
227 |
qDebug() << "changeTabTitle: Widget not found in tabs: " << w;
|
218 |
}
|
228 |
}
|
219 |
}
|
229 |
}
|
220 |
|
230 |
|
|
|
231 |
void DirBrowser::saveSearchHistory()
|
|
|
232 |
{
|
|
|
233 |
// Search terms history:
|
|
|
234 |
// We want to have the new text at the top and any older identical
|
|
|
235 |
// entry to be erased. There is no standard qt policy to do this ?
|
|
|
236 |
// So do it by hand.
|
|
|
237 |
QString txt = ui->searchCMB->currentText();
|
|
|
238 |
QString txtt = txt.trimmed();
|
|
|
239 |
int index = ui->searchCMB->findText(txtt);
|
|
|
240 |
if (index > 0) {
|
|
|
241 |
ui->searchCMB->removeItem(index);
|
|
|
242 |
}
|
|
|
243 |
if (index != 0) {
|
|
|
244 |
ui->searchCMB->insertItem(0, txtt);
|
|
|
245 |
ui->searchCMB->setEditText(txt);
|
|
|
246 |
}
|
|
|
247 |
|
|
|
248 |
// Limit saved size to reasonable value
|
|
|
249 |
const int maxcount = 200;
|
|
|
250 |
int count = ui->searchCMB->count();
|
|
|
251 |
if (count > maxcount) {
|
|
|
252 |
count = maxcount;
|
|
|
253 |
}
|
|
|
254 |
m_searchHistory.clear();
|
|
|
255 |
for (int index = 0; index < count; index++) {
|
|
|
256 |
m_searchHistory.push_back(ui->searchCMB->itemText(index));
|
|
|
257 |
}
|
|
|
258 |
QSettings settings;
|
|
|
259 |
settings.setValue(cstr_searchhistorykey, m_searchHistory);
|
|
|
260 |
}
|
|
|
261 |
|
221 |
// Any of the tabs searchcaps changed. Update the current one just in case.
|
262 |
// Any of the tabs searchcaps changed. Update the current one just in case.
|
222 |
void DirBrowser::onSearchcapsChanged()
|
263 |
void DirBrowser::onSearchcapsChanged()
|
223 |
{
|
264 |
{
|
224 |
onCurrentTabChanged(-1);
|
265 |
onCurrentTabChanged(-1);
|
225 |
}
|
266 |
}
|
|
... |
|
... |
310 |
QString text = ui->searchCMB->lineEdit()->text();
|
351 |
QString text = ui->searchCMB->lineEdit()->text();
|
311 |
if (ui->searchCMB->findText(text))
|
352 |
if (ui->searchCMB->findText(text))
|
312 |
ui->searchCMB->insertItem(0, text);
|
353 |
ui->searchCMB->insertItem(0, text);
|
313 |
searchNext();
|
354 |
searchNext();
|
314 |
}
|
355 |
}
|
|
|
356 |
saveSearchHistory();
|
315 |
}
|
357 |
}
|
316 |
|
358 |
|
317 |
void DirBrowser::serverSearch()
|
359 |
void DirBrowser::serverSearch()
|
318 |
{
|
360 |
{
|
319 |
QString text = ui->searchCMB->lineEdit()->text().trimmed();
|
361 |
QString text = ui->searchCMB->lineEdit()->text().trimmed();
|