changeset 278:9a13687c078b

* Add SingleColourLayer to manage colours for layers that have a single predominant colour (i.e. most of them).
author Chris Cannam
date Thu, 12 Jul 2007 16:14:59 +0000
parents 3b8008d09541
children 7802b0e2b0ff
files base/ColourDatabase.cpp base/ColourDatabase.h data/fileio/RemoteFile.cpp
diffstat 3 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/base/ColourDatabase.cpp	Wed Jul 11 17:21:37 2007 +0000
+++ b/base/ColourDatabase.cpp	Thu Jul 12 16:14:59 2007 +0000
@@ -16,6 +16,8 @@
 #include "ColourDatabase.h"
 #include "XmlExportable.h"
 
+#include <QPainter>
+
 ColourDatabase
 ColourDatabase::m_instance;
 
@@ -97,7 +99,10 @@
 ColourDatabase::setUseDarkBackground(int c, bool dark)
 {
     if (c < 0 || size_t(c) >= m_colours.size()) return;
-    m_colours[c].darkbg = dark;
+    if (m_colours[c].darkbg != dark) {
+        m_colours[c].darkbg = dark;
+        emit colourDatabaseChanged();
+    }
 }
 
 int
@@ -182,3 +187,20 @@
     }
 }
 
+QPixmap
+ColourDatabase::getExamplePixmap(int index, QSize size) const
+{
+    QPixmap pmap(size);
+    pmap.fill(useDarkBackground(index) ? Qt::black : Qt::white);
+    QPainter paint(&pmap);
+    QColor colour(getColour(index));
+    paint.setPen(colour);
+    paint.setBrush(colour);
+    int margin = 2;
+    if (size.width() < 4 || size.height() < 4) margin = 0;
+    else if (size.width() < 8 || size.height() < 8) margin = 1;
+    paint.drawRect(margin, margin,
+                   size.width() - margin*2 - 1, size.height() - margin*2 - 1);
+    return pmap;
+}
+
--- a/base/ColourDatabase.h	Wed Jul 11 17:21:37 2007 +0000
+++ b/base/ColourDatabase.h	Thu Jul 12 16:14:59 2007 +0000
@@ -19,6 +19,8 @@
 #include <QObject>
 #include <QString>
 #include <QColor>
+#include <QSize>
+#include <QPixmap>
 #include <vector>
 
 class ColourDatabase : public QObject
@@ -58,6 +60,8 @@
 
     // for use by PropertyContainer getPropertyRangeAndValue methods
     void getColourPropertyRange(int *min, int *max) const;
+
+    QPixmap getExamplePixmap(int index, QSize size) const;
     
 signals:
     void colourDatabaseChanged();
--- a/data/fileio/RemoteFile.cpp	Wed Jul 11 17:21:37 2007 +0000
+++ b/data/fileio/RemoteFile.cpp	Thu Jul 12 16:14:59 2007 +0000
@@ -64,7 +64,9 @@
                 this, SLOT(dataReadProgress(int, int)));
         connect(m_http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
                 this, SLOT(httpResponseHeaderReceived(const QHttpResponseHeader &)));
-        m_http->get(url.path(), m_localFile);
+        QString path = url.path();
+        std::cerr << "RemoteFile: path is \"" << path.toStdString() << "\"" << std::endl;
+        m_http->get(path, m_localFile);
 
     } else if (scheme == "ftp") {