blob: 750fd92205559922c2230415e2490e2420716575 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/***************************************************************************
copyright : (C) 2003-2007 by Robby Stephenson
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of version 2 of the GNU General Public License as *
* published by the Free Software Foundation; *
* *
***************************************************************************/
#include "entryitem.h"
#include "entry.h"
#include "gui/counteditem.h"
#include "collection.h"
#include "controller.h"
#include <kiconloader.h>
using Tellico::EntryItem;
EntryItem::EntryItem(GUI::ListView* parent, Data::EntryPtr entry)
: GUI::ListViewItem(parent), m_entry(entry), m_isDetailedList(true) {
}
EntryItem::EntryItem(GUI::CountedItem* parent_, Data::EntryPtr entry_)
: GUI::ListViewItem(parent_), m_entry(entry_), m_isDetailedList(false) {
setText(0, m_entry->title());
setPixmap(0, UserIcon(entry_->collection()->typeName()));
}
Tellico::Data::EntryPtr const EntryItem::entry() const {
return m_entry;
}
TQString EntryItem::key(int col_, bool) const {
// first column is always title unless it's a detailed list
// detailed list takes care of things on its own
bool checkArticles = (!m_isDetailedList && col_ == 0);
// there's some sort of painting bug if the key is identical for multiple entries
// probably a null string in the group view. TODO
// don't add the entry id if it's a detailed view cause that messes up secondary sorting
TQString key = (checkArticles ? Data::Field::sortKeyTitle(text(col_)) : text(col_));
return (m_isDetailedList ? key : key + TQString::number(m_entry->id()));
}
void EntryItem::doubleClicked() {
Controller::self()->editEntry(m_entry);
}
Tellico::Data::EntryVec EntryItem::entries() const {
return Data::EntryVec(entry());
}
|