+/*
+ * This file is part of NeighborNote
+ * Copyright 2013 Yuki Takahashi
+ *
+ * This file may be licensed under the terms of of the
+ * GNU General Public License Version 2 (the ``GPL'').
+ *
+ * Software distributed under the License is distributed
+ * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the GPL for the specific language
+ * governing rights and limitations.
+ *
+ * You should have received a copy of the GPL along with this
+ * program. If not, go to http://www.gnu.org/licenses/gpl.html
+ * or write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+*/
+
// ICHANGED
package cx.fbn.nevernote.gui;
import com.trolltech.qt.gui.QPaintEvent;
import com.trolltech.qt.gui.QPainter;
import com.trolltech.qt.gui.QPalette;
+import com.trolltech.qt.gui.QPen;
import com.trolltech.qt.gui.QTextOption;
import com.trolltech.qt.gui.QWidget;
private final int relationPoints;
private final String noteCreated;
private final String tagNames;
- private String noteContent;
+ private final String noteContent;
private final RensoNoteList parent;
private final boolean isStared;
private final int allPointSum;
+ private final QPalette palette;
private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");
this.tagNames = new String(sb);
// this.noteContent = new String(note.getContent());
- this.noteContent = conn.getNoteTable().getNoteContentNoUTFConversion(note.getGuid());
- this.noteContent = this.noteContent.replaceAll("<.+?>", "");
- this.noteContent = this.noteContent.replaceAll("\\s{2,}", " ");
- String kaigyo = System.getProperty("line.separator");
- this.noteContent = this.noteContent.replaceAll(kaigyo, "");
-
- QPalette p = new QPalette();
- p.setColor(QPalette.ColorRole.Window, new QColor(255, 255, 255));
- this.setPalette(p);
+// this.noteContent = Global.extractPlainText(conn.getNoteTable().getNoteContentNoUTFConversion(note.getGuid()));
+ this.noteContent = conn.getNoteTable().getNoteContentText(note.getGuid());
+ palette = new QPalette();
+ palette.setColor(QPalette.ColorRole.Window, new QColor(255, 255, 255));
+ this.setPalette(palette);
this.setAutoFillBackground(true);
this.setBackgroundRole(QPalette.ColorRole.Window);
}
// 項目の中身
// フォント設定
QFont relationFont = new QFont();
- relationFont.setPixelSize(35);
+ relationFont.setPixelSize(25);
relationFont.setBold(true);
QFont titleFont = new QFont();
titleFont.setPixelSize(15);
QFont normalFont = new QFont();
normalFont.setPixelSize(12);
- // 関連度
- double ratio = (double)relationPoints / allPointSum;
- int green = (int) (255 * (1.0 - ratio));
- painter.setPen(new QColor(255, green, 0, 120));
- painter.setFont(relationFont);
- painter.drawText(85, size().height() - 40, size().width() - 85, 40, Qt.AlignmentFlag.AlignRight.value(), String.valueOf((int)(ratio * 100)) + "%");
// タイトル
painter.setPen(QColor.black);
painter.setFont(titleFont);
painter.setPen(QColor.black);
painter.drawText(165, 23, size().width() - 165, 17, Qt.AlignmentFlag.AlignLeft.value(), tagNames);
// ノート内容
+ QPen tmpPen = painter.pen();
+ painter.setPen(new QColor(100, 100, 100));
QTextOption option = new QTextOption();
option.setAlignment(Qt.AlignmentFlag.AlignLeft);
option.setUseDesignMetrics(true);
- painter.drawText(new QRectF(85, 40, width() - 85, 40), noteContent, option);
+ painter.drawText(new QRectF(85, 40, width() - 85, 45), noteContent, option);
+ painter.setPen(tmpPen);
+ // 関連度
+ double ratio = (double)relationPoints / allPointSum;
+ QColor relationColor;
+ if (ratio >= 0.5) {
+ relationColor = new QColor(255, 0, 0);
+ } else if (ratio >= 0.25) {
+ relationColor = new QColor(255, 100, 0);
+ } else {
+ relationColor = new QColor(255, 200, 0);
+ }
+ painter.setFont(relationFont);
+ tmpPen = painter.pen();
+ painter.setPen(this.palette().color(QPalette.ColorRole.Window));
+ painter.drawText(size().width() - 70, size().height() - 33, 67, 33, Qt.AlignmentFlag.AlignRight.value(), String.valueOf((int)(ratio * 100)) + "%");
+ painter.drawText(size().width() - 70, size().height() - 33, 73, 33, Qt.AlignmentFlag.AlignRight.value(), String.valueOf((int)(ratio * 100)) + "%");
+ painter.drawText(70, size().height() - 36, size().width() - 70, 36, Qt.AlignmentFlag.AlignRight.value(), String.valueOf((int)(ratio * 100)) + "%");
+ painter.drawText(70, size().height() - 30, size().width() - 70, 30, Qt.AlignmentFlag.AlignRight.value(), String.valueOf((int)(ratio * 100)) + "%");
+ painter.setPen(relationColor);
+ painter.drawText(70, size().height() - 33, size().width() - 70, 33, Qt.AlignmentFlag.AlignRight.value(), String.valueOf((int)(ratio * 100)) + "%");
+ painter.setPen(tmpPen);
// サムネイル
QImage img;
String thumbnailName = Global.getFileManager().getResDirPath("thumbnail-" + noteGuid + ".png");
@Override
protected void enterEvent(QEvent e){
if (!parent.isContextMenuVisible()) {
- QPalette p = new QPalette();
- p.setColor(QPalette.ColorRole.Window, new QColor(225, 235, 255));
- this.setPalette(p);
+ palette.setColor(QPalette.ColorRole.Window, new QColor(225, 235, 255));
+ this.setPalette(palette);
}
}
@Override
protected void mousePressEvent(QMouseEvent e) {
- QPalette p = new QPalette();
- p.setColor(QPalette.ColorRole.Window, new QColor(165, 175, 255));
- this.setPalette(p);
+
+ palette.setColor(QPalette.ColorRole.Window, new QColor(165, 175, 255));
+ this.setPalette(palette);
super.mousePressEvent(e);
}
public void setDefaultBackground() {
- QPalette p = new QPalette();
- p.setColor(QPalette.ColorRole.Window, new QColor(255, 255, 255));
- this.setPalette(p);
+ palette.setColor(QPalette.ColorRole.Window, new QColor(255, 255, 255));
+ this.setPalette(palette);
}
}