• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kget

  • sources
  • kde-4.12
  • kdenetwork
  • kget
  • conf
autopastemodel.h
Go to the documentation of this file.
1 /***************************************************************************
2 * Copyright (C) 2010 Matthias Fuchs <mat69@gmx.net> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program 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 *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18 ***************************************************************************/
19 
20 #ifndef AUTOPASTEMODEL
21 #define AUTOPASTEMODEL
22 
23 #include <QtCore/QAbstractTableModel>
24 #include <QtGui/QStyledItemDelegate>
25 
26 class AutoPasteDelegate : public QStyledItemDelegate
27 {
28  Q_OBJECT
29 
30  public:
31  AutoPasteDelegate(QAbstractItemModel *types, QAbstractItemModel *syntaxes, QObject *parent = 0);
32 
33  QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
34  void setEditorData(QWidget *editor, const QModelIndex &index) const;
35  void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
36  void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
37  QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
38 
39  private:
40  QAbstractItemModel *m_types;
41  QAbstractItemModel *m_syntaxes;
42 };
43 
44 class AutoPasteModel : public QAbstractTableModel
45 {
46  Q_OBJECT
47 
48  public:
49  enum DataType {
50  Type = 0,
51  Pattern,
52  PatternSyntax
53  };
54  enum TypeData {
55  Include = 0,
56  Exclude
57  };
58  enum PatternSyntaxData {
59  Wildcard = 0,
60  RegExp
61  };
62 
63  explicit AutoPasteModel(QObject *parent = 0);
64  ~AutoPasteModel();
65 
66  int rowCount(const QModelIndex &index = QModelIndex()) const;
67  int columnCount(const QModelIndex &index = QModelIndex()) const;
68  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
69  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
70  Qt::ItemFlags flags(const QModelIndex &index) const;
71  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
72  bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
73 
79  void addItem(TypeData dataType, PatternSyntaxData patternSyntax, const QString &pattern);
80 
88  bool moveItem(int sourceRow, int destinationRow);
89 
90  public slots:
95  void load();
96 
101  void save();
102 
106  void resetDefaults();
107 
108  private:
109  void addItems(const QList<int> &dataTypes, const QList<int> patternSyntaxes, const QStringList &patterns);
110 
111  private:
112  struct Data
113  {
114  TypeData type;
115  QString pattern;
116  PatternSyntaxData syntax;
117  };
118 
119  QList<Data> m_data;
120 };
121 
122 #endif
123 
AutoPasteModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Definition: autopastemodel.cpp:229
AutoPasteModel
Definition: autopastemodel.h:44
AutoPasteDelegate::setModelData
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
Definition: autopastemodel.cpp:92
AutoPasteModel::removeRows
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
Definition: autopastemodel.cpp:259
AutoPasteModel::PatternSyntaxData
PatternSyntaxData
Definition: autopastemodel.h:58
AutoPasteModel::rowCount
int rowCount(const QModelIndex &index=QModelIndex()) const
Definition: autopastemodel.cpp:148
AutoPasteModel::resetDefaults
void resetDefaults()
Resets the model to the default data.
Definition: autopastemodel.cpp:341
AutoPasteModel::~AutoPasteModel
~AutoPasteModel()
Definition: autopastemodel.cpp:144
QWidget
AutoPasteModel::DataType
DataType
Definition: autopastemodel.h:49
QObject
AutoPasteModel::RegExp
Definition: autopastemodel.h:60
QStyledItemDelegate
AutoPasteModel::TypeData
TypeData
Definition: autopastemodel.h:54
AutoPasteDelegate::createEditor
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: autopastemodel.cpp:35
AutoPasteDelegate::AutoPasteDelegate
AutoPasteDelegate(QAbstractItemModel *types, QAbstractItemModel *syntaxes, QObject *parent=0)
Definition: autopastemodel.cpp:28
AutoPasteModel::Include
Definition: autopastemodel.h:55
AutoPasteModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const
Definition: autopastemodel.cpp:222
AutoPasteModel::Wildcard
Definition: autopastemodel.h:59
AutoPasteModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Definition: autopastemodel.cpp:166
AutoPasteModel::data
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition: autopastemodel.cpp:183
AutoPasteModel::load
void load()
Loads the stored data.
Definition: autopastemodel.cpp:313
QAbstractItemModel
AutoPasteDelegate::setEditorData
void setEditorData(QWidget *editor, const QModelIndex &index) const
Definition: autopastemodel.cpp:63
AutoPasteDelegate
Definition: autopastemodel.h:26
AutoPasteModel::Type
Definition: autopastemodel.h:50
AutoPasteModel::columnCount
int columnCount(const QModelIndex &index=QModelIndex()) const
Definition: autopastemodel.cpp:157
AutoPasteDelegate::updateEditorGeometry
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: autopastemodel.cpp:124
AutoPasteModel::Pattern
Definition: autopastemodel.h:51
AutoPasteModel::moveItem
bool moveItem(int sourceRow, int destinationRow)
Moves an item to a new position.
Definition: autopastemodel.cpp:297
AutoPasteModel::PatternSyntax
Definition: autopastemodel.h:52
AutoPasteModel::save
void save()
Saves the current data.
Definition: autopastemodel.cpp:324
AutoPasteModel::addItem
void addItem(TypeData dataType, PatternSyntaxData patternSyntax, const QString &pattern)
Adds an an item.
Definition: autopastemodel.cpp:275
AutoPasteModel::AutoPasteModel
AutoPasteModel(QObject *parent=0)
Definition: autopastemodel.cpp:139
AutoPasteModel::Exclude
Definition: autopastemodel.h:56
QAbstractTableModel
AutoPasteDelegate::sizeHint
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: autopastemodel.cpp:130
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kget

Skip menu "kget"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal