Quark  0.1
RecentFileTableModel.h++
Go to the documentation of this file.
1 
2 #ifndef __libquark_gui_RecentFileTableModel_hxx
3 #define __libquark_gui_RecentFileTableModel_hxx
4 
6 #include <quark/RecentFile.h++>
7 
8 namespace quark {
9 namespace gui {
10 
22 class RecentFileTableModel : public BasicTableModel<RecentFile>
23 {
24  Q_OBJECT;
25 
26  public:
27 
38  RecentFileTableModel(const QString &settingName, int maxItems = 10,
39  QObject *parent = NULL);
40  virtual ~RecentFileTableModel();
41 
47  { _showFullPath = showFullPath; }
48 
50  bool showFullPath() const
51  { return(_showFullPath); }
52 
53  public slots:
54 
61  void addFile(const QString &path);
62 
66  void load();
67 
71  void save();
72 
73  protected:
74 
75  virtual QVariant getFieldValue(const RecentFile &item, int field) const;
76 
77  virtual QString itemMimeType() const;
78  virtual void writeItem(const RecentFile &item, QDataStream &stream);
79  virtual RecentFile *readItem(QDataStream &stream);
80 
81  private:
82 
83  int findFile(const QString &path) const;
84 
85  QString _settingName;
86  int _maxItems;
87  bool _showFullPath;
88  bool _loaded;
89 };
90 
91 } // namespace gui
92 } // namespace quark
93 
94 #endif // __libquark_gui_RecentFileTableModel_hxx
void addFile(const QString &path)
Adds a new file to the model.
RecentFileTableModel(const QString &settingName, int maxItems=10, QObject *parent=NULL)
Constructs a new RecentFileTableModel with the given attributes.
virtual void writeItem(const RecentFile &item, QDataStream &stream)
An object representing a recently opened file.
Definition: RecentFile.h++:16
void setShowFullPath(bool showFullPath)
Specifies whether the items will be visually represented by the full paths of the files...
Definition: RecentFileTableModel.h++:46
virtual QString itemMimeType() const
Returns the model&#39;s native MIME-type.
virtual QVariant getFieldValue(const RecentFile &item, int field) const
Returns the value of the given field of an object.
void load()
Loads the model from the settings.
Definition: BarChartView.h++:6
A partial implementation of AbstractTableModel that stores its elements in a QVector.
Definition: BasicTableModel.h++:17
void save()
Saves the model to the settings.
virtual QModelIndex parent(const QModelIndex &index) const
Specified by QAbstractItemModel.
A data model for storing a list of RecentFile objects, representing files that were "recently opened"...
Definition: RecentFileTableModel.h++:22
virtual RecentFile * readItem(QDataStream &stream)
Deserializes an item that is being dropped into the model.
bool showFullPath() const
Tests whether the model shows full paths.
Definition: RecentFileTableModel.h++:50