Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
geometrize::dialog::RecentTasksList::RecentTasksListImpl Class Reference
Collaboration diagram for geometrize::dialog::RecentTasksList::RecentTasksListImpl:
Collaboration graph
[legend]

Public Member Functions

 RecentTasksListImpl (RecentTasksList *pQ)
 
RecentTasksListImpl operator= (const RecentTasksListImpl &)=delete
 
 RecentTasksListImpl (const RecentTasksListImpl &)=delete
 
 ~RecentTasksListImpl ()=default
 
void setRecentItems (RecentItems *recents)
 
void clearItemDataAndMenu () const
 
void removeItemDataAndMenuItems (const QList< QListWidgetItem * > &items)
 
void onLanguageChange ()
 

Static Public Member Functions

static QString getDisplayNameForTaskPath (const QUrl &url)
 

Private Member Functions

void populateUi ()
 
void loadExistingItems ()
 
void setupConnections ()
 
void addItem (const RecentItem &recentItem) const
 
void removeItem (const QString &key) const
 
void clear () const
 
QString getMenuItemKey (const QListWidgetItem *const item) const
 
void setMenuItemKey (QListWidgetItem *item, const QString &key) const
 

Private Attributes

RecentTasksListq
 
RecentItemsm_recents
 
std::vector
< QMetaObject::Connection > 
m_connections
 

Constructor & Destructor Documentation

geometrize::dialog::RecentTasksList::RecentTasksListImpl::RecentTasksListImpl ( RecentTasksList pQ)
inline
26  : q{pQ}, m_recents{nullptr}
27  {
28  q->setSizeAdjustPolicy(QListWidget::AdjustToContents);
29  q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
30  populateUi();
31  }
RecentTasksList * q
Definition: recenttaskslist.cpp:168
void populateUi()
Definition: recenttaskslist.cpp:85
RecentItems * m_recents
Definition: recenttaskslist.cpp:169
geometrize::dialog::RecentTasksList::RecentTasksListImpl::RecentTasksListImpl ( const RecentTasksListImpl )
delete
geometrize::dialog::RecentTasksList::RecentTasksListImpl::~RecentTasksListImpl ( )
default

Member Function Documentation

void geometrize::dialog::RecentTasksList::RecentTasksListImpl::addItem ( const RecentItem recentItem) const
inlineprivate
127  {
128  dialog::TaskItemWidget* button{new dialog::TaskItemWidget(recentItem.getKey(), recentItem.getDisplayName(),
129  [](const QString& taskItemId) {
130  geometrize::util::openTasks({taskItemId}, false);
131  },
132  [](const QString& taskItemId) {
133  geometrize::getRecentItems().remove(taskItemId);
134  })};
135  QListWidgetItem* item{new QListWidgetItem()};
136  item->setToolTip(recentItem.getKey());
137  item->setSizeHint(button->sizeHint());
138  setMenuItemKey(item, recentItem.getKey());
139  q->addItem(item);
140  q->setItemWidget(item, button);
141  }
RecentTasksList * q
Definition: recenttaskslist.cpp:168
RecentItems & getRecentItems()
getRecentItems Gets a reference to the recent files list.
Definition: recentitems.cpp:206
void remove(const QString &itemId)
remove Removes an item from the recent items.
Definition: recentitems.cpp:190
void openTasks(const QStringList &urls, const bool addToRecents)
Definition: taskutil.cpp:56
void setMenuItemKey(QListWidgetItem *item, const QString &key) const
Definition: recenttaskslist.cpp:163

Here is the call graph for this function:

Here is the caller graph for this function:

void geometrize::dialog::RecentTasksList::RecentTasksListImpl::clear ( ) const
inlineprivate
154  {
155  q->clear();
156  }
RecentTasksList * q
Definition: recenttaskslist.cpp:168

Here is the caller graph for this function:

void geometrize::dialog::RecentTasksList::RecentTasksListImpl::clearItemDataAndMenu ( ) const
inline
62  {
63  if(m_recents == nullptr) {
64  return;
65  }
66  m_recents->clear();
67  }
RecentItems * m_recents
Definition: recenttaskslist.cpp:169
void clear()
clear Removes all items from the recent items.
Definition: recentitems.cpp:196

Here is the call graph for this function:

static QString geometrize::dialog::RecentTasksList::RecentTasksListImpl::getDisplayNameForTaskPath ( const QUrl &  url)
inlinestatic
38  {
39  if(url.isEmpty()) {
40  return "";
41  }
42 
43  // Look for a filename first
44  const QString fileName{url.fileName(QUrl::FullyDecoded)};
45  if(!fileName.isEmpty() ) {
46  return fileName;
47  }
48 
49  // Otherwise return only a trimmed part of the URL's path
50  return url.path(QUrl::FullyDecoded).rightJustified(50, '.', false);
51  }

Here is the caller graph for this function:

QString geometrize::dialog::RecentTasksList::RecentTasksListImpl::getMenuItemKey ( const QListWidgetItem *const  item) const
inlineprivate
159  {
160  return item->data(Qt::UserRole).toString();
161  }

Here is the caller graph for this function:

void geometrize::dialog::RecentTasksList::RecentTasksListImpl::loadExistingItems ( )
inlineprivate
91  {
92  if(m_recents == nullptr) {
93  return;
94  }
95 
96  const QList<RecentItem> items{m_recents->getItems()};
97  for(const RecentItem& item : items) {
98  addItem(item);
99  }
100  }
RecentItems * m_recents
Definition: recenttaskslist.cpp:169
QList< RecentItem > getItems() const
getItems Gets the recent items.
Definition: recentitems.cpp:172
void addItem(const RecentItem &recentItem) const
Definition: recenttaskslist.cpp:126

Here is the call graph for this function:

Here is the caller graph for this function:

void geometrize::dialog::RecentTasksList::RecentTasksListImpl::onLanguageChange ( )
inline
80  {
81  populateUi();
82  }
void populateUi()
Definition: recenttaskslist.cpp:85

Here is the call graph for this function:

RecentTasksListImpl geometrize::dialog::RecentTasksList::RecentTasksListImpl::operator= ( const RecentTasksListImpl )
delete
void geometrize::dialog::RecentTasksList::RecentTasksListImpl::populateUi ( )
inlineprivate
86  {
87 
88  }

Here is the caller graph for this function:

void geometrize::dialog::RecentTasksList::RecentTasksListImpl::removeItem ( const QString &  key) const
inlineprivate
144  {
145  for(int i = 0; i < q->count(); i++) {
146  if(getMenuItemKey(q->item(i)) == key) {
147  q->takeItem(i);
148  return;
149  }
150  }
151  }
RecentTasksList * q
Definition: recenttaskslist.cpp:168
QString getMenuItemKey(const QListWidgetItem *const item) const
Definition: recenttaskslist.cpp:158

Here is the call graph for this function:

Here is the caller graph for this function:

void geometrize::dialog::RecentTasksList::RecentTasksListImpl::removeItemDataAndMenuItems ( const QList< QListWidgetItem * > &  items)
inline
70  {
71  if(m_recents == nullptr) {
72  return;
73  }
74  for(const QListWidgetItem* const item : items) {
76  }
77  }
void remove(const QString &itemId)
remove Removes an item from the recent items.
Definition: recentitems.cpp:190
QString getMenuItemKey(const QListWidgetItem *const item) const
Definition: recenttaskslist.cpp:158
RecentItems * m_recents
Definition: recenttaskslist.cpp:169

Here is the call graph for this function:

void geometrize::dialog::RecentTasksList::RecentTasksListImpl::setMenuItemKey ( QListWidgetItem *  item,
const QString &  key 
) const
inlineprivate
164  {
165  item->setData(Qt::UserRole, key);
166  }

Here is the caller graph for this function:

void geometrize::dialog::RecentTasksList::RecentTasksListImpl::setRecentItems ( RecentItems recents)
inline
54  {
55  m_recents = recents;
56  q->clear();
59  }
RecentTasksList * q
Definition: recenttaskslist.cpp:168
void setupConnections()
Definition: recenttaskslist.cpp:102
RecentItems * m_recents
Definition: recenttaskslist.cpp:169
void loadExistingItems()
Definition: recenttaskslist.cpp:90

Here is the call graph for this function:

void geometrize::dialog::RecentTasksList::RecentTasksListImpl::setupConnections ( )
inlineprivate
103  {
104  for(auto& connection : m_connections) {
105  QObject::disconnect(connection);
106  }
107  m_connections.clear();
108 
109  if(m_recents == nullptr) {
110  return;
111  }
112 
113  m_connections.push_back(connect(m_recents, &RecentItems::signal_added, [this](const RecentItem& item) {
114  addItem(item);
115  }));
116 
117  m_connections.push_back(connect(m_recents, &RecentItems::signal_cleared, [this]() {
118  clear();
119  }));
120 
121  m_connections.push_back(connect(m_recents, &RecentItems::signal_removed, [this](const QString& key) {
122  removeItem(key);
123  }));
124  }
void clear() const
Definition: recenttaskslist.cpp:153
void signal_removed(const QString &itemId)
signal_removed is emitted after an item is removed.
RecentItems * m_recents
Definition: recenttaskslist.cpp:169
void signal_added(const RecentItem &item)
signal_added is emitted after an item is added.
void addItem(const RecentItem &recentItem) const
Definition: recenttaskslist.cpp:126
std::vector< QMetaObject::Connection > m_connections
Definition: recenttaskslist.cpp:170
void removeItem(const QString &key) const
Definition: recenttaskslist.cpp:143
void signal_cleared()
signal_cleared is emitted after the recent items are cleared.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

std::vector<QMetaObject::Connection> geometrize::dialog::RecentTasksList::RecentTasksListImpl::m_connections
private
RecentItems* geometrize::dialog::RecentTasksList::RecentTasksListImpl::m_recents
private
RecentTasksList* geometrize::dialog::RecentTasksList::RecentTasksListImpl::q
private

The documentation for this class was generated from the following file: