~lubuntu-dev/lxde/libfm-qt-debian-git

« back to all changes in this revision

Viewing changes to src/list.h

  • Committer: Alf Gaida
  • Date: 2016-10-17 23:09:00 UTC
  • Revision ID: git-v1:5b9cc025327af9d0eb7f4b300f1dd10fce002a8f
Tags: debian/0.11.1-2
Cherry-picking upstream release 0.11.1.

* Syncded debian foo with experimental
* Bump compat to 10
* Removed --parallel from rules, standard compat 10
* Bumped Standards to 3.9.8, no changes needed
* Bump minimum version debhelper (>= 10)
* Bump minimum version libqt5xdg-dev (>= 2.0.0)
* Re-introduce build dependency liblxqt0-dev (>= 0.11.0)
* Added build dependency libqt5svg5-dev
* Added Recommends libfm-qt-l10n
* Exported LC_ALL=C.UTF-8 - define language settings for reproducible
  builds
* Hard override translation control
* Use DCMAKE_BUILD_TYPE=RelWithDebInfo
* Fixed copyright Format field, using https
* Fixed copyrights, removed obsolete files
* Fixed libfm-qt3.install, don't install translations

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2016 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2.1 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
17
 *
 
18
 */
 
19
 
 
20
#ifndef __LIBFM_QT_FM_LIST_H__
 
21
#define __LIBFM_QT_FM_LIST_H__
 
22
 
 
23
#include <libfm/fm.h>
 
24
#include <QObject>
 
25
#include <QtGlobal>
 
26
#include "libfmqtglobals.h"
 
27
 
 
28
 
 
29
namespace Fm {
 
30
 
 
31
 
 
32
class LIBFM_QT_API List {
 
33
public:
 
34
 
 
35
 
 
36
  List(FmListFuncs* funcs) {
 
37
    dataPtr_ = reinterpret_cast<FmList*>(fm_list_new(funcs));
 
38
  }
 
39
 
 
40
 
 
41
  // default constructor
 
42
  List() {
 
43
    dataPtr_ = nullptr;
 
44
  }
 
45
 
 
46
 
 
47
  List(FmList* dataPtr){
 
48
    dataPtr_ = dataPtr != nullptr ? reinterpret_cast<FmList*>(fm_list_ref(dataPtr)) : nullptr;
 
49
  }
 
50
 
 
51
 
 
52
  // copy constructor
 
53
  List(const List& other) {
 
54
    dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast<FmList*>(fm_list_ref(other.dataPtr_)) : nullptr;
 
55
  }
 
56
 
 
57
 
 
58
  // move constructor
 
59
  List(List&& other) {
 
60
    dataPtr_ = reinterpret_cast<FmList*>(other.takeDataPtr());
 
61
  }
 
62
 
 
63
 
 
64
  // destructor
 
65
  ~List() {
 
66
    if(dataPtr_ != nullptr) {
 
67
      fm_list_unref(dataPtr_);
 
68
    }
 
69
  }
 
70
 
 
71
 
 
72
  // create a wrapper for the data pointer without increasing the reference count
 
73
  static List wrapPtr(FmList* dataPtr) {
 
74
    List obj;
 
75
    obj.dataPtr_ = reinterpret_cast<FmList*>(dataPtr);
 
76
    return obj;
 
77
  }
 
78
 
 
79
  // disown the managed data pointer
 
80
  FmList* takeDataPtr() {
 
81
    FmList* data = reinterpret_cast<FmList*>(dataPtr_);
 
82
    dataPtr_ = nullptr;
 
83
    return data;
 
84
  }
 
85
 
 
86
  // get the raw pointer wrapped
 
87
  FmList* dataPtr() {
 
88
    return reinterpret_cast<FmList*>(dataPtr_);
 
89
  }
 
90
 
 
91
  // automatic type casting
 
92
  operator FmList*() {
 
93
    return dataPtr();
 
94
  }
 
95
 
 
96
  // automatic type casting
 
97
  operator void*() {
 
98
    return dataPtr();
 
99
  }
 
100
 
 
101
 
 
102
  // copy assignment
 
103
  List& operator=(const List& other) {
 
104
    if(dataPtr_ != nullptr) {
 
105
      fm_list_unref(dataPtr_);
 
106
    }
 
107
    dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast<FmList*>(fm_list_ref(other.dataPtr_)) : nullptr;
 
108
    return *this;
 
109
  }
 
110
 
 
111
 
 
112
  // move assignment
 
113
  List& operator=(List&& other) {
 
114
    dataPtr_ = reinterpret_cast<FmList*>(other.takeDataPtr());
 
115
    return *this;
 
116
  }
 
117
 
 
118
  bool isNull() {
 
119
    return (dataPtr_ == nullptr);
 
120
  }
 
121
 
 
122
  // methods
 
123
 
 
124
  void deleteLink(GList* l_) {
 
125
    fm_list_delete_link(dataPtr(), l_);
 
126
  }
 
127
 
 
128
 
 
129
  void removeAll(gpointer data) {
 
130
    fm_list_remove_all(dataPtr(), data);
 
131
  }
 
132
 
 
133
 
 
134
  void remove(gpointer data) {
 
135
    fm_list_remove(dataPtr(), data);
 
136
  }
 
137
 
 
138
 
 
139
  void clear(void) {
 
140
    fm_list_clear(dataPtr());
 
141
  }
 
142
 
 
143
 
 
144
 
 
145
private:
 
146
  FmList* dataPtr_; // data pointer for the underlying C struct
 
147
 
 
148
};
 
149
 
 
150
 
 
151
}
 
152
 
 
153
#endif // __LIBFM_QT_FM_LIST_H__