forked from srazi/Saaghar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsaagharwidget.h
196 lines (161 loc) · 6.18 KB
/
saagharwidget.h
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/***************************************************************************
* This file is part of Saaghar, a Persian poetry software *
* *
* Copyright (C) 2010-2016 by S. Razi Alavizadeh *
* E-Mail: <[email protected]>, WWW: <http://pozh.org> *
* *
* 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 3 of the License, *
* (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, see http://www.gnu.org/licenses/ *
* *
***************************************************************************/
#ifndef SAAGHARWIDGET_H
#define SAAGHARWIDGET_H
#include <QObject>
#include <QWidget>
#include <QHBoxLayout>
#include <QScrollArea>
#include <QGroupBox>
#include <QTableWidget>
#include <QTableWidgetItem>
#include <QHeaderView>
#include <QPushButton>
#include <QToolBar>
#include <QUndoStack>
#include "databaseelements.h"
#include "bookmarks.h"
class DatabaseBrowser;
class QSearchLineEdit;
class QTextEdit;
class QSplitter;
#ifdef MEDIA_PLAYER
class QMusicPlayer;
#endif
class SaagharWidget : public QWidget
{
Q_OBJECT
public:
SaagharWidget(QWidget* parent, QToolBar* catsToolBar, QTableWidget* tableWidget, const QString &connectionID);
~SaagharWidget();
#ifdef MEDIA_PLAYER
static QMusicPlayer* musicPlayer;
#endif
enum PoemViewStyle {
TwoHemistichLine,
OneHemistichLine,
SteppedHemistichLine
};
enum PageType {
CategoryViewerPage,
PoemViewerPage
};
struct MetaInfo {
PageType type;
int id;
//QString mediaFile;
} pageMetaInfo;
QString currentCaption;
QPushButton* parentCatButton;
QTableWidget* tableViewWidget;
void applyDefaultSectionsHeight();
void resizeTable(QTableWidget* table);
bool nextPoem();
bool previousPoem();
void clearSaagharWidget();
QToolBar* parentCatsToolBar;
void showHome();
QString currentPageGanjoorUrl();
void loadSettings();
void showParentCategory(GanjoorCat category);
// empty connectionID means the current m_connectionID
void processClickedItem(QString type, int id, bool error, bool pushToStack = true, const QString &connectionID = QString());
void navigateToPage(QString type, int id, bool error);
int currentVerticalPosition();
void setVerticalPosition(int vPosition);
QString highlightCell(int vorder);
bool isLocalDataset() const;
QString connectionID() const;
int minMesraWidth;
bool m_hasPoem;
//STATIC Variables
static QString poetsImagesDir;
static QLocale persianIranLocal;
//static QFont tableFont;
static bool showBeytNumbers;
static bool backgroundImageState;
static PoemViewStyle CurrentViewStyle;
//static bool newSearchFlag;
//static bool newSearchSkipNonAlphabet;
static QString backgroundImagePath;
//static QColor textColor;
static QColor matchedTextColor;
static QColor backgroundColor;
static QTableWidgetItem* lastOveredItem;
static int maxPoetsPerGroup;
//bookmark widget
static Bookmarks* bookmarks;
//search field object
static QSearchLineEdit* lineEditSearchText;
//DataBase
static int computeRowHeight(const QFontMetrics &fontMetric, int textWidth, int width, int height = 0);
static QHash<int, QPair<QString, qint64> > mediaInfoCash;
static QHash<int, QString> longestHemistiches;
static QFont resolvedFont(const QString &name);
static QColor resolvedColor(const QString &name);
static QString rootTitle(bool localized = true);
int currentPoem;
int currentCat;
int currentParentID;
QStringList currentLocationList;
QString currentPoemTitle;
void homeResizeColsRows();
inline bool isDirty()
{return dirty;}
inline void setDirty()
{dirty = true;}
QStringList identifier();
void refresh();
inline void setMVPosition(int value) { m_vPosition = value; }
//Undo FrameWork
QUndoStack* undoStack;
private:
void doPoemLayout(int* prow, QTableWidgetItem* mesraItem, const QString ¤tVerseText, const QFontMetrics &fontMetric, VersePosition versePosition/*, Qt::Alignment beytAlignment*/);
QTextEdit* createItemForLongText(int row, int column, const QString &text = "", const QString &highlightText = "");
bool initializeCustomizedHome();
QMap<int, QPair<int, int> > rowParagraphHeightMap;
QMap<int, int> rowSingleHeightMap;
void showCategory(GanjoorCat category);
void showPoem(GanjoorPoem poem);
QPoint pressedPosition;
bool dirty;
int m_vPosition;
QString m_connectionID;
private slots:
void createCustomContextMenu(const QPoint &pos);
void parentCatClicked();
void clickedOnItem(int row, int col);
void pressedOnItem(int row, int col);
void setFromMVPosition();
#ifdef Q_OS_MAC
void forceReLayoutTable();
#endif
public slots:
QTableWidgetItem* scrollToFirstItemContains(const QString &phrase, bool pharseIsList = true, bool scroll = true);
signals:
void captionChanged();
void navNextActionState(bool);
void navPreviousActionState(bool);
void loadingStatusText(const QString &, int num = 0);
void createContextMenuRequested(const QPoint &);
void currentLocationChanged(const QStringList &, const QString &);
};
#endif // SAAGHARWIDGET_H