diff options
Diffstat (limited to 'notebookmodel.cc')
-rw-r--r-- | notebookmodel.cc | 15 |
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 ¬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; |