'Add an empty book item to the library. This does not import any formats
from a book file.'

def add_empty(self, *args):

    author = series = title = None
    index = self.gui.library_view.currentIndex()
    if index.isValid():
        raw = index.model().db.authors(index.row())
        if raw:
            authors = [a.strip().replace('|', ',') for a in raw.split(',')]
            if authors:
                author = authors[0]
        series = index.model().db.series(index.row())
        title = index.model().db.title(index.row())
    dlg = AddEmptyBookDialog(self.gui, self.gui.library_view.model().db, author, series, dup_title=title)
    if (dlg.exec_() == dlg.Accepted):
        temp_files = []
        num = dlg.qty_to_add
        series = dlg.selected_series
        title = (dlg.selected_title or _('Unknown'))
        db = self.gui.library_view.model().db
        (ids, orig_fmts) = ([], [])
        if dlg.duplicate_current_book:
            origmi = db.get_metadata(index.row(), get_cover=True, cover_as_data=True)
            if dlg.copy_formats.isChecked():
                book_id = db.id(index.row())
                orig_fmts = tuple((db.new_api.format(book_id, fmt, as_path=True) for fmt in db.new_api.formats(book_id)))
        for x in xrange(num):
            if dlg.duplicate_current_book:
                mi = origmi
            else:
                mi = MetaInformation(title, dlg.selected_authors)
                if series:
                    mi.series = series
                    mi.series_index = db.get_next_series_num_for(series)
            fmts = []
            empty_format = gprefs.get('create_empty_format_file', '')
            if (dlg.duplicate_current_book and dlg.copy_formats.isChecked()):
                fmts = orig_fmts
            elif empty_format:
                from calibre.ebooks.oeb.polish.create import create_book
                pt = PersistentTemporaryFile(suffix=('.' + empty_format))
                pt.close()
                temp_files.append(pt.name)
                create_book(mi, pt.name, fmt=empty_format)
                fmts = [pt.name]
            ids.append(db.import_book(mi, fmts))
        tuple(map(os.remove, orig_fmts))
        self.refresh_gui(num)
        if ids:
            ids.reverse()
            self.gui.library_view.select_rows(ids)
        for path in temp_files:
            os.remove(path)
