aboutsummaryrefslogtreecommitdiff
path: root/notebookmodel.cc
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2020-04-12 00:45:32 +0200
committerJavier <dev.git@javispedro.com>2020-04-12 01:24:39 +0200
commit5cb277888995edecfafd83fed4cf2bd510052a4b (patch)
tree9c94054e59035eece0e34e8be10ee77769b1d9e4 /notebookmodel.cc
parent7f3d796c50b1855e690f74b35fd35798142ceb35 (diff)
downloadscribiu-5cb277888995edecfafd83fed4cf2bd510052a4b.tar.gz
scribiu-5cb277888995edecfafd83fed4cf2bd510052a4b.zip
port to qt5, libusb 1.0, and openobex 1.7
Diffstat (limited to 'notebookmodel.cc')
-rw-r--r--notebookmodel.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/notebookmodel.cc b/notebookmodel.cc
index e52d3f4..b9c897e 100644
--- a/notebookmodel.cc
+++ b/notebookmodel.cc
@@ -18,10 +18,10 @@
#include <QtCore/QDebug>
#include <QtCore/QSettings>
-#include <QtGui/QApplication>
#include <QtGui/QIcon>
#include <QtGui/QDesktopServices>
-#include <QtGui/QStyle>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QStyle>
#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 &notebook
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;