summaryrefslogtreecommitdiffstats
blob: 191b239ee45cc4ec3b4575aa0153bede5c9e1cb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
 * Copyright (c) 2012 Maciej Niedzielski
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

#include <cassert>

#include <Swift/QtUI/QtHighlightEditorWidget.h>
#include <Swift/QtUI/QtHighlightRulesItemModel.h>

namespace Swift {

QtHighlightEditor::QtHighlightEditor(QtSettingsProvider* settings, QWidget* parent)
	: QWidget(parent), settings_(settings)
{
	ui_.setupUi(this);

	//itemModel_ = new QtHighlightRulesItemModel(this);
	//ui_.treeView->setModel(itemModel_);
	//ui_.ruleWidget->setModel(itemModel_);
//
	//for (int i = 0; i < QtHighlightRulesItemModel::NumberOfColumns; ++i) {
		//switch (i) {
			//case QtHighlightRulesItemModel::ApplyTo:
			//case QtHighlightRulesItemModel::Sender:
			//case QtHighlightRulesItemModel::Keyword:
			//case QtHighlightRulesItemModel::Action:
				//ui_.treeView->showColumn(i);
				//break;
			//default:
				//ui_.treeView->hideColumn(i);
				//break;
		//}
	//}
//
	//setHighlightManager(NULL); // setup buttons for empty rules list
//
	//connect(ui_.treeView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), SLOT(onCurrentRowChanged(QModelIndex)));
//
	//connect(ui_.newButton, SIGNAL(clicked()), SLOT(onNewButtonClicked()));
	//connect(ui_.deleteButton, SIGNAL(clicked()), SLOT(onDeleteButtonClicked()));
//
	//connect(ui_.moveUpButton, SIGNAL(clicked()), SLOT(onMoveUpButtonClicked()));
	//connect(ui_.moveDownButton, SIGNAL(clicked()), SLOT(onMoveDownButtonClicked()));
//
	//connect(ui_.closeButton, SIGNAL(clicked()), SLOT(close()));

	setWindowTitle(tr("Highlight Rules"));
}

QtHighlightEditor::~QtHighlightEditor()
{
}

void QtHighlightEditor::show()
{
	//if (itemModel_->rowCount(QModelIndex())) {
		//selectRow(0);
	//}
	QWidget::show();
	QWidget::activateWindow();
}

void QtHighlightEditor::setHighlightManager(HighlightManager* highlightManager)
{
	//itemModel_->setHighlightManager(highlightManager);
	//ui_.newButton->setEnabled(highlightManager != NULL);
//
	//ui_.ruleWidget->setEnabled(false);
	//ui_.deleteButton->setEnabled(false);
	//ui_.moveUpButton->setEnabled(false);
	//ui_.moveDownButton->setEnabled(false);
}

void QtHighlightEditor::closeEvent(QCloseEvent* event) {
	//ui_.ruleWidget->save();
	//event->accept();
}

void QtHighlightEditor::onNewButtonClicked()
{
	//int row = getSelectedRow() + 1;
	//itemModel_->insertRow(row, QModelIndex());
	//selectRow(row);
}

void QtHighlightEditor::onDeleteButtonClicked()
{
	//int row = getSelectedRow();
	//assert(row >= 0);
//
	//itemModel_->removeRow(row, QModelIndex());
	//if (row == itemModel_->rowCount(QModelIndex())) {
		//--row;
	//}
	//selectRow(row);
}

void QtHighlightEditor::onMoveUpButtonClicked()
{
	//int row = getSelectedRow();
	//assert(row > 0);
//
	//ui_.ruleWidget->save();
	//ui_.ruleWidget->setActiveIndex(QModelIndex());
	//itemModel_->swapRows(row, row - 1);
	//selectRow(row - 1);
}

void QtHighlightEditor::onMoveDownButtonClicked()
{
	//int row = getSelectedRow();
	//assert(row < itemModel_->rowCount(QModelIndex()) - 1);
//
	//ui_.ruleWidget->save();
	//ui_.ruleWidget->setActiveIndex(QModelIndex());
	//if (itemModel_->swapRows(row, row + 1)) {
		//selectRow(row + 1);
	//}
}

void QtHighlightEditor::onCurrentRowChanged(const QModelIndex& index)
{
	//ui_.ruleWidget->save();
	//ui_.ruleWidget->setActiveIndex(index);
//
	//ui_.ruleWidget->setEnabled(index.isValid());
//
	//ui_.deleteButton->setEnabled(index.isValid());
//
	//ui_.moveUpButton->setEnabled(index.isValid() && index.row() != 0);
	//ui_.moveDownButton->setEnabled(index.isValid() && index.row() != itemModel_->rowCount(QModelIndex()) - 1);
}

void QtHighlightEditor::selectRow(int row)
{
	//QModelIndex index = itemModel_->index(row, 0, QModelIndex());
	//ui_.treeView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
}

/** Return index of selected row or -1 if none is selected */
int QtHighlightEditor::getSelectedRow() const
{
	//QModelIndexList rows = ui_.treeView->selectionModel()->selectedRows();
	//return rows.isEmpty() ? -1 : rows[0].row();
	return 0;
}

}