Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/qt
diff options
context:
space:
mode:
authorDarafei Praliaskouski <komzpa@gmail.com>2013-02-18 16:01:02 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:51:08 +0300
commitd454c374834a7091540dee308dc4294f85cf4f7e (patch)
tree3fa2822109648734e032545975441a4fdff7be67 /qt
parent36cb56960ae2860f858e7082bb9963979e4be909 (diff)
Removed visibility.txt
Diffstat (limited to 'qt')
-rw-r--r--qt/classificator_tree.cpp294
-rw-r--r--qt/classificator_tree.hpp83
-rw-r--r--qt/mainwindow.cpp17
-rw-r--r--qt/qt.pro4
-rw-r--r--qt/res/resources.qrc8
5 files changed, 2 insertions, 404 deletions
diff --git a/qt/classificator_tree.cpp b/qt/classificator_tree.cpp
deleted file mode 100644
index caac3ab274..0000000000
--- a/qt/classificator_tree.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-#include "../base/SRC_FIRST.hpp"
-#include "classificator_tree.hpp"
-
-#include "../indexer/classificator_loader.hpp"
-#include "../indexer/classificator.hpp"
-
-#include "../platform/platform.hpp"
-
-#include "../base/assert.hpp"
-
-#include "../std/bind.hpp"
-
-#include <QtGui/QTreeWidget>
-#include <QtGui/QHBoxLayout>
-#include <QtGui/QCheckBox>
-#include <QtGui/QPushButton>
-#include <QtGui/QToolBar>
-#include <QtGui/QFileDialog>
-
-
-namespace qt
-{
-
-typedef ClassifObject::visible_mask_t mask_t;
-
-///////////////////////////////////////////////////////////////////////////
-// QClassifTree implementation
-///////////////////////////////////////////////////////////////////////////
-
-class QClassifTree : public QTreeWidget
-{
- typedef QTreeWidget base_type;
-
- ClassifTreeHolder * get_parent()
- {
- return dynamic_cast<ClassifTreeHolder *>(parentWidget());
- }
-
-public:
- QClassifTree(ClassifTreeHolder * pParent) : base_type(pParent) {}
-
-protected:
- virtual void contextMenuEvent(QContextMenuEvent * /*e*/)
- {
- int const col = currentColumn();
- if (col == 1)
- get_parent()->EditItem(currentItem());
- }
-};
-
-///////////////////////////////////////////////////////////////////////////
-// QEditChecks implementation
-///////////////////////////////////////////////////////////////////////////
-
-QEditChecks::QEditChecks(QWidget * pParent)
-: base_type(pParent)
-{
- QVBoxLayout * pLayout = new QVBoxLayout(this);
-
- for (size_t i = 0; i < s_count; ++i)
- {
- m_arr[i] = new QCheckBox(QString::number(i), this);
- pLayout->addWidget(m_arr[i]);
- }
-
- QPushButton * p = new QPushButton(tr("OK"), this);
- connect(p, SIGNAL(pressed()), this, SLOT(OnOK()));
- pLayout->addWidget(p);
-
- setLayout(pLayout);
-}
-
-void QEditChecks::Show(ClassifObject * p, QPoint const & pt)
-{
- m_pObj = p;
- mask_t mask = p->GetVisibilityMask();
-
- for (size_t i = 0; i < s_count; ++i)
- m_arr[i]->setChecked(mask[i]);
-
- show();
- move(pt);
-}
-
-void QEditChecks::OnOK()
-{
- mask_t mask;
- for (size_t i = 0; i < s_count; ++i)
- mask[i] = m_arr[i]->isChecked();
-
- close();
-
- m_pObj->SetVisibilityMask(mask);
- emit applied();
-}
-
-///////////////////////////////////////////////////////////////////////////
-// QClassifTreeHolder implementation
-///////////////////////////////////////////////////////////////////////////
-
-ClassifTreeHolder::ClassifTreeHolder(QWidget * pParent,
- QWidget * drawWidget, char const * drawSlot)
-: base_type(pParent)
-{
- QVBoxLayout * pLayout = new QVBoxLayout(this);
- pLayout->setContentsMargins(0, 0, 0, 0);
-
- QToolBar * pToolBar = new QToolBar(this);
- pToolBar->setIconSize(QSize(32, 32));
- pToolBar->addAction(QIcon(":/classif32/save.png"), tr("Save visibility settings"), this, SLOT(OnSave()));
- pToolBar->addAction(QIcon(":/classif32/load.png"), tr("Load visibility settings"), this, SLOT(OnLoad()));
- pToolBar->addAction(QIcon(":/classif32/select.png"), tr("Select all checks"), this, SLOT(OnSelectAll()));
- pToolBar->addAction(QIcon(":/classif32/clear.png"), tr("Clear all checks"), this, SLOT(OnClearAll()));
-
- m_pTree = new QClassifTree(this);
- m_pEditor = new QEditChecks(this);
-
- connect(m_pEditor, SIGNAL(applied()), this, SLOT(OnEditFinished()));
- drawWidget->connect(m_pEditor, SIGNAL(applied()), drawWidget, drawSlot);
- drawWidget->connect(this, SIGNAL(redraw_model()), drawWidget, drawSlot);
-
- m_pTree->setColumnCount(2);
-
- QStringList headers;
- headers << tr("Type") << tr("Mask");
- m_pTree->setHeaderLabels(headers);
-
- pLayout->addWidget(pToolBar);
- pLayout->addWidget(m_pTree);
- setLayout(pLayout);
-}
-
-namespace
-{
- void to_item(QTreeWidgetItem * p, ClassifObject * pObj)
- {
- qulonglong ptr = reinterpret_cast<qulonglong>(pObj);
- return p->setData(1, Qt::UserRole, QVariant(ptr));
- }
-
- ClassifObject * from_item(QTreeWidgetItem * p)
- {
- bool isOK;
- qulonglong ptr = p->data(1, Qt::UserRole).toULongLong(&isOK);
- ASSERT ( isOK, () );
- return reinterpret_cast<ClassifObject *>(ptr);
- }
-}
-
-void ClassifTreeHolder::Process(QTreeWidgetItem * pParent, ClassifObject * p)
-{
- QTreeWidgetItem * pItem = 0;
-
- // do not add root item (leave more useful space)
- if (p != m_pRoot)
- {
- QStringList values;
- values << QString::fromStdString(p->GetName()) << GetMaskValue(p);
-
- if (pParent)
- pItem = new QTreeWidgetItem(pParent, values);
- else
- pItem = new QTreeWidgetItem(m_pTree, values);
-
- to_item(pItem, p);
- }
-
- p->ForEachObject(bind(&ClassifTreeHolder::Process, this, pItem, _1));
-}
-
-QString ClassifTreeHolder::GetMaskValue(ClassifObject const * p) const
-{
- mask_t mask = p->GetVisibilityMask();
- size_t const count = mask.size();
- string str;
- str.resize(count);
- for (size_t i = 0; i < mask.size(); ++i)
- str[i] = (mask[i] ? '1' : '0');
-
- return QString::fromStdString(str);
-}
-
-void ClassifTreeHolder::SetRoot(ClassifObject * pRoot)
-{
- m_pTree->clear();
-
- m_pRoot = pRoot;
- Process(0, m_pRoot);
- m_pTree->expandAll();
-}
-
-void ClassifTreeHolder::EditItem(QTreeWidgetItem * p)
-{
- m_pCurrent = p;
- ClassifObject * pObj = from_item(p);
-
- // find best position of edit-window newar the cursor
- QPoint pt = QCursor::pos();
- int const h = m_pEditor->frameSize().height();
- pt.ry() -= (h / 2);
-
- pt.ry() = max(0, pt.y());
- pt.ry() = min(mapToGlobal(rect().bottomRight()).y() - h, pt.y());
-
- // show window
- m_pEditor->Show(pObj, pt);
-}
-
-void ClassifTreeHolder::OnEditFinished()
-{
- m_pCurrent->setText(1, GetMaskValue(from_item(m_pCurrent)));
-}
-
-void ClassifTreeHolder::OnSave()
-{
- QString const fName = QFileDialog::getSaveFileName(this,
- tr("Save classificator visibility"),
- QString::fromStdString(GetPlatform().WritableDir()),
- tr("Text Files (*.txt)"));
-
- classif().PrintVisibility(fName.toAscii().constData());
-}
-
-void ClassifTreeHolder::OnLoad()
-{
- QString const fName = QFileDialog::getOpenFileName(this,
- tr("Open classificator visibility"),
- QString::fromStdString(GetPlatform().WritableDir()),
- tr("Text Files (*.txt)"));
-
- classificator::ReadVisibility(fName.toAscii().constData());
-
- Rebuild();
-}
-
-namespace
-{
- template <class ToDo> void ForEachRecursive(ClassifObject * p, ToDo & toDo)
- {
- toDo(p);
- p->ForEachObject(bind(&ForEachRecursive<ToDo>, _1, ref(toDo)));
- }
-
- class do_select
- {
- mask_t m_mask;
- public:
- do_select(mask_t mask) : m_mask(mask) {}
- void operator() (ClassifObject * p)
- {
- p->SetVisibilityMask(m_mask);
- }
- };
-}
-
-template <class TMask>
-void ClassifTreeHolder::OnSetMask(TMask mask)
-{
- do_select doSelect(mask);
- ForEachRecursive(GetRoot(), doSelect);
- Rebuild();
-}
-
-void ClassifTreeHolder::OnSelectAll()
-{
- mask_t mask;
- mask.set();
- OnSetMask(mask);
-}
-
-void ClassifTreeHolder::OnClearAll()
-{
- mask_t mask;
- mask.reset();
- OnSetMask(mask);
-}
-
-ClassifObject * ClassifTreeHolder::GetRoot()
-{
- return classif().GetMutableRoot();
-}
-
-void ClassifTreeHolder::Rebuild()
-{
- SetRoot(GetRoot());
- Redraw();
-}
-
-void ClassifTreeHolder::Redraw()
-{
- emit redraw_model();
-}
-
-}
diff --git a/qt/classificator_tree.hpp b/qt/classificator_tree.hpp
deleted file mode 100644
index 32cf70d158..0000000000
--- a/qt/classificator_tree.hpp
+++ /dev/null
@@ -1,83 +0,0 @@
-#pragma once
-
-#include <QtGui/QWidget>
-#include <QtGui/QDialog>
-
-class ClassifObject;
-
-class QTreeWidget;
-class QTreeWidgetItem;
-class QCheckBox;
-class QToolBar;
-
-namespace qt
-{
- class QClassifTree;
-
- class QEditChecks : public QDialog
- {
- typedef QDialog base_type;
-
- static const int s_count = 18;
- QCheckBox * m_arr[s_count];
-
- ClassifObject * m_pObj;
-
- Q_OBJECT
-
- public:
- QEditChecks(QWidget * pParent);
-
- void Show(ClassifObject * p, QPoint const & cursor);
-
- public Q_SLOTS:
- void OnOK();
-
- Q_SIGNALS:
- void applied();
- };
-
- class ClassifTreeHolder : public QWidget
- {
- typedef QWidget base_type;
-
- void Process(QTreeWidgetItem * pParent, ClassifObject * p);
-
- QString GetMaskValue(ClassifObject const * p) const;
-
- Q_OBJECT
-
- public:
- ClassifTreeHolder(QWidget * pParent,
- QWidget * drawWidget, char const * drawSlot);
-
- void SetRoot(ClassifObject * pRoot);
-
- void EditItem(QTreeWidgetItem * p);
-
- public Q_SLOTS:
- void OnEditFinished();
- void OnSave();
- void OnLoad();
- void OnSelectAll();
- void OnClearAll();
-
-Q_SIGNALS:
- void redraw_model();
-
- protected:
- ClassifObject * GetRoot();
- void Rebuild();
- void Redraw();
-
- private:
- template <class TMask> void OnSetMask(TMask mask);
-
- QClassifTree * m_pTree;
- QEditChecks * m_pEditor;
-
- ClassifObject * m_pRoot;
-
- QTreeWidgetItem * m_pCurrent;
- };
-}
diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp
index 9553a76855..0854cd5055 100644
--- a/qt/mainwindow.cpp
+++ b/qt/mainwindow.cpp
@@ -24,7 +24,6 @@
#ifndef NO_DOWNLOADER
#include "update_dialog.hpp"
-#include "classificator_tree.hpp"
#include "info_dialog.hpp"
#include "../indexer/classificator.hpp"
@@ -45,11 +44,6 @@ MainWindow::MainWindow()
CreateNavigationBar();
CreateSearchBarAndPanel();
-#ifndef NO_DOWNLOADER
- CreateClassifPanel();
-// CreateGuidePanel();
-#endif // NO_DOWNLOADER
-
setCentralWidget(m_pDrawWidget);
setWindowTitle(tr("MapsWithMe"));
@@ -381,17 +375,6 @@ void MainWindow::ShowGuidePanel()
m_Docks[1]->show();
}
-void MainWindow::CreateClassifPanel()
-{
- CreatePanelImpl(0, Qt::LeftDockWidgetArea, tr("Classificator Bar"),
- QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C), SLOT(ShowClassifPanel()));
-
- ClassifTreeHolder * pCTree = new ClassifTreeHolder(m_Docks[0], m_pDrawWidget, SLOT(Repaint()));
- pCTree->SetRoot(classif().GetMutableRoot());
-
- m_Docks[0]->setWidget(pCTree);
-}
-
//void MainWindow::CreateGuidePanel()
//{
// CreatePanelImpl(1, Qt::LeftDockWidgetArea, tr("Guide Bar"),
diff --git a/qt/qt.pro b/qt/qt.pro
index f29186afd5..212f9358ac 100644
--- a/qt/qt.pro
+++ b/qt/qt.pro
@@ -42,7 +42,7 @@ macx* {
../data/languages.txt ../data/categories.txt \
../data/packed_polygons.bin
CLASSIFICATOR_RES.path = Contents/Resources
- CLASSIFICATOR_RES.files = ../data/classificator.txt ../data/visibility.txt \
+ CLASSIFICATOR_RES.files = ../data/classificator.txt \
../data/types.txt
CONFIG(production) {
CLASSIFICATOR_RES.files += ../data/drules_proto.bin
@@ -96,10 +96,8 @@ RESOURCES += res/resources.qrc
SOURCES += \
update_dialog.cpp \
- classificator_tree.cpp \
HEADERS += \
update_dialog.hpp \
- classificator_tree.hpp \
}
diff --git a/qt/res/resources.qrc b/qt/res/resources.qrc
index 4d87d25bb9..a7451afabd 100644
--- a/qt/res/resources.qrc
+++ b/qt/res/resources.qrc
@@ -1,10 +1,4 @@
<RCC>
- <qresource prefix="/classif32">
- <file>save.png</file>
- <file>load.png</file>
- <file>select.png</file>
- <file>clear.png</file>
- </qresource>
<qresource prefix="/navig64">
<file>search.png</file>
<file>up.png</file>
@@ -23,4 +17,4 @@
<file>busy.png</file>
<file>x.png</file>
</qresource>
-</RCC> \ No newline at end of file
+</RCC>