├── .gitignore
├── FastTable.pro
├── README
├── Resources.qrc
├── Resources.rc
├── TODO.txt
├── examples
└── VsTableWidget
│ ├── VsTableWidget.pro
│ ├── main.cpp
│ ├── mainwindow.cpp
│ ├── mainwindow.h
│ ├── mainwindow.ui
│ ├── statisticsframe.cpp
│ ├── statisticsframe.h
│ └── statisticsframe.ui
├── images
├── CellBottom.png
├── CellBottomLeft.png
├── CellBottomLeftSelected.png
├── CellBottomRight.png
├── CellBottomRightSelected.png
├── CellBottomSelected.png
├── CellCenter.png
├── CellCenterSelected.png
├── CellLeft.png
├── CellLeftSelected.png
├── CellRight.png
├── CellRightSelected.png
├── CellTop.png
├── CellTopLeft.png
├── CellTopLeftSelected.png
├── CellTopRight.png
├── CellTopRightSelected.png
├── CellTopSelected.png
├── Find.png
└── icon.ico
├── push.sh
└── src
├── controller
├── aligndialog.cpp
├── aligndialog.h
├── aligndialog.ui
├── controllerdialog.cpp
├── controllerdialog.h
├── controllerdialog.ui
├── customfasttablepersonal.cpp
├── customfasttablepersonal.h
├── fasttablepersonal.cpp
├── fasttablepersonal.h
├── viewdialog.cpp
├── viewdialog.h
└── viewdialog.ui
├── fasttable
├── customfasttablewidget.cpp
├── customfasttablewidget.h
├── fastdefines.h
├── fasttable.pri
├── fasttablewidget.cpp
├── fasttablewidget.h
└── optimallist
│ ├── optimallist.cpp
│ ├── optimallist.h
│ └── optimallist.pri
├── main.cpp
├── main
├── mainwindow.cpp
├── mainwindow.h
└── mainwindow.ui
└── tests
├── publictablewidget.cpp
├── publictablewidget.h
├── testdialog.cpp
├── testdialog.h
├── testdialog.ui
├── testframe.cpp
├── testframe.h
└── testframe.ui
/.gitignore:
--------------------------------------------------------------------------------
1 | *build-*
2 | debug/
3 | release/
4 | *.pro.user*
5 | Makefile*
6 | *.pdb
--------------------------------------------------------------------------------
/FastTable.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2011-07-16T23:29:32
4 | #
5 | #-------------------------------------------------
6 |
7 | include("src/fasttable/fasttable.pri")
8 |
9 | QT += core gui
10 |
11 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
12 |
13 | TARGET = FastTable
14 | TEMPLATE = app
15 |
16 | RC_FILE = Resources.rc
17 | RESOURCES += Resources.qrc
18 |
19 | CONFIG (debug, debug|release) {
20 | DESTDIR = debug/
21 | OBJECTS_DIR = debug/gen
22 | MOC_DIR = debug/gen
23 | RCC_DIR = debug/gen
24 | } else {
25 | DESTDIR = release/
26 | OBJECTS_DIR = release/gen
27 | MOC_DIR = release/gen
28 | RCC_DIR = release/gen
29 | }
30 |
31 | SOURCES += \
32 | src/controller/aligndialog.cpp \
33 | src/controller/controllerdialog.cpp \
34 | src/controller/customfasttablepersonal.cpp \
35 | src/controller/fasttablepersonal.cpp \
36 | src/controller/viewdialog.cpp \
37 | src/main.cpp \
38 | src/main/mainwindow.cpp \
39 | src/tests/publictablewidget.cpp \
40 | src/tests/testdialog.cpp \
41 | src/tests/testframe.cpp
42 |
43 | HEADERS += \
44 | src/controller/aligndialog.h \
45 | src/controller/controllerdialog.h \
46 | src/controller/customfasttablepersonal.h \
47 | src/controller/fasttablepersonal.h \
48 | src/controller/viewdialog.h \
49 | src/main/mainwindow.h \
50 | src/tests/publictablewidget.h \
51 | src/tests/testdialog.h \
52 | src/tests/testframe.h
53 |
54 | FORMS += \
55 | src/controller/aligndialog.ui \
56 | src/controller/controllerdialog.ui \
57 | src/controller/viewdialog.ui \
58 | src/main/mainwindow.ui \
59 | src/tests/testdialog.ui \
60 | src/tests/testframe.ui
61 |
62 | OTHER_FILES += \
63 | TODO.txt
64 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/README
--------------------------------------------------------------------------------
/Resources.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | images/CellTopSelected.png
4 | images/CellBottom.png
5 | images/CellBottomLeft.png
6 | images/CellBottomLeftSelected.png
7 | images/CellBottomRight.png
8 | images/CellBottomRightSelected.png
9 | images/CellBottomSelected.png
10 | images/CellCenter.png
11 | images/CellCenterSelected.png
12 | images/CellLeft.png
13 | images/CellLeftSelected.png
14 | images/CellRight.png
15 | images/CellRightSelected.png
16 | images/CellTop.png
17 | images/CellTopLeft.png
18 | images/CellTopLeftSelected.png
19 | images/CellTopRight.png
20 | images/CellTopRightSelected.png
21 | images/Find.png
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Resources.rc:
--------------------------------------------------------------------------------
1 | IDI_ICON1 ICON DISCARDABLE "images/Icon.ico"
2 |
--------------------------------------------------------------------------------
/TODO.txt:
--------------------------------------------------------------------------------
1 | Full column selection and merged headers cells
2 | Check for asserts
3 | Cell editing
4 | Sort
5 | Cell widgets
6 | Merge and mouse
7 | Merge and keyboard
8 | Merge and cell editing
9 | Action queue to remove unnecessary function calls
10 | Cell flags (Selection, Editing, Enabled)
11 | Selection types: Select row, column, cell
12 | Use setCapacity on clear and setRowCount...
13 | Optimize painting with selecting update rectangles
14 |
--------------------------------------------------------------------------------
/examples/VsTableWidget/VsTableWidget.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2012-04-25T10:48:37
4 | #
5 | #-------------------------------------------------
6 |
7 | include("../../src/fasttable/fasttable.pri")
8 |
9 | QT += core gui
10 |
11 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
12 |
13 | TARGET = VsTableWidget
14 | TEMPLATE = app
15 |
16 | CONFIG (debug, debug|release) {
17 | DESTDIR = debug/
18 | OBJECTS_DIR = debug/gen
19 | MOC_DIR = debug/gen
20 | RCC_DIR = debug/gen
21 | } else {
22 | DESTDIR = release/
23 | OBJECTS_DIR = release/gen
24 | MOC_DIR = release/gen
25 | RCC_DIR = release/gen
26 | }
27 |
28 | SOURCES += main.cpp\
29 | mainwindow.cpp \
30 | statisticsframe.cpp
31 |
32 | HEADERS += mainwindow.h \
33 | statisticsframe.h
34 |
35 | FORMS += mainwindow.ui \
36 | statisticsframe.ui
--------------------------------------------------------------------------------
/examples/VsTableWidget/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "mainwindow.h"
3 |
4 | int main(int argc, char *argv[])
5 | {
6 | QApplication a(argc, argv);
7 | MainWindow w;
8 | w.show();
9 |
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/examples/VsTableWidget/mainwindow.cpp:
--------------------------------------------------------------------------------
1 | #include "mainwindow.h"
2 | #include "ui_mainwindow.h"
3 |
4 | #include "../../src/fasttable/fasttablewidget.h"
5 |
6 | MainWindow::MainWindow(QWidget *parent) :
7 | QMainWindow(parent),
8 | ui(new Ui::MainWindow)
9 | {
10 | ui->setupUi(this);
11 |
12 | StatisticsFrame* aFrame;
13 |
14 | aFrame=new StatisticsFrame(new CustomFastTableWidget(this), this);
15 | mFrames.append(aFrame);
16 | ui->mainTabWidget->addTab(aFrame, "CustomFastTableWidget");
17 |
18 | aFrame=new StatisticsFrame(new FastTableWidget(this), this);
19 | mFrames.append(aFrame);
20 | ui->mainTabWidget->addTab(aFrame, "FastTableWidget");
21 |
22 | aFrame=new StatisticsFrame(new QTableWidget(this), this);
23 | mFrames.append(aFrame);
24 | ui->mainHorizontalLayout->addWidget(aFrame);
25 |
26 | ui->cloneTabWidget->setVisible(false);
27 |
28 | QTimer::singleShot(0, this, SLOT(startComparing()));
29 | }
30 |
31 | MainWindow::~MainWindow()
32 | {
33 | delete ui;
34 | }
35 |
36 | void MainWindow::startComparing()
37 | {
38 | for (int i=0; imainTabWidget->setCurrentIndex(i);
43 | }
44 |
45 | mFrames.at(i)->startGetData();
46 | }
47 |
48 | for (int i=0; imTableWidget;
51 | }
52 |
53 | ui->mainHorizontalLayout->removeWidget(mFrames.last());
54 | ui->mainTabWidget->addTab(mFrames.last(), "QTableWidget");
55 |
56 | for (int i=0; imainTabWidget->count(); i++)
57 | {
58 | ui->cloneTabWidget->addTab(new StatisticsFrame((StatisticsFrame*)ui->mainTabWidget->widget(i), this), ui->mainTabWidget->tabText(i));
59 | }
60 |
61 | ui->cloneTabWidget->setVisible(true);
62 |
63 | resize(width(), 0);
64 |
65 | ui->mainTabWidget->setCurrentIndex(0);
66 | ui->cloneTabWidget->setCurrentIndex(ui->cloneTabWidget->count()-1);
67 |
68 | connect(ui->mainTabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
69 | connect(ui->cloneTabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
70 |
71 | tabChanged(-1);
72 | }
73 |
74 | void MainWindow::tabChanged(int index)
75 | {
76 | StatisticsFrame *aLeftFrame=(StatisticsFrame *)ui->mainTabWidget->currentWidget();
77 | StatisticsFrame *aRightFrame=(StatisticsFrame *)ui->cloneTabWidget->currentWidget();
78 |
79 | compareLabels(aLeftFrame->ui->maximumCountResLabel, aRightFrame->ui->maximumCountResLabel, false);
80 | compareLabels(aLeftFrame->ui->timeToAppendResLabel, aRightFrame->ui->timeToAppendResLabel, true);
81 | compareLabels(aLeftFrame->ui->timeToDeleteEndResLabel, aRightFrame->ui->timeToDeleteEndResLabel, true);
82 | compareLabels(aLeftFrame->ui->timeToInsertResLabel, aRightFrame->ui->timeToInsertResLabel, true);
83 | compareLabels(aLeftFrame->ui->timeToDeleteBeginResLabel, aRightFrame->ui->timeToDeleteBeginResLabel, true);
84 | }
85 |
86 | void MainWindow::compareLabels(QLabel *label1, QLabel *label2, bool lessBetter)
87 | {
88 | QString text1=label1->text();
89 | QString text2=label2->text();
90 |
91 | text1=text1.remove(" ").remove("ms");
92 | text2=text2.remove(" ").remove("ms");
93 |
94 | if (text1==text2)
95 | {
96 | QPalette aPalette;
97 |
98 | aPalette.setColor(QPalette::WindowText, QColor(0, 0, 0));
99 |
100 | label1->setPalette(aPalette);
101 | label2->setPalette(aPalette);
102 | }
103 | else
104 | {
105 | QPalette redPalette;
106 | QPalette greenPalette;
107 |
108 | redPalette.setColor(QPalette::WindowText, QColor(128, 0, 0));
109 | greenPalette.setColor(QPalette::WindowText, QColor(0, 128, 0));
110 |
111 | if ((text1.toLongLong()setPalette(greenPalette);
114 | label2->setPalette(redPalette);
115 | }
116 | else
117 | {
118 | label1->setPalette(redPalette);
119 | label2->setPalette(greenPalette);
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/examples/VsTableWidget/mainwindow.h:
--------------------------------------------------------------------------------
1 | #ifndef MAINWINDOW_H
2 | #define MAINWINDOW_H
3 |
4 | #include
5 |
6 | #include
7 |
8 | #include "statisticsframe.h"
9 |
10 | namespace Ui {
11 | class MainWindow;
12 | }
13 |
14 | class MainWindow : public QMainWindow
15 | {
16 | Q_OBJECT
17 |
18 | public:
19 | Ui::MainWindow *ui;
20 | QList mFrames;
21 |
22 | explicit MainWindow(QWidget *parent = 0);
23 | ~MainWindow();
24 |
25 | void compareLabels(QLabel *label1, QLabel *label2, bool lessBetter);
26 |
27 | public slots:
28 | void startComparing();
29 | void tabChanged(int index);
30 | };
31 |
32 | #endif // MAINWINDOW_H
33 |
--------------------------------------------------------------------------------
/examples/VsTableWidget/mainwindow.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | MainWindow
4 |
5 |
6 |
7 | 0
8 | 0
9 | 1024
10 | 768
11 |
12 |
13 |
14 | FastTableWidget VS QTableWidget
15 |
16 |
17 |
18 |
19 | 4
20 |
21 |
22 | 4
23 |
24 | -
25 |
26 |
27 | -1
28 |
29 |
30 |
31 | -
32 |
33 |
34 | -1
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/examples/VsTableWidget/statisticsframe.cpp:
--------------------------------------------------------------------------------
1 | #include "statisticsframe.h"
2 |
3 | #include
4 |
5 | #include "../../src/fasttable/fasttablewidget.h"
6 |
7 | StatisticsFrame::StatisticsFrame(QWidget *tableWidget, QWidget *parent) :
8 | QWidget(parent),
9 | ui(new Ui::StatisticsFrame)
10 | {
11 | ui->setupUi(this);
12 |
13 | mTableWidget=tableWidget;
14 | ui->frameVerticalLayout->insertWidget(0, mTableWidget);
15 | }
16 |
17 | StatisticsFrame::StatisticsFrame(StatisticsFrame *frame, QWidget *parent) :
18 | QWidget(parent),
19 | ui(new Ui::StatisticsFrame)
20 | {
21 | ui->setupUi(this);
22 |
23 | ui->maximumCountResLabel->setText (frame->ui->maximumCountResLabel->text());
24 | ui->timeToAppendResLabel->setText (frame->ui->timeToAppendResLabel->text());
25 | ui->timeToDeleteEndResLabel->setText (frame->ui->timeToDeleteEndResLabel->text());
26 | ui->timeToInsertResLabel->setText (frame->ui->timeToInsertResLabel->text());
27 | ui->timeToDeleteBeginResLabel->setText(frame->ui->timeToDeleteBeginResLabel->text());
28 | }
29 |
30 |
31 | StatisticsFrame::~StatisticsFrame()
32 | {
33 | delete ui;
34 | }
35 |
36 | void StatisticsFrame::startGetData()
37 | {
38 | if (mTableWidget->inherits("QTableWidget"))
39 | {
40 | qint64 aStartTime;
41 | QTableWidget *aTableWidget=(QTableWidget *)mTableWidget;
42 |
43 | #ifdef MAXCOUNT_TABLEWIDGET
44 | ui->maximumCountResLabel->setText(numberWithSpaces(MAXCOUNT_TABLEWIDGET));
45 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
46 | #else
47 | aTableWidget->setColumnCount(1000);
48 |
49 | for (int i=0; ; i++)
50 | {
51 | ui->maximumCountResLabel->setText(numberWithSpaces(i*aTableWidget->columnCount()));
52 |
53 | try
54 | {
55 | void *buffer=malloc(65535);
56 |
57 | if (buffer)
58 | {
59 | free(buffer);
60 | }
61 | else
62 | {
63 | throw "Finished";
64 | }
65 |
66 | aTableWidget->insertRow(i);
67 |
68 | for (int j=0; jcolumnCount(); j++)
69 | {
70 | aTableWidget->setItem(i, j, new QTableWidgetItem("Hello"));
71 | }
72 | }
73 | catch(...)
74 | {
75 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
76 | break;
77 | }
78 |
79 | if (i % 100 == 0)
80 | {
81 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
82 | }
83 | }
84 |
85 | aTableWidget->clearContents();
86 | aTableWidget->setRowCount(0);
87 | aTableWidget->setColumnCount(0);
88 | #endif
89 |
90 | //--------------------------------------------------------------------------------------------------
91 |
92 | aStartTime=QDateTime::currentMSecsSinceEpoch();
93 |
94 | aTableWidget->setColumnCount(1000);
95 |
96 | for (int i=0; i<1000; i++)
97 | {
98 | aTableWidget->insertRow(i);
99 |
100 | for (int j=0; jcolumnCount(); j++)
101 | {
102 | aTableWidget->setItem(i, j, new QTableWidgetItem("Hello"));
103 | }
104 |
105 | if ((i+1) % 100==0)
106 | {
107 | ui->timeToAppendResLabel->setText(numberWithSpaces(QDateTime::currentMSecsSinceEpoch()-aStartTime)+" ms");
108 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
109 | }
110 | }
111 |
112 | //--------------------------------------------------------------------------------------------------
113 |
114 | aStartTime=QDateTime::currentMSecsSinceEpoch();
115 |
116 | for (int i=999; i>=0; i--)
117 | {
118 | aTableWidget->removeRow(i);
119 |
120 | if (i % 100==0)
121 | {
122 | ui->timeToDeleteEndResLabel->setText(numberWithSpaces(QDateTime::currentMSecsSinceEpoch()-aStartTime)+" ms");
123 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
124 | }
125 | }
126 |
127 | //--------------------------------------------------------------------------------------------------
128 |
129 | aStartTime=QDateTime::currentMSecsSinceEpoch();
130 |
131 | aTableWidget->setColumnCount(1000);
132 |
133 | for (int i=0; i<1000; i++)
134 | {
135 | aTableWidget->insertRow(0);
136 |
137 | for (int j=0; jcolumnCount(); j++)
138 | {
139 | aTableWidget->setItem(0, j, new QTableWidgetItem("Hello"));
140 | }
141 |
142 | if ((i+1) % 100==0)
143 | {
144 | ui->timeToInsertResLabel->setText(numberWithSpaces(QDateTime::currentMSecsSinceEpoch()-aStartTime)+" ms");
145 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
146 | }
147 | }
148 |
149 | //--------------------------------------------------------------------------------------------------
150 |
151 | aStartTime=QDateTime::currentMSecsSinceEpoch();
152 |
153 | for (int i=999; i>=0; i--)
154 | {
155 | aTableWidget->removeRow(0);
156 |
157 | if (i % 100==0)
158 | {
159 | ui->timeToDeleteBeginResLabel->setText(numberWithSpaces(QDateTime::currentMSecsSinceEpoch()-aStartTime)+" ms");
160 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
161 | }
162 | }
163 | }
164 |
165 | else
166 | {
167 | qint64 aStartTime;
168 | CustomFastTableWidget *aTableWidget=(CustomFastTableWidget *)mTableWidget;
169 |
170 | if (aTableWidget->inherits("FastTableWidget"))
171 | {
172 | #ifdef MAXCOUNT_FASTTABLEWIDGET
173 | ui->maximumCountResLabel->setText(numberWithSpaces(MAXCOUNT_FASTTABLEWIDGET));
174 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
175 | #endif
176 | }
177 | else
178 | {
179 | #ifdef MAXCOUNT_CUSTOMFASTTABLEWIDGET
180 | ui->maximumCountResLabel->setText(numberWithSpaces(MAXCOUNT_CUSTOMFASTTABLEWIDGET));
181 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
182 | #endif
183 | }
184 |
185 | if (ui->maximumCountResLabel->text()=="0")
186 | {
187 | aTableWidget->setSizes(0, 1000);
188 |
189 | for (int i=0; ; i++)
190 | {
191 | ui->maximumCountResLabel->setText(numberWithSpaces(i*aTableWidget->columnCount()));
192 |
193 | try
194 | {
195 | void *buffer=malloc(65535);
196 |
197 | if (buffer)
198 | {
199 | free(buffer);
200 | }
201 | else
202 | {
203 | throw "Finished";
204 | }
205 |
206 | aTableWidget->insertRow(i);
207 |
208 | for (int j=0; jcolumnCount(); j++)
209 | {
210 | aTableWidget->setText(i, j, "Hello");
211 | }
212 | }
213 | catch(...)
214 | {
215 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
216 | break;
217 | }
218 |
219 | if (i % 100 == 0)
220 | {
221 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
222 | }
223 | }
224 |
225 | aTableWidget->clear();
226 | }
227 |
228 | //--------------------------------------------------------------------------------------------------
229 |
230 | aStartTime=QDateTime::currentMSecsSinceEpoch();
231 |
232 | aTableWidget->setSizes(0, 1000);
233 |
234 | for (int i=0; i<1000; i++)
235 | {
236 | aTableWidget->insertRow(i);
237 |
238 | for (int j=0; jcolumnCount(); j++)
239 | {
240 | aTableWidget->setText(i, j, "Hello");
241 | }
242 |
243 | if ((i+1) % 100==0)
244 | {
245 | ui->timeToAppendResLabel->setText(numberWithSpaces(QDateTime::currentMSecsSinceEpoch()-aStartTime)+" ms");
246 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
247 | }
248 | }
249 |
250 | //--------------------------------------------------------------------------------------------------
251 |
252 | aStartTime=QDateTime::currentMSecsSinceEpoch();
253 |
254 | for (int i=999; i>=0; i--)
255 | {
256 | aTableWidget->removeRow(i);
257 |
258 | if (i % 100==0)
259 | {
260 | ui->timeToDeleteEndResLabel->setText(numberWithSpaces(QDateTime::currentMSecsSinceEpoch()-aStartTime)+" ms");
261 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
262 | }
263 | }
264 |
265 | //--------------------------------------------------------------------------------------------------
266 |
267 | aStartTime=QDateTime::currentMSecsSinceEpoch();
268 |
269 | aTableWidget->setSizes(0, 1000);
270 |
271 | for (int i=0; i<1000; i++)
272 | {
273 | aTableWidget->insertRow(0);
274 |
275 | for (int j=0; jcolumnCount(); j++)
276 | {
277 | aTableWidget->setText(0, j, "Hello");
278 | }
279 |
280 | if ((i+1) % 100==0)
281 | {
282 | ui->timeToInsertResLabel->setText(numberWithSpaces(QDateTime::currentMSecsSinceEpoch()-aStartTime)+" ms");
283 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
284 | }
285 | }
286 |
287 | //--------------------------------------------------------------------------------------------------
288 |
289 | aStartTime=QDateTime::currentMSecsSinceEpoch();
290 |
291 | for (int i=999; i>=0; i--)
292 | {
293 | aTableWidget->removeRow(0);
294 |
295 | if (i % 100==0)
296 | {
297 | ui->timeToDeleteBeginResLabel->setText(numberWithSpaces(QDateTime::currentMSecsSinceEpoch()-aStartTime)+" ms");
298 | QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
299 | }
300 | }
301 | }
302 | }
303 |
304 | QString StatisticsFrame::numberWithSpaces(qint64 value)
305 | {
306 | QString res=QString::number(value);
307 |
308 | for (int i=res.length()-3; i>0; i-=3)
309 | {
310 | res.insert(i, " ");
311 | }
312 |
313 | return res;
314 | }
315 |
--------------------------------------------------------------------------------
/examples/VsTableWidget/statisticsframe.h:
--------------------------------------------------------------------------------
1 | #ifndef STATISTICSFRAME_H
2 | #define STATISTICSFRAME_H
3 |
4 | #include
5 | #include "ui_statisticsframe.h"
6 |
7 | namespace Ui {
8 | class StatisticsFrame;
9 | }
10 |
11 | // Comment this if you want to know your own statistics (It will take 5 minutes)
12 | #define MAXCOUNT_TABLEWIDGET 13500000
13 | #define MAXCOUNT_CUSTOMFASTTABLEWIDGET 39200000
14 | #define MAXCOUNT_FASTTABLEWIDGET 23100000
15 |
16 | class StatisticsFrame : public QWidget
17 | {
18 | Q_OBJECT
19 |
20 | public:
21 | Ui::StatisticsFrame *ui;
22 | QWidget *mTableWidget;
23 |
24 | explicit StatisticsFrame(QWidget *tableWidget, QWidget *parent = 0);
25 | explicit StatisticsFrame(StatisticsFrame *frame, QWidget *parent = 0);
26 | ~StatisticsFrame();
27 |
28 | void startGetData();
29 | QString numberWithSpaces(qint64 value);
30 | };
31 |
32 | #endif // STATISTICSFRAME_H
33 |
--------------------------------------------------------------------------------
/examples/VsTableWidget/statisticsframe.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | StatisticsFrame
4 |
5 |
6 |
7 | 0
8 | 0
9 | 404
10 | 114
11 |
12 |
13 |
14 |
15 | 4
16 |
17 |
18 | 4
19 |
20 | -
21 |
22 |
-
23 |
24 |
25 |
26 | 0
27 | 0
28 |
29 |
30 |
31 |
32 | 10
33 |
34 |
35 |
36 | Maximum cell count
37 |
38 |
39 |
40 | -
41 |
42 |
43 |
44 | 10
45 | 75
46 | true
47 |
48 |
49 |
50 | 0
51 |
52 |
53 | Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
54 |
55 |
56 |
57 | -
58 |
59 |
60 |
61 | 0
62 | 0
63 |
64 |
65 |
66 |
67 | 10
68 |
69 |
70 |
71 | Time to append 1000 rows at the end (1000 columns in table)
72 |
73 |
74 |
75 | -
76 |
77 |
78 |
79 | 10
80 | 75
81 | true
82 |
83 |
84 |
85 | 0 ms
86 |
87 |
88 | Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
89 |
90 |
91 |
92 | -
93 |
94 |
95 |
96 | 0
97 | 0
98 |
99 |
100 |
101 |
102 | 10
103 |
104 |
105 |
106 | Time to insert 1000 rows at the begin (1000 columns in table)
107 |
108 |
109 |
110 | -
111 |
112 |
113 |
114 | 10
115 | 75
116 | true
117 |
118 |
119 |
120 | 0 ms
121 |
122 |
123 | Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
124 |
125 |
126 |
127 | -
128 |
129 |
130 |
131 | 0
132 | 0
133 |
134 |
135 |
136 |
137 | 10
138 |
139 |
140 |
141 | Time to delete 1000 rows at the end (1000 columns in table)
142 |
143 |
144 |
145 | -
146 |
147 |
148 |
149 | 10
150 | 75
151 | true
152 |
153 |
154 |
155 | 0 ms
156 |
157 |
158 | Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
159 |
160 |
161 |
162 | -
163 |
164 |
165 |
166 | 0
167 | 0
168 |
169 |
170 |
171 |
172 | 10
173 |
174 |
175 |
176 | Time to delete 1000 rows at the begin (1000 columns in table)
177 |
178 |
179 |
180 | -
181 |
182 |
183 |
184 | 10
185 | 75
186 | true
187 |
188 |
189 |
190 | 0 ms
191 |
192 |
193 | Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
--------------------------------------------------------------------------------
/images/CellBottom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellBottom.png
--------------------------------------------------------------------------------
/images/CellBottomLeft.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellBottomLeft.png
--------------------------------------------------------------------------------
/images/CellBottomLeftSelected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellBottomLeftSelected.png
--------------------------------------------------------------------------------
/images/CellBottomRight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellBottomRight.png
--------------------------------------------------------------------------------
/images/CellBottomRightSelected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellBottomRightSelected.png
--------------------------------------------------------------------------------
/images/CellBottomSelected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellBottomSelected.png
--------------------------------------------------------------------------------
/images/CellCenter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellCenter.png
--------------------------------------------------------------------------------
/images/CellCenterSelected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellCenterSelected.png
--------------------------------------------------------------------------------
/images/CellLeft.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellLeft.png
--------------------------------------------------------------------------------
/images/CellLeftSelected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellLeftSelected.png
--------------------------------------------------------------------------------
/images/CellRight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellRight.png
--------------------------------------------------------------------------------
/images/CellRightSelected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellRightSelected.png
--------------------------------------------------------------------------------
/images/CellTop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellTop.png
--------------------------------------------------------------------------------
/images/CellTopLeft.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellTopLeft.png
--------------------------------------------------------------------------------
/images/CellTopLeftSelected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellTopLeftSelected.png
--------------------------------------------------------------------------------
/images/CellTopRight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellTopRight.png
--------------------------------------------------------------------------------
/images/CellTopRightSelected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellTopRightSelected.png
--------------------------------------------------------------------------------
/images/CellTopSelected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/CellTopSelected.png
--------------------------------------------------------------------------------
/images/Find.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/Find.png
--------------------------------------------------------------------------------
/images/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gris87/Qt_FastTableWidget/f6700abf58c135fd2def5a672a35dc8741cd91a1/images/icon.ico
--------------------------------------------------------------------------------
/push.sh:
--------------------------------------------------------------------------------
1 | git push origin master
--------------------------------------------------------------------------------
/src/controller/aligndialog.cpp:
--------------------------------------------------------------------------------
1 | #include "aligndialog.h"
2 | #include "ui_aligndialog.h"
3 |
4 | AlignDialog::AlignDialog(int initAlignment, QWidget *parent) :
5 | QDialog(parent),
6 | ui(new Ui::AlignDialog)
7 | {
8 | ui->setupUi(this);
9 |
10 | ui->topLeftButton ->setIcon((initAlignment & (Qt::AlignTop | Qt::AlignLeft))==(Qt::AlignTop | Qt::AlignLeft) ? QIcon(":/images/CellTopLeftSelected.png") : QIcon(":/images/CellTopLeft.png"));
11 | ui->topButton ->setIcon((initAlignment & (Qt::AlignTop | Qt::AlignHCenter))==(Qt::AlignTop | Qt::AlignHCenter) ? QIcon(":/images/CellTopSelected.png") : QIcon(":/images/CellTop.png"));
12 | ui->topRightButton ->setIcon((initAlignment & (Qt::AlignTop | Qt::AlignRight))==(Qt::AlignTop | Qt::AlignRight) ? QIcon(":/images/CellTopRightSelected.png") : QIcon(":/images/CellTopRight.png"));
13 | ui->leftButton ->setIcon((initAlignment & (Qt::AlignVCenter | Qt::AlignLeft))==(Qt::AlignVCenter | Qt::AlignLeft) ? QIcon(":/images/CellLeftSelected.png") : QIcon(":/images/CellLeft.png"));
14 | ui->centerButton ->setIcon((initAlignment & Qt::AlignCenter)==Qt::AlignCenter ? QIcon(":/images/CellCenterSelected.png") : QIcon(":/images/CellCenter.png"));
15 | ui->rightButton ->setIcon((initAlignment & (Qt::AlignVCenter | Qt::AlignRight))==(Qt::AlignVCenter | Qt::AlignRight) ? QIcon(":/images/CellRightSelected.png") : QIcon(":/images/CellRight.png"));
16 | ui->bottomLeftButton ->setIcon((initAlignment & (Qt::AlignBottom | Qt::AlignLeft))==(Qt::AlignBottom | Qt::AlignLeft) ? QIcon(":/images/CellBottomLeftSelected.png") : QIcon(":/images/CellBottomLeft.png"));
17 | ui->bottomButton ->setIcon((initAlignment & (Qt::AlignBottom | Qt::AlignHCenter))==(Qt::AlignBottom | Qt::AlignHCenter) ? QIcon(":/images/CellBottomSelected.png") : QIcon(":/images/CellBottom.png"));
18 | ui->bottomRightButton->setIcon((initAlignment & (Qt::AlignBottom | Qt::AlignRight))==(Qt::AlignBottom | Qt::AlignRight) ? QIcon(":/images/CellBottomRightSelected.png") : QIcon(":/images/CellBottomRight.png"));
19 | }
20 |
21 | AlignDialog::~AlignDialog()
22 | {
23 | delete ui;
24 | }
25 |
26 | void AlignDialog::on_topLeftButton_clicked()
27 | {
28 | resultAlignment=Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap;
29 | accept();
30 | }
31 |
32 | void AlignDialog::on_topButton_clicked()
33 | {
34 | resultAlignment=Qt::AlignTop | Qt::AlignHCenter | Qt::TextWordWrap;
35 | accept();
36 | }
37 |
38 | void AlignDialog::on_topRightButton_clicked()
39 | {
40 | resultAlignment=Qt::AlignTop | Qt::AlignRight | Qt::TextWordWrap;
41 | accept();
42 | }
43 |
44 | void AlignDialog::on_leftButton_clicked()
45 | {
46 | resultAlignment=Qt::AlignVCenter | Qt::AlignLeft | Qt::TextWordWrap;
47 | accept();
48 | }
49 |
50 | void AlignDialog::on_centerButton_clicked()
51 | {
52 | resultAlignment=Qt::AlignCenter | Qt::TextWordWrap;
53 | accept();
54 | }
55 |
56 | void AlignDialog::on_rightButton_clicked()
57 | {
58 | resultAlignment=Qt::AlignVCenter | Qt::AlignRight | Qt::TextWordWrap;
59 | accept();
60 | }
61 |
62 | void AlignDialog::on_bottomLeftButton_clicked()
63 | {
64 | resultAlignment=Qt::AlignBottom | Qt::AlignLeft | Qt::TextWordWrap;
65 | accept();
66 | }
67 |
68 | void AlignDialog::on_bottomButton_clicked()
69 | {
70 | resultAlignment=Qt::AlignBottom | Qt::AlignHCenter | Qt::TextWordWrap;
71 | accept();
72 | }
73 |
74 | void AlignDialog::on_bottomRightButton_clicked()
75 | {
76 | resultAlignment=Qt::AlignBottom | Qt::AlignRight | Qt::TextWordWrap;
77 | accept();
78 | }
79 |
--------------------------------------------------------------------------------
/src/controller/aligndialog.h:
--------------------------------------------------------------------------------
1 | #ifndef ALIGNDIALOG_H
2 | #define ALIGNDIALOG_H
3 |
4 | #include
5 |
6 | namespace Ui {
7 | class AlignDialog;
8 | }
9 |
10 | class AlignDialog : public QDialog
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | int resultAlignment;
16 |
17 | explicit AlignDialog(int initAlignment=0, QWidget *parent = 0);
18 | ~AlignDialog();
19 |
20 | private:
21 | Ui::AlignDialog *ui;
22 |
23 | private slots:
24 | void on_topLeftButton_clicked();
25 | void on_topButton_clicked();
26 | void on_topRightButton_clicked();
27 | void on_leftButton_clicked();
28 | void on_centerButton_clicked();
29 | void on_rightButton_clicked();
30 | void on_bottomLeftButton_clicked();
31 | void on_bottomButton_clicked();
32 | void on_bottomRightButton_clicked();
33 | };
34 |
35 | #endif // ALIGNDIALOG_H
36 |
--------------------------------------------------------------------------------
/src/controller/aligndialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | AlignDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 160
10 | 160
11 |
12 |
13 |
14 |
15 | 160
16 | 160
17 |
18 |
19 |
20 | Alignment
21 |
22 |
23 |
24 | 4
25 |
26 |
27 | 4
28 |
29 | -
30 |
31 |
32 |
33 | 48
34 | 48
35 |
36 |
37 |
38 |
39 | 48
40 | 48
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | 48
49 | 48
50 |
51 |
52 |
53 | false
54 |
55 |
56 | true
57 |
58 |
59 |
60 | -
61 |
62 |
63 |
64 | 48
65 | 48
66 |
67 |
68 |
69 |
70 | 48
71 | 48
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | 48
80 | 48
81 |
82 |
83 |
84 | false
85 |
86 |
87 | true
88 |
89 |
90 |
91 | -
92 |
93 |
94 |
95 | 48
96 | 48
97 |
98 |
99 |
100 |
101 | 48
102 | 48
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 | 48
111 | 48
112 |
113 |
114 |
115 | false
116 |
117 |
118 | true
119 |
120 |
121 |
122 | -
123 |
124 |
125 |
126 | 48
127 | 48
128 |
129 |
130 |
131 |
132 | 48
133 | 48
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 | 48
142 | 48
143 |
144 |
145 |
146 | false
147 |
148 |
149 | true
150 |
151 |
152 |
153 | -
154 |
155 |
156 |
157 | 48
158 | 48
159 |
160 |
161 |
162 |
163 | 48
164 | 48
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 | 48
173 | 48
174 |
175 |
176 |
177 | false
178 |
179 |
180 | true
181 |
182 |
183 |
184 | -
185 |
186 |
187 |
188 | 48
189 | 48
190 |
191 |
192 |
193 |
194 | 48
195 | 48
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 | 48
204 | 48
205 |
206 |
207 |
208 | false
209 |
210 |
211 | true
212 |
213 |
214 |
215 | -
216 |
217 |
218 |
219 | 48
220 | 48
221 |
222 |
223 |
224 |
225 | 48
226 | 48
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 | 48
235 | 48
236 |
237 |
238 |
239 | false
240 |
241 |
242 | true
243 |
244 |
245 |
246 | -
247 |
248 |
249 |
250 | 48
251 | 48
252 |
253 |
254 |
255 |
256 | 48
257 | 48
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 | 48
266 | 48
267 |
268 |
269 |
270 | false
271 |
272 |
273 | true
274 |
275 |
276 |
277 | -
278 |
279 |
280 |
281 | 48
282 | 48
283 |
284 |
285 |
286 |
287 | 48
288 | 48
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 | 48
297 | 48
298 |
299 |
300 |
301 | false
302 |
303 |
304 | true
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
--------------------------------------------------------------------------------
/src/controller/controllerdialog.h:
--------------------------------------------------------------------------------
1 | #ifndef CONTROLLERDIALOG_H
2 | #define CONTROLLERDIALOG_H
3 |
4 | #include
5 |
6 | #include "../fasttable/customfasttablewidget.h"
7 |
8 | namespace Ui {
9 | class ControllerDialog;
10 | }
11 |
12 | class ControllerDialog : public QDialog
13 | {
14 | Q_OBJECT
15 |
16 | public:
17 | CustomFastTableWidget* mFastTableWidget;
18 |
19 | explicit ControllerDialog(QWidget *parent = 0);
20 | ~ControllerDialog();
21 |
22 | void setStyleButtonsFlat();
23 |
24 | private:
25 | Ui::ControllerDialog *ui;
26 |
27 | private slots:
28 | void tableInsertRow();
29 | void tableDeleteRow();
30 | void tableInsertColumn();
31 | void tableDeleteColumn();
32 | void tableMergeCells();
33 | void tableContextMenuRequested(QPoint pos);
34 |
35 | void on_deleteButton_clicked();
36 | void on_styleSimpleButton_clicked();
37 | void on_styleLinuxButton_clicked();
38 | void on_styleWinXPButton_clicked();
39 | void on_styleWin7Button_clicked();
40 |
41 | void on_rowCountSpinBox_valueChanged(int value);
42 | void on_columnCountSpinBox_valueChanged(int value);
43 | void on_horizontalHeaderRowCountSpinBox_valueChanged(int value);
44 | void on_verticalHeaderColumnCountSpinBox_valueChanged(int value);
45 | void on_addRowButton_clicked();
46 | void on_insertRowButton_clicked();
47 | void on_deleteRowButton_clicked();
48 | void on_addColumnButton_clicked();
49 | void on_insertColumnButton_clicked();
50 | void on_deleteColumnButton_clicked();
51 | void on_addHeaderRowButton_clicked();
52 | void on_insertHeaderRowButton_clicked();
53 | void on_deleteHeaderRowButton_clicked();
54 | void on_addHeaderColumnButton_clicked();
55 | void on_insertHeaderColumnButton_clicked();
56 | void on_deleteHeaderColumnButton_clicked();
57 | void on_clearButton_clicked();
58 | void on_fontButton_clicked();
59 | void on_autoVerticalHeaderSizeCheckBox_toggled(bool checked);
60 | void on_alternatingRowColorsCheckBox_toggled(bool checked);
61 | void on_horizontalStrectCheckBox_toggled(bool checked);
62 | void on_verticalStrectCheckBox_toggled(bool checked);
63 | void on_selectRowButton_clicked();
64 | void on_unselectRowButton_clicked();
65 | void on_selectColumnButton_clicked();
66 | void on_unselectColumnButton_clicked();
67 | void on_selectAllButton_clicked();
68 | void on_unselectAllButton_clicked();
69 | void on_windowColorButton_clicked();
70 | void on_defaultBackgroundButton_clicked();
71 | void on_alternateBackgroundButton_clicked();
72 | void on_defaultForegroundButton_clicked();
73 | void on_gridColorButton_clicked();
74 | void on_cellBorderColorButton_clicked();
75 | void on_horizontalDefaultBackgroundButton_clicked();
76 | void on_horizontalDefaultForegroundButton_clicked();
77 | void on_horizontalGridColorButton_clicked();
78 | void on_horizontalCellBorderColorButton_clicked();
79 | void on_verticalDefaultBackgroundButton_clicked();
80 | void on_verticalDefaultForegroundButton_clicked();
81 | void on_verticalGridColorButton_clicked();
82 | void on_verticalCellBorderColorButton_clicked();
83 | void on_selectionColorButton_clicked();
84 | void on_selectionTextColorButton_clicked();
85 | void on_defaultWidthSpinBox_valueChanged(int value);
86 | void on_defaultHeightSpinBox_valueChanged(int value);
87 | void on_columnWidthButton_clicked();
88 | void on_rowHeightButton_clicked();
89 | void on_headerColumnWidthButton_clicked();
90 | void on_headerRowHeightButton_clicked();
91 | void on_showColumnButton_clicked();
92 | void on_hideColumnButton_clicked();
93 | void on_showRowButton_clicked();
94 | void on_hideRowButton_clicked();
95 | void on_headerShowColumnButton_clicked();
96 | void on_headerHideColumnButton_clicked();
97 | void on_headerShowRowButton_clicked();
98 | void on_headerHideRowButton_clicked();
99 | void on_scrollToCellButton_clicked();
100 | void on_scrollToCurrentCellButton_clicked();
101 | void on_scrollToTopButton_clicked();
102 | void on_scrollToBottomButton_clicked();
103 | void on_textButton_clicked();
104 | void on_horizontalTextButton_clicked();
105 | void on_verticalTextButton_clicked();
106 | void on_cellSelectedButton_clicked();
107 | void on_currentCellButton_clicked();
108 | void on_currentChangedCheckBox_toggled(bool checked);
109 | void on_doubleClickedCheckBox_toggled(bool checked);
110 | void on_selectedClickedCheckBox_toggled(bool checked);
111 | void on_editKeyPressedCheckBox_toggled(bool checked);
112 | void on_anyKeyPressedCheckBox_toggled(bool checked);
113 |
114 | void on_backgroundButton_clicked();
115 | void on_resetBackgroundButton_clicked();
116 | void on_resetAllBackgroundButton_clicked();
117 | void on_foregroundButton_clicked();
118 | void on_resetForegroundButton_clicked();
119 | void on_resetAllForegroundButton_clicked();
120 | void on_cellFontButton_clicked();
121 | void on_resetCellFontButton_clicked();
122 | void on_resetAllCellFontButton_clicked();
123 | void on_cellTextFlagsButton_clicked();
124 | void on_resetCellTextFlagsButton_clicked();
125 | void on_resetAllCellTextFlagsButton_clicked();
126 | void on_horizontalBackgroundButton_clicked();
127 | void on_horizontalResetBackgroundButton_clicked();
128 | void on_horizontalResetAllBackgroundButton_clicked();
129 | void on_horizontalForegroundButton_clicked();
130 | void on_horizontalResetForegroundButton_clicked();
131 | void on_horizontalResetAllForegroundButton_clicked();
132 | void on_horizontalCellFontButton_clicked();
133 | void on_horizontalResetCellFontButton_clicked();
134 | void on_horizontalResetAllCellFontButton_clicked();
135 | void on_horizontalCellTextFlagsButton_clicked();
136 | void on_horizontalResetCellTextFlagsButton_clicked();
137 | void on_horizontalResetAllCellTextFlagsButton_clicked();
138 | void on_verticalBackgroundButton_clicked();
139 | void on_verticalResetBackgroundButton_clicked();
140 | void on_verticalResetAllBackgroundButton_clicked();
141 | void on_verticalForegroundButton_clicked();
142 | void on_verticalResetForegroundButton_clicked();
143 | void on_verticalResetAllForegroundButton_clicked();
144 | void on_verticalCellFontButton_clicked();
145 | void on_verticalResetCellFontButton_clicked();
146 | void on_verticalResetAllCellFontButton_clicked();
147 | void on_verticalCellTextFlagsButton_clicked();
148 | void on_verticalResetCellTextFlagsButton_clicked();
149 | void on_verticalResetAllCellTextFlagsButton_clicked();
150 | void on_mergeButton_clicked();
151 | void on_clearSpansButton_clicked();
152 | void on_horizontalMergeButton_clicked();
153 | void on_horizontalClearSpansButton_clicked();
154 | void on_verticalMergeButton_clicked();
155 | void on_verticalClearSpansButton_clicked();
156 |
157 | //------------------------------------------------------------------------
158 |
159 | void on_rowCountViewButton_clicked();
160 | void on_columnCountViewButton_clicked();
161 | void on_horizontalHeaderRowCountViewButton_clicked();
162 | void on_verticalHeaderColumnCountViewButton_clicked();
163 | void on_defaultWidthViewButton_clicked();
164 | void on_defaultHeightViewButton_clicked();
165 | void on_columnWidthViewButton_clicked();
166 | void on_rowHeightViewButton_clicked();
167 | void on_headerColumnWidthViewButton_clicked();
168 | void on_headerRowHeightViewButton_clicked();
169 | void on_totalWidthViewButton_clicked();
170 | void on_totalHeightViewButton_clicked();
171 | void on_headerTotalWidthViewButton_clicked();
172 | void on_headerTotalHeightViewButton_clicked();
173 | void on_visibleRangesViewButton_clicked();
174 | void on_horizontalVisibleRangesViewButton_clicked();
175 | void on_verticalVisibleRangesViewButton_clicked();
176 | void on_columnVisibleViewButton_clicked();
177 | void on_rowVisibleViewButton_clicked();
178 | void on_headerColumnVisibleViewButton_clicked();
179 | void on_headerRowVisibleViewButton_clicked();
180 | void on_textViewButton_clicked();
181 | void on_horizontalTextViewButton_clicked();
182 | void on_verticalTextViewButton_clicked();
183 | void on_cellSelectedViewButton_clicked();
184 | void on_selectedCellsViewButton_clicked();
185 | void on_selectedRangesViewButton_clicked();
186 | void on_topLeftSelectedCellViewButton_clicked();
187 | void on_rowsSelectedViewButton_clicked();
188 | void on_columnsSelectedViewButton_clicked();
189 | void on_currentCellViewButton_clicked();
190 | void on_lastXViewButton_clicked();
191 | void on_lastYViewButton_clicked();
192 | void on_mouseXForShiftViewButton_clicked();
193 | void on_mouseYForShiftViewButton_clicked();
194 | void on_mouseResizeLineXViewButton_clicked();
195 | void on_mouseResizeLineYViewButton_clicked();
196 | void on_mouseResizeCellViewButton_clicked();
197 | void on_mousePressedViewButton_clicked();
198 | void on_ctrlPressedViewButton_clicked();
199 | void on_shiftPressedViewButton_clicked();
200 | void on_mouseLocationViewButton_clicked();
201 | void on_mouseLocationForShiftViewButton_clicked();
202 | void on_mouseSelectedCellsViewButton_clicked();
203 |
204 | void on_mergeParentViewButton_clicked();
205 | void on_mergeXYViewButton_clicked();
206 | void on_mergesViewButton_clicked();
207 | void on_horizontalMergeParentViewButton_clicked();
208 | void on_horizontalMergeXYViewButton_clicked();
209 | void on_horizontalMergesViewButton_clicked();
210 | void on_verticalMergeParentViewButton_clicked();
211 | void on_verticalMergeXYViewButton_clicked();
212 | void on_verticalMergesViewButton_clicked();
213 |
214 | //------------------------------------------------------------------------
215 |
216 | void on_createCustomTableButton_clicked();
217 | void on_createFastTableButton_clicked();
218 | void on_createCustomTablePersonalButton_clicked();
219 | void on_createFastTablePersonalButton_clicked();
220 | };
221 |
222 | #endif // CONTROLLERDIALOG_H
223 |
--------------------------------------------------------------------------------
/src/controller/customfasttablepersonal.cpp:
--------------------------------------------------------------------------------
1 | #include "customfasttablepersonal.h"
2 |
3 | CustomFastTablePersonal::CustomFastTablePersonal(QWidget *parent) :
4 | CustomFastTableWidget(false, parent)
5 | {
6 | }
7 |
8 | QString CustomFastTablePersonal::text(const int row, const int column)
9 | {
10 | return QString::number(row)+"+"+QString::number(column)+"="+QString::number(row+column);
11 | }
12 |
13 | QBrush CustomFastTablePersonal::backgroundBrush(const int row, const int /*column*/)
14 | {
15 | return QBrush(QColor((quint8)(row << 6), (quint8)(row >> 2), (quint8)(row >> 10)));
16 | }
17 |
18 | QColor CustomFastTablePersonal::foregroundColor(const int row, const int column)
19 | {
20 | quint8 aPart=row*8+column;
21 | return QColor(255-aPart, 255-aPart, 255-aPart);
22 | }
23 |
24 | QFont CustomFastTablePersonal::cellFont(const int /*row*/, const int /*column*/)
25 | {
26 | return QFont("Arial", 12, QFont::Bold);
27 | }
28 |
29 | int CustomFastTablePersonal::cellTextFlags(const int /*row*/, const int /*column*/)
30 | {
31 | return Qt::AlignRight | Qt::AlignVCenter;
32 | }
33 |
--------------------------------------------------------------------------------
/src/controller/customfasttablepersonal.h:
--------------------------------------------------------------------------------
1 | #ifndef CUSTOMFASTTABLEPERSONAL_H
2 | #define CUSTOMFASTTABLEPERSONAL_H
3 |
4 | #include "../fasttable/customfasttablewidget.h"
5 |
6 | class CustomFastTablePersonal : public CustomFastTableWidget
7 | {
8 | Q_OBJECT
9 | public:
10 | explicit CustomFastTablePersonal(QWidget *parent = 0);
11 |
12 | QString text(const int row, const int column);
13 | QBrush backgroundBrush(const int row, const int column);
14 | QColor foregroundColor(const int row, const int column);
15 | QFont cellFont(const int row, const int column);
16 | int cellTextFlags(const int row, const int column);
17 | };
18 |
19 | #endif // CUSTOMFASTTABLEPERSONAL_H
20 |
--------------------------------------------------------------------------------
/src/controller/fasttablepersonal.cpp:
--------------------------------------------------------------------------------
1 | #include "fasttablepersonal.h"
2 |
3 | FastTablePersonal::FastTablePersonal(QWidget *parent) :
4 | FastTableWidget(false, parent)
5 | {
6 | }
7 |
8 | QString FastTablePersonal::text(const int row, const int column)
9 | {
10 | return QString::number(row)+"+"+QString::number(column)+"="+QString::number(row+column);
11 | }
12 |
13 | QBrush FastTablePersonal::backgroundBrush(const int row, const int /*column*/)
14 | {
15 | return QBrush(QColor((quint8)(row << 6), (quint8)(row >> 2), (quint8)(row >> 10)));
16 | }
17 |
18 | QColor FastTablePersonal::foregroundColor(const int row, const int column)
19 | {
20 | quint8 aPart=row*8+column;
21 | return QColor(255-aPart, 255-aPart, 255-aPart);
22 | }
23 |
24 | QFont FastTablePersonal::cellFont(const int /*row*/, const int /*column*/)
25 | {
26 | return QFont("Arial", 12, QFont::Bold);
27 | }
28 |
29 | int FastTablePersonal::cellTextFlags(const int /*row*/, const int /*column*/)
30 | {
31 | return Qt::AlignRight | Qt::AlignVCenter;
32 | }
33 |
--------------------------------------------------------------------------------
/src/controller/fasttablepersonal.h:
--------------------------------------------------------------------------------
1 | #ifndef FASTTABLEPERSONAL_H
2 | #define FASTTABLEPERSONAL_H
3 |
4 | #include "../fasttable/fasttablewidget.h"
5 |
6 | class FastTablePersonal : public FastTableWidget
7 | {
8 | Q_OBJECT
9 | public:
10 | explicit FastTablePersonal(QWidget *parent = 0);
11 |
12 | QString text(const int row, const int column);
13 | QBrush backgroundBrush(const int row, const int column);
14 | QColor foregroundColor(const int row, const int column);
15 | QFont cellFont(const int row, const int column);
16 | int cellTextFlags(const int row, const int column);
17 | };
18 |
19 | #endif // FASTTABLEPERSONAL_H
20 |
--------------------------------------------------------------------------------
/src/controller/viewdialog.cpp:
--------------------------------------------------------------------------------
1 | #include "viewdialog.h"
2 | #include "ui_viewdialog.h"
3 |
4 | ViewDialog::ViewDialog(QWidget *parent) :
5 | QDialog(parent),
6 | ui(new Ui::ViewDialog)
7 | {
8 | VIEWDIALOG_BASE_CONSTRUCTOR;
9 | }
10 |
11 | ViewDialog::ViewDialog(int aValue, QWidget *parent) :
12 | QDialog(parent),
13 | ui(new Ui::ViewDialog)
14 | {
15 | VIEWDIALOG_BASE_CONSTRUCTOR;
16 |
17 | mFastTableWidget->setText(0, 0, valueToString(aValue));
18 | }
19 |
20 | ViewDialog::ViewDialog(bool aValue, QWidget *parent) :
21 | QDialog(parent),
22 | ui(new Ui::ViewDialog)
23 | {
24 | VIEWDIALOG_BASE_CONSTRUCTOR;
25 |
26 | mFastTableWidget->setText(0, 0, valueToString(aValue));
27 | }
28 |
29 | ViewDialog::ViewDialog(CustomFastTableWidget::MouseLocation aValue, QWidget *parent) :
30 | QDialog(parent),
31 | ui(new Ui::ViewDialog)
32 | {
33 | VIEWDIALOG_BASE_CONSTRUCTOR;
34 |
35 | mFastTableWidget->horizontalHeader_SetText(0, "MouseLocation");
36 |
37 | mFastTableWidget->setText(0, 0, valueToString(aValue));
38 | }
39 |
40 | ViewDialog::ViewDialog(QPoint aValue, QWidget *parent) :
41 | QDialog(parent),
42 | ui(new Ui::ViewDialog)
43 | {
44 | VIEWDIALOG_BASE_CONSTRUCTOR;
45 |
46 | mFastTableWidget->setColumnCount(2);
47 |
48 | mFastTableWidget->horizontalHeader_SetText(0, "X");
49 | mFastTableWidget->horizontalHeader_SetText(1, "Y");
50 |
51 | mFastTableWidget->setText(0, 0, valueToString(aValue.x()));
52 | mFastTableWidget->setText(0, 1, valueToString(aValue.y()));
53 | }
54 |
55 | ViewDialog::ViewDialog(QRect aValue, QWidget *parent) :
56 | QDialog(parent),
57 | ui(new Ui::ViewDialog)
58 | {
59 | VIEWDIALOG_BASE_CONSTRUCTOR;
60 |
61 | mFastTableWidget->setColumnCount(4);
62 |
63 | mFastTableWidget->horizontalHeader_SetText(0, "Left");
64 | mFastTableWidget->horizontalHeader_SetText(1, "Top");
65 | mFastTableWidget->horizontalHeader_SetText(2, "Right");
66 | mFastTableWidget->horizontalHeader_SetText(3, "Bottom");
67 |
68 | mFastTableWidget->setText(0, 0, valueToString(aValue.left()));
69 | mFastTableWidget->setText(0, 1, valueToString(aValue.top()));
70 | mFastTableWidget->setText(0, 2, valueToString(aValue.right()));
71 | mFastTableWidget->setText(0, 3, valueToString(aValue.bottom()));
72 | }
73 |
74 | ViewDialog::ViewDialog(QList *aValues, bool isVertical, QWidget *parent) :
75 | QDialog(parent),
76 | ui(new Ui::ViewDialog)
77 | {
78 | VIEWDIALOG_BASE_CONSTRUCTOR;
79 |
80 | if (isVertical)
81 | {
82 | mFastTableWidget->setRowCount(aValues->length());
83 |
84 | for (int i=0; ilength(); i++)
85 | {
86 | mFastTableWidget->setText(i, 0, valueToString(aValues->at(i)));
87 | }
88 | }
89 | else
90 | {
91 | mFastTableWidget->setColumnCount(aValues->length());
92 |
93 | for (int i=0; ilength(); i++)
94 | {
95 | mFastTableWidget->setText(0, i, valueToString(aValues->at(i)));
96 | }
97 | }
98 | }
99 |
100 | ViewDialog::ViewDialog(QList *aValues, bool isVertical, QWidget *parent) :
101 | QDialog(parent),
102 | ui(new Ui::ViewDialog)
103 | {
104 | VIEWDIALOG_BASE_CONSTRUCTOR;
105 |
106 | if (isVertical)
107 | {
108 | mFastTableWidget->setRowCount(aValues->length());
109 |
110 | for (int i=0; ilength(); i++)
111 | {
112 | mFastTableWidget->setText(i, 0, valueToString(aValues->at(i)));
113 | }
114 | }
115 | else
116 | {
117 | mFastTableWidget->setColumnCount(aValues->length());
118 |
119 | for (int i=0; ilength(); i++)
120 | {
121 | mFastTableWidget->setText(0, i, valueToString(aValues->at(i)));
122 | }
123 | }
124 | }
125 |
126 | ViewDialog::ViewDialog(QList *aValues, bool isVertical, QWidget *parent) :
127 | QDialog(parent),
128 | ui(new Ui::ViewDialog)
129 | {
130 | VIEWDIALOG_BASE_CONSTRUCTOR;
131 |
132 | if (isVertical)
133 | {
134 | mFastTableWidget->setRowCount(aValues->length());
135 |
136 | for (int i=0; ilength(); i++)
137 | {
138 | mFastTableWidget->setText(i, 0, valueToString(aValues->at(i)));
139 | }
140 | }
141 | else
142 | {
143 | mFastTableWidget->setColumnCount(aValues->length());
144 |
145 | for (int i=0; ilength(); i++)
146 | {
147 | mFastTableWidget->setText(0, i, valueToString(aValues->at(i)));
148 | }
149 | }
150 | }
151 |
152 | ViewDialog::ViewDialog(QList *aValues, QWidget *parent) :
153 | QDialog(parent),
154 | ui(new Ui::ViewDialog)
155 | {
156 | VIEWDIALOG_BASE_CONSTRUCTOR;
157 |
158 | mFastTableWidget->setRowCount(aValues->length());
159 | mFastTableWidget->setColumnCount(2);
160 |
161 | mFastTableWidget->horizontalHeader_SetText(0, "X");
162 | mFastTableWidget->horizontalHeader_SetText(1, "Y");
163 |
164 | for (int i=0; ilength(); i++)
165 | {
166 | mFastTableWidget->setText(i, 0, valueToString(aValues->at(i).x()));
167 | mFastTableWidget->setText(i, 1, valueToString(aValues->at(i).y()));
168 | }
169 | }
170 |
171 | ViewDialog::ViewDialog(QList *aValues, QWidget *parent) :
172 | QDialog(parent),
173 | ui(new Ui::ViewDialog)
174 | {
175 | VIEWDIALOG_BASE_CONSTRUCTOR;
176 |
177 | mFastTableWidget->setRowCount(aValues->length());
178 | mFastTableWidget->setColumnCount(4);
179 |
180 | mFastTableWidget->horizontalHeader_SetText(0, "Left");
181 | mFastTableWidget->horizontalHeader_SetText(1, "Top");
182 | mFastTableWidget->horizontalHeader_SetText(2, "Right");
183 | mFastTableWidget->horizontalHeader_SetText(3, "Bottom");
184 |
185 | for (int i=0; ilength(); i++)
186 | {
187 | mFastTableWidget->setText(i, 0, valueToString(aValues->at(i).left()));
188 | mFastTableWidget->setText(i, 1, valueToString(aValues->at(i).top()));
189 | mFastTableWidget->setText(i, 2, valueToString(aValues->at(i).right()));
190 | mFastTableWidget->setText(i, 3, valueToString(aValues->at(i).bottom()));
191 | }
192 | }
193 |
194 | ViewDialog::ViewDialog(QList > *aValues, QWidget *parent) :
195 | QDialog(parent),
196 | ui(new Ui::ViewDialog)
197 | {
198 | VIEWDIALOG_BASE_CONSTRUCTOR;
199 |
200 | mFastTableWidget->setRowCount(aValues->length());
201 |
202 | if (aValues->length()>0)
203 | {
204 | mFastTableWidget->setColumnCount(aValues->at(0).length());
205 |
206 | for (int i=0; ilength(); i++)
207 | {
208 | for (int j=0; jat(i).length(); j++)
209 | {
210 | mFastTableWidget->setText(i, j, valueToString(aValues->at(i).at(j)));
211 | }
212 | }
213 | }
214 | else
215 | {
216 | mFastTableWidget->setColumnCount(0);
217 | }
218 | }
219 |
220 | ViewDialog::ViewDialog(QList > *aValues, QWidget *parent) :
221 | QDialog(parent),
222 | ui(new Ui::ViewDialog)
223 | {
224 | VIEWDIALOG_BASE_CONSTRUCTOR;
225 |
226 | mFastTableWidget->setRowCount(aValues->length());
227 |
228 | if (aValues->length()>0)
229 | {
230 | mFastTableWidget->setColumnCount(aValues->at(0).length());
231 |
232 | for (int i=0; ilength(); i++)
233 | {
234 | for (int j=0; jat(i).length(); j++)
235 | {
236 | mFastTableWidget->setText(i, j, valueToString(aValues->at(i).at(j)));
237 | }
238 | }
239 | }
240 | else
241 | {
242 | mFastTableWidget->setColumnCount(0);
243 | }
244 | }
245 |
246 | ViewDialog::ViewDialog(QList *aValues, QWidget *parent) :
247 | QDialog(parent),
248 | ui(new Ui::ViewDialog)
249 | {
250 | VIEWDIALOG_BASE_CONSTRUCTOR;
251 |
252 | mFastTableWidget->setRowCount(aValues->length());
253 |
254 | if (aValues->length()>0)
255 | {
256 | mFastTableWidget->setColumnCount(aValues->at(0).length());
257 |
258 | for (int i=0; ilength(); i++)
259 | {
260 | for (int j=0; jat(i).length(); j++)
261 | {
262 | mFastTableWidget->setText(i, j, valueToString(aValues->at(i).at(j)));
263 | }
264 | }
265 | }
266 | else
267 | {
268 | mFastTableWidget->setColumnCount(0);
269 | }
270 | }
271 |
272 | ViewDialog::~ViewDialog()
273 | {
274 | delete ui;
275 | }
276 |
277 | QString ViewDialog::valueToString(int aValue)
278 | {
279 | return QString::number(aValue);
280 | }
281 |
282 | QString ViewDialog::valueToString(bool aValue)
283 | {
284 | if (aValue)
285 | {
286 | return "true";
287 | }
288 | else
289 | {
290 | return "false";
291 | }
292 | }
293 |
294 | QString ViewDialog::valueToString(CustomFastTableWidget::MouseLocation aValue)
295 | {
296 | switch (aValue)
297 | {
298 | case CustomFastTableWidget::InMiddleWorld: return "InMiddleWorld";
299 | case CustomFastTableWidget::InCell: return "InCell";
300 | case CustomFastTableWidget::InHorizontalHeaderCell: return "InHorizontalHeaderCell";
301 | case CustomFastTableWidget::InVerticalHeaderCell: return "InVerticalHeaderCell";
302 | case CustomFastTableWidget::InTopLeftCorner: return "InTopLeftCorner";
303 | }
304 |
305 | return "";
306 | }
307 |
308 | QString ViewDialog::valueToString(QString aValue)
309 | {
310 | return aValue;
311 | }
312 |
313 | int ViewDialog::exec()
314 | {
315 | int aWidth=mFastTableWidget->totalWidth()+30;
316 | int aHeight=mFastTableWidget->totalHeight()+30;
317 |
318 | if (aWidth>800)
319 | {
320 | aWidth=800;
321 | }
322 |
323 | if (aHeight>600)
324 | {
325 | aHeight=600;
326 | }
327 |
328 | resize(aWidth, aHeight);
329 |
330 | for (int i=0; icolumnCount(); i++)
331 | {
332 | if (mFastTableWidget->horizontalHeader_Text(i)=="")
333 | {
334 | mFastTableWidget->horizontalHeader_SetText(i, QString::number(i+1));
335 | }
336 | }
337 |
338 | return QDialog::exec();
339 | }
340 |
--------------------------------------------------------------------------------
/src/controller/viewdialog.h:
--------------------------------------------------------------------------------
1 | #ifndef VIEWDIALOG_H
2 | #define VIEWDIALOG_H
3 |
4 | #include
5 |
6 | #include "../fasttable/fasttablewidget.h"
7 |
8 | #define VIEWDIALOG_BASE_CONSTRUCTOR ui->setupUi(this);\
9 | \
10 | setWindowFlags(Qt::Window);\
11 | \
12 | mFastTableWidget=new FastTableWidget(this);\
13 | ui->fastTableLayout->addWidget(mFastTableWidget);\
14 | \
15 | mFastTableWidget->setSizes(1, 1);
16 |
17 |
18 |
19 | namespace Ui {
20 | class ViewDialog;
21 | }
22 |
23 | class ViewDialog : public QDialog
24 | {
25 | Q_OBJECT
26 |
27 | public:
28 | FastTableWidget* mFastTableWidget;
29 |
30 | explicit ViewDialog(QWidget *parent = 0);
31 | explicit ViewDialog(int aValue, QWidget *parent = 0);
32 | explicit ViewDialog(bool aValue, QWidget *parent = 0);
33 | explicit ViewDialog(CustomFastTableWidget::MouseLocation aValue, QWidget *parent = 0);
34 | explicit ViewDialog(QPoint aValue, QWidget *parent = 0);
35 | explicit ViewDialog(QRect aValue, QWidget *parent = 0);
36 | explicit ViewDialog(QList *aValues, bool isVertical = false, QWidget *parent = 0);
37 | explicit ViewDialog(QList *aValues, bool isVertical = false, QWidget *parent = 0);
38 | explicit ViewDialog(QList *aValues, bool isVertical = false, QWidget *parent = 0);
39 | explicit ViewDialog(QList *aValues, QWidget *parent = 0);
40 | explicit ViewDialog(QList *aValues, QWidget *parent = 0);
41 | explicit ViewDialog(QList > *aValues, QWidget *parent = 0);
42 | explicit ViewDialog(QList > *aValues, QWidget *parent = 0);
43 | explicit ViewDialog(QList *aValues, QWidget *parent = 0);
44 | ~ViewDialog();
45 |
46 | private:
47 | Ui::ViewDialog *ui;
48 |
49 | inline QString valueToString(int aValue);
50 | inline QString valueToString(bool aValue);
51 | inline QString valueToString(CustomFastTableWidget::MouseLocation aValue);
52 | inline QString valueToString(QString aValue);
53 |
54 | public slots:
55 | int exec();
56 | };
57 |
58 | #endif // VIEWDIALOG_H
59 |
--------------------------------------------------------------------------------
/src/controller/viewdialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | ViewDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 800
10 | 600
11 |
12 |
13 |
14 | View
15 |
16 |
17 |
18 | 4
19 |
20 |
21 | 4
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/fasttable/customfasttablewidget.h:
--------------------------------------------------------------------------------
1 | #ifndef CUSTOMCustomFastTableWidget_H
2 | #define CUSTOMCustomFastTableWidget_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #include "fastdefines.h"
22 |
23 | //------------------------------------------------------------------------------
24 |
25 | class CustomFastTableWidget : public QAbstractScrollArea
26 | {
27 | Q_OBJECT
28 | Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount)
29 | Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount)
30 | Q_PROPERTY(qint16 horizontalHeader_RowCount READ horizontalHeader_RowCount WRITE horizontalHeader_SetRowCount)
31 | Q_PROPERTY(qint16 verticalHeader_ColumnCount READ verticalHeader_ColumnCount WRITE verticalHeader_SetColumnCount)
32 | Q_PROPERTY(quint16 defaultWidth READ defaultWidth WRITE setDefaultWidth)
33 | Q_PROPERTY(quint16 defaultHeight READ defaultHeight WRITE setDefaultHeight)
34 | Q_PROPERTY(int totalWidth READ totalWidth)
35 | Q_PROPERTY(int totalHeight READ totalHeight)
36 | Q_PROPERTY(int verticalHeader_TotalWidth READ verticalHeader_TotalWidth)
37 | Q_PROPERTY(int horizontalHeader_TotalHeight READ horizontalHeader_TotalHeight)
38 | Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors)
39 | Q_PROPERTY(bool horizontalHeader_StretchLastSection READ horizontalHeader_StretchLastSection WRITE horizontalHeader_SetStretchLastSection)
40 | Q_PROPERTY(bool verticalHeader_StretchLastSection READ verticalHeader_StretchLastSection WRITE verticalHeader_SetStretchLastSection)
41 | Q_PROPERTY(QColor gridColor READ gridColor WRITE setGridColor)
42 | Q_PROPERTY(QColor cellBorderColor READ cellBorderColor WRITE setCellBorderColor)
43 | Q_PROPERTY(QBrush horizontalHeader_DefaultBackgroundBrush READ horizontalHeader_DefaultBackgroundBrush WRITE horizontalHeader_SetDefaultBackgroundBrush)
44 | Q_PROPERTY(QColor horizontalHeader_DefaultForegroundColor READ horizontalHeader_DefaultForegroundColor WRITE horizontalHeader_SetDefaultForegroundColor)
45 | Q_PROPERTY(QColor horizontalHeader_GridColor READ horizontalHeader_GridColor WRITE horizontalHeader_SetGridColor)
46 | Q_PROPERTY(QColor horizontalHeader_CellBorderColor READ horizontalHeader_CellBorderColor WRITE horizontalHeader_SetCellBorderColor)
47 | Q_PROPERTY(QBrush verticalHeader_DefaultBackgroundBrush READ verticalHeader_DefaultBackgroundBrush WRITE verticalHeader_SetDefaultBackgroundBrush)
48 | Q_PROPERTY(QColor verticalHeader_DefaultForegroundColor READ verticalHeader_DefaultForegroundColor WRITE verticalHeader_SetDefaultForegroundColor)
49 | Q_PROPERTY(QColor verticalHeader_GridColor READ verticalHeader_GridColor WRITE verticalHeader_SetGridColor)
50 | Q_PROPERTY(QColor verticalHeader_CellBorderColor READ verticalHeader_CellBorderColor WRITE verticalHeader_SetCellBorderColor)
51 |
52 | public:
53 | Q_ENUMS(DrawComponent Style MouseLocation)
54 |
55 | enum DrawComponent {DrawCell, DrawHorizontalHeaderCell, DrawVerticalHeaderCell, DrawTopLeftCorner};
56 | enum Style {StyleSimple, StyleLinux, StyleWinXP, StyleWin7};
57 | enum MouseLocation {InMiddleWorld, InCell, InHorizontalHeaderCell, InVerticalHeaderCell, InTopLeftCorner};
58 |
59 | typedef void (*DrawFunction)(QPainter &painter, const int x, const int y, const int width, const int height, const bool headerPressed, QColor *aGridColor, QBrush *aBackgroundBrush, QColor *aBorderColor);
60 |
61 | explicit CustomFastTableWidget(QWidget *parent = 0);
62 | explicit CustomFastTableWidget(const bool aUseInternalData, QWidget *parent = 0);
63 | ~CustomFastTableWidget();
64 |
65 | bool updatesEnabled() const;
66 | void setUpdatesEnabled(bool enable);
67 |
68 | void setHorizontalScrollBar(QScrollBar *scrollbar);
69 | void setVerticalScrollBar(QScrollBar *scrollbar);
70 |
71 | virtual void clear();
72 |
73 | void copy();
74 |
75 | virtual void selectRow(const int row);
76 | virtual void unselectRow(const int row);
77 |
78 | virtual void selectColumn(const int column);
79 | virtual void unselectColumn(const int column);
80 |
81 | void searchNext(const QString &pattern, const QTableWidget::SelectionBehavior behaviour=QTableWidget::SelectItems, const int column=-1, const bool centered=true);
82 | void searchPrevious(const QString &pattern, const QTableWidget::SelectionBehavior behaviour=QTableWidget::SelectItems, const int column=-1, const bool centered=true);
83 |
84 | Style style();
85 | void setStyle(Style style, bool keepColors=false);
86 |
87 | void setDrawCellFunction(DrawFunction aDrawCellFunction);
88 | void setDrawHeaderCellFunction(DrawFunction aDrawHeaderCellFunction);
89 |
90 | void selectAll();
91 | void unselectAll();
92 |
93 | void addRow();
94 | virtual void insertRow(int row);
95 | virtual void removeRow(int row);
96 |
97 | void addColumn();
98 | virtual void insertColumn(int column);
99 | virtual void removeColumn(int column);
100 |
101 | void horizontalHeader_AddRow();
102 | virtual void horizontalHeader_InsertRow(int row);
103 | virtual void horizontalHeader_RemoveRow(int row);
104 |
105 | void verticalHeader_AddColumn();
106 | virtual void verticalHeader_InsertColumn(int column);
107 | virtual void verticalHeader_RemoveColumn(int column);
108 |
109 | int rowCount();
110 | void setRowCount(int count);
111 |
112 | int columnCount();
113 | void setColumnCount(int count);
114 |
115 | qint16 horizontalHeader_RowCount();
116 | void horizontalHeader_SetRowCount(qint16 count);
117 |
118 | qint16 verticalHeader_ColumnCount();
119 | void verticalHeader_SetColumnCount(qint16 count);
120 |
121 | void setSizes(int aRowCount, int aColumnCount, qint16 aHorizontalHeaderRowCount=1, qint16 aVerticalHeaderColumnCount=1);
122 |
123 | void setFont(const QFont &aFont);
124 |
125 | bool autoVerticalHeaderSize();
126 | void setAutoVerticalHeaderSize(bool enable);
127 |
128 | bool alternatingRowColors();
129 | void setAlternatingRowColors(bool enable);
130 |
131 | bool horizontalHeader_StretchLastSection();
132 | void horizontalHeader_SetStretchLastSection(bool enable);
133 |
134 | bool verticalHeader_StretchLastSection();
135 | void verticalHeader_SetStretchLastSection(bool enable);
136 |
137 | QColor gridColor();
138 | void setGridColor(QColor color);
139 |
140 | QColor cellBorderColor();
141 | void setCellBorderColor(QColor color);
142 |
143 | QBrush horizontalHeader_DefaultBackgroundBrush();
144 | void horizontalHeader_SetDefaultBackgroundBrush(QBrush brush);
145 |
146 | QColor horizontalHeader_DefaultForegroundColor();
147 | void horizontalHeader_SetDefaultForegroundColor(QColor color);
148 |
149 | QColor horizontalHeader_GridColor();
150 | void horizontalHeader_SetGridColor(QColor color);
151 |
152 | QColor horizontalHeader_CellBorderColor();
153 | void horizontalHeader_SetCellBorderColor(QColor color);
154 |
155 | QBrush verticalHeader_DefaultBackgroundBrush();
156 | void verticalHeader_SetDefaultBackgroundBrush(QBrush brush);
157 |
158 | QColor verticalHeader_DefaultForegroundColor();
159 | void verticalHeader_SetDefaultForegroundColor(QColor color);
160 |
161 | QColor verticalHeader_GridColor();
162 | void verticalHeader_SetGridColor(QColor color);
163 |
164 | QColor verticalHeader_CellBorderColor();
165 | void verticalHeader_SetCellBorderColor(QColor color);
166 |
167 | quint16 defaultWidth();
168 | void setDefaultWidth(quint16 width);
169 |
170 | quint16 defaultHeight();
171 | void setDefaultHeight(quint16 height);
172 |
173 | quint16 columnWidth(const int column);
174 | void setColumnWidth(const int column, quint16 width, bool forceUpdate=true);
175 |
176 | quint16 rowHeight(const int row);
177 | void setRowHeight(const int row, quint16 height, bool forceUpdate=true);
178 |
179 | quint16 verticalHeader_ColumnWidth(const int column);
180 | void verticalHeader_SetColumnWidth(const int column, quint16 width, bool forceUpdate=true);
181 |
182 | quint16 horizontalHeader_RowHeight(const int row);
183 | void horizontalHeader_SetRowHeight(const int row, quint16 height, bool forceUpdate=true);
184 |
185 | int totalWidth();
186 | int totalHeight();
187 | int verticalHeader_TotalWidth();
188 | int horizontalHeader_TotalHeight();
189 |
190 | bool columnVisible(const int column);
191 | void setColumnVisible(const int column, bool visible, bool forceUpdate=true);
192 |
193 | bool rowVisible(const int row);
194 | void setRowVisible(const int row, bool visible, bool forceUpdate=true);
195 |
196 | bool verticalHeader_ColumnVisible(const int column);
197 | void verticalHeader_SetColumnVisible(const int column, bool visible, bool forceUpdate=true);
198 |
199 | bool horizontalHeader_RowVisible(const int row);
200 | void horizontalHeader_SetRowVisible(const int row, bool visible, bool forceUpdate=true);
201 |
202 | int rowOffset(const int row);
203 | int columnOffset(const int column);
204 | int horizontalHeader_rowOffset(const int row);
205 | int verticalHeader_columnOffset(const int column);
206 |
207 | void updateOffsetsX(const int fromIndex=0);
208 | void updateOffsetsY(const int fromIndex=0);
209 | void verticalHeader_UpdateOffsetsX(const int fromIndex=0);
210 | void horizontalHeader_UpdateOffsetsY(const int fromIndex=0);
211 |
212 | QRect visibleRange();
213 | QRect horizontalHeader_VisibleRange();
214 | QRect verticalHeader_VisibleRange();
215 |
216 | virtual QRect cellRectangle(const int row, const int column);
217 | virtual QRect horizontalHeader_CellRectangle(const int row, const int column);
218 | virtual QRect verticalHeader_CellRectangle(const int row, const int column);
219 | void scrollToCell(const int row, const int column, const bool centered=false);
220 |
221 | virtual QString text(const int row, const int column);
222 | virtual void setText(const int row, const int column, const QString text);
223 |
224 | QString horizontalHeader_Text(const int row, const int column);
225 | QString horizontalHeader_Text(const int column);
226 | void horizontalHeader_SetText(const int row, const int column, const QString text);
227 | void horizontalHeader_SetText(const int column, const QString text);
228 |
229 | QString verticalHeader_Text(const int row, const int column);
230 | QString verticalHeader_Text(const int row);
231 | void verticalHeader_SetText(const int row, const int column, const QString text);
232 | void verticalHeader_SetText(const int row, const QString text);
233 |
234 | virtual QBrush backgroundBrush(const int row, const int column);
235 | virtual void setBackgroundBrush(const int row, const int column, const QBrush brush);
236 |
237 | virtual QColor foregroundColor(const int row, const int column);
238 | virtual void setForegroundColor(const int row, const int column, const QColor color);
239 |
240 | virtual QFont cellFont(const int row, const int column);
241 | virtual void setCellFont(const int row, const int column, const QFont font);
242 |
243 | virtual int cellTextFlags(const int row, const int column);
244 | virtual void setCellTextFlags(const int row, const int column, const int flags);
245 |
246 | virtual bool cellSelected(const int row, const int column);
247 | virtual void setCellSelected(const int row, const int column, const bool selected);
248 |
249 | QList selectedCells();
250 | QList selectedRanges();
251 | QPoint topLeftSelectedCell();
252 | bool rowHasSelection(const int row);
253 | bool columnHasSelection(const int column);
254 |
255 | QPoint currentCell();
256 | virtual void setCurrentCell(const int row, const int column, const bool keepSelection=false);
257 |
258 | int currentRow();
259 | void setCurrentRow(const int row, const bool keepSelection=false);
260 |
261 | int currentColumn();
262 | void setCurrentColumn(const int column, const bool keepSelection=false);
263 |
264 | QPoint cellAt(const int x, const int y);
265 | QPoint horizontalHeader_CellAt(const int x, const int y);
266 | QPoint verticalHeader_CellAt(const int x, const int y);
267 | bool atTopLeftCorner(const int x, const int y);
268 |
269 | QAbstractItemView::EditTriggers editTriggers() const;
270 | void setEditTriggers(const QAbstractItemView::EditTriggers aEditTriggers);
271 |
272 | virtual void editCell(const int row, const int column);
273 |
274 | protected:
275 | bool mUseInternalData;
276 |
277 | Style mStyle;
278 |
279 | DrawFunction mDrawCellFunction;
280 | DrawFunction mDrawHeaderCellFunction;
281 |
282 | bool mAutoVerticalHeaderSize;
283 | bool mAlternatingRowColors;
284 | bool mHorizontalHeaderStretchLastSection;
285 | bool mVerticalHeaderStretchLastSection;
286 |
287 | QColor mGridColor;
288 | QColor mCellBorderColor;
289 |
290 | QBrush mHorizontalHeader_DefaultBackgroundBrush;
291 | QColor mHorizontalHeader_DefaultForegroundColor;
292 | QColor mHorizontalHeader_GridColor;
293 | QColor mHorizontalHeader_CellBorderColor;
294 |
295 | QBrush mVerticalHeader_DefaultBackgroundBrush;
296 | QColor mVerticalHeader_DefaultForegroundColor;
297 | QColor mVerticalHeader_GridColor;
298 | QColor mVerticalHeader_CellBorderColor;
299 |
300 | int mRowCount;
301 | int mColumnCount;
302 | qint16 mHorizontalHeader_RowCount;
303 | qint16 mVerticalHeader_ColumnCount;
304 |
305 | quint16 mDefaultWidth;
306 | quint16 mDefaultHeight;
307 | int mTotalWidth;
308 | int mTotalHeight;
309 | int mVerticalHeader_TotalWidth;
310 | int mHorizontalHeader_TotalHeight;
311 |
312 | int mVisibleLeft;
313 | int mVisibleRight;
314 | int mVisibleTop;
315 | int mVisibleBottom;
316 |
317 | int mHorizontalHeader_VisibleBottom;
318 |
319 | int mVerticalHeader_VisibleRight;
320 |
321 | QList< QStringList > *mData;
322 | QList< qint16 > *mRowHeights;
323 | QList< qint16 > *mColumnWidths;
324 | QList< int > *mOffsetX;
325 | QList< int > *mOffsetY;
326 |
327 | QList< QStringList > *mHorizontalHeader_Data;
328 | QList< qint16 > *mHorizontalHeader_RowHeights;
329 | QList< int > *mHorizontalHeader_OffsetY;
330 |
331 | QList< QStringList > *mVerticalHeader_Data;
332 | QList< qint16 > *mVerticalHeader_ColumnWidths;
333 | QList< int > *mVerticalHeader_OffsetX;
334 |
335 | QList< QList > *mSelectedCells;
336 | QList< QPoint > *mCurSelection;
337 | QList< int > *mHorizontalHeader_SelectedColumns;
338 | QList< int > *mVerticalHeader_SelectedRows;
339 |
340 | int mCurrentRow;
341 | int mCurrentColumn;
342 |
343 | int mLastX;
344 | int mLastY;
345 | int mMouseXForShift;
346 | int mMouseYForShift;
347 | int mMouseResizeLineX;
348 | int mMouseResizeLineY;
349 | int mMouseResizeCell;
350 |
351 | bool mMousePressed;
352 | bool mCtrlPressed;
353 | bool mShiftPressed;
354 |
355 | MouseLocation mMouseLocation;
356 | MouseLocation mMouseLocationForShift;
357 |
358 | QList< QList > *mMouseSelectedCells;
359 |
360 | QTimer mMouseHoldTimer;
361 | QMouseEvent mMouseEvent;
362 |
363 | QAbstractItemView::EditTriggers mEditTriggers;
364 | int mEditCellRow;
365 | int mEditCellColumn;
366 | QWidget *mEditor;
367 | bool mEditorPaintByTable;
368 |
369 | void init(const bool aUseInternalData);
370 | void createLists();
371 | void deleteLists();
372 |
373 | void keyPressEvent(QKeyEvent *event);
374 | bool focusNextPrevChild(bool next);
375 | void mousePressEvent(QMouseEvent *event);
376 | void mouseMoveEvent(QMouseEvent *event);
377 | void mouseReleaseEvent(QMouseEvent *event);
378 | void mouseDoubleClickEvent(QMouseEvent *event);
379 | bool eventFilter(QObject *aObject, QEvent *aEvent);
380 | void leaveEvent(QEvent *event);
381 | void resizeEvent(QResizeEvent *event);
382 | void paintEvent(QPaintEvent *event);
383 |
384 | virtual void selectRangeForHandlers(int resX, int resY);
385 | virtual void horizontalHeader_SelectRangeForHandlers(int resX);
386 | virtual void verticalHeader_SelectRangeForHandlers(int resY);
387 |
388 | virtual void paintCell(QPainter &painter, const int x, const int y, const int width, const int height, const int row, const int column, const DrawComponent drawComponent);
389 | virtual void paintCell(QPainter &painter, const int x, const int y, const int width, const int height, const DrawComponent drawComponent, bool headerPressed, QColor *aGridColor,
390 | QBrush *aBackgroundBrush, QColor *aBorderColor, QColor *aTextColor, QString *aText, QFont *aFont, int aTextFlags);
391 |
392 | static void paintCellLinux(QPainter &painter, const int x, const int y, const int width, const int height, const bool headerPressed, QColor *aGridColor, QBrush *aBackgroundBrush, QColor *aBorderColor);
393 | static void paintCellDefault(QPainter &painter, const int x, const int y, const int width, const int height, const bool headerPressed, QColor *aGridColor, QBrush *aBackgroundBrush, QColor *aBorderColor);
394 | static void paintHeaderCellLinux(QPainter &painter, const int x, const int y, const int width, const int height, const bool headerPressed, QColor *aGridColor, QBrush *aBackgroundBrush, QColor *aBorderColor);
395 | static void paintHeaderCellWinXP(QPainter &painter, const int x, const int y, const int width, const int height, const bool headerPressed, QColor *aGridColor, QBrush *aBackgroundBrush, QColor *aBorderColor);
396 | static void paintHeaderCellWin7(QPainter &painter, const int x, const int y, const int width, const int height, const bool headerPressed, QColor *aGridColor, QBrush *aBackgroundBrush, QColor *aBorderColor);
397 | static void paintHeaderCellDefault(QPainter &painter, const int x, const int y, const int width, const int height, const bool headerPressed, QColor *aGridColor, QBrush *aBackgroundBrush, QColor *aBorderColor);
398 |
399 | void updateVerticalHeaderSize();
400 | void updateSizes();
401 | void updateBarsRanges();
402 | virtual void updateVisibleRange();
403 | void initShiftSelectionForKeyboard();
404 | void initShiftSelection();
405 | void fillShiftSelection();
406 |
407 | bool isEditKey(const QString aText);
408 | void removeEditor();
409 | virtual QWidget* createEditor(const int row, const int column);
410 | virtual QString editorText(QWidget *editor, const int row, const int column);
411 | void updateEditorPosition();
412 | void finishEditing();
413 | virtual void commitData(QWidget *editor, const int row, const int column);
414 |
415 | public slots:
416 | void scrollToTop();
417 | void scrollToBottom();
418 | void scrollToCurrentCell(const bool centered=false);
419 |
420 | protected slots:
421 | void scrollBarValueChanged(int value);
422 |
423 | void mouseHoldTick();
424 |
425 | signals:
426 | void cellClicked(int row, int column);
427 | void cellRightClicked(int row, int column);
428 | void cellDoubleClicked(int row, int column);
429 |
430 | void horizontalHeader_CellClicked(int row, int column);
431 | void horizontalHeader_CellRightClicked(int row, int column);
432 | void horizontalHeader_CellDoubleClicked(int row, int column);
433 |
434 | void verticalHeader_CellClicked(int row, int column);
435 | void verticalHeader_CellRightClicked(int row, int column);
436 | void verticalHeader_CellDoubleClicked(int row, int column);
437 |
438 | void topLeftCornerClicked();
439 | void topLeftCornerRightClicked();
440 | void topLeftCornerDoubleClicked();
441 |
442 | void currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);
443 | void cellChanged(int row, int column);
444 | void selectionChanged();
445 |
446 | void rowHeightChanged(int row, int value);
447 | void columnWidthChanged(int column, int value);
448 |
449 | void horizontalHeader_RowHeightChanged(int row, int value);
450 | void verticalHeader_ColumnWidthChanged(int column, int value);
451 | };
452 |
453 | #endif // CUSTOMCustomFastTableWidget_H
454 |
--------------------------------------------------------------------------------
/src/fasttable/fastdefines.h:
--------------------------------------------------------------------------------
1 | #ifndef FASTDEFINES_H
2 | #define FASTDEFINES_H
3 |
4 | #include
5 |
6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7 | // Asserting
8 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9 | #if 1
10 | #define FASTTABLE_ASSERT(condition) Q_ASSERT(condition)
11 | #else
12 | #define FASTTABLE_ASSERT(condition)
13 | #endif
14 |
15 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 | // Debuging
17 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
18 | #if 0
19 | #define FASTTABLE_DEBUG qDebug()<<"Debug:"< > *mBackgroundBrushes;
120 | QList< QList > *mForegroundColors;
121 | QList< QList > *mCellFonts;
122 | QList< QList > *mCellTextFlags;
123 | QList< QList > *mCellMergeX;
124 | QList< QList > *mCellMergeY;
125 | QList< QList > *mCellMergeParentRow;
126 | QList< QList > *mCellMergeParentColumn;
127 | QList< QRect > *mMerges;
128 |
129 | QList< QList > *mHorizontalHeader_BackgroundBrushes;
130 | QList< QList > *mHorizontalHeader_ForegroundColors;
131 | QList< QList > *mHorizontalHeader_CellFonts;
132 | QList< QList > *mHorizontalHeader_CellTextFlags;
133 | QList< QList > *mHorizontalHeader_CellMergeX;
134 | QList< QList > *mHorizontalHeader_CellMergeY;
135 | QList< QList > *mHorizontalHeader_CellMergeParentRow;
136 | QList< QList > *mHorizontalHeader_CellMergeParentColumn;
137 | QList< QRect > *mHorizontalHeader_Merges;
138 |
139 | QList< QList > *mVerticalHeader_BackgroundBrushes;
140 | QList< QList > *mVerticalHeader_ForegroundColors;
141 | QList< QList > *mVerticalHeader_CellFonts;
142 | QList< QList > *mVerticalHeader_CellTextFlags;
143 | QList< QList > *mVerticalHeader_CellMergeX;
144 | QList< QList > *mVerticalHeader_CellMergeY;
145 | QList< QList > *mVerticalHeader_CellMergeParentRow;
146 | QList< QList > *mVerticalHeader_CellMergeParentColumn;
147 | QList< QRect > *mVerticalHeader_Merges;
148 |
149 | void createLists();
150 | void deleteLists();
151 |
152 | void paintEvent(QPaintEvent *event);
153 | void paintCell(QPainter &painter, const int x, const int y, const int width, const int height, const int row, const int column, const DrawComponent drawComponent);
154 |
155 | void updateVisibleRange();
156 | };
157 |
158 | #endif // FASTTABLEWIDGET_H
159 |
--------------------------------------------------------------------------------
/src/fasttable/optimallist/optimallist.cpp:
--------------------------------------------------------------------------------
1 | #include "optimallist.h"
2 |
3 | OptimalListSharedData::OptimalListSharedData()
4 | {
5 | mBuffer=0;
6 | mBegin=0;
7 | mCount=0;
8 | mCapacity=0;
9 | mReserved=0;
10 | mReferences=1;
11 | }
12 |
--------------------------------------------------------------------------------
/src/fasttable/optimallist/optimallist.h:
--------------------------------------------------------------------------------
1 | #ifndef OPTIMALLIST_H
2 | #define OPTIMALLIST_H
3 |
4 | #include
5 |
6 | class OptimalListSharedData
7 | {
8 | public:
9 | OptimalListSharedData();
10 |
11 | void* mBuffer;
12 | int mBegin;
13 | int mCount;
14 | int mCapacity;
15 | int mReserved;
16 | int mReferences;
17 | };
18 |
19 | template
20 | class OptimalList
21 | {
22 | public:
23 | OptimalList();
24 | OptimalList(OptimalList &list);
25 | ~OptimalList();
26 |
27 | void clear();
28 |
29 | void reserve(int size);
30 |
31 | void prepend(const T &t);
32 | void append(const T &t);
33 | void append(const OptimalList &t);
34 | void insert(int i, const T &t);
35 |
36 | void replace(int i, const T &t);
37 |
38 | void removeAt(int i);
39 | void removeFirst();
40 | void removeLast();
41 | int removeAll(const T &t);
42 | bool removeOne(const T &t);
43 |
44 | T takeAt(int i);
45 | T takeFirst();
46 | T takeLast();
47 |
48 | const T &at(int i) const;
49 | const T &operator[](int i) const;
50 | T &operator[](int i);
51 | T value(int i) const;
52 | T value(int i, const T &defaultValue) const;
53 | T& first();
54 | const T& first() const;
55 | T& last();
56 | const T& last() const;
57 |
58 | int length() const;
59 | int size() const;
60 | int count() const;
61 |
62 | bool isEmpty() const;
63 |
64 | void move(int from, int to);
65 | void swap(int i, int j);
66 | void swap(OptimalList &other);
67 |
68 | int indexOf(const T &t, int from = 0) const;
69 | int lastIndexOf(const T &t, int from = -1) const;
70 | bool contains(const T &t) const;
71 | bool startsWith(const T &t) const;
72 | bool endsWith(const T &t) const;
73 |
74 | int count(const T &t) const;
75 |
76 | OptimalList mid(int pos, int length = -1) const;
77 |
78 | OptimalList &operator=(OptimalList &l);
79 | bool operator==(const OptimalList &l) const;
80 | bool operator!=(const OptimalList &l) const;
81 |
82 | protected:
83 | enum
84 | {
85 | // Should be like this, but we use as below. Maybe it is good
86 | // isLarge = QTypeInfo::isLarge || QTypeInfo::isStatic,
87 | isLarge = (sizeof(T)>sizeof(void *)*4),// || QTypeInfo::isStatic,
88 | sizeOfElement = isLarge ? sizeof(void *) : sizeof(T)
89 | };
90 |
91 | void* mBuffer;
92 | int mBegin;
93 | int mCount;
94 | int mCapacity;
95 | int mReserved;
96 |
97 | void setOptimalCapacity();
98 | inline void* pointerAt(const int i);
99 | };
100 |
101 | template
102 | OptimalList::OptimalList()
103 | {
104 | mBuffer=0;
105 | mBegin=0;
106 | mCount=0;
107 | mCapacity=0;
108 | mReserved=0;
109 | }
110 |
111 | template
112 | OptimalList::OptimalList(OptimalList &list)
113 | {
114 | mBuffer=0;
115 | mBegin=0;
116 | mCount=0;
117 | mCapacity=0;
118 | mReserved=0;
119 |
120 | *this=list;
121 | }
122 |
123 | template
124 | OptimalList::~OptimalList()
125 | {
126 | clear();
127 | }
128 |
129 | template
130 | void OptimalList::clear()
131 | {
132 | if (isLarge)
133 | {
134 | for (int i=0; i(pointerAt(i));
137 | }
138 | }
139 |
140 | mBegin=0;
141 | mCount=0;
142 | mReserved=0;
143 | setOptimalCapacity();
144 | }
145 |
146 | template
147 | void OptimalList::reserve(int size)
148 | {
149 | if (mReserved!=size)
150 | {
151 | mReserved=size;
152 | setOptimalCapacity();
153 | }
154 | }
155 |
156 | template
157 | void OptimalList::prepend(const T &t)
158 | {
159 | ++mCount;
160 |
161 | if (mBegin==0)
162 | {
163 | if (mCount>=(mCapacity << 1)/3)
164 | {
165 | mBegin=mCapacity-mCount+1; // +1 - to increase capacity at the next step
166 | setOptimalCapacity();
167 | }
168 |
169 | mBegin=(mCapacity-mCount) >> 1;
170 |
171 | if (mBegin==0)
172 | {
173 | mBegin=1;
174 | }
175 |
176 | memmove(pointerAt(0), mBuffer, (mCount-1)*sizeOfElement);
177 | }
178 |
179 | --mBegin;
180 |
181 | if (isLarge)
182 | {
183 | *reinterpret_cast(pointerAt(0))=new T(t);
184 | }
185 | else
186 | if (QTypeInfo::isComplex)
187 | {
188 | new (pointerAt(0)) T(t);
189 | }
190 | else
191 | {
192 | *reinterpret_cast(pointerAt(0))=t;
193 | }
194 | }
195 |
196 | template
197 | void OptimalList::append(const T &t)
198 | {
199 | ++mCount;
200 | setOptimalCapacity();
201 |
202 | if (isLarge)
203 | {
204 | *reinterpret_cast(pointerAt(mCount-1))=new T(t);
205 | }
206 | else
207 | if (QTypeInfo::isComplex)
208 | {
209 | new (pointerAt(mCount-1)) T(t);
210 | }
211 | else
212 | {
213 | *reinterpret_cast(pointerAt(mCount-1))=t;
214 | }
215 | }
216 |
217 | template
218 | void OptimalList::append(const OptimalList &t)
219 | {
220 | if (t.mCount>0)
221 | {
222 | mCount+=t.mCount;
223 | setOptimalCapacity();
224 |
225 | for (int i=0; i(pointerAt(mCount+i-t.mCount))=new T(**reinterpret_cast(t.pointerAt(i)));
230 | }
231 | else
232 | if (QTypeInfo::isComplex)
233 | {
234 | new (pointerAt(mCount+i-t.mCount)) T(*reinterpret_cast(t.pointerAt(i)));
235 | }
236 | else
237 | {
238 | *reinterpret_cast(pointerAt(mCount+i-t.mCount))=*reinterpret_cast(t.pointerAt(i));
239 | }
240 | }
241 | }
242 | }
243 |
244 | template
245 | void OptimalList::insert(int i, const T &t)
246 | {
247 | if (i<=0)
248 | {
249 | prepend(t);
250 | return;
251 | }
252 |
253 | if (i>=mCount)
254 | {
255 | append(t);
256 | return;
257 | }
258 |
259 | ++mCount;
260 |
261 | if (mBegin==0 || i>(mCount >> 1))
262 | {
263 | setOptimalCapacity();
264 |
265 | if (i>(mCount >> 1))
266 | {
267 | memmove(pointerAt(i+1), pointerAt(i), (mCount-i-1)*sizeOfElement);
268 | }
269 | else
270 | {
271 | // mBegin was 0
272 | mBegin=(mCapacity-mCount) >> 1;
273 |
274 | if (mBegin==0)
275 | {
276 | mBegin=1;
277 | }
278 |
279 | memmove(pointerAt(0), mBuffer, (mCount-1)*sizeOfElement);
280 |
281 | --mBegin;
282 | memmove(pointerAt(0), pointerAt(1), i*sizeOfElement);
283 | }
284 | }
285 | else
286 | {
287 | --mBegin;
288 | memmove(pointerAt(0), pointerAt(1), i*sizeOfElement);
289 | }
290 |
291 | if (isLarge)
292 | {
293 | *reinterpret_cast(pointerAt(i))=new T(t);
294 | }
295 | else
296 | if (QTypeInfo::isComplex)
297 | {
298 | new (pointerAt(i)) T(t);
299 | }
300 | else
301 | {
302 | *reinterpret_cast(pointerAt(i))=t;
303 | }
304 | }
305 |
306 | template
307 | void OptimalList::replace(int i, const T &t)
308 | {
309 | Q_ASSERT_X(i >= 0 && i < mCount, "OptimalList::replace", "index out of range");
310 |
311 | if (isLarge)
312 | {
313 | **reinterpret_cast(pointerAt(i))=t;
314 | }
315 | else
316 | {
317 | *reinterpret_cast(pointerAt(i))=t;
318 | }
319 | }
320 |
321 | template
322 | void OptimalList::removeAt(int i)
323 | {
324 | Q_ASSERT_X(i >= 0 && i < mCount, "OptimalList::removeAt", "index out of range");
325 |
326 | if (isLarge)
327 | {
328 | delete *reinterpret_cast(pointerAt(i));
329 | }
330 |
331 | if (i>mCount >> 1)
332 | {
333 | memmove(pointerAt(i), pointerAt(i+1), (mCount-i-1)*sizeOfElement);
334 | }
335 | else
336 | {
337 | memmove(pointerAt(1), pointerAt(0), i*sizeOfElement);
338 |
339 | ++mBegin;
340 | }
341 |
342 | --mCount;
343 | setOptimalCapacity();
344 | }
345 |
346 | template
347 | void OptimalList::removeFirst()
348 | {
349 | if (mCount>0)
350 | {
351 | removeAt(0);
352 | }
353 | }
354 |
355 | template
356 | void OptimalList::removeLast()
357 | {
358 | if (mCount>0)
359 | {
360 | removeAt(mCount-1);
361 | }
362 | }
363 |
364 | template
365 | int OptimalList::removeAll(const T &t)
366 | {
367 | int removed=0;
368 |
369 | int i=0;
370 |
371 | while (i
388 | bool OptimalList::removeOne(const T &t)
389 | {
390 | int index=indexOf(t);
391 |
392 | if (index>=0)
393 | {
394 | removeAt(index);
395 | return true;
396 | }
397 |
398 | return false;
399 | }
400 |
401 | template
402 | T OptimalList::takeAt(int i)
403 | {
404 | Q_ASSERT_X(i >= 0 && i < mCount, "OptimalList::takeAt", "index out of range");
405 |
406 | T t=at(i);
407 | removeAt(i);
408 | return t;
409 | }
410 |
411 | template
412 | T OptimalList::takeFirst()
413 | {
414 | T t=first();
415 | removeFirst();
416 | return t;
417 | }
418 |
419 | template
420 | T OptimalList::takeLast()
421 | {
422 | T t=last();
423 | removeLast();
424 | return t;
425 | }
426 |
427 | template
428 | const T &OptimalList::at(int i) const
429 | {
430 | Q_ASSERT_X(i >= 0 && i < mCount, "OptimalList::at", "index out of range");
431 |
432 | if (isLarge)
433 | {
434 | return **reinterpret_cast(pointerAt(i));
435 | }
436 | else
437 | {
438 | return *reinterpret_cast(pointerAt(i));
439 | }
440 | }
441 |
442 | template
443 | const T &OptimalList::operator[](int i) const
444 | {
445 | Q_ASSERT_X(i >= 0 && i < mCount, "OptimalList::operator[]", "index out of range");
446 |
447 | if (isLarge)
448 | {
449 | return **reinterpret_cast(pointerAt(i));
450 | }
451 | else
452 | {
453 | return *reinterpret_cast(pointerAt(i));
454 | }
455 | }
456 |
457 | template
458 | T &OptimalList::operator[](int i)
459 | {
460 | Q_ASSERT_X(i >= 0 && i < mCount, "OptimalList::operator[]", "index out of range");
461 |
462 | if (isLarge)
463 | {
464 | return **reinterpret_cast(pointerAt(i));
465 | }
466 | else
467 | {
468 | return *reinterpret_cast(pointerAt(i));
469 | }
470 | }
471 |
472 | template
473 | T OptimalList::value(int i) const
474 | {
475 | if (i>=0 && i
486 | T OptimalList::value(int i, const T &defaultValue) const
487 | {
488 | if (i>=0 && i
499 | T& OptimalList::first()
500 | {
501 | Q_ASSERT(!isEmpty());
502 |
503 | if (isLarge)
504 | {
505 | return **reinterpret_cast(pointerAt(0));
506 | }
507 | else
508 | {
509 | return *reinterpret_cast(pointerAt(0));
510 | }
511 | }
512 |
513 | template
514 | const T& OptimalList::first() const
515 | {
516 | Q_ASSERT(!isEmpty());
517 |
518 | if (isLarge)
519 | {
520 | return **reinterpret_cast(pointerAt(0));
521 | }
522 | else
523 | {
524 | return *reinterpret_cast(pointerAt(0));
525 | }
526 | }
527 |
528 | template
529 | T& OptimalList::last()
530 | {
531 | Q_ASSERT(!isEmpty());
532 |
533 | if (isLarge)
534 | {
535 | return **reinterpret_cast(pointerAt(mCount-1));
536 | }
537 | else
538 | {
539 | return *reinterpret_cast(pointerAt(mCount-1));
540 | }
541 | }
542 |
543 | template
544 | const T& OptimalList::last() const
545 | {
546 | if (isLarge)
547 | {
548 | return **reinterpret_cast(pointerAt(mCount-1));
549 | }
550 | else
551 | {
552 | return *reinterpret_cast(pointerAt(mCount-1));
553 | }
554 | }
555 |
556 | template
557 | int OptimalList::length() const
558 | {
559 | return mCount;
560 | }
561 |
562 | template
563 | int OptimalList::size() const
564 | {
565 | return mCount;
566 | }
567 |
568 | template
569 | int OptimalList::count() const
570 | {
571 | return mCount;
572 | }
573 |
574 | template
575 | bool OptimalList::isEmpty() const
576 | {
577 | return mCount==0;
578 | }
579 |
580 | template
581 | void OptimalList::move(int from, int to)
582 | {
583 | Q_ASSERT_X(from >= 0 && from < mCount && to >= 0 && to < mCount, "OptimalList::move", "index out of range");
584 |
585 | if (from == to)
586 | {
587 | return;
588 | }
589 |
590 |
591 | }
592 |
593 | template
594 | void OptimalList::swap(int i, int j)
595 | {
596 | Q_ASSERT_X(i >= 0 && i < mCount && j >= 0 && j < mCount, "OptimalList::swap", "index out of range");
597 |
598 | if (isLarge)
599 | {
600 | T *t = *reinterpret_cast(pointerAt(i));
601 | *reinterpret_cast(pointerAt(i)) = *reinterpret_cast(pointerAt(j));
602 | *reinterpret_cast(pointerAt(j)) = t;
603 | }
604 | else
605 | {
606 | T t=*reinterpret_cast(pointerAt(i));
607 | *reinterpret_cast(pointerAt(i)) = *reinterpret_cast(pointerAt(j));
608 | *reinterpret_cast(pointerAt(j)) = t;
609 | }
610 | }
611 |
612 | template
613 | void OptimalList::swap(OptimalList &other)
614 | {
615 | qSwap(mBuffer, other.mBuffer);
616 | qSwap(mBegin, other.mBegin);
617 | qSwap(mCount, other.mCount);
618 | qSwap(mCapacity, other.mCapacity);
619 | qSwap(mReserved, other.mReserved);
620 | }
621 |
622 | template
623 | int OptimalList::indexOf(const T &t, int from) const
624 | {
625 | if (from<0)
626 | {
627 | from+=mCount;
628 |
629 | if (from<0)
630 | {
631 | from=0;
632 | }
633 | }
634 |
635 | for (int i=from; i
647 | int OptimalList::lastIndexOf(const T &t, int from) const
648 | {
649 | if (from<0)
650 | {
651 | from+=mCount;
652 | }
653 | else
654 | if (from>=mCount)
655 | {
656 | from=mCount-1;
657 | }
658 |
659 | for (int i=from; i>=0; --i)
660 | {
661 | if (at(i)==t)
662 | {
663 | return i;
664 | }
665 | }
666 |
667 | return -1;
668 | }
669 |
670 | template
671 | bool OptimalList::contains(const T &t) const
672 | {
673 | return indexOf(t)>=0;
674 | }
675 |
676 | template
677 | bool OptimalList::startsWith(const T &t) const
678 | {
679 | return mCount>0 && at(0)==t;
680 | }
681 |
682 | template
683 | bool OptimalList::endsWith(const T &t) const
684 | {
685 | return mCount>0 && at(mCount-1)==t;
686 | }
687 |
688 | template
689 | int OptimalList::count(const T &t) const
690 | {
691 | int res=0;
692 |
693 | for (int i=0; i
705 | OptimalList OptimalList::mid(int pos, int length) const
706 | {
707 | if (length<0 || pos+length>mCount)
708 | {
709 | length=mCount-pos;
710 | }
711 |
712 | if (pos==0 && length==mCount)
713 | {
714 | return *this;
715 | }
716 |
717 | OptimalList list;
718 |
719 | list.mCount=length;
720 | list.setOptimalCapacity();
721 |
722 | if (isLarge)
723 | {
724 | if (isLarge)
725 | {
726 | for (int i=0; i(list.pointerAt(i))=new T(**reinterpret_cast(pointerAt(pos+i)));
729 | }
730 | }
731 | else
732 | {
733 | for (int i=0; i(list.pointerAt(i))=*reinterpret_cast(pointerAt(pos+i));
736 | }
737 | }
738 | }
739 |
740 | return list;
741 | }
742 |
743 | template
744 | OptimalList &OptimalList::operator=(OptimalList &l)
745 | {
746 | clear();
747 |
748 | mCount=l.mCount;
749 | setOptimalCapacity();
750 |
751 | if (isLarge)
752 | {
753 | for (int i=0; i(pointerAt(i))=new T(**reinterpret_cast(l.pointerAt(i)));
756 | }
757 | }
758 | else
759 | if (QTypeInfo::isComplex)
760 | {
761 | for (int i=0; i