From 5cb277888995edecfafd83fed4cf2bd510052a4b Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 12 Apr 2020 00:45:32 +0200 Subject: port to qt5, libusb 1.0, and openobex 1.7 --- notebookmodel.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'notebookmodel.cc') diff --git a/notebookmodel.cc b/notebookmodel.cc index e52d3f4..b9c897e 100644 --- a/notebookmodel.cc +++ b/notebookmodel.cc @@ -18,10 +18,10 @@ #include #include -#include #include #include -#include +#include +#include #include "paperreplay.h" #include "afdnotebook.h" #include "notebookmodel.h" @@ -46,7 +46,7 @@ NotebookModel::NotebookModel(QObject *parent) : QString NotebookModel::defaultDataDirectory() { - QString path = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); if (path.isEmpty()) { path = QDir::home().absoluteFilePath(".scribiu"); } @@ -150,6 +150,7 @@ QVariant NotebookModel::data(const QModelIndex &index, int role) const } break; } + break; case Qt::TextAlignmentRole: switch (index.column()) { case 0: @@ -158,6 +159,7 @@ QVariant NotebookModel::data(const QModelIndex &index, int role) const case 2: return Qt::AlignCenter; } + break; } } return QVariant(); @@ -239,9 +241,10 @@ void NotebookModel::refresh() { QStringList pens = _dataDir.entryList(QStringList("*.pen"), QDir::Dirs, QDir::Name); for (int i = 0; i < pens.size(); i++) { - pens[i].chop(4); + pens[i].chop(4); // Remove .pen extension } + // Insert/remove new/deleted pens int i = 0, j = 0; while (i < _pens.size() && j < pens.size()) { int comp = QString::compare(_pens[i], pens[j], Qt::CaseInsensitive); @@ -336,7 +339,7 @@ void NotebookModel::refreshPen(const QString &name) int NotebookModel::indexOfPen(const QString &name) { - QStringList::const_iterator it = qBinaryFind(_pens, name); + auto it = std::lower_bound(_pens.begin(), _pens.end(), name); if (it == _pens.end()) { return -1; } else { @@ -361,7 +364,7 @@ QIcon NotebookModel::getNotebookIcon(const QString &pen, const QString ¬ebook candidates << "userdata/icon/Notebook.png" << "userdata/icon/active_64x64.png" << "userdata/icon/active_32x32.png" - << "userdata/icon/active_16x16.png"; + << "userdata/icon/active_16x16.png"; } QIcon icon; -- cgit v1.2.3