LocationListEditor.cpp   LocationListEditor.cpp 
skipping to change at line 31 skipping to change at line 31
#include "LocationListEditor.hpp" #include "LocationListEditor.hpp"
#include "ui_LocationListEditor.h" #include "ui_LocationListEditor.h"
#include <QApplication> #include <QApplication>
#include <QCloseEvent> #include <QCloseEvent>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QFileDialog> #include <QFileDialog>
#include <QFileInfo> #include <QFileInfo>
#include <QInputDialog> #include <QInputDialog>
#include <QLabel>
#include <QMessageBox> #include <QMessageBox>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include "kfilterdev.h" // For compressing binary lists #include "kfilterdev.h" // For compressing binary lists
#include "LocationListModel.hpp" #include "LocationListModel.hpp"
LocationListEditor::LocationListEditor(QWidget *parent) : LocationListEditor::LocationListEditor(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::LocationListEditor), ui(new Ui::LocationListEditor),
filterIndicator(0),
locations(0), locations(0),
proxyModel(0) proxyModel(0),
selectionModel(0)
{ {
ui->setupUi(this); ui->setupUi(this);
setWindowIcon(QIcon(":/locationListEditor/icon.bmp")); setWindowIcon(QIcon(":/locationListEditor/icon.bmp"));
filterIndicator = new QLabel();
ui->statusBar->addPermanentWidget(filterIndicator);
connect(ui->actionOpenFile, SIGNAL(triggered()), connect(ui->actionOpenFile, SIGNAL(triggered()),
this, SLOT(open())); this, SLOT(open()));
connect(ui->actionOpenProject, SIGNAL(triggered()), connect(ui->actionOpenProject, SIGNAL(triggered()),
this, SLOT(openProjectLocations())); this, SLOT(openProjectLocations()));
connect(ui->actionOpenUser, SIGNAL(triggered()), connect(ui->actionOpenUser, SIGNAL(triggered()),
this, SLOT(openUserLocations())); this, SLOT(openUserLocations()));
connect(ui->actionSave, SIGNAL(triggered()), connect(ui->actionSave, SIGNAL(triggered()),
this, SLOT(save())); this, SLOT(save()));
connect(ui->actionSaveAs, SIGNAL(triggered()), connect(ui->actionSaveAs, SIGNAL(triggered()),
this, SLOT(saveAs())); this, SLOT(saveAs()));
skipping to change at line 68 skipping to change at line 74
connect(ui->actionInsertBefore, SIGNAL(triggered()), connect(ui->actionInsertBefore, SIGNAL(triggered()),
this, SLOT(insertBefore())); this, SLOT(insertBefore()));
connect(ui->actionInsertAfter, SIGNAL(triggered()), connect(ui->actionInsertAfter, SIGNAL(triggered()),
this, SLOT(insertAfter())); this, SLOT(insertAfter()));
connect(ui->actionCloneSelected, SIGNAL(triggered()), connect(ui->actionCloneSelected, SIGNAL(triggered()),
this, SLOT(cloneSelected())); this, SLOT(cloneSelected()));
connect(ui->actionDelete, SIGNAL(triggered()), connect(ui->actionDelete, SIGNAL(triggered()),
this, SLOT(deleteSelected())); this, SLOT(deleteSelected()));
connect(ui->actionGoToRow, SIGNAL(triggered()), connect(ui->actionGoToRow, SIGNAL(triggered()),
this, SLOT(goToRow())); this, SLOT(goToRow()));
connect(ui->actionSearchFilter, SIGNAL(triggered()),
ui->lineEditFilter, SLOT(setFocus()));
connect(ui->actionNextDuplicate, SIGNAL(triggered()), connect(ui->actionNextDuplicate, SIGNAL(triggered()),
this, SLOT(goToNextDuplicate())); this, SLOT(goToNextDuplicate()));
connect(ui->actionExit, SIGNAL(triggered()), connect(ui->actionExit, SIGNAL(triggered()),
this, SLOT(close())); this, SLOT(close()));
connect(ui->actionAbout, SIGNAL(triggered()), connect(ui->actionAbout, SIGNAL(triggered()),
this, SLOT(showAboutWindow())); this, SLOT(showAboutWindow()));
connect(ui->actionAboutQt, SIGNAL(triggered()),
qApp, SLOT(aboutQt()));
connect(ui->actionTest, SIGNAL(triggered()), connect(ui->actionTest, SIGNAL(triggered()),
this, SLOT(test())); this, SLOT(test()));
connect(ui->comboBoxFilteredColumn, SIGNAL(currentIndexChanged(int)) , connect(ui->comboBoxFilteredColumn, SIGNAL(currentIndexChanged(int)) ,
this, SLOT(setFilteredColumn(int))); this, SLOT(setFilteredColumn(int)));
// Base location list // Base location list
QFileInfo projectList(QDir::current(), "../../data/base_locations.tx t"); QFileInfo projectList(QDir::current(), "../../data/base_locations.tx t");
if (projectList.exists()) if (projectList.exists())
projectFilePath = projectList.absoluteFilePath(); projectFilePath = projectList.absoluteFilePath();
skipping to change at line 231 skipping to change at line 241
delete locations; delete locations;
} }
locations = newLocations; locations = newLocations;
connect(locations, SIGNAL(modified(bool)), connect(locations, SIGNAL(modified(bool)),
this, SLOT(setWindowModified(bool))); this, SLOT(setWindowModified(bool)));
if (proxyModel) if (proxyModel)
{ {
delete proxyModel; delete proxyModel;
} }
proxyModel = newProxy; proxyModel = newProxy;
connect(ui->lineEditFilter, SIGNAL(textEdited(QString)), connect(ui->lineEditFilter, SIGNAL(editingFinished()),
proxyModel, SLOT(setFilterWildcard(QString))); this, SLOT(filter()));
setFilterCaseSensitivity(false); setFilterCaseSensitivity(false);
connect(ui->checkBoxCaseSensitive, SIGNAL(toggled(bool)), connect(ui->checkBoxCaseSensitive, SIGNAL(toggled(bool)),
this, SLOT(setFilterCaseSensitivity(bool))); this, SLOT(setFilterCaseSensitivity(bool)));
updateFilterIndicator();
selectionModel = ui->tableView->selectionModel();
connect(selectionModel,
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this,
SLOT(updateSelectionCount()));
if (checkIfFileIsLoaded()) if (checkIfFileIsLoaded())
ui->statusBar->showMessage("Loaded " + path); ui->statusBar->showMessage("Loaded " + path);
if (!locations->loadingLog.isEmpty()) if (!locations->loadingLog.isEmpty())
{ {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setWindowTitle(qApp->applicationName()); msgBox.setWindowTitle(qApp->applicationName());
msgBox.setText(path + " was loaded succsessfully, but there were some errors."); msgBox.setText(path + " was loaded succsessfully, but there were some errors.");
msgBox.setInformativeText("Click \"Show details\" to see the log or \"Save\" to save it to file."); msgBox.setInformativeText("Click \"Show details\" to see the log or \"Save\" to save it to file.");
skipping to change at line 374 skipping to change at line 391
device->close(); device->close();
delete device; delete device;
file.close(); file.close();
return ok; return ok;
} }
QList<int> LocationListEditor::getIndexesOfSelection() QList<int> LocationListEditor::getIndexesOfSelection()
{ {
QList<int> rows; QList<int> rows;
QItemSelectionModel* selectionModel = ui->tableView->selectionModel(
);
if (!selectionModel->hasSelection()) if (!selectionModel->hasSelection())
return rows; return rows;
QModelIndexList list = selectionModel->selectedRows(); QModelIndexList list = selectionModel->selectedRows();
foreach (const QModelIndex& index, list) foreach (const QModelIndex& index, list)
rows.append(proxyModel->mapToSource(index).row()); rows.append(proxyModel->mapToSource(index).row());
qSort(rows); qSort(rows);
return rows; return rows;
} }
int LocationListEditor::getIndexOfCurrentRow() int LocationListEditor::getIndexOfCurrentRow()
{ {
QItemSelectionModel* selectionModel = ui->tableView->selectionModel( );
QModelIndex index = selectionModel->currentIndex(); QModelIndex index = selectionModel->currentIndex();
if (index.isValid()) if (index.isValid())
return index.row(); return index.row();
else else
return -1; return -1;
} }
void LocationListEditor::setCurrentlyEditedLocation(int row) void LocationListEditor::setCurrentlyEditedLocation(int row)
{ {
QModelIndex index = locations->index(row, 0); QModelIndex index = locations->index(row, 0);
skipping to change at line 420 skipping to change at line 434
void LocationListEditor::goToRow(int row) void LocationListEditor::goToRow(int row)
{ {
QModelIndex index = locations->index(row, 0); QModelIndex index = locations->index(row, 0);
if (!index.isValid()) if (!index.isValid())
return; return;
QModelIndex proxyIndex = proxyModel->mapFromSource(index); QModelIndex proxyIndex = proxyModel->mapFromSource(index);
ui->tableView->setCurrentIndex(proxyIndex); ui->tableView->setCurrentIndex(proxyIndex);
ui->tableView->scrollTo(proxyIndex, QTableView::PositionAtCenter); ui->tableView->scrollTo(proxyIndex, QTableView::PositionAtCenter);
} }
void LocationListEditor::updateFilterIndicator()
{
Q_ASSERT(proxyModel);
int originalCount = proxyModel->sourceModel()->rowCount();
int filteredCount = proxyModel->rowCount();
if (originalCount == filteredCount)
{
filterIndicator->setText(QString::number(originalCount));
}
else
{
QString s = QString("%1 / %2").arg(filteredCount).arg(origin
alCount);
filterIndicator->setText(s);
}
}
void LocationListEditor::open() void LocationListEditor::open()
{ {
if (checkIfFileIsSaved()) if (checkIfFileIsSaved())
{ {
QString filePath = QFileDialog::getOpenFileName(this, QString filePath = QFileDialog::getOpenFileName(this,
"Open file.. .", "Open file.. .",
QString(), QString(),
fileFilters) ; fileFilters) ;
if (!filePath.isEmpty()) if (!filePath.isEmpty())
loadFile(filePath); loadFile(filePath);
skipping to change at line 588 skipping to change at line 619
void LocationListEditor::setFilterCaseSensitivity(bool sensitive) void LocationListEditor::setFilterCaseSensitivity(bool sensitive)
{ {
if (proxyModel) if (proxyModel)
{ {
if (sensitive) if (sensitive)
proxyModel->setFilterCaseSensitivity(Qt::CaseSensiti ve); proxyModel->setFilterCaseSensitivity(Qt::CaseSensiti ve);
else else
proxyModel->setFilterCaseSensitivity(Qt::CaseInsensi tive); proxyModel->setFilterCaseSensitivity(Qt::CaseInsensi tive);
} }
} }
void LocationListEditor::filter()
{
Q_ASSERT(proxyModel);
proxyModel->setFilterWildcard(ui->lineEditFilter->text());
updateFilterIndicator();
}
void LocationListEditor::updateSelectionCount()
{
int rowCount = selectionModel->selectedRows().count();
if (rowCount < 1)
return;
if (rowCount > 1)
ui->statusBar->showMessage(QString("%1 items selected.").arg
(rowCount));
else
ui->statusBar->clearMessage();
}
 End of changes. 12 change blocks. 
7 lines changed or deleted 38 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/