1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
/*********************************************************************************
NixNote - An open-source client for the Evernote service.
Copyright (C) 2013 Randy Baumgarte
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
***********************************************************************************/
#ifndef NNOTEBOOKVIEW_H
#define NNOTEBOOKVIEW_H
#include "nnotebookviewitem.h"
#include "treewidgeteditor.h"
#include <QTreeWidget>
#include <QMenu>
#include <QShortcut>
class NNotebookView : public QTreeWidget
{
Q_OBJECT
private:
virtual void mousePressEvent(QMouseEvent *event);
int filterPosition;
QMenu context;
QMenu *stackMenu;
QAction *addAction;
QAction *propertiesAction;
QAction *deleteAction;
QAction *renameAction;
QAction *newStackAction;
QAction *removeFromStackAction;
//QShortcut *renameShortcut;
QShortcut *addShortcut;
QShortcut *deleteShortcut;
TreeWidgetEditor *editor;
QHash<QString, QAction*> menuData;
int maxCount;
void sortStackMenu();
QImage *collapsedImage;
QImage *expandedImage;
private slots:
int calculateHeightRec(QTreeWidgetItem * item);
void calculateHeight();
void editComplete();
public:
explicit NNotebookView(QWidget *parent = 0);
~NNotebookView();
NNotebookViewItem *root;
void resetSize();
void updateSelection();
void loadData();
bool rebuildNotebookTreeNeeded;
void contextMenuEvent(QContextMenuEvent *event);
QHash<qint32, NNotebookViewItem*> dataStore;
QHash<QString, NNotebookViewItem*> stackStore;
QSize sizeHint();
void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const;
void reloadIcons();
signals:
void updateSelectionRequested();
void notebookRenamed(qint32 lid, QString oldName, QString newName);
void notebookDeleted(qint32 lid, QString name);
void notebookAdded(qint32 lid);
void stackAdded(QString name);
void stackDeleted(QString name);
void stackRenamed(QString oldName, QString newName);
void notebookSelectionChanged(qint32);
void updateNoteList(qint32 noteLid, int column, QVariant tags);
void updateCounts();
public slots:
void notebookUpdated(qint32 lid, QString name, QString stackName, bool linked, bool shared);
void rebuildTree();
void buildSelection();
void addRequested();
void propertiesRequested();
void deleteRequested();
void renameRequested();
void moveToStackRequested();
void moveToNewStackRequested();
void removeFromStackRequested();
void notebookExpunged(qint32 lid);
void updateTotals(qint32 lid, qint32 subTotal, qint32 total);
bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action);
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void mouseMoveEvent(QMouseEvent *event);
};
#endif // NNOTEBOOKVIEW_H
|