LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
unhidelistviewbase.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #include "unhidelistviewbase.h"
10 #include <QQmlContext>
11 #include <QQuickItem>
12 #include <QtDebug>
16 #include <util/sys/paths.h>
18 #include <util/qml/util.h>
19 
20 namespace LC::Util
21 {
23  const std::function<void (UnhideListModel*)>& filler, QWidget *parent)
24  : QQuickWidget (parent)
25  , Model_ (new UnhideListModel (this))
26  {
27  new UnhoverDeleteMixin (this);
28 
29  if (filler)
30  filler (Model_);
31 
32  const auto& file = GetSysPath (SysPath::QML, QStringLiteral ("common"), QStringLiteral ("UnhideListView.qml"));
33  if (file.isEmpty ())
34  {
35  qWarning () << Q_FUNC_INFO
36  << "file not found";
37  deleteLater ();
38  return;
39  }
40 
41  setWindowFlags (Qt::ToolTip);
43 
44  for (const auto& cand : GetPathCandidates (SysPath::QML, {}))
45  engine ()->addImportPath (cand);
46 
47  rootContext ()->setContextProperty (QStringLiteral ("unhideListModel"), Model_);
48  rootContext ()->setContextProperty (QStringLiteral ("colorProxy"),
49  new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this));
50  engine ()->addImageProvider (QStringLiteral ("ThemeIcons"), new Util::ThemeImageProvider (proxy));
51  setSource (QUrl::fromLocalFile (file));
52 
53  connect (rootObject (),
54  SIGNAL (closeRequested ()),
55  this,
56  SLOT (deleteLater ()));
57  connect (rootObject (),
58  SIGNAL (itemUnhideRequested (QString)),
59  this,
60  SIGNAL (itemUnhideRequested (QString)));
61  }
62 
64  {
65  Model_->invisibleRootItem ()->appendRows (items);
66  }
67 }
LC::Util::GetPathCandidates
QStringList GetPathCandidates(SysPath path, QString suffix)
Returns possible full paths for the path and subfolder.
Definition: paths.cpp:30
unhidelistviewbase.h
QList
Definition: ianrulesstorage.h:14
LC::Util
Definition: icoreproxy.h:33
themeimageprovider.h
LC::Util::UnhideListViewBase::SetItems
void SetItems(const QList< QStandardItem * > &items)
Sets the items of the view model to items.
Definition: unhidelistviewbase.cpp:69
colorthemeproxy.h
paths.h
unhoverdeletemixin.h
ICoreProxy_ptr
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition: icoreproxy.h:181
LC::Util::UnhideListViewBase::Model_
UnhideListModel *const Model_
Definition: unhidelistviewbase.h:40
LC::Util::SysPath::QML
@ QML
Root path for QML files.
LC::Util::ColorThemeProxy
Proxy for QML files to use colors from current color theme.
Definition: colorthemeproxy.h:105
LC::Util::GetSysPath
QString GetSysPath(SysPath path, const QString &suffix, const QString &filename)
Returns path to the file in the given root path and subfolder.
Definition: paths.cpp:62
util.h
LC::Util::EnableTransparency
void EnableTransparency(QQuickWidget *widget)
Definition: util.cpp:20
LC::Util::UnhideListViewBase::UnhideListViewBase
UnhideListViewBase(const ICoreProxy_ptr &proxy, const std::function< void(UnhideListModel *)> &modelFiller, QWidget *parent=nullptr)
Initializes the view and fills it with the items.
Definition: unhidelistviewbase.cpp:28
LC::Util::ThemeImageProvider
Provides icons from the current theme by their FDO name.
Definition: themeimageprovider.h:62
unhidelistmodel.h